Files
Jyotisha/frontend/tests/rectification-session-title-repair.test.ts
T
jesse-ux 2d7698ead3
Independent Staging Quality Gate / validate (push) Successful in 11m43s
Independent Staging Quality Gate / publish (push) Successful in 2m3s
fix(chat): keep stored rectification titles on open
Opening a saved birth-time session no longer restamps the title or updatedAt from the wall clock. Occupies BUG-699, recurrence of BUG-553.
2026-09-15 14:48:03 +08:00

61 lines
1.7 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import {
datedRectificationTitle,
repairedRectificationTitle,
} from "../src/lib/rectification-session-title-repair.ts";
test("dated titles use the product calendar, not UTC", () => {
const createdAt = new Date("2026-09-11T18:30:00.000Z");
assert.equal(datedRectificationTitle(createdAt), "9月12日 · 生时校正");
});
test("repair rewrites a wall-clock today stamp back to created_at's local date", () => {
assert.equal(
repairedRectificationTitle({
title: "9月15日 · 生时校正",
createdAt: new Date("2026-09-12T03:00:00.000Z"),
}),
"9月12日 · 生时校正",
);
assert.equal(
repairedRectificationTitle({
title: "9月15日 · 生时校正 14:32",
createdAt: new Date("2026-09-12T03:00:00.000Z"),
}),
"9月12日 · 生时校正",
);
});
test("repair leaves matching dates and user-renamed titles alone", () => {
assert.equal(
repairedRectificationTitle({
title: "9月12日 · 生时校正",
createdAt: new Date("2026-09-12T03:00:00.000Z"),
}),
null,
);
assert.equal(
repairedRectificationTitle({
title: "9月12日 · 生时校正 14:32",
createdAt: new Date("2026-09-12T03:00:00.000Z"),
}),
null,
);
assert.equal(
repairedRectificationTitle({
title: "家里那次校正",
createdAt: new Date("2026-09-12T03:00:00.000Z"),
}),
null,
);
});
test("missing created_at falls back to a dateless title instead of guessing", () => {
assert.equal(
repairedRectificationTitle({ title: "9月15日 · 生时校正", createdAt: null }),
"生时校正",
);
});