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
refactor: share one test-Chrome resolver across browser suites, pregate and CI warm-up (#12315)
[._.]/ Adam Eivybda40eed3169
diff --git a/client/src/components/CmdKSearch.browser.test.js b/client/src/components/CmdKSearch.browser.test.jsindex d0748c6176..f25b54c5d1 100644--- a/client/src/components/CmdKSearch.browser.test.js+++ b/client/src/components/CmdKSearch.browser.test.js@@ -1,12 +1,12 @@// @vitest-environment nodeimport { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { createRequire } from 'node:module';import { join } from 'node:path';import { fileURLToPath } from 'node:url';import { createServer } from 'vite';import react from '@vitejs/plugin-react';import { BROWSER_FIXTURE_STARTUP_MS, startBrowserFixture } from '../test/browserFixture.js';+import { resolveTestChrome } from '../../../server/lib/browserSuiteGate.js';const require = createRequire(import.meta.url);// Prefer the client dev dependency; linked worktrees can also use the same@@ -15,10 +15,7 @@ const { chromium } = require(require.resolve('playwright-core', { paths: [fileURLToPath(new URL('../..', import.meta.url)),fileURLToPath(new URL('../../../server', import.meta.url)),] }));-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();describe.skipIf(!chrome)('command palette viewport and keyboard layout', () => {let browser;diff --git a/client/src/components/Drawer.browser.test.js b/client/src/components/Drawer.browser.test.jsindex 0e17a60661..6cff630aa3 100644--- a/client/src/components/Drawer.browser.test.js+++ b/client/src/components/Drawer.browser.test.js@@ -1,18 +1,15 @@// @vitest-environment nodeimport { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { join } from 'node:path';import { fileURLToPath } from 'node:url';import { createServer } from 'vite';import react from '@vitejs/plugin-react';import { chromium } from 'playwright-core';import { BROWSER_FIXTURE_STARTUP_MS, startBrowserFixture } from '../test/browserFixture.js';+import { resolveTestChrome } from '../../../server/lib/browserSuiteGate.js';const auditCdp = process.env.PORTOS_AUDIT_CDP;-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();// Native :disabled includes inherited fieldset state and the first-legend// exception. Happy DOM does not model it, so exercise actual browser tab order.diff --git a/client/src/components/ProviderModelSelector.browser.test.js b/client/src/components/ProviderModelSelector.browser.test.jsindex ea9c7a4ee1..01ea18e46d 100644--- a/client/src/components/ProviderModelSelector.browser.test.js+++ b/client/src/components/ProviderModelSelector.browser.test.js@@ -1,17 +1,14 @@// @vitest-environment nodeimport { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { join } from 'node:path';import { fileURLToPath } from 'node:url';import { createServer } from 'vite';import react from '@vitejs/plugin-react';import { chromium } from 'playwright-core';import { BROWSER_FIXTURE_STARTUP_MS, startBrowserFixture } from '../test/browserFixture.js';+import { resolveTestChrome } from '../../../server/lib/browserSuiteGate.js';-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();const isFixtureRequest = (origin, route) => {const url = new URL(route.request().url());diff --git a/client/src/components/ThemeSwitcher.browser.test.js b/client/src/components/ThemeSwitcher.browser.test.jsindex 66808ef2e1..64a33242bf 100644--- a/client/src/components/ThemeSwitcher.browser.test.js+++ b/client/src/components/ThemeSwitcher.browser.test.js@@ -1,6 +1,5 @@// @vitest-environment nodeimport { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { createRequire } from 'node:module';import { join } from 'node:path';import { fileURLToPath } from 'node:url';@@ -8,16 +7,14 @@ import { createServer } from 'vite';import react from '@vitejs/plugin-react';import { BROWSER_FIXTURE_STARTUP_MS, startBrowserFixture } from '../test/browserFixture.js';import { THEME_IDS } from '../themes/portosThemes.js';+import { resolveTestChrome } from '../../../server/lib/browserSuiteGate.js';const require = createRequire(import.meta.url);const { chromium } = require(require.resolve('playwright-core', { paths: [fileURLToPath(new URL('../..', import.meta.url)),fileURLToPath(new URL('../../../server', import.meta.url)),] }));-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();describe.skipIf(!chrome)('theme chooser in short viewports', () => {let browser;diff --git a/client/src/components/brain/tabs/InboxTab.browser.test.js b/client/src/components/brain/tabs/InboxTab.browser.test.jsindex aa9acb57f4..8a8f31a3b6 100644--- a/client/src/components/brain/tabs/InboxTab.browser.test.js+++ b/client/src/components/brain/tabs/InboxTab.browser.test.js@@ -1,12 +1,12 @@// @vitest-environment nodeimport { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';-import { existsSync } from 'node:fs';import { createRequire } from 'node:module';import { join } from 'node:path';import { fileURLToPath } from 'node:url';import { createServer } from 'vite';import react from '@vitejs/plugin-react';import { BROWSER_FIXTURE_STARTUP_MS, startBrowserFixture } from '../../../test/browserFixture.js';+import { resolveTestChrome } from '../../../../../server/lib/browserSuiteGate.js';// Browser startup/navigation is bounded separately from 5s interactions.vi.setConfig({ testTimeout: 30000 });@@ -18,10 +18,7 @@ const { chromium } = require(require.resolve('playwright-core', { paths: [fileURLToPath(new URL('../../../..', import.meta.url)),fileURLToPath(new URL('../../../../../server', import.meta.url)),] }));-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();describe.skipIf(!chrome)('Brain inbox capture geometry', () => {let fixture;diff --git a/client/src/components/cos/tabs/RunsTab.browser.test.js b/client/src/components/cos/tabs/RunsTab.browser.test.jsindex 7e50787981..2145f7e4ec 100644--- a/client/src/components/cos/tabs/RunsTab.browser.test.js+++ b/client/src/components/cos/tabs/RunsTab.browser.test.js@@ -1,18 +1,15 @@// @vitest-environment nodeimport { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { join } from 'node:path';import { fileURLToPath } from 'node:url';import { createServer } from 'vite';import react from '@vitejs/plugin-react';import { chromium } from 'playwright-core';import { BROWSER_FIXTURE_STARTUP_MS, startBrowserFixture } from '../../../test/browserFixture.js';+import { resolveTestChrome } from '../../../../../server/lib/browserSuiteGate.js';const auditCdp = process.env.PORTOS_AUDIT_CDP;-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();// Happy DOM cannot expose hover-gated opacity or real touch geometry. Exercise// the actual row actions and stylesheet, without calling the running instance.diff --git a/client/src/components/goals/GoalsOrganization.browser.test.js b/client/src/components/goals/GoalsOrganization.browser.test.jsindex 2599016fc4..30e7d92d29 100644--- a/client/src/components/goals/GoalsOrganization.browser.test.js+++ b/client/src/components/goals/GoalsOrganization.browser.test.js@@ -1,6 +1,5 @@// @vitest-environment nodeimport { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { createRequire } from 'node:module';import { join } from 'node:path';import { fileURLToPath } from 'node:url';@@ -8,13 +7,11 @@ import { createServer } from 'vite';import react from '@vitejs/plugin-react';import { BROWSER_FIXTURE_STARTUP_MS, startBrowserFixture } from '../../test/browserFixture.js';import { ASYNC_UTIL_TIMEOUT_MS } from '../../test/timeouts.js';+import { resolveTestChrome } from '../../../../server/lib/browserSuiteGate.js';const require = createRequire(import.meta.url);const { chromium } = require('playwright-core');-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();describe.skipIf(!chrome)('Goals organization responsive controls (#9712)', () => {let browser;diff --git a/client/src/components/goals/GoalsTreeView.browser.test.js b/client/src/components/goals/GoalsTreeView.browser.test.jsindex e7f1bdd082..4f4ce1a7e9 100644--- a/client/src/components/goals/GoalsTreeView.browser.test.js+++ b/client/src/components/goals/GoalsTreeView.browser.test.js@@ -1,12 +1,12 @@// @vitest-environment nodeimport { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { createRequire } from 'node:module';import { join } from 'node:path';import { fileURLToPath } from 'node:url';import { createServer } from 'vite';import react from '@vitejs/plugin-react';import { BROWSER_FIXTURE_STARTUP_MS, startBrowserFixture } from '../../test/browserFixture.js';+import { resolveTestChrome } from '../../../../server/lib/browserSuiteGate.js';const require = createRequire(import.meta.url);// Prefer the client dev dependency; linked worktrees can also use the same@@ -15,10 +15,7 @@ const { chromium } = require(require.resolve('playwright-core', { paths: [fileURLToPath(new URL('../../..', import.meta.url)),fileURLToPath(new URL('../../../../server', import.meta.url)),] }));-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();// No live API or external service is reachable from this fixture.const isolateFixture = origin => route => {diff --git a/client/src/components/media/MediaLightbox.browser.test.js b/client/src/components/media/MediaLightbox.browser.test.jsindex dd83497aa7..b718556043 100644--- a/client/src/components/media/MediaLightbox.browser.test.js+++ b/client/src/components/media/MediaLightbox.browser.test.js@@ -1,22 +1,19 @@// @vitest-environment nodeimport { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { createRequire } from 'node:module';import { join } from 'node:path';import { fileURLToPath } from 'node:url';import { createServer } from 'vite';import react from '@vitejs/plugin-react';import { BROWSER_FIXTURE_STARTUP_MS, startBrowserFixture } from '../../test/browserFixture.js';+import { resolveTestChrome } from '../../../../server/lib/browserSuiteGate.js';const require = createRequire(import.meta.url);const { chromium } = require(require.resolve('playwright-core', { paths: [fileURLToPath(new URL('../../..', import.meta.url)),fileURLToPath(new URL('../../../../server', import.meta.url)),] }));-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();// The document's activeElement stays VIDEO throughout native control traversal.// CDP reads its user-agent shadow root without changing the player or tab order.diff --git a/client/src/components/ui/InfoTooltip.browser.test.js b/client/src/components/ui/InfoTooltip.browser.test.jsindex 27c872ff25..09dca3497f 100644--- a/client/src/components/ui/InfoTooltip.browser.test.js+++ b/client/src/components/ui/InfoTooltip.browser.test.js@@ -1,22 +1,19 @@// @vitest-environment nodeimport { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { createRequire } from 'node:module';import { join } from 'node:path';import { fileURLToPath } from 'node:url';import { createServer } from 'vite';import react from '@vitejs/plugin-react';import { BROWSER_FIXTURE_STARTUP_MS, startBrowserFixture } from '../../test/browserFixture.js';+import { resolveTestChrome } from '../../../../server/lib/browserSuiteGate.js';const require = createRequire(import.meta.url);const { chromium } = require(require.resolve('playwright-core', { paths: [fileURLToPath(new URL('../../..', import.meta.url)),fileURLToPath(new URL('../../../../server', import.meta.url)),] }));-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();describe.skipIf(!chrome)('help above glass cards and clipped scrollers', () => {let browser;diff --git a/client/src/components/ui/OverflowMenu.browser.test.js b/client/src/components/ui/OverflowMenu.browser.test.jsindex 0397688435..8844ff242a 100644--- a/client/src/components/ui/OverflowMenu.browser.test.js+++ b/client/src/components/ui/OverflowMenu.browser.test.js@@ -1,12 +1,12 @@// @vitest-environment nodeimport { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { createRequire } from 'node:module';import { join } from 'node:path';import { fileURLToPath } from 'node:url';import { createServer } from 'vite';import react from '@vitejs/plugin-react';import { BROWSER_FIXTURE_STARTUP_MS, startBrowserFixture } from '../../test/browserFixture.js';+import { resolveTestChrome } from '../../../../server/lib/browserSuiteGate.js';const require = createRequire(import.meta.url);// Prefer the client dev dependency; linked worktrees can also use the same@@ -16,10 +16,7 @@ const { chromium } = require(require.resolve('playwright-core', { paths: [fileURLToPath(new URL('../../../../server', import.meta.url)),] }));const auditCdp = process.env.PORTOS_AUDIT_CDP;-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();describe.skipIf(!chrome && !auditCdp)('overflow menu keyboard focus', () => {let browser;diff --git a/client/src/pages/Loras.browser.test.js b/client/src/pages/Loras.browser.test.jsindex 45546504ed..8dd58c3998 100644--- a/client/src/pages/Loras.browser.test.js+++ b/client/src/pages/Loras.browser.test.js@@ -1,17 +1,14 @@// @vitest-environment nodeimport { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { join } from 'node:path';import { fileURLToPath } from 'node:url';import { createServer } from 'vite';import react from '@vitejs/plugin-react';import { chromium } from 'playwright-core';import { BROWSER_FIXTURE_STARTUP_MS, startBrowserFixture } from '../test/browserFixture.js';+import { resolveTestChrome } from '../../../server/lib/browserSuiteGate.js';-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();const isFixtureRequest = (origin, route) => {const url = new URL(route.request().url());diff --git a/client/src/pages/PromptManager.browser.test.js b/client/src/pages/PromptManager.browser.test.jsindex c8065019ec..b359e77630 100644--- a/client/src/pages/PromptManager.browser.test.js+++ b/client/src/pages/PromptManager.browser.test.js@@ -1,12 +1,12 @@// @vitest-environment nodeimport { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';-import { existsSync } from 'node:fs';import { createRequire } from 'node:module';import { join } from 'node:path';import { fileURLToPath } from 'node:url';import { createServer } from 'vite';import react from '@vitejs/plugin-react';import { BROWSER_FIXTURE_STARTUP_MS, startBrowserFixture } from '../test/browserFixture.js';+import { resolveTestChrome } from '../../../server/lib/browserSuiteGate.js';vi.setConfig({ testTimeout: 30000 });@@ -17,10 +17,7 @@ const { chromium } = require(require.resolve('playwright-core', { paths: [fileURLToPath(new URL('../..', import.meta.url)),fileURLToPath(new URL('../../../server', import.meta.url)),] }));-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();// Where the Layout would put the page: the viewport minus the sidebar. The// fixture draws that box itself, so the matrix can vary navigation state.diff --git a/client/src/pages/Shell.browser.test.js b/client/src/pages/Shell.browser.test.jsindex 1f081dd900..ba1014d100 100644--- a/client/src/pages/Shell.browser.test.js+++ b/client/src/pages/Shell.browser.test.js@@ -1,17 +1,14 @@// @vitest-environment nodeimport { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { join } from 'node:path';import { fileURLToPath } from 'node:url';import { createServer } from 'vite';import react from '@vitejs/plugin-react';import { BROWSER_FIXTURE_STARTUP_MS, startBrowserFixture } from '../test/browserFixture.js';import { chromium } from 'playwright-core';+import { resolveTestChrome } from '../../../server/lib/browserSuiteGate.js';-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();const isFixtureRequest = (origin, route) => {const url = new URL(route.request().url());diff --git a/client/src/pages/StoryBuilder.browser.test.js b/client/src/pages/StoryBuilder.browser.test.jsindex 97efe98ec8..3cc77d5322 100644--- a/client/src/pages/StoryBuilder.browser.test.js+++ b/client/src/pages/StoryBuilder.browser.test.js@@ -1,17 +1,14 @@// @vitest-environment nodeimport { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { join } from 'node:path';import { fileURLToPath } from 'node:url';import { createServer } from 'vite';import react from '@vitejs/plugin-react';import { chromium } from 'playwright-core';import { BROWSER_FIXTURE_STARTUP_MS, startBrowserFixture } from '../test/browserFixture.js';+import { resolveTestChrome } from '../../../server/lib/browserSuiteGate.js';-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();const steps = ['idea', 'universeAesthetic', 'plotArc', 'readerMap', 'characters', 'issues', 'production'].map((id, index) => ({ id, label: ['Idea', 'Universe Aesthetic', 'Plot Arc', 'Reader Map', 'Characters', 'Issues', 'Production'][index], description: 'Review the current work.' }));diff --git a/scripts/browser-fidelity.js b/scripts/browser-fidelity.jsindex 7638825bfd..202f7fd4eb 100644--- a/scripts/browser-fidelity.js+++ b/scripts/browser-fidelity.js@@ -1,9 +1,8 @@#!/usr/bin/env nodeimport { execFileSync } from 'node:child_process';-import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';+import { lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';import { dirname, join, resolve } from 'node:path';-import { createRequire } from 'node:module';import { fileURLToPath } from 'node:url';import { tmpdir, platform, arch } from 'node:os';import { runNpm, toRunnerPath } from './run-ci-tests.js';@@ -40,18 +39,14 @@ export function fidelityChildEnv(env, diagnostics) {}async function fidelityToolchain(env) {- const require = createRequire(new URL('../server/package.json', import.meta.url));- const { chromium } = require('playwright-core');const { findFfmpeg } = await import('../server/lib/ffmpeg.js');const { _testChromeCaptureArgs } = await import('../server/services/htmlComposition/testBrowserCleanup.js');- const chromePath = [env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/usr/bin/google-chrome',- '/usr/bin/chromium', '/usr/bin/chromium-browser'].find(path => path && existsSync(path));+ const { resolveTestChrome, probeChromeH264, describeH264Probe } = await import('../server/lib/browserSuiteGate.js');+ const chromePath = resolveTestChrome(env);const ffmpegPath = await findFfmpeg();if (!chromePath || !ffmpegPath) throw Error('Fidelity Chrome/FFmpeg toolchain unavailable.');// Surface the structured probe cause here: the suite's own prerequisite gate// reports through vitest output, which this command's refusal never relays.- const { probeChromeH264, describeH264Probe } = await import('../server/lib/browserSuiteGate.js');const probe = await probeChromeH264(chromePath);if (!probe.ok) throw Error(describeH264Probe(probe));const version = (path, args) => {diff --git a/scripts/browser-suite-registry.test.js b/scripts/browser-suite-registry.test.jsindex d60aab877c..8b4414837d 100644--- a/scripts/browser-suite-registry.test.js+++ b/scripts/browser-suite-registry.test.js@@ -11,7 +11,7 @@ const root = fileURLToPath(new URL('../', import.meta.url));// Scans the tracked tree, so it is registered in ALWAYS_RUN_TESTS (#10312).describe('cross-workspace browser suite registry', () => {it('lists exactly the suites that guard canRun with the browser suite gate', () => {- const gated = execFileSync('git', ['grep', '-l', 'browserSuiteGate', '--', 'server/**/*.browser.test.js'], { cwd: root, encoding: 'utf8' })+ const gated = execFileSync('git', ['grep', '-l', 'browserSuiteCanRun', '--', 'server/**/*.browser.test.js'], { cwd: root, encoding: 'utf8' }).split('\n').filter(Boolean).sort();expect(gated).toEqual([...BROWSER_SUITES].sort());});diff --git a/scripts/ci-warm-test-chrome.sh b/scripts/ci-warm-test-chrome.shindex fcb3b0392d..469e20c79a 100755--- a/scripts/ci-warm-test-chrome.sh+++ b/scripts/ci-warm-test-chrome.sh@@ -22,7 +22,15 @@set -uo pipefailBUDGET="${CHROME_WARM_BUDGET_SECONDS:-90}"-read -r -a CANDIDATES <<< "${CHROME_WARM_CANDIDATES:-${CHROME_PATH:-} /usr/bin/google-chrome /usr/bin/chromium /usr/bin/chromium-browser}"+# The default list is resolveTestChrome's (server/lib/browserSuiteGate.js), the one+# resolver the suites, pregate and test memo share (#12315): this asks it for the+# Chrome a suite would launch rather than keeping a shell copy of the paths.+if [ -n "${CHROME_WARM_CANDIDATES+x}" ]; then+ read -r -a CANDIDATES <<< "$CHROME_WARM_CANDIDATES"+else+ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"+ CANDIDATES=("$(node -e "import(require('url').pathToFileURL(process.argv[1])).then((m) => process.stdout.write(m.resolveTestChrome() ?? ''))" "$ROOT/server/lib/browserSuiteGate.js" 2>/dev/null)")+fi# Never replace the wall-clock budget with an unbounded read. GNU coreutils# installs timeout as gtimeout on some developer machines.diff --git a/scripts/lib/pregateResources.js b/scripts/lib/pregateResources.jsindex 29b6ea9955..4ca624df74 100644--- a/scripts/lib/pregateResources.js+++ b/scripts/lib/pregateResources.js@@ -9,13 +9,12 @@* never substitutes for the suite. A failed probe leaves the suite reported* as not covered, with the remedy, rather than a green stage that ran nothing.*/-import { existsSync } from 'node:fs';import { createRequire } from 'node:module';import { join } from 'node:path';import databaseSettings from './databaseSettings.cjs';import { parseEnvFile } from './envFile.js';import { findFfmpeg } from '../../server/lib/ffmpeg.js';-import { browserSuiteBlockReason, chromeWithH264 } from '../../server/lib/browserSuiteGate.js';+import { browserSuiteBlockReason, chromeWithH264, resolveTestChrome } from '../../server/lib/browserSuiteGate.js';/** The only database the DB stage may target; `server/lib/db.js` refuses the rest. */export const TEST_DATABASE = 'portos_test';@@ -27,11 +26,6 @@ const ROUTING_ENV = ['PGHOSTADDR', 'PGSERVICE', 'PGSERVICEFILE', 'PGOPTIONS'];/** The suite whose guard also needs a Chrome that decodes H.264. */const H264_SUITE = 'server/services/musicVideo/documentRender.browser.test.js';-// The same candidate order every registered browser suite uses to find Chrome.-const CHROME_CANDIDATES = [- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-];const CLIENT_BUNDLER_PACKAGES = ['vite', '@vitejs/plugin-react', '@tailwindcss/postcss'];/**@@ -109,14 +103,7 @@ export async function probeTestDatabase(stageEnv, { repoRoot }) {* decode — and return the guards' own wording when something is missing.*/export async function probeBrowserPrerequisites(files, { repoRoot, env = process.env }) {- const requireServer = createRequire(join(repoRoot, 'server', 'package.json'));- let bundledChrome;- try {- bundledChrome = requireServer('playwright-core').chromium.executablePath();- } catch (error) {- if (error.code !== 'MODULE_NOT_FOUND') throw error;- }- const chrome = [env.CHROME_PATH, bundledChrome, ...CHROME_CANDIDATES].find((path) => path && existsSync(path));+ const chrome = resolveTestChrome(env);let bundler;try {const requireClient = createRequire(join(repoRoot, 'client', 'package.json'));diff --git a/server/lib/filmLook.browser.test.js b/server/lib/filmLook.browser.test.jsindex 51f0c8c13d..fe3fb68654 100644--- a/server/lib/filmLook.browser.test.js+++ b/server/lib/filmLook.browser.test.js@@ -1,11 +1,10 @@import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';-import { existsSync } from 'node:fs';import { mkdir, writeFile } from 'node:fs/promises';import { join } from 'node:path';import { chromium } from 'playwright-core';import { startOwnedBrowserFixture } from '../test/browserFixture.js';import sharp from 'sharp';-import { browserSuiteCanRun } from './browserSuiteGate.js';+import { browserSuiteCanRun, resolveTestChrome } from './browserSuiteGate.js';import { filmLookFilterMarkup, filmLookPreset, filmLookRuntimeSource } from './filmLook.js';import { cleanupTempDataRoots, lazyTempDataRoot, makePathsProxy } from './mockPathsDataRoot.js';@@ -15,9 +14,7 @@ vi.mock('./paths.js', async (original) => makePathsProxy(await original(), {vi.mock('../services/browserService.js', () => ({ loadConfig: async () => ({ chromePath: chrome }), cdpRequest: vi.fn() }));afterAll(() => cleanupTempDataRoots());-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/usr/bin/google-chrome', '/usr/bin/chromium',-].find((path) => path && existsSync(path));+const chrome = resolveTestChrome();const canRun = browserSuiteCanRun('film look runtime browser', { Chrome: chrome });const width = 390;const height = 219;diff --git a/server/lib/filmLookGpu.browser.test.js b/server/lib/filmLookGpu.browser.test.jsindex 54381eae71..ef0a07873f 100644--- a/server/lib/filmLookGpu.browser.test.js+++ b/server/lib/filmLookGpu.browser.test.js@@ -7,20 +7,18 @@*/import { afterAll, beforeAll, describe, expect, it } from 'vitest';import { execFileSync } from 'node:child_process';-import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';+import { mkdtempSync, readFileSync, rmSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { chromium } from 'playwright-core';import sharp from 'sharp';import { startOwnedBrowserFixture } from '../test/browserFixture.js';import { _withTestPreviewLoadDiagnostics } from '../services/musicVideo/testPreviewLoadDiagnostics.js';-import { browserSuiteCanRun } from './browserSuiteGate.js';+import { browserSuiteCanRun, resolveTestChrome } from './browserSuiteGate.js';import { FILM_LOOK_CONTROLS, FILM_LOOK_PRESETS, filmLookFilterMarkup, filmLookPreset, normalizeFilmLook } from './filmLook.js';import { filmLookGpuRuntimeSource } from './filmLookGpu.js';-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/usr/bin/google-chrome', '/usr/bin/chromium',-].find((path) => path && existsSync(path));+const chrome = resolveTestChrome();const canRun = browserSuiteCanRun('film look GPU browser', { Chrome: chrome });const width = 320;const height = 180;diff --git a/server/lib/musicVideoTitleCard.browser.test.js b/server/lib/musicVideoTitleCard.browser.test.jsindex db1a23b88b..8e0db7fd39 100644--- a/server/lib/musicVideoTitleCard.browser.test.js+++ b/server/lib/musicVideoTitleCard.browser.test.js@@ -1,9 +1,9 @@import { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync, readFileSync } from 'node:fs';+import { readFileSync } from 'node:fs';import { chromium } from 'playwright-core';import { startOwnedBrowserFixture } from '../test/browserFixture.js';import sharp from 'sharp';-import { browserSuiteCanRun } from './browserSuiteGate.js';+import { browserSuiteCanRun, resolveTestChrome } from './browserSuiteGate.js';import { filmLookRuntimeSource } from './filmLook.js';import { TITLE_CARD_FONT_FACES, titleCardRuntimeSource } from './musicVideoTitleCard.js';@@ -13,9 +13,7 @@ import { TITLE_CARD_FONT_FACES, titleCardRuntimeSource } from './musicVideoTitle* the card over the document's own frame inside its window and nothing outside* it, chaining the film look's seek wrapper rather than replacing it.*/-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/usr/bin/google-chrome', '/usr/bin/chromium',-].find((p) => p && existsSync(p));+const chrome = resolveTestChrome();const canRun = browserSuiteCanRun('title card browser', { Chrome: chrome });const W = 640;diff --git a/server/routes/musicVideoProductionReview.browser.test.js b/server/routes/musicVideoProductionReview.browser.test.jsindex 53198dfcc5..c362aacba4 100644--- a/server/routes/musicVideoProductionReview.browser.test.js+++ b/server/routes/musicVideoProductionReview.browser.test.js@@ -1,7 +1,6 @@/** Actual review controls + router/file store + Chrome/ffmpeg proof. No provider or live data. */import { afterAll, describe, expect, it, vi } from 'vitest';import express from 'express';-import { existsSync } from 'node:fs';import { mkdir, writeFile, copyFile } from 'node:fs/promises';import { join, resolve } from 'node:path';import { execFileSync, spawn } from 'node:child_process';@@ -9,7 +8,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';+import { browserSuiteCanRun, resolveTestChrome } 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' }));@@ -19,7 +18,7 @@ let endpoint;vi.mock('../services/browserService.js', () => ({ loadConfig: async () => ({ chromePath: chrome }), cdpRequest: path => fetch(`${endpoint}${path}`) }));const { findFfmpeg } = await import('../lib/ffmpeg.js');const { _testChromeCaptureArgs, _waitForTestChrome, _cleanupTestBrowser, _testBrowserCleanupSettled, _createTestArtifactsRoot } = await import('../services/htmlComposition/testBrowserCleanup.js');-const chrome = [process.env.CHROME_PATH, chromium.executablePath(), '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/usr/bin/google-chrome'].find(p => p && existsSync(p));+const chrome = resolveTestChrome();const ffmpeg = await findFfmpeg();// Server-only CI intentionally does not install the client workspace. This// cross-workspace visual test runs when all three local QA prerequisites exist.diff --git a/server/routes/musicVideoRichAuthoring.browser.test.js b/server/routes/musicVideoRichAuthoring.browser.test.jsindex c6d19ad714..ee0cc8f5a1 100644--- a/server/routes/musicVideoRichAuthoring.browser.test.js+++ b/server/routes/musicVideoRichAuthoring.browser.test.js@@ -8,7 +8,6 @@ vi.mock('../services/promptRunner.js', () => ({resolveProviderAndModel: async () => ({ provider: { id: 'stub-provider', type: 'api', enabled: true }, selectedModel: 'fixture-model' }),runPromptThroughProvider: async ({ prompt }) => { author.prompt = prompt; return { text: JSON.stringify({ sections: [{ id: author.sectionId, source: richSceneSource }] }) }; },}));-import { existsSync } from 'node:fs';import { mkdir, writeFile, copyFile } from 'node:fs/promises';import { join, resolve } from 'node:path';import { execFileSync, spawn } from 'node:child_process';@@ -17,7 +16,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';+import { browserSuiteCanRun, resolveTestChrome } 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' }));@@ -29,7 +28,7 @@ let endpoint;vi.mock('../services/browserService.js', () => ({ loadConfig: async () => ({ chromePath: chrome }), cdpRequest: path => fetch(`${endpoint}${path}`) }));const { findFfmpeg } = await import('../lib/ffmpeg.js');const { _testChromeCaptureArgs, _waitForTestChrome, _cleanupTestBrowser, _testBrowserCleanupSettled, _createTestArtifactsRoot } = await import('../services/htmlComposition/testBrowserCleanup.js');-const chrome = [process.env.CHROME_PATH, chromium.executablePath(), '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/usr/bin/google-chrome'].find(p => p && existsSync(p));+const chrome = resolveTestChrome();const ffmpeg = await findFfmpeg();// Server-only CI intentionally does not install the client workspace. This// cross-workspace visual test runs when all three local QA prerequisites exist.diff --git a/server/routes/musicVideoSongRevision.browser.test.js b/server/routes/musicVideoSongRevision.browser.test.jsindex e9b9d19696..dd97fd9798 100644--- a/server/routes/musicVideoSongRevision.browser.test.js+++ b/server/routes/musicVideoSongRevision.browser.test.js@@ -2,7 +2,6 @@import { afterAll, describe, expect, it, vi } from 'vitest';import express from 'express';import { Server } from 'socket.io';-import { existsSync } from 'node:fs';import { mkdir, writeFile, symlink } from 'node:fs/promises';import { join, resolve } from 'node:path';import { spawn } from 'node:child_process';@@ -11,11 +10,11 @@ import { chromium } from 'playwright-core';import { makePathsProxy, lazyTempDataRoot, cleanupTempDataRoots } from '../lib/mockPathsDataRoot.js';import { waitForAbort } from '../lib/testHelper.js';import { errorMiddleware } from '../lib/errorHandler.js';-import { browserSuiteCanRun } from '../lib/browserSuiteGate.js';+import { browserSuiteCanRun, resolveTestChrome } 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, _testBrowserCleanupSettled, _createTestArtifactsRoot } = await import('../services/htmlComposition/testBrowserCleanup.js');-const chrome = [process.env.CHROME_PATH, chromium.executablePath(), '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/usr/bin/google-chrome'].find(p => p && existsSync(p));+const chrome = resolveTestChrome();const client = resolve(import.meta.dirname, '../../client');const requireClient = createRequire(join(client, 'package.json'));let bundler;diff --git a/server/services/codeAnimation/export.realBrowser.test.js b/server/services/codeAnimation/export.realBrowser.test.jsindex 51e9e478a2..211dc9423e 100644--- a/server/services/codeAnimation/export.realBrowser.test.js+++ b/server/services/codeAnimation/export.realBrowser.test.js@@ -2,7 +2,7 @@// the staged document runs in real Chrome, renderComposition encodes it with// real ffmpeg, and the MP4 is compared to direct renderFrame(t) screenshots.import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';-import { existsSync, readFileSync } from 'node:fs';+import { readFileSync } from 'node:fs';import { createHash } from 'node:crypto';import { execFileSync, spawn } from 'node:child_process';import { join } from 'node:path';@@ -31,10 +31,7 @@ const { renderComposition } = await import('../htmlComposition/index.js');const { openComposition } = await import('../htmlComposition/browser.js');const { PATHS } = await import('../../lib/fileUtils.js');-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();const ffmpeg = await findFfmpeg();const ffprobe = await findFfprobe();@@ -79,6 +76,7 @@ import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';import { OutputPass } from 'three/addons/postprocessing/OutputPass.js';import { RoundedBoxGeometry } from 'three/addons/geometries/RoundedBoxGeometry.js';+import { resolveTestChrome } from '../../lib/browserSuiteGate.js';window.ANIMATION_META = { title: 'Three', duration: 1, fps: ${FPS}, width: ${WIDTH}, height: ${HEIGHT} };const film = document.getElementById('film');const renderer = new THREE.WebGLRenderer({ canvas: film, antialias: false, preserveDrawingBuffer: true });diff --git a/server/services/codeAnimation/stages.realBrowser.db.test.js b/server/services/codeAnimation/stages.realBrowser.db.test.jsindex 2c00019375..8515a02422 100644--- a/server/services/codeAnimation/stages.realBrowser.db.test.js+++ b/server/services/codeAnimation/stages.realBrowser.db.test.js@@ -9,9 +9,10 @@ import { readFile, mkdir, writeFile } from 'node:fs/promises';import { execFileSync, spawn } from 'node:child_process';import { join } from 'node:path';import { chromium } from 'playwright-core';+import { resolveTestChrome } from '../../lib/browserSuiteGate.js';import { cleanupTempDataRoots, lazyTempDataRoot, makePathsProxy } from '../../lib/mockPathsDataRoot.js';import { findFfmpeg, findFfprobe } from '../../lib/ffmpeg.js';-import { _cleanupTestBrowser, _createTestArtifactsRoot, _selectTestChrome, _waitForTestChrome, _testChromeCaptureArgs } from '../htmlComposition/testBrowserCleanup.js';+import { _cleanupTestBrowser, _createTestArtifactsRoot, _waitForTestChrome, _testChromeCaptureArgs } from '../htmlComposition/testBrowserCleanup.js';let endpoint;vi.mock('../browserService.js', () => ({ cdpRequest: path => fetch(`${endpoint}${path}`) }));@@ -35,15 +36,8 @@ const health = await checkHealth().catch(error => ({ connected: false, error: erconst dbReady = requireDbOrSkip('codeAnimation/stages.realBrowser.db.test', health.connected, health.error);if (dbReady) await ensureSchema();-const selected = _selectTestChrome([- { source: 'env', path: process.env.CHROME_PATH },- { source: 'playwright', path: chromium.executablePath() },- { source: 'mac-app', path: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' },- { source: 'system-google-chrome', path: '/usr/bin/google-chrome' },- { source: 'system-chromium', path: '/usr/bin/chromium' },- { source: 'system-chromium-browser', path: '/usr/bin/chromium-browser' },-]);-const chrome = selected?.path;+const chrome = resolveTestChrome();+const selected = chrome ? { source: 'resolveTestChrome', path: chrome } : null;const ffmpeg = await findFfmpeg();const ffprobe = await findFfprobe();diff --git a/server/services/htmlComposition/index.test.js b/server/services/htmlComposition/index.test.jsindex e3b44f72ff..3548f7b73f 100644--- a/server/services/htmlComposition/index.test.js+++ b/server/services/htmlComposition/index.test.js@@ -13,6 +13,7 @@ import { videoGenEvents } from '../videoGen/events.js';import { renderComposition, cancel } from './index.js';import { installMotionKit } from './motionKit.js';import { _cleanupTestBrowser, _createTestArtifactsRoot, _waitForTestChrome, _testChromeCaptureArgs } from './testBrowserCleanup.js';+import { resolveTestChrome } from '../../lib/browserSuiteGate.js';vi.mock('./encode.js', async importOriginal => {const actual = await importOriginal();@@ -29,10 +30,7 @@ vi.mock('../../lib/fileUtils.js', async importOriginal => makePathsProxy(await idataRoot: () => lazyTempDataRoot('portos-html-composition-'),}));-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();const ffmpeg = await findFfmpeg();let proc;let browser;diff --git a/server/services/musicVideo/animaticCapture.browser.test.js b/server/services/musicVideo/animaticCapture.browser.test.jsindex 884bcad4fb..382fdc222a 100644--- a/server/services/musicVideo/animaticCapture.browser.test.js+++ b/server/services/musicVideo/animaticCapture.browser.test.js@@ -1,5 +1,4 @@import { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { mkdtemp, rm, symlink, writeFile } from 'node:fs/promises';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -9,7 +8,7 @@ import express from 'express';import sharp from 'sharp';import { chromium } from 'playwright-core';import { startOwnedBrowserFixture } from '../../test/browserFixture.js';-import { browserSuiteCanRun } from '../../lib/browserSuiteGate.js';+import { browserSuiteCanRun, resolveTestChrome } from '../../lib/browserSuiteGate.js';import { findFfmpeg } from '../../lib/ffmpeg.js';import { filmLookPreset } from '../../lib/filmLook.js';import { buildLyricPlaythroughPreview } from './lyricPlaythrough.js';@@ -21,7 +20,7 @@ const requireClient = createRequire(join(client, 'package.json'));let bundlers;try { bundlers = ['vite', '@vitejs/plugin-react', '@tailwindcss/postcss'].map((name) => requireClient.resolve(name)); }catch (error) { if (error.code !== 'MODULE_NOT_FOUND') throw error; }-const chrome = [process.env.CHROME_PATH, chromium.executablePath(), '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/usr/bin/google-chrome', '/usr/bin/chromium'].find((path) => path && existsSync(path));+const chrome = resolveTestChrome();const ffmpeg = await findFfmpeg();const canRun = browserSuiteCanRun('animatic frame capture', { Chrome: chrome, ffmpeg, 'client dependencies': bundlers });diff --git a/server/services/musicVideo/compositionRender.test.js b/server/services/musicVideo/compositionRender.test.jsindex 63d869d774..d1a59103b4 100644--- a/server/services/musicVideo/compositionRender.test.js+++ b/server/services/musicVideo/compositionRender.test.js@@ -11,6 +11,7 @@ import { _cleanupTestBrowser, _createTestArtifactsRoot, _waitForTestChrome } froimport { beatSnapClips, buildMusicVideoFfmpegArgs, resolveSceneClips } from './render.js';import { composedLyricWindows, projectTypographyPlan, renderableCues, sectionCardCues } from './composition.js';import { COMPOSITION_SCRATCH_DIR, removeCompositionScratch, renderTypographyOverlays } from './compositionRender.js';+import { resolveTestChrome } from '../../lib/browserSuiteGate.js';let endpoint;vi.mock('../browserService.js', () => ({ cdpRequest: path => fetch(`${endpoint}${path}`) }));@@ -18,10 +19,7 @@ vi.mock('../../lib/fileUtils.js', async importOriginal => makePathsProxy(await idataRoot: () => lazyTempDataRoot('portos-mv-composition-'),}));-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();const ffmpeg = await findFfmpeg();// Vitest runs no hooks for a file whose every test is skipped, so on a runner// without Chrome or ffmpeg the afterAll below never fires — yet importingdiff --git a/server/services/musicVideo/documentRender.browser.test.js b/server/services/musicVideo/documentRender.browser.test.jsindex d143b18e7b..54a5357841 100644--- a/server/services/musicVideo/documentRender.browser.test.js+++ b/server/services/musicVideo/documentRender.browser.test.js@@ -16,7 +16,7 @@ import { execFileSync, spawn } from 'node:child_process';import { chromium } from 'playwright-core';import sharp from 'sharp';import { cleanupTempDataRoots, lazyTempDataRoot, makePathsProxy, ownTestBodies } from '../../lib/mockPathsDataRoot.js';-import { browserSuiteCanRun, chromeWithH264 } from '../../lib/browserSuiteGate.js';+import { browserSuiteCanRun, chromeWithH264, resolveTestChrome } from '../../lib/browserSuiteGate.js';const { it, drain } = ownTestBodies(vitestIt);const lifecycle = vi.hoisted(() => ({ diagnostics: null, chromeProcess: null, fixtureWritersSettled: false }));@@ -75,10 +75,7 @@ afterAll(() => {if (!lifecycle.chromeProcess || (lifecycle.fixtureWritersSettled && _testBrowserCleanupSettled(lifecycle.chromeProcess))) cleanupTempDataRoots();});-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',- '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find((path) => path && existsSync(path));+const chrome = resolveTestChrome();const ffmpeg = await findFfmpeg();// Imported discovery helpers can initialize mocked paths even on a skip.const canRun = browserSuiteCanRun('documentRender browser suite', { 'Chrome with H.264': await chromeWithH264(chrome), ffmpeg }, { onUnavailable: cleanupTempDataRoots });diff --git a/server/services/musicVideo/documentTemplates/layered/engine.overlay.browser.test.js b/server/services/musicVideo/documentTemplates/layered/engine.overlay.browser.test.jsindex 72d8a7367b..c4adf1de7a 100644--- a/server/services/musicVideo/documentTemplates/layered/engine.overlay.browser.test.js+++ b/server/services/musicVideo/documentTemplates/layered/engine.overlay.browser.test.js@@ -1,17 +1,15 @@-import { existsSync, readFileSync } from 'node:fs';+import { readFileSync } from 'node:fs';import { afterAll, beforeAll, describe, expect, it } from 'vitest';import { chromium } from 'playwright-core';-import { browserSuiteCanRun } from '../../../../lib/browserSuiteGate.js';+import { browserSuiteCanRun, resolveTestChrome } from '../../../../lib/browserSuiteGate.js';import { startOwnedBrowserFixture } from '../../../../test/browserFixture.js';import { gateAutoReview } from '../../autoReviewJudge.js';const engine = readFileSync(new URL('./engine.js', import.meta.url), 'utf8');const lyricType = readFileSync(new URL('../shared/lyricType.js', import.meta.url), 'utf8');-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();const canRun = browserSuiteCanRun('layered overlay browser', { Chrome: chrome });describe.skipIf(!canRun)('layered footage review through rendered browser pixels', () => {diff --git a/server/services/musicVideo/documentTemplates/shared/lyricType.browser.test.js b/server/services/musicVideo/documentTemplates/shared/lyricType.browser.test.jsindex 984660a9c2..7138521321 100644--- a/server/services/musicVideo/documentTemplates/shared/lyricType.browser.test.js+++ b/server/services/musicVideo/documentTemplates/shared/lyricType.browser.test.js@@ -1,8 +1,8 @@-import { existsSync, readFileSync } from 'node:fs';+import { readFileSync } from 'node:fs';import { afterAll, beforeAll, describe, expect, it } from 'vitest';import { chromium } from 'playwright-core';import { startOwnedBrowserFixture } from '../../../../test/browserFixture.js';-import { browserSuiteCanRun } from '../../../../lib/browserSuiteGate.js';+import { browserSuiteCanRun, resolveTestChrome } from '../../../../lib/browserSuiteGate.js';// A synthetic song: a verse line, a chorus line, a spoken direction, all word-timed.const words = (text, start, step = 0.3) => text.split(' ').map((w, i) => ({ text: w, startSec: start + i * step, endSec: start + i * step + 0.25 }));@@ -27,8 +27,7 @@ const MV = {],};-const chrome = [process.env.CHROME_PATH, chromium.executablePath(), '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'].find((path) => path && existsSync(path));+const chrome = resolveTestChrome();const canRun = browserSuiteCanRun('lyric type browser', { Chrome: chrome });describe.skipIf(!canRun)('lyricType in the layered template (browser pixels)', () => {diff --git a/server/services/musicVideo/documentTemplates/shared/toonWorld.browser.test.js b/server/services/musicVideo/documentTemplates/shared/toonWorld.browser.test.jsindex da6bb03a70..46c9c61fb3 100644--- a/server/services/musicVideo/documentTemplates/shared/toonWorld.browser.test.js+++ b/server/services/musicVideo/documentTemplates/shared/toonWorld.browser.test.js@@ -1,17 +1,14 @@import { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { readFile } from 'node:fs/promises';import { dirname, join } from 'node:path';import { createRequire } from 'node:module';import { fileURLToPath } from 'node:url';import { chromium } from 'playwright-core';import { startOwnedBrowserFixture } from '../../../../test/browserFixture.js';-import { browserSuiteCanRun } from '../../../../lib/browserSuiteGate.js';+import { browserSuiteCanRun, resolveTestChrome } from '../../../../lib/browserSuiteGate.js';const require = createRequire(import.meta.url);-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/usr/bin/google-chrome', '/usr/bin/chromium',-].find(p => p && existsSync(p));+const chrome = resolveTestChrome();const canRun = browserSuiteCanRun('toon world browser', { Chrome: chrome });const root = dirname(fileURLToPath(import.meta.url));const threeRoot = dirname(require.resolve('three'));diff --git a/server/services/musicVideo/overlayTextService.browser.test.js b/server/services/musicVideo/overlayTextService.browser.test.jsindex 30fa7c06e2..dd567e80b3 100644--- a/server/services/musicVideo/overlayTextService.browser.test.js+++ b/server/services/musicVideo/overlayTextService.browser.test.js@@ -10,14 +10,12 @@* plated data readout included.*/import { afterAll, describe, expect, it, vi } from 'vitest';-import { existsSync } from 'node:fs';import { mkdir, writeFile } from 'node:fs/promises';import { join } from 'node:path';-import { chromium } from 'playwright-core';import { cleanupTempDataRoots, lazyTempDataRoot, makePathsProxy } from '../../lib/mockPathsDataRoot.js';+import { resolveTestChrome } from '../../lib/browserSuiteGate.js';-const chrome = [process.env.CHROME_PATH, chromium.executablePath(), '/usr/bin/google-chrome', '/usr/bin/chromium',- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'].find((path) => path && existsSync(path));+const chrome = resolveTestChrome();vi.mock('../../lib/paths.js', async (importOriginal) => makePathsProxy(await importOriginal(), { dataRoot: () => lazyTempDataRoot('mv-overlay-text-') }));vi.mock('../settings.js', () => ({ getSettings: vi.fn(async () => ({})) }));diff --git a/server/services/musicVideo/publish/linkedin.browser.test.js b/server/services/musicVideo/publish/linkedin.browser.test.jsindex 98e4cc7876..e5105a2283 100644--- a/server/services/musicVideo/publish/linkedin.browser.test.js+++ b/server/services/musicVideo/publish/linkedin.browser.test.js@@ -1,15 +1,12 @@import { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { writeFile } from 'node:fs/promises';import { join } from 'node:path';import { chromium } from 'playwright-core';-import { browserSuiteCanRun } from '../../../lib/browserSuiteGate.js';+import { browserSuiteCanRun, resolveTestChrome } from '../../../lib/browserSuiteGate.js';import { startOwnedBrowserFixture } from '../../../test/browserFixture.js';import { linkedinAdapter } from './linkedin.js';-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/usr/bin/google-chrome', '/usr/bin/chromium',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();const canRun = browserSuiteCanRun('LinkedIn draft browser', { Chrome: chrome });const POST_URL = 'https://www.linkedin.com/feed/update/urn:li:activity:123456789/';const text = 'Example film.\n\nA second paragraph.\n\n\nFinal paragraph.';diff --git a/server/services/musicVideo/publish/sunoHook.browser.test.js b/server/services/musicVideo/publish/sunoHook.browser.test.jsindex f7f02fd527..5315275770 100644--- a/server/services/musicVideo/publish/sunoHook.browser.test.js+++ b/server/services/musicVideo/publish/sunoHook.browser.test.js@@ -1,15 +1,12 @@import { afterAll, beforeAll, describe, expect, it } from 'vitest';-import { existsSync } from 'node:fs';import { writeFile } from 'node:fs/promises';import { join } from 'node:path';import { chromium } from 'playwright-core';-import { browserSuiteCanRun } from '../../../lib/browserSuiteGate.js';+import { browserSuiteCanRun, resolveTestChrome } from '../../../lib/browserSuiteGate.js';import { startOwnedBrowserFixture } from '../../../test/browserFixture.js';import { sunoHookAdapter } from './sunoHook.js';-const chrome = [process.env.CHROME_PATH, chromium.executablePath(),- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/usr/bin/google-chrome', '/usr/bin/chromium',-].find(path => path && existsSync(path));+const chrome = resolveTestChrome();const canRun = browserSuiteCanRun('Suno Hook draft browser', { Chrome: chrome });const ID = '12345678-abcd-4abc-8abc-123456789abc';