Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Stop flagging the expected /api/audit 409 as a console defect (#4769)

Nick Gomez48a4694cc37c
diff --git a/packages/app/package.json b/packages/app/package.json
index b81717a6b..0298db574 100644
--- a/packages/app/package.json
+++ b/packages/app/package.json
@@ -37,7 +37,7 @@
"measure:stress": "bash scripts/measure-stress.sh",
"measure:sweep": "bash scripts/measure-sweep.sh",
"perf:compare": "bash scripts/perf-compare.sh",
- "test:e2e": "playwright test tests/stress/list-item-drag.e2e.ts tests/stress/ux-interactions.e2e.ts tests/stress/file-tree-create.e2e.ts tests/stress/file-tree-drag-to-root.e2e.ts tests/stress/file-tree-deselect-to-root.e2e.ts tests/stress/file-tree-collapse-spaced-folder.e2e.ts tests/stress/sidebar-file-list-fills.e2e.ts tests/stress/file-tree-sticky-collapse.e2e.ts tests/stress/file-tree-collapse-persistence.e2e.ts tests/stress/file-tree-fractional-zoom.e2e.ts tests/stress/create-then-rename-editable.e2e.ts tests/stress/find-replace.e2e.ts tests/stress/editor-tabs.e2e.ts tests/stress/crdt-stress.e2e.ts tests/stress/slash-command.e2e.ts tests/stress/paste-fidelity.e2e.ts tests/stress/fr-7a-disconnect-source-mode.e2e.ts tests/stress/docs-open.e2e.ts tests/stress/frozen-table-headers.e2e.ts tests/stress/asset-embed.e2e.ts tests/stress/asset-embed-advanced.e2e.ts tests/stress/asset-click-dispatch.e2e.ts tests/stress/handoff.e2e.ts tests/stress/multi-agent-presence.e2e.ts tests/stress/editor-mode-persistence.e2e.ts tests/stress/lint-config-toggle.e2e.ts tests/stress/plugin-enable-notice.e2e.ts tests/stress/schema-edit-fields-view.e2e.ts tests/stress/sidebar-search-pill.e2e.ts tests/stress/navigation-history.e2e.ts tests/stress/command-palette-semantic.e2e.ts tests/stress/agent-activity-panel.e2e.ts tests/stress/drop-pipeline-auto-open.e2e.ts tests/stress/command-palette-flicker.e2e.ts tests/stress/cm6-list-hanging-indent.e2e.ts tests/stress/ng7-rapid-nav-coherence.e2e.ts tests/stress/reveal-on-activate.e2e.ts tests/stress/selection-indicator.e2e.ts tests/stress/new-file-cross-doc-bleed.e2e.ts tests/stress/new-item-shortcut-fast-path.e2e.ts tests/stress/editor-mode-flip-cross-doc-bleed.e2e.ts tests/stress/editor-area-viewport-resize.e2e.ts tests/stress/qa-sidebar-responsive.e2e.ts tests/stress/prd-6955-reassertion-repro.e2e.ts tests/stress/prd-6955-reassertion-wedge.e2e.ts tests/stress/prd-6914-repro.e2e.ts tests/stress/showall-lazy-tree.e2e.ts tests/stress/tabs-component-strip.e2e.ts tests/stress/source-find-scroll.e2e.ts tests/stress/harness-app-warmth.e2e.ts tests/stress/qa-canary-authoring-both-modes.e2e.ts tests/stress/qa-canary-live-typing.e2e.ts tests/stress/keystroke-cadence-danger-space.e2e.ts tests/stress/jsx-unregistered-backspace-delete.e2e.ts tests/stress/jsx-unregistered-ime-concurrent.e2e.ts tests/stress/jsx-backspace-delete.e2e.ts tests/stress/link-authoring-bytes.e2e.ts tests/stress/link-authoring-apex.e2e.ts tests/stress/command-palette-parity.e2e.ts tests/stress/settings-search.e2e.ts tests/stress/okf-generated-index-settings.e2e.ts tests/stress/okf-recommended-skill-install.e2e.ts tests/stress/chip-popover-positioning.e2e.ts tests/stress/docs-open-scroll-restore.e2e.ts tests/stress/file-tree-decoration-chip-strip-repro.e2e.ts tests/stress/grip-click-nodeselect.e2e.ts tests/stress/jsx-halo-semantics.e2e.ts tests/stress/jsx-image-body-click.e2e.ts tests/stress/jsx-prop-panel-placeholder.e2e.ts tests/stress/jsx-range-encompass-halo.e2e.ts tests/stress/jsx-wildcard-convert.e2e.ts tests/stress/markdown-lint.e2e.ts tests/stress/frontmatter-schema-badge.e2e.ts tests/stress/frontmatter-glob-picker.e2e.ts tests/stress/unified-problems.e2e.ts tests/stress/mid-type-recovery.e2e.ts tests/stress/observer-a-multi-client.e2e.ts tests/stress/outline-toolbar-occlusion.e2e.ts tests/stress/selection-surface-pane-clip.e2e.ts tests/stress/quiet-tree-hidden-doc.e2e.ts tests/stress/raw-mdx-fallback-onblur-upgrade.e2e.ts tests/stress/rename-noext-probe.e2e.ts tests/stress/show-ok-folders.e2e.ts tests/stress/source-polish.e2e.ts tests/stress/warm-skeleton-scroll-restore.e2e.ts tests/stress/props-toggle-scroll-preserve.e2e.ts tests/stress/yjs-no-dual-import.e2e.ts tests/stress/graph-panel-surfaces.e2e.ts tests/stress/asset-embed-real-fidelity.e2e.ts tests/stress/image-invalid-placeholder.e2e.ts tests/stress/local-target-audit.e2e.ts tests/stress/rename-content-preservation.e2e.ts tests/stress/rename-consolidation.e2e.ts tests/stress/outline-active-heading.e2e.ts tests/stress/outline-navigation.e2e.ts tests/stress/prd-7627-default-swatch.e2e.ts tests/stress/clipboard-dollar-math-source-fallback.e2e.ts tests/stress/source-mode-undo-keymap.e2e.ts tests/stress/source-undo-mode-flip.e2e.ts tests/stress/timeline-recovered-restore.e2e.ts tests/stress/blank-line-preservation.e2e.ts tests/stress/landing-helpers.e2e.ts tests/stress/agent-follow-scroll.e2e.ts tests/stress/mode-switch-landing.e2e.ts tests/stress/mode-switch-ordinal-divergence.e2e.ts tests/stress/comment-annotation-visibility.e2e.ts tests/stress/comment-opens-in-panel.e2e.ts tests/stress/qa-miles-edge-blanks.e2e.ts tests/stress/prop-upload.e2e.ts tests/stress/slash-command-auto-open.e2e.ts tests/stress/clipboard-relative-url-source-fallback.e2e.ts tests/stress/editor-split-view.e2e.ts tests/stress/language-load-failure.e2e.ts tests/stress/language-first-paint.e2e.ts tests/stress/user-text-direction.e2e.ts tests/stress/pseudolocale.e2e.ts tests/stress/language-picker.e2e.ts tests/stress/zh-hans-coverage-sweep.e2e.ts tests/stress/preview-tab-promotion.e2e.ts tests/stress/cv-paint-lock-click.e2e.ts tests/stress/cv-auto-paint-lock-click.e2e.ts tests/stress/history-traversal-preview-tab.e2e.ts tests/stress/tab-close-scroll-restore.e2e.ts tests/stress/skills-sidebar-open.e2e.ts tests/stress/trailing-affordance.e2e.ts tests/stress/text-doc-composer-inset.e2e.ts tests/stress/composer-control-alignment.e2e.ts tests/stress/agents-settings-accessible-names.e2e.ts tests/stress/composer-growth-eof-reveal.e2e.ts tests/stress/theme-fade.e2e.ts tests/stress/theme-color-conversion.e2e.ts tests/stress/composer-open-caret-reveal.e2e.ts tests/stress/spellcheck-browser-absence.e2e.ts tests/stress/agents-panel-reload-visibility.e2e.ts tests/stress/rail-flex-distribution-law.e2e.ts",
+ "test:e2e": "playwright test tests/stress/list-item-drag.e2e.ts tests/stress/ux-interactions.e2e.ts tests/stress/file-tree-create.e2e.ts tests/stress/file-tree-drag-to-root.e2e.ts tests/stress/file-tree-deselect-to-root.e2e.ts tests/stress/file-tree-collapse-spaced-folder.e2e.ts tests/stress/sidebar-file-list-fills.e2e.ts tests/stress/file-tree-sticky-collapse.e2e.ts tests/stress/file-tree-collapse-persistence.e2e.ts tests/stress/file-tree-fractional-zoom.e2e.ts tests/stress/create-then-rename-editable.e2e.ts tests/stress/find-replace.e2e.ts tests/stress/editor-tabs.e2e.ts tests/stress/crdt-stress.e2e.ts tests/stress/slash-command.e2e.ts tests/stress/paste-fidelity.e2e.ts tests/stress/fr-7a-disconnect-source-mode.e2e.ts tests/stress/docs-open.e2e.ts tests/stress/frozen-table-headers.e2e.ts tests/stress/asset-embed.e2e.ts tests/stress/asset-embed-advanced.e2e.ts tests/stress/asset-click-dispatch.e2e.ts tests/stress/handoff.e2e.ts tests/stress/multi-agent-presence.e2e.ts tests/stress/editor-mode-persistence.e2e.ts tests/stress/lint-config-toggle.e2e.ts tests/stress/plugin-enable-notice.e2e.ts tests/stress/schema-edit-fields-view.e2e.ts tests/stress/sidebar-search-pill.e2e.ts tests/stress/navigation-history.e2e.ts tests/stress/command-palette-semantic.e2e.ts tests/stress/agent-activity-panel.e2e.ts tests/stress/drop-pipeline-auto-open.e2e.ts tests/stress/command-palette-flicker.e2e.ts tests/stress/cm6-list-hanging-indent.e2e.ts tests/stress/ng7-rapid-nav-coherence.e2e.ts tests/stress/reveal-on-activate.e2e.ts tests/stress/selection-indicator.e2e.ts tests/stress/new-file-cross-doc-bleed.e2e.ts tests/stress/new-item-shortcut-fast-path.e2e.ts tests/stress/editor-mode-flip-cross-doc-bleed.e2e.ts tests/stress/editor-area-viewport-resize.e2e.ts tests/stress/qa-sidebar-responsive.e2e.ts tests/stress/prd-6955-reassertion-repro.e2e.ts tests/stress/prd-6955-reassertion-wedge.e2e.ts tests/stress/prd-6914-repro.e2e.ts tests/stress/showall-lazy-tree.e2e.ts tests/stress/tabs-component-strip.e2e.ts tests/stress/source-find-scroll.e2e.ts tests/stress/harness-app-warmth.e2e.ts tests/stress/qa-canary-authoring-both-modes.e2e.ts tests/stress/qa-canary-live-typing.e2e.ts tests/stress/keystroke-cadence-danger-space.e2e.ts tests/stress/jsx-unregistered-backspace-delete.e2e.ts tests/stress/jsx-unregistered-ime-concurrent.e2e.ts tests/stress/jsx-backspace-delete.e2e.ts tests/stress/link-authoring-bytes.e2e.ts tests/stress/link-authoring-apex.e2e.ts tests/stress/command-palette-parity.e2e.ts tests/stress/settings-search.e2e.ts tests/stress/okf-generated-index-settings.e2e.ts tests/stress/okf-recommended-skill-install.e2e.ts tests/stress/chip-popover-positioning.e2e.ts tests/stress/docs-open-scroll-restore.e2e.ts tests/stress/file-tree-decoration-chip-strip-repro.e2e.ts tests/stress/grip-click-nodeselect.e2e.ts tests/stress/jsx-halo-semantics.e2e.ts tests/stress/jsx-image-body-click.e2e.ts tests/stress/jsx-prop-panel-placeholder.e2e.ts tests/stress/jsx-range-encompass-halo.e2e.ts tests/stress/jsx-wildcard-convert.e2e.ts tests/stress/markdown-lint.e2e.ts tests/stress/frontmatter-schema-badge.e2e.ts tests/stress/frontmatter-glob-picker.e2e.ts tests/stress/unified-problems.e2e.ts tests/stress/mid-type-recovery.e2e.ts tests/stress/observer-a-multi-client.e2e.ts tests/stress/outline-toolbar-occlusion.e2e.ts tests/stress/selection-surface-pane-clip.e2e.ts tests/stress/quiet-tree-hidden-doc.e2e.ts tests/stress/raw-mdx-fallback-onblur-upgrade.e2e.ts tests/stress/rename-noext-probe.e2e.ts tests/stress/show-ok-folders.e2e.ts tests/stress/source-polish.e2e.ts tests/stress/warm-skeleton-scroll-restore.e2e.ts tests/stress/props-toggle-scroll-preserve.e2e.ts tests/stress/yjs-no-dual-import.e2e.ts tests/stress/graph-panel-surfaces.e2e.ts tests/stress/asset-embed-real-fidelity.e2e.ts tests/stress/image-invalid-placeholder.e2e.ts tests/stress/local-target-audit.e2e.ts tests/stress/rename-content-preservation.e2e.ts tests/stress/rename-consolidation.e2e.ts tests/stress/outline-active-heading.e2e.ts tests/stress/outline-navigation.e2e.ts tests/stress/prd-7627-default-swatch.e2e.ts tests/stress/clipboard-dollar-math-source-fallback.e2e.ts tests/stress/source-mode-undo-keymap.e2e.ts tests/stress/source-undo-mode-flip.e2e.ts tests/stress/timeline-recovered-restore.e2e.ts tests/stress/blank-line-preservation.e2e.ts tests/stress/landing-helpers.e2e.ts tests/stress/agent-follow-scroll.e2e.ts tests/stress/mode-switch-landing.e2e.ts tests/stress/mode-switch-ordinal-divergence.e2e.ts tests/stress/comment-annotation-visibility.e2e.ts tests/stress/comment-opens-in-panel.e2e.ts tests/stress/qa-miles-edge-blanks.e2e.ts tests/stress/prop-upload.e2e.ts tests/stress/slash-command-auto-open.e2e.ts tests/stress/clipboard-relative-url-source-fallback.e2e.ts tests/stress/editor-split-view.e2e.ts tests/stress/language-load-failure.e2e.ts tests/stress/language-first-paint.e2e.ts tests/stress/user-text-direction.e2e.ts tests/stress/pseudolocale.e2e.ts tests/stress/language-picker.e2e.ts tests/stress/zh-hans-coverage-sweep.e2e.ts tests/stress/preview-tab-promotion.e2e.ts tests/stress/cv-paint-lock-click.e2e.ts tests/stress/cv-auto-paint-lock-click.e2e.ts tests/stress/history-traversal-preview-tab.e2e.ts tests/stress/tab-close-scroll-restore.e2e.ts tests/stress/skills-sidebar-open.e2e.ts tests/stress/trailing-affordance.e2e.ts tests/stress/text-doc-composer-inset.e2e.ts tests/stress/composer-control-alignment.e2e.ts tests/stress/agents-settings-accessible-names.e2e.ts tests/stress/composer-growth-eof-reveal.e2e.ts tests/stress/theme-fade.e2e.ts tests/stress/theme-color-conversion.e2e.ts tests/stress/composer-open-caret-reveal.e2e.ts tests/stress/spellcheck-browser-absence.e2e.ts tests/stress/agents-panel-reload-visibility.e2e.ts tests/stress/rail-flex-distribution-law.e2e.ts tests/stress/audit-409-console-record.e2e.ts",
"test:e2e:install-browsers": "playwright install chromium webkit firefox",
"test:visual": "playwright test --config playwright.visual.config.ts",
"test:visual:update": "playwright test --config playwright.visual.config.ts --update-snapshots",
diff --git a/packages/app/tests/meta/error-filters.test.ts b/packages/app/tests/meta/error-filters.test.ts
index 6f84ef40b..82623ccd0 100644
--- a/packages/app/tests/meta/error-filters.test.ts
+++ b/packages/app/tests/meta/error-filters.test.ts
@@ -1,5 +1,10 @@
import { describe, expect, it } from 'vitest';
-import { filterCriticalErrors } from '../stress/_helpers/error-filters';
+import {
+ AUDIT_CONSOLE_RECORD_CASES,
+ type ConsoleRecordCase,
+ chromiumResourceFailureRecord,
+} from '../stress/_helpers/audit-console-records.test-helper.ts';
+import { filterCriticalErrors } from '../stress/_helpers/error-filters.ts';
describe('filterCriticalErrors', () => {
const prebundled = 'http://localhost:5173/node_modules/.vite/deps/@codemirror_state.js';
@@ -18,7 +23,7 @@ describe('filterCriticalErrors', () => {
filterCriticalErrors([
{
type: 'error',
- text: 'Failed to load resource: the server responded with a status of 504',
+ text: 'Failed to load resource: the server responded with a status of 504 (Outdated Optimize Dep)',
url: prebundled,
},
{
@@ -35,3 +40,41 @@ describe('filterCriticalErrors', () => {
expect(filterCriticalErrors([entry])).toEqual([entry]);
});
});
+
+describe('console records a product endpoint is designed to produce', () => {
+ const origin = 'http://127.0.0.1:63824';
+
+ for (const entry of AUDIT_CONSOLE_RECORD_CASES) {
+ it(`${entry.retainedByClassifier ? 'keeps' : 'drops'} ${entry.label}`, () => {
+ const record = chromiumResourceFailureRecord(origin, entry);
+ expect(
+ filterCriticalErrors([record]),
+ `${entry.label} must be ${entry.retainedByClassifier ? 'retained' : 'dropped'}`,
+ ).toEqual(entry.retainedByClassifier ? [record] : []);
+ });
+ }
+
+ it('refuses a case whose status has no reason phrase instead of building a record for it', () => {
+ const unmapped: ConsoleRecordCase = {
+ label: 'a status with no registered reason phrase',
+ path: '/api/audit',
+ status: 599,
+ retainedByClassifier: false,
+ };
+ expect(() => chromiumResourceFailureRecord(origin, unmapped)).toThrow(String(unmapped.status));
+ });
+
+ it('drops only the audit-superseded 409s when every case arrives together', () => {
+ const records = AUDIT_CONSOLE_RECORD_CASES.map((entry) =>
+ chromiumResourceFailureRecord(origin, entry),
+ );
+ expect(
+ records,
+ 'the shared fixture table gained or lost a case; update this literal deliberately, because deriving it from AUDIT_CONSOLE_RECORD_CASES.length makes this toHaveLength assertion a tautology and lets the table resize silently',
+ ).toHaveLength(7);
+ const retained = AUDIT_CONSOLE_RECORD_CASES.filter((entry) => entry.retainedByClassifier).map(
+ (entry) => chromiumResourceFailureRecord(origin, entry),
+ );
+ expect(filterCriticalErrors(records)).toEqual(retained);
+ });
+});
diff --git a/packages/app/tests/stress/_helpers/audit-console-records.test-helper.ts b/packages/app/tests/stress/_helpers/audit-console-records.test-helper.ts
new file mode 100644
index 000000000..41cfbabd3
--- /dev/null
+++ b/packages/app/tests/stress/_helpers/audit-console-records.test-helper.ts
@@ -0,0 +1,69 @@
+import { STATUS_CODES } from 'node:http';
+import type { LogEntry } from './error-filters.ts';
+
+export interface ConsoleRecordCase {
+ readonly label: string;
+ readonly path: string;
+ readonly status: number;
+ readonly retainedByClassifier: boolean;
+}
+
+export const AUDIT_CONSOLE_RECORD_CASES: readonly ConsoleRecordCase[] = [
+ {
+ label: 'an expected-by-design audit-superseded 409 from the query-less /api/audit call',
+ path: '/api/audit',
+ status: 409,
+ retainedByClassifier: false,
+ },
+ {
+ label: 'an expected-by-design audit-superseded 409 from the query-carrying /api/audit call',
+ path: '/api/audit?doc=uv-open-c77a7381',
+ status: 409,
+ retainedByClassifier: false,
+ },
+ {
+ label: 'a 409 from an endpoint that is not /api/audit',
+ path: '/api/create-page',
+ status: 409,
+ retainedByClassifier: true,
+ },
+ {
+ label: 'a 409 on the sibling /api/lint/audit route, which no page-side code calls',
+ path: '/api/lint/audit',
+ status: 409,
+ retainedByClassifier: true,
+ },
+ {
+ label: 'a 409 on a URL whose path continues past /api/audit into more characters',
+ path: '/api/audit-history',
+ status: 409,
+ retainedByClassifier: true,
+ },
+ {
+ label: 'a 409 on /api/create-page whose query string ends with /api/audit',
+ path: '/api/create-page?ref=/api/audit',
+ status: 409,
+ retainedByClassifier: true,
+ },
+ {
+ label: 'a non-409 failure on /api/audit itself',
+ path: '/api/audit?doc=uv-open-broken',
+ status: 500,
+ retainedByClassifier: true,
+ },
+];
+
+export function chromiumResourceFailureRecord(origin: string, entry: ConsoleRecordCase): LogEntry {
+ const phrase = STATUS_CODES[entry.status];
+ if (phrase === undefined) {
+ throw new Error(
+ `case '${entry.label}' uses status ${entry.status}, which has no reason phrase`,
+ );
+ }
+ return {
+ type: 'error',
+ text: `Failed to load resource: the server responded with a status of ${entry.status} (${phrase})`,
+ url: `${origin}${entry.path}`,
+ line: 0,
+ };
+}
diff --git a/packages/app/tests/stress/_helpers/error-filters.ts b/packages/app/tests/stress/_helpers/error-filters.ts
index 98291bf0d..33100da83 100644
--- a/packages/app/tests/stress/_helpers/error-filters.ts
+++ b/packages/app/tests/stress/_helpers/error-filters.ts
@@ -8,6 +8,9 @@ export interface LogEntry {
const LOAD_FAILURE =
/Failed to load resource|net::ERR_|Failed to fetch|error loading dynamically imported module|status of \d{3}/i;
+const AUDIT_ENDPOINT_PATH = '/api/audit';
+
+// STOP: a predicate here matching a bare load failure or a bare status masks genuine failures on every other endpoint, in every stress spec that shares this filter.
const BENIGN_PREDICATES: Array<(e: LogEntry) => boolean> = [
(e) => e.text.includes('favicon'),
(e) => e.text.includes('HMR'),
@@ -29,6 +32,9 @@ const BENIGN_PREDICATES: Array<(e: LogEntry) => boolean> = [
(e) => !!e.url?.includes('/collab') && e.url.startsWith('ws://'),
(e) => e.text.includes("can't establish a connection"),
(e) => e.text.includes('can’t establish a connection'),
+
+ (e) =>
+ URL.parse(e.url ?? '')?.pathname === AUDIT_ENDPOINT_PATH && e.text.includes('status of 409'),
];
export function filterCriticalErrors(logs: LogEntry[]): LogEntry[] {
diff --git a/packages/app/tests/stress/_helpers/index.ts b/packages/app/tests/stress/_helpers/index.ts
index da8194629..ba59fac7c 100644
--- a/packages/app/tests/stress/_helpers/index.ts
+++ b/packages/app/tests/stress/_helpers/index.ts
@@ -1,4 +1,8 @@
export { acpCatalogBody } from './acp-catalog.ts';
+export {
+ AUDIT_CONSOLE_RECORD_CASES,
+ chromiumResourceFailureRecord,
+} from './audit-console-records.test-helper.ts';
export { simulateCopyAndRead, simulateCutAndRead } from './clipboard.ts';
export { resetContentToFixtureBaseline } from './content-reset.ts';
export {
diff --git a/packages/app/tests/stress/audit-409-console-record.e2e.ts b/packages/app/tests/stress/audit-409-console-record.e2e.ts
new file mode 100644
index 000000000..947f17458
--- /dev/null
+++ b/packages/app/tests/stress/audit-409-console-record.e2e.ts
@@ -0,0 +1,115 @@
+import { createServer } from 'node:http';
+import type { AddressInfo } from 'node:net';
+// STOP: import test/expect from '@playwright/test', not the _helpers barrel, whose extended test resolves baseURL from the worker-scoped workerServer fixture and boots a Vite + Hocuspocus stack this probe never uses.
+import { expect, test } from '@playwright/test';
+import {
+ AUDIT_CONSOLE_RECORD_CASES,
+ chromiumResourceFailureRecord,
+ type LogEntry,
+} from './_helpers';
+
+const PROBE_PAGE = '<!doctype html><html><body><div id="probe">probe</div></body></html>';
+const CONSOLE_RECORD_TIMEOUT_MS = 5_000;
+const WORK_OUTSIDE_POLLS_BUDGET_MS = 30_000;
+const TEST_TIMEOUT_MS =
+ AUDIT_CONSOLE_RECORD_CASES.length * CONSOLE_RECORD_TIMEOUT_MS + WORK_OUTSIDE_POLLS_BUDGET_MS;
+
+const describeServerError = (error: Error): string => error.stack ?? String(error);
+
+test('real Chromium emits the console records the shared fixtures describe', async ({
+ browser,
+}) => {
+ test.setTimeout(TEST_TIMEOUT_MS);
+ const byPath = new Map(AUDIT_CONSOLE_RECORD_CASES.map((entry) => [entry.path, entry]));
+ const server = createServer((req, res) => {
+ if (req.url === '/') {
+ res.writeHead(200, { 'content-type': 'text/html' });
+ res.end(PROBE_PAGE);
+ return;
+ }
+ const hit = byPath.get(req.url ?? '');
+ if (hit) {
+ res.writeHead(hit.status);
+ res.end();
+ return;
+ }
+ res.writeHead(404, { 'content-type': 'text/plain' });
+ res.end('missing');
+ });
+
+ let serverError: Error | undefined;
+ server.on('error', (error) => {
+ serverError = error;
+ process.stderr.write(`probe-server-error: ${describeServerError(error)}\n`);
+ });
+ await new Promise<void>((resolve, reject) => {
+ const onBindError = (error: Error) => reject(error);
+ server.once('error', onBindError);
+ server.listen(0, '127.0.0.1', () => {
+ server.removeListener('error', onBindError);
+ resolve();
+ });
+ });
+ const origin = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;
+ const captured: LogEntry[] = [];
+ try {
+ const page = await browser.newPage();
+ page.on('console', (msg) => {
+ if (msg.type() !== 'error') return;
+ const location = msg.location();
+ captured.push({
+ type: 'error',
+ text: msg.text(),
+ url: location.url,
+ line: location.lineNumber,
+ });
+ });
+
+ try {
+ await page.goto(`${origin}/`);
+
+ for (const entry of AUDIT_CONSOLE_RECORD_CASES) {
+ expect(serverError, 'the probe server must not have emitted an error').toBeUndefined();
+ const priorRecords = captured.length;
+ const served = await page.evaluate(async (path) => (await fetch(path)).status, entry.path);
+ expect(served, `${entry.label} must be served as ${entry.status}`).toBe(entry.status);
+ await expect
+ .poll(
+ () =>
+ captured
+ .slice(priorRecords)
+ .some((record) => record.url === `${origin}${entry.path}`),
+ {
+ message: `${entry.label} must produce a console record`,
+ timeout: CONSOLE_RECORD_TIMEOUT_MS,
+ },
+ )
+ .toBe(true);
+ }
+
+ const apiRecords = captured.filter((record) => record.url?.startsWith(`${origin}/api/`));
+ const expected = AUDIT_CONSOLE_RECORD_CASES.map((entry) =>
+ chromiumResourceFailureRecord(origin, entry),
+ );
+ expect(
+ apiRecords,
+ 'real Chromium must emit exactly the records the shared fixtures describe',
+ ).toEqual(expected);
+ } finally {
+ await page.close();
+ }
+ } finally {
+ if (serverError !== undefined) {
+ test.info().annotations.push({
+ type: 'probe-server-error',
+ description: describeServerError(serverError),
+ });
+ }
+ await new Promise<void>((resolve) => {
+ server.closeAllConnections();
+ server.close(() => resolve());
+ });
+ }
+
+ expect(serverError, 'the probe server must not have emitted an error').toBeUndefined();
+});