Skip to content

enzyme -> RTL: convert the Metrics screen suites - #439

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

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

Conversation

@blaipr

@blaipr blaipr commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
SUMMARY

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

Files migrated off mountWithContexts/enzyme onto renderWithContexts:

  • LineChart — asserts the #chart container renders and the help text lands in it
  • Metrics — empty state, instance/metric Select interactions driving the exact MetricsAPI.read call, and exclusion of receptor/execution nodes from the instance list

Interactions now go through accessible roles (Selects scoped by their ouiaId) 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 Metrics directory: 2 suites, 4 tests, all passing. ESLint clean. No production code changed — test-only.

Migrate the Metrics screen's test suite off enzyme/mountWithContexts onto
renderWithContexts (React Testing Library): LineChart and the Metrics
page (instance/metric selects + chart fetch). Behaviour and assertions
are preserved; interactions go through accessible roles and real user
events.
@blaipr blaipr changed the title Convert Metrics screen tests from enzyme to React Testing Library enzyme -> RTL: convert the Metrics 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 Metrics screen test suites to RTL, switching from mountWithContexts to renderWithContexts and updating tests to use user-driven interactions and accessible queries.

Changes:

  • Migrated Metrics screen tests from Enzyme mountWithContexts + direct prop calls to RTL renderWithContexts + userEvent interactions.
  • Updated the LineChart test to assert against the rendered #chart container and its help text content in a jsdom-friendly way.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
awx/ui/src/screens/Metrics/Metrics.test.js Rewrites Metrics suite to RTL with helper-based select interactions and API-call assertions.
awx/ui/src/screens/Metrics/LineChart.test.js Rewrites LineChart suite to RTL and validates #chart + help text rendering.

});
// open the Instance select and pick "instance 1"
const instanceSelect = await openSelect('Instance-select');
await user.click(within(instanceSelect).getByText('instance 1'));

// open the Metric select and pick "metric1"
const metricSelect = await openSelect('Metric-select');
await user.click(within(metricSelect).getByText('metric1'));
).toHaveLength(3);
const instanceSelect = await openSelect('Instance-select');

const listbox = await within(instanceSelect).findByRole('listbox');
@blaipr

blaipr commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. The option lookups now query from screen (the open listbox) instead of scoping to the select container, so the Popper-rendered options are found reliably.

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