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

61 lines
2.1 KiB
TypeScript

import { expect, test } from "bun:test";
import { migrateLegacy } from "../src/client/state/reader/migration.ts";
import {
routineRows,
placementFor,
} from "../src/client/state/reader/routines.ts";
const at = "2026-10-16T12:00:00.000Z";
test("routine placements are independent and an absent new routine is not followed", () => {
const state = migrateLegacy({}, ["genshin"], at, () => "account:one");
const a = state.accounts["account:one"]!;
a.routines["routine:genshin:weekly-bosses"] = {
followed: true,
checklist: false,
timeline: true,
};
expect(placementFor(a, "new-routine")).toEqual({
followed: false,
checklist: false,
timeline: false,
});
const rows = routineRows(state, a.id, Date.parse(at));
expect(
rows.find((r) => r.id === "routine:genshin:weekly-bosses")?.placement,
).toEqual({ followed: true, checklist: false, timeline: true });
});
test("a changed reset reads only its own current revision without deleting older history", () => {
const state = migrateLegacy({}, ["genshin"], at, () => "account:one");
const a = state.accounts["account:one"]!;
a.clocks.push({
...a.clocks[0]!,
id: "changed",
effectiveAt: at,
reset: { hour: 5, minute: 30 },
});
state.data[a.id]!.daily.initial = {
"dailies:genshin": { days: ["2026-10-16"], at },
};
const row = routineRows(state, a.id, Date.parse(at)).find(
(r) => r.id === "dailies:genshin",
)!;
expect(row.days).toEqual([]);
expect(state.data[a.id]!.daily.initial).toHaveProperty("dailies:genshin");
});
import { sampleEvent } from "./helpers/reader.ts";
test("an event the reader marked daily remains a directly tickable routine", () => {
const s = migrateLegacy({}, ["genshin"], at, () => "account:one");
s.seenEvents.x = {
accountId: "account:one",
event: sampleEvent,
firstSeenAt: at,
lastSeenAt: at,
clockRevision: "initial",
};
s.data["account:one"]!.progress[sampleEvent.id] = { daily: true, at };
const row = routineRows(s, "account:one", Date.parse(at)).find(
(r) => r.id === sampleEvent.id,
);
expect(row?.placement.followed).toBe(true);
expect(row?.cadence).toBe("day");
});