fix(rectification): resolve missing birth timezone offsets
Independent Staging Quality Gate / validate (push) Successful in 12m36s
Independent Staging Quality Gate / publish (push) Successful in 9m33s

This commit is contained in:
Jesse_Chen
2026-08-15 21:01:00 +08:00
parent 5b023e9480
commit 47a22319fd
3 changed files with 85 additions and 1 deletions
@@ -168,6 +168,68 @@ test("period-only profiles open with their selected server-owned range", async (
}
});
test("period-only profiles with an IANA timezone can open when the cached offset is missing", async () => {
const originalFetch = globalThis.fetch;
const capturedArgs: { value: Record<string, unknown> | null } = { value: null };
let timezoneLookupCalled = false;
globalThis.fetch = async (input, init) => {
timezoneLookupCalled = true;
assert.equal(String(input), "http://127.0.0.1:5200/api/location/timezone");
assert.deepEqual(JSON.parse(String(init?.body)), {
latitude: 36.420487,
longitude: 114.209936,
birthDate: "1997-08-08",
birthTime: "20:30",
});
return new Response(JSON.stringify({
available: true,
timezoneId: "Asia/Shanghai",
timezoneOffset: 8,
}), { status: 200 });
};
try {
const accounting = fakeAccounting({
profile: {
...completeProfile,
reported_birth_time: null,
birth_time_source: "period_only",
birth_time_period: "evening",
timezone_offset: null,
},
rpc: async (_fn, args) => {
capturedArgs.value = args;
return {
data: {
disposition: "created",
case_id: caseId,
session_id: sessionId,
status: "draft",
should_start_opening: true,
skill_version: "9.0.0",
},
error: null,
};
},
});
const response = await openRectificationCase(accounting, "user-1", {
intent: "homepage",
requestId,
});
assert.equal(response.disposition, "created");
assert.equal(timezoneLookupCalled, true);
assert.deepEqual(capturedArgs.value?.p_candidate_range, { start_time: "18:00", end_time: "22:59" });
assert.equal(
(capturedArgs.value?.p_baseline_birth_snapshot as Record<string, unknown>).timezone_offset,
8,
);
} finally {
globalThis.fetch = originalFetch;
}
});
test("unknown-time profiles open with a full-day server-owned range", async () => {
const capturedArgs: { value: Record<string, unknown> | null } = { value: null };
const accounting = fakeAccounting({