vouchington-tooling 0.52.1 → 0.54.0

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.
Files changed (199) hide show
  1. package/README.md +103 -12
  2. package/dist/agent-blackboard/index.d.mts +0 -1
  3. package/dist/agent-blackboard/index.mjs +0 -23
  4. package/dist/cli/commands/agent-blackboard-flags.d.mts +0 -1
  5. package/dist/cli/commands/agent-blackboard-flags.mjs +0 -9
  6. package/dist/cli/commands/agent-blackboard.d.mts +0 -2
  7. package/dist/cli/commands/agent-blackboard.mjs +7 -121
  8. package/dist/cli/commands/story-coverage.d.mts +2 -0
  9. package/dist/cli/commands/story-coverage.mjs +56 -0
  10. package/dist/cli/commands/worktree.d.mts +2 -0
  11. package/dist/cli/commands/worktree.mjs +21 -0
  12. package/dist/cli/index.mjs +9 -0
  13. package/dist/cli/parse-forwarded-commands.d.mts +6 -0
  14. package/dist/cli/parse-forwarded-commands.mjs +4 -0
  15. package/dist/cli/parse-story-coverage-fields.d.mts +19 -0
  16. package/dist/cli/parse-story-coverage-fields.mjs +69 -0
  17. package/dist/cli/parse-story-coverage.d.mts +8 -0
  18. package/dist/cli/parse-story-coverage.mjs +34 -0
  19. package/dist/cli/parse.d.mts +8 -1
  20. package/dist/cli/parse.mjs +3 -0
  21. package/dist/cli/usage.d.mts +1 -1
  22. package/dist/cli/usage.mjs +14 -7
  23. package/dist/git-worktrees/assess.d.mts +14 -0
  24. package/dist/git-worktrees/assess.mjs +68 -0
  25. package/dist/git-worktrees/list.d.mts +10 -0
  26. package/dist/git-worktrees/list.mjs +34 -0
  27. package/dist/git-worktrees/reclaim.d.mts +15 -0
  28. package/dist/git-worktrees/reclaim.mjs +80 -0
  29. package/dist/git-worktrees/reclaim.test-helpers.d.mts +16 -0
  30. package/dist/git-worktrees/reclaim.test-helpers.mjs +113 -0
  31. package/dist/git-worktrees/run.d.mts +13 -0
  32. package/dist/git-worktrees/run.mjs +50 -0
  33. package/dist/host-storage/check.d.mts +38 -0
  34. package/dist/host-storage/check.mjs +109 -0
  35. package/dist/host-storage/cli.d.mts +7 -0
  36. package/dist/host-storage/cli.mjs +102 -0
  37. package/dist/host-storage/host-storage.test-helpers.d.mts +26 -0
  38. package/dist/host-storage/host-storage.test-helpers.mjs +58 -0
  39. package/dist/host-storage/index.d.mts +3 -0
  40. package/dist/host-storage/index.mjs +3 -0
  41. package/dist/host-storage/preflight.d.mts +22 -0
  42. package/dist/host-storage/preflight.mjs +105 -0
  43. package/dist/index.d.mts +2 -0
  44. package/dist/index.mjs +1 -0
  45. package/dist/playwright/assertions.d.mts +1 -0
  46. package/dist/playwright/assertions.mjs +5 -0
  47. package/dist/playwright/blocked-external-network.d.mts +15 -0
  48. package/dist/playwright/blocked-external-network.mjs +73 -0
  49. package/dist/playwright/browser-dialog-issues.d.mts +12 -0
  50. package/dist/playwright/browser-dialog-issues.mjs +29 -0
  51. package/dist/playwright/browser-errors.d.mts +22 -0
  52. package/dist/playwright/browser-errors.mjs +130 -0
  53. package/dist/playwright/browser-issue-monitor.test-helpers.d.mts +31 -0
  54. package/dist/playwright/browser-issue-monitor.test-helpers.mjs +51 -0
  55. package/dist/playwright/browser-issue-records.d.mts +42 -0
  56. package/dist/playwright/browser-issue-records.mjs +148 -0
  57. package/dist/playwright/browser-test.d.mts +21 -0
  58. package/dist/playwright/browser-test.mjs +68 -0
  59. package/dist/playwright/expect-no-broken-images.d.mts +17 -0
  60. package/dist/playwright/expect-no-broken-images.mjs +39 -0
  61. package/dist/playwright/index.d.mts +30 -0
  62. package/dist/playwright/index.mjs +22 -0
  63. package/dist/playwright/mobile-assertions.d.mts +14 -0
  64. package/dist/playwright/mobile-assertions.mjs +43 -0
  65. package/dist/playwright/navigate-to.d.mts +27 -0
  66. package/dist/playwright/navigate-to.mjs +39 -0
  67. package/dist/playwright/radix-select.d.mts +18 -0
  68. package/dist/playwright/radix-select.mjs +19 -0
  69. package/dist/playwright/random-id.d.mts +34 -0
  70. package/dist/playwright/random-id.mjs +37 -0
  71. package/dist/playwright/retry-on-connection-lost.d.mts +7 -0
  72. package/dist/playwright/retry-on-connection-lost.mjs +107 -0
  73. package/dist/playwright/scroll-to-load-more.d.mts +37 -0
  74. package/dist/playwright/scroll-to-load-more.mjs +158 -0
  75. package/dist/playwright/storybook.d.mts +2 -0
  76. package/dist/playwright/storybook.mjs +13 -0
  77. package/dist/playwright/test-fixtures.d.mts +1 -0
  78. package/dist/playwright/test-fixtures.mjs +2 -0
  79. package/dist/playwright/test-lifecycle-reporter.d.mts +11 -0
  80. package/dist/playwright/test-lifecycle-reporter.mjs +35 -0
  81. package/dist/playwright/totp.d.mts +6 -0
  82. package/dist/playwright/totp.mjs +37 -0
  83. package/dist/playwright/turnstile-stub.d.mts +8 -0
  84. package/dist/playwright/turnstile-stub.mjs +61 -0
  85. package/dist/playwright/viewport-constants.d.mts +30 -0
  86. package/dist/playwright/viewport-constants.mjs +9 -0
  87. package/dist/playwright/virtual-authenticator.d.mts +5 -0
  88. package/dist/playwright/virtual-authenticator.mjs +15 -0
  89. package/dist/playwright/wait-for-hydration.d.mts +29 -0
  90. package/dist/playwright/wait-for-hydration.mjs +81 -0
  91. package/dist/shell-parse/ansi-c-string.d.mts +12 -0
  92. package/dist/shell-parse/ansi-c-string.mjs +80 -0
  93. package/dist/shell-parse/index.d.mts +20 -0
  94. package/dist/shell-parse/index.mjs +15 -0
  95. package/dist/shell-parse/shell-command-substitution-reads.d.mts +8 -0
  96. package/dist/shell-parse/shell-command-substitution-reads.mjs +53 -0
  97. package/dist/shell-parse/shell-command-substitutions.d.mts +8 -0
  98. package/dist/shell-parse/shell-command-substitutions.mjs +52 -0
  99. package/dist/shell-parse/shell-command-wrappers.d.mts +26 -0
  100. package/dist/shell-parse/shell-command-wrappers.mjs +143 -0
  101. package/dist/shell-parse/shell-commands.d.mts +24 -0
  102. package/dist/shell-parse/shell-commands.mjs +155 -0
  103. package/dist/shell-parse/shell-heredoc-delimiter.d.mts +5 -0
  104. package/dist/shell-parse/shell-heredoc-delimiter.mjs +52 -0
  105. package/dist/shell-parse/shell-heredoc-parser.d.mts +7 -0
  106. package/dist/shell-parse/shell-heredoc-parser.mjs +49 -0
  107. package/dist/shell-parse/shell-heredoc-quote-state.d.mts +19 -0
  108. package/dist/shell-parse/shell-heredoc-quote-state.mjs +40 -0
  109. package/dist/shell-parse/shell-heredoc.d.mts +10 -0
  110. package/dist/shell-parse/shell-heredoc.mjs +90 -0
  111. package/dist/shell-parse/shell-redirections.d.mts +5 -0
  112. package/dist/shell-parse/shell-redirections.mjs +34 -0
  113. package/dist/shell-parse/shell-script-operand.d.mts +13 -0
  114. package/dist/shell-parse/shell-script-operand.mjs +103 -0
  115. package/dist/shell-parse/shell-stdin-script.d.mts +6 -0
  116. package/dist/shell-parse/shell-stdin-script.mjs +61 -0
  117. package/dist/shell-parse/shell-token-utils.d.mts +9 -0
  118. package/dist/shell-parse/shell-token-utils.mjs +33 -0
  119. package/dist/shell-parse/shell-tokenizer-comments.d.mts +1 -0
  120. package/dist/shell-parse/shell-tokenizer-comments.mjs +57 -0
  121. package/dist/shell-parse/shell-tokenizer-operators.d.mts +14 -0
  122. package/dist/shell-parse/shell-tokenizer-operators.mjs +47 -0
  123. package/dist/shell-parse/shell-tokenizer.d.mts +12 -0
  124. package/dist/shell-parse/shell-tokenizer.mjs +104 -0
  125. package/dist/story-coverage/analyze.d.mts +8 -0
  126. package/dist/story-coverage/analyze.mjs +24 -0
  127. package/dist/story-coverage/check.d.mts +11 -0
  128. package/dist/story-coverage/check.mjs +42 -0
  129. package/dist/story-coverage/components.d.mts +10 -0
  130. package/dist/story-coverage/components.mjs +40 -0
  131. package/dist/story-coverage/coverage.d.mts +10 -0
  132. package/dist/story-coverage/coverage.mjs +43 -0
  133. package/dist/story-coverage/index.d.mts +13 -0
  134. package/dist/story-coverage/index.mjs +7 -0
  135. package/dist/story-coverage/messages.d.mts +10 -0
  136. package/dist/story-coverage/messages.mjs +42 -0
  137. package/dist/story-coverage/options.d.mts +27 -0
  138. package/dist/story-coverage/options.mjs +51 -0
  139. package/dist/story-coverage/workspace.d.mts +2 -0
  140. package/dist/story-coverage/workspace.mjs +27 -0
  141. package/dist/test-helpers/cancel-runs.test-helpers.d.mts +39 -0
  142. package/dist/test-helpers/cancel-runs.test-helpers.mjs +124 -0
  143. package/dist/test-helpers/run-bounded-exit-observer.test-helpers.d.mts +12 -0
  144. package/dist/test-helpers/run-bounded-exit-observer.test-helpers.mjs +68 -0
  145. package/dist/test-helpers/run-bounded-output-fixture.test-helpers.d.mts +18 -0
  146. package/dist/test-helpers/run-bounded-output-fixture.test-helpers.mjs +162 -0
  147. package/dist/vitest-diagnostics/index.d.mts +9 -1
  148. package/dist/vitest-diagnostics/index.mjs +5 -1
  149. package/dist/vitest-diagnostics/vitest-fake-timer-guard.d.mts +6 -0
  150. package/dist/vitest-diagnostics/vitest-fake-timer-guard.mjs +34 -0
  151. package/dist/vitest-diagnostics/vitest-fork-leak-detection.d.mts +1 -0
  152. package/dist/vitest-diagnostics/vitest-fork-leak-detection.mjs +8 -0
  153. package/dist/vitest-diagnostics/vitest-fork-leak-diagnostics.d.mts +10 -1
  154. package/dist/vitest-diagnostics/vitest-fork-leak-diagnostics.mjs +43 -2
  155. package/dist/vitest-diagnostics/vitest-fork-leak-handshake-samples.d.mts +50 -0
  156. package/dist/vitest-diagnostics/vitest-fork-leak-handshake-samples.mjs +69 -0
  157. package/dist/vitest-diagnostics/vitest-fork-leak-handshake.d.mts +19 -0
  158. package/dist/vitest-diagnostics/vitest-fork-leak-handshake.mjs +136 -0
  159. package/dist/vitest-diagnostics/vitest-network-allowlist-dns.d.mts +7 -0
  160. package/dist/vitest-diagnostics/vitest-network-allowlist-dns.mjs +54 -0
  161. package/dist/vitest-diagnostics/vitest-network-allowlist-host.d.mts +8 -0
  162. package/dist/vitest-diagnostics/vitest-network-allowlist-host.mjs +48 -0
  163. package/dist/vitest-diagnostics/vitest-network-allowlist-socket.d.mts +14 -0
  164. package/dist/vitest-diagnostics/vitest-network-allowlist-socket.mjs +39 -0
  165. package/dist/vitest-diagnostics/vitest-network-allowlist.d.mts +7 -0
  166. package/dist/vitest-diagnostics/vitest-network-allowlist.mjs +72 -0
  167. package/dist/vitest-diagnostics/vitest-process-resources.d.mts +6 -0
  168. package/dist/vitest-diagnostics/vitest-process-resources.mjs +51 -0
  169. package/dist/vitest-effective-timeout/cap.d.mts +9 -0
  170. package/dist/vitest-effective-timeout/cap.mjs +28 -0
  171. package/dist/vitest-effective-timeout/check-profiles.d.mts +15 -0
  172. package/dist/vitest-effective-timeout/check-profiles.mjs +52 -0
  173. package/dist/vitest-effective-timeout/config-file.d.mts +6 -0
  174. package/dist/vitest-effective-timeout/config-file.mjs +23 -0
  175. package/dist/vitest-effective-timeout/fixtures.d.mts +2 -0
  176. package/dist/vitest-effective-timeout/fixtures.mjs +18 -0
  177. package/dist/vitest-effective-timeout/index.d.mts +7 -0
  178. package/dist/vitest-effective-timeout/index.mjs +4 -0
  179. package/dist/vitest-effective-timeout/profiles.d.mts +10 -0
  180. package/dist/vitest-effective-timeout/profiles.mjs +33 -0
  181. package/dist/vitest-effective-timeout/run-profile.d.mts +31 -0
  182. package/dist/vitest-effective-timeout/run-profile.mjs +95 -0
  183. package/docs/mcp-server.md +2 -13
  184. package/package.json +32 -2
  185. package/scripts/__pycache__/run_bounded_process.cpython-312.pyc +0 -0
  186. package/scripts/chromium-launch-probe.d.mts +7 -0
  187. package/scripts/chromium-launch-probe.mjs +101 -0
  188. package/scripts/run-bounded-fixtures/run-bounded-backpressure.py +186 -0
  189. package/scripts/run-bounded-fixtures/run-bounded-merged-output.py +75 -0
  190. package/scripts/run-bounded-fixtures/run-bounded-reset-socket.py +25 -0
  191. package/scripts/run-bounded.py +199 -0
  192. package/scripts/run_bounded_process.py +129 -0
  193. package/scripts/worktree/git-index-lock.sh +16 -0
  194. package/scripts/worktree/git-worktrees.sh +23 -20
  195. package/scripts/worktree/reset-worktree-run.sh +199 -0
  196. package/scripts/worktree/reset-worktree.sh +122 -0
  197. package/skills/blackboard/SKILL.md +4 -64
  198. package/skills/stacked-prs/SKILL.md +1 -1
  199. package/skills/stacked-prs/references/drain.md +2 -2
@@ -0,0 +1,27 @@
1
+ import type { Page } from '@playwright/test';
2
+ import { retryOnConnectionLost } from './retry-on-connection-lost.mts';
3
+ import { installTurnstileStub } from './turnstile-stub.mts';
4
+ /**
5
+ * Navigate to a URL and wait for network idle (or a custom wait state).
6
+ * Always use this instead of raw page.goto() to avoid flaky tests
7
+ * caused by interacting with pages before they've fully loaded.
8
+ *
9
+ * Installs the Turnstile stub once per page (see turnstile-stub.mts) so the
10
+ * widget script does not keep third-party traffic alive past the navigation
11
+ * timeout. Pass `dependencies.installTurnstileStub` to replace that install.
12
+ *
13
+ * Retries transient connection errors (ERR_CONNECTION_REFUSED / RESET) using
14
+ * bounded retries and 5s backoff to absorb cold starts.
15
+ *
16
+ * Pass `waitUntil: 'load'` for pages with a connection that stays open and
17
+ * never reaches networkidle.
18
+ *
19
+ * Safe for URLs that redirect on the client — the readiness wait restarts against
20
+ * whichever document the redirect lands on (see wait-for-hydration.mts).
21
+ */
22
+ export declare function navigateTo(page: Page, url: string, { waitUntil }?: {
23
+ waitUntil?: "load" | "networkidle" | undefined;
24
+ }, dependencies?: Partial<{
25
+ installTurnstileStub: typeof installTurnstileStub;
26
+ retryOnConnectionLost: typeof retryOnConnectionLost;
27
+ }>): Promise<void>;
@@ -0,0 +1,39 @@
1
+ import { retryOnConnectionLost } from "./retry-on-connection-lost.mjs";
2
+ import { installTurnstileStub } from "./turnstile-stub.mjs";
3
+ import { waitForBelowFoldHydration } from "./wait-for-hydration.mjs";
4
+ /**
5
+ * Navigate to a URL and wait for network idle (or a custom wait state).
6
+ * Always use this instead of raw page.goto() to avoid flaky tests
7
+ * caused by interacting with pages before they've fully loaded.
8
+ *
9
+ * Installs the Turnstile stub once per page (see turnstile-stub.mts) so the
10
+ * widget script does not keep third-party traffic alive past the navigation
11
+ * timeout. Pass `dependencies.installTurnstileStub` to replace that install.
12
+ *
13
+ * Retries transient connection errors (ERR_CONNECTION_REFUSED / RESET) using
14
+ * bounded retries and 5s backoff to absorb cold starts.
15
+ *
16
+ * Pass `waitUntil: 'load'` for pages with a connection that stays open and
17
+ * never reaches networkidle.
18
+ *
19
+ * Safe for URLs that redirect on the client — the readiness wait restarts against
20
+ * whichever document the redirect lands on (see wait-for-hydration.mts).
21
+ */
22
+ export async function navigateTo(page, url, { waitUntil = 'networkidle' } = {}, dependencies) {
23
+ const installStub = dependencies?.installTurnstileStub ?? installTurnstileStub;
24
+ const retry = dependencies?.retryOnConnectionLost ?? retryOnConnectionLost;
25
+ await installStub(page);
26
+ await retry(async () => {
27
+ await page.goto(url, { waitUntil: 'domcontentloaded' });
28
+ await page.waitForLoadState(waitUntil);
29
+ // React 19 + React Compiler can attach above-fold handlers after networkidle on
30
+ // slower machines. This bounded idle probe reduces that race but cannot prove
31
+ // every handler is wired; a control that rejects early interaction owns a
32
+ // disabled-until-hydrated boundary, and tests assert that boundary is enabled.
33
+ //
34
+ // A route that redirects on the client can reach `waitUntil` before the
35
+ // redirect fires, so pass it through: if the redirect lands mid-wait, the
36
+ // replacement document is settled to the same state this call asked for.
37
+ await waitForBelowFoldHydration(page, { waitUntil });
38
+ });
39
+ }
@@ -0,0 +1,18 @@
1
+ import type { Locator } from '@playwright/test';
2
+ /**
3
+ * Opens a Radix UI Select or DropdownMenu by pressing Space on the trigger.
4
+ *
5
+ * Radix portals the dropdown content outside the trigger's DOM subtree, so the
6
+ * trigger must be focused first; Space is the reliable keyboard activation path
7
+ * (ArrowDown also works for DropdownMenu but Space is universal for both).
8
+ *
9
+ * After calling this, wait for the option you want with `toBeAttached()` before
10
+ * clicking — not `toBeVisible()`. Radix items are attached to the DOM immediately
11
+ * but may not pass the visibility check until the CSS animation settles.
12
+ *
13
+ * @example
14
+ * await openRadixDropdown(page.getByTestId('sort-trigger'))
15
+ * await expect(page.getByTestId('sort-option-new')).toBeAttached()
16
+ * await page.getByTestId('sort-option-new').click()
17
+ */
18
+ export declare function openRadixDropdown(trigger: Locator): Promise<void>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Opens a Radix UI Select or DropdownMenu by pressing Space on the trigger.
3
+ *
4
+ * Radix portals the dropdown content outside the trigger's DOM subtree, so the
5
+ * trigger must be focused first; Space is the reliable keyboard activation path
6
+ * (ArrowDown also works for DropdownMenu but Space is universal for both).
7
+ *
8
+ * After calling this, wait for the option you want with `toBeAttached()` before
9
+ * clicking — not `toBeVisible()`. Radix items are attached to the DOM immediately
10
+ * but may not pass the visibility check until the CSS animation settles.
11
+ *
12
+ * @example
13
+ * await openRadixDropdown(page.getByTestId('sort-trigger'))
14
+ * await expect(page.getByTestId('sort-option-new')).toBeAttached()
15
+ * await page.getByTestId('sort-option-new').click()
16
+ */
17
+ export async function openRadixDropdown(trigger) {
18
+ await trigger.press(' ');
19
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Generate a short random suffix for unique-ID-style usage in Playwright tests.
3
+ * Use this instead of `Date.now()`, which can collide between parallel workers
4
+ * and which returns different values when called twice in the same test.
5
+ *
6
+ * The suffix is 12 lowercase hex characters (about 48 bits of entropy), which
7
+ * is plenty for slug/title/hostname uniqueness while remaining short and
8
+ * readable in CI logs and screenshots.
9
+ *
10
+ * Compute the suffix once per test and reuse it everywhere a related ID is
11
+ * needed (slug, name, hostname, etc.) so all values stay consistent:
12
+ *
13
+ * ```ts
14
+ * const suffix = randomSuffix()
15
+ * await insertRecord(`Example ${suffix}`, `example-${suffix}`)
16
+ * ```
17
+ *
18
+ * If a `beforeAll` hook seeds data shared by a `describe` block (or a whole
19
+ * file), call `randomSuffix()` *inside* that hook, not at module/describe
20
+ * scope. Playwright's `fullyParallel` scheduler can hand a worker a second
21
+ * test from the same file, re-running `beforeAll` with module scope intact —
22
+ * a suffix hoisted outside the hook stays the same across that re-entry and
23
+ * produces the same slug/name twice, which throws on any unique column.
24
+ * Assign it as the first statement of the hook so every entry mints a fresh value:
25
+ *
26
+ * ```ts
27
+ * let suffix = ''
28
+ * test.beforeAll(async () => {
29
+ * suffix = randomSuffix()
30
+ * await insertRecord(`Example ${suffix}`, `example-${suffix}`)
31
+ * })
32
+ * ```
33
+ */
34
+ export declare function randomSuffix(): string;
@@ -0,0 +1,37 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ /**
3
+ * Generate a short random suffix for unique-ID-style usage in Playwright tests.
4
+ * Use this instead of `Date.now()`, which can collide between parallel workers
5
+ * and which returns different values when called twice in the same test.
6
+ *
7
+ * The suffix is 12 lowercase hex characters (about 48 bits of entropy), which
8
+ * is plenty for slug/title/hostname uniqueness while remaining short and
9
+ * readable in CI logs and screenshots.
10
+ *
11
+ * Compute the suffix once per test and reuse it everywhere a related ID is
12
+ * needed (slug, name, hostname, etc.) so all values stay consistent:
13
+ *
14
+ * ```ts
15
+ * const suffix = randomSuffix()
16
+ * await insertRecord(`Example ${suffix}`, `example-${suffix}`)
17
+ * ```
18
+ *
19
+ * If a `beforeAll` hook seeds data shared by a `describe` block (or a whole
20
+ * file), call `randomSuffix()` *inside* that hook, not at module/describe
21
+ * scope. Playwright's `fullyParallel` scheduler can hand a worker a second
22
+ * test from the same file, re-running `beforeAll` with module scope intact —
23
+ * a suffix hoisted outside the hook stays the same across that re-entry and
24
+ * produces the same slug/name twice, which throws on any unique column.
25
+ * Assign it as the first statement of the hook so every entry mints a fresh value:
26
+ *
27
+ * ```ts
28
+ * let suffix = ''
29
+ * test.beforeAll(async () => {
30
+ * suffix = randomSuffix()
31
+ * await insertRecord(`Example ${suffix}`, `example-${suffix}`)
32
+ * })
33
+ * ```
34
+ */
35
+ export function randomSuffix() {
36
+ return randomUUID().replaceAll('-', '').slice(0, 12);
37
+ }
@@ -0,0 +1,7 @@
1
+ interface RetryOnConnectionLostOptions {
2
+ backoffMs?: number;
3
+ maxRetries?: number;
4
+ maxDurationMs?: number;
5
+ }
6
+ export declare function retryOnConnectionLost<T>(fn: () => Promise<T>, options?: RetryOnConnectionLostOptions): Promise<T>;
7
+ export {};
@@ -0,0 +1,107 @@
1
+ const CONNECTION_RETRY_DEFAULT_BACKOFF_MS = 5000;
2
+ const CONNECTION_RETRY_DEFAULT_DURATION_MS = 55_000;
3
+ const CONNECTION_RETRY_MINIMUM_BACKOFF_MS = 50;
4
+ const CONNECTION_RETRY_BUDGET_EXCEEDED_MESSAGE = 'connection retry budget exceeded';
5
+ function validateRetryInputs(backoffMs, maxDurationMs, maxRetries) {
6
+ if (!Number.isFinite(backoffMs) || backoffMs <= 0) {
7
+ throw new Error('connection retry backoffMs must be a finite number greater than 0');
8
+ }
9
+ if (!Number.isFinite(maxDurationMs) || maxDurationMs <= 0) {
10
+ throw new Error('connection retry maxDurationMs must be a finite number greater than 0');
11
+ }
12
+ if (maxRetries !== undefined &&
13
+ (!Number.isFinite(maxRetries) || maxRetries < 0 || !Number.isInteger(maxRetries))) {
14
+ throw new Error('connection retry maxRetries must be a finite non-negative integer');
15
+ }
16
+ }
17
+ function getDefaultMaxRetries(backoffMs, maxDurationMs) {
18
+ return Math.max(1, Math.ceil(maxDurationMs / backoffMs));
19
+ }
20
+ const CONNECTION_LOST_PATTERN = /\bERR_(CONNECTION_REFUSED|CONNECTION_RESET|CONNECTION_CLOSED|SOCKET_NOT_CONNECTED|NETWORK_CHANGED|EMPTY_RESPONSE|ABORTED|INCOMPLETE_CHUNKED_ENCODING)\b/i;
21
+ const NAVIGATION_TIMEOUT_PATTERN = /\bpage\.goto: Timeout \d+ms exceeded\b/;
22
+ function isLocalUrl(value) {
23
+ try {
24
+ const { hostname } = new URL(value);
25
+ const normalizedHostname = hostname.replace(/^\[(.*)]$/, '$1');
26
+ return ['', 'localhost', '127.0.0.1', '::1'].includes(normalizedHostname);
27
+ }
28
+ catch {
29
+ return false;
30
+ }
31
+ }
32
+ function isLocalNavigationTimeout(message) {
33
+ if (!NAVIGATION_TIMEOUT_PATTERN.test(message))
34
+ return false;
35
+ const navigatingMatch = message.match(/navigating to "([^"]+)"/);
36
+ const target = navigatingMatch?.[1];
37
+ return target !== undefined && isLocalUrl(target);
38
+ }
39
+ function isConnectionLostError(err) {
40
+ const message = err instanceof Error ? err.message : String(err);
41
+ return CONNECTION_LOST_PATTERN.test(message) || isLocalNavigationTimeout(message);
42
+ }
43
+ async function runWithDeadline(fn, deadlineMs) {
44
+ if (deadlineMs <= 0) {
45
+ throw new Error(CONNECTION_RETRY_BUDGET_EXCEEDED_MESSAGE);
46
+ }
47
+ let timedOut = false;
48
+ let timerId;
49
+ const timeout = new Promise((_, reject) => {
50
+ timerId = setTimeout(() => {
51
+ timedOut = true;
52
+ reject(new Error(CONNECTION_RETRY_BUDGET_EXCEEDED_MESSAGE));
53
+ }, deadlineMs);
54
+ });
55
+ let attempt;
56
+ try {
57
+ attempt = Promise.resolve().then(fn);
58
+ const result = await Promise.race([attempt, timeout]);
59
+ return result;
60
+ }
61
+ catch (err) {
62
+ if (timedOut && attempt) {
63
+ attempt.catch(() => undefined);
64
+ }
65
+ throw err;
66
+ }
67
+ finally {
68
+ clearTimeout(timerId);
69
+ }
70
+ }
71
+ // Retries fn on transient network/worker errors matched by CONNECTION_LOST_PATTERN
72
+ // for a bounded recovery window, using configurable backoff sleeps and a total
73
+ // elapsed-time budget to absorb process restart windows, OS-level
74
+ // network changes (ERR_NETWORK_CHANGED), and related cold-start races.
75
+ export function retryOnConnectionLost(fn, options = {}) {
76
+ const backoffMs = options.backoffMs ?? CONNECTION_RETRY_DEFAULT_BACKOFF_MS;
77
+ const maxDurationMs = options.maxDurationMs ?? CONNECTION_RETRY_DEFAULT_DURATION_MS;
78
+ validateRetryInputs(backoffMs, maxDurationMs, options.maxRetries);
79
+ const effectiveBackoffMs = Math.max(CONNECTION_RETRY_MINIMUM_BACKOFF_MS, backoffMs);
80
+ const maxRetries = options.maxRetries ?? getDefaultMaxRetries(effectiveBackoffMs, maxDurationMs);
81
+ const deadline = Date.now() + maxDurationMs;
82
+ const retry = async (remainingRetries) => {
83
+ try {
84
+ return await runWithDeadline(fn, deadline - Date.now());
85
+ }
86
+ catch (err) {
87
+ if (!isConnectionLostError(err) || remainingRetries <= 0)
88
+ throw err;
89
+ const remainingMs = Math.max(0, deadline - Date.now());
90
+ if (remainingMs <= 0)
91
+ throw err;
92
+ await new Promise((resolve) => setTimeout(resolve, Math.min(effectiveBackoffMs, remainingMs)));
93
+ if (Date.now() >= deadline) {
94
+ throw new Error(CONNECTION_RETRY_BUDGET_EXCEEDED_MESSAGE, { cause: err });
95
+ }
96
+ return retry(remainingRetries - 1);
97
+ }
98
+ };
99
+ return retry(maxRetries).catch((err) => {
100
+ if (err instanceof Error && err.message === CONNECTION_RETRY_BUDGET_EXCEEDED_MESSAGE) {
101
+ throw new Error(`retryOnConnectionLost: ${CONNECTION_RETRY_BUDGET_EXCEEDED_MESSAGE}`, {
102
+ cause: err,
103
+ });
104
+ }
105
+ throw err;
106
+ });
107
+ }
@@ -0,0 +1,37 @@
1
+ import type { Page } from '@playwright/test';
2
+ /**
3
+ * Trigger pagination with a real scroll gesture.
4
+ *
5
+ * The pagination control gates `onLoadMore` behind a one-shot window `scroll`
6
+ * listener plus IntersectionObserver, so this wheels a viewport at a time
7
+ * until the sentinel is on screen. Do not use `scrollIntoViewIfNeeded()`:
8
+ * it is a no-op on an already-visible element and emits no `scroll` event
9
+ * (`playwright-no-scroll-into-view-sentinel`).
10
+ *
11
+ * After the sentinel is in view, wait for below-fold hydration and issue a
12
+ * net-zero extra scroll so a deferred listener still sees a live event.
13
+ *
14
+ * Probe `count()` before `boundingBox()` and bound `boundingBox()` to
15
+ * {@link BOUNDING_BOX_TIMEOUT_MS} so a detached sentinel cannot consume the
16
+ * action timeout. The loop is also bounded by
17
+ * {@link SCROLL_LOOP_BUDGET_MS}; a detached attempt waits up to
18
+ * {@link DETACHED_REMOUNT_WAIT_MS} for remount.
19
+ *
20
+ * The pagination control unmounts the sentinel when `hasNextPage` becomes false.
21
+ * If this helper already saw the sentinel attached (typically below the fold)
22
+ * and it stays gone after that remount wait, pagination already loaded the
23
+ * last page. Treating that as failure flakes the scroll-gated specs.
24
+ */
25
+ export declare function scrollToLoadMore(page: Page, { sentinelTestId }?: {
26
+ sentinelTestId?: string;
27
+ }): Promise<void>;
28
+ /**
29
+ * Force `main` to exceed the viewport height before hydration, so
30
+ * the pagination control's short-page escape hatch (which auto-loads when
31
+ * `document.documentElement.scrollHeight <= window.innerHeight`) cannot open
32
+ * the pagination gate on its own. Use this alongside `scrollToLoadMore(page)`
33
+ * so a scroll-triggered pagination test exercises the scroll-gated path
34
+ * deterministically rather than depending on whichever seeded content happens
35
+ * to render.
36
+ */
37
+ export declare function forceMainScrollableBeforeHydration(page: Page): Promise<void>;
@@ -0,0 +1,158 @@
1
+ import { waitForBelowFoldHydration } from "./wait-for-hydration.mjs";
2
+ const SENTINEL_TEST_ID = 'infinite-scroll-sentinel';
3
+ const MAX_SCROLL_ATTEMPTS = 30;
4
+ const POST_HYDRATION_SCROLL_RETRIES = 3;
5
+ const BOUNDING_BOX_TIMEOUT_MS = 2_000;
6
+ const SCROLL_LOOP_BUDGET_MS = 10_000;
7
+ const DETACHED_REMOUNT_WAIT_MS = 1_000;
8
+ function readScrollTop(page) {
9
+ return page.evaluate(() => globalThis.document.scrollingElement?.scrollTop ?? 0);
10
+ }
11
+ /**
12
+ * Trigger pagination with a real scroll gesture.
13
+ *
14
+ * The pagination control gates `onLoadMore` behind a one-shot window `scroll`
15
+ * listener plus IntersectionObserver, so this wheels a viewport at a time
16
+ * until the sentinel is on screen. Do not use `scrollIntoViewIfNeeded()`:
17
+ * it is a no-op on an already-visible element and emits no `scroll` event
18
+ * (`playwright-no-scroll-into-view-sentinel`).
19
+ *
20
+ * After the sentinel is in view, wait for below-fold hydration and issue a
21
+ * net-zero extra scroll so a deferred listener still sees a live event.
22
+ *
23
+ * Probe `count()` before `boundingBox()` and bound `boundingBox()` to
24
+ * {@link BOUNDING_BOX_TIMEOUT_MS} so a detached sentinel cannot consume the
25
+ * action timeout. The loop is also bounded by
26
+ * {@link SCROLL_LOOP_BUDGET_MS}; a detached attempt waits up to
27
+ * {@link DETACHED_REMOUNT_WAIT_MS} for remount.
28
+ *
29
+ * The pagination control unmounts the sentinel when `hasNextPage` becomes false.
30
+ * If this helper already saw the sentinel attached (typically below the fold)
31
+ * and it stays gone after that remount wait, pagination already loaded the
32
+ * last page. Treating that as failure flakes the scroll-gated specs.
33
+ */
34
+ export async function scrollToLoadMore(page, { sentinelTestId = SENTINEL_TEST_ID } = {}) {
35
+ const sentinel = page.getByTestId(sentinelTestId);
36
+ const viewport = page.viewportSize();
37
+ const centerX = (viewport?.width ?? 0) / 2;
38
+ const viewportHeight = viewport?.height ?? 0;
39
+ await page.mouse.move(centerX, viewportHeight / 2);
40
+ let sentinelInView = false;
41
+ let lastPageConsumedSentinel = false;
42
+ let sawSentinelAttached = false;
43
+ let lastCount = 0;
44
+ let lastBox = null;
45
+ const initialScrollTop = await readScrollTop(page);
46
+ const scrollTops = [initialScrollTop];
47
+ const attemptStates = [];
48
+ const loopDeadline = Date.now() + SCROLL_LOOP_BUDGET_MS;
49
+ for (let attempt = 0; attempt < MAX_SCROLL_ATTEMPTS && Date.now() < loopDeadline; attempt++) {
50
+ // oxlint-disable-next-line no-await-in-loop -- count() must resolve before deciding whether to probe further
51
+ lastCount = await sentinel.count();
52
+ if (lastCount > 0) {
53
+ sawSentinelAttached = true;
54
+ let boundingBoxTimedOut = false;
55
+ // oxlint-disable-next-line no-await-in-loop -- bounded so a count()/boundingBox() detach race can't consume the full action timeout
56
+ lastBox = await sentinel.boundingBox({ timeout: BOUNDING_BOX_TIMEOUT_MS }).catch(() => {
57
+ boundingBoxTimedOut = true;
58
+ return null;
59
+ });
60
+ if (lastBox && lastBox.y < viewportHeight) {
61
+ sentinelInView = true;
62
+ break;
63
+ }
64
+ attemptStates.push(lastBox ? 'below-fold' : boundingBoxTimedOut ? 'race-detach' : 'no-box');
65
+ }
66
+ else {
67
+ lastBox = null;
68
+ attemptStates.push('detached');
69
+ // oxlint-disable-next-line no-await-in-loop -- bounded wait gives a transient detach real time to remount
70
+ await sentinel
71
+ .waitFor({ state: 'attached', timeout: DETACHED_REMOUNT_WAIT_MS })
72
+ .catch(() => undefined);
73
+ // oxlint-disable-next-line no-await-in-loop -- remount vs last-page unmount must be distinguished before wheeling
74
+ lastCount = await sentinel.count();
75
+ if (lastCount > 0)
76
+ continue;
77
+ if (sawSentinelAttached) {
78
+ lastPageConsumedSentinel = true;
79
+ break;
80
+ }
81
+ }
82
+ // oxlint-disable-next-line no-await-in-loop -- scrolling all at once would overshoot the sentinel
83
+ await page.mouse.wheel(0, viewportHeight);
84
+ // oxlint-disable-next-line no-await-in-loop -- records this attempt's post-wheel position for diagnosis
85
+ scrollTops.push(await readScrollTop(page));
86
+ }
87
+ if (!sentinelInView && !lastPageConsumedSentinel) {
88
+ const documentState = await page.evaluate(() => ({
89
+ scrollHeight: globalThis.document.documentElement.scrollHeight,
90
+ innerHeight: globalThis.window
91
+ .innerHeight,
92
+ }));
93
+ const documentScrolled = scrollTops.at(-1) > initialScrollTop;
94
+ const tally = {
95
+ detached: 0,
96
+ 'race-detach': 0,
97
+ 'no-box': 0,
98
+ 'below-fold': 0,
99
+ };
100
+ for (const s of attemptStates)
101
+ tally[s] += 1;
102
+ const state = !documentScrolled
103
+ ? `the document never scrolled despite ${attemptStates.length} wheel events ` +
104
+ `(scrollTop stayed at ${initialScrollTop}) — the wheel target may have landed on a ` +
105
+ `nested scroll container instead of the document`
106
+ : tally.detached === attemptStates.length
107
+ ? `sentinel was detached from the DOM on every attempt (count()=0 all ` +
108
+ `${attemptStates.length} times) — it never (re)mounted during the scroll loop`
109
+ : `sentinel state varied across ${attemptStates.length} attempts: ` +
110
+ `${tally.detached} detached, ${tally['race-detach']} attached-but-boundingBox-timed-out, ` +
111
+ `${tally['no-box']} attached-but-invisible, ${tally['below-fold']} below-fold`;
112
+ throw new Error(`scrollToLoadMore: sentinel [data-testid="${sentinelTestId}"] did not enter the ` +
113
+ `viewport after ${attemptStates.length} scroll attempts: ${state}. ` +
114
+ `lastCount()=${lastCount}, lastBox=${JSON.stringify(lastBox)}, ` +
115
+ `scrollTop=${scrollTops[0]}->${scrollTops.at(-1)}, ` +
116
+ `documentScrollHeight=${documentState.scrollHeight}, windowInnerHeight=${documentState.innerHeight}`);
117
+ }
118
+ if (!sentinelInView)
119
+ return;
120
+ for (let retry = 0; retry < POST_HYDRATION_SCROLL_RETRIES; retry++) {
121
+ // oxlint-disable-next-line no-await-in-loop -- each retry must wait for hydration to catch up first
122
+ await waitForBelowFoldHydration(page);
123
+ // oxlint-disable-next-line no-await-in-loop -- must complete before the wheel-forward below
124
+ await page.mouse.wheel(0, -50);
125
+ // oxlint-disable-next-line no-await-in-loop -- closes the net-zero scroll pair for this retry
126
+ await page.mouse.wheel(0, 50);
127
+ }
128
+ }
129
+ /**
130
+ * Force `main` to exceed the viewport height before hydration, so
131
+ * the pagination control's short-page escape hatch (which auto-loads when
132
+ * `document.documentElement.scrollHeight <= window.innerHeight`) cannot open
133
+ * the pagination gate on its own. Use this alongside `scrollToLoadMore(page)`
134
+ * so a scroll-triggered pagination test exercises the scroll-gated path
135
+ * deterministically rather than depending on whichever seeded content happens
136
+ * to render.
137
+ */
138
+ export async function forceMainScrollableBeforeHydration(page) {
139
+ await page.addInitScript(() => {
140
+ const styleId = 'pw-force-scrollable-main';
141
+ const document = globalThis.document;
142
+ const installStyle = () => {
143
+ if (document.getElementById(styleId))
144
+ return;
145
+ const styleRoot = document.head ?? document.documentElement;
146
+ if (!styleRoot)
147
+ return;
148
+ const style = document.createElement('style');
149
+ style.id = styleId;
150
+ style.textContent = 'main { min-height: 180vh !important; }';
151
+ styleRoot.append(style);
152
+ };
153
+ if (document.readyState === 'loading') {
154
+ document.addEventListener('DOMContentLoaded', installStyle, { once: true });
155
+ }
156
+ installStyle();
157
+ });
158
+ }
@@ -0,0 +1,2 @@
1
+ import type { Page } from '@playwright/test';
2
+ export declare function storybookBundleHasStory(page: Page, id: string): Promise<boolean>;
@@ -0,0 +1,13 @@
1
+ export async function storybookBundleHasStory(page, id) {
2
+ let response;
3
+ try {
4
+ response = await page.request.get('/storybook/index.json', { timeout: 5000 });
5
+ }
6
+ catch {
7
+ return false;
8
+ }
9
+ if (!response.ok())
10
+ return false;
11
+ const storyIndex = (await response.json());
12
+ return id in (storyIndex.entries ?? {});
13
+ }
@@ -0,0 +1 @@
1
+ export declare const TEST_PNG: Buffer<ArrayBuffer>;
@@ -0,0 +1,2 @@
1
+ // Minimal 1x1 white PNG for image upload tests
2
+ export const TEST_PNG = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==', 'base64');
@@ -0,0 +1,11 @@
1
+ import type { FullConfig, Reporter, TestCase, TestResult } from '@playwright/test/reporter';
2
+ export default class TestLifecycleReporter implements Reporter {
3
+ static readonly modulePath: string;
4
+ private rootDir;
5
+ private shard;
6
+ onBegin(config: FullConfig): void;
7
+ onTestBegin(test: TestCase, result: TestResult): void;
8
+ onTestEnd(test: TestCase, result: TestResult): void;
9
+ printsToStdio(): boolean;
10
+ private record;
11
+ }
@@ -0,0 +1,35 @@
1
+ import { relative } from 'node:path';
2
+ export default class TestLifecycleReporter {
3
+ static modulePath = import.meta.filename;
4
+ rootDir = '';
5
+ shard = null;
6
+ onBegin(config) {
7
+ this.rootDir = config.rootDir;
8
+ this.shard = config.shard;
9
+ }
10
+ onTestBegin(test, result) {
11
+ this.record('begin', test, result);
12
+ }
13
+ onTestEnd(test, result) {
14
+ this.record('end', test, result);
15
+ }
16
+ printsToStdio() {
17
+ return true;
18
+ }
19
+ record(event, test, result) {
20
+ process.stdout.write(`${JSON.stringify({
21
+ marker: 'playwright-test-lifecycle',
22
+ event,
23
+ observedAt: new Date().toISOString(),
24
+ testId: test.id,
25
+ file: relative(this.rootDir, test.location.file),
26
+ line: test.location.line,
27
+ project: test.parent.project()?.name,
28
+ shard: this.shard,
29
+ retry: result.retry,
30
+ workerIndex: result.workerIndex,
31
+ parallelIndex: result.parallelIndex,
32
+ ...(event === 'end' ? { status: result.status, durationMs: result.duration } : {}),
33
+ })}\n`);
34
+ }
35
+ }
@@ -0,0 +1,6 @@
1
+ import type { Page } from '@playwright/test';
2
+ /**
3
+ * Generate a TOTP code using WebCrypto in the browser context.
4
+ * Uses SHA-1 HMAC with 6-digit output and 30-second period (RFC 6238).
5
+ */
6
+ export declare function generateTotpCode(page: Page, base32Secret: string): Promise<string>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Generate a TOTP code using WebCrypto in the browser context.
3
+ * Uses SHA-1 HMAC with 6-digit output and 30-second period (RFC 6238).
4
+ */
5
+ export function generateTotpCode(page, base32Secret) {
6
+ return page.evaluate(async (secret) => {
7
+ const BASE32 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
8
+ const BASE32_MAP = new Map(Array.from(BASE32).map((ch, i) => [ch, i]));
9
+ const upper = secret.toUpperCase().replace(/=+$/, '').replace(/\s/g, '');
10
+ let bits = '';
11
+ for (const c of upper) {
12
+ const idx = BASE32_MAP.get(c);
13
+ if (idx !== undefined)
14
+ bits += idx.toString(2).padStart(5, '0');
15
+ }
16
+ const bytes = [];
17
+ for (let i = 0; i + 8 <= bits.length; i += 8) {
18
+ bytes.push(parseInt(bits.slice(i, i + 8), 2));
19
+ }
20
+ const counter = Math.floor(Date.now() / 1000 / 30);
21
+ const counterBytes = new Uint8Array(8);
22
+ let rem = counter;
23
+ for (let i = 7; i >= 0; i--) {
24
+ counterBytes[i] = rem & 0xff;
25
+ rem = Math.floor(rem / 256);
26
+ }
27
+ const key = await crypto.subtle.importKey('raw', new Uint8Array(bytes), { name: 'HMAC', hash: 'SHA-1' }, false, ['sign']);
28
+ const sig = new Uint8Array(await crypto.subtle.sign('HMAC', key, counterBytes));
29
+ const offset = sig[19] & 0x0f;
30
+ const code = (((sig[offset] & 0x7f) << 24) |
31
+ ((sig[offset + 1] & 0xff) << 16) |
32
+ ((sig[offset + 2] & 0xff) << 8) |
33
+ (sig[offset + 3] & 0xff)) %
34
+ 1_000_000;
35
+ return String(code).padStart(6, '0');
36
+ }, base32Secret);
37
+ }
@@ -0,0 +1,8 @@
1
+ import type { Page } from '@playwright/test';
2
+ export declare const DEFAULT_TURNSTILE_STUB_TOKEN = "PLAYWRIGHT_TURNSTILE_TOKEN";
3
+ export declare const DEFAULT_TURNSTILE_STUB_ATTRIBUTE = "data-pw";
4
+ export interface TurnstileStubOptions {
5
+ attributeName?: string;
6
+ token?: string;
7
+ }
8
+ export declare function installTurnstileStub(page: Page, options?: TurnstileStubOptions): Promise<void>;