- 首页按咨询机构影像版式重排,保留原站文案与“洞察→行业→能力”段序 - 导航/页脚/品牌页换用上下锁定字标,alt 维持法定主体名 - 修复 reduce 下 PageTransition 祖先 opacity 停留导致的白屏 - 4 浏览器 × 9 宽度多端复核,axe 0 violation - 视觉基线 106 张更新并只读复跑 125/125
223 lines
11 KiB
TypeScript
223 lines
11 KiB
TypeScript
import { test, expect, type Page } from './fixtures';
|
||
|
||
/**
|
||
* UJ-11: 首页转化旅程(设计优化专项)
|
||
*
|
||
* 覆盖首页关键转化路径,作为封版验收依据:
|
||
* UJ-11a: 首屏说服链路 — Hero + 可审计数字账本 → 透明信任层 → 成果槽 → 转化 CTA
|
||
* UJ-11b: 信任验证旅程 — 口径标注 + 首批客户共创 → 联系转化
|
||
* UJ-11c: 移动端首屏转化旅程 — 390px 下 CTA 首屏可见、无横向滚动
|
||
*
|
||
* 关联设计优化计划:docs/plans/2026-08-18-vibe-design-optimization-plan.md
|
||
* 关联 critique:.impeccable/critique/
|
||
*
|
||
* ⚠ 2026-10-17 按 home-content-v16 重写(ADR-0008 决策四:首页 10 段收 8 段,对标 Bain 段序)。
|
||
* 锚点全部以实测 DOM 为准,探针与读数留存于 `docs/acceptance/2026-10-17-ia-e2e/probe-home*.mjs`。
|
||
* 三处断言语义随结构变化,逐条说明(不要把它们改回旧锚点,旧锚点已不存在):
|
||
* 1) `hero-primary-cta` / `hero-secondary-link` → 合并为 `hero-cta`(v16 Hero 只留一条主 CTA,
|
||
* 次级链接按对标语法取消:两家 Hero 只有一条动作)。
|
||
* 2) `trust-section` → `home-ledger` + `home-ledger-signals` + `metrics-basis-note`:
|
||
* 原「信任四元组」被拆成**量化项与定性项两列**,因为「成都 / 全流程 / 共创」根本不是数字。
|
||
* 3) 「数据来源」→ 「目标口径,非既成结果」:口径角注由 `MetricsBasisNote` 按最弱 basis 出文,
|
||
* 本仓当前最弱口径是 target,所以文案是这一条。断言**判据是"有没有口径标注"**,
|
||
* 不是某个具体字符串——否则 target 升到 verified 时会误红。
|
||
* 4) 原 `narrative-section`(01/02/03 问题→方法→结果)整段删除:v16 把它的位置让给
|
||
* 成果槽(ResultsSlot),共创四步「问题梳理 / 小步验证 / 交付物验收 / 能力交接」
|
||
* 承担了原来那三幕想说的"过程可控",不再单独占一段。
|
||
* ⇒ 这里改为断言成果槽的**可判别空态**,语义更强:既验"有过程叙事",也验"没有假案例"。
|
||
*/
|
||
|
||
test.setTimeout(90000);
|
||
|
||
// ==================== 辅助函数 ====================
|
||
|
||
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);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 断言页面无横向滚动(scrollWidth <= clientWidth + 1px 容差)
|
||
*/
|
||
async function expectNoHorizontalOverflow(page: Page) {
|
||
const overflow = await page.evaluate(() => {
|
||
const doc = document.documentElement;
|
||
return { scrollWidth: doc.scrollWidth, clientWidth: doc.clientWidth };
|
||
});
|
||
expect(overflow.scrollWidth).toBeLessThanOrEqual(overflow.clientWidth + 1);
|
||
}
|
||
|
||
async function gotoHome(page: Page) {
|
||
await page.goto('/', { waitUntil: 'domcontentloaded', timeout: 30000 });
|
||
await page.waitForTimeout(2500);
|
||
// PageTransition 在 hydration 后把内容移进 motion.div;移入瞬间整棵子树会重挂。
|
||
// 过早 scrollIntoView 会撞 "Element is not attached to the DOM"(2026-10-20 WebKit 实测)。
|
||
// 等这一层的 opacity 归 1 再开始抓元素,不改变任何产品断言。
|
||
await page
|
||
.waitForFunction(
|
||
() => {
|
||
const wrappers = [...document.querySelectorAll('main div')].filter((el) => {
|
||
const r = el.getBoundingClientRect();
|
||
return r.height > 2000 && (el.getAttribute('style') || '').includes('opacity');
|
||
});
|
||
return wrappers.every((el) => parseFloat(getComputedStyle(el).opacity) > 0.99);
|
||
},
|
||
{ timeout: 12000 },
|
||
)
|
||
.catch(() => {});
|
||
await closeCookieBanner(page);
|
||
}
|
||
|
||
// ==================== UJ-11a: 首屏说服链路 ====================
|
||
test.describe('UJ-11a: 首屏说服链路(Hero → 账本 → 信任 → 成果)', () => {
|
||
test('@journey @critical 首页首屏 Hero、单一 CTA、可审计数字账本渲染正常', async ({ page }) => {
|
||
await gotoHome(page);
|
||
|
||
// === L1 Hero:声明先行 + 单一 CTA(v16 起 min-h 90vh → 70vh,且无粒子场)===
|
||
const heroSection = page.locator('[data-testid="hero-section"]').first();
|
||
await expect(heroSection).toBeVisible({ timeout: 15000 });
|
||
|
||
const heroTitle = page.locator('h1').first();
|
||
await expect(heroTitle).toBeVisible();
|
||
|
||
// === 单一主 CTA,且必须落到联系页 ===
|
||
const cta = page.locator('[data-testid="hero-cta"]').first();
|
||
await expect(cta).toBeVisible();
|
||
await expect(cta).toHaveAttribute('href', '/contact');
|
||
|
||
// === L2 数字账本:量化项与口径角注同时在场 ===
|
||
const ledger = page.locator('[data-testid="home-ledger"]').first();
|
||
await expect(ledger).toBeVisible({ timeout: 10000 });
|
||
expect(await page.locator('[data-testid="ledger-metric"]').count()).toBeGreaterThan(0);
|
||
|
||
await expectNoHorizontalOverflow(page);
|
||
});
|
||
|
||
test('@journey @critical 首页信任层展示可验证信号与口径标注', async ({ page }) => {
|
||
await gotoHome(page);
|
||
|
||
// 定性信号列(成都 / 全流程 / 共创)—— 它们不是数字,所以与 ledger-metric 分列
|
||
const signals = page.locator('[data-testid="home-ledger-signals"]').first();
|
||
await signals.scrollIntoViewIfNeeded();
|
||
await expect(signals).toBeVisible({ timeout: 10000 });
|
||
|
||
const signalText = await signals.textContent();
|
||
expect(signalText).toContain('成都');
|
||
expect(signalText).toContain('全流程');
|
||
expect(signalText).toContain('共创');
|
||
|
||
// 口径标注:零编造前提下每个数字必须带可追溯口径。
|
||
// 判据是「这一格存在且非空」,不锁具体措辞(口径升级时文案会变,锁字符串会误红)。
|
||
const basisNote = page.locator('[data-testid="metrics-basis-note"]').first();
|
||
await expect(basisNote).toBeVisible();
|
||
expect(((await basisNote.textContent()) ?? '').trim().length).toBeGreaterThan(0);
|
||
});
|
||
|
||
test('@journey @critical 首页按对标段序呈现 洞察 → 行业 → 能力 三段', async ({ page }) => {
|
||
await gotoHome(page);
|
||
|
||
// v16 段序:Hero(1) 账本(2) 承诺(3) 成果(4) 洞察(5) 行业(6) 能力(7) CTA(8)
|
||
// 这三段是原「叙事区」位置上的替代结构,逐个锚 testid 而不是靠文案,
|
||
// 因为三段的标题都可被 CMS pageCopy 覆盖。
|
||
const anchors = ['home-insights', 'home-industries', 'home-capabilities'];
|
||
const positions: number[] = [];
|
||
for (const id of anchors) {
|
||
const el = page.locator(`[data-testid="${id}"]`).first();
|
||
await expect(el).toBeVisible({ timeout: 10000 });
|
||
// 段序要用**文档坐标**,不能用 boundingBox().y —— 那是视口相对值,
|
||
// scrollIntoViewIfNeeded 之后每段都被滚到同一带区,读数只反映滚动位置不反映先后
|
||
// (第一版就是这么错的:y 出现 -0.5 / -151.8 这类值,断言按"自上而下"必然判不出顺序)。
|
||
const docY = await el.evaluate((e) => e.getBoundingClientRect().top + window.scrollY);
|
||
positions.push(docY);
|
||
}
|
||
// 段序即信息架构:颠倒说明装配顺序被动过
|
||
expect(positions).toEqual([...positions].sort((a, b) => a - b));
|
||
});
|
||
});
|
||
|
||
// ==================== UJ-11b: 信任验证旅程 ====================
|
||
test.describe('UJ-11b: 信任验证旅程(共创 → 转化)', () => {
|
||
test('@journey @critical 首页首批客户共创标签引导至联系转化', async ({ page }) => {
|
||
await gotoHome(page);
|
||
|
||
const placeholder = page.locator('[data-testid="results-slot-placeholder"]').first();
|
||
await placeholder.scrollIntoViewIfNeeded();
|
||
await expect(placeholder).toBeVisible({ timeout: 10000 });
|
||
|
||
const cardText = await placeholder.textContent();
|
||
expect(cardText).toContain('共创');
|
||
|
||
const coCreationCta = placeholder.locator('a[href="/contact"]').first();
|
||
await expect(coCreationCta).toBeVisible();
|
||
await expect(coCreationCta).toContainText('成为首批共创客户');
|
||
});
|
||
|
||
test('@journey @critical 空案例区呈现共创内容块而非裸空态', async ({ page }) => {
|
||
await gotoHome(page);
|
||
|
||
const bodyText = await page.locator('body').textContent();
|
||
// 无「暂无案例数据」裸空态
|
||
expect(bodyText).not.toContain('暂无案例数据');
|
||
// 成果槽处于**可判别的共创态**,而不是"没数据所以什么都不渲染"
|
||
await expect(page.locator('[data-testid="results-slot-co-creation"]').first()).toBeVisible();
|
||
// 明说不冒充案例(反伪造不变量的用户可见面)
|
||
expect(bodyText).toContain('不会写一个出来');
|
||
// 过程叙事在场:原「01/02/03 三幕」的语义由共创四步承担
|
||
expect(bodyText).toContain('问题梳理');
|
||
expect(bodyText).toContain('交付物验收');
|
||
|
||
// 转化出口仍在
|
||
const placeholder = page.locator('[data-testid="results-slot-placeholder"]').first();
|
||
await expect(placeholder.locator('a[href="/contact"]').first()).toBeVisible();
|
||
});
|
||
});
|
||
|
||
// ==================== UJ-11c: 移动端首屏转化旅程 ====================
|
||
test.describe('UJ-11c: 移动端首屏转化旅程', () => {
|
||
test('@mobile @journey @critical 移动端 CTA 首屏可见且无横向滚动', async ({ page }) => {
|
||
// 模拟移动端视口
|
||
await page.setViewportSize({ width: 390, height: 844 });
|
||
await gotoHome(page);
|
||
|
||
// 无横向滚动
|
||
await expectNoHorizontalOverflow(page);
|
||
|
||
// 首屏 Hero 区块可见
|
||
const heroSection = page.locator('[data-testid="hero-section"]').first();
|
||
await expect(heroSection).toBeVisible({ timeout: 15000 });
|
||
|
||
// CTA 不只是"存在",必须在 844px 首屏折线内 —— 实测 hero 收 70vh 后 y≈418、h≈51
|
||
const cta = page.locator('[data-testid="hero-cta"]').first();
|
||
await expect(cta).toBeVisible();
|
||
const box = await cta.boundingBox();
|
||
expect(box).not.toBeNull();
|
||
expect(box!.y).toBeGreaterThanOrEqual(0);
|
||
expect(box!.y + box!.height).toBeLessThanOrEqual(844);
|
||
});
|
||
|
||
test('@mobile @journey @critical 移动端信任层与成果区单列堆叠无溢出', async ({ page }) => {
|
||
await page.setViewportSize({ width: 390, height: 844 });
|
||
await gotoHome(page);
|
||
|
||
// dev 服务高负载下区块节点会被替换,直接 scrollIntoViewIfNeeded 会撞上
|
||
// 「Element is not attached to the DOM」(chain3 实测 firefox),先等可见再滚动。
|
||
for (const id of ['home-ledger', 'home-ledger-signals', 'results-slot-placeholder', 'home-capabilities']) {
|
||
const el = page.locator(`[data-testid="${id}"]`).first();
|
||
await expect(el).toBeVisible({ timeout: 15000 });
|
||
await el.scrollIntoViewIfNeeded();
|
||
await expect(el).toBeVisible();
|
||
}
|
||
|
||
const basisNote = page.locator('[data-testid="metrics-basis-note"]').first();
|
||
await expect(basisNote).toBeVisible();
|
||
|
||
// 全程无横向滚动(滚动到页面底部后再测一次,窄视口下的溢出通常在末段才暴露)
|
||
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
|
||
await page.waitForTimeout(400);
|
||
await expectNoHorizontalOverflow(page);
|
||
});
|
||
});
|