enzyme -> RTL: convert the Dashboard screen suites - #443
Merged
Conversation
Migrate the Dashboard screen's test suite off enzyme/mountWithContexts onto renderWithContexts (React Testing Library): Dashboard page, the job-graph panel, and the shared Count component. The d3 LineChart is stubbed (jsdom has no SVG geometry) and coverage kept on the surrounding controls and graph API calls. Behaviour and assertions are preserved.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR continues the incremental Enzyme → React Testing Library migration by converting the Dashboard screen test suites to RTL using renderWithContexts, while stubbing the d3-based LineChart where jsdom lacks required SVG geometry APIs.
Changes:
- Migrated
DashboardandDashboardGraphtests from Enzyme mount/simulate patterns to RTLscreen/userEventqueries and interactions. - Updated
shared/Counttests to assert styling via DOM class checks. - Added
LineChartstubs in the dashboard-related suites to keep assertions focused on controls and API calls.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| awx/ui/src/screens/Dashboard/shared/Count.test.js | Converts Count tests to RTL and validates failed styling via DOM classes. |
| awx/ui/src/screens/Dashboard/DashboardGraph.test.js | Converts graph filter/API-call tests to RTL and stubs LineChart. |
| awx/ui/src/screens/Dashboard/Dashboard.test.js | Converts dashboard tab/render tests to RTL, stubs LineChart, and expands API mocks for template tab. |
Comment on lines
+28
to
+32
| beforeEach(() => { | ||
| DashboardAPI.read.mockResolvedValue({}); | ||
| graphRequest = DashboardAPI.readJobGraph; | ||
| graphRequest.mockResolvedValue({}); | ||
| }); |
Comment on lines
+23
to
+44
| beforeEach(() => { | ||
| DashboardAPI.read.mockResolvedValue({}); | ||
| RootAPI.readAssetVariables.mockResolvedValue({ | ||
| data: { | ||
| BRAND_NAME: 'AWX', | ||
| }, | ||
| }); | ||
| graphRequest = DashboardAPI.readJobGraph; | ||
| graphRequest.mockResolvedValue({}); | ||
| UnifiedJobTemplatesAPI.read.mockResolvedValue({ | ||
| data: { count: 0, results: [] }, | ||
| }); | ||
| UnifiedJobTemplatesAPI.readOptions.mockResolvedValue({ | ||
| data: { actions: {}, related_search_fields: [] }, | ||
| }); | ||
| JobTemplatesAPI.readOptions.mockResolvedValue({ | ||
| data: { actions: {} }, | ||
| }); | ||
| WorkflowJobTemplatesAPI.readOptions.mockResolvedValue({ | ||
| data: { actions: {} }, | ||
| }); | ||
| }); |
Contributor
Author
|
Thanks for the review. readJobGraph is now mocked with the expected data.jobs shape, so the success path is actually exercised instead of throwing and being swallowed. |
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 Dashboard 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 ontorenderWithContexts:Dashboard— filter selects, tabs, templates-tab empty state, graph API callsDashboardGraph— period/job-type/job-status selects (scoped by source className) + option counts,readJobGraphargsshared/Count—failedstyling via DOM classThe d3
LineChartis stubbed (jsdom implements no SVG geometry /getTotalLength); coverage is kept on the surrounding controls and theDashboardAPI.readJobGraph/UnifiedJobTemplatesAPI.readcalls. Behaviour and assertions are preserved.ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
npm testfor the Dashboard directory: 3 suites, 8 tests, all passing. ESLint clean. No production code changed — test-only.