范围 {segmentLabel(decision.segment)}
{ownChoice ? <> -按你自己的选择:报告和问答都按这个时间写,开头会说明是你选的。
+ {/* BUG-2256 (产品负责人 2026-11-23): 原值「按你自己的选择:报告和问答都按这个时间写,开头会说明是你选的。」; + 删除,且报告与问答自 BUG-2146/2184 起不再在开头说明. */}按你自己的选择/);
+});
+
+test("every 生时纠正 POST records its step, whatever the outcome", () => {
+ for (const route of ["packet", "adopt", "supplement", "reuse", "astrologer"]) {
+ const source = read(`../src/app/api/chart-choice/${route}/route.ts`);
+ assert.match(source, /import \{ recordChartChoiceStep \} from "@\/lib\/chart-choice\/step-log";/, route);
+ assert.match(source, /const response = await \(async \(\) => \{/, route);
+ assert.match(source, /await recordChartChoiceStep\(\{ userId: caller\.userId, subjectId: parsed\.data\.subjectId, step: [^,]+, request: parsed\.data, response \}\);\n return response;/, route);
+ }
+});
+
+test("the step table goes with the account and the profile, and only the server writes it", () => {
+ const sql = read("../supabase/migrations/20261123090000_chart_choice_steps.sql");
+ assert.match(sql, /user_id uuid not null references auth\.users\(id\) on delete cascade/);
+ assert.match(sql, /chart_profile_id uuid references public\.chart_profiles\(id\) on delete cascade/);
+ assert.match(sql, /enable row level security/);
+ assert.match(sql, /revoke all on table public\.chart_choice_steps from public, anon, authenticated, service_role;/);
+ assert.match(sql, /grant execute on function public\.chart_choice_log_step_v1\(uuid, uuid, text, text, text, jsonb, jsonb\) to service_role;/);
+ // The stated facts and the time source are read as they stand when the step runs.
+ assert.match(sql, /v_declaration jsonb := public\.chart_choice_declaration\(p_user_id, p_chart_profile_id\);/);
+ assert.match(sql, /birth_time_source into v_source/);
+});
+
+test("the privacy policy says what is recorded and for what", () => {
+ const text = PRIVACY.sections.flatMap((section) => section.paragraphs).join("\n");
+ assert.match(text, /改进生时纠正:你在生时纠正里填写的出生时间及其来源、经历、每一步的回答与选择,会逐步记录下来/);
+ assert.match(text, /生时纠正的逐步记录:在账号存续期间保存;删除对应的人物档案或注销账号时一并删除。/);
+ assert.doesNotMatch(text, /生时纠正的问题数量与收敛情况,不含出生资料/);
+});
diff --git a/frontend/tests/rect-step-log-2256.test.ts b/frontend/tests/rect-step-log-2256.test.ts
new file mode 100644
index 000000000..0d5f17760
--- /dev/null
+++ b/frontend/tests/rect-step-log-2256.test.ts
@@ -0,0 +1,35 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { chartChoiceStepResult, recordChartChoiceStepWith as recordChartChoiceStep } from "../src/lib/chart-choice/step-log-core.ts";
+
+// BUG-2256:记录只留状态、代码和放得下的 decision;写不进去时不影响用户这一步。
+
+test("the kept result is the status, the code and the decision when it fits", () => {
+ assert.deepEqual(chartChoiceStepResult(200, { status: "choose", decision: { segment: "a" }, packet: { big: true } }),
+ { http: 200, status: "choose", decision: { segment: "a" } });
+ assert.deepEqual(chartChoiceStepResult(400, { error: "请求格式不对", code: "bad_request" }), { http: 400, code: "bad_request" });
+ const big = chartChoiceStepResult(200, { decision: { text: "x".repeat(20_000) } });
+ assert.equal(big.decision, undefined);
+ assert.ok(Number(big.decision_omitted) > 12_000);
+ assert.deepEqual(chartChoiceStepResult(500, null), { http: 500 });
+});
+
+test("one step is one call with the subject, the request and the outcome", async () => {
+ const calls: { name: string; args: Record