import { test, expect } from './fixtures'; /** * 客户端导航可见性回归(2026-10-20 生产白屏)。 * * 缺陷原型:首页点击导航后 URL 与正文都已切换,但 PageTransition 的 motion.div 停在 * exit 变体(inline opacity:0; translateY(-8px)),新页面永不进入 ⇒ 整页白屏,刷新才恢复。 * 只看 h1 自身 opacity 读不到(恒为 1),必须读祖先链的乘积累积。 * * 复核:`E2E_TARGET=production npx playwright test client-navigation-visibility`。 */ const NAV_STEPS = [ { href: '/about', label: '关于我们' }, { href: '/products', label: '产品矩阵' }, { href: '/methodology', label: '方法论' }, { href: '/insights', label: '洞察' }, { href: '/about/brand', label: '品牌故事' }, ]; function effectiveOpacity(page: import('@playwright/test').Page) { return page.evaluate(() => { const main = document.querySelector('main#main-content'); let opacity = 1; let node: Element | null = main; while (node) { opacity *= Number(getComputedStyle(node).opacity); node = node.parentElement; } return opacity; }); } test('首页经客户端导航到各栏目后内容必须可见', async ({ page }) => { await page.goto('/', { waitUntil: 'networkidle', timeout: 60000 }); await expect .poll(() => effectiveOpacity(page), { timeout: 15000 }) .toBeGreaterThan(0.99); for (const step of NAV_STEPS) { await page.getByTestId('footer').locator(`a[href="${step.href}"]`).first().click(); await page.waitForURL(`**${step.href}`, { timeout: 15000 }); // 退场 200ms + 入场 280ms 都在 URL 变化之后才落定;URL 一变就采样会读到退场前的 1(假绿)。 await page.waitForTimeout(800); await expect .poll(() => effectiveOpacity(page), { timeout: 5000, message: `导航到 ${step.href}(${step.label})后整页有效 opacity 未回到 1(白屏)`, }) .toBeGreaterThan(0.99); } });