Skip to content

enzyme -> RTL: convert the Template screen suites - #483

Merged
cigamit merged 5 commits into
ctrliq:mainfrom
blaipr:feature/rtl-screens-template
Jun 18, 2026
Merged

cigamit merged 5 commits into
ctrliq:mainfrom
blaipr:feature/rtl-screens-template

Conversation

@blaipr

@blaipr blaipr commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
SUMMARY

Converts the screens/Template test suites from enzyme to React Testing Library — the last remaining screens/ directory in the enzyme→RTL migration (follows #398 and #433#453). 47 enzyme suites converted; no production code changed.

Covers:

  • Templates / Template / WorkflowJobTemplate + TemplateSurvey
  • JobTemplate and WorkflowJobTemplate Add / Edit / Detail screens
  • shared JobTemplateForm / WorkflowJobTemplateForm / WebhookSubForm
  • the Survey editor (list / item / question add-edit-form / reorder / toolbar / multiple-choice field)
  • the entire WorkflowJobTemplateVisualizer tree — graph / node / link / start-screen / toolbar, the link and node modals, and the node-type resource lists

Same pattern as the merged conversions: renderWithContexts + screen / fireEvent / waitFor, APIs mocked, fixtures and assertion intent preserved. d3/SVG and PatternFly portals are asserted via element ids, data-cy / data-ouia-component-id, foreignObject content and accessible names rather than geometry or component-name lookups.

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • UI
ADDITIONAL INFORMATION
  • 48 suites / 257 tests pass, 2 documented skips (npx jest src/screens/Template).
  • The two skips are interactions infeasible in jsdom, kept as test.skip with a note: native drag-and-drop reorder in SurveyReorderModal, and the pre-existing Visualizer save-error scenario that already carried a // TODO: ... the scenario passes in the ui marker (preserved, not a new regression).
  • No production (non-test) source files are modified.

Convert all 47 enzyme test suites under screens/Template to React Testing
Library (the last remaining screens/ directory), matching the
renderWithContexts + screen/fireEvent/waitFor pattern of the prior
conversions (ctrliq#398, ctrliq#433-ctrliq#453).

Covers: Templates / Template / WorkflowJobTemplate + TemplateSurvey, the
JobTemplate and WorkflowJobTemplate Add/Edit/Detail screens, the shared
JobTemplateForm / WorkflowJobTemplateForm / WebhookSubForm, the Survey editor
(list/item/question add-edit-form/reorder/toolbar/multiple-choice), and the
entire WorkflowJobTemplateVisualizer tree (graph/node/link/start/toolbar, the
link and node modals, and the node-type resource lists).

d3/SVG and PatternFly portals are asserted via element ids,
data-cy / data-ouia-component-id, foreignObject content and accessible names
rather than geometry or component-name lookups. Two interactions that are
infeasible in jsdom (native drag reorder; one visualizer save-error scenario
that passes in the browser) are kept as documented skips.

48 suites / 257 tests pass (2 documented skips); no production code changed.

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 completes the enzyme → React Testing Library migration for the awx/ui/src/screens/Template/ test suites, converting the last remaining screens/ directory while keeping production code unchanged.

Changes:

  • Converted Workflow Job Template Visualizer suites (graph/link/node/toolbar/modals) from enzyme to RTL using renderWithContexts, screen, and fireEvent.
  • Converted Template / WorkflowJobTemplate Add/Edit/Detail/container suites to RTL patterns, including form stubbing where appropriate.
  • Converted Survey editor suites (list/item/add/edit/toolbar/reorder/multiple-choice) to RTL interactions and assertions.

Reviewed changes

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

Show a summary per file
File Description
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerToolbar.test.js RTL conversion of visualizer toolbar assertions and dispatch tests
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerStartScreen.test.js RTL conversion for start-screen dispatch and read-only behavior
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerLink.test.js RTL conversion for SVG link hover/tooltip actions and dispatches
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerGraph.test.js RTL conversion for graph render, node/link presence, hover help text
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/UnsavedChangesModal.test.js RTL conversion for unsaved-changes modal button wiring
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/RunStep.test.js RTL conversion for selecting run-step cards and verifying selection changes
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeViewModal.test.js RTL conversion for portal modal loading + API call assertions
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/WorkflowJobTemplatesList.test.js RTL conversion for workflow job template selection list behaviors
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/SystemJobTemplatesList.test.js RTL conversion for system job template selection list behaviors
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/ProjectsList.test.js RTL conversion for project selection list behaviors
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/NodeTypeStep.test.js RTL conversion for node-type switching and list rendering
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/JobTemplatesList.test.js RTL conversion for job template selection list and error state
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/InventorySourcesList.test.js RTL conversion for inventory source selection list behaviors
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeNextButton.test.js RTL conversion for wizard next-button behavior and rerender triggering
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeEditModal.test.js RTL conversion using NodeModal stub to invoke onSave directly
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeDeleteModal.test.js RTL conversion for delete-node modal dispatch assertions
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeAddModal.test.js RTL conversion using NodeModal stub to invoke onSave directly
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/DaysToKeepStep.test.js RTL conversion for required field and initial value assertions
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkModal.test.js RTL conversion for add/edit link modal dropdown + confirm/cancel
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkEditModal.test.js RTL conversion for link edit confirm dispatch
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkDeleteModal.test.js RTL conversion for link delete modal dispatch and portal close
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkAddModal.test.js RTL conversion for link add confirm dispatch
awx/ui/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/DeleteAllNodesModal.test.js RTL conversion for delete-all-nodes modal dispatch assertions
awx/ui/src/screens/Template/WorkflowJobTemplateEdit/WorkflowJobTemplateEdit.test.js RTL conversion of WFJT edit container using form stub + API assertions
awx/ui/src/screens/Template/WorkflowJobTemplateDetail/WorkflowJobTemplateDetail.test.js RTL conversion using assertDetail + link/activity/delete-details checks
awx/ui/src/screens/Template/WorkflowJobTemplateAdd/WorkflowJobTemplateAdd.test.js RTL conversion of WFJT add container using form stub + API assertions
awx/ui/src/screens/Template/WorkflowJobTemplate.test.js RTL conversion for top-level WFJT screen tab/route behaviors
awx/ui/src/screens/Template/TemplateSurvey.test.js RTL conversion for TemplateSurvey routing, toggle, update, delete flows
awx/ui/src/screens/Template/Templates.test.js RTL conversion for Templates screen smoke render assertion
awx/ui/src/screens/Template/Template.test.js RTL conversion for Job Template screen tab/route behaviors
awx/ui/src/screens/Template/Survey/SurveyToolbar.test.js RTL conversion for survey toolbar enable/disable and handler wiring
awx/ui/src/screens/Template/Survey/SurveyReorderModal.test.js RTL conversion for reorder modal rendering + save/cancel; keep DnD skipped
awx/ui/src/screens/Template/Survey/SurveyQuestionEdit.test.js RTL conversion for question edit submit, duplicate validation, redirect
awx/ui/src/screens/Template/Survey/SurveyQuestionAdd.test.js RTL conversion for question add submit and duplicate validation
awx/ui/src/screens/Template/Survey/SurveyListItem.test.js RTL conversion for survey row rendering, chips, edit visibility
awx/ui/src/screens/Template/Survey/SurveyList.test.js RTL conversion for list interactions (toggle/select/delete/modal)
awx/ui/src/screens/Template/Survey/MultipleChoiceField.test.js RTL conversion for multiple-choice default toggle behavior
awx/ui/src/screens/Template/shared/WorkflowJobTemplateForm.test.js RTL conversion for WFJT form field rendering and key webhook interactions
awx/ui/src/screens/Template/shared/WebhookSubForm.test.js RTL conversion for webhook subform initial values, service switching, warnings
awx/ui/src/screens/Template/JobTemplateEdit/JobTemplateEdit.test.js RTL conversion of JT edit container using form stub + update/cancel flows
awx/ui/src/screens/Template/JobTemplateDetail/JobTemplateDetail.test.js RTL conversion using assertDetail + delete/details/error behaviors
awx/ui/src/screens/Template/JobTemplateAdd/JobTemplateAdd.test.js RTL conversion of JT add container using form stub + create/cancel/navigation

Comment on lines 104 to 108
test('Delete All button dispatches as expected (duplicate)', () => {
renderToolbar();
fireEvent.click(screen.getByRole('button', { name: 'Delete all nodes' }));
expect(dispatch).toHaveBeenCalledWith({
type: 'SET_SHOW_DELETE_ALL_NODES_MODAL',
expect(onClick).toHaveBeenCalledWith(activeStep);
});

test('onNext triggered when triggerNext counter incrimented', () => {
);
});

test('should toggle jt survery on', async () => {
blaipr added 3 commits June 17, 2026 09:44
# Conflicts:
#	awx/ui/src/screens/Template/WorkflowJobTemplate.test.js
Remove the duplicated Delete All dispatch test; fix the 'incrimented' and 'survery' test-name typos.
awx/ui/node_modules was committed as a self-referential symlink; .gitignore only excludes the directory contents, not the symlink itself. Untrack it so checkout doesn't clobber a real node_modules.
@blaipr

blaipr commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Pushed a commit: removed the duplicated Delete All dispatch test and fixed the incrimented and survery test-name typos. I also removed an accidentally committed node_modules symlink on this branch.

blaipr added a commit to blaipr/ascender that referenced this pull request Jun 17, 2026
These three files were the only overlap between this PR and the screens/Template RTL conversion (ctrliq#483). Make this PR own them outright: convert them from enzyme to React Testing Library, mounted under the real v6 parent route so useParams resolves :id. ctrliq#483 drops these three so the two PRs become independently mergeable in either order, with all three landing as RTL.
Templates.test.js, Template.test.js and WorkflowJobTemplate.test.js are the only files this PR shared with ctrliq#484 (Templates route tree -> v6). ctrliq#484 now owns and RTL-converts those three (mounted for v6). Revert them here so the two PRs touch disjoint files and are independently mergeable in either order; this PR still converts the rest of screens/Template to RTL.
cigamit pushed a commit that referenced this pull request Jun 18, 2026
…#484)

* Convert the Templates route tree to react-router v6 (last <Switch>)

App.js is now v6 (#425) and mounts Templates as a descendant at /templates/*, so Templates.js becomes v6 <Routes> with relative children (job_template/add, workflow_job_template/add, job_template/:id/*, workflow_job_template/:id/*, index list). Template.js and WorkflowJobTemplate.js move their internal <Routes> to relative paths and read useParams from react-router-dom-v5-compat (v5 useParams returns {} as a v6 descendant). Tests remount these under the real v6 parent route. This removes the last <Switch> from main, unblocking the eventual react-router-dom-v5-compat bridge removal.

* Convert the 3 Template entry/detail test suites to RTL (v6-mounted)

These three files were the only overlap between this PR and the screens/Template RTL conversion (#483). Make this PR own them outright: convert them from enzyme to React Testing Library, mounted under the real v6 parent route so useParams resolves :id. #483 drops these three so the two PRs become independently mergeable in either order, with all three landing as RTL.
@cigamit
cigamit merged commit b8874f7 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