Files
gacha-event-tracker/test/reader-archive.test.ts
T
Lucas WintherandClaude Opus 5.5 50c6e91b00 feat: the redesigned Event Clock
The new reader app replaces the old UI: Checklist with a rail (focus
pills, Next to expire, today's dailies, pinned routines), Timeline in a
new and a classic look, Routines, Archive and a Settings area, in a
Structured (default) and a Relaxed interface. It follows the approved
Round 6 B and Round 7 mockups, corrected screen by screen with the owner.

Reader data moves to a v2 store (gacha-tracker:v2:*). Existing v1 data
is migrated on first load, a recovery copy is written first, and the v1
keys are never removed, so a rollback finds them unchanged. Redeem codes
for Genshin arrive as their own feed.

Also: live's urgency ramp, editable per theme; completion and
section-complete fireworks; a returning-user tour; the design mockups,
specs, plans, reviews and handoff record.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-18 01:55:16 +02:00

53 lines
1.8 KiB
TypeScript

import { expect, test } from "bun:test";
import { migrateLegacy } from "../src/client/state/reader/migration.ts";
import {
captureSeen,
reconcileArchive,
archiveOutcome,
restoreArchive,
} from "../src/client/state/reader/archive.ts";
import { readerEventRows } from "../src/client/state/reader/eventRows.ts";
import { sampleEvent } from "./helpers/reader.ts";
import { pairKey } from "../src/client/state/reader/schema.ts";
const at = "2026-10-16T12:00:00.000Z";
test("archive saves metadata and outcome immediately; restore preserves the event snapshot", () => {
let s = migrateLegacy({}, ["genshin"], at, () => "account:one");
s = captureSeen(s, readerEventRows(s, [sampleEvent], Date.parse(at)), at);
s = archiveOutcome(s, "account:one", sampleEvent.id, "done", at);
expect(s.archive[pairKey("account:one", sampleEvent.id)]?.event.title).toBe(
"Test",
);
expect(s.data["account:one"]?.progress[sampleEvent.id]).toHaveProperty(
"status",
"done",
);
s = restoreArchive(s, "account:one", sampleEvent.id);
expect(s.archive).toEqual({});
expect(s.seenEvents[pairKey("account:one", sampleEvent.id)]).toBeDefined();
});
test("missing source rows are not proof of expiry, and unknown end remains unresolved", () => {
let s = migrateLegacy({}, ["genshin"], at, () => "account:one");
s = captureSeen(
s,
readerEventRows(
s,
[
sampleEvent,
{
...sampleEvent,
id: "genshin:unknown:2026-10-01",
endsAt: null,
endPrecision: "unknown",
},
],
Date.parse(at),
),
at,
);
s = reconcileArchive(s, [], Date.parse(at));
expect(s.archive).toEqual({});
s = reconcileArchive(s, [], Date.parse("2026-11-01T12:00:00Z"));
expect(Object.values(s.archive)).toHaveLength(1);
expect(Object.values(s.archive)[0]?.outcome).toBe("unfinished");
});