fix: allow complete other charts without rectification

This commit is contained in:
732642856
2026-07-20 02:24:54 +08:00
committed by GitHub
parent e7e2628d4b
commit 6c1c421582
2 changed files with 19 additions and 1 deletions
+8 -1
View File
@@ -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<HTMLFormElement>) {
event.preventDefault();
const nextProfile = { ...otherProfileDraft, name: otherProfileDraft.name.trim() };
if (missingProfileStep(nextProfile)) {
if (missingOtherProfileStep(nextProfile)) {
setAccountError("请补全其他星盘的称呼、出生时间和出生地点。");
return;
}
@@ -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\)/);
});