feat: add comprehensive end-to-end test suite
This commit is contained in:
committed by
Loic Coenen (aider)
parent
af7588b832
commit
18eb27e9c8
71
e2e/test_rapid_key_mash.ts
Normal file
71
e2e/test_rapid_key_mash.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { setupTest, startEngine, startClientInTmux, openCmdFifo, writeFifoCommand, wait, tmuxSendKeys, tmuxCapturePane, teardownTest } from './test_utils';
|
||||
|
||||
export async function testRapidKeyMashConsistency(): Promise<void> {
|
||||
console.log("\nTest: RAPID KEY MASH CONSISTENCY (burst of 10 keys, verify pane)");
|
||||
setupTest();
|
||||
const engine = await startEngine();
|
||||
await startClientInTmux();
|
||||
openCmdFifo();
|
||||
await wait(500);
|
||||
|
||||
// Add channels up to column 5
|
||||
for (let i = 1; i <= 5; i++) {
|
||||
writeFifoCommand("add");
|
||||
await wait(100);
|
||||
}
|
||||
|
||||
const ITERATIONS = 20;
|
||||
for (let iter = 0; iter < ITERATIONS; iter++) {
|
||||
const seed = iter * 7;
|
||||
let keys = "";
|
||||
for (let k = 0; k < 10; k++) {
|
||||
const dir = (seed + k) % 4;
|
||||
switch (dir) {
|
||||
case 0: keys += "l"; break;
|
||||
case 1: keys += "h"; break;
|
||||
case 2: keys += "j"; break;
|
||||
case 3: keys += "k"; break;
|
||||
}
|
||||
}
|
||||
keys += "t"; // record
|
||||
tmuxSendKeys("looper", "0", keys);
|
||||
await wait(500);
|
||||
|
||||
// Capture pane
|
||||
const pane = tmuxCapturePane("looper", "0");
|
||||
|
||||
// 1. Selected line must be present
|
||||
const selMatch = pane.match(/Selected: Grid \d+, Row (\d+), Col (\d+)/);
|
||||
if (!selMatch) {
|
||||
console.log(` FAIL at iteration ${iter}: No selected line in pane`);
|
||||
console.log(" Pane:\n" + pane.slice(0, 500));
|
||||
engine.kill(); teardownTest();
|
||||
throw new Error("Selected line missing after burst");
|
||||
}
|
||||
|
||||
const row = parseInt(selMatch[1]);
|
||||
const col = parseInt(selMatch[2]);
|
||||
if (row < 0 || row > 7 || col < 0 || col > 7) {
|
||||
console.log(` FAIL at iteration ${iter}: selected (${row},${col}) out of bounds`);
|
||||
engine.kill(); teardownTest();
|
||||
throw new Error("Selected cell out of bounds after burst");
|
||||
}
|
||||
|
||||
// 2. At least one 'R' must appear in the pane
|
||||
const hasR = pane.includes("R");
|
||||
if (!hasR) {
|
||||
console.log(` FAIL at iteration ${iter}: No 'R' found after burst`);
|
||||
console.log(" Pane:\n" + pane.slice(0, 1000));
|
||||
engine.kill(); teardownTest();
|
||||
throw new Error("No 'R' indicator after rapid key mash");
|
||||
}
|
||||
|
||||
// 3. Toggle back to idle for next iteration
|
||||
tmuxSendKeys("looper", "0", "t");
|
||||
await wait(300);
|
||||
}
|
||||
|
||||
console.log(" PASS: Rapid key mash consistency maintained over " + ITERATIONS + " iterations");
|
||||
engine.kill();
|
||||
teardownTest();
|
||||
}
|
||||
Reference in New Issue
Block a user