Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
ci: run cross-workspace browser suites where they cannot skip (#10312)
[._.]/ Adam Eivya90db04010fe
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex bab4a3950b..7305a07ac1 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -44,6 +44,7 @@ jobs:client_files: ${{ steps.plan.outputs.client_files }}client_sources: ${{ steps.plan.outputs.client_sources }}db: ${{ steps.plan.outputs.db }}+ browser_files: ${{ steps.plan.outputs.browser_files }}lint_mode: ${{ steps.plan.outputs.lint_mode }}lint_files: ${{ steps.plan.outputs.lint_files }}build: ${{ steps.plan.outputs.build }}@@ -103,6 +104,7 @@ jobs:SERVER_MODE: ${{ steps.plan.outputs.server_mode }}CLIENT_MODE: ${{ steps.plan.outputs.client_mode }}DB_MODE: ${{ steps.plan.outputs.db }}+ BROWSER_FILES: ${{ steps.plan.outputs.browser_files }}LINT_MODE: ${{ steps.plan.outputs.lint_mode }}BUILD_MODE: ${{ steps.plan.outputs.build }}SMOKE_MODE: ${{ steps.plan.outputs.smoke }}@@ -121,6 +123,7 @@ jobs:echo "- Server tests: \`${SERVER_MODE}\` (shards \`${SERVER_SHARDS}\`)"echo "- Client tests: \`${CLIENT_MODE}\` (shards \`${CLIENT_SHARDS}\`)"echo "- DB tests: \`${DB_MODE}\`"+ echo "- Cross-workspace browser suites: \`${BROWSER_FILES}\`"echo "- Client lint: \`${LINT_MODE}\`"echo "- Client build: \`${BUILD_MODE}\`"echo "- Server smoke: \`${SMOKE_MODE}\`"@@ -511,9 +514,15 @@ jobs:run: node scripts/cancel-current-ci-run.jsdatabase:+ # Also the host for the cross-workspace browser suites (issue #10312): the+ # server job installs no client workspace, so `server/**/*.browser.test.js`+ # skip there. This job already has ffmpeg and a runner with Chrome, so it+ # adds the client install and runs the files the planner selected with+ # PORTOS_REQUIRE_BROWSER_SUITES set, which turns a missing prerequisite into+ # a failure instead of a green skip. The DB steps run only when `db` is set.name: DB testsneeds: impact- if: needs.impact.outputs.db == 'true'+ if: needs.impact.outputs.db == 'true' || needs.impact.outputs.browser_files != '[]'runs-on: ubuntu-latesttimeout-minutes: 20permissions:@@ -635,6 +644,7 @@ jobs:vitest-server-${{ runner.os }}-- name: Provision test database (portos_test)+ if: needs.impact.outputs.db == 'true'run: npm run setup:db:test --prefix server# Backup restore coverage takes a real pg_dump. The runner's default@@ -652,6 +662,7 @@ jobs:echo "/usr/lib/postgresql/17/bin" >> "$GITHUB_PATH"- name: Run DB-backed tests (portos_test)+ if: needs.impact.outputs.db == 'true'run: |set +estart=$(date +%s)@@ -663,6 +674,32 @@ jobs:env:PGDATABASE: portos_test+ # Same client cache entry as the `client` job (see it for the key and why+ # an exact hit needs no rebuild).+ - name: Cache client node_modules+ id: client-modules+ if: needs.impact.outputs.browser_files != '[]'+ uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ path: client/node_modules+ key: client-modules-${{ runner.os }}-${{ runner.arch }}-node24-${{ hashFiles('client/package-lock.json', 'client/package.json', 'client/.npmrc', 'scripts/trusted-rebuilds.js') }}++ - name: Install client dependencies+ if: needs.impact.outputs.browser_files != '[]' && steps.client-modules.outputs.cache-hit != 'true'+ run: npm ci --prefix client++ # Fail-closed: PORTOS_REQUIRE_BROWSER_SUITES makes the suites' canRun guard+ # throw (see server/lib/browserSuiteGate.js) when Chrome, ffmpeg or the+ # client bundler is missing, so a skip can never pass this step.+ - name: Run cross-workspace browser suites+ if: needs.impact.outputs.browser_files != '[]'+ env:+ CI_TEST_MODE: files+ CI_TEST_FILES: ${{ needs.impact.outputs.browser_files }}+ PORTOS_REQUIRE_BROWSER_SUITES: '1'+ PORTOS_TEST_QUIET: 1+ run: node scripts/run-ci-tests.js server+- name: Report the failure, then cancel sibling CI jobsif: failure() && github.event_name == 'pull_request'env:diff --git a/docs/GITHUB_ACTIONS.md b/docs/GITHUB_ACTIONS.mdindex 9c33defed8..e561795018 100644--- a/docs/GITHUB_ACTIONS.md+++ b/docs/GITHUB_ACTIONS.md@@ -446,6 +446,23 @@ The selected work is split across parallel jobs:`Cache client node_modules` with the client job, so on a hit it pays no install.- **DB tests** — provisions only the isolated `portos_test` database and runsthe serial DB suite when database-sensitive files changed.+- **Cross-workspace browser suites** (same `database` job) — the+ `server/**/*.browser.test.js` suites (`musicVideoProductionReview`,+ `musicVideoRichAuthoring`, `musicVideoSongRevision`, …) bundle real client+ components and drive them in Chrome. The `server` job installs no client+ workspace, so they skip there and would otherwise skip in every CI job (#10312:+ a `ProductionReviewPanel` prop change left all three harnesses blank behind a+ green CI). The planner emits `browser_files`: every tracked server browser+ suite on a full plan, otherwise the ones selected by a changed test or by the+ basename lookup of a changed client source in a harness `entry` string. When it+ is non-empty the `database` job also runs (even with `db` false), installs+ the client workspace (sharing `Cache client node_modules`) and runs those files+ with `PORTOS_REQUIRE_BROWSER_SUITES=1`, which makes+ `server/lib/browserSuiteGate.js` throw instead of skip when Chrome, ffmpeg or+ the client bundler is missing. Local runs without the prerequisites still skip.+ Limit: selection follows the basename named in a harness entry, so a change to+ a component the entry only imports transitively runs these suites on a full+ plan or when a suite file itself changes, not on a scoped PR.- **Windows server tests** — the same server selection, but only on full CI(the `main` → `release` PR, nightly, release, workflow dispatch) or when aWindows-sensitive surface changed (`.ps1` / `.cmd` spawn, PowerShell BOM,diff --git a/scripts/ci-test-plan.js b/scripts/ci-test-plan.jsindex 18f65f6c38..9abc56c1ec 100644--- a/scripts/ci-test-plan.js+++ b/scripts/ci-test-plan.js@@ -22,6 +22,13 @@ const EXECUTABLE_RE = /\.(?:cjs|css|html|js|jsx|json|mjs|sql|ts|tsx|ya?ml)$/i;const MAX_CHANGED_CODE_FILES = 30;const MAX_TARGETED_TEST_FILES = 120;+// Server-runner suites that drive real client components in Chrome. The server+// job installs no client workspace, so there they always skip; the `database`+// job (client deps + Chrome + ffmpeg, PORTOS_REQUIRE_BROWSER_SUITES=1) is where+// the files selected here run for real (issue #10312).+const BROWSER_SUITE_RE = /^server\/.*\.browser\.test\.js$/;+const browserSuitesIn = (paths) => uniqueSorted(paths.filter((path) => BROWSER_SUITE_RE.test(path)));+// Python sidecar scripts (`scripts/generate_ltx2.py`, …). Vitest's import graph// cannot reach into them, but their contracts are pinned by suites that read// the .py source as text, so main() finds the suites naming each changed script@@ -591,6 +598,9 @@ const suiteReasonsFor = (plan, { appRouteOnly = false } = {}) => ({: plan.full? `full matrix: ${plan.reason}`: 'client-impacting source changed',+ browser: plan.browserFiles.length > 0+ ? (plan.full ? `full matrix: ${plan.reason}` : `${plan.browserFiles.length} cross-workspace browser suite(s) selected`)+ : 'skipped: no cross-workspace browser suite selected',db: plan.db ? (plan.full ? `full matrix: ${plan.reason}` : 'database-risk source changed') : 'skipped: no database-risk source changed',lint: plan.lint.mode === 'skip' ? 'skipped: no changed client source needs linting' : plan.full ? `full matrix: ${plan.reason}` : 'changed client source',build: plan.build ? (plan.full ? `full matrix: ${plan.reason}` : 'client-impacting source changed') : 'skipped: no client-impacting source changed',@@ -688,6 +698,7 @@ export function buildCiTestPlan(changedFiles, {changedFiles: changed,server: alwaysRunServer.length > 0 ? { mode: 'files', files: alwaysRunServer, sources: [] } : skippedRunner(),client: alwaysRunClient.length > 0 ? { mode: 'files', files: alwaysRunClient, sources: [] } : skippedRunner(),+ browserFiles: browserSuitesIn(alwaysRun),db: false,lint: { mode: 'skip', files: [] },build: false,@@ -845,6 +856,7 @@ export function buildCiTestPlan(changedFiles, {changedFiles: changed,server,client,+ browserFiles: browserSuitesIn(serverFiles),db,lint: {// Same deleted-path guard as directTests above — ESLint given a@@ -905,6 +917,7 @@ function fullPlan(changedFiles, reason, options = {}) {changedFiles,server: { mode: 'full', files: [], sources: [] },client: { mode: 'full', files: [], sources: [] },+ browserFiles: browserSuitesIn([...trackedSet]),db: true,lint: { mode: 'full', files: [] },build: true,@@ -942,6 +955,7 @@ export function emitGitHubPlan(plan) {client_mode: plan.client.mode,client_files: JSON.stringify(plan.client.files),client_sources: JSON.stringify(plan.client.sources),+ browser_files: JSON.stringify(plan.browserFiles),db: plan.db,lint_mode: plan.lint.mode,lint_files: JSON.stringify(plan.lint.files),diff --git a/scripts/ci-test-plan.test.js b/scripts/ci-test-plan.test.jsindex fcd54da6d4..cbb0350895 100644--- a/scripts/ci-test-plan.test.js+++ b/scripts/ci-test-plan.test.js@@ -1387,3 +1387,49 @@ describe('Windows escalation on a full plan (#7440)', () => {});});});++describe('cross-workspace browser suites (#10312)', () => {+ const BROWSER_SUITES = [+ 'server/routes/musicVideoProductionReview.browser.test.js',+ 'server/routes/musicVideoRichAuthoring.browser.test.js',+ 'server/routes/musicVideoSongRevision.browser.test.js',+ ];++ it('selects every music-video browser suite when a client component they mount changes', () => {+ const cwd = fileURLToPath(new URL('../', import.meta.url));+ const source = 'client/src/components/musicVideo/ProductionReviewPanel.jsx';+ const inputs = collectPlanInputs({ baseSha: 'HEAD', changedFiles: [source], cwd });+ const plan = buildCiTestPlan(inputs.changedFiles, inputs);++ expect(plan.full).toBe(false);+ expect(plan.browserFiles).toEqual(expect.arrayContaining(BROWSER_SUITES));+ expect(plan.suiteReasons.browser).toMatch(/browser suite/);+ });++ it('runs every tracked server browser suite on a full plan, and none from client or non-browser tests', () => {+ const trackedFiles = [+ ...BROWSER_SUITES,+ 'client/src/pages/Shell.browser.test.js',+ 'server/routes/browser.test.js',+ ];+ const plan = buildCiTestPlan(['package.json'], { trackedFiles });++ expect(plan.full).toBe(true);+ expect(plan.browserFiles).toEqual(BROWSER_SUITES);+ });++ it('selects nothing when the diff names no browser suite, and ignores a deleted suite', () => {+ const trackedFiles = [...BROWSER_SUITES, 'server/services/auth.js', 'server/services/auth.test.js'];++ expect(buildCiTestPlan(['server/services/auth.js'], { trackedFiles }).browserFiles).toEqual([]);+ expect(buildCiTestPlan(['README.md'], { trackedFiles }).browserFiles).toEqual([]);+ // A deleted path is not in trackedFiles, so it cannot become a vitest selector.+ expect(buildCiTestPlan(['server/routes/gone.browser.test.js'], { trackedFiles }).browserFiles).toEqual([]);+ });++ it('selects a browser suite that is itself the changed file', () => {+ const plan = buildCiTestPlan([BROWSER_SUITES[0]], { trackedFiles: BROWSER_SUITES });++ expect(plan.browserFiles).toEqual([BROWSER_SUITES[0]]);+ });+});diff --git a/scripts/run-ci-tests.test.js b/scripts/run-ci-tests.test.jsindex 64861821e3..8280fd4138 100644--- a/scripts/run-ci-tests.test.js+++ b/scripts/run-ci-tests.test.js@@ -45,8 +45,11 @@ describe('ci.yml shard wiring', () => {const runners = Object.entries(workflowJobs(WORKFLOW)).filter(([, body]) => body.includes('run-ci-tests.js'));it('builds every test runner matrix from the planner and hands each slice to the runner', () => {- expect(runners.map(([id]) => id).sort()).toEqual(['client', 'server', 'windows-server']);- for (const [id, body] of runners) {+ expect(runners.map(([id]) => id).sort()).toEqual(['client', 'database', 'server', 'windows-server']);+ // `database` runs run-ci-tests.js only in `files` mode, for the+ // cross-workspace browser suites the planner selected (#10312): an exact+ // file list has nothing to shard, so it is the one runner without a matrix.+ for (const [id, body] of runners.filter(([id]) => id !== 'database')) {// The fan-out is decided by the impact job, never hardcoded here: a// scoped plan must collapse to one runner, and a job-level `if` cannot// read `matrix` to skip the extra shards itself.@@ -58,6 +61,20 @@ describe('ci.yml shard wiring', () => {}});+ it('runs the planner-selected browser suites on the database job with prerequisites required (#10312)', () => {+ const body = workflowJobs(WORKFLOW).database;+ expect(body).toContain("if: needs.impact.outputs.db == 'true' || needs.impact.outputs.browser_files != '[]'");+ const start = body.indexOf('- name: Run cross-workspace browser suites');+ expect(start).toBeGreaterThan(0);+ const step = body.slice(start, body.indexOf('- name:', start + 1));+ expect(step).toContain('CI_TEST_MODE: files');+ expect(step).toContain('CI_TEST_FILES: ${{ needs.impact.outputs.browser_files }}');+ expect(step).toContain("PORTOS_REQUIRE_BROWSER_SUITES: '1'");+ // The client workspace must be installed before the suites bundle it.+ expect(body.indexOf('npm ci --prefix client')).toBeGreaterThan(0);+ expect(body.indexOf('npm ci --prefix client')).toBeLessThan(start);+ });+it('runs once-only steps on the first shard alone', () => {// Smoke boot, the production build, and the Scalar-removal pin are not// sharded work; on every shard they would triple the cost for no coverage.diff --git a/server/deadExports.test.js b/server/deadExports.test.jsindex 59fdbbc43f..6c01c34f58 100644--- a/server/deadExports.test.js+++ b/server/deadExports.test.js@@ -16,6 +16,7 @@ function excluded(file, name) {if (file.startsWith('server/integrations/')) return true; // Standalone integration API clients.if (file.startsWith('server/lib/aiToolkit/')) return true; // Vendored toolkit public barrel surface.if (file === 'server/lib/mockPathsDataRoot.js') return true; // Test-only helper module (#9032) — every export here is meant to be reached exclusively from *.test.js, which this scan intentionally excludes as a "mention".+ if (file === 'server/lib/browserSuiteGate.js') return true; // Test-only `canRun` guard (#10312) — reached exclusively from *.browser.test.js.return false;}diff --git a/server/envExampleDrift.test.js b/server/envExampleDrift.test.jsindex c4699167ea..eac55206b8 100644--- a/server/envExampleDrift.test.js+++ b/server/envExampleDrift.test.js@@ -112,6 +112,7 @@ const INHERITED_ENV = {TEST_DB_OK: 'test-harness flag for the DB-backed suites',PGTESTDATABASE: 'test-harness override naming portos_test',PORTOS_REQUIRE_DB: 'CI flag that turns a skipped DB suite into a failure',+ PORTOS_REQUIRE_BROWSER_SUITES: 'CI flag that turns a skipped cross-workspace browser suite into a failure',PORTOS_TEST_PYTHON: 'test-harness interpreter override',PORTOS_TEST_QUIET: 'test-harness log silencer',};diff --git a/server/lib/README.md b/server/lib/README.mdindex 5041d2a42d..fd50f6e4ba 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -740,6 +740,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| Module | Purpose ||---|---|+| `browserSuiteGate.js` | `browserSuiteCanRun(label, prerequisites)` is the `canRun` guard for the cross-workspace `*.browser.test.js` suites (Chrome + ffmpeg + the client bundler). Pass `{ name: discoveredValue }`; a falsy value is missing. Returns `false` with a visible skip log locally, but throws naming the missing prerequisites when `PORTOS_REQUIRE_BROWSER_SUITES` is set — the flag the CI `database` job sets for the browser suites the planner selected (#10312). || `dbTestGate.js` | `requireDbOrSkip(label, dbReady, reason)` keeps a missing local test database as a visible skipped suite, but throws when `PORTOS_REQUIRE_DB` is set so CI cannot pass after DB-backed suites disappear. || `gitTestRepo.js` | Shared real-git sandbox for integration tests (#4394): one initialized template (working tree + bare origin) per worker, then `fs.cp` into a fresh temp dir. `makeGitSandbox({ origin })`, `attachBareOrigin(scratch, repo)`, `materializeGitRepo(dest)`, `destroyGitSandbox`, plus `SKIP_HEAVY_INTEGRATION` (`VITEST_FAST=1`). `resetGitSandbox({ scratch, repo, initialHead })` / `resetGitWorktreeSandbox(repo, initialHead)` restore a sandbox in place (branches, worktrees, remote) so a `describe` can build one sandbox in `beforeAll` and reset between tests instead of paying the fs.cp/rm cycle per test (#5902). Every entry point runs `assertTempPath` first, so a path outside `os.tmpdir()` throws instead of `git init`-ing or `rm -rf`-ing a real checkout (#4554). Still real git — just not rebuilt from `init`+`commit`+`push` in every `beforeEach`. || `mirrorParity.js` | Source-extraction and comparison primitives for declaration-level contract tests: the vendored `aiToolkit/` copy of `TOOL_USE_RE` (`localModelHeuristics.mirror.test.js`), and the bootstrap sequence's body assertions (`bootstrap*.test.js`). A pure module the browser needs is imported by the client rather than mirrored, so no client↔server copy test should need these: `stripCommentsAndNormalize` (so per-side commentary may diverge but logic may not), `extractDeclaration(src, name)` (balanced `{}`/`()`/`[]` walk over `function` / `async function` / `const`), and `compareDeclaration(serverSrc, clientSrc, name)`. Use these instead of hand-rolling a brace-walker per mirror. Pure — no `vitest` import — so callers own the assertions. |diff --git a/server/lib/browserSuiteGate.js b/server/lib/browserSuiteGate.jsnew file mode 100644index 0000000000..ea656ea904--- /dev/null+++ b/server/lib/browserSuiteGate.js@@ -0,0 +1,23 @@+/**+ * Keep cross-workspace browser suites as visible skips on machines without+ * Chrome, ffmpeg or the client workspace, while letting the one CI job that+ * provisions them fail fast instead of passing green on a skip.+ *+ * `prerequisites` maps a human label to whatever was discovered (a path, a+ * resolved bundler list, or undefined/null when absent). `onUnavailable` runs+ * before the skip or the throw: prerequisite discovery can initialize mocked+ * path fixtures, and Vitest runs no cleanup hooks for a skipped (or failed) file.+ */+export function browserSuiteCanRun(label, prerequisites, { onUnavailable } = {}) {+ const missing = Object.entries(prerequisites).filter(([, found]) => !found).map(([name]) => name);+ if (missing.length === 0) return true;++ onUnavailable?.();+ const reason = `missing ${missing.join(', ')}`;+ if (process.env.PORTOS_REQUIRE_BROWSER_SUITES) {+ throw new Error(`${label}: browser suite skipped but PORTOS_REQUIRE_BROWSER_SUITES is set — ${reason}`);+ }++ console.log(`⏭️ ${label}: skipping suite — ${reason}`);+ return false;+}diff --git a/server/lib/browserSuiteGate.test.js b/server/lib/browserSuiteGate.test.jsnew file mode 100644index 0000000000..dc2e59dbba--- /dev/null+++ b/server/lib/browserSuiteGate.test.js@@ -0,0 +1,46 @@+import { afterEach, describe, expect, it, vi } from 'vitest';+import { browserSuiteCanRun } from './browserSuiteGate.js';++const original = process.env.PORTOS_REQUIRE_BROWSER_SUITES;++afterEach(() => {+ if (original === undefined) delete process.env.PORTOS_REQUIRE_BROWSER_SUITES;+ else process.env.PORTOS_REQUIRE_BROWSER_SUITES = original;+ vi.restoreAllMocks();+});++describe('browserSuiteCanRun', () => {+ it('skips with a visible log naming the missing prerequisites when the flag is unset', () => {+ delete process.env.PORTOS_REQUIRE_BROWSER_SUITES;+ const log = vi.spyOn(console, 'log').mockImplementation(() => {});++ expect(browserSuiteCanRun('suite', { Chrome: '/usr/bin/chrome', ffmpeg: null, 'client bundler': undefined })).toBe(false);+ expect(log).toHaveBeenCalledWith('⏭️ suite: skipping suite — missing ffmpeg, client bundler');+ });++ it('fails loudly, naming the missing prerequisites, when CI requires browser suites', () => {+ process.env.PORTOS_REQUIRE_BROWSER_SUITES = '1';++ expect(() => browserSuiteCanRun('suite', { Chrome: '/usr/bin/chrome', 'client bundler': undefined }))+ .toThrow('suite: browser suite skipped but PORTOS_REQUIRE_BROWSER_SUITES is set — missing client bundler');+ });++ it('runs the cleanup hook before it skips or throws, since Vitest runs no hooks for a skipped file', () => {+ const onUnavailable = vi.fn();+ vi.spyOn(console, 'log').mockImplementation(() => {});++ delete process.env.PORTOS_REQUIRE_BROWSER_SUITES;+ browserSuiteCanRun('suite', { Chrome: null }, { onUnavailable });+ process.env.PORTOS_REQUIRE_BROWSER_SUITES = '1';+ expect(() => browserSuiteCanRun('suite', { Chrome: null }, { onUnavailable })).toThrow();+ expect(onUnavailable).toHaveBeenCalledTimes(2);+ });++ it('runs, even when the flag is set, once every prerequisite is present', () => {+ process.env.PORTOS_REQUIRE_BROWSER_SUITES = '1';+ const log = vi.spyOn(console, 'log').mockImplementation(() => {});++ expect(browserSuiteCanRun('suite', { Chrome: '/usr/bin/chrome', ffmpeg: '/usr/bin/ffmpeg' })).toBe(true);+ expect(log).not.toHaveBeenCalled();+ });+});diff --git a/server/lib/index.js b/server/lib/index.jsindex 43858a2866..e61936f7d4 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -715,6 +715,7 @@ export * from './gitTestRepo.js';export * from './mockPathsDataRoot.js';export * from './settingsTestUtil.js';export * from './dbTestGate.js';+export * from './browserSuiteGate.js';export * from './runtimeEnv.js';export * from './testDataIsolation.js';export * from './testHelper.js';diff --git a/server/routes/musicVideoProductionReview.browser.test.js b/server/routes/musicVideoProductionReview.browser.test.jsindex e57e1422a1..926bb1228a 100644--- a/server/routes/musicVideoProductionReview.browser.test.js+++ b/server/routes/musicVideoProductionReview.browser.test.js@@ -9,6 +9,7 @@ import { chromium } from 'playwright-core';import { createRequire } from 'node:module';import { makePathsProxy, lazyTempDataRoot, cleanupTempDataRoots } from '../lib/mockPathsDataRoot.js';import { errorMiddleware } from '../lib/errorHandler.js';+import { browserSuiteCanRun } from '../lib/browserSuiteGate.js';vi.mock('../lib/paths.js', async original => makePathsProxy(await original(), { dataRoot: () => lazyTempDataRoot('mv-review-browser-') }));vi.mock('../services/instanceIdentity.js', () => ({ ensureInstanceId: async () => 'synthetic-instance' }));@@ -33,8 +34,7 @@ try {// Dependency discovery can read the mocked PATHS through ffmpeg imports.// Vitest does not run afterAll when the whole suite is skipped.-const canRun = Boolean(chrome && ffmpeg && clientBundler);-if (!canRun) cleanupTempDataRoots();+const canRun = browserSuiteCanRun('musicVideo browser suite', { Chrome: chrome, ffmpeg, 'client workspace dependencies': clientBundler }, { onUnavailable: cleanupTempDataRoots });let browser, proc, server;afterAll(async () => {diff --git a/server/routes/musicVideoRichAuthoring.browser.test.js b/server/routes/musicVideoRichAuthoring.browser.test.jsindex 4284eda95d..e04b67706e 100644--- a/server/routes/musicVideoRichAuthoring.browser.test.js+++ b/server/routes/musicVideoRichAuthoring.browser.test.js@@ -17,6 +17,7 @@ import { chromium } from 'playwright-core';import { createRequire } from 'node:module';import { makePathsProxy, lazyTempDataRoot, cleanupTempDataRoots } from '../lib/mockPathsDataRoot.js';import { errorMiddleware } from '../lib/errorHandler.js';+import { browserSuiteCanRun } from '../lib/browserSuiteGate.js';vi.mock('../lib/paths.js', async original => makePathsProxy(await original(), { dataRoot: () => lazyTempDataRoot('mv-rich-ui-browser-') }));vi.mock('../services/instanceIdentity.js', () => ({ ensureInstanceId: async () => 'synthetic-instance' }));@@ -41,8 +42,7 @@ try {// Read-only dependency discovery can still initialize mocked path fixtures.// Vitest skips cleanup hooks when no browser test can run.-const canRun = Boolean(chrome && ffmpeg && clientBundler);-if (!canRun) cleanupTempDataRoots();+const canRun = browserSuiteCanRun('musicVideo browser suite', { Chrome: chrome, ffmpeg, 'client workspace dependencies': clientBundler }, { onUnavailable: cleanupTempDataRoots });let browser, proc, server;afterAll(async () => {diff --git a/server/routes/musicVideoSongRevision.browser.test.js b/server/routes/musicVideoSongRevision.browser.test.jsindex 7efc1158b7..2d003838ce 100644--- a/server/routes/musicVideoSongRevision.browser.test.js+++ b/server/routes/musicVideoSongRevision.browser.test.js@@ -10,6 +10,7 @@ import { createRequire } from 'node:module';import { chromium } from 'playwright-core';import { makePathsProxy, lazyTempDataRoot, cleanupTempDataRoots } from '../lib/mockPathsDataRoot.js';import { errorMiddleware } from '../lib/errorHandler.js';+import { browserSuiteCanRun } from '../lib/browserSuiteGate.js';vi.mock('../lib/paths.js', async original => makePathsProxy(await original(), { dataRoot: () => lazyTempDataRoot('mv-song-browser-') }));vi.mock('../services/settings.js', () => ({ getSettings: async () => ({}) }));const { _testChromeCaptureArgs, _waitForTestChrome, _cleanupTestBrowser } = await import('../services/htmlComposition/testBrowserCleanup.js');@@ -19,9 +20,8 @@ const requireClient = createRequire(join(client, 'package.json'));let bundler;try { bundler = ['vite', '@vitejs/plugin-react', '@tailwindcss/postcss'].map(name => requireClient.resolve(name)); }catch (err) { if (err.code !== 'MODULE_NOT_FOUND') throw err; }-const canRun = Boolean(chrome && bundler);+const canRun = browserSuiteCanRun('song revision browser suite', { Chrome: chrome, 'client workspace dependencies': bundler }, { onUnavailable: cleanupTempDataRoots });// Prerequisite discovery may initialize mocked paths; skipped suites have no cleanup hooks.-if (!canRun) cleanupTempDataRoots();let browser, proc, server, io, songs, musicVideoEvents;const broadcast = event => io.emit('music-video:song-revision', event);afterAll(async () => {