fix(frontend): preserve owner profile when switching charts

This commit is contained in:
Jesse_Chen
2026-08-30 14:54:36 +08:00
parent 796e4cf8cf
commit f9a00dc568
3 changed files with 173 additions and 35 deletions
@@ -33,7 +33,7 @@ test("adding another chart waits for the user to choose a relationship type", ()
test("a successful cloud read replaces stale local other charts", () => {
assert.match(
source,
/fetchCloudChartLibrary\(\)[\s\S]{0,800}upsertSelfChart\(cloudLibrary\.filter\(\(record\) => record\.role !== "self"\), profile\)/,
/fetchCloudChartLibrary\(\)[\s\S]{0,800}upsertSelfChart\(cloudLibrary\.filter\(\(record\) => record\.role !== "self"\), profileForLibrary\)/,
);
assert.doesNotMatch(source, /fetchCloudChartLibrary\(\)[\s\S]{0,800}new Map\(\[[\s\S]{0,500}current\.filter\(\(record\) => record\.role === "other"\)/);
});
@@ -81,3 +81,12 @@ test("relationship intent selects domain-specific evidence instead of treating e
assert.match(source, /基础商业合作证据筛查/);
assert.match(source, /relationshipType === "business"/);
});
test("current chart selection is local and does not overwrite the owner's profile", () => {
assert.match(source, /activeChartStorageKey/);
assert.match(source, /localStorage\.setItem\(activeChartStorageKey\(accountId\), record\.id\)/);
assert.match(source, /已设为当前使用资料,账户本人的出生资料未被覆盖/);
assert.doesNotMatch(source, /function makeDefaultChart[\s\S]{0,500}persistProfile\(/);
assert.match(readFileSync(new URL("../src/app/api/chart-profiles/[id]/route.ts", import.meta.url), "utf8"), /星盘不存在或无权更新/);
});