fix(settings): gender is set only in the people archive; drop the 个人资料 duplicate (BUG-1119)
Independent Staging Quality Gate / publish (push) Canceled after 0s
Independent Staging Quality Gate / validate (push) Canceled after 7m59s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N4f2nya58RoRu4yEmJgRGE
This commit is contained in:
Jesse_Chen
2026-09-30 11:11:47 +08:00
co-authored by Claude Opus 5.5
parent 3177ffe61d
commit 3e29b697db
8 changed files with 34 additions and 79 deletions
@@ -1,5 +1,5 @@
// TASK-consult-gender-optional-20260927 T2: optional gender radio (女 / 男 / 不填)
// in the people-archive edit form and the owner's 个人资料, one explanatory
// in the people-archive edit form (the only place since 2026-09-30), one explanatory
// line, and the detail card shows the stored value (未填 when empty).
// Fictional people only (AGENTS §8).
import assert from "node:assert/strict";
@@ -125,16 +125,24 @@ test("detail card: 性别 shows the stored value, 未填 when empty; 本人 edit
});
test("个人资料: the owner's gender saves on its own and birth-data saves never send it", () => {
// 原值: 个人资料 rendered the 女 / 男 / 不填 radios (["女:true", "男:false", "不填:false"]) plus the hint, and
// use-profile-onboarding's persistGender sent the one-field PATCH
// 新值: 个人资料 has no gender control; the one-field PATCH is saveSelfGender, called from the people archive's self edit
// 原因: 产品 2026-09-30「性别应该在档案里设置而不是在个人资料的账户里设置」——两个入口删一个(BUG-1119)
const account = { user: { id: "u", email: "fictional@example.invalid" }, avatar: null } as unknown as Account;
const panel = renderToStaticMarkup(
<ProfilePanel account={account} profile={{ ...selfProfile, gender: "female" }} avatarSaving={false} avatarNotice=""
accountError="" persistAvatar={() => {}} persistGender={async () => {}} />,
accountError="" persistAvatar={() => {}} />,
);
assert.deepEqual(radios(panel), ["女:true", "男:false", "不填:false"]);
assert.ok(panel.includes(PROFILE_GENDER_HINT));
assert.deepEqual(radios(panel), []);
assert.equal(panel.includes(PROFILE_GENDER_HINT), false);
const people = readFileSync(new URL("../src/components/people/people-page.tsx", import.meta.url), "utf8");
assert.match(people, /await saveSelfGender\(gender\)/);
const selfSave = readFileSync(new URL("../src/lib/self-profile-save.ts", import.meta.url), "utf8");
const saveGender = selfSave.slice(selfSave.indexOf("export async function saveSelfGender"));
assert.match(saveGender, /body: JSON\.stringify\(\{ gender \}\)/);
const hook = readFileSync(new URL("../src/hooks/use-profile-onboarding.ts", import.meta.url), "utf8");
const persistGender = hook.slice(hook.indexOf("async function persistGender"), hook.indexOf("async function persistProfile"));
assert.match(persistGender, /body: JSON\.stringify\(\{ gender \}\)/);
assert.equal(/persistGender/.test(hook), false, "no second gender entry in the home hook");
const persistProfile = hook.slice(hook.indexOf("async function persistProfile"), hook.indexOf("async function assessSavedBirthTime"));
assert.equal(/gender/.test(persistProfile), false, "onboarding and birth-data saves do not carry gender");
const onboarding = readFileSync(new URL("../src/components/home-onboarding-shell.tsx", import.meta.url), "utf8");