Skip to content

test(ui): pin the Calendar clock so range specs stop depending on today - #16

Open
ArdaDDemir wants to merge 1 commit into
mainfrom
fix/calendar-range-test
Open

test(ui): pin the Calendar clock so range specs stop depending on today#16
ArdaDDemir wants to merge 1 commit into
mainfrom
fix/calendar-range-test

Conversation

@ArdaDDemir

Copy link
Copy Markdown
Owner

What

Calendar (smoke) > supports range start then end has been failing since 1 August with no source change. This pins the clock for the spec file and closes the hole that let the failure hide.

Why it broke

In range mode the opening view is derived from rangeValue / defaultRangeValue (calendar.tsx:231-235); an empty range falls back to today. The spec passed defaultValue="2026-07-01", which range mode deliberately ignores, so the panel opened on the current month and the hardcoded 2026-07-10 / 2026-07-12 cells were never rendered.

That made it a time bomb: green through July 2026, red every other month. Confirmed by running the unmodified spec against a frozen clock — July passes, January / April / October / December fail.

A second issue kept it quiet: user-event no-ops on a null target instead of throwing, so expect(onRangeValueChange).not.toHaveBeenCalled() passed vacuously and the failure surfaced one assertion later, pointing at the wrong line.

Verified in a browser against the running docs gallery: with an empty range the panel opens on today's month, while the pinned Range showcase opens on July 2026 and highlights 10-14 correctly. Clicking two days produces the expected data-range-start / data-range-end. The component behaves correctly — only the spec was wrong.

Changes

  • Freeze the clock at 2026-07-15 for calendar.test.tsx, with a comment explaining why the literal dates need it
  • Route every click through dayCell(), which fails loudly when a cell is absent
  • Add coverage for end-first range ordering and for the default current-month view

Verification

  • npm test — 45 files, 79/79 pass (was 76/77)
  • npm run typecheck — clean
  • Spec re-run with the real clock frozen to January, April, August and December — 4/4 in each
  • npm run lint — 6 pre-existing problems in apps/web, identical on main at ccf4ad3, untouched here

Test-only change; no source files modified.

🤖 Generated with Claude Code

The range specs clicked hardcoded July 2026 cells, but in range mode the
opening view is derived from `defaultRangeValue`, and an empty range falls
back to today. Those cells only render while the clock sits in July 2026,
so the suite went red on 1 August with no source change.

user-event no-ops on a null target instead of throwing, so the missing
cells also made `expect(onRangeValueChange).not.toHaveBeenCalled()` pass
vacuously and pushed the failure one assertion further down.

- freeze the clock at 2026-07-15 for this file
- route every click through `dayCell()`, which fails when a cell is absent
- add coverage for end-first range ordering and the default month view

Verified green with the real clock frozen to January, April, August and
December.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.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.

1 participant