Files
Jyotisha/frontend/tests/session-model-persistence.test.ts
T
ClaudeandClaude Opus 5.5 30637729ff refactor: remove conversational rectification from the web app (BUG-1644)
Home chat surface, onboarding assessment, rectification cases API, Mastra
rectification tools and admin telemetry are gone; 生时纠正 is the standalone
/rectification page. Old birth_time_rectification sessions are hidden from
lists. Consult offer card links to the page. Copy renamed to 生时纠正.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXozbkyFNqbu8pVEtZ7W
2026-11-06 07:55:04 +08:00

37 lines
2.2 KiB
TypeScript

import assert from "node:assert/strict";
import { existsSync, readFileSync } from "node:fs";
import test from "node:test";
// 原值:本文件测 `src/lib/session-model-persistence.ts` 的三个用例——
// 「persists only model_id for the owned session」
// 「serializes model writes for the same session」
// 「continues with the latest model write after an earlier sync fails」
// 即输入框里选的模型逐会话写回云端、同会话串行、失败后以最后一次为准。
// 新值:输入框没有模型选择器,客户端不再按会话保存模型;每条普通咨询都请求后台配置的默认模型,
// 老会话由服务器在这一轮改到默认模型(见 consult-session-model-fallback.test.ts)。下面三条替换上面三条。
// 原因:2026-11-02 产品定(首页界面整理第 4 条):用户不再选模型,模块随选择器一起删除。
const read = (path: string) => readFileSync(new URL(path, import.meta.url), "utf8");
test("the client keeps no per-session model choice to write back", () => {
assert.equal(existsSync(new URL("../src/lib/session-model-persistence.ts", import.meta.url)), false);
for (const path of ["../src/app/(app)/page.tsx", "../src/hooks/use-session-management.ts"]) {
assert.doesNotMatch(read(path), /persistSessionModelSelection|SessionModelPersistenceQueue|selectSessionModel/, path);
}
});
test("no composer renders a model picker", () => {
assert.equal(existsSync(new URL("../src/components/model-selector.tsx", import.meta.url)), false);
for (const path of ["../src/app/(app)/page.tsx", "../src/components/chat-composer.tsx"]) {
assert.doesNotMatch(read(path), /ModelSelector|model-selector|onSelectModel|toolbar=/, path);
}
assert.doesNotMatch(read("../src/app/globals.css"), /\.model-selector-|\.composer-tools/);
});
test("every ordinary turn asks for the admin default model", () => {
// A synastry follow-up keeps its session's model: that route still requires the exact id.
const run = read("../src/hooks/use-consultation-run.ts");
assert.match(run, /modelId: modelCatalog\.defaultModelId,\n\s*name: profile\.name,/);
assert.match(run, /sessionId: currentSession\.id,\n\s*modelId: currentSession\.modelId,\n\s*question,\n\s*theme: "marriage",/);
});