[Bugfix:Forum] Handle invalid category date#12675
Closed
Asterisk-Hunter wants to merge 1 commit into
Closed
Conversation
- Add try-catch for InvalidArgumentException when parsing category visible date - Return user-friendly error message instead of crashing on invalid input - Add data-testid attributes to category date editing elements for testing - Add data-testid to Edit Categories link in ForumBar - Add Cypress test to verify error handling for invalid date format Fixes Submitty#12327
Member
|
This is a duplicate of #12328. I just talked to the creator of that PR today and he plans to make changes to it soon. |
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.
Why is this Change Important & Necessary?
Fixes #12327
When editing a forum category's visible date and entering an invalid format, the system throws an unhandled
InvalidArgumentExceptionfromDateUtils::parseDateTime(). This causes a poor user experience - instead of showing a helpful error message, users see a generic error or stack trace.This PR also supersedes the abandoned PR #12328 and addresses the reviewer feedback from that PR (using data-testid attributes instead of class selectors in tests, not using
force: truein Cypress).What is the New Behavior?
The system now catches the
InvalidArgumentExceptionand returns a friendly error message ("Invalid date format.") to the user via the standard popup notification. The page remains stable and users can correct their input.What steps should a reviewer take to reproduce or test the bug or new feature?
Automated Testing & Documentation
Added a Cypress test in
forums.spec.jsthat:The test follows the feedback from PR #12328:
data-testidattributes instead of class selectorsforce: true[data-testid="popup-message"]) for the error messageOther information
This is not a breaking change. No migrations needed. No security concerns.