From 6c1c421582a00843300a4d0a438ee4ddbe367d15 Mon Sep 17 00:00:00 2001 From: 732642856 <732642856@qq.com> Date: Mon, 20 Jul 2026 02:24:54 +0800 Subject: [PATCH] fix: allow complete other charts without rectification --- frontend/src/app/page.tsx | 9 ++++++++- frontend/tests/chart-library-other-profile.test.ts | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 frontend/tests/chart-library-other-profile.test.ts diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index ab9a15c6..c87b054c 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -402,6 +402,13 @@ function missingProfileStep(profile: Profile): OnboardingStep | null { return null; } +function missingOtherProfileStep(profile: Profile): "name" | "birth" | "place" | null { + if (!profile.name.trim()) return "name"; + if (!isBirthTimeDraftReady(profile)) return "birth"; + if (!selectedBirthPlace(profile)) return "place"; + return null; +} + function birthQuestion(name: string) { return `${name},你好。接下来请告诉我出生日期,以及你对出生时间知道到什么程度。不确定也没关系,我不会要求你猜一个具体时间。`; } @@ -1431,7 +1438,7 @@ export default function Home() { async function saveOtherChart(event: FormEvent) { event.preventDefault(); const nextProfile = { ...otherProfileDraft, name: otherProfileDraft.name.trim() }; - if (missingProfileStep(nextProfile)) { + if (missingOtherProfileStep(nextProfile)) { setAccountError("请补全其他星盘的称呼、出生时间和出生地点。"); return; } diff --git a/frontend/tests/chart-library-other-profile.test.ts b/frontend/tests/chart-library-other-profile.test.ts new file mode 100644 index 00000000..dbd8023f --- /dev/null +++ b/frontend/tests/chart-library-other-profile.test.ts @@ -0,0 +1,11 @@ +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import test from "node:test"; + +const source = readFileSync(new URL("../src/app/page.tsx", import.meta.url), "utf8"); + +test("other chart saves do not require the owner's rectification state", () => { + assert.match(source, /function missingOtherProfileStep\(profile: Profile\)/); + assert.match(source, /if \(missingOtherProfileStep\(nextProfile\)\)/); + assert.doesNotMatch(source, /saveOtherChart[\s\S]{0,500}missingProfileStep\(nextProfile\)/); +});