Skip to content

enzyme -> RTL: convert the Login screen suites - #440

Merged
cigamit merged 2 commits into
ctrliq:mainfrom
blaipr:feature/rtl-batch-login
Jun 18, 2026
Merged

enzyme -> RTL: convert the Login screen suites#440
cigamit merged 2 commits into
ctrliq:mainfrom
blaipr:feature/rtl-batch-login

Conversation

@blaipr

@blaipr blaipr commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
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.js migrated off mountWithContexts/enzyme onto renderWithContexts:

  • credential inputs (queried by id) and the Log In button
  • validation errors asserted via pf-m-hidden helper-text class and inputs' aria-invalid
  • social-auth links counted via their data-cy anchors
  • post-login redirects asserted via the resulting history.location.pathname (/home, /projects) plus localStorage behaviour

Interactions now go through accessible roles and real user events. Behaviour and assertions are preserved.

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • UI
ADDITIONAL INFORMATION

npm test for the Login directory: 1 suite, 15 tests, all passing. ESLint clean. No production code changed — test-only.

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.
@blaipr blaipr changed the title Convert Login screen tests from enzyme to React Testing Library enzyme -> RTL: convert the Login screen suites Jun 16, 2026
@cigamit
cigamit requested a review from Copilot June 17, 2026 07:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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/waitForElement usage with RTL renderWithContexts, screen, and waitFor.
  • 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 thread awx/ui/src/screens/Login/Login.test.js Outdated
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 thread awx/ui/src/screens/Login/Login.test.js Outdated
Comment on lines 293 to 297
await waitFor(() =>
expect(window.localStorage.getItem).toHaveBeenCalledWith(SESSION_USER_ID)
);
expect(window.localStorage.setItem).toHaveBeenCalledWith(
SESSION_USER_ID,
@blaipr

blaipr commented Jun 17, 2026

Copy link
Copy Markdown
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
cigamit merged commit 4c86444 into ctrliq:main Jun 18, 2026
@cigamit cigamit self-assigned this Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants