// Shared helpers for the fake-terminal E2E tests. // // Desktop interaction model (see src/script.js + src/terminal.js): // the hero section overlays the rack background, so the terminal is opened // by clicking the hero (outside of any .btn). That focuses the hidden // inside .terminal-display, and all keystrokes go there. /** Click the hero to expand the terminal and focus its hidden input. */ async function openTerminal(page) { await page.locator('#hero h1').click(); await page.waitForSelector('.terminal-display.grown', { timeout: 5000 }); } /** Type a command into the focused terminal and press Enter. */ async function typeCommand(page, cmd) { await page.keyboard.type(cmd); await page.keyboard.press('Enter'); } /** The current (last) line of the terminal output. */ function currentPromptLine(page) { return page.locator('.terminal-content > div').last(); } /** All rendered terminal lines. */ function terminalLines(page) { return page.locator('.terminal-content > div'); } module.exports = { openTerminal, typeCommand, currentPromptLine, terminalLines };