Files
gacha-event-tracker/test/reader-event-rows.test.ts
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

45 lines
1.8 KiB
TypeScript

import { expect, test } from "bun:test";
import { readerEventRows } from "../src/client/state/reader/eventRows.ts";
import { migrateLegacy } from "../src/client/state/reader/migration.ts";
import { createAccount } from "../src/client/state/reader/accounts.ts";
import { sampleEvent } from "./helpers/reader.ts";
const at = "2026-10-16T12:00:00.000Z";
test("events resolve on each account's server without changing domain identities", () => {
const s = migrateLegacy({}, ["genshin"], at, () => "account:one");
s.accounts["account:two"] = createAccount(
"genshin",
"asia",
at,
"account:two",
);
s.data["account:two"] = { progress: {}, ignored: {}, daily: {}, amounts: {} };
const rows = readerEventRows(s, [sampleEvent], Date.parse(at));
expect(rows).toHaveLength(2);
expect(rows[0]?.event.id).toBe(sampleEvent.id);
expect(new Set(rows.map((r) => r.clock.endsMs)).size).toBe(2);
expect(new Set(rows.map((r) => r.accountId)).size).toBe(2);
});
test("missing future and unknown-end seen events remain accessible", () => {
const s = migrateLegacy({}, ["genshin"], at, () => "account:one");
s.seenEvents.a = {
accountId: "account:one",
event: { ...sampleEvent, endsAt: null, endPrecision: "unknown" },
firstSeenAt: at,
lastSeenAt: at,
clockRevision: "initial",
};
expect(readerEventRows(s, [], Date.parse(at))[0]?.clock.endsMs).toBeNull();
});
test("deleted reader events are not resurrected from their seen snapshots", () => {
const s = migrateLegacy({}, ["genshin"], at, () => "account:one");
s.seenEvents.a = {
accountId: "account:one",
event: { ...sampleEvent, id: "myevent:deleted", sourceUrl: null },
firstSeenAt: at,
lastSeenAt: at,
clockRevision: "initial",
};
expect(readerEventRows(s, [], Date.parse(at))).toHaveLength(0);
});