Skip to content

test(frontend): add OTP and email reminder page coverage (issue #127)#226

Open
savanigit wants to merge 1 commit intoshrixtacy:masterfrom
savanigit:test/issue-127-frontend-otp-coverage
Open

test(frontend): add OTP and email reminder page coverage (issue #127)#226
savanigit wants to merge 1 commit intoshrixtacy:masterfrom
savanigit:test/issue-127-frontend-otp-coverage

Conversation

@savanigit
Copy link
Copy Markdown
Contributor

@savanigit savanigit commented Mar 26, 2026

Pull Request

Description

Brief description of the changes in this PR.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring

Related Issues

Fixes #(issue number)

Changes Made

  • List the main changes made in this PR
  • Be specific about what was added, modified, or removed

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this change manually

Testing Details

Describe the tests you ran to verify your changes:

# Example test code or commands

Documentation

  • I have updated the documentation accordingly
  • I have added docstrings to new functions/classes
  • I have updated the README if needed

Code Quality

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for email verification reminder functionality, including resend behavior and error handling.
    • Added comprehensive test coverage for OTP verification flow, including input validation, successful verification, error scenarios, and OTP resend functionality.

@github-actions
Copy link
Copy Markdown

🎉 Thanks for creating a PR!

We'll review it as soon as possible. ☺️

📝 Pre-Review Checklist:

  • ✅ Double-check the file changes tab
  • ✅ Ensure all commits are accurate and properly formatted
  • ✅ Verify that your PR is linked to an issue (our bot will check this)
  • ✅ All tests pass locally
  • ✅ Code follows project style guidelines

💬 Review Process:

  • If there are any unresolved review comments, please address them
  • Respond to reviewer feedback promptly
  • Keep your branch up to date with the base branch

Thank you for your contribution! 🙌🏼

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

📝 Walkthrough

Walkthrough

Two 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

Cohort / File(s) Summary
Email and OTP Verification Tests
web_app/frontend-react/src/pages/VerifyEmailReminder.test.jsx, web_app/frontend-react/src/pages/VerifyOTP.test.jsx
Added Jest test suites with mocked dependencies. VerifyEmailReminder tests initial render, successful resend with API call verification, and error handling with both formatted and generic error messages. VerifyOTP tests render, client-side validation for incomplete OTP, successful verification with auth store updates and navigation, failed verification with field reset, OTP resend, and redirect when userId is missing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Two test files hop into place,
Verifying emails with swift grace,
OTP codes and toasts aligned,
With mocks and stubs, so well-designed,
Our verification flows, now defined!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is a template with only placeholder text and unchecked checkboxes; it lacks concrete information about changes, testing performed, or implementation details. Replace template placeholders with actual details: describe the two new test files, mark relevant checkboxes, specify issue #127, and detail the test cases added for VerifyEmailReminder and VerifyOTP.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding test coverage for OTP and email reminder pages, directly matching the changeset which adds two new test files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

✅ Issue Link Status

Great job @savanigit! This PR is linked to the following issue(s):

📋 Reminder:

  • Ensure your changes address the linked issue(s)
  • All tests should pass
  • Follow the project's coding standards
  • Update documentation if needed

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0ccfe87 and 06c65a6.

📒 Files selected for processing (2)
  • web_app/frontend-react/src/pages/VerifyEmailReminder.test.jsx
  • web_app/frontend-react/src/pages/VerifyOTP.test.jsx

Comment on lines +116 to +120
await waitFor(() => {
expect(toast.error).toHaveBeenCalledWith('Invalid OTP');
expect(inputs[0]).toHaveValue('');
expect(inputs[5]).toHaveValue('');
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
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.

@shrixtacy shrixtacy linked an issue Mar 28, 2026 that may be closed by this pull request
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.

[Testing] Missing Frontend Test Coverage

1 participant