Skip to content

enzyme -> RTL: convert the PromptDetail component suites - #459

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

enzyme -> RTL: convert the PromptDetail component suites#459
cigamit merged 2 commits into
ctrliq:mainfrom
blaipr:feature/rtl-components-promptdetail

Conversation

@blaipr

@blaipr blaipr commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
SUMMARY

Converts the PromptDetail component test suite (components/PromptDetail) from enzyme to React Testing Library, continuing the enzyme → RTL migration (components, one directory per PR).

Files migrated off mountWithContexts/enzyme onto renderWithContexts: PromptDetail and the per-resource detail variants — PromptJobTemplateDetail, PromptWFJobTemplateDetail, PromptInventorySourceDetail, PromptProjectDetail.

Prompt-override detail rows and credential/label chips are asserted via assertDetail/getByText; empty Detail rows (which render null) are asserted as absent. Behaviour and assertions are preserved.

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

npm test for components/PromptDetail: 5 suites, 20 tests, all passing. ESLint clean (--no-ignore). No production code changed — test-only. (Redundant mount-only "renders successfully" tests were folded into the detail-render tests since RTL renders fresh per test — no coverage dropped.)

Migrate components/PromptDetail (PromptDetail and the per-resource detail
variants: JobTemplate, WorkflowJobTemplate, InventorySource, Project) off
enzyme/mountWithContexts onto renderWithContexts (React Testing Library).
Prompt-override detail rows and credential/label chips are asserted via
assertDetail/getByText; 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 enzyme → React Testing Library migration by converting the components/PromptDetail test suites to use renderWithContexts/RTL queries, focusing on the main PromptDetail suite and its per-resource detail variants.

Changes:

  • Replaced enzyme mountWithContexts wrappers with RTL renderWithContexts + screen queries.
  • Standardized many label/value assertions using the shared assertDetail helper.
  • Updated “empty Detail” expectations to assert the label is absent (since Detail returns null when isEmpty).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
awx/ui/src/components/PromptDetail/PromptDetail.test.js Migrates the main PromptDetail suite to RTL and updates prompt override section assertions.
awx/ui/src/components/PromptDetail/PromptJobTemplateDetail.test.js Migrates Job Template prompt detail tests to RTL; adds link/content assertions for chips and sparkline links.
awx/ui/src/components/PromptDetail/PromptWFJobTemplateDetail.test.js Migrates Workflow Job Template detail tests to RTL; updates activity/labels empty-row assertions.
awx/ui/src/components/PromptDetail/PromptInventorySourceDetail.test.js Migrates Inventory Source detail tests to RTL; updates chips/options assertions and “Deleted” expectations.
awx/ui/src/components/PromptDetail/PromptProjectDetail.test.js Migrates Project detail tests to RTL; replaces enzyme selectors with assertDetail/text assertions.
Comments suppressed due to low confidence (1)

awx/ui/src/components/PromptDetail/PromptJobTemplateDetail.test.js:149

  • This test overwrites summary_fields with only { labels: { results: [] } }, which drops other summary_fields keys and can change unrelated rendering. Spread the original summary_fields and override only labels.
        resource={{
          ...mockJT,
          summary_fields: {
            labels: {
              results: [],
            },
          },

Comment on lines 100 to 104
test('should render "Deleted" details', () => {
delete mockJT.summary_fields.inventory;
delete mockJT.summary_fields.organization;
delete mockJT.summary_fields.project;

Comment on lines 115 to 120
@@ -139,12 +120,11 @@ describe('PromptJobTemplateDetail', () => {
}}
Comment on lines 129 to 134
@@ -154,14 +134,11 @@ describe('PromptJobTemplateDetail', () => {
}}
Comment on lines +96 to +97
// Variables uses react-ace (empty under jsdom); assert the surrounding label
expect(screen.getByText('Variables')).toBeInTheDocument();
Comment on lines 55 to 60
@@ -74,12 +60,12 @@ describe('PromptWFJobTemplateDetail', () => {
}}
Comment on lines +121 to +122
// No launchConfig prompt data + no overrides -> no "Prompted Values" section
expect(screen.queryByRole('heading', { level: 2 })).toBeNull();
Comment on lines +170 to +172
expect(
screen.getByRole('heading', { level: 2 })
).toHaveTextContent('Prompted Values');
Comment on lines +87 to +88
// Variables uses react-ace (empty under jsdom); assert the surrounding label
expect(screen.getByText('Variables')).toBeInTheDocument();
Comment on lines +186 to +187
// Variables uses react-ace (empty under jsdom); assert the surrounding label
expect(screen.getByText('Variables')).toBeInTheDocument();
Comment on lines 57 to +62
test('should render "Deleted" details', () => {
delete mockProject.summary_fields.organization;
wrapper = mountWithContexts(
<PromptProjectDetail resource={mockProject} />,
{
context: { config },
}
);
assertDetail(wrapper, 'Organization', 'Deleted');
renderWithContexts(<PromptProjectDetail resource={mockProject} />, {
context: { config },
});
assertDetail('Organization', 'Deleted');
Mock the CodeEditor leaf to assert the rendered extra_vars/source_vars YAML; clone shared mocks before deleting fields; spread summary_fields when overriding a single key; query the Prompted Values heading by accessible name; restore the Inventory File row assertion.
@blaipr

blaipr commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Pushed a commit: mock the CodeEditor leaf to assert the rendered extra_vars and source_vars YAML, clone the shared mocks before deleting fields, spread summary_fields when overriding a single key, query the Prompted Values heading by its accessible name, and restore the Inventory File row assertion.

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