@dloizides/game-e2e 1.6.0 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,89 +1,106 @@
1
- # Changelog
2
-
3
- All notable changes to `@dloizides/game-e2e` are documented here.
4
-
5
- ## 1.6.0
6
-
7
- GAME-INPUT-PROMPTS-1 "Every action bound, with device labels":
8
-
9
- - `expectActionsBound(page, bindings, options?)`, `measureActionBinding`, `readActionElements`, `toActionReading`,
10
- `summariseActionBinding`, `actionBindingFindings`: fails when a visible clickable has no `data-gi-action`, a tagged
11
- action has no key or pad binding, a visible `data-gi-prompt` shows a label other than the current binding, or zero
12
- elements were read. Bindings are an input (`ActionBindings`), so the gate does not depend on a game-input release.
13
-
14
- ## 1.5.0
15
-
16
- TEXT-FIT-1 "UI text never overflows its box at 360x640 or desktop, in every state":
17
-
18
- - `expectTextFits(page, selector?, options?)`, `measureTextFit`, `readTextBoxes`, `summariseTextFit`, `textFitFindings`:
19
- fails when visible text is wider/taller than its box or spills its parent, across named UI states. Trigger: Surge's
20
- "Daily run" button with the "Completed today" badge ran past the button edge at 360x640 and 1280.
21
-
22
- ## 1.4.0
23
-
24
- GAME-E2E-PRESS-1 "Faster pad presses in game-e2e walks":
25
-
26
- - `stubGamepad().press` holds the button for exactly one sampled frame and resolves once a reader has seen it
27
- released (`navigator.getGamepads()` calls latched to `document.timeline.currentTime`), instead of 3+3 fixed
28
- `requestAnimationFrame` ticks. Under CPU load the old hold outlasted the 380 ms pad repeat delay and moved focus
29
- twice, so the walk skipped rows. `STUB_FRAMES` is now 1; `PRESS_WAIT_FRAMES` (240) caps the wait when no reader polls.
30
-
31
- ## 1.3.0
32
-
33
- NAV-1 "Every game menu works with arrow keys and controller", phase 4 (canvas menus):
34
-
35
- - `expectHookMenuWalkable(page, { screens, open, via?, sizes? })` / `walkHookMenus`: walks menus drawn on a canvas
36
- (Phaser, Babylon GUI) through the `window.__menuWalk` hook (`MenuWalkHook` from `@dloizides/game-input` 1.6.0).
37
- Per screen, at phone (360x640) and desktop (1280x720) viewports, by arrow keys and the stubbed pad: learns every
38
- focus transition until no direction is left untried, fails naming each unreached item. `activates: { item, to }`
39
- checks Enter / A opens a screen; Escape / B must leave the screen unless `leaves: false`.
40
- - Arrow/pad driver moved to `menu-walk-driver.ts`, shared by the DOM and hook walkers (adds Enter / A `activate`).
41
-
42
- ## 1.2.1
43
-
44
- - Listener lookup is one `Runtime.evaluate` (DevTools `getEventListeners`) instead of two CDP calls per element. The
45
- per-element calls slowed the walk enough that a screen re-rendering on a late fetch (Surge `stagePreview`) went red.
46
-
47
- ## 1.2.0
48
-
49
- NAV-1 "Every game menu works with arrow keys and controller", walker gap:
50
-
51
- - The walker now finds pointer-only items whose click / pointerdown / pointerup handler is set as a property
52
- (`el.onclick = ...`) or added with `addEventListener`, not only the `[onclick]` attribute. A visible element
53
- with such a handler that is not focusable is reported `unreached`.
54
- - Listeners are read through CDP `DOMDebugger.getEventListeners` (Chromium). Without CDP (Firefox, WebKit) only
55
- the attribute and properties are checked, and each result carries a `notes` line saying so.
56
- - Delegation: an element that contains a walk control, or sits inside one, is never flagged, so a listener on a
57
- menu container does not flag the container or its children. When nested elements are both flagged, only the
58
- innermost is reported.
59
- - `WalkResult.notes` (new, printed as `note:` by `renderWalk`).
60
-
61
- ## 1.1.0
62
-
63
- NAV-1 "Every game menu works with arrow keys and controller", phase 1:
64
-
65
- - `walkMenus()` / `expectMenuWalkable()`: open each screen, walk every focusable control by arrow keys and
66
- by a stubbed gamepad (breadth-first from the focused control), report unreached controls, a dialog that
67
- opens without focus inside it, sliders that ignore Left/Right, and Escape / B that does not close a dialog.
68
- Exemptions take a selector and a printed reason.
69
- - `stubGamepad()`: a `navigator.getGamepads()` stand-in driven from the test (`PadDriver.press`).
70
- - `renderWalk()`, `walkFailed()`, `WALK_INPUTS`.
71
- - Depends on `@dloizides/game-input` ^1.5.1 for the shared focusable and dialog selectors.
72
-
73
- ## 1.0.0
74
-
75
- First release. Playwright helpers that Aurora, Surge and Morphe each carried a copy of, unified on the
76
- strictest behaviour of the three:
77
-
78
- - `phone()` / `desktop()` / `gameProjects()`: Galaxy S5 and Desktop Chrome device descriptors (touch,
79
- mobile UA, isMobile on the phone), resized; never a bare viewport.
80
- - `armVisibleHeight()` / `shrinkVisibleHeight()`: a simulated browser toolbar. `relayoutGlobal` waits for
81
- every active Phaser scene to re-create and throws when the global is missing.
82
- - `expectFitTo()`, `expectCanvasHeight()`, `expectCanvasInside()`: game-shell fit assertions with a
83
- configurable canvas selector.
84
- - `domControls()`, `overlaps()`, `findOverlaps()`, `findOverlapsWithin()`, `canvasBoxToPage()`.
85
- - `diffPngs()` / `regionDiff()` / `countDiff()`: exact by default (tolerance 0, sizes must match);
86
- `ANTI_ALIAS_TOLERANCE` (48) and `width`/`height` opt into Surge's tolerant, scaled comparison.
87
- - `auditTouchTargets()` + `expectTouchTargets(AcrossRoutes)()`: the 44x44 hit-box gate.
88
- - `readHorizontalOverflow()` + `expectNoHorizontalOverflow(AcrossRoutes)()`: the no-horizontal-scroll
89
- gate, measured against the narrower of visualViewport width and clientWidth.
1
+ # Changelog
2
+
3
+ All notable changes to `@dloizides/game-e2e` are documented here.
4
+
5
+ ## 1.7.1
6
+
7
+ D-BTV-E2E-3 "nav1 under 180 s by speeding up the walker" (tag v1.7.0 was pushed before the version bump and never published):
8
+
9
+ - `walkMenus` / `expectMenuWalkable` stop the breadth-first walk once every control is reached; the remaining presses
10
+ could not change the result, so no assertion is dropped (slider, dialog focus and back checks run as before).
11
+ - A pad walk step (focus, press, read focus) is one page round trip: new `PadDriver.move(button, { attr, id })`.
12
+ Profiled on a BeyondTheVoid title walk, pad presses were 75% of the walk time.
13
+
14
+ ## 1.6.1
15
+
16
+ GAME-INPUT-PROMPTS-1 "Every action bound, with device labels", D-GIP-9 "Widen AC-GIP-5":
17
+
18
+ - `actionBindingFindings` reports `prompt missing` when a bound action's binding carries a prompt label but no visible
19
+ `data-gi-prompt` shows it (absent, hidden or zero-size chip). Before, such a chip passed. On touch the caller passes
20
+ bindings with `prompt: null`, so hidden chips still pass (AC-GIP-9).
21
+
22
+ ## 1.6.0
23
+
24
+ GAME-INPUT-PROMPTS-1 "Every action bound, with device labels":
25
+
26
+ - `expectActionsBound(page, bindings, options?)`, `measureActionBinding`, `readActionElements`, `toActionReading`,
27
+ `summariseActionBinding`, `actionBindingFindings`: fails when a visible clickable has no `data-gi-action`, a tagged
28
+ action has no key or pad binding, a visible `data-gi-prompt` shows a label other than the current binding, or zero
29
+ elements were read. Bindings are an input (`ActionBindings`), so the gate does not depend on a game-input release.
30
+
31
+ ## 1.5.0
32
+
33
+ TEXT-FIT-1 "UI text never overflows its box at 360x640 or desktop, in every state":
34
+
35
+ - `expectTextFits(page, selector?, options?)`, `measureTextFit`, `readTextBoxes`, `summariseTextFit`, `textFitFindings`:
36
+ fails when visible text is wider/taller than its box or spills its parent, across named UI states. Trigger: Surge's
37
+ "Daily run" button with the "Completed today" badge ran past the button edge at 360x640 and 1280.
38
+
39
+ ## 1.4.0
40
+
41
+ GAME-E2E-PRESS-1 "Faster pad presses in game-e2e walks":
42
+
43
+ - `stubGamepad().press` holds the button for exactly one sampled frame and resolves once a reader has seen it
44
+ released (`navigator.getGamepads()` calls latched to `document.timeline.currentTime`), instead of 3+3 fixed
45
+ `requestAnimationFrame` ticks. Under CPU load the old hold outlasted the 380 ms pad repeat delay and moved focus
46
+ twice, so the walk skipped rows. `STUB_FRAMES` is now 1; `PRESS_WAIT_FRAMES` (240) caps the wait when no reader polls.
47
+
48
+ ## 1.3.0
49
+
50
+ NAV-1 "Every game menu works with arrow keys and controller", phase 4 (canvas menus):
51
+
52
+ - `expectHookMenuWalkable(page, { screens, open, via?, sizes? })` / `walkHookMenus`: walks menus drawn on a canvas
53
+ (Phaser, Babylon GUI) through the `window.__menuWalk` hook (`MenuWalkHook` from `@dloizides/game-input` 1.6.0).
54
+ Per screen, at phone (360x640) and desktop (1280x720) viewports, by arrow keys and the stubbed pad: learns every
55
+ focus transition until no direction is left untried, fails naming each unreached item. `activates: { item, to }`
56
+ checks Enter / A opens a screen; Escape / B must leave the screen unless `leaves: false`.
57
+ - Arrow/pad driver moved to `menu-walk-driver.ts`, shared by the DOM and hook walkers (adds Enter / A `activate`).
58
+
59
+ ## 1.2.1
60
+
61
+ - Listener lookup is one `Runtime.evaluate` (DevTools `getEventListeners`) instead of two CDP calls per element. The
62
+ per-element calls slowed the walk enough that a screen re-rendering on a late fetch (Surge `stagePreview`) went red.
63
+
64
+ ## 1.2.0
65
+
66
+ NAV-1 "Every game menu works with arrow keys and controller", walker gap:
67
+
68
+ - The walker now finds pointer-only items whose click / pointerdown / pointerup handler is set as a property
69
+ (`el.onclick = ...`) or added with `addEventListener`, not only the `[onclick]` attribute. A visible element
70
+ with such a handler that is not focusable is reported `unreached`.
71
+ - Listeners are read through CDP `DOMDebugger.getEventListeners` (Chromium). Without CDP (Firefox, WebKit) only
72
+ the attribute and properties are checked, and each result carries a `notes` line saying so.
73
+ - Delegation: an element that contains a walk control, or sits inside one, is never flagged, so a listener on a
74
+ menu container does not flag the container or its children. When nested elements are both flagged, only the
75
+ innermost is reported.
76
+ - `WalkResult.notes` (new, printed as `note:` by `renderWalk`).
77
+
78
+ ## 1.1.0
79
+
80
+ NAV-1 "Every game menu works with arrow keys and controller", phase 1:
81
+
82
+ - `walkMenus()` / `expectMenuWalkable()`: open each screen, walk every focusable control by arrow keys and
83
+ by a stubbed gamepad (breadth-first from the focused control), report unreached controls, a dialog that
84
+ opens without focus inside it, sliders that ignore Left/Right, and Escape / B that does not close a dialog.
85
+ Exemptions take a selector and a printed reason.
86
+ - `stubGamepad()`: a `navigator.getGamepads()` stand-in driven from the test (`PadDriver.press`).
87
+ - `renderWalk()`, `walkFailed()`, `WALK_INPUTS`.
88
+ - Depends on `@dloizides/game-input` ^1.5.1 for the shared focusable and dialog selectors.
89
+
90
+ ## 1.0.0
91
+
92
+ First release. Playwright helpers that Aurora, Surge and Morphe each carried a copy of, unified on the
93
+ strictest behaviour of the three:
94
+
95
+ - `phone()` / `desktop()` / `gameProjects()`: Galaxy S5 and Desktop Chrome device descriptors (touch,
96
+ mobile UA, isMobile on the phone), resized; never a bare viewport.
97
+ - `armVisibleHeight()` / `shrinkVisibleHeight()`: a simulated browser toolbar. `relayoutGlobal` waits for
98
+ every active Phaser scene to re-create and throws when the global is missing.
99
+ - `expectFitTo()`, `expectCanvasHeight()`, `expectCanvasInside()`: game-shell fit assertions with a
100
+ configurable canvas selector.
101
+ - `domControls()`, `overlaps()`, `findOverlaps()`, `findOverlapsWithin()`, `canvasBoxToPage()`.
102
+ - `diffPngs()` / `regionDiff()` / `countDiff()`: exact by default (tolerance 0, sizes must match);
103
+ `ANTI_ALIAS_TOLERANCE` (48) and `width`/`height` opt into Surge's tolerant, scaled comparison.
104
+ - `auditTouchTargets()` + `expectTouchTargets(AcrossRoutes)()`: the 44x44 hit-box gate.
105
+ - `readHorizontalOverflow()` + `expectNoHorizontalOverflow(AcrossRoutes)()`: the no-horizontal-scroll
106
+ gate, measured against the narrower of visualViewport width and clientWidth.
package/dist/index.d.mts CHANGED
@@ -248,8 +248,14 @@ declare function walkMenus(page: Page, screens: readonly WalkScreen[], options?:
248
248
  /** NAV-1 gate: throws, listing every unreached control and problem, unless every screen walks by keys and pad. */
249
249
  declare function expectMenuWalkable(page: Page, screens: readonly WalkScreen[], options?: WalkOptions): Promise<void>;
250
250
 
251
+ interface WalkFocus {
252
+ attr: string;
253
+ id: number;
254
+ }
251
255
  interface PadDriver {
252
256
  press(button: number): Promise<void>;
257
+ /** Focuses walk control `focus.id`, presses `button` and returns the walk id focused after it, in one page round trip. */
258
+ move(button: number, focus: WalkFocus): Promise<number | null>;
253
259
  hold(axis: number, value: number): Promise<void>;
254
260
  }
255
261
  declare const STUB_FRAMES = 1;
@@ -350,7 +356,7 @@ interface ActionBindingFinding {
350
356
  name: string;
351
357
  why: string;
352
358
  }
353
- /** Every way one element breaks "every action bound": untagged, no key, no pad button, stale prompt. */
359
+ /** Every way one element breaks "every action bound": untagged, no key, no pad button, stale or missing prompt. */
354
360
  declare function actionBindingFindings(r: ActionReading): ActionBindingFinding[];
355
361
  /** Folds every reading into one tally; zero readings is a blind probe and counts as a problem. */
356
362
  declare function summariseActionBinding(readings: readonly ActionReading[], where: string): GateSummary;
package/dist/index.d.ts CHANGED
@@ -248,8 +248,14 @@ declare function walkMenus(page: Page, screens: readonly WalkScreen[], options?:
248
248
  /** NAV-1 gate: throws, listing every unreached control and problem, unless every screen walks by keys and pad. */
249
249
  declare function expectMenuWalkable(page: Page, screens: readonly WalkScreen[], options?: WalkOptions): Promise<void>;
250
250
 
251
+ interface WalkFocus {
252
+ attr: string;
253
+ id: number;
254
+ }
251
255
  interface PadDriver {
252
256
  press(button: number): Promise<void>;
257
+ /** Focuses walk control `focus.id`, presses `button` and returns the walk id focused after it, in one page round trip. */
258
+ move(button: number, focus: WalkFocus): Promise<number | null>;
253
259
  hold(axis: number, value: number): Promise<void>;
254
260
  }
255
261
  declare const STUB_FRAMES = 1;
@@ -350,7 +356,7 @@ interface ActionBindingFinding {
350
356
  name: string;
351
357
  why: string;
352
358
  }
353
- /** Every way one element breaks "every action bound": untagged, no key, no pad button, stale prompt. */
359
+ /** Every way one element breaks "every action bound": untagged, no key, no pad button, stale or missing prompt. */
354
360
  declare function actionBindingFindings(r: ActionReading): ActionBindingFinding[];
355
361
  /** Folds every reading into one tally; zero readings is a blind probe and counts as a problem. */
356
362
  declare function summariseActionBinding(readings: readonly ActionReading[], where: string): GateSummary;
package/dist/index.js CHANGED
@@ -496,11 +496,18 @@ function installStub([buttons, axes]) {
496
496
  Object.defineProperty(navigator, "getGamepads", { configurable: true, value: sample });
497
497
  window.addEventListener("load", () => window.dispatchEvent(Object.assign(new Event("gamepadconnected"), { gamepad: pad })));
498
498
  }
499
- async function pressInPage([button, maxFrames, idleFrames]) {
499
+ async function pressInPage([button, maxFrames, idleFrames, focus]) {
500
500
  const { __navPad: pad, __navPress: latch } = window;
501
+ const focused = () => {
502
+ const v = focus === null ? null : document.activeElement?.getAttribute(focus.attr) ?? null;
503
+ return v === null ? null : Number(v);
504
+ };
505
+ if (focus !== null) {
506
+ document.querySelector(`[${focus.attr}="${focus.id}"]`)?.focus();
507
+ }
501
508
  const target = pad.buttons[button];
502
509
  if (target === void 0) {
503
- return;
510
+ return focused();
504
511
  }
505
512
  target.pressed = true;
506
513
  target.value = 1;
@@ -522,17 +529,63 @@ async function pressInPage([button, maxFrames, idleFrames]) {
522
529
  };
523
530
  requestAnimationFrame(() => step(maxFrames));
524
531
  });
532
+ return focused();
525
533
  }
526
534
  async function stubGamepad(page) {
527
535
  await page.addInitScript(installStub, [STANDARD_BUTTON_COUNT, AXIS_COUNT]);
528
536
  return {
529
- press: (button) => page.evaluate(pressInPage, [button, PRESS_WAIT_FRAMES, IDLE_RELEASE_FRAMES]),
537
+ press: async (button) => {
538
+ await page.evaluate(pressInPage, [button, PRESS_WAIT_FRAMES, IDLE_RELEASE_FRAMES, null]);
539
+ },
540
+ move: (button, focus) => page.evaluate(pressInPage, [button, PRESS_WAIT_FRAMES, IDLE_RELEASE_FRAMES, focus]),
530
541
  hold: (axis, value) => page.evaluate(([a, v]) => {
531
542
  window.__navPad.axes[a] = v;
532
543
  }, [axis, value])
533
544
  };
534
545
  }
535
546
 
547
+ // src/menu-walk-page.ts
548
+ var WALK_ATTR = "data-walk-id";
549
+ function scanScreen(a) {
550
+ const shown = (el) => el.getClientRects().length > 0 && el.closest('[hidden], [inert], [aria-hidden="true"]') === null && getComputedStyle(el).visibility !== "hidden";
551
+ const dialogs = Array.from(document.querySelectorAll(a.dialogSel)).filter(shown);
552
+ const modal = dialogs.filter((d) => d.getAttribute("aria-modal") === "true");
553
+ const root = (modal.length > 0 ? modal : dialogs).pop() ?? document.body;
554
+ document.querySelectorAll(`[${a.attr}], [${a.rootAttr}]`).forEach((el) => {
555
+ el.removeAttribute(a.attr);
556
+ el.removeAttribute(a.rootAttr);
557
+ });
558
+ root.setAttribute(a.rootAttr, "");
559
+ const list = Array.from(root.querySelectorAll(`${a.focusSel}, [onclick]`)).filter((el) => shown(el) && el.disabled !== true && !a.exempt.some((s) => el.matches(s)));
560
+ list.forEach((el, i) => el.setAttribute(a.attr, String(i)));
561
+ const nonText = ["range", "checkbox", "radio", "button", "submit", "reset", "color", "file", "image"];
562
+ const isText = (el) => el.tagName === "TEXTAREA" || el instanceof HTMLInputElement && !nonText.includes(el.type);
563
+ const isSlider = (el) => el instanceof HTMLInputElement && el.type === "range" || el.getAttribute("role") === "slider";
564
+ const active2 = document.activeElement;
565
+ return {
566
+ identities: list.map((el) => ({ tag: el.tagName, id: el.id, className: el.getAttribute("class") ?? "", text: el.textContent ?? "" })),
567
+ isDialog: root !== document.body,
568
+ focusedInRoot: active2 instanceof HTMLElement && active2 !== root && root.contains(active2),
569
+ sliders: list.flatMap((el, i) => isSlider(el) ? [i] : []),
570
+ textFields: list.flatMap((el, i) => isText(el) ? [i] : [])
571
+ };
572
+ }
573
+ function activeWalkId(attr) {
574
+ const v = document.activeElement?.getAttribute(attr) ?? null;
575
+ return v === null ? null : Number(v);
576
+ }
577
+ function focusWalkId([attr, id]) {
578
+ document.querySelector(`[${attr}="${id}"]`)?.focus();
579
+ }
580
+ function controlValue([attr, id]) {
581
+ const el = document.querySelector(`[${attr}="${id}"]`);
582
+ return el instanceof HTMLInputElement ? el.value : el?.getAttribute("aria-valuenow") ?? "";
583
+ }
584
+ function rootOpen(rootAttr) {
585
+ const r = document.querySelector(`[${rootAttr}]`);
586
+ return r !== null && r.getClientRects().length > 0 && r.closest("[hidden]") === null;
587
+ }
588
+
536
589
  // src/menu-walk-report.ts
537
590
  var WALK_INPUTS = { keys: "keys", pad: "pad" };
538
591
  var walkFailed = (r) => r.unreached.length > 0 || r.problems.length > 0;
@@ -552,9 +605,14 @@ var KEYS = { up: "ArrowUp", down: "ArrowDown", left: "ArrowLeft", right: "ArrowR
552
605
  var PAD_BUTTONS = { up: gameInput.STANDARD_BUTTON.dpadUp, down: gameInput.STANDARD_BUTTON.dpadDown, left: gameInput.STANDARD_BUTTON.dpadLeft, right: gameInput.STANDARD_BUTTON.dpadRight };
553
606
  function driverFor(page, via, pad) {
554
607
  if (via === WALK_INPUTS.pad && pad !== null) {
555
- return { dir: (d) => pad.press(PAD_BUTTONS[d]), back: () => pad.press(gameInput.STANDARD_BUTTON.east), activate: () => pad.press(gameInput.STANDARD_BUTTON.south) };
608
+ return { dir: (d) => pad.press(PAD_BUTTONS[d]), move: (from, d) => pad.move(PAD_BUTTONS[d], { attr: WALK_ATTR, id: from }), back: () => pad.press(gameInput.STANDARD_BUTTON.east), activate: () => pad.press(gameInput.STANDARD_BUTTON.south) };
556
609
  }
557
- return { dir: (d) => page.keyboard.press(KEYS[d]), back: () => page.keyboard.press("Escape"), activate: () => page.keyboard.press("Enter") };
610
+ const move = async (from, d) => {
611
+ await page.evaluate(focusWalkId, [WALK_ATTR, from]);
612
+ await page.keyboard.press(KEYS[d]);
613
+ return page.evaluate(activeWalkId, WALK_ATTR);
614
+ };
615
+ return { dir: (d) => page.keyboard.press(KEYS[d]), move, back: () => page.keyboard.press("Escape"), activate: () => page.keyboard.press("Enter") };
558
616
  }
559
617
 
560
618
  // src/menu-walk-listeners.ts
@@ -595,49 +653,7 @@ async function pointerOnlyControls(page, cdp, args, start) {
595
653
  return { identities, notes: cdp === null ? [NO_CDP_NOTE] : [] };
596
654
  }
597
655
 
598
- // src/menu-walk-page.ts
599
- function scanScreen(a) {
600
- const shown = (el) => el.getClientRects().length > 0 && el.closest('[hidden], [inert], [aria-hidden="true"]') === null && getComputedStyle(el).visibility !== "hidden";
601
- const dialogs = Array.from(document.querySelectorAll(a.dialogSel)).filter(shown);
602
- const modal = dialogs.filter((d) => d.getAttribute("aria-modal") === "true");
603
- const root = (modal.length > 0 ? modal : dialogs).pop() ?? document.body;
604
- document.querySelectorAll(`[${a.attr}], [${a.rootAttr}]`).forEach((el) => {
605
- el.removeAttribute(a.attr);
606
- el.removeAttribute(a.rootAttr);
607
- });
608
- root.setAttribute(a.rootAttr, "");
609
- const list = Array.from(root.querySelectorAll(`${a.focusSel}, [onclick]`)).filter((el) => shown(el) && el.disabled !== true && !a.exempt.some((s) => el.matches(s)));
610
- list.forEach((el, i) => el.setAttribute(a.attr, String(i)));
611
- const nonText = ["range", "checkbox", "radio", "button", "submit", "reset", "color", "file", "image"];
612
- const isText = (el) => el.tagName === "TEXTAREA" || el instanceof HTMLInputElement && !nonText.includes(el.type);
613
- const isSlider = (el) => el instanceof HTMLInputElement && el.type === "range" || el.getAttribute("role") === "slider";
614
- const active2 = document.activeElement;
615
- return {
616
- identities: list.map((el) => ({ tag: el.tagName, id: el.id, className: el.getAttribute("class") ?? "", text: el.textContent ?? "" })),
617
- isDialog: root !== document.body,
618
- focusedInRoot: active2 instanceof HTMLElement && active2 !== root && root.contains(active2),
619
- sliders: list.flatMap((el, i) => isSlider(el) ? [i] : []),
620
- textFields: list.flatMap((el, i) => isText(el) ? [i] : [])
621
- };
622
- }
623
- function activeWalkId(attr) {
624
- const v = document.activeElement?.getAttribute(attr) ?? null;
625
- return v === null ? null : Number(v);
626
- }
627
- function focusWalkId([attr, id]) {
628
- document.querySelector(`[${attr}="${id}"]`)?.focus();
629
- }
630
- function controlValue([attr, id]) {
631
- const el = document.querySelector(`[${attr}="${id}"]`);
632
- return el instanceof HTMLInputElement ? el.value : el?.getAttribute("aria-valuenow") ?? "";
633
- }
634
- function rootOpen(rootAttr) {
635
- const r = document.querySelector(`[${rootAttr}]`);
636
- return r !== null && r.getClientRects().length > 0 && r.closest("[hidden]") === null;
637
- }
638
-
639
656
  // src/menu-walk.ts
640
- var WALK_ATTR = "data-walk-id";
641
657
  var ROOT_ATTR = "data-walk-root";
642
658
  var PROBE_ATTR = "data-walk-probe";
643
659
  var PRESSES_PER_CONTROL = 4;
@@ -656,13 +672,12 @@ async function bfs(page, driver, total) {
656
672
  reached.add(start);
657
673
  const queue = [start];
658
674
  let presses = 0;
659
- while (queue.length > 0 && presses < PRESSES_PER_CONTROL * total) {
675
+ const open = () => reached.size < total && presses < PRESSES_PER_CONTROL * total;
676
+ while (queue.length > 0 && open()) {
660
677
  const from = queue.shift();
661
- for (const d of DIRS) {
662
- await focusId(page, from);
663
- await driver.dir(d);
678
+ for (const d of DIRS.filter(open)) {
679
+ const at2 = await driver.move(from, d);
664
680
  presses += 1;
665
- const at2 = await active(page);
666
681
  if (at2 !== null && !reached.has(at2)) {
667
682
  reached.add(at2);
668
683
  queue.push(at2);
@@ -1027,10 +1042,12 @@ function bindingFindings(r, action) {
1027
1042
  return found;
1028
1043
  }
1029
1044
  function promptFinding(r) {
1030
- const comparable = r.promptText !== null && r.expectedPromptText !== null;
1031
- if (!comparable || r.promptText === r.expectedPromptText) {
1045
+ if (r.expectedPromptText === null || r.promptText === r.expectedPromptText) {
1032
1046
  return null;
1033
1047
  }
1048
+ if (r.promptText === null) {
1049
+ return { name: r.name, why: `prompt missing: the current binding is "${r.expectedPromptText}" but no visible data-gi-prompt shows it` };
1050
+ }
1034
1051
  return { name: r.name, why: `prompt shows "${String(r.promptText)}" but the current binding is "${String(r.expectedPromptText)}"` };
1035
1052
  }
1036
1053
  function actionBindingFindings(r) {