enzyme -> RTL: convert the Login screen suites - #440
Merged
Conversation
Migrate the Login screen's test suite off enzyme/mountWithContexts onto renderWithContexts (React Testing Library): credential inputs, validation errors, social-auth links, and post-login redirects. Behaviour and assertions are preserved; interactions go through accessible roles and real user events.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR continues the incremental migration from Enzyme to React Testing Library by converting the Login screen’s Jest suite to use renderWithContexts, RTL queries, and userEvent interactions while preserving existing assertions around validation, branding, SSO buttons, and redirect behavior.
Changes:
- Replaced Enzyme
mountWithContexts/waitForElementusage with RTLrenderWithContexts,screen, andwaitFor. - Updated interaction/validation assertions to use DOM-centric checks (
aria-invalid,pf-m-hidden, role-based button lookup). - Reworked post-auth redirect assertions to validate navigation via
history.location.pathname.
Comment on lines
263
to
267
| await waitFor(() => expect(MeAPI.read).toHaveBeenCalled()); | ||
| expect(window.localStorage.getItem).toHaveBeenCalledWith(SESSION_USER_ID); | ||
| expect(window.localStorage.setItem).toHaveBeenCalledWith( | ||
| SESSION_USER_ID, | ||
| '1' |
Comment on lines
293
to
297
| await waitFor(() => | ||
| expect(window.localStorage.getItem).toHaveBeenCalledWith(SESSION_USER_ID) | ||
| ); | ||
| expect(window.localStorage.setItem).toHaveBeenCalledWith( | ||
| SESSION_USER_ID, |
Contributor
Author
|
Thanks for the review. The localStorage getItem and setItem assertions and the redirect are now wrapped together in a single waitFor, so the test waits for the full post-auth state. |
cigamit
approved these changes
Jun 18, 2026
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.
SUMMARY
Converts the Login screen's test suite from enzyme to React Testing Library, continuing the incremental enzyme → RTL migration (one screen directory per PR).
Login.test.jsmigrated offmountWithContexts/enzyme ontorenderWithContexts:pf-m-hiddenhelper-text class and inputs'aria-invaliddata-cyanchorshistory.location.pathname(/home,/projects) plus localStorage behaviourInteractions now go through accessible roles and real user events. Behaviour and assertions are preserved.
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
npm testfor the Login directory: 1 suite, 15 tests, all passing. ESLint clean. No production code changed — test-only.