test(qa): e2e 装配修正 + 集成/门禁测试与工具链重构

- e2e:修死选择器与蜜罐误命中、补断言、GA4/security-headers 用例诚实标注
  skip 边界;新增 assert-helpers/fixtures/hydrated/primary-nav/touch-targets
  等复用桩。
- 集成层:config/test/jest.integration.config.js + tests-integration/ 真库
  一次性 SQLite 用例,teardown 守卫开发库指纹。
- 门禁工具链:jest.setup 归位到根、scripts/accessibility 全站 axe 节点计数、
  check-brand-text-token/check-motion-constraints 机械守卫、stryker/lighthouse
  配置收敛。
This commit is contained in:
2026-09-28 10:48:08 +08:00
parent a366bd1400
commit 6bb7c557ee
142 changed files with 6597 additions and 2653 deletions
+18 -8
View File
@@ -1,4 +1,4 @@
import { test, expect, type Page } from '@playwright/test';
import { test, expect, type Page } from './fixtures';
/**
* P6: 缺失路径 E2E 测试补充
@@ -12,6 +12,10 @@ import { test, expect, type Page } from '@playwright/test';
test.setTimeout(60000);
// 本套件走桌面导航(desktop-navigation 在 md 断点以下 display:none):
// 固定桌面视口,使 chromium-mobile 项目也按用例真实语义验证引擎而非布局。
test.use({ viewport: { width: 1440, height: 900 } });
// ==================== 1. 滚动进度条测试 ====================
test.describe('滚动进度条 - 全局组件行为', { tag: '@regression' }, () => {
@@ -224,16 +228,22 @@ test.describe('关键用户路径 - 首页 → 产品 → 详情', { tag: ['@smo
});
test('从产品详情页可跳转回产品列表', async ({ page }) => {
// erp 为 seed 中已发布产品(prisma/dev.db ContentItem slug='erp')。
// N-27 修复:原守卫 `if (count > 0 && isVisible)` ⇒ 返回链接消失时静默通过。
// product-detail-content-v3.tsx:97 恒定渲染 data-testid="product-detail-hero-secondary"
// 的「查看更多产品」CTA(href="/products"),以此做硬断言 + 真跳转。
await page.goto('/products/erp', { waitUntil: 'domcontentloaded', timeout: 30000 });
await page.waitForTimeout(2000);
// 查找返回或面包屑链接
const backLink = page.locator('a[href="/products"], a:has-text("返回")').first();
if (await backLink.count() > 0 && await backLink.isVisible()) {
await backLink.click();
await page.waitForURL(/\/products/, { timeout: 10000 });
await expect(page).toHaveURL(/\/products/);
}
const backLink = page.locator('[data-testid="product-detail-hero-secondary"]');
await expect(backLink).toBeVisible();
await expect(backLink).toHaveAttribute('href', '/products');
await Promise.all([
page.waitForURL((url) => new URL(url).pathname === '/products', { waitUntil: 'commit', timeout: 15000 }),
backLink.click(),
]);
await expect(page).toHaveURL((url) => url.pathname === '/products');
});
});