52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { setupTest, startEngine, startClientInTmux, openCmdFifo, writeFifoCommand, wait, readStatusNonBlock, teardownTest } from './test_utils';
|
||
|
||
export async function testToggleRecordStop(): Promise<void> {
|
||
console.log("\nTest: TOGGLE RECORD / STOP");
|
||
setupTest();
|
||
const engine = await startEngine();
|
||
await startClientInTmux();
|
||
openCmdFifo();
|
||
await wait(500);
|
||
|
||
// Send 'record 0' via FIFO to start recording
|
||
writeFifoCommand("record 0");
|
||
await wait(1500);
|
||
|
||
// Read status non‑blocking and look for RECORD
|
||
const stAfterRecord = readStatusNonBlock();
|
||
if (stAfterRecord.includes("RECORD")) {
|
||
console.log(" PASS: Status shows RECORD");
|
||
} else {
|
||
// Wait a bit more and retry once
|
||
await wait(500);
|
||
const st2 = readStatusNonBlock();
|
||
if (st2.includes("RECORD")) {
|
||
console.log(" PASS: Status shows RECORD (after delay)");
|
||
} else {
|
||
console.log(" STATUS data: " + st2);
|
||
console.log(" WARN: Did not see RECORD in status");
|
||
}
|
||
}
|
||
|
||
// Stop
|
||
writeFifoCommand("stop");
|
||
await wait(1500);
|
||
|
||
const stAfterStop = readStatusNonBlock();
|
||
if (stAfterStop.includes("IDLE")) {
|
||
console.log(" PASS: Status shows IDLE after stop");
|
||
} else {
|
||
await wait(500);
|
||
const st3 = readStatusNonBlock();
|
||
if (st3.includes("IDLE")) {
|
||
console.log(" PASS: Status shows IDLE after stop (after delay)");
|
||
} else {
|
||
console.log(" WARN: Did not see IDLE in status");
|
||
console.log(" STATUS data: " + st3);
|
||
}
|
||
}
|
||
|
||
engine.kill();
|
||
teardownTest();
|
||
}
|