import assert from 'node:assert/strict'; import { execFile } from 'node:child_process'; import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { promisify } from 'node:util'; const execFileAsync = promisify(execFile); const root = new URL('../', import.meta.url); const css = await readFile(new URL('public/cloud/styles.css', root), 'utf8'); const layouts = await Promise.all([ 'resources/views/venix/cloud/page.tpl', 'resources/views/venix/user/layout_header.tpl', 'resources/views/venix/user/layout_plain_header.tpl', 'resources/views/venix/auth/layout_header.tpl', ].map(path => readFile(new URL(path, root), 'utf8'))); for (const layout of layouts) { assert.match(layout, /\/cloud\/styles\.css\?v=/, 'A user-facing layout does not load the shared interaction stylesheet.'); } const chromeCandidates = [ '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/Applications/Chromium.app/Contents/MacOS/Chromium', '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser', ]; let chrome = ''; for (const candidate of chromeCandidates) { try { await execFileAsync(candidate, ['--version']); chrome = candidate; break; } catch { /* Try the next local browser. */ } } if (chrome) { const directory = await mkdtemp(join(tmpdir(), 'user-touch-highlight-')); const fixture = join(directory, 'fixture.html'); const safeCss = css.replaceAll('
链接按钮 行按钮