test(e2e): 覆盖分母补齐 + GA 断言与 opt-in 实现对齐
三件事同批,共同点是「门禁/断言与实现脱钩,而脱钩处恰好没人跑」。
1. GA4 consent 断言(新发现,上一轮遗留)
DEF-09 把 analytics_storage 默认从 granted 改成 denied(opt-in),
实现与单测都改了,e2e/ga4-event-tracking.spec.ts:132 仍断言 granted。
它能藏住是因为那 4 个 @critical 用例**只在 test:e2e:prod 下真正执行**
(dev 下 NEXT_PUBLIC_GA_MEASUREMENT_ID 不存在 ⇒ test.skip)⇒ 本地全绿看不见。
改为同时钉两件事:default 必须是 denied;已存偏好由内联片段在 config
之前以 consent update 放行。只改前者会让「偏好回放坏了」变成新盲区。
判据:E2E_TARGET=production 跑 ga4 spec ⇒ 4 passed。
2. UJ-10 假红(TA-11)
原断言「分类后恰 1 篇 / 全部恰 2 篇」,并行写库用例插入的 E2E 新闻会让它假红。
改为钉两篇种子 slug 的可见/缺席 —— 比数条数更具体:数条数只证明「有 1 条」,
钉 slug 才证明「筛掉的是另一类」。桌面 + 移动两份同步改。
3. 覆盖分母 + 取样稳定性
- headings PAGES 11 → 34 页(与 check:axe:routes 的 35 条对齐,去掉按 404
契约的 /_not-found)。实测 34/34 通过、0 问题。此前只扫 11 页,
新增路由失踪时门禁仍然绿 —— 「分母静默变小」的第三种形态。
- axe settle() 改逐屏 max(400, 0.8×viewport) 步进 + 双 rAF,回顶后等
main * 内 opacity:0 元素清零(8s 超时抛出,不吞)。原「一次跳到底」
会跳过 IntersectionObserver 目标,半透明文字被读成低对比度,失败集合漂移。
- website-acceptance 的 pollBoundingBox 由「非空即返回」改为连续 5 次取样
一致再返回(TA-12):页面入场 transform 未落定时会抓到 29.936px 中途值。
超时仍 throw,判据强度不降。
判据:type-check / type-check:e2e EXIT=0;test:e2e:prod 135 passed / 0 failed
/ 9 skipped / EXIT=0;check:axe 35 路由 × 4 组合 140 rows 全 0、规则级 105/105。
This commit is contained in:
1 parent
3128d59164
commit
eba4e10442
8 files changed
+172
-32
No files matched your search
@@ -414,12 +414,14 @@ test.describe('UJ-10 Mobile: 深度搜索者旅程(分类浏览 → 逐篇阅
|
||||
await expect(companyNewsBtn).toBeVisible();
|
||||
await expect(devNewsBtn).toBeVisible();
|
||||
|
||||
// === Step 2: 点击"公司新闻"分类筛选 → 恰收窄到 1 篇 ===
|
||||
// === Step 2: 点击"公司新闻"分类筛选 → 种子公司新闻可见、研发新闻被过滤 ===
|
||||
// TA-11:共享副本库可能被写库用例插入额外新闻,用种子 slug 钉住过滤契约。
|
||||
await companyNewsBtn.click();
|
||||
await expect(page.locator('a[href*="/news/"]')).toHaveCount(1);
|
||||
await expect(page.locator('a[href="/news/company-founded"]')).toBeVisible();
|
||||
await expect(page.locator('a[href="/news/digital-transformation-solution"]')).toHaveCount(0);
|
||||
|
||||
// === Step 3: 阅读第一篇新闻文章 ===
|
||||
const firstArticle = page.locator('a[href*="/news/"]').first();
|
||||
const firstArticle = page.locator('a[href="/news/company-founded"]');
|
||||
await expect(firstArticle).toContainText('正式成立');
|
||||
await Promise.all([
|
||||
page.waitForURL(/\/news\/.+/, { timeout: 15000, waitUntil: 'commit' }),
|
||||
@@ -445,10 +447,11 @@ test.describe('UJ-10 Mobile: 深度搜索者旅程(分类浏览 → 逐篇阅
|
||||
const devNewsBtn2 = page.locator('button', { hasText: '研发动态' }).first();
|
||||
await expect(devNewsBtn2).toBeVisible();
|
||||
await devNewsBtn2.click();
|
||||
await expect(page.locator('a[href*="/news/"]')).toHaveCount(1);
|
||||
await expect(page.locator('a[href="/news/digital-transformation-solution"]')).toBeVisible();
|
||||
await expect(page.locator('a[href="/news/company-founded"]')).toHaveCount(0);
|
||||
|
||||
// === Step 5: 阅读第二篇新闻文章 ===
|
||||
const secondArticle = page.locator('a[href*="/news/"]').first();
|
||||
const secondArticle = page.locator('a[href="/news/digital-transformation-solution"]');
|
||||
await Promise.all([
|
||||
page.waitForURL(/\/news\/.+/, { timeout: 15000, waitUntil: 'commit' }),
|
||||
secondArticle.click(),
|
||||
@@ -470,13 +473,15 @@ test.describe('UJ-10 Mobile: 深度搜索者旅程(分类浏览 → 逐篇阅
|
||||
await expect(allBtn).toBeVisible();
|
||||
await allBtn.click();
|
||||
|
||||
// 全部种子新闻恰好 2 篇
|
||||
await expect(page.locator('a[href*="/news/"]')).toHaveCount(2);
|
||||
// 两个种子 slug 均可见(不约束总数)
|
||||
await expect(page.locator('a[href="/news/company-founded"]')).toHaveCount(1);
|
||||
await expect(page.locator('a[href="/news/digital-transformation-solution"]')).toHaveCount(1);
|
||||
|
||||
// 最终验证:搜索发现能力('数字化转型' 恰命中 1 篇)
|
||||
// 最终验证:搜索发现能力(命中研发种子、排除公司种子)
|
||||
const searchInput = page.getByLabel('搜索新闻');
|
||||
await expect(searchInput).toBeVisible();
|
||||
await searchInput.fill('数字化转型');
|
||||
await expect(page.locator('a[href*="/news/"]')).toHaveCount(1);
|
||||
await expect(page.locator('a[href="/news/digital-transformation-solution"]')).toBeVisible();
|
||||
await expect(page.locator('a[href="/news/company-founded"]')).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user