镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

test(usage): make UsagePage read-window test DST-safe - #1668

Merged
matt2e merged 1 commit into
mainfrom
bad-test-date-maths
Oct 27, 2026
Merged

matt2e merged 1 commit into
mainfrom
bad-test-date-maths

Conversation

@matt2e

@matt2e matt2e commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a flaky test in src/bundled/usage/UsagePage.test.tsx that fails around daylight-saving changes.

The Usage page starts its reads at since(now), which is local midnight 29 days ago. The test checked that this start was more than 29 × 24 h before now. That only holds when no daylight-saving change falls inside the window. If clocks went forward within the last 29 days, one of those days is 23 h long. The test then fails whenever it runs between local midnight and 1 am. It was seen failing at 00:24 AEDT after the 4 October spring-forward, 36 minutes short.

The test now compares the read's since with the same since(now) helper the page uses. stats.test.ts already pins since to dayStart(now, 29), so this still checks that the page uses the documented 30-day window, without repeating the calendar arithmetic in the test.

Test-only change. No production code changes.

Validation

  • Reproduced with a fake clock set to 2026-10-20T00:24+11:00 under TZ=Australia/Sydney: the old assertion fails and the new one passes.
  • Pre-push hooks passed (types and related unit tests, design-system).

🤖 Generated with Claude Code

The Usage page starts its reads at `since(now)`: local midnight 29 days
ago. The test asserted that start was more than 29 × 24 h before now,
which is only true while no daylight-saving change falls inside the
window. When clocks have gone forward within the last 29 days, one of
those days is 23 h long, so that midnight is 29 × 24 h − 1 h before the
current midnight and the test fails whenever it runs between local
midnight and 1 am (seen at 00:24 AEDT, 36 minutes short, after the
4 October spring-forward).

Compare the read's `since` with the `since(now)` helper the page uses
instead. stats.test.ts already pins `since` to `dayStart(now, 29)`, so
this still checks the page wires the documented window without redoing
calendar arithmetic. Reproduced by faking the clock to
2026-10-20T00:24+11:00 under TZ=Australia/Sydney: the old assertion
fails there and the new one passes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
@matt2e
matt2e requested a review from a team as a code owner October 26, 2026 21:03

@kalvinnchau kalvinnchau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 No actionable findings at 8c90b4f. The assertion preserves page-to-reader wiring coverage while the separate stats test pins the calendar-day contract. DST reproductions passed at head and failed on base; current-head Vitest CI passed. Validation covered unit/component and date-contract behavior, not native or real-relay workflows.

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Star Lord’s automated source review via Wes’s account, integrating independent Rocket, Mantis and Groot reviews: no changes requested (source assessment 9/10). The assertion now checks the calendar-day window used by UsagePage, while stats.test.ts separately checks the 29-day offset; production behavior is unchanged.

Head 8c90b4f0d7a891442817b26f2ff61b53382c38ed, base 3a4cccebf37038ade5053e7f0edcb141642bc16d, merge-base e7dbf6a257adfaf6e97851f490acb58a80e47e68. Source-only; no tests or app execution, and the author’s DST reproduction was not rerun; hosted CI required is successful, while live-clock midnight sensitivity remains an optional follow-up.

@jameskraus jameskraus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@jameskraus jameskraus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad this is fixed

@matt2e
matt2e merged commit 1db9a6c into main Oct 27, 2026
37 checks passed
@matt2e
matt2e deleted the bad-test-date-maths branch October 27, 2026 22:03
rileycrane added a commit that referenced this pull request Oct 28, 2026
…ted-setup

* origin/main: (24 commits)
  feat(agents): share agents to the community catalog and export snapshots (#1649)
  feat(navigation): dialogs never become Back/Forward destinations (#1696)
  fix(builderlab): sign in when finishing a hosted agent's setup (#1768)
  fix(messages): link #name prose to open channels the directory has named (#1706)
  feat(agents): keep the Mac awake while agents work (#1718)
  perf(panels): skip layout for covered workspace tabs (#1542)
  feat(composer): offer model and effort in a DM with an agent without a mention (#1621)
  test(workflows): wait for dialog initial focus before pasting YAML in WorkflowEditor test (#1705)
  fix(builderlab): show all captured activity without a conversation toggle (#1764)
  feat(agents): add a UI for Attention watches (#1663)
  Keep thread reply branches one level deep (#1751)
  fix(messages): keep table scrollbars inside webkit message rows (#1677)
  feat(agents): sync agent config through config channels (#1226)
  fix(agents): offer a new hosted agent in Solo chats right away (#1759)
  test(usage): make UsagePage read-window test DST-safe (#1668)
  fix(panels): scope split motion selectors to layout owners (#1681)
  feat(agents): simplify imports and clarify community scope (#1660)
  fix(pi): stop posting replies the agent did not send (#1758)
  feat(identity): support a local debug restore helper (#1517)
  test(perf): cover rich thread open close and reopen (#1683)
  ...

Signed-off-by: Riley Crane <rileycrane@squareup.com>
rileycrane added a commit that referenced this pull request Oct 28, 2026
…into rileycrane/bestie-hourly-wake

* origin/rileycrane/bestie-hosted-setup: (25 commits)
  Give Bestie's test fixture the native keepAwake that main now requires
  feat(agents): share agents to the community catalog and export snapshots (#1649)
  feat(navigation): dialogs never become Back/Forward destinations (#1696)
  fix(builderlab): sign in when finishing a hosted agent's setup (#1768)
  fix(messages): link #name prose to open channels the directory has named (#1706)
  feat(agents): keep the Mac awake while agents work (#1718)
  perf(panels): skip layout for covered workspace tabs (#1542)
  feat(composer): offer model and effort in a DM with an agent without a mention (#1621)
  test(workflows): wait for dialog initial focus before pasting YAML in WorkflowEditor test (#1705)
  fix(builderlab): show all captured activity without a conversation toggle (#1764)
  feat(agents): add a UI for Attention watches (#1663)
  Keep thread reply branches one level deep (#1751)
  fix(messages): keep table scrollbars inside webkit message rows (#1677)
  feat(agents): sync agent config through config channels (#1226)
  fix(agents): offer a new hosted agent in Solo chats right away (#1759)
  test(usage): make UsagePage read-window test DST-safe (#1668)
  fix(panels): scope split motion selectors to layout owners (#1681)
  feat(agents): simplify imports and clarify community scope (#1660)
  fix(pi): stop posting replies the agent did not send (#1758)
  feat(identity): support a local debug restore helper (#1517)
  ...

Signed-off-by: Riley Crane <rileycrane@squareup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants