From 3dd48c0dc3f0fd9b5637df86448a49d0ab91f3b4 Mon Sep 17 00:00:00 2001 From: jesse-ux Date: Fri, 25 Sep 2026 03:32:36 +0800 Subject: [PATCH] fix(test): follow the home split in source contracts and expose element colors Gate 2888 failed ten frontend contracts after the onboarding shell and bootstrap moved out of page.tsx, and the western element colors were missing from @theme. The scans now follow the new files and still require the home page to mount them. --- docs/BUG_HISTORY.md | 2 +- frontend/src/app/globals.css | 4 ++++ frontend/src/lib/home-bootstrap-run.ts | 1 + .../tests/birth-time-guided-review-fixes.test.ts | 7 ++++++- .../tests/chat-notice-and-scroll-contract.test.ts | 7 ++++++- .../tests/first-paint-fallback-contract.test.ts | 7 ++++++- frontend/tests/home-surface.ts | 4 ++++ frontend/tests/rectification-lazy-loading.test.ts | 15 ++++++++++----- frontend/tests/session-lookup-unlisted.test.ts | 7 ++++++- 9 files changed, 44 insertions(+), 10 deletions(-) diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index 2ad73ecd..3c6803e9 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -13756,7 +13756,7 @@ - 触发条件:首页拆分把引导屏 JSX 从 `page.tsx` 搬到 `home-onboarding-shell.tsx` 后推 staging。 - 根因:合同把 ` { const pageSource = readFileSync(new URL("../src/app/(app)/page.tsx", import.meta.url), "utf8"); + const shell = readFileSync(new URL("../src/components/home-onboarding-shell.tsx", import.meta.url), "utf8"); + // 原值: 地点回显写在 page.tsx。 + // 新值: 回显在引导屏,page.tsx 仍挂载它。 + // 原因: 首页拆分搬走了引导屏,完成校正后不重复地点的条件没变。 + assert.match(pageSource, / { test("keeps the recovery poll from stacking repeated notices", () => { // Given: the recovery loop repeats the same message every 1750ms. - assert.match(pageSource, /timer = window\.setTimeout\(\(\) => void poll\(\), 1_750\)/); + const recoveryPoll = readFileSync(new URL("../src/lib/consultation-recovery-poll.ts", import.meta.url), "utf8"); + // 原值: 1750ms 轮询写在 page.tsx。 + // 新值: 轮询在 consultation-recovery-poll.ts,page.tsx 仍调用它。 + // 原因: 首页拆分搬走了恢复轮询,间隔没变。 + assert.match(pageSource, /runConsultationRecoveryPoll/); + assert.match(recoveryPoll, /timer = window\.setTimeout\(\(\) => void poll\(\), 1_750\)/); // Then: a stable toast id plus last-message dedupe replaces instead of accumulating. assert.match(noticeSource, /export const chatNoticeToastId = "chat-notice"/); diff --git a/frontend/tests/first-paint-fallback-contract.test.ts b/frontend/tests/first-paint-fallback-contract.test.ts index 1be7ebb4..29313515 100644 --- a/frontend/tests/first-paint-fallback-contract.test.ts +++ b/frontend/tests/first-paint-fallback-contract.test.ts @@ -198,7 +198,12 @@ test("fallback script is classic ES5 and waits past the bootstrap budgets", () = assert.match(hook, /!document\.documentElement\) return/); assert.match(hook, /document\.documentElement\.dataset\.hydrated = "1"/); assert.equal(page.includes("dataset.hydrated"), false); - assert.match(page, /连接云端服务超时/); + const bootstrapRun = read("src/lib/home-bootstrap-run.ts"); + // 原值: 超时句写在 page.tsx。 + // 新值: 超时句在 home-bootstrap-run.ts,page.tsx 仍挂载错误屏。 + // 原因: 首页拆分把启动失败文案收成常量,兜底脚本仍不得抢先写出这句。 + assert.match(page, / { diff --git a/frontend/tests/home-surface.ts b/frontend/tests/home-surface.ts index 58485b7b..2db5a6d4 100644 --- a/frontend/tests/home-surface.ts +++ b/frontend/tests/home-surface.ts @@ -4,6 +4,8 @@ const homeSurfaceFiles = [ "../src/app/(app)/page.tsx", "../src/lib/home-types.ts", "../src/components/onboarding-chat-message.tsx", + "../src/components/home-onboarding-shell.tsx", + "../src/components/home-bootstrap-error.tsx", "../src/lib/home-profile.ts", "../src/lib/home-cloud-sync.ts", "../src/components/birth-location-fields.tsx", @@ -24,6 +26,8 @@ const optionalHomeHookFiles = [ "../src/hooks/use-home-shell-registration.ts", "../src/lib/session-list-context.tsx", "../src/lib/session-list-filter.ts", + "../src/lib/home-bootstrap-run.ts", + "../src/lib/consultation-recovery-poll.ts", ] as const; export const homeSurface = [ diff --git a/frontend/tests/rectification-lazy-loading.test.ts b/frontend/tests/rectification-lazy-loading.test.ts index 1ec025b2..bcd93757 100644 --- a/frontend/tests/rectification-lazy-loading.test.ts +++ b/frontend/tests/rectification-lazy-loading.test.ts @@ -3,11 +3,16 @@ import { readFileSync } from "node:fs"; import test from "node:test"; const page = readFileSync(new URL("../src/app/(app)/page.tsx", import.meta.url), "utf8"); +const shell = readFileSync(new URL("../src/components/home-onboarding-shell.tsx", import.meta.url), "utf8"); test("loads birth-time rectification only when its onboarding stage is reached", () => { - assert.match(page, /import dynamic from "next\/dynamic"/); - assert.match(page, /const BirthTimeRectification = dynamic\(/); - assert.match(page, /import\("@\/components\/birth-time-rectification"\)/); - assert.match(page, /ssr: false/); - assert.match(page, /role="status"/); + // 原值: dynamic() 写在 page.tsx。 + // 新值: dynamic() 在引导屏组件,page.tsx 仍挂载该组件。 + // 原因: 首页拆分搬走了引导屏,懒加载本身没变。 + assert.match(page, /