Files
Jyotisha/frontend/tests/server-owned-birth-profile.test.ts
T
jesse-ux b85c4a686a
Independent Staging Quality Gate / validate (push) Successful in 13m27s
Independent Staging Quality Gate / publish (push) Failing after 1h0m1s
fix(rectification): anchor candidate windows to civil dates across midnight
Carry explicit local date intervals instead of inferring the day from clock
order. Cluster width, delivery, adoption, and reports keep the actual civil
date; adopted date is stored separately from the reported birth_date.

Algorithm identity is scoring-9 / spec-v5. Scoring weights, confirmation
thresholds, and Skill version are unchanged. Isolated Linux final-3 gates
passed; four pre-existing Python failures remain. This is not a production
release.
2026-09-21 02:55:00 +08:00

95 lines
3.3 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { readFileSync } from "node:fs";
import {
ACCOUNT_BIRTH_SELECT,
globalBirthProfileFromAccountRow,
globalBirthProfileFromStoredChart,
} from "../src/lib/server-owned-birth-profile.ts";
test("accepted account rows use the server active minute, not a reported leftover", () => {
const profile = globalBirthProfileFromAccountRow({
name: "测试",
birth_date: "1990-06-15",
reported_birth_time: "08:00:00",
active_birth_time: "09:15:00",
birth_time_status: "accepted",
country_code: "CN",
province_code: "310000",
city_code: "310100",
latitude: 31.2,
longitude: 121.5,
timezone_offset: 8,
timezone_id: "Asia/Shanghai",
});
assert.equal(profile.date, "1990-06-15");
assert.equal(profile.time, "09:15");
assert.equal(profile.timezoneId, "Asia/Shanghai");
assert.equal(profile.birthTimeStatus, "accepted");
});
test("reported rows keep the declared clock until an active minute exists", () => {
const profile = globalBirthProfileFromAccountRow({
birth_date: new Date("1991-01-02T00:00:00.000Z"),
reported_birth_time: "07:40",
active_birth_time: null,
birth_time_status: "reported",
});
assert.equal(profile.date, "1991-01-02");
assert.equal(profile.time, "07:40");
});
test("stored other-chart JSON keeps the library camelCase shape", () => {
const profile = globalBirthProfileFromStoredChart({
name: "对方",
date: "1988-03-04",
time: "18:20",
reportedTime: "18:20",
countryCode: "CN",
provinceCode: "110000",
cityCode: "110100",
latitude: 39.9,
longitude: 116.4,
timezoneOffset: 8,
timezoneId: "Asia/Shanghai",
});
assert.deepEqual(profile, {
name: "对方",
date: "1988-03-04",
time: "18:20",
countryCode: "CN",
provinceCode: "110000",
cityCode: "110100",
districtCode: undefined,
latitude: 39.9,
longitude: 116.4,
timezoneOffset: 8,
timezoneId: "Asia/Shanghai",
ayanamsa: "raman",
birthTimeStatus: undefined,
});
});
test("a stored chart without a clock cannot be used for synastry", () => {
assert.equal(globalBirthProfileFromStoredChart({ date: "1990-01-01", name: "对方" }), null);
assert.equal(globalBirthProfileFromStoredChart(null), null);
});
test("daily and synastry routes share a literal account-birth select string", () => {
const daily = readFileSync(new URL("../src/app/api/daily-starlanguage/route.ts", import.meta.url), "utf8");
const synastry = readFileSync(new URL("../src/app/api/synastry/route.ts", import.meta.url), "utf8");
assert.equal(
ACCOUNT_BIRTH_SELECT,
"name,birth_date,active_birth_date,active_birth_timezone_offset,active_birth_provenance,reported_birth_time,active_birth_time,birth_time,birth_time_status,birth_time_source,country_code,province_code,city_code,district_code,latitude,longitude,timezone_offset,timezone_id,ayanamsa,birth_place_label,uncertainty_before_minutes,uncertainty_after_minutes,declared_window_start,declared_window_end",
);
assert.match(daily, /select\(ACCOUNT_BIRTH_SELECT\)/);
assert.match(synastry, /select\(ACCOUNT_BIRTH_SELECT\)/);
assert.doesNotMatch(daily, /accountBirthColumns/);
assert.doesNotMatch(synastry, /accountBirthColumns/);
assert.doesNotMatch(daily, /\.join\(",\"\)/);
assert.doesNotMatch(synastry, /\.join\(",\"\)/);
});