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
+13 -12
View File
@@ -1,4 +1,5 @@
import { test, expect, devices } from '@playwright/test';
import { test, expect, devices } from './fixtures';
import { pollBoundingBox } from './assert-helpers';
/**
* 移动端专项 E2E 测试套件
@@ -261,13 +262,11 @@ test.describe('移动端产品浏览 - 产品中心 @mobile @regression', () =>
const card = productCards.nth(i);
await expect(card).toBeVisible();
// 检查卡片边界在视口内
const box = await card.boundingBox();
expect(box).not.toBeNull();
if (box) {
expect(box.x).toBeGreaterThanOrEqual(0);
expect(box.x + box.width).toBeLessThanOrEqual(390); // iPhone 14 宽度
}
// 检查卡片边界在视口内(N-27 修复:原 `if (box)` 守卫会在盒模型读取失败时
// 静默跳过边界断言 ⇒ 改用 pollBoundingBox,超时/消失即红)
const box = await pollBoundingBox(card);
expect(box.x).toBeGreaterThanOrEqual(0);
expect(box.x + box.width).toBeLessThanOrEqual(390); // iPhone 14 宽度(test.use 固定 390 视口)
}
});
@@ -330,10 +329,12 @@ test.describe('移动端产品浏览 - 产品中心 @mobile @regression', () =>
expect(contentText!.length).toBeGreaterThan(100);
// 移动端详情页应包含返回操作
const backLink = page.locator('a[href="/products"], a:has-text("返回")').first();
if (await backLink.count() > 0) {
await expect(backLink).toBeVisible();
}
// N-27 修复:原 `if (count > 0)` 守卫 ⇒ 返回链接消失时静默通过。
// 证据:product-detail-content-v3.tsx:97 恒定渲染「查看更多产品」CTA
//(data-testid="product-detail-hero-secondary",href="/products")。
const backLink = page.locator('[data-testid="product-detail-hero-secondary"]');
await expect(backLink).toBeVisible();
await expect(backLink).toHaveAttribute('href', '/products');
});
test('移动端产品详情页可返回列表', async ({ page }) => {