import { setupTest, startEngine, startClientInTmux, openCmdFifo, writeFifoCommand, wait, readStatusNonBlock, teardownTest } from './test_utils'; export async function testChannelAddRemove(): Promise { console.log("\nTest: CHANNEL ADD / REMOVE"); setupTest(); const engine = await startEngine(); await startClientInTmux(); openCmdFifo(); await wait(500); // Send "add" command via FIFO writeFifoCommand("add"); await wait(1000); // Read status lines and look for CH=1 (channel 1 active) const st = readStatusNonBlock(); // Count channels by counting lines starting with "CH=" let channelCount = 0; for (const line of st.split("\n")) { if (line.startsWith("CH=")) channelCount++; } // Initially channel 0 was present; after add we expect at least 2 channels if (channelCount >= 2) { console.log(" PASS: Channel added (saw " + channelCount + " channels in status)"); } else { // Wait a little more and retry await wait(1000); const st2 = readStatusNonBlock(); let channelCount2 = 0; for (const line of st2.split("\n")) { if (line.startsWith("CH=")) channelCount2++; } if (channelCount2 >= 2) { console.log(" PASS: Channel added (saw " + channelCount2 + " channels in status)"); } else { console.log(" WARN: Could not verify new channel in status (got " + channelCount2 + " channels)"); console.log(" Status data: " + st2); } } engine.kill(); teardownTest(); }