Files
gacha-event-tracker/test/redesign-routines.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 <noreply@anthropic.com>
2026-10-18 01:55:16 +02:00

121 lines
4.5 KiB
TypeScript

import { expect, test } from "bun:test";
import { renderToStaticMarkup as render } from "react-dom/server";
import { RoutineGroup } from "../src/client/components/redesign/RoutineGroup.tsx";
test("always expanded groups have no collapse affordance", () => {
const html = render(
<RoutineGroup title="Genshin" policy="always" focused={false}>
<p>Direct daily controls</p>
</RoutineGroup>,
);
expect(html).not.toContain("<summary");
expect(html).toContain("Direct daily controls");
});
test("focus expands groups without changing the saved default", () => {
const html = render(
<RoutineGroup title="Genshin" policy="collapsed" focused={true}>
<p>Controls</p>
</RoutineGroup>,
);
expect(html).toContain('open=""');
});
import { placementAccounts } from "../src/client/components/redesign/RoutinesPage.tsx";
import { migrateLegacy } from "../src/client/state/reader/migration.ts";
import { routineRows } from "../src/client/state/reader/routines.ts";
test("bulk pins combine changes per account and preserve the other placement", () => {
const at = "2026-10-16T12:00:00.000Z";
const state = migrateLegacy({}, ["genshin"], at, () => "account:bulk");
const a = state.accounts["account:bulk"]!;
a.routines["routine:genshin:weekly-bosses"] = {
followed: true,
checklist: false,
timeline: true,
};
const rows = routineRows(state, a.id, Date.parse(at));
expect(rows.length).toBeGreaterThan(1);
const accounts = placementAccounts(state, rows, "checklist", true);
expect(accounts).toHaveLength(1);
for (const row of rows) {
expect(accounts[0]!.routines[row.id]!.checklist).toBe(true);
expect(accounts[0]!.routines[row.id]!.timeline).toBe(
row.placement.timeline,
);
}
expect(a.routines["routine:genshin:weekly-bosses"]!.checklist).toBe(false);
});
import { RoutinesPage } from "../src/client/components/redesign/RoutinesPage.tsx";
test("the routines table shows progress as text with an edit affordance, not inputs", () => {
const at = "2026-10-16T12:00:00.000Z";
const state = migrateLegacy({}, ["genshin"], at, () => "account:table");
const pin = { followed: true, checklist: true, timeline: true };
state.accounts["account:table"]!.routines["routine:genshin:weekly-bosses"] =
pin;
state.accounts["account:table"]!.routines["dailies:genshin"] = pin;
const html = render(
<RoutinesPage
state={state}
onAction={async () => ({ ok: true })}
now={Date.parse(at)}
/>,
);
expect(html).toContain('class="rt"');
expect(html).toContain('class="gcell"');
expect(html).toContain('title="Enter an amount"');
expect(html).toContain("/ 3 runs");
expect(html).not.toContain('type="number"');
expect(html).toContain('class="pin"');
// One server: the game cell does not name it.
expect(html).not.toContain(">europe<");
});
test("routine bands are named by cadence: Dailies, Weeklies", () => {
const at = "2026-10-16T12:00:00.000Z";
const state = migrateLegacy({}, ["genshin"], at, () => "account:bands");
const pin = { followed: true, checklist: true, timeline: true };
state.accounts["account:bands"]!.routines["routine:genshin:weekly-bosses"] =
pin;
state.accounts["account:bands"]!.routines["dailies:genshin"] = pin;
const html = render(
<RoutinesPage
state={state}
onAction={async () => ({ ok: true })}
now={Date.parse(at)}
/>,
);
expect(html).toContain(">Dailies<");
expect(html).toContain(">Weeklies<");
expect(html).not.toContain(">Today<");
expect(html).not.toContain(">This week<");
});
import { Fireworks } from "../src/client/components/Fireworks.tsx";
test("the grand celebration is wider than the single burst and carries the game's colour", () => {
const single = render(<Fireworks />);
const grand = render(<Fireworks grand hue="#4EA8DE" />);
const count = (html: string) => html.split('class="spark"').length - 1;
expect(count(single)).toBe(27);
expect(count(grand)).toBe(98);
expect(grand).toContain('class="fireworks grand"');
expect(grand).toContain("background:#4EA8DE");
});
test("a finished routine group is marked complete but does not celebrate on arrival", () => {
const html = render(
<RoutineGroup
title="Genshin"
policy="always"
focused={false}
done={2}
total={2}
summary="All 2 done"
>
<p>rows</p>
</RoutineGroup>,
);
expect(html).toContain('data-complete="true"');
expect(html).toContain("All 2 done");
expect(html).not.toContain("data-celebrate");
expect(html).not.toContain("fireworks");
});