/** 单腿负对照:CSS 缺失时哨兵必须判红(expected 取不到 ⇒ 不是空串通过)。 */ import { chromium } from 'playwright'; const b = await chromium.launch(); const p = await b.newPage({ colorScheme: 'dark' }); await p.goto('http://localhost:3102/', { waitUntil: 'domcontentloaded', timeout: 20000 }); await p.waitForTimeout(1500); const r = await p.evaluate(() => { const t = (getComputedStyle(document.documentElement).getPropertyValue('--color-bg-primary-rgb') || '').trim().split(/\s+/).filter(Boolean); const cssHref = [...document.querySelectorAll('link[rel=stylesheet]')].map(l => l.getAttribute('href')); return { expected: t.length >= 3 ? `rgb(${t.slice(0, 3).join(', ')})` : '', actual: getComputedStyle(document.body).backgroundColor, cssHref }; }); const green = r.expected !== '' && r.actual === r.expected; console.log('CSS 链:', r.cssHref.slice(0, 2).join(' '), '| expected=', JSON.stringify(r.expected), '| actual=', r.actual); console.log(green ? '✗ 负对照失败:样式没加载却判绿 ⇒ 哨兵已被改瞎' : '✓ 负对照成立:样式没加载 ⇒ 哨兵判红'); await b.close(); process.exit(green ? 1 : 0);