50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { setupTest, startEngine, startClientInTmux, tmuxSendKeys, wait, tmuxCapturePane, waitForPaneText, teardownTest } from './test_utils';
|
|
|
|
export async function testGridNavigation(): Promise<void> {
|
|
console.log("\nTest: GRID NAVIGATION");
|
|
setupTest();
|
|
const engine = await startEngine();
|
|
await startClientInTmux();
|
|
|
|
// Default location should be Row 0, Col 0
|
|
let pane = await waitForPaneText("Selected: Grid 0, Row 0, Col 0", 5000);
|
|
if (pane.includes("Selected: Grid 0, Row 0, Col 0")) {
|
|
console.log(" PASS: Default selection at origin");
|
|
} else {
|
|
console.log(" FAIL: Expected 'Selected: Grid 0, Row 0, Col 0'");
|
|
console.log(" Actual pane content:\n" + pane);
|
|
engine.kill(); teardownTest();
|
|
throw new Error("Grid navigation test failed");
|
|
}
|
|
|
|
// Move right then down
|
|
tmuxSendKeys("looper", "0", "l");
|
|
tmuxSendKeys("looper", "0", "j");
|
|
await wait(200);
|
|
pane = tmuxCapturePane("looper", "0");
|
|
if (pane.includes("Selected: Grid 0, Row 1, Col 1")) {
|
|
console.log(" PASS: Moved to Row 1, Col 1");
|
|
} else {
|
|
console.log(" FAIL: Expected 'Row 1, Col 1'");
|
|
engine.kill(); teardownTest();
|
|
throw new Error("Grid navigation test failed");
|
|
}
|
|
|
|
// Cycle back to origin
|
|
tmuxSendKeys("looper", "0", "h");
|
|
await wait(400);
|
|
tmuxSendKeys("looper", "0", "k");
|
|
await wait(400);
|
|
pane = tmuxCapturePane("looper", "0");
|
|
if (pane.includes("Selected: Grid 0, Row 0, Col 0")) {
|
|
console.log(" PASS: Returned to origin");
|
|
} else {
|
|
console.log(" FAIL: Not at origin after h/k");
|
|
engine.kill(); teardownTest();
|
|
throw new Error("Grid navigation test failed");
|
|
}
|
|
|
|
engine.kill();
|
|
teardownTest();
|
|
}
|