Skip to content

enzyme -> RTL: convert the HostMetrics screen suites - #441

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

enzyme -> RTL: convert the HostMetrics screen suites#441
cigamit merged 2 commits into
ctrliq:mainfrom
blaipr:feature/rtl-batch-host-metrics

Conversation

@blaipr

@blaipr blaipr commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
SUMMARY

Converts the HostMetrics screen's test suite from enzyme to React Testing Library, continuing the incremental enzyme → RTL migration (one screen directory per PR).

HostMetrics.test.js migrated off mountWithContexts/enzyme onto renderWithContexts: list rendering and row presence after data load. Interactions 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 HostMetrics directory: 1 suite, 2 tests, all passing. ESLint clean. No production code changed — test-only.

Migrate the HostMetrics screen's test suite off enzyme/mountWithContexts
onto renderWithContexts (React Testing Library). Behaviour and assertions
are preserved; interactions go through accessible roles and real user
events.
@blaipr blaipr changed the title Convert HostMetrics screen tests from enzyme to React Testing Library enzyme -> RTL: convert the HostMetrics 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 enzyme → React Testing Library migration by converting the HostMetrics screen test suite to use renderWithContexts and RTL queries, without changing production UI code.

Changes:

  • Replaced enzyme mountWithContexts + act/waitForElement usage with RTL renderWithContexts and @testing-library/react utilities.
  • Updated assertions to validate post-load rendering via DOM/RTL queries and API call verification.

Comment on lines +38 to +43
renderWithContexts(
<HostMetrics
match={{ path: '/hosts', url: '/hosts' }}
location={{ search: '', pathname: '/hosts' }}
/>
);
Comment on lines +57 to +59
expect(
document.querySelectorAll('[id^="host_metrics-row-"]')
).toHaveLength(1);
@blaipr

blaipr commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. The ignored match and location props are gone, and the host row count is asserted via an accessible role query instead of querySelectorAll.

@cigamit
cigamit merged commit e7a10ee 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