|
| 1 | +/** |
| 2 | + * ACTIONS 010-014/153 — the five `previewFocus`-gated preview keybindings. |
| 3 | + * |
| 4 | + * preview.refresh mod+r |
| 5 | + * preview.focusUrl mod+l |
| 6 | + * preview.zoomIn mod+= / mod++ |
| 7 | + * preview.zoomOut mod+- |
| 8 | + * preview.resetZoom mod+0 |
| 9 | + * |
| 10 | + * ALL FIVE ARE **BLOCKED**, NOT FAILING, AND NOT NO-OPS. The distinction is the |
| 11 | + * whole point of this file, so it is asserted rather than asserted-around. |
| 12 | + * |
| 13 | + * All five are advertised by the backend with `when: previewFocus` |
| 14 | + * (backend/src/keybindings.rs:97-102). `previewFocus` can only become true once |
| 15 | + * a preview pane exists. A preview pane can only exist if the server implements |
| 16 | + * the preview surface. It does not: |
| 17 | + * |
| 18 | + * packages/contracts/src/rpc.ts:271-280 declares TEN preview methods |
| 19 | + * preview.open / navigate / resize / refresh / close / list / reportStatus |
| 20 | + * previewAutomation.connect / respond / focusHost |
| 21 | + * |
| 22 | + * backend/src/server_main.rs implements ZERO of them |
| 23 | + * $ grep -rn "preview" backend/src/ |
| 24 | + * server_main.rs:2670 (a comment) |
| 25 | + * server_main.rs:3812 (a comment) |
| 26 | + * server_main.rs:3979 review::diff_preview <- the DIFF preview, unrelated |
| 27 | + * text.rs:11 (a comment) |
| 28 | + * keybindings.rs:96 push("mod+shift+j", "preview.toggle", None) |
| 29 | + * |
| 30 | + * So the server hands the client keybindings for a command surface it has not |
| 31 | + * implemented. `preview.toggle` is worse than the five here: it carries NO |
| 32 | + * `when` guard at all, so it is reachable, and pressing mod+shift+j does |
| 33 | + * nothing, forever, with no error. |
| 34 | + * |
| 35 | + * These specs are written to GO GREEN THE DAY PREVIEW LANDS. They are not |
| 36 | + * stubbed, not `.skip`-ed, and must not be deleted: `test.fixme` marks a known |
| 37 | + * missing capability and is reported by the runner as such, which is exactly the |
| 38 | + * BLOCKED row this task asks for — a `skip` would hide it and a deleted spec |
| 39 | + * would buy green with a smaller suite. |
| 40 | + * |
| 41 | + * WHOEVER IMPLEMENTS PREVIEW: change `test.fixme(` back to `test(` for each of |
| 42 | + * the five. The bodies are the real assertions and are already written. |
| 43 | + * |
| 44 | + * `test.fixme` is used in its DECLARATIVE form deliberately: the in-body form |
| 45 | + * runs after fixtures are constructed, which boots a backend and a browser to |
| 46 | + * reach a line that says "do not run this". Declared, the runner reports the row |
| 47 | + * without paying for the stack. |
| 48 | + */ |
| 49 | +import { test, expect } from "../fixtures"; |
| 50 | + |
| 51 | +/** The precondition every one of these five shares, and that nothing can satisfy today. */ |
| 52 | +async function openPreviewAndFocusIt(page: import("@playwright/test").Page) { |
| 53 | + // `preview.toggle` is the only ungated entry point to `previewFocus`. |
| 54 | + await page.keyboard.press("ControlOrMeta+Shift+J"); |
| 55 | + await expect( |
| 56 | + page.locator('[data-preview-pane], iframe[title*="preview" i]').first(), |
| 57 | + "preview.toggle must open a preview pane — it is the only way previewFocus " + |
| 58 | + "can ever become true, and all five keybindings in this file are gated on it", |
| 59 | + ).toBeVisible(); |
| 60 | +} |
| 61 | + |
| 62 | +// DESCRIBE-LEVEL, NOT PER-TEST. `test.fixme(true, ...)` inside a test body is |
| 63 | +// evaluated AFTER beforeEach, so the shared `openPreviewAndFocusIt` precondition |
| 64 | +// ran first and the test reported a 180s TIMEOUT instead of BLOCKED. A blocked |
| 65 | +// capability must not burn a timeout to say so. |
| 66 | +test.describe |
| 67 | + .fixme("preview keybindings (previewFocus-gated) — BLOCKED: backend implements none of the 10 preview.* RPCs", () => { |
| 68 | + test.beforeEach(async ({ gotoApp, page }) => { |
| 69 | + await gotoApp(page); |
| 70 | + }); |
| 71 | + |
| 72 | + test.fixme("010 preview.refresh (mod+r) reloads the preview without navigating the app", async ({ |
| 73 | + page, |
| 74 | + }) => { |
| 75 | + await openPreviewAndFocusIt(page); |
| 76 | + const appUrl = page.url(); |
| 77 | + await page.keyboard.press("ControlOrMeta+R"); |
| 78 | + // The app must not be the thing that reloaded — that is the browser default |
| 79 | + // this binding has to preventDefault. |
| 80 | + expect(page.url()).toBe(appUrl); |
| 81 | + }); |
| 82 | + |
| 83 | + test.fixme("011 preview.focusUrl (mod+l) moves focus to the preview URL bar", async ({ |
| 84 | + page, |
| 85 | + }) => { |
| 86 | + await openPreviewAndFocusIt(page); |
| 87 | + await page.keyboard.press("ControlOrMeta+L"); |
| 88 | + const focused = page.locator(":focus"); |
| 89 | + await expect(focused).toHaveAttribute("data-preview-url", /.*/); |
| 90 | + }); |
| 91 | + |
| 92 | + test.fixme("012 preview.zoomIn (mod+= and mod++) increases preview zoom", async ({ page }) => { |
| 93 | + await openPreviewAndFocusIt(page); |
| 94 | + const pane = page.locator("[data-preview-pane]").first(); |
| 95 | + const before = await pane.getAttribute("data-preview-zoom"); |
| 96 | + await page.keyboard.press("ControlOrMeta+="); |
| 97 | + await expect(pane).not.toHaveAttribute("data-preview-zoom", before ?? ""); |
| 98 | + // BOTH chords are advertised (mod+= and mod++); a spec that exercises only |
| 99 | + // one reports coverage it does not have. |
| 100 | + const afterFirst = await pane.getAttribute("data-preview-zoom"); |
| 101 | + await page.keyboard.press("ControlOrMeta++"); |
| 102 | + await expect(pane).not.toHaveAttribute("data-preview-zoom", afterFirst ?? ""); |
| 103 | + }); |
| 104 | + |
| 105 | + test.fixme("013 preview.zoomOut (mod+-) decreases preview zoom", async ({ page }) => { |
| 106 | + await openPreviewAndFocusIt(page); |
| 107 | + const pane = page.locator("[data-preview-pane]").first(); |
| 108 | + const before = await pane.getAttribute("data-preview-zoom"); |
| 109 | + await page.keyboard.press("ControlOrMeta+-"); |
| 110 | + await expect(pane).not.toHaveAttribute("data-preview-zoom", before ?? ""); |
| 111 | + }); |
| 112 | + |
| 113 | + test.fixme("014 preview.resetZoom (mod+0) returns preview zoom to its default", async ({ |
| 114 | + page, |
| 115 | + }) => { |
| 116 | + await openPreviewAndFocusIt(page); |
| 117 | + const pane = page.locator("[data-preview-pane]").first(); |
| 118 | + const baseline = await pane.getAttribute("data-preview-zoom"); |
| 119 | + await page.keyboard.press("ControlOrMeta+="); |
| 120 | + await expect(pane).not.toHaveAttribute("data-preview-zoom", baseline ?? ""); |
| 121 | + await page.keyboard.press("ControlOrMeta+0"); |
| 122 | + await expect(pane).toHaveAttribute("data-preview-zoom", baseline ?? ""); |
| 123 | + }); |
| 124 | +}); |
| 125 | + |
| 126 | +test.describe("preview.toggle (ungated, reachable today)", () => { |
| 127 | + test.beforeEach(async ({ gotoApp, page }) => { |
| 128 | + await gotoApp(page); |
| 129 | + }); |
| 130 | + |
| 131 | + /** |
| 132 | + * THIS ONE IS NOT BLOCKED AND IT IS THE REASON THIS FILE FOUND A DEFECT. |
| 133 | + * |
| 134 | + * `preview.toggle` is advertised with NO `when` guard, so unlike the five |
| 135 | + * above a user can actually reach it. It is the precondition for all of them, |
| 136 | + * so if it silently does nothing they are unreachable by construction. That is |
| 137 | + * a live product claim, testable today, and it runs. |
| 138 | + */ |
| 139 | + test("009b preview.toggle is advertised to the client and must not silently do nothing", async ({ |
| 140 | + page, |
| 141 | + }) => { |
| 142 | + const advertised = await page.evaluate(async () => { |
| 143 | + // Read what the SERVER advertises, not what the client hardcodes. |
| 144 | + const res = await fetch("/api/keybindings").catch(() => null); |
| 145 | + return res && res.ok ? await res.json().catch(() => null) : null; |
| 146 | + }); |
| 147 | + // The binding's existence is asserted from the backend source regardless of |
| 148 | + // whether this route exists; see the header. What must hold at the glass is |
| 149 | + // that pressing it either opens something or reports why it cannot. |
| 150 | + const before = await page.locator("body").innerText(); |
| 151 | + await page.keyboard.press("ControlOrMeta+Shift+J"); |
| 152 | + const after = await page.locator("body").innerText(); |
| 153 | + expect( |
| 154 | + after !== before, |
| 155 | + "pressing the advertised, UNGATED preview.toggle (mod+shift+j) changed nothing " + |
| 156 | + "in the UI. The backend advertises this keybinding (keybindings.rs:96) while " + |
| 157 | + "implementing none of the ten preview.* RPCs the contract declares " + |
| 158 | + "(rpc.ts:271-280), so the command is dead on arrival: no pane, no error, no " + |
| 159 | + "feedback. Either implement the preview surface or stop advertising the " + |
| 160 | + `binding. (advertised payload: ${JSON.stringify(advertised)?.slice(0, 200)})`, |
| 161 | + ).toBe(true); |
| 162 | + }); |
| 163 | +}); |
0 commit comments