Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

Refresh shared browser gate with current dev regressions

tt-a1i7d0770d0156e
diff --cc archify/test/browser-gate.test.mjs
index 1d121306,00000000..d2febba4
mode 100644,000000..100644
--- a/archify/test/browser-gate.test.mjs
+++ b/archify/test/browser-gate.test.mjs
@@@ -1,86 -1,0 +1,86 @@@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { spawnSync } from 'node:child_process';
+import fs from 'node:fs';
+import os from 'node:os';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const skillRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
+const repoRoot = path.dirname(skillRoot);
+const runner = path.join(repoRoot, 'scripts/run-browser-tests.mjs');
+
+test('browser gate rejects an unavailable explicit browser instead of skipping', (t) => {
+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-browser-gate-'));
+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));
+ for (const chrome of ['', path.join(directory, 'missing-chrome')]) {
+ const result = spawnSync(process.execPath, [runner], {
+ encoding: 'utf8', env: { ...process.env, ARCHIFY_CHROME: chrome },
+ });
+ assert.equal(result.status, 1, result.stdout || result.stderr);
+ assert.match(result.stderr, /require an executable Chrome\/Chromium/);
+ assert.doesNotMatch(result.stdout, /# SKIP/);
+ }
+});
+
+// Observe the public runner's child invocation without starting real browsers
+// in the ordinary Node matrix. The explicit browser gate supplies real coverage.
+function interceptedRun(t, outcome) {
+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-browser-gate-'));
+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));
+ const preload = path.join(directory, 'capture-runner.cjs');
+ fs.writeFileSync(preload, `
+const childProcess = require('node:child_process');
+childProcess.spawnSync = (command, args, options) => {
+ console.log(JSON.stringify({ command, args, cwd: options.cwd, chrome: options.env.ARCHIFY_CHROME }));
+ return ${JSON.stringify(outcome)};
+};
+require('node:module').syncBuiltinESMExports();
+`);
+ return spawnSync(process.execPath, ['--require', preload, runner], {
+ cwd: directory,
+ encoding: 'utf8',
+ env: { ...process.env, ARCHIFY_CHROME: process.execPath },
+ });
+}
+
+test('browser gate includes dedicated and mixed browser suites and enables them', (t) => {
+ const result = interceptedRun(t, { status: 0, signal: null });
+ assert.equal(result.status, 0, result.stderr);
+ const call = JSON.parse(result.stdout);
+ assert.equal(call.command, process.execPath);
+ assert.equal(fs.realpathSync(call.cwd), fs.realpathSync(skillRoot));
+ assert.equal(call.chrome, process.execPath);
+ assert.ok(call.args.includes('--test'));
+ const files = call.args.filter((arg) => !arg.startsWith('--'));
+ assert.equal(new Set(files).size, files.length);
+ for (const file of files) assert.ok(fs.existsSync(path.join(skillRoot, file)), file);
+ const required = [
+ ...fs.readdirSync(path.join(skillRoot, 'test')).filter((file) => file.endsWith('-browser.test.mjs')),
- 'repository-evidence.test.mjs', 'i18n.test.mjs', 'semantic-radar.test.mjs', 'viewer-chrome-layout.test.mjs',
++ 'sequence-header-clearance.test.mjs', 'repository-evidence.test.mjs', 'i18n.test.mjs', 'semantic-radar.test.mjs', 'viewer-chrome-layout.test.mjs',
+ ];
+ for (const file of required) assert.ok(files.includes(path.join('test', file)), `${file} must run in the browser gate`);
+});
+
+for (const outcome of [{ status: 7, signal: null }, { status: null, signal: 'SIGTERM' }]) {
+ test(`browser gate propagates child failure (${outcome.signal || outcome.status})`, (t) => {
+ const result = interceptedRun(t, outcome);
+ assert.equal(result.status, outcome.status ?? 1);
+ if (outcome.signal) assert.match(result.stderr, /terminated by SIGTERM/);
+ });
+}
+
+test('CI and release use the same browser command and retain WebM decoding', () => {
+ const manifest = JSON.parse(fs.readFileSync(path.join(skillRoot, 'package.json'), 'utf8'));
+ assert.equal(manifest.scripts['test:browser'], 'node ../scripts/run-browser-tests.mjs');
+ for (const workflow of ['ci.yml', 'release.yml']) {
+ const source = fs.readFileSync(path.join(repoRoot, '.github/workflows', workflow), 'utf8');
+ const gate = source.match(/ {6}- name: Run shared browser regression gate\n([\s\S]*?)(?=\n {6}- name:|\n {2}[\w-]+:|$)/)?.[1];
+ assert.ok(gate, `${workflow} must invoke the shared gate`);
+ assert.match(gate, /run: npm run test:browser\n/);
+ assert.match(gate, /working-directory: archify/);
+ assert.match(gate, /ARCHIFY_CHROME: \$\{\{ steps\.setup-chrome\.outputs\.chrome-path \}\}/);
+ assert.match(source, /run: npm run test:webm/);
+ assert.doesNotMatch(source, /run: node --test[^\n]*test\/.*browser/);
+ }
+});
diff --cc scripts/run-browser-tests.mjs
index ef31623f,00000000..bb2b6315
mode 100644,000000..100644
--- a/scripts/run-browser-tests.mjs
+++ b/scripts/run-browser-tests.mjs
@@@ -1,48 -1,0 +1,50 @@@
+#!/usr/bin/env node
+
+import { spawnSync } from 'node:child_process';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { findChrome } from '../archify/bin/visual-check.mjs';
+
+const skillRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'archify');
+// Shared by PR CI and tag releases. WebM decoding stays in test:webm.
+const testFiles = [
+ 'desktop-reader-browser.test.mjs',
+ 'reader-layout-browser.test.mjs',
++ 'sequence-header-clearance.test.mjs',
++ 'lifecycle-rail-browser.test.mjs',
+ 'export-cleanup-browser.test.mjs',
+ 'offline-font-browser.test.mjs',
+ 'i18n.test.mjs',
+ 'semantic-radar.test.mjs',
+ 'viewer-chrome-layout.test.mjs',
+ 'viewer-camera-browser.test.mjs',
+ 'motion-governor-browser.test.mjs',
+ 'finder-browser.test.mjs',
+ 'intent-trace-browser.test.mjs',
+ 'semantic-lens-browser.test.mjs',
+ 'route-probe-browser.test.mjs',
+ 'guided-views-browser.test.mjs',
+ 'focus-browser.test.mjs',
+ 'export-browser.test.mjs',
+ 'viewer-identifiers-browser.test.mjs',
+ 'repository-evidence.test.mjs',
+];
+
+const chrome = findChrome();
+if (!chrome) {
+ console.error('Browser tests require an executable Chrome/Chromium. Set ARCHIFY_CHROME to its path; this gate cannot skip browser coverage.');
+ process.exit(1);
+}
+
+const args = ['--test'];
+const [major, minor] = process.versions.node.split('.').map(Number);
+if (major > 18 || (major === 18 && minor >= 19)) args.push('--test-concurrency=2');
+args.push(...testFiles.map((file) => path.join('test', file)));
+const result = spawnSync(process.execPath, args, {
+ cwd: skillRoot,
+ env: { ...process.env, ARCHIFY_CHROME: chrome },
+ stdio: 'inherit',
+});
+if (result.error) throw result.error;
+if (result.signal) console.error(`browser test runner terminated by ${result.signal}`);
+process.exitCode = result.status ?? 1;