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

45 lines
1.3 KiB
TypeScript

import { expect, test } from "bun:test";
import { newCodes } from "../src/client/state/reader/codes.ts";
import { reduceReader } from "../src/client/state/reader/reducer.ts";
import { migrateLegacy } from "../src/client/state/reader/migration.ts";
const at = "2026-10-16T12:00:00.000Z";
test("viewing codes clears newness independently from redemption on two accounts", () => {
const feed = {
schemaVersion: 1 as const,
sources: [],
codes: [
{
id: "code",
game: "genshin" as const,
code: "TEST",
reward: null,
expiresAt: null,
firstObservedAt: at,
sourceUrl: "https://example.com",
},
],
};
let state = migrateLegacy({}, ["genshin"], at, () => "account:one");
expect(newCodes(feed, [], "genshin")).toHaveLength(1);
state = reduceReader(state, {
type: "seen",
kind: "codeSeen",
id: "genshin",
ids: ["code"],
at,
opId: "seen",
});
expect(newCodes(feed, state.codeSeen.genshin!, "genshin")).toHaveLength(0);
expect(state.codeRedeemed).toEqual({});
state = reduceReader(state, {
type: "redeem",
accountId: "account:one",
codeId: "code",
redeemed: true,
at,
opId: "redeem",
});
expect(state.codeRedeemed["account:one"]?.code).toBe(at);
expect(state.codeRedeemed["account:two"]).toBeUndefined();
});