Skip to content

Conversation

@iamlokanath
Copy link

@iamlokanath iamlokanath commented Jan 17, 2026

Summary by CodeRabbit

  • New Features

    • Added a confirmation dialog when resetting your passcode that warns resetting will delete stored cards and require re-downloading from issuers.
    • Localized the confirmation prompt across multiple languages.
  • Tests

    • Updated automated tests to cover the new confirmation step and related interactions.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

Walkthrough

Adds a passcode-reset confirmation modal and UI state to PasscodePage, plus localized strings for the confirmation prompt across multiple locale files; tests updated to exercise the new confirm step and translations.

Changes

Cohort / File(s) Summary
Localization - passcode confirmation
src/locales/ar.json, src/locales/en.json, src/locales/fr.json, src/locales/hi.json, src/locales/kn.json, src/locales/pt.json, src/locales/ta.json
Added PasscodePage.forgotPasscodeConfirmation object with title and message strings (new localized confirmation text).
Passcode page UI & logic
src/pages/User/Passcode/PasscodePage.tsx
Added showForgotPasscodeConfirmation state, handlers handleForgotPasscodeClick / handleConfirmForgotPasscode / handleCancelForgotPasscode, renders ConfirmationModal, and extended WalletLockStatus with PERMANENTLY_LOCKED and LAST_ATTEMPT_BEFORE_LOCKOUT.
Tests
src/__tests__/pages/User/PasscodePage.test.tsx
Updated test imports/formatting, added mocked translation keys for confirmation, adjusted interactions to include confirm step and async navigation/waitFor assertions.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant User as User
participant Page as PasscodePage
participant Modal as ConfirmationModal
participant Router as Router/Navigation
User->>Page: Click "Forgot passcode"
Page->>Page: set showForgotPasscodeConfirmation = true
Page->>Modal: render ConfirmationModal
Modal->>User: show title & message (localized)
User->>Modal: Click "Confirm"
Modal->>Page: onConfirm
Page->>Router: navigate to reset-passcode route (with walletId)
Router-->>User: navigates to reset-passcode

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • jackjain

Poem

"I'm a little rabbit, hopping by the screen,
A modal springs up, polite and clean.
'Reset your passcode?' — in seven tongues I say,
Confirm with care, then scamper on your way.
🐇✨"

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a confirmation step before the reset passcode page to prevent accidental resets, which aligns with the core objective and changes across all modified files.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

…e, reducing accidental resets.

Signed-off-by: Lkanath Panda <[email protected]>
@iamlokanath
Copy link
Author

INJIWEB-1585.mp4

@jackjain
Copy link
Contributor

@iamlokanath unit tests are failing on the PR

@sanchi-singh24 please confirm on the modal design

@iamlokanath iamlokanath changed the title added a confirmation step before navigating to the reset passcode page, reducing accidental resets. INJIWEB-1585, added a confirmation step before navigating to the reset passcode page, reducing accidental resets. Jan 27, 2026
@sonarqubecloud
Copy link

Copy link

@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

🤖 Fix all issues with AI agents
In `@inji-web/src/__tests__/pages/User/PasscodePage.test.tsx`:
- Around line 171-185: The test "should redirect to forgot passcode page when
forgot passcode button is clicked and user confirms" uses userEvent.click()
without awaiting it, causing flakiness; update the interactions in this test
(findByTestId "btn-forgot-passcode" click and "btn-confirm" click) to await the
userEvent.click calls so the confirmation modal renders before the next action,
and apply the same fix to the other tests in this file that call
userEvent.click() without await (the tests touching test ids at lines
referenced: "btn-forgot-passcode"/"btn-confirm" and the other failing clicks
noted at lines 193, 244, 279, 292, 321) to ensure each userEvent.click is
awaited.

Comment on lines +171 to 185
test("should redirect to forgot passcode page when forgot passcode button is clicked and user confirms", async () => {
mockApiResponse({ data: successWalletResponse })
renderWithProviders(<PasscodePage />);

const forgotPasscodeButton = await screen.findByTestId("btn-forgot-passcode");
expect(forgotPasscodeButton).toBeInTheDocument();
forgotPasscodeButton.click();
userEvent.click(forgotPasscodeButton);

const confirmButton = await screen.findByTestId("btn-confirm");
expect(confirmButton).toBeInTheDocument();
userEvent.click(confirmButton);

expect(mockNavigate).toBeCalledWith("/user/reset-passcode", {"state": {"walletId": "2c2e1810-19c8-4c85-910d-aa1622412413"}}
await waitFor(() =>
expect(mockNavigate).toHaveBeenCalledWith("/user/reset-passcode", { "state": { "walletId": "2c2e1810-19c8-4c85-910d-aa1622412413" } })
);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cd inji-web && find . -name "PasscodePage.test.tsx" -type f

Repository: inji/inji-web

Length of output: 105


🏁 Script executed:

cat -n inji-web/src/__tests__/pages/User/PasscodePage.test.tsx | head -200

Repository: inji/inji-web

Length of output: 10061


🏁 Script executed:

cd inji-web && grep -n "userEvent\|@testing-library/user-event" src/__tests__/pages/User/PasscodePage.test.tsx | head -20

Repository: inji/inji-web

Length of output: 1227


🏁 Script executed:

cd inji-web && cat package.json | grep -A 2 -B 2 "@testing-library/user-event"

Repository: inji/inji-web

Length of output: 220


🏁 Script executed:

cd inji-web && rg "userEvent\.setup\(\)" src/__tests__ | head -10

Repository: inji/inji-web

Length of output: 39


🏁 Script executed:

cd inji-web && web_search "@testing-library/user-event v13 api click async"

Repository: inji/inji-web

Length of output: 107


🏁 Script executed:

curl -s "https://www.npmjs.com/package/@testing-library/user-event?activeTab=readme" 2>/dev/null | head -100 || echo "Checking local documentation instead"

Repository: inji/inji-web

Length of output: 7367


🏁 Script executed:

cd inji-web && rg "await.*userEvent\.(click|type)" src/__tests__ --context 2 | head -30

Repository: inji/inji-web

Length of output: 2585


Await userEvent.click() to prevent test flakiness.

userEvent.click() is async in v13 and must be awaited. Without awaiting, the confirmation modal may not render before the next interaction, causing race conditions. (Note: userEvent.setup() is not available in v13.5.0; use direct await instead.)

💡 Proposed fix
 test("should redirect to forgot passcode page when forgot passcode button is clicked and user confirms", async () => {
     mockApiResponse({ data: successWalletResponse })
     renderWithProviders(<PasscodePage />);

     const forgotPasscodeButton = await screen.findByTestId("btn-forgot-passcode");
     expect(forgotPasscodeButton).toBeInTheDocument();
-    userEvent.click(forgotPasscodeButton);
+    await userEvent.click(forgotPasscodeButton);

     const confirmButton = await screen.findByTestId("btn-confirm");
     expect(confirmButton).toBeInTheDocument();
-    userEvent.click(confirmButton);
+    await userEvent.click(confirmButton);

     await waitFor(() =>
         expect(mockNavigate).toHaveBeenCalledWith("/user/reset-passcode", { "state": { "walletId": "2c2e1810-19c8-4c85-910d-aa1622412413" } })
     );
 })

Apply the same pattern to other tests in this file that use userEvent.click() without await (lines 193, 244, 279, 292, 321).

📝 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
test("should redirect to forgot passcode page when forgot passcode button is clicked and user confirms", async () => {
mockApiResponse({ data: successWalletResponse })
renderWithProviders(<PasscodePage />);
const forgotPasscodeButton = await screen.findByTestId("btn-forgot-passcode");
expect(forgotPasscodeButton).toBeInTheDocument();
forgotPasscodeButton.click();
userEvent.click(forgotPasscodeButton);
const confirmButton = await screen.findByTestId("btn-confirm");
expect(confirmButton).toBeInTheDocument();
userEvent.click(confirmButton);
expect(mockNavigate).toBeCalledWith("/user/reset-passcode", {"state": {"walletId": "2c2e1810-19c8-4c85-910d-aa1622412413"}}
await waitFor(() =>
expect(mockNavigate).toHaveBeenCalledWith("/user/reset-passcode", { "state": { "walletId": "2c2e1810-19c8-4c85-910d-aa1622412413" } })
);
test("should redirect to forgot passcode page when forgot passcode button is clicked and user confirms", async () => {
mockApiResponse({ data: successWalletResponse })
renderWithProviders(<PasscodePage />);
const forgotPasscodeButton = await screen.findByTestId("btn-forgot-passcode");
expect(forgotPasscodeButton).toBeInTheDocument();
await userEvent.click(forgotPasscodeButton);
const confirmButton = await screen.findByTestId("btn-confirm");
expect(confirmButton).toBeInTheDocument();
await userEvent.click(confirmButton);
await waitFor(() =>
expect(mockNavigate).toHaveBeenCalledWith("/user/reset-passcode", { "state": { "walletId": "2c2e1810-19c8-4c85-910d-aa1622412413" } })
);
})
🤖 Prompt for AI Agents
In `@inji-web/src/__tests__/pages/User/PasscodePage.test.tsx` around lines 171 -
185, The test "should redirect to forgot passcode page when forgot passcode
button is clicked and user confirms" uses userEvent.click() without awaiting it,
causing flakiness; update the interactions in this test (findByTestId
"btn-forgot-passcode" click and "btn-confirm" click) to await the
userEvent.click calls so the confirmation modal renders before the next action,
and apply the same fix to the other tests in this file that call
userEvent.click() without await (the tests touching test ids at lines
referenced: "btn-forgot-passcode"/"btn-confirm" and the other failing clicks
noted at lines 193, 244, 279, 292, 321) to ensure each userEvent.click is
awaited.

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.

2 participants