决策二把「产品」退出一级后,**手机上到 /products 没有任何导航路径**(只剩页脚)。
判据抓到的,不是人肉走查:`mobile-user-journeys.spec.ts` 里那条
「抽屉里没有、底部 TabBar 里也没有 ⇒ 可能已成孤儿」的守卫稳定判红。
实测证据(探针 `docs/acceptance/2026-10-17-ia-e2e/probe-tabbar.mjs` / `probe-drawer.mjs`):
底部 TabBar 的 hrefs 只有 `['/','/solutions','/services','/insights','/contact']`,
而移动抽屉原本只渲染 `config.mainNav` 这一层(header.tsx:222-246)。
桌面端靠 hover mega 面板仍可达 ⇒ 这是**只有移动端会中**的 IA 完成度缺口。
若把那条断言改成"找不到就跳过",/products 会在手机上静默消失。
改动:
- 抽屉为带 `dropdownKey` 的轴渲染其 mega 组(组标题 + 二级链接)。
不做手风琴:抽屉本身 `overflow-y-auto` 可滚,常驻展开少一个交互态、
也少一处 a11y 契约要维护。复测:抽屉 **26 条链接、含 /products 1 条、二级项 21 个**。
- `group.items` 加 `?? []` 守卫 —— CMS 行的形状不受类型约束,
`header.test.tsx` 的夹具里就有无 items 的组,5 例因 `undefined.map` 崩。
这条是单测抓到的:我的 dev-server 探针走的是真实 config,看不出这个边界。
- `mobile-tab-bar.tsx` 的 `<nav>` 补 `role/aria-label="底部标签导航"` 与
`data-testid="mobile-tab-bar"`:原来两个 nav landmark 里只有抽屉有名字,
而用例只能靠"页面上任何 a[href]"去找底部导航 —— 那会命中页脚那条同名链接,
被抽屉遮罩拦住指针事件,15s 重试 6 次全超时(本轮真实症状)。
- `uj-08-service-journey.spec.ts`:helper 从 `a:has-text("服务")` 改为
hover「能力」→ `a[href="/services"]`。旧注释那句
「服务导航项是直接链接,无下拉菜单」在新 IA 下已不成立。
- `user-journey.spec.ts` UJ-03 teardown:删行后补一次 revalidate。
根因链(证据:`news.html` 的 mtime 与 uj03 命中、allure 步骤时序):
01:16:31 创建 → 01:16:33 revalidate ⇒ ISR 在这一刻把**带测试行的 HTML 落盘** →
01:16:35 DELETE ⇒ 库里行没了但没人再刷 ⇒ 之后 UJ-10 断言"筛出恰 1 条"拿 2 条判红,
而 `x-nextjs-cache: HIT`、`s-maxage=3600`。
**只修测试这一层**;产品层缺口(后台发布/删除全都不触发失效)另记 DEC-N5。
本笔也记一次自伤(§5.42,因为它差点把结论带偏):
为清那份冻结产物我 `rm -rf` 了构建输出子树,连带删掉已编译的 `news/page.js` ⇒
服务打 `Cannot find module` ×6、两条旅程因页面 500 而红;
而我当时的"清除验证"是数产物里的 uj03 命中数,得到 **0** ——
读起来像"缓存干净了",实际是 **500 的错误页里当然不含那一行**。
重建后 uj03 又出现 2 次,才暴露库里真有 2 条因中途失败而未清理的残留行。
善后:按 id 删自造的 2 条 news(连带 AuditLog 与 ContentZone.items 引用),
`news` 已发布行回到 seed 的 2 条,再 `npm run build`。
⇒ 三条纪律进 lessons:重置 ISR 只靠重建或 revalidate、不许手删 dist/**;
「命中 0」必须同时断言页面健康(正对照),否则"仪器坏了"与"问题没了"共用同一个 0;
破坏性清理让用例中途失败后要清点它留下了什么半成品数据。
另记 §5.43 / DEC-N6:`e2e/**/*.ts` 不在 tsconfig include 里 ⇒
teardown 补丁中重复的 `const revalidateSecret` 让 type-check 全程 EXIT=0,
只有 `npx playwright test --list` 才报 `already been declared`(整档无法加载)。
台账与文档:`qa-tracker.md` §11.5(25 条 prod 目标红的三类归因、真缺陷、自伤、
新登记 DEC-N5/DEC-N6)、ADR-0008「已知偏差」补第 7、8 条、
`CONTEXT.md` 加「移动端二级目的地必须在抽屉里可达」、
`docs/lessons-learned.md` §5.42–§5.43 + 更新记录 2 行。
复跑(一律重定向后读 `$?`,不用管道):
`header.test.tsx` 18 passed;`UJ-01/02/08/10` × chromium + chromium-mobile **14 passed**;
`npm run test:all` ⇒ **EXIT=0**(141 套件 / 1747 例、integration 23、
check:visual 11/11 + accents 成立、e2e:fast 59 passed / 25 skipped);
`type-check` EXIT=0、`lint` EXIT=0(0 error / 81 warning)、`build` EXIT=0。
未闭合(须单独授权或另行裁定):视觉基线重采(AUTH-VISUAL,只读复跑实测
**109 failed = 104 例像素不符 + 5 例死选择器超时**,后者已在本笔改成反向守卫并经
变异验证:把 founder-quote-section 塞回首页 ⇒ 该条判红、还原 ⇒ 通过);
`--radius-cta: 12px` 负对照依赖基线先入库;
GA4 在本 worktree **无法取证**(worktree 无 `.env.production`,
`NEXT_PUBLIC_*` 在 build 期烘焙 ⇒ 那 16 例即便 `E2E_TARGET=production` 仍是 skipped);
`check:motion` 残留 8 处(基线既有红);DEC-N1 彩色编码第二通道待设计裁定。
218 lines
10 KiB
TypeScript
218 lines
10 KiB
TypeScript
import { test, expect, type Page } from './fixtures';
|
||
|
||
/**
|
||
* UJ-08: 服务探索者旅程
|
||
*
|
||
* 覆盖范围:
|
||
* 服务列表 → 服务详情 → 联系表单
|
||
*/
|
||
|
||
test.setTimeout(90000);
|
||
|
||
// 本套件走桌面导航(desktop-navigation 在 md 断点以下 display:none):
|
||
// 固定桌面视口,使 chromium-mobile 项目也按用例真实语义验证引擎而非布局。
|
||
test.use({ viewport: { width: 1440, height: 900 } });
|
||
|
||
// ==================== 辅助函数 ====================
|
||
|
||
/**
|
||
* 关闭 Cookie 同意横幅(如果存在)
|
||
*/
|
||
async function closeCookieBanner(page: Page) {
|
||
const acceptAllButton = page.locator('button:has-text("接受所有")').first();
|
||
if (await acceptAllButton.count() > 0 && await acceptAllButton.isVisible()) {
|
||
await acceptAllButton.click();
|
||
await page.waitForTimeout(500);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 从桌面主导航进入服务列表页(/services)。
|
||
*
|
||
* 注释里那句「服务导航项是直接链接,无下拉菜单」在 2026-10-17 双轴 IA 后**不再成立**:
|
||
* 一级导航改成 行业 × 能力 + 洞察(ADR-0008 决策二),原「服务」轴改名「能力」,
|
||
* 且四项里除「关于我们」外**全部是下拉触发器(button)**,主导航里已经没有任何
|
||
* `a:has-text("服务")` 元素 ⇒ 原 helper 在 4 个 project 上稳定判红(本轮 prod 目标实测 ×4)。
|
||
*
|
||
* 到达路径按新 IA 走:hover「能力」→ 点面板底部的「查看全部能力」(href=/services)。
|
||
* 目的地仍由**导航项自己声明的 href** 断言,不靠中文标签反推路由(同 e9bd9654 的纪律)。
|
||
*/
|
||
async function navigateFromServiceNav(page: Page) {
|
||
const desktopNav = page.locator('[data-testid="desktop-navigation"]').first();
|
||
const capabilitiesTrigger = desktopNav.locator('button:has-text("能力")').first();
|
||
await expect(capabilitiesTrigger).toBeVisible({ timeout: 5000 });
|
||
await capabilitiesTrigger.hover();
|
||
|
||
const servicesLink = desktopNav.locator('a[href="/services"]').first();
|
||
await expect(servicesLink, '能力面板里没有指向 /services 的入口').toBeVisible({ timeout: 5000 });
|
||
await servicesLink.hover(); // 防止 mouseleave 收起面板
|
||
await servicesLink.click();
|
||
}
|
||
|
||
// ==================== UJ-08: 服务探索者旅程 ====================
|
||
test.describe('UJ-08: 服务探索者旅程(服务列表 → 服务详情 → 联系表单)', () => {
|
||
test('@journey @regression 访客从服务列表浏览到详情页并填写联系表单', async ({ page }) => {
|
||
// === Step 1: 访问首页,确认 Hero 区域可见 ===
|
||
console.log('UJ-08: 访问首页');
|
||
await page.goto('/', { waitUntil: 'domcontentloaded', timeout: 30000 });
|
||
await page.waitForTimeout(2500);
|
||
await closeCookieBanner(page);
|
||
|
||
// 验证 Hero 区域可见
|
||
const heroTitle = page.locator('h1').first();
|
||
await expect(heroTitle).toBeVisible({ timeout: 15000 });
|
||
const titleText = await heroTitle.textContent();
|
||
expect(titleText).toBeTruthy();
|
||
expect(titleText!.length).toBeGreaterThan(0);
|
||
console.log('UJ-08: 首页 Hero 区域可见');
|
||
|
||
// === Step 2: 通过桌面主导航的"服务"链接,导航到服务列表页 ===
|
||
console.log('UJ-08: 从导航进入服务列表页');
|
||
await navigateFromServiceNav(page);
|
||
|
||
// 等待导航到服务列表页
|
||
await page.waitForURL(/\/services/, { timeout: 10000 });
|
||
await expect(page).toHaveURL(/\/services/);
|
||
await page.waitForTimeout(2000);
|
||
console.log('UJ-08: 已导航到服务列表页');
|
||
|
||
// === Step 3: 验证服务列表页加载成功 ===
|
||
// 服务列表页的 h1 可能为标语而非"服务"文字,验证 URL 和页面标题
|
||
const pageTitle = await page.title();
|
||
expect(pageTitle).toContain('服务');
|
||
console.log('UJ-08: 服务列表页页面标题:', pageTitle);
|
||
|
||
// 验证服务卡片/链接存在
|
||
const serviceLinks = page.locator('a[href*="/services/"]:not([href$="/services"])');
|
||
const linkCount = await serviceLinks.count();
|
||
expect(linkCount).toBeGreaterThan(0);
|
||
console.log('UJ-08: 找到服务链接数量:', linkCount);
|
||
|
||
// === Step 4: 点击第一个服务链接进入详情页 ===
|
||
console.log('UJ-08: 点击第一个服务链接');
|
||
const firstServiceLink = serviceLinks.first();
|
||
const serviceHref = await firstServiceLink.getAttribute('href');
|
||
console.log('UJ-08: 服务链接地址:', serviceHref);
|
||
await firstServiceLink.click();
|
||
|
||
await page.waitForURL(/\/services\/.+/, { timeout: 10000 });
|
||
await expect(page).toHaveURL(/\/services\/.+/);
|
||
await page.waitForTimeout(2000);
|
||
console.log('UJ-08: 已导航到服务详情页');
|
||
|
||
// === Step 5: 验证服务详情页加载成功 ===
|
||
// L1 Hero: 标题可见且有内容
|
||
const detailTitle = page.locator('h1').first();
|
||
await expect(detailTitle).toBeVisible({ timeout: 10000 });
|
||
const detailTitleText = await detailTitle.textContent();
|
||
expect(detailTitleText).toBeTruthy();
|
||
expect(detailTitleText!.length).toBeGreaterThan(0);
|
||
console.log('UJ-08: 服务详情页标题:', detailTitleText);
|
||
|
||
// 验证 main 内容长度 > 200 字符
|
||
const mainContent = page.locator('main').first();
|
||
await expect(mainContent).toBeVisible();
|
||
const mainText = await mainContent.textContent();
|
||
expect(mainText!.length).toBeGreaterThan(200);
|
||
console.log('UJ-08: 服务详情页 main 内容长度:', mainText!.length);
|
||
|
||
// === Step 6: 验证服务详情页包含四层叙事结构中的关键元素 ===
|
||
// L2 Value: 核心价值/服务内容/实施流程区域
|
||
// 服务详情页使用的 L2 区域标题为"解决什么问题","核心能力","服务流程"
|
||
const valueIndicators = ['核心价值', '服务内容', '实施流程', 'Value Proposition', '解决什么问题', '核心能力', '服务流程'];
|
||
let hasValueSection = false;
|
||
for (const indicator of valueIndicators) {
|
||
if (mainText!.includes(indicator)) {
|
||
hasValueSection = true;
|
||
console.log('UJ-08: 找到核心价值区域:', indicator);
|
||
break;
|
||
}
|
||
}
|
||
expect(hasValueSection).toBe(true);
|
||
|
||
// L3 Trust: 信任证明(客户案例或资质认证)
|
||
const trustIndicators = ['客户案例', '资质认证', '可衡量的成果', '成功案例', '真实案例'];
|
||
let hasTrustSection = false;
|
||
for (const indicator of trustIndicators) {
|
||
if (mainText!.includes(indicator)) {
|
||
hasTrustSection = true;
|
||
console.log('UJ-08: 找到信任证明区域:', indicator);
|
||
break;
|
||
}
|
||
}
|
||
// 服务详情页的信任区域可能为"查看案例"链接而非文本块。
|
||
// N-27 修复:原 `isVisible().catch(() => false)` 把定位器/基础设施异常吞成
|
||
// 「链接不存在」,回退校验只在异常路径之外才被读到 ⇒ 改为无条件执行路径上的
|
||
// 硬断言:链接消失 ⇒ toBeVisible 超时判红;基础设施异常 ⇒ 原样抛出,不再伪装。
|
||
if (!hasTrustSection) {
|
||
const caseLink = page.locator('a:has-text("查看案例")').first();
|
||
await expect(caseLink, '服务详情页信任区域应含文本关键词或"查看案例"链接').toBeVisible({ timeout: 5000 });
|
||
hasTrustSection = true;
|
||
console.log('UJ-08: 找到"查看案例"链接作为信任证明');
|
||
}
|
||
expect(hasTrustSection).toBe(true);
|
||
|
||
// L4 CTA: 验证 CTA 区域存在(链接到联系页面)
|
||
const ctaLink = page.locator('a[href="/contact"]').first();
|
||
await expect(ctaLink).toBeVisible();
|
||
console.log('UJ-08: CTA 链接可见');
|
||
|
||
// === Step 7: 从服务详情页导航到联系页面 ===
|
||
console.log('UJ-08: 导航到联系页面');
|
||
await page.goto('/contact', { waitUntil: 'domcontentloaded', timeout: 30000 });
|
||
await page.waitForTimeout(2500);
|
||
|
||
// 验证联系页面加载成功
|
||
const contactTitle = page.locator('h1').first();
|
||
await expect(contactTitle).toBeVisible({ timeout: 10000 });
|
||
const contactTitleText = await contactTitle.textContent();
|
||
expect(contactTitleText).toBeTruthy();
|
||
expect(contactTitleText!.length).toBeGreaterThan(0);
|
||
console.log('UJ-08: 联系页面标题:', contactTitleText);
|
||
|
||
// === Step 8: 填写联系表单 ===
|
||
// 验证表单字段可见
|
||
const nameInput = page.locator('[data-testid="name-input"]').first();
|
||
await expect(nameInput).toBeVisible({ timeout: 5000 });
|
||
console.log('UJ-08: 表单字段可见');
|
||
|
||
// 填写表单字段
|
||
await page.locator('[data-testid="name-input"]').fill('张经理');
|
||
await page.locator('[data-testid="phone-input"]').fill('13812345678');
|
||
await page.locator('[data-testid="email-input"]').fill('zhang@example.com');
|
||
await page.locator('[data-testid="subject-input"]').fill('服务咨询 - 数字化转型咨询');
|
||
await page.locator('[data-testid="message-input"]').fill('您好,我在浏览了贵司的数字化转型服务后非常感兴趣,希望进一步了解服务内容和实施细节,请安排专人联系。');
|
||
|
||
// === Step 9: 验证表单字段可交互 ===
|
||
// 验证填写内容已正确填入
|
||
const filledName = await page.locator('[data-testid="name-input"]').inputValue();
|
||
expect(filledName).toBe('张经理');
|
||
|
||
const filledPhone = await page.locator('[data-testid="phone-input"]').inputValue();
|
||
expect(filledPhone).toBe('13812345678');
|
||
|
||
const filledEmail = await page.locator('[data-testid="email-input"]').inputValue();
|
||
expect(filledEmail).toBe('zhang@example.com');
|
||
|
||
const filledSubject = await page.locator('[data-testid="subject-input"]').inputValue();
|
||
expect(filledSubject).toBe('服务咨询 - 数字化转型咨询');
|
||
|
||
const filledMessage = await page.locator('[data-testid="message-input"]').inputValue();
|
||
expect(filledMessage).toBe('您好,我在浏览了贵司的数字化转型服务后非常感兴趣,希望进一步了解服务内容和实施细节,请安排专人联系。');
|
||
|
||
console.log('UJ-08: 表单字段已正确填写');
|
||
|
||
// === Step 10: 验证联系页面存在 CTA 提交按钮 ===
|
||
const submitButton = page.locator('[data-testid="submit-button"]').first();
|
||
await expect(submitButton).toBeVisible({ timeout: 5000 });
|
||
await submitButton.scrollIntoViewIfNeeded();
|
||
|
||
// 验证提交按钮可点击
|
||
await expect(submitButton).toBeEnabled({ timeout: 3000 });
|
||
const submitButtonText = await submitButton.textContent();
|
||
expect(submitButtonText).toBeTruthy();
|
||
console.log('UJ-08: 提交按钮可见且可点击:', submitButtonText);
|
||
|
||
console.log('UJ-08: 服务探索者旅程测试完成');
|
||
});
|
||
}); |