44 lines
1.7 KiB
TypeScript
44 lines
1.7 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import test from "node:test";
|
|
|
|
const component = readFileSync(
|
|
new URL("../src/components/conversational-birth-time-rectification.tsx", import.meta.url),
|
|
"utf8",
|
|
);
|
|
const chat = readFileSync(
|
|
new URL("../src/components/rectification-agentic-chat.tsx", import.meta.url),
|
|
"utf8",
|
|
);
|
|
const route = readFileSync(
|
|
new URL("../src/app/api/rectification/agent/route.ts", import.meta.url),
|
|
"utf8",
|
|
);
|
|
const page = readFileSync(new URL("../src/app/page.tsx", import.meta.url), "utf8");
|
|
|
|
test("birth-time rectification entry no longer routes through V4", () => {
|
|
assert.doesNotMatch(component, /loadActiveRectificationV4|RectificationV4Panel|transitionRectificationV4/);
|
|
assert.match(component, /return <AgenticRectificationChat \{\.\.\.props\} \/>/);
|
|
});
|
|
|
|
test("opening is a server-owned operation rather than a hidden user prompt", () => {
|
|
assert.doesNotMatch(chat, /agenticOpeningInstruction|用户刚进入生时校正会话/);
|
|
assert.match(chat, /action: "opening"/);
|
|
assert.match(route, /z\.literal\("opening"\)/);
|
|
assert.match(route, /parsed\.data\.action === "opening"/);
|
|
});
|
|
|
|
test("incomplete profiles stay in the shared onboarding flow", () => {
|
|
const opening = page.slice(
|
|
page.indexOf("async function openBirthTimeRectification"),
|
|
page.indexOf("resumeRectificationSession.current ="),
|
|
);
|
|
assert.match(opening, /const missingStep = missingProfileStep\(profile\)/);
|
|
assert.match(opening, /setOnboardingStep\(missingStep\)/);
|
|
assert.ok(
|
|
opening.indexOf("const missingStep = missingProfileStep(profile)")
|
|
< opening.indexOf("setRectificationSessionId(rectificationSession.id)"),
|
|
);
|
|
assert.match(chat, /payload\?\.code === "profile_incomplete"/);
|
|
});
|