feat: add comprehensive end-to-end test suite

This commit is contained in:
Loic Coenen
2026-06-06 17:46:52 +00:00
committed by Loic Coenen (aider)
parent af7588b832
commit 18eb27e9c8
20 changed files with 1261 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
import { setupTest, startEngine, startClientInTmux, openCmdFifo, writeFifoCommand, wait, tmuxSendKeys, tmuxCapturePane, ensureGenTone, teardownTest } from './test_utils';
export async function testRecordOnSelectedCell(): Promise<void> {
console.log("\nTest: RECORD ON SELECTED CELL (col 1, row 0)");
setupTest();
const engine = await startEngine();
await startClientInTmux();
openCmdFifo();
ensureGenTone();
await wait(500);
// Add a new channel so column 1 (channel 1) exists
writeFifoCommand("add");
await wait(500);
// Navigation: move right once to column 1 (channel 1)
tmuxSendKeys("looper", "0", "l"); // right once → col 1
await wait(500);
// Verify selection shows column 1
let pane = tmuxCapturePane("looper", "0");
if (!pane.includes("Selected: Grid 0, Row 0, Col 1")) {
console.log(" FAIL: Could not navigate to Col 1");
engine.kill(); teardownTest();
throw new Error("Navigation to column 1 failed");
}
console.log(" PASS: Successfully navigated to Col 1");
// Press 't' to start recording no extra key, TUI should redraw on its own
tmuxSendKeys("looper", "0", "t");
await wait(1500);
// Capture the pane once this is the TUI's state
const paneAfter = tmuxCapturePane("looper", "0");
// 1. The grid should show 'R' near cell 1 (col 1, row 0)
const paneLines = paneAfter.split("\n");
let cell1Line = -1, recordLine = -1;
for (let i = 0; i < paneLines.length; i++) {
if (paneLines[i].includes(" 1")) cell1Line = i;
if (paneLines[i].includes("R")) recordLine = i;
}
if (cell1Line === -1 || recordLine === -1 || Math.abs(recordLine - cell1Line) > 2) {
console.log(" FAIL: Grid did not show 'R' near cell 1");
console.log(" Pane excerpt:\n" + paneAfter.slice(0, 1000));
engine.kill(); teardownTest();
throw new Error("Grid indicator not updated for selected cell");
}
console.log(" PASS: Grid shows 'R' indicator near cell 1 after single 't'");
// 2. Verify that cell (row 0, col 0) does NOT show 'R' via pane char position
// Cell (0,0) has its state character at line 5, column 4 (based on grid layout)
const cell00StateCh = (paneLines.length > 5 && paneLines[5].length > 4) ? paneLines[5][4] : '?';
if (cell00StateCh === 'R') {
console.log(" FAIL: Cell (0,0) shows 'R' (crosstalk)");
engine.kill(); teardownTest();
throw new Error("Crosstalk detected on cell 0");
}
console.log(" PASS: Cell (0,0) does not show 'R' (no crosstalk)");
engine.kill();
teardownTest();
}