test(frontend): add OTP and email reminder page coverage (issue #127)#226
test(frontend): add OTP and email reminder page coverage (issue #127)#226savanigit wants to merge 1 commit intoshrixtacy:masterfrom
Conversation
🎉 Thanks for creating a PR!We'll review it as soon as possible. 📝 Pre-Review Checklist:
💬 Review Process:
Thank you for your contribution! 🙌🏼 |
📝 WalkthroughWalkthroughTwo new test files have been added for email verification reminder and OTP verification pages. The tests comprehensively mock dependencies including toast notifications, API calls, auth store hooks, and router functionality to verify component behavior across success paths, error handling, and edge cases. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Issue Link StatusGreat job @savanigit! This PR is linked to the following issue(s): 📋 Reminder:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@web_app/frontend-react/src/pages/VerifyOTP.test.jsx`:
- Around line 116-120: The test currently only asserts that inputs[0] and
inputs[5] are cleared after an invalid OTP; update the assertion inside the
waitFor in VerifyOTP.test.jsx to verify that all six OTP input fields (inputs[0]
through inputs[5]) have been reset to '' so partial-reset regressions are
caught—locate the waitFor block that checks toast.error and the inputs array and
add expectations for inputs[1], inputs[2], inputs[3], and inputs[4]
toHaveValue('') alongside the existing checks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: af9e09d6-e8ba-40c6-8da6-27f2d2651cc7
📒 Files selected for processing (2)
web_app/frontend-react/src/pages/VerifyEmailReminder.test.jsxweb_app/frontend-react/src/pages/VerifyOTP.test.jsx
| await waitFor(() => { | ||
| expect(toast.error).toHaveBeenCalledWith('Invalid OTP'); | ||
| expect(inputs[0]).toHaveValue(''); | ||
| expect(inputs[5]).toHaveValue(''); | ||
| }); |
There was a problem hiding this comment.
Strengthen OTP reset assertion to all six fields.
On failure, the component resets every OTP slot, but the test only checks Line 118 and Line 119. This can let partial-reset regressions slip through.
✅ Suggested test assertion update
await waitFor(() => {
expect(toast.error).toHaveBeenCalledWith('Invalid OTP');
- expect(inputs[0]).toHaveValue('');
- expect(inputs[5]).toHaveValue('');
+ inputs.forEach((input) => expect(input).toHaveValue(''));
});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| await waitFor(() => { | |
| expect(toast.error).toHaveBeenCalledWith('Invalid OTP'); | |
| expect(inputs[0]).toHaveValue(''); | |
| expect(inputs[5]).toHaveValue(''); | |
| }); | |
| await waitFor(() => { | |
| expect(toast.error).toHaveBeenCalledWith('Invalid OTP'); | |
| inputs.forEach((input) => expect(input).toHaveValue('')); | |
| }); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@web_app/frontend-react/src/pages/VerifyOTP.test.jsx` around lines 116 - 120,
The test currently only asserts that inputs[0] and inputs[5] are cleared after
an invalid OTP; update the assertion inside the waitFor in VerifyOTP.test.jsx to
verify that all six OTP input fields (inputs[0] through inputs[5]) have been
reset to '' so partial-reset regressions are caught—locate the waitFor block
that checks toast.error and the inputs array and add expectations for inputs[1],
inputs[2], inputs[3], and inputs[4] toHaveValue('') alongside the existing
checks.
Pull Request
Description
Brief description of the changes in this PR.
Type of Change
Related Issues
Fixes #(issue number)
Changes Made
Testing
Testing Details
Describe the tests you ran to verify your changes:
# Example test code or commandsDocumentation
Code Quality
Summary by CodeRabbit