Files
gacha-event-tracker/test/redesign-pinned-routine.test.tsx
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

64 lines
2.4 KiB
TypeScript

import { expect, test } from "bun:test";
import { renderToStaticMarkup as render } from "react-dom/server";
import {
PinnedRoutine,
lastDayInPeriod,
} from "../src/client/components/redesign/PinnedRoutine.tsx";
import { migrateLegacy } from "../src/client/state/reader/migration.ts";
import { routineRows } from "../src/client/state/reader/routines.ts";
const at = "2026-10-16T12:00:00.000Z";
const now = Date.parse(at);
function row(id: string) {
const state = migrateLegacy({}, ["genshin"], at, () => "account:pin");
state.accounts["account:pin"]!.routines[id] = {
followed: true,
checklist: true,
timeline: false,
};
return routineRows(state, "account:pin", now).find((r) => r.id === id)!;
}
const ok = async () => ({ ok: true }) as const;
test("an amount routine short of its target offers +1, an editable count and one-click complete", () => {
const r = row("routine:genshin:weekly-bosses");
const html = render(
<PinnedRoutine row={r} hue="#4EA8DE" onAction={ok} now={now} />,
);
expect(html).toContain("0 / 3 runs");
expect(html).toContain("+1");
expect(html).toContain("Mark Weekly Bosses complete");
expect(html).toContain('aria-pressed="false"');
expect(html).not.toContain("data-done");
});
test("a met target reads done this week, drops +1, and its box offers undo", () => {
const r = row("routine:genshin:weekly-bosses");
const met = { ...r, status: { ...r.status, count: 3, met: true, needed: 0 } };
const html = render(
<PinnedRoutine row={met} hue="#4EA8DE" onAction={ok} now={now} />,
);
expect(html).toContain('data-done="true"');
expect(html).toContain("Done this week");
expect(html).toContain("3 / 3 runs");
expect(html).not.toContain("+1");
expect(html).toContain("done this week. Undo");
expect(html).toContain('aria-pressed="true"');
// Arriving complete is not completing it: no fireworks on render.
expect(html).not.toContain("fireworks");
});
test("undoing a check-in removes the period's latest tick, not one from before it", () => {
const r = row("routine:genshin:realm-depot");
const today = "2026-10-16";
const ticked = {
...r,
days: ["2026-10-08", "2026-10-13", "2026-10-14"],
status: { ...r.status, periodStart: "2026-10-12" },
};
expect(lastDayInPeriod(ticked, today)).toBe("2026-10-14");
expect(
lastDayInPeriod({ ...ticked, days: ["2026-10-08"] }, today),
).toBeNull();
});