Fix: show error for year with more than 4 digits in Time Formatter#297
Merged
Conversation
✅ Deploy Preview for freedevtool ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Time Formatter behavior when a user enters a year with more than 4 digits by validating the year segment up-front and displaying a clear inline error instead of silently producing no output.
Changes:
- Added
yearErrorstate and a year-length validation guard informatTimeto show an error and clear results when year > 9999. - Added an inline error banner in the Time Formatter UI (with
data-testid="year-error"). - Added an E2E test covering the invalid 5-digit year path and asserting no formatted results are shown.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| client/src/pages/tools/time-formatter.tsx | Adds year validation logic and renders an inline error banner when the year exceeds 4 digits. |
| tests/e2e/tools/time-formatter.spec.ts | Adds an E2E test ensuring a 5-digit year shows an error and clears formatted outputs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #281
When a user typed a year with more than 4 digits (e.g. `12345-01-01`) into the Time Formatter's date input, the tool silently produced no output. The fix validates the year portion of the date string before attempting to format, and shows a clear error message.
Changes
`client/src/pages/tools/time-formatter.tsx`:
`tests/e2e/tools/time-formatter.spec.ts`: New test sets the date input to `12345-01-01` via the native value setter + synthetic events (bypassing the browser's date-picker UI), then asserts the error banner is visible, contains "4 digits", and no formatted results are shown.