Skip to content

test(date-range): pin system date to avoid month-boundary failures#1246

Merged
danimuller20 merged 41 commits intomasterfrom
fix/daterange-tomorrow-month-boundary
Apr 30, 2026
Merged

test(date-range): pin system date to avoid month-boundary failures#1246
danimuller20 merged 41 commits intomasterfrom
fix/daterange-tomorrow-month-boundary

Conversation

@danimuller20
Copy link
Copy Markdown
Contributor

Summary

  • A aritmética de dias nos testes de DateRange assumia que TODAY ± 1 ficava no mesmo mês, quebrando nos dias 30/31 (falha reproduzida em 30/04/2026 — TOMORROW=31 não existia em abril).
  • new Date() (sem args) é fixado em uma data fixa de meio de mês (15/06/2025) para que TODAY/YESTERDAY/TOMORROW sempre caiam no mesmo mês visível do calendário. Date.now() e timers seguem reais para não afetar waitFor nem o teste de tooltip por timeout.
  • commonDisabledDaysProps.disabledDays virou getter para avaliar new Date() no momento do uso (e respeitar a data fixada), em vez de capturar no import.

Test plan

  • npx jest packages/ocean-react/src/Date/__tests__/DateRange.test.tsx — 24/24 passam
  • npm test — 62 suites, 699 testes, todos passam

🤖 Generated with Claude Code

danimuller20 and others added 11 commits December 30, 2025 15:19
Day arithmetic in DateRange tests assumed TODAY ± 1 stayed within the
same calendar month, which broke on the 30/31 of any month. Pin
`new Date()` (no-args) to a fixed mid-month date and make the disabled
days helper lazy so it picks up the pinned date at use time.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Addresses SonarCloud typescript:S7764 issues on the pinned-Date setup.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The project's eslint env does not expose globalThis, so the previous
commit broke the lint step. Declare it explicitly via /* global */.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@danimuller20 danimuller20 merged commit 071ad24 into master Apr 30, 2026
10 of 12 checks passed
@danimuller20 danimuller20 deleted the fix/daterange-tomorrow-month-boundary branch April 30, 2026 19:42
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.

3 participants