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 }), "生时校正", ); });