Fix date picker test resilience by selecting any available date#104
Conversation
…date - Updated date picker story test to find any available day button instead of a specific date - Added top-level regex constant for better performance - Made date format assertion more flexible to handle any valid date format - This fixes the failing test that was looking for a specific date that wasn't available The previous revert (e93dbf3) had made the test brittle again by hardcoding it to look for 'Sunday, June 1st, 2025'. This change restores the resilient approach that works regardless of which dates are available in the calendar view. Requested by: Jake Ruesink
|
|
WalkthroughThe test play function for the date picker story was updated to select any enabled day button with numeric text in the calendar, rather than a hardcoded date. The assertion for the submitted date was also generalized to match any standard date format. A regex constant for day button identification was added. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (8)**/*.{tsx,ts}📄 CodeRabbit Inference Engine (.cursor/rules/form-component-patterns.mdc)
Files:
{apps,packages}/**/*.{ts,tsx}📄 CodeRabbit Inference Engine (.cursor/rules/monorepo-organization.mdc)
Files:
{apps,packages}/**/src/**/*.{ts,tsx}📄 CodeRabbit Inference Engine (.cursor/rules/monorepo-organization.mdc)
Files:
apps/docs/**/*.{ts,tsx}📄 CodeRabbit Inference Engine (.cursor/rules/monorepo-organization.mdc)
Files:
{apps,packages}/**/src/**/*.{tsx,ts}📄 CodeRabbit Inference Engine (.cursor/rules/monorepo-organization.mdc)
Files:
**/*.{ts,tsx}📄 CodeRabbit Inference Engine (.cursor/rules/monorepo-organization.mdc)
Files:
apps/docs/src/remix-hook-form/*.stories.tsx📄 CodeRabbit Inference Engine (.cursor/rules/storybook-testing.mdc)
Files:
**/*.stories.tsx📄 CodeRabbit Inference Engine (.cursor/rules/storybook-testing.mdc)
Files:
🧠 Learnings (2)📓 Common learningsapps/docs/src/remix-hook-form/date-picker.stories.tsx (20)Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR 🔇 Additional comments (3)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
📝 Storybook Preview: View Storybook This preview will be updated automatically when you push new changes to this PR.
|
Problem
The date picker test was failing because it was hardcoded to look for a specific date button with aria-label
'Sunday, June 1st, 2025', but that specific date might not be available in the current calendar view.This issue was introduced when commit
e93dbf368be3cc9749d758ed4a530a5b0c4105cbreverted a previous fix that had made the test more resilient.Error
Solution
This PR restores the resilient approach by:
DAY_BUTTON_REGEX) to identify day buttons by their numeric content\d{1,2}\/\d{1,2}\/\d{4})Changes
apps/docs/src/remix-hook-form/date-picker.stories.tsxto use the more resilient test approachDAY_BUTTON_REGEXconstant for better performance and readabilityTesting
✅ All tests now pass (27/27)
✅ Date picker test specifically works regardless of which dates are available in the calendar
Context
This fix addresses the test failure that occurred after Mohsen's revert, making the test robust and preventing future failures due to calendar date availability.
Requested by: Jake Ruesink
💻 View my work • 🚫 Ban all checks • About Codegen
Summary by CodeRabbit