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.
- package/README.md +103 -12
- package/dist/agent-blackboard/index.d.mts +0 -1
- package/dist/agent-blackboard/index.mjs +0 -23
- package/dist/cli/commands/agent-blackboard-flags.d.mts +0 -1
- package/dist/cli/commands/agent-blackboard-flags.mjs +0 -9
- package/dist/cli/commands/agent-blackboard.d.mts +0 -2
- package/dist/cli/commands/agent-blackboard.mjs +7 -121
- package/dist/cli/commands/story-coverage.d.mts +2 -0
- package/dist/cli/commands/story-coverage.mjs +56 -0
- package/dist/cli/commands/worktree.d.mts +2 -0
- package/dist/cli/commands/worktree.mjs +21 -0
- package/dist/cli/index.mjs +9 -0
- package/dist/cli/parse-forwarded-commands.d.mts +6 -0
- package/dist/cli/parse-forwarded-commands.mjs +4 -0
- package/dist/cli/parse-story-coverage-fields.d.mts +19 -0
- package/dist/cli/parse-story-coverage-fields.mjs +69 -0
- package/dist/cli/parse-story-coverage.d.mts +8 -0
- package/dist/cli/parse-story-coverage.mjs +34 -0
- package/dist/cli/parse.d.mts +8 -1
- package/dist/cli/parse.mjs +3 -0
- package/dist/cli/usage.d.mts +1 -1
- package/dist/cli/usage.mjs +14 -7
- package/dist/git-worktrees/assess.d.mts +14 -0
- package/dist/git-worktrees/assess.mjs +68 -0
- package/dist/git-worktrees/list.d.mts +10 -0
- package/dist/git-worktrees/list.mjs +34 -0
- package/dist/git-worktrees/reclaim.d.mts +15 -0
- package/dist/git-worktrees/reclaim.mjs +80 -0
- package/dist/git-worktrees/reclaim.test-helpers.d.mts +16 -0
- package/dist/git-worktrees/reclaim.test-helpers.mjs +113 -0
- package/dist/git-worktrees/run.d.mts +13 -0
- package/dist/git-worktrees/run.mjs +50 -0
- package/dist/host-storage/check.d.mts +38 -0
- package/dist/host-storage/check.mjs +109 -0
- package/dist/host-storage/cli.d.mts +7 -0
- package/dist/host-storage/cli.mjs +102 -0
- package/dist/host-storage/host-storage.test-helpers.d.mts +26 -0
- package/dist/host-storage/host-storage.test-helpers.mjs +58 -0
- package/dist/host-storage/index.d.mts +3 -0
- package/dist/host-storage/index.mjs +3 -0
- package/dist/host-storage/preflight.d.mts +22 -0
- package/dist/host-storage/preflight.mjs +105 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/playwright/assertions.d.mts +1 -0
- package/dist/playwright/assertions.mjs +5 -0
- package/dist/playwright/blocked-external-network.d.mts +15 -0
- package/dist/playwright/blocked-external-network.mjs +73 -0
- package/dist/playwright/browser-dialog-issues.d.mts +12 -0
- package/dist/playwright/browser-dialog-issues.mjs +29 -0
- package/dist/playwright/browser-errors.d.mts +22 -0
- package/dist/playwright/browser-errors.mjs +130 -0
- package/dist/playwright/browser-issue-monitor.test-helpers.d.mts +31 -0
- package/dist/playwright/browser-issue-monitor.test-helpers.mjs +51 -0
- package/dist/playwright/browser-issue-records.d.mts +42 -0
- package/dist/playwright/browser-issue-records.mjs +148 -0
- package/dist/playwright/browser-test.d.mts +21 -0
- package/dist/playwright/browser-test.mjs +68 -0
- package/dist/playwright/expect-no-broken-images.d.mts +17 -0
- package/dist/playwright/expect-no-broken-images.mjs +39 -0
- package/dist/playwright/index.d.mts +30 -0
- package/dist/playwright/index.mjs +22 -0
- package/dist/playwright/mobile-assertions.d.mts +14 -0
- package/dist/playwright/mobile-assertions.mjs +43 -0
- package/dist/playwright/navigate-to.d.mts +27 -0
- package/dist/playwright/navigate-to.mjs +39 -0
- package/dist/playwright/radix-select.d.mts +18 -0
- package/dist/playwright/radix-select.mjs +19 -0
- package/dist/playwright/random-id.d.mts +34 -0
- package/dist/playwright/random-id.mjs +37 -0
- package/dist/playwright/retry-on-connection-lost.d.mts +7 -0
- package/dist/playwright/retry-on-connection-lost.mjs +107 -0
- package/dist/playwright/scroll-to-load-more.d.mts +37 -0
- package/dist/playwright/scroll-to-load-more.mjs +158 -0
- package/dist/playwright/storybook.d.mts +2 -0
- package/dist/playwright/storybook.mjs +13 -0
- package/dist/playwright/test-fixtures.d.mts +1 -0
- package/dist/playwright/test-fixtures.mjs +2 -0
- package/dist/playwright/test-lifecycle-reporter.d.mts +11 -0
- package/dist/playwright/test-lifecycle-reporter.mjs +35 -0
- package/dist/playwright/totp.d.mts +6 -0
- package/dist/playwright/totp.mjs +37 -0
- package/dist/playwright/turnstile-stub.d.mts +8 -0
- package/dist/playwright/turnstile-stub.mjs +61 -0
- package/dist/playwright/viewport-constants.d.mts +30 -0
- package/dist/playwright/viewport-constants.mjs +9 -0
- package/dist/playwright/virtual-authenticator.d.mts +5 -0
- package/dist/playwright/virtual-authenticator.mjs +15 -0
- package/dist/playwright/wait-for-hydration.d.mts +29 -0
- package/dist/playwright/wait-for-hydration.mjs +81 -0
- package/dist/shell-parse/ansi-c-string.d.mts +12 -0
- package/dist/shell-parse/ansi-c-string.mjs +80 -0
- package/dist/shell-parse/index.d.mts +20 -0
- package/dist/shell-parse/index.mjs +15 -0
- package/dist/shell-parse/shell-command-substitution-reads.d.mts +8 -0
- package/dist/shell-parse/shell-command-substitution-reads.mjs +53 -0
- package/dist/shell-parse/shell-command-substitutions.d.mts +8 -0
- package/dist/shell-parse/shell-command-substitutions.mjs +52 -0
- package/dist/shell-parse/shell-command-wrappers.d.mts +26 -0
- package/dist/shell-parse/shell-command-wrappers.mjs +143 -0
- package/dist/shell-parse/shell-commands.d.mts +24 -0
- package/dist/shell-parse/shell-commands.mjs +155 -0
- package/dist/shell-parse/shell-heredoc-delimiter.d.mts +5 -0
- package/dist/shell-parse/shell-heredoc-delimiter.mjs +52 -0
- package/dist/shell-parse/shell-heredoc-parser.d.mts +7 -0
- package/dist/shell-parse/shell-heredoc-parser.mjs +49 -0
- package/dist/shell-parse/shell-heredoc-quote-state.d.mts +19 -0
- package/dist/shell-parse/shell-heredoc-quote-state.mjs +40 -0
- package/dist/shell-parse/shell-heredoc.d.mts +10 -0
- package/dist/shell-parse/shell-heredoc.mjs +90 -0
- package/dist/shell-parse/shell-redirections.d.mts +5 -0
- package/dist/shell-parse/shell-redirections.mjs +34 -0
- package/dist/shell-parse/shell-script-operand.d.mts +13 -0
- package/dist/shell-parse/shell-script-operand.mjs +103 -0
- package/dist/shell-parse/shell-stdin-script.d.mts +6 -0
- package/dist/shell-parse/shell-stdin-script.mjs +61 -0
- package/dist/shell-parse/shell-token-utils.d.mts +9 -0
- package/dist/shell-parse/shell-token-utils.mjs +33 -0
- package/dist/shell-parse/shell-tokenizer-comments.d.mts +1 -0
- package/dist/shell-parse/shell-tokenizer-comments.mjs +57 -0
- package/dist/shell-parse/shell-tokenizer-operators.d.mts +14 -0
- package/dist/shell-parse/shell-tokenizer-operators.mjs +47 -0
- package/dist/shell-parse/shell-tokenizer.d.mts +12 -0
- package/dist/shell-parse/shell-tokenizer.mjs +104 -0
- package/dist/story-coverage/analyze.d.mts +8 -0
- package/dist/story-coverage/analyze.mjs +24 -0
- package/dist/story-coverage/check.d.mts +11 -0
- package/dist/story-coverage/check.mjs +42 -0
- package/dist/story-coverage/components.d.mts +10 -0
- package/dist/story-coverage/components.mjs +40 -0
- package/dist/story-coverage/coverage.d.mts +10 -0
- package/dist/story-coverage/coverage.mjs +43 -0
- package/dist/story-coverage/index.d.mts +13 -0
- package/dist/story-coverage/index.mjs +7 -0
- package/dist/story-coverage/messages.d.mts +10 -0
- package/dist/story-coverage/messages.mjs +42 -0
- package/dist/story-coverage/options.d.mts +27 -0
- package/dist/story-coverage/options.mjs +51 -0
- package/dist/story-coverage/workspace.d.mts +2 -0
- package/dist/story-coverage/workspace.mjs +27 -0
- package/dist/test-helpers/cancel-runs.test-helpers.d.mts +39 -0
- package/dist/test-helpers/cancel-runs.test-helpers.mjs +124 -0
- package/dist/test-helpers/run-bounded-exit-observer.test-helpers.d.mts +12 -0
- package/dist/test-helpers/run-bounded-exit-observer.test-helpers.mjs +68 -0
- package/dist/test-helpers/run-bounded-output-fixture.test-helpers.d.mts +18 -0
- package/dist/test-helpers/run-bounded-output-fixture.test-helpers.mjs +162 -0
- package/dist/vitest-diagnostics/index.d.mts +9 -1
- package/dist/vitest-diagnostics/index.mjs +5 -1
- package/dist/vitest-diagnostics/vitest-fake-timer-guard.d.mts +6 -0
- package/dist/vitest-diagnostics/vitest-fake-timer-guard.mjs +34 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-detection.d.mts +1 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-detection.mjs +8 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-diagnostics.d.mts +10 -1
- package/dist/vitest-diagnostics/vitest-fork-leak-diagnostics.mjs +43 -2
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake-samples.d.mts +50 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake-samples.mjs +69 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake.d.mts +19 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake.mjs +136 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-dns.d.mts +7 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-dns.mjs +54 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-host.d.mts +8 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-host.mjs +48 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-socket.d.mts +14 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-socket.mjs +39 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist.d.mts +7 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist.mjs +72 -0
- package/dist/vitest-diagnostics/vitest-process-resources.d.mts +6 -0
- package/dist/vitest-diagnostics/vitest-process-resources.mjs +51 -0
- package/dist/vitest-effective-timeout/cap.d.mts +9 -0
- package/dist/vitest-effective-timeout/cap.mjs +28 -0
- package/dist/vitest-effective-timeout/check-profiles.d.mts +15 -0
- package/dist/vitest-effective-timeout/check-profiles.mjs +52 -0
- package/dist/vitest-effective-timeout/config-file.d.mts +6 -0
- package/dist/vitest-effective-timeout/config-file.mjs +23 -0
- package/dist/vitest-effective-timeout/fixtures.d.mts +2 -0
- package/dist/vitest-effective-timeout/fixtures.mjs +18 -0
- package/dist/vitest-effective-timeout/index.d.mts +7 -0
- package/dist/vitest-effective-timeout/index.mjs +4 -0
- package/dist/vitest-effective-timeout/profiles.d.mts +10 -0
- package/dist/vitest-effective-timeout/profiles.mjs +33 -0
- package/dist/vitest-effective-timeout/run-profile.d.mts +31 -0
- package/dist/vitest-effective-timeout/run-profile.mjs +95 -0
- package/docs/mcp-server.md +2 -13
- package/package.json +32 -2
- package/scripts/__pycache__/run_bounded_process.cpython-312.pyc +0 -0
- package/scripts/chromium-launch-probe.d.mts +7 -0
- package/scripts/chromium-launch-probe.mjs +101 -0
- package/scripts/run-bounded-fixtures/run-bounded-backpressure.py +186 -0
- package/scripts/run-bounded-fixtures/run-bounded-merged-output.py +75 -0
- package/scripts/run-bounded-fixtures/run-bounded-reset-socket.py +25 -0
- package/scripts/run-bounded.py +199 -0
- package/scripts/run_bounded_process.py +129 -0
- package/scripts/worktree/git-index-lock.sh +16 -0
- package/scripts/worktree/git-worktrees.sh +23 -20
- package/scripts/worktree/reset-worktree-run.sh +199 -0
- package/scripts/worktree/reset-worktree.sh +122 -0
- package/skills/blackboard/SKILL.md +4 -64
- package/skills/stacked-prs/SKILL.md +1 -1
- package/skills/stacked-prs/references/drain.md +2 -2
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { createConsoleErrorIssue, createDialogIssue, createPageCrashIssue, createRequestFailedIssue, createWebErrorIssue, formatBrowserIssue, isBrowserSynthesizedResourceLoadError, isExpectedBrowserCancellation, isRetryableLocalConnectionLoss, matchesAllowlist, validateAllowlist, } from "./browser-issue-records.mjs";
|
|
2
|
+
const REACT_RENDER_WARNING_PATTERN = /hydration|Encountered a script tag|Text content (?:does|did) not match|prop\b.*\bdid not match\b|\bdid not match\.\s*Server\b|Warning: An update to/i;
|
|
3
|
+
export class BrowserIssueMonitor {
|
|
4
|
+
allowlist;
|
|
5
|
+
issues = [];
|
|
6
|
+
monitoredContexts = [];
|
|
7
|
+
testInfo;
|
|
8
|
+
warningPattern;
|
|
9
|
+
constructor(testInfo, options = {}) {
|
|
10
|
+
this.allowlist = options.allowlist ?? [];
|
|
11
|
+
this.warningPattern = options.warningPattern ?? REACT_RENDER_WARNING_PATTERN;
|
|
12
|
+
validateAllowlist(this.allowlist);
|
|
13
|
+
this.testInfo = testInfo;
|
|
14
|
+
}
|
|
15
|
+
monitorContext(context) {
|
|
16
|
+
if (this.monitoredContexts.some((monitored) => monitored.context === context))
|
|
17
|
+
return;
|
|
18
|
+
const consoleListener = (message) => {
|
|
19
|
+
if (
|
|
20
|
+
// `console.assert(false, ...)` fires a console event with type `assert`.
|
|
21
|
+
// We treat these the same as `console.error`: both are browser-side failures
|
|
22
|
+
// that should fail the test. Both are recorded as `type: 'consoleerror'` in the
|
|
23
|
+
// issue record, so allowlist entries of type `'consoleerror'` cover both.
|
|
24
|
+
(message.type() === 'assert' || message.type() === 'error') &&
|
|
25
|
+
!isBrowserSynthesizedResourceLoadError(message)) {
|
|
26
|
+
this.recordIssue(createConsoleErrorIssue(message));
|
|
27
|
+
}
|
|
28
|
+
else if (message.type() === 'warning') {
|
|
29
|
+
// Global and sticky patterns keep lastIndex between test() calls.
|
|
30
|
+
this.warningPattern.lastIndex = 0;
|
|
31
|
+
if (this.warningPattern.test(message.text())) {
|
|
32
|
+
this.recordIssue(createConsoleErrorIssue(message));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const webErrorListener = (webError) => {
|
|
37
|
+
this.recordIssue(createWebErrorIssue(webError));
|
|
38
|
+
};
|
|
39
|
+
const dialogListener = (dialog) => {
|
|
40
|
+
const issue = createDialogIssue(dialog);
|
|
41
|
+
if (!matchesAllowlist(issue, this.allowlist))
|
|
42
|
+
this.recordIssue(issue);
|
|
43
|
+
void dialog.dismiss().catch(() => undefined);
|
|
44
|
+
};
|
|
45
|
+
const requestFailedListener = (request) => {
|
|
46
|
+
this.recordIssue(createRequestFailedIssue(request));
|
|
47
|
+
};
|
|
48
|
+
const pages = [];
|
|
49
|
+
const monitorPage = (page) => {
|
|
50
|
+
if (pages.some((monitored) => monitored.page === page))
|
|
51
|
+
return;
|
|
52
|
+
const crashListener = () => {
|
|
53
|
+
this.recordIssue(createPageCrashIssue(page));
|
|
54
|
+
};
|
|
55
|
+
const closeListener = () => {
|
|
56
|
+
page.off('crash', crashListener);
|
|
57
|
+
page.off('close', closeListener);
|
|
58
|
+
const pageIndex = pages.findIndex((monitored) => monitored.page === page);
|
|
59
|
+
if (pageIndex !== -1) {
|
|
60
|
+
pages.splice(pageIndex, 1);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
page.on('crash', crashListener);
|
|
64
|
+
page.on('close', closeListener);
|
|
65
|
+
pages.push({ closeListener, crashListener, page });
|
|
66
|
+
};
|
|
67
|
+
context.on('console', consoleListener);
|
|
68
|
+
context.on('dialog', dialogListener);
|
|
69
|
+
context.on('page', monitorPage);
|
|
70
|
+
context.on('weberror', webErrorListener);
|
|
71
|
+
context.on('requestfailed', requestFailedListener);
|
|
72
|
+
for (const page of context.pages()) {
|
|
73
|
+
monitorPage(page);
|
|
74
|
+
}
|
|
75
|
+
this.monitoredContexts.push({
|
|
76
|
+
consoleListener,
|
|
77
|
+
context,
|
|
78
|
+
dialogListener,
|
|
79
|
+
pageListener: monitorPage,
|
|
80
|
+
pages,
|
|
81
|
+
requestFailedListener,
|
|
82
|
+
webErrorListener,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
dispose() {
|
|
86
|
+
for (const monitored of this.monitoredContexts.splice(0)) {
|
|
87
|
+
const { context } = monitored;
|
|
88
|
+
context.off('console', monitored.consoleListener);
|
|
89
|
+
context.off('dialog', monitored.dialogListener);
|
|
90
|
+
context.off('page', monitored.pageListener);
|
|
91
|
+
context.off('weberror', monitored.webErrorListener);
|
|
92
|
+
context.off('requestfailed', monitored.requestFailedListener);
|
|
93
|
+
for (const monitoredPage of monitored.pages) {
|
|
94
|
+
monitoredPage.page.off('crash', monitoredPage.crashListener);
|
|
95
|
+
monitoredPage.page.off('close', monitoredPage.closeListener);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async attachIssuesIfAny() {
|
|
100
|
+
if (this.issues.length === 0)
|
|
101
|
+
return false;
|
|
102
|
+
await this.testInfo.attach('browser-issues.txt', {
|
|
103
|
+
body: Buffer.from(this.formatIssues()),
|
|
104
|
+
contentType: 'text/plain',
|
|
105
|
+
});
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
async assertNoIssues() {
|
|
109
|
+
if (!(await this.attachIssuesIfAny()))
|
|
110
|
+
return;
|
|
111
|
+
const issueCount = this.issues.length;
|
|
112
|
+
const issueWord = issueCount === 1 ? 'issue' : 'issues';
|
|
113
|
+
throw new Error(`Unhandled browser ${issueWord} detected (${issueCount}). See browser-issues.txt attachment.\n\n${this.formatIssueSummary()}`);
|
|
114
|
+
}
|
|
115
|
+
formatIssues() {
|
|
116
|
+
return this.issues.map(formatBrowserIssue).join('\n\n---\n\n');
|
|
117
|
+
}
|
|
118
|
+
formatIssueSummary() {
|
|
119
|
+
return this.issues.slice(0, 3).map(formatBrowserIssue).join('\n\n---\n\n');
|
|
120
|
+
}
|
|
121
|
+
recordIssue(issue) {
|
|
122
|
+
if (isExpectedBrowserCancellation(issue))
|
|
123
|
+
return;
|
|
124
|
+
if (isRetryableLocalConnectionLoss(issue))
|
|
125
|
+
return;
|
|
126
|
+
if (matchesAllowlist(issue, this.allowlist))
|
|
127
|
+
return;
|
|
128
|
+
this.issues.push(issue);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Page, Request, TestInfo } from '@playwright/test';
|
|
2
|
+
type Listener = (...args: never[]) => void;
|
|
3
|
+
declare class MockBrowserContext {
|
|
4
|
+
readonly listeners: Map<string, Set<Listener>>;
|
|
5
|
+
emit(event: string, ...args: never[]): void;
|
|
6
|
+
off(event: string, listener: Listener): this;
|
|
7
|
+
on(event: string, listener: Listener): this;
|
|
8
|
+
pages(): never[];
|
|
9
|
+
}
|
|
10
|
+
declare function createTestInfo(): {
|
|
11
|
+
attach: import("vitest").Mock<(name: string, options: {
|
|
12
|
+
body: Buffer;
|
|
13
|
+
contentType: string;
|
|
14
|
+
}) => Promise<void>>;
|
|
15
|
+
attachments: {
|
|
16
|
+
body: Buffer;
|
|
17
|
+
contentType: string;
|
|
18
|
+
name: string;
|
|
19
|
+
}[];
|
|
20
|
+
testInfo: TestInfo;
|
|
21
|
+
};
|
|
22
|
+
declare function createPage(url?: string): Page;
|
|
23
|
+
declare function createRequest(overrides?: Partial<{
|
|
24
|
+
failureText: null | string;
|
|
25
|
+
frameThrows: boolean;
|
|
26
|
+
frameUrl: string;
|
|
27
|
+
method: string;
|
|
28
|
+
resourceType: string;
|
|
29
|
+
url: string;
|
|
30
|
+
}>): Request;
|
|
31
|
+
export { createPage, createRequest, createTestInfo, MockBrowserContext };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { vi } from 'vitest';
|
|
2
|
+
class MockBrowserContext {
|
|
3
|
+
listeners = new Map();
|
|
4
|
+
emit(event, ...args) {
|
|
5
|
+
for (const listener of this.listeners.get(event) ?? []) {
|
|
6
|
+
listener(...args);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
off(event, listener) {
|
|
10
|
+
this.listeners.get(event)?.delete(listener);
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
on(event, listener) {
|
|
14
|
+
const listeners = this.listeners.get(event) ?? new Set();
|
|
15
|
+
listeners.add(listener);
|
|
16
|
+
this.listeners.set(event, listeners);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
pages() {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function createTestInfo() {
|
|
24
|
+
const attachments = [];
|
|
25
|
+
const attach = vi.fn((name, options) => {
|
|
26
|
+
attachments.push({ name, ...options });
|
|
27
|
+
return Promise.resolve();
|
|
28
|
+
});
|
|
29
|
+
const testInfo = { attach };
|
|
30
|
+
return { attach, attachments, testInfo };
|
|
31
|
+
}
|
|
32
|
+
function createPage(url = 'http://localhost:8787/path') {
|
|
33
|
+
return {
|
|
34
|
+
url: () => url,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function createRequest(overrides = {}) {
|
|
38
|
+
const { failureText = 'net::ERR_FAILED', frameThrows = false, frameUrl = 'http://localhost:8787/frame', method = 'GET', resourceType = 'script', url = 'https://example.com/script.js', } = overrides;
|
|
39
|
+
return {
|
|
40
|
+
failure: () => (failureText === null ? null : { errorText: failureText }),
|
|
41
|
+
frame: () => {
|
|
42
|
+
if (frameThrows)
|
|
43
|
+
throw new Error('frame unavailable');
|
|
44
|
+
return { url: () => frameUrl };
|
|
45
|
+
},
|
|
46
|
+
method: () => method,
|
|
47
|
+
resourceType: () => resourceType,
|
|
48
|
+
url: () => url,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export { createPage, createRequest, createTestInfo, MockBrowserContext };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ConsoleMessage, Page, Request, WebError } from '@playwright/test';
|
|
2
|
+
import { type BrowserDialogIssue } from './browser-dialog-issues.mts';
|
|
3
|
+
type BrowserWebErrorIssue = {
|
|
4
|
+
error: Error;
|
|
5
|
+
pageUrl: string;
|
|
6
|
+
type: 'weberror';
|
|
7
|
+
};
|
|
8
|
+
type BrowserRequestFailedIssue = {
|
|
9
|
+
failureText: string;
|
|
10
|
+
frameUrl: string;
|
|
11
|
+
method: string;
|
|
12
|
+
resourceType: string;
|
|
13
|
+
type: 'requestfailed';
|
|
14
|
+
url: string;
|
|
15
|
+
};
|
|
16
|
+
type BrowserConsoleErrorIssue = {
|
|
17
|
+
location: string;
|
|
18
|
+
pageUrl: string;
|
|
19
|
+
text: string;
|
|
20
|
+
type: 'consoleerror';
|
|
21
|
+
};
|
|
22
|
+
type BrowserPageCrashIssue = {
|
|
23
|
+
pageUrl: string;
|
|
24
|
+
type: 'pagecrash';
|
|
25
|
+
};
|
|
26
|
+
export type BrowserIssue = BrowserConsoleErrorIssue | BrowserDialogIssue | BrowserPageCrashIssue | BrowserRequestFailedIssue | BrowserWebErrorIssue;
|
|
27
|
+
export type BrowserIssueAllowlistEntry = {
|
|
28
|
+
pattern: RegExp;
|
|
29
|
+
reason: string;
|
|
30
|
+
type: BrowserIssue['type'];
|
|
31
|
+
};
|
|
32
|
+
export { createDialogIssue } from './browser-dialog-issues.mts';
|
|
33
|
+
export declare function validateAllowlist(entries: BrowserIssueAllowlistEntry[]): void;
|
|
34
|
+
export declare function createWebErrorIssue(webError: WebError): BrowserWebErrorIssue;
|
|
35
|
+
export declare function createRequestFailedIssue(request: Request): BrowserRequestFailedIssue;
|
|
36
|
+
export declare function createConsoleErrorIssue(message: ConsoleMessage): BrowserConsoleErrorIssue;
|
|
37
|
+
export declare function createPageCrashIssue(page: Page): BrowserPageCrashIssue;
|
|
38
|
+
export declare function formatBrowserIssue(issue: BrowserIssue): string;
|
|
39
|
+
export declare function matchesAllowlist(issue: BrowserIssue, allowlist: BrowserIssueAllowlistEntry[]): boolean;
|
|
40
|
+
export declare function isExpectedBrowserCancellation(issue: BrowserIssue): boolean;
|
|
41
|
+
export declare function isBrowserSynthesizedResourceLoadError(message: ConsoleMessage): boolean;
|
|
42
|
+
export declare function isRetryableLocalConnectionLoss(issue: BrowserIssue): boolean;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { formatBrowserDialogIssue, getBrowserDialogIssueSearchableValues, getPageUrl, } from "./browser-dialog-issues.mjs";
|
|
2
|
+
export { createDialogIssue } from "./browser-dialog-issues.mjs";
|
|
3
|
+
export function validateAllowlist(entries) {
|
|
4
|
+
for (const entry of entries) {
|
|
5
|
+
if (!entry.reason.trim()) {
|
|
6
|
+
throw new Error(`Browser issue allowlist entry for ${entry.pattern} must include a reason`);
|
|
7
|
+
}
|
|
8
|
+
const probeValues = [
|
|
9
|
+
'',
|
|
10
|
+
'unrelated browser issue probe',
|
|
11
|
+
'https://example.invalid/unrelated-probe',
|
|
12
|
+
];
|
|
13
|
+
// The empty probe is skipped so patterns such as /./ and /.+/ are still rejected.
|
|
14
|
+
const matchesEveryProbe = probeValues.filter(Boolean).every((value) => {
|
|
15
|
+
entry.pattern.lastIndex = 0;
|
|
16
|
+
return entry.pattern.test(value);
|
|
17
|
+
});
|
|
18
|
+
if (matchesEveryProbe) {
|
|
19
|
+
throw new Error(`Browser issue allowlist entry for ${entry.pattern} is too broad`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function getRequestFrameUrl(request) {
|
|
24
|
+
try {
|
|
25
|
+
return request.frame().url();
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return '(frame URL unavailable)';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function createWebErrorIssue(webError) {
|
|
32
|
+
return {
|
|
33
|
+
error: webError.error(),
|
|
34
|
+
pageUrl: getPageUrl(webError.page()),
|
|
35
|
+
type: 'weberror',
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function createRequestFailedIssue(request) {
|
|
39
|
+
return {
|
|
40
|
+
failureText: request.failure()?.errorText ?? '(no failure text)',
|
|
41
|
+
frameUrl: getRequestFrameUrl(request),
|
|
42
|
+
method: request.method(),
|
|
43
|
+
resourceType: request.resourceType(),
|
|
44
|
+
type: 'requestfailed',
|
|
45
|
+
url: request.url(),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function createConsoleErrorIssue(message) {
|
|
49
|
+
const location = message.location();
|
|
50
|
+
const coordinates = `${location.lineNumber}:${location.columnNumber}`;
|
|
51
|
+
return {
|
|
52
|
+
location: location.url ? `${location.url}:${coordinates}` : coordinates,
|
|
53
|
+
pageUrl: getPageUrl(message.page()),
|
|
54
|
+
text: message.text(),
|
|
55
|
+
type: 'consoleerror',
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export function createPageCrashIssue(page) {
|
|
59
|
+
return { pageUrl: getPageUrl(page), type: 'pagecrash' };
|
|
60
|
+
}
|
|
61
|
+
export function formatBrowserIssue(issue) {
|
|
62
|
+
if (issue.type === 'consoleerror') {
|
|
63
|
+
return [
|
|
64
|
+
'[consoleerror]',
|
|
65
|
+
`Page: ${issue.pageUrl}`,
|
|
66
|
+
`Location: ${issue.location}`,
|
|
67
|
+
issue.text,
|
|
68
|
+
].join('\n');
|
|
69
|
+
}
|
|
70
|
+
if (issue.type === 'weberror') {
|
|
71
|
+
return [
|
|
72
|
+
'[weberror]',
|
|
73
|
+
`Page: ${issue.pageUrl}`,
|
|
74
|
+
`Message: ${issue.error.message}`,
|
|
75
|
+
issue.error.stack ?? issue.error.message,
|
|
76
|
+
].join('\n');
|
|
77
|
+
}
|
|
78
|
+
if (issue.type === 'dialog') {
|
|
79
|
+
return formatBrowserDialogIssue(issue);
|
|
80
|
+
}
|
|
81
|
+
if (issue.type === 'pagecrash') {
|
|
82
|
+
return ['[pagecrash]', `Page: ${issue.pageUrl}`, 'The browser page crashed.'].join('\n');
|
|
83
|
+
}
|
|
84
|
+
return [
|
|
85
|
+
'[requestfailed]',
|
|
86
|
+
`${issue.method} ${issue.url}`,
|
|
87
|
+
`Resource: ${issue.resourceType}`,
|
|
88
|
+
`Frame: ${issue.frameUrl}`,
|
|
89
|
+
`Failure: ${issue.failureText}`,
|
|
90
|
+
].join('\n');
|
|
91
|
+
}
|
|
92
|
+
export function matchesAllowlist(issue, allowlist) {
|
|
93
|
+
const searchableValues = issue.type === 'requestfailed'
|
|
94
|
+
? [issue.url, issue.failureText, issue.frameUrl, issue.resourceType]
|
|
95
|
+
: issue.type === 'consoleerror'
|
|
96
|
+
? [issue.text, issue.pageUrl, issue.location]
|
|
97
|
+
: issue.type === 'dialog'
|
|
98
|
+
? getBrowserDialogIssueSearchableValues(issue)
|
|
99
|
+
: issue.type === 'weberror'
|
|
100
|
+
? [issue.error?.message ?? '', issue.pageUrl]
|
|
101
|
+
: [issue.pageUrl];
|
|
102
|
+
return allowlist.some((entry) => {
|
|
103
|
+
if (entry.type !== issue.type)
|
|
104
|
+
return false;
|
|
105
|
+
return searchableValues.some((value) => {
|
|
106
|
+
entry.pattern.lastIndex = 0;
|
|
107
|
+
return entry.pattern.test(value);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
export function isExpectedBrowserCancellation(issue) {
|
|
112
|
+
return issue.type === 'requestfailed' && issue.failureText === 'net::ERR_ABORTED';
|
|
113
|
+
}
|
|
114
|
+
export function isBrowserSynthesizedResourceLoadError(message) {
|
|
115
|
+
if (!message.text().startsWith('Failed to load resource: '))
|
|
116
|
+
return false;
|
|
117
|
+
const location = message.location();
|
|
118
|
+
if (location.lineNumber !== 0 || location.columnNumber !== 0)
|
|
119
|
+
return false;
|
|
120
|
+
// JS/CSS/WASM assets that 404 don't emit requestfailed, so let those through
|
|
121
|
+
// so that broken chunk loads are still detectable.
|
|
122
|
+
if (/\.(?:js|mjs|css|wasm)(?:[?#]|$)/i.test(location.url))
|
|
123
|
+
return false;
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
function isLocalUrl(value) {
|
|
127
|
+
try {
|
|
128
|
+
const { hostname } = new URL(value);
|
|
129
|
+
const normalizedHostname = hostname.replace(/^\[(.*)]$/, '$1');
|
|
130
|
+
return ['', 'localhost', '127.0.0.1', '::1'].includes(normalizedHostname);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export function isRetryableLocalConnectionLoss(issue) {
|
|
137
|
+
if (issue.type !== 'requestfailed')
|
|
138
|
+
return false;
|
|
139
|
+
const isLocalRequest = isLocalUrl(issue.url) &&
|
|
140
|
+
(issue.frameUrl === '(frame URL unavailable)' || isLocalUrl(issue.frameUrl));
|
|
141
|
+
if (!isLocalRequest)
|
|
142
|
+
return false;
|
|
143
|
+
if (issue.failureText === 'net::ERR_NETWORK_CHANGED')
|
|
144
|
+
return true;
|
|
145
|
+
return (issue.resourceType === 'document' &&
|
|
146
|
+
(issue.failureText === 'net::ERR_CONNECTION_RESET' ||
|
|
147
|
+
issue.failureText === 'net::ERR_CONNECTION_REFUSED'));
|
|
148
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { expect, type Browser, type BrowserContext, type Page, type TestInfo } from '@playwright/test';
|
|
2
|
+
import { BrowserIssueMonitor } from './browser-errors.mts';
|
|
3
|
+
import type { BrowserIssueAllowlistEntry } from './browser-issue-records.mts';
|
|
4
|
+
import { type BlockedExternalNetworkRule } from './blocked-external-network.mts';
|
|
5
|
+
export interface BrowserTestOptions {
|
|
6
|
+
allowlist?: readonly BrowserIssueAllowlistEntry[];
|
|
7
|
+
assertTimeout?: (timeout: number, label: string) => void;
|
|
8
|
+
/** Replaces the default GTM/GA/DoubleClick rules; spread BLOCKED_EXTERNAL_NETWORK_RULES to extend them. */
|
|
9
|
+
rules?: readonly BlockedExternalNetworkRule[];
|
|
10
|
+
warningPattern?: RegExp;
|
|
11
|
+
}
|
|
12
|
+
interface BrowserErrorFixtures {
|
|
13
|
+
browserErrors: BrowserIssueMonitor;
|
|
14
|
+
}
|
|
15
|
+
export declare function createBrowserErrorsFixture(options?: BrowserTestOptions): ({ context }: {
|
|
16
|
+
context: BrowserContext;
|
|
17
|
+
}, run: (monitor: BrowserIssueMonitor) => Promise<void>, testInfo: TestInfo) => Promise<void>;
|
|
18
|
+
export declare function createBrowserTest(options?: BrowserTestOptions): import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & BrowserErrorFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
19
|
+
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & BrowserErrorFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
20
|
+
export { expect };
|
|
21
|
+
export declare function withMonitoredPage<T>(browserOrContext: Browser | BrowserContext, testInfo: TestInfo, callback: (page: Page) => Promise<T>, options?: BrowserTestOptions): Promise<T>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { expect, test as base, } from '@playwright/test';
|
|
2
|
+
import { BrowserIssueMonitor } from "./browser-errors.mjs";
|
|
3
|
+
import { BLOCKED_EXTERNAL_NETWORK_RULES, blockedExternalRequestFailureAllowlist, installBlockedExternalNetwork, } from "./blocked-external-network.mjs";
|
|
4
|
+
function monitorOptions(options) {
|
|
5
|
+
const allowlist = [
|
|
6
|
+
...(options.allowlist ?? blockedExternalRequestFailureAllowlist([], options.rules)),
|
|
7
|
+
];
|
|
8
|
+
if (options.warningPattern === undefined)
|
|
9
|
+
return { allowlist };
|
|
10
|
+
return { allowlist, warningPattern: options.warningPattern };
|
|
11
|
+
}
|
|
12
|
+
export function createBrowserErrorsFixture(options = {}) {
|
|
13
|
+
const rules = options.rules ?? BLOCKED_EXTERNAL_NETWORK_RULES;
|
|
14
|
+
return async function browserErrorsFixture({ context }, run, testInfo) {
|
|
15
|
+
options.assertTimeout?.(testInfo.timeout, 'Playwright effective test timeout');
|
|
16
|
+
const monitor = new BrowserIssueMonitor(testInfo, monitorOptions(options));
|
|
17
|
+
await installBlockedExternalNetwork(context, rules);
|
|
18
|
+
monitor.monitorContext(context);
|
|
19
|
+
try {
|
|
20
|
+
try {
|
|
21
|
+
await run(monitor);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
await monitor.attachIssuesIfAny();
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
if (testInfo.status === testInfo.expectedStatus)
|
|
28
|
+
await monitor.assertNoIssues();
|
|
29
|
+
else
|
|
30
|
+
await monitor.attachIssuesIfAny();
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
monitor.dispose();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function createBrowserTest(options = {}) {
|
|
38
|
+
return base.extend({
|
|
39
|
+
browserErrors: [createBrowserErrorsFixture(options), { auto: true }],
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export const test = createBrowserTest();
|
|
43
|
+
export { expect };
|
|
44
|
+
export async function withMonitoredPage(browserOrContext, testInfo, callback, options = {}) {
|
|
45
|
+
options.assertTimeout?.(testInfo.timeout, 'Playwright effective test timeout');
|
|
46
|
+
const monitor = new BrowserIssueMonitor(testInfo, monitorOptions(options));
|
|
47
|
+
const page = await browserOrContext.newPage();
|
|
48
|
+
let removeRoutes;
|
|
49
|
+
try {
|
|
50
|
+
removeRoutes = await installBlockedExternalNetwork(page.context(), options.rules ?? BLOCKED_EXTERNAL_NETWORK_RULES);
|
|
51
|
+
monitor.monitorContext(page.context());
|
|
52
|
+
let result;
|
|
53
|
+
try {
|
|
54
|
+
result = await callback(page);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
await monitor.attachIssuesIfAny();
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
await monitor.assertNoIssues();
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
monitor.dispose();
|
|
65
|
+
await removeRoutes?.();
|
|
66
|
+
await page.close().catch(() => undefined);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Page } from '@playwright/test';
|
|
2
|
+
interface ImageResponseGuard {
|
|
3
|
+
assertNoImageFailures(): void;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Registers response and requestfailed listeners on `page` to record any image
|
|
7
|
+
* requests that fail at the network level or return a non-2xx HTTP status.
|
|
8
|
+
*
|
|
9
|
+
* Call once at the top of a test, then call `assertNoImageFailures()` after the
|
|
10
|
+
* interaction under test completes. This is the network-level gate — it catches
|
|
11
|
+
* off-screen and lazy-loaded images that a visible-element poll cannot see.
|
|
12
|
+
*
|
|
13
|
+
* Any image failure during the test surfaces here. Ignore a known-flaky host in
|
|
14
|
+
* the caller's network policy instead of suppressing the error here.
|
|
15
|
+
*/
|
|
16
|
+
export declare function installImageResponseGuard(page: Page): ImageResponseGuard;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers response and requestfailed listeners on `page` to record any image
|
|
3
|
+
* requests that fail at the network level or return a non-2xx HTTP status.
|
|
4
|
+
*
|
|
5
|
+
* Call once at the top of a test, then call `assertNoImageFailures()` after the
|
|
6
|
+
* interaction under test completes. This is the network-level gate — it catches
|
|
7
|
+
* off-screen and lazy-loaded images that a visible-element poll cannot see.
|
|
8
|
+
*
|
|
9
|
+
* Any image failure during the test surfaces here. Ignore a known-flaky host in
|
|
10
|
+
* the caller's network policy instead of suppressing the error here.
|
|
11
|
+
*/
|
|
12
|
+
export function installImageResponseGuard(page) {
|
|
13
|
+
const failures = [];
|
|
14
|
+
// Treat 2xx (success) and 3xx (304 Not Modified, redirect hops) as healthy — Playwright
|
|
15
|
+
// emits a response event for each hop, and the terminal response is what matters.
|
|
16
|
+
page.on('response', (response) => {
|
|
17
|
+
const status = response.status();
|
|
18
|
+
if (status >= 200 && status < 400)
|
|
19
|
+
return;
|
|
20
|
+
if (response.request().resourceType() === 'image') {
|
|
21
|
+
failures.push({ url: response.url(), status });
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
page.on('requestfailed', (request) => {
|
|
25
|
+
if (request.resourceType() === 'image') {
|
|
26
|
+
failures.push({ url: request.url(), status: null });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
assertNoImageFailures() {
|
|
31
|
+
if (failures.length === 0)
|
|
32
|
+
return;
|
|
33
|
+
const details = failures
|
|
34
|
+
.map((failure) => ` ${failure.status ?? 'failed'} ${failure.url}`)
|
|
35
|
+
.join('\n');
|
|
36
|
+
throw new Error(`${failures.length} image(s) failed to load:\n${details}`);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import TestLifecycleReporter from './test-lifecycle-reporter.mts';
|
|
2
|
+
export { BrowserIssueMonitor } from './browser-errors.mts';
|
|
3
|
+
export type { BrowserIssueAllowlistEntry } from './browser-issue-records.mts';
|
|
4
|
+
export { createDialogIssue, formatBrowserDialogIssue, getBrowserDialogIssueSearchableValues, getPageUrl, } from './browser-dialog-issues.mts';
|
|
5
|
+
export type { BrowserDialogIssue } from './browser-dialog-issues.mts';
|
|
6
|
+
export { createConsoleErrorIssue, createPageCrashIssue, createRequestFailedIssue, createWebErrorIssue, formatBrowserIssue, isBrowserSynthesizedResourceLoadError, isExpectedBrowserCancellation, isRetryableLocalConnectionLoss, matchesAllowlist, validateAllowlist, } from './browser-issue-records.mts';
|
|
7
|
+
export type { BrowserIssue } from './browser-issue-records.mts';
|
|
8
|
+
export { BLOCKED_EXTERNAL_NETWORK_RULES, blockedExternalRequestFailureAllowlist, installBlockedExternalNetwork, isBlockedExternalNetworkUrl, } from './blocked-external-network.mts';
|
|
9
|
+
export type { BlockedExternalNetworkRule } from './blocked-external-network.mts';
|
|
10
|
+
export { createBrowserErrorsFixture, createBrowserTest, expect, test, withMonitoredPage, } from './browser-test.mts';
|
|
11
|
+
export type { BrowserTestOptions } from './browser-test.mts';
|
|
12
|
+
export type { Browser, BrowserContext, Locator, Page, Request, TestInfo } from '@playwright/test';
|
|
13
|
+
export { navigateTo } from './navigate-to.mts';
|
|
14
|
+
export { retryOnConnectionLost } from './retry-on-connection-lost.mts';
|
|
15
|
+
export { forceMainScrollableBeforeHydration, scrollToLoadMore } from './scroll-to-load-more.mts';
|
|
16
|
+
export { DEFAULT_TURNSTILE_STUB_ATTRIBUTE, DEFAULT_TURNSTILE_STUB_TOKEN, installTurnstileStub, } from './turnstile-stub.mts';
|
|
17
|
+
export type { TurnstileStubOptions } from './turnstile-stub.mts';
|
|
18
|
+
export { waitForBelowFoldHydration } from './wait-for-hydration.mts';
|
|
19
|
+
export { requireTestValue } from './assertions.mts';
|
|
20
|
+
export { installImageResponseGuard } from './expect-no-broken-images.mts';
|
|
21
|
+
export { assertNoHorizontalScroll, getHorizontalOverflowState } from './mobile-assertions.mts';
|
|
22
|
+
export type { HorizontalOverflowState } from './mobile-assertions.mts';
|
|
23
|
+
export { openRadixDropdown } from './radix-select.mts';
|
|
24
|
+
export { randomSuffix } from './random-id.mts';
|
|
25
|
+
export { storybookBundleHasStory } from './storybook.mts';
|
|
26
|
+
export { TEST_PNG } from './test-fixtures.mts';
|
|
27
|
+
export { TestLifecycleReporter };
|
|
28
|
+
export { generateTotpCode } from './totp.mts';
|
|
29
|
+
export { DESKTOP_VIEWPORT, MOBILE_VIEWPORTS } from './viewport-constants.mts';
|
|
30
|
+
export { setupVirtualAuthenticator } from './virtual-authenticator.mts';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import TestLifecycleReporter from "./test-lifecycle-reporter.mjs";
|
|
2
|
+
export { BrowserIssueMonitor } from "./browser-errors.mjs";
|
|
3
|
+
export { createDialogIssue, formatBrowserDialogIssue, getBrowserDialogIssueSearchableValues, getPageUrl, } from "./browser-dialog-issues.mjs";
|
|
4
|
+
export { createConsoleErrorIssue, createPageCrashIssue, createRequestFailedIssue, createWebErrorIssue, formatBrowserIssue, isBrowserSynthesizedResourceLoadError, isExpectedBrowserCancellation, isRetryableLocalConnectionLoss, matchesAllowlist, validateAllowlist, } from "./browser-issue-records.mjs";
|
|
5
|
+
export { BLOCKED_EXTERNAL_NETWORK_RULES, blockedExternalRequestFailureAllowlist, installBlockedExternalNetwork, isBlockedExternalNetworkUrl, } from "./blocked-external-network.mjs";
|
|
6
|
+
export { createBrowserErrorsFixture, createBrowserTest, expect, test, withMonitoredPage, } from "./browser-test.mjs";
|
|
7
|
+
export { navigateTo } from "./navigate-to.mjs";
|
|
8
|
+
export { retryOnConnectionLost } from "./retry-on-connection-lost.mjs";
|
|
9
|
+
export { forceMainScrollableBeforeHydration, scrollToLoadMore } from "./scroll-to-load-more.mjs";
|
|
10
|
+
export { DEFAULT_TURNSTILE_STUB_ATTRIBUTE, DEFAULT_TURNSTILE_STUB_TOKEN, installTurnstileStub, } from "./turnstile-stub.mjs";
|
|
11
|
+
export { waitForBelowFoldHydration } from "./wait-for-hydration.mjs";
|
|
12
|
+
export { requireTestValue } from "./assertions.mjs";
|
|
13
|
+
export { installImageResponseGuard } from "./expect-no-broken-images.mjs";
|
|
14
|
+
export { assertNoHorizontalScroll, getHorizontalOverflowState } from "./mobile-assertions.mjs";
|
|
15
|
+
export { openRadixDropdown } from "./radix-select.mjs";
|
|
16
|
+
export { randomSuffix } from "./random-id.mjs";
|
|
17
|
+
export { storybookBundleHasStory } from "./storybook.mjs";
|
|
18
|
+
export { TEST_PNG } from "./test-fixtures.mjs";
|
|
19
|
+
export { TestLifecycleReporter };
|
|
20
|
+
export { generateTotpCode } from "./totp.mjs";
|
|
21
|
+
export { DESKTOP_VIEWPORT, MOBILE_VIEWPORTS } from "./viewport-constants.mjs";
|
|
22
|
+
export { setupVirtualAuthenticator } from "./virtual-authenticator.mjs";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Page } from '@playwright/test';
|
|
2
|
+
export interface HorizontalOverflowState {
|
|
3
|
+
overflow: boolean;
|
|
4
|
+
scrollWidth: number;
|
|
5
|
+
clientWidth: number;
|
|
6
|
+
offenders: Array<{
|
|
7
|
+
tag: string;
|
|
8
|
+
id: string;
|
|
9
|
+
cls: string;
|
|
10
|
+
right: number;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export declare function getHorizontalOverflowState(): HorizontalOverflowState;
|
|
14
|
+
export declare function assertNoHorizontalScroll(page: Page): Promise<void>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { expect } from '@playwright/test';
|
|
2
|
+
export function getHorizontalOverflowState() {
|
|
3
|
+
const root = globalThis.document;
|
|
4
|
+
const scrollWidth = root.documentElement.scrollWidth;
|
|
5
|
+
const clientWidth = root.documentElement.clientWidth;
|
|
6
|
+
if (scrollWidth <= clientWidth) {
|
|
7
|
+
return { overflow: false, scrollWidth, clientWidth, offenders: [] };
|
|
8
|
+
}
|
|
9
|
+
const offenders = [];
|
|
10
|
+
for (const element of root.querySelectorAll('*')) {
|
|
11
|
+
const rect = element.getBoundingClientRect();
|
|
12
|
+
if (rect.right > clientWidth + 1) {
|
|
13
|
+
offenders.push({
|
|
14
|
+
tag: element.tagName,
|
|
15
|
+
id: element.id,
|
|
16
|
+
cls: (element.getAttribute('class') ?? '').slice(0, 60),
|
|
17
|
+
right: Math.round(rect.right),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return { overflow: true, scrollWidth, clientWidth, offenders: offenders.slice(0, 10) };
|
|
22
|
+
}
|
|
23
|
+
export async function assertNoHorizontalScroll(page) {
|
|
24
|
+
// Poll until layout settles — CSS transitions like
|
|
25
|
+
// sidebar collapse may briefly cause scrollWidth > clientWidth.
|
|
26
|
+
const state = { lastResult: null };
|
|
27
|
+
try {
|
|
28
|
+
await expect
|
|
29
|
+
.poll(async () => {
|
|
30
|
+
state.lastResult = await page.evaluate(getHorizontalOverflowState);
|
|
31
|
+
return state.lastResult.overflow;
|
|
32
|
+
}, { timeout: 5000, intervals: [50, 100] })
|
|
33
|
+
.toBe(false);
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
// Log only once after all retries are exhausted
|
|
37
|
+
const { lastResult } = state;
|
|
38
|
+
if (lastResult?.overflow) {
|
|
39
|
+
console.error(`Horizontal overflow detected: scrollWidth=${lastResult.scrollWidth} clientWidth=${lastResult.clientWidth}\nOffending elements:`, JSON.stringify(lastResult.offenders, null, 2));
|
|
40
|
+
}
|
|
41
|
+
throw err;
|
|
42
|
+
}
|
|
43
|
+
}
|