Skip to content

enzyme -> RTL: convert the Dashboard screen suites - #443

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

enzyme -> RTL: convert the Dashboard screen suites#443
cigamit merged 2 commits into
ctrliq:mainfrom
blaipr:feature/rtl-batch-dashboard

Conversation

@blaipr

@blaipr blaipr commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
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 onto renderWithContexts:

  • Dashboard — filter selects, tabs, templates-tab empty state, graph API calls
  • DashboardGraph — period/job-type/job-status selects (scoped by source className) + option counts, readJobGraph args
  • shared/Countfailed styling via DOM class

The d3 LineChart is stubbed (jsdom implements no SVG geometry / getTotalLength); coverage is kept on the surrounding controls and the DashboardAPI.readJobGraph / UnifiedJobTemplatesAPI.read calls. Behaviour and assertions are preserved.

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

npm test for the Dashboard directory: 3 suites, 8 tests, all passing. ESLint clean. No production code changed — test-only.

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.

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 Dashboard screen test suites to RTL using renderWithContexts, while stubbing the d3-based LineChart where jsdom lacks required SVG geometry APIs.

Changes:

  • Migrated Dashboard and DashboardGraph tests from Enzyme mount/simulate patterns to RTL screen/userEvent queries and interactions.
  • Updated shared/Count tests to assert styling via DOM class checks.
  • Added LineChart stubs 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: {} },
});
});
@blaipr

blaipr commented Jun 17, 2026

Copy link
Copy Markdown
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
cigamit merged commit a175bf2 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