// Keys the page ADVERTISES, executed. Two properties: a key this client cannot // compose declines out loud (improvise-rmvx), and the one text-entry room the // browser could enter but never showed you typing in (improvise-fdt6). import { test, expect } from "@playwright/test"; /// The shipped demo, focused, with a grid on screen. `#grid` must have focus /// or the page's keydown listener never sees a key and every assertion below /// would pass or fail for a reason that has nothing to do with resolution. async function theDemo(page) { await page.goto("/app/index.html"); await expect(page.locator("#grid table")).toBeVisible({ timeout: 20_000 }); await page.locator("#grid").focus(); await expect(page.locator("#grid td.editable").first()).toBeVisible(); } test.describe("an advertised key is never silent", () => { // Each of these is named in the mode's own hint line, so silence read as // broken rather than as unavailable (gotcha 47). The subjects must differ: // one message reached by three keys would tell the user nothing. test("the three Normal-mode keys this client cannot compose each say their own subject", async ({ page, }) => { await theDemo(page); for (const [key, said] of [ ["P", "hiding empty rows and columns is not available in the browser yet"], ["R", "records mode is not available in the browser yet"], [":", "the command line is not available in the browser yet"], ]) { // A stale status would let the NEXT key pass on the previous key's // message, so each assertion is preceded by a state it is not. await expect(page.locator("#status")).not.toContainText(said); await page.keyboard.press(key); await expect(page.locator("#status")).toContainText(said); // A refusal that changed the mode would be a door opened anyway. await expect(page.locator("#mode")).toHaveText("NORMAL"); } }); }); test.describe("a formula can be composed in the browser", () => { // improvise-fdt6. `commit-buffer formula` resolved here already; what did // not exist was any way to SEE the typing, so the room swallowed it. test("the formula minibuffer shows what is typed and the commit reaches the panel", async ({ page, }) => { await theDemo(page); await expect(page.locator("#minibuffer")).toBeHidden(); await page.keyboard.press("F"); await expect(page.locator("#mode")).toHaveText("FORMULAS"); await page.keyboard.press("n"); await expect(page.locator("#mode")).toHaveText("FORMULA"); // The property: every character is visible while it is being typed. await expect(page.locator("#minibuffer")).toBeVisible(); await page.keyboard.type("Margin = Profit"); await expect(page.locator("#minibuffer")).toContainText("Margin = Profit"); await page.keyboard.press("Enter"); await expect(page.locator("#minibuffer")).toBeHidden(); // And it reached the DOCUMENT, not just the buffer: the panel is a // projection the host sends back. await expect(page.locator("#formulas")).toContainText("Margin = Profit"); }); });