refactor: the event row takes its clock instead of reading one
Every other surface here is handed `now` — the headline, the board, the dailies strip, the detail sheet — for the reason the parsers are: a function that reads the clock cannot be rendered against a fixed instant, so nothing about it can be asserted. The list row was the one exception, calling the wall clock twice for its window caption and its "starts in". Two things follow from fixing it. Those numbers were counted from a different instant than the `clock` sitting beside them in the same row, which is a disagreement nobody would ever notice and nobody could ever prove. And the countdown is now testable: rendering one row at two instants gives the two answers the injected clock implies, which is what the new test pins. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
fb390c1af8
commit
7bb7dc843c
@@ -348,6 +348,7 @@ export function App() {
|
||||
<EventRow
|
||||
key={row.event.id}
|
||||
row={row}
|
||||
now={now}
|
||||
completed={isDone(row.event.id)}
|
||||
status={prog.progress[row.event.id]?.status}
|
||||
effort={prog.progress[row.event.id]?.effort}
|
||||
|
||||
@@ -23,6 +23,17 @@ export interface DailyBadge {
|
||||
|
||||
interface EventRowProps {
|
||||
row: RowEvent;
|
||||
/**
|
||||
* The instant the page is being read at.
|
||||
*
|
||||
* Passed in like every other surface's, rather than read off the clock here.
|
||||
* This row was the one component asking the wall clock itself, which meant its
|
||||
* caption and its "starts in" counted from a different instant than the
|
||||
* `clock` beside them had been computed against — and that neither could be
|
||||
* rendered against a fixed time in a test, which is the rule the rest of this
|
||||
* codebase holds to.
|
||||
*/
|
||||
now: number;
|
||||
completed: boolean;
|
||||
status?: Status | undefined;
|
||||
effort?: Effort | undefined;
|
||||
@@ -36,6 +47,7 @@ interface EventRowProps {
|
||||
|
||||
export function EventRow({
|
||||
row,
|
||||
now,
|
||||
completed,
|
||||
status,
|
||||
effort,
|
||||
@@ -49,13 +61,13 @@ export function EventRow({
|
||||
const game = gameMeta(event.game);
|
||||
const heat = URGENCY_COLOR[clock.urgency];
|
||||
|
||||
const caption = windowCaption(clock, Date.now());
|
||||
const caption = windowCaption(clock, now);
|
||||
// Only ever a warning when the reader gave an estimate — inferring one to
|
||||
// justify the warning would be inventing their input.
|
||||
const risk = status === "done" ? "fine" : pressure(effort, clock.msRemaining);
|
||||
|
||||
const countdown = clock.upcoming
|
||||
? `starts in ${formatRemaining(clock.startsMs - Date.now())}`
|
||||
? `starts in ${formatRemaining(clock.startsMs - now)}`
|
||||
: clock.msRemaining === null
|
||||
? "end date unknown"
|
||||
: formatRemaining(clock.msRemaining);
|
||||
|
||||
Reference in New Issue
Block a user