Skip to content

fix(site): stabilize date-dependent storybook snapshots#23657

Merged
ethanndickson merged 2 commits intomainfrom
license-settings-cr8z
Mar 26, 2026
Merged

fix(site): stabilize date-dependent storybook snapshots#23657
ethanndickson merged 2 commits intomainfrom
license-settings-cr8z

Conversation

@ethanndickson
Copy link
Copy Markdown
Member

@ethanndickson ethanndickson commented Mar 26, 2026

Generated by mux but reviewed by a human

Several stories computed dates relative to dayjs() / new Date() at render time, causing snapshot text to shift daily. I ran into this on my PRs.

This adds an optional now prop to DateRangePicker, TemplateInsightsControls, and CreateTokenForm so stories can inject a deterministic clock without global mocking. License stories replace the misleadingly-named FIXED_NOW = dayjs().startOf("day") with absolute timestamps. All fixed timestamps use noon UTC to avoid timezone boundary issues.

Affected stories:

  • AgentSettingsPageView: Usage Date Filter, Usage Date Filter Refetch Overlay
  • LicenseCard: Expired/future AI Governance variants, Not Yet Valid
  • LicensesSettingsPage: Shows Addon Ui For Future License Before Nbf
  • TemplateInsightsControls: Day
  • CreateTokenPage: Default

Replace dynamic date computations with fixed timestamps in stories and
add an optional now prop to DateRangePicker, TemplateInsightsControls,
and CreateTokenForm so stories can inject a deterministic clock without
global mocking.

- DateRangePicker: accept optional now prop, thread it through presets,
  boundary normalization, and calendar disabled-date logic
- LicenseCard.stories: replace shifting dayjs().startOf('day') with
  absolute timestamps (2000-01-01 for expired, 2099-01-01 for future)
- LicensesSettingsPage.stories: anchor createLicense helper to a fixed
  STORY_NOW constant instead of bare dayjs() calls
- TemplateInsightsControls.stories: pass fixed now matching endDate
- CreateTokenPage: plumb now prop through to CreateTokenForm for the
  visible expiration description text
- All fixed timestamps use noon UTC to avoid timezone boundary issues
@ethanndickson ethanndickson marked this pull request as ready for review March 26, 2026 05:22
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4685203cc1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ethanndickson
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Contributor

@jaaydenh jaaydenh left a comment

Choose a reason for hiding this comment

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

Looks good, just needs a story for DateRangePicker to consume the new "now" prop

…ion time and pin stories

Recompute now at commit/preset click time so toBoundary always uses a
fresh clock in production. When the now prop is provided (stories), the
injected value is still used for determinism.

Also pass now={fixedNow.toDate()} through all DateRangePicker stories
so calendar grid and preset behavior are snapshot-stable.
@ethanndickson ethanndickson merged commit 87aafd4 into main Mar 26, 2026
27 checks passed
@ethanndickson ethanndickson deleted the license-settings-cr8z branch March 26, 2026 14:21
@github-actions github-actions bot locked and limited conversation to collaborators Mar 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants