Skip to content

Conversation

@iamlokanath
Copy link

@iamlokanath iamlokanath commented Jan 15, 2026

Summary by CodeRabbit

  • New Features

    • Added a login success notification on the user home that triggers after navigation or via a sessionStorage fallback.
    • Localization added for the notification in English, Arabic, French, Hindi, Kannada, Portuguese, and Tamil.
  • Tests

    • Updated tests to verify notification display and that the sessionStorage flag is set and cleared as expected.

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

@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

Walkthrough

Adds a login-success notification flow: new User.Home.loginSuccess translations in seven locale files; PasscodePage sets navigation state and a sessionStorage fallback on successful unlock; HomePage shows a success toast when it detects loginSuccess via location state or sessionStorage.

Changes

Cohort / File(s) Summary
Locale file updates
inji-web/src/locales/{ar,en,fr,hi,kn,pt,ta}.json
Added User.Home.loginSuccess localized strings and adjusted JSON formatting (trailing comma after welcome) across seven locale files.
Home page toast logic
inji-web/src/pages/User/Home/HomePage.tsx
Added useLocation and useRef; new useEffect shows a delayed success toast when location.state.loginSuccess or sessionStorage.showLoginSuccessToast is present; clears sessionStorage flag after showing.
Passcode navigation state
inji-web/src/pages/User/Passcode/PasscodePage.tsx
handleUnlockSuccess now navigates with { state: { loginSuccess: true } } and attempts to set sessionStorage.showLoginSuccessToast = "true" as a fallback (with warning on storage failure).
Tests updated/added
inji-web/src/__tests__/pages/User/*.test.tsx
Updated HomePage and PasscodePage tests: mock useLocation, wrap renders with MemoryRouter, assert toast shown for location/state and sessionStorage cases, and assert sessionStorage set/cleared appropriately.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant PasscodePage as "PasscodePage\n(runs handleUnlockSuccess)"
    participant Router as "Router\n(navigate)"
    participant HomePage as "HomePage\n(useEffect)"
    participant sessionStorage as "sessionStorage"
    participant Toast as "Toast\n(showToast)"

    User->>PasscodePage: Unlock with passcode
    PasscodePage->>sessionStorage: setItem('showLoginSuccessToast','true') (try)
    PasscodePage->>Router: navigate('/user/home', { state: { loginSuccess: true } })
    Router->>HomePage: new location (with state/key)
    HomePage->>HomePage: useEffect on location.key
    HomePage->>HomePage: check location.state.loginSuccess OR sessionStorage flag
    HomePage->>HomePage: delay 100ms
    HomePage->>Toast: showToast(t('Home.loginSuccess'), type: success)
    Toast->>User: display success notification
    HomePage->>sessionStorage: removeItem('showLoginSuccessToast')
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • jackjain

Poem

🐰 I hopped a little hop, then leapt with cheer,
Seven tongues now shout, "Login successful!" clear,
A passcode click, a toast appears,
From state or storage the message nears—
Rabbit smiles, the login song is here! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main feature: adding a success message display on successful login and home page redirect, which aligns with the comprehensive changeset across locale files and components.
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 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.

@iamlokanath
Copy link
Author

INJIWEB-1616.mp4

setDisplayName(userDisplayName);
}, [userDisplayName]);

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please add unit tests for this code ?

AppStorage.removeItem(KEYS.REDIRECT_TO, true);
}
navigate(redirectPath);
// Set sessionStorage flag as backup in case navigation state is lost
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please add unit tests for this code ?

@jackjain
Copy link
Contributor

@iamlokanath unit tests are failing on the PR, please check the same

@iamlokanath iamlokanath changed the title A success message will display when a successful login happens and user redirects to home screen INJIWEB-1616, A success message will display when a successful login happens and user redirects to home screen Jan 27, 2026
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: 2

🤖 Fix all issues with AI agents
In `@inji-web/src/__tests__/pages/User/HomePage.test.tsx`:
- Around line 95-116: The test asserts Storage.prototype.removeItem too early
and can race with HomePage's async effect; update the test so the assertion for
removeItem (the spy created via jest.spyOn(Storage.prototype, 'removeItem')) is
performed inside the same waitFor that checks showToast (or in a separate await
waitFor) after rendering HomePage, ensuring the call with
'showLoginSuccessToast' is awaited before calling removeItemSpy.mockRestore();
keep the rest of the setup (mocking useUser/useLocation and setting
sessionStorage) unchanged.

In `@inji-web/src/__tests__/pages/User/PasscodePage.test.tsx`:
- Around line 181-195: Add an afterEach cleanup block so spies and shared mocks
don't leak between tests: add afterEach(() => { jest.restoreAllMocks();
jest.clearAllMocks(); if (typeof mockNavigate?.mockClear === "function")
mockNavigate.mockClear(); }); This ensures any Storage.prototype.setItem spy
(e.g., setItemSpy created in the test) is restored and global mocks like
mockNavigate (declared in the describe scope) are cleared between tests to avoid
accumulated call counts.

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
inji-web/src/__tests__/pages/User/PasscodePage.test.tsx (1)

375-403: Remove duplicate test.

This test is identical to the one at lines 311-339 (same name: "should clear passcode input fields when wrong passcode is entered during unlock wallet", same logic, same assertions). This appears to be a copy-paste error.

🔧 Proposed fix
-    test("should clear passcode input fields when wrong passcode is entered during unlock wallet", async () => {
-        const expectedErrorMsg = "The passcode doesn't seem right. Please try again, or tap 'Forgot Passcode' if you need help resetting it";
-        // Mock wallet exists
-        mockApiResponseSequence([
-            { data: successWalletResponse }, // fetchWallets
-            { error: { response: { data: { errorCode: "incorrect_passcode" } } }, status: 400 } // unlockWallet
-        ]);
-
-        renderWithProviders(<PasscodePage />);
-
-        await waitFor(() => {
-            expect(mockUseApi.fetchData).toHaveBeenCalledTimes(1);
-        });
-
-        // Enter passcode
-        await enterPasscode();
-        const inputs = screen.getAllByTestId('input-passcode');
-        inputs.forEach(input => expect(input).toHaveValue('1'));
-
-        // Submit
-        userEvent.click(screen.getByTestId("btn-submit-passcode"));
-
-        // Wait for error and check inputs are cleared
-        await waitFor(() => {
-            inputs.forEach(input => expect(input).toHaveValue(''));
-        });
-
-        await verifyPasscodeErrorAndInteractiveElementStatus(expectedErrorMsg, false, "", true, "error-msg-passcode");
-    });
-
     describe('Passcode mismatch validation', () => {

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