enzyme -> RTL: convert the Schedule component suites - #457
Merged
Conversation
Migrate components/Schedule (the schedule list/detail/toggle/occurrences, ScheduleAdd/Edit, the shared ScheduleForm and DateTimePicker) off enzyme/mountWithContexts onto renderWithContexts (React Testing Library). The RRULE frequency/exception form is driven through real selects/inputs; behaviour and assertions are preserved.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR continues the UI test migration from Enzyme to React Testing Library for the Schedule component area, updating suites to use renderWithContexts/RTL queries and user interactions while keeping behavior coverage equivalent.
Changes:
- Migrates Schedule-related tests from Enzyme
mountWithContextsto RTLrenderWithContextsacross the Schedule subtree. - Updates tests to interact with PF controls via DOM-level events/queries (roles, labels, OUIA ids) rather than component props.
- Introduces targeted handling for PF Popper/unmount warnings in jsdom to avoid failing the global console trap.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| awx/ui/src/components/Schedule/shared/ScheduleForm.test.js | Converts ScheduleForm suite to RTL; adds helpers and PF popper warning filtering. |
| awx/ui/src/components/Schedule/shared/DateTimePicker.test.js | Converts DateTimePicker tests to RTL and adds PF popper warning filtering. |
| awx/ui/src/components/Schedule/ScheduleToggle/ScheduleToggle.test.js | Uses RTL to verify schedule toggle behavior and error modal behavior. |
| awx/ui/src/components/Schedule/Schedules.test.js | Updates routing-based render test to RTL and asserts initial toolbar presence. |
| awx/ui/src/components/Schedule/ScheduleOccurrences/ScheduleOccurrences.test.js | Migrates to RTL with DOM assertions for toggle state and rendered occurrences. |
| awx/ui/src/components/Schedule/ScheduleList/ScheduleListItem.test.js | Migrates row rendering assertions to RTL (links, toggles, selection). |
| awx/ui/src/components/Schedule/ScheduleList/ScheduleList.test.js | Migrates list interactions (select, delete, toggle) to RTL and async DOM waits. |
| awx/ui/src/components/Schedule/ScheduleEdit/ScheduleEdit.test.js | Mocks ScheduleForm and drives ScheduleEdit submission logic directly under RTL. |
| awx/ui/src/components/Schedule/ScheduleAdd/ScheduleAdd.test.js | Mocks ScheduleForm and drives ScheduleAdd submission logic directly under RTL. |
| awx/ui/src/components/Schedule/ScheduleDetail/ScheduleDetail.test.js | Converts ScheduleDetail rendering and prompted-values assertions to RTL. |
| awx/ui/src/components/Schedule/Schedule.test.js | Updates Schedule container/tab rendering test to RTL with v5-compat routing. |
Comment on lines
98
to
104
| describe('<ScheduleAdd />', () => { | ||
| beforeEach(async () => { | ||
| beforeEach(() => { | ||
| SchedulesAPI.readZoneInfo.mockResolvedValue({ | ||
| data: [ | ||
| { | ||
| name: 'America/New_York', | ||
| }, | ||
| ], | ||
| data: [{ name: 'America/New_York' }], | ||
| }); | ||
| JobTemplatesAPI.createSchedule.mockResolvedValue({ data: { id: 3 } }); | ||
|
|
||
| CredentialTypesAPI.loadAllTypes.mockResolvedValue([ |
Comment on lines
130
to
136
| describe('<ScheduleEdit />', () => { | ||
| beforeEach(async () => { | ||
| beforeEach(() => { | ||
| SchedulesAPI.readZoneInfo.mockResolvedValue({ | ||
| data: [ | ||
| { | ||
| name: 'America/New_York', | ||
| }, | ||
| ], | ||
| data: [{ name: 'America/New_York' }], | ||
| }); | ||
|
|
||
| SchedulesAPI.readCredentials.mockResolvedValue({ | ||
| data: { |
Comment on lines
+14
to
+30
| const realConsoleError = console.error; | ||
| beforeAll(() => { | ||
| jest.spyOn(console, 'error').mockImplementation((...args) => { | ||
| if ( | ||
| typeof args[0] === 'string' && | ||
| args[0].includes( | ||
| "Can't perform a React state update on an unmounted component" | ||
| ) | ||
| ) { | ||
| return; | ||
| } | ||
| realConsoleError(...args); | ||
| }); | ||
| }); | ||
| afterAll(() => { | ||
| console.error.mockRestore(); | ||
| }); |
Comment on lines
+18
to
+34
| const realConsoleError = console.error; | ||
| beforeAll(() => { | ||
| jest.spyOn(console, 'error').mockImplementation((...args) => { | ||
| if ( | ||
| typeof args[0] === 'string' && | ||
| args[0].includes( | ||
| "Can't perform a React state update on an unmounted component" | ||
| ) | ||
| ) { | ||
| return; | ||
| } | ||
| realConsoleError(...args); | ||
| }); | ||
| }); | ||
| afterAll(() => { | ||
| console.error.mockRestore(); | ||
| }); |
Reset the captured formProps in beforeEach and install the console.error filter per-test (beforeEach/afterEach) so resetMocks doesn't leave stale state between tests.
Contributor
Author
|
Thanks for the review. Pushed a commit: reset the captured formProps in beforeEach and install the console.error filter per test in beforeEach and afterEach, so resetMocks does not leave stale state between tests. |
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 Schedule component test suite (
components/Schedule) from enzyme to React Testing Library, continuing the enzyme → RTL migration (components, one directory per PR).Files migrated off
mountWithContexts/enzyme ontorenderWithContexts:Schedule/Schedules,ScheduleList(+item),ScheduleDetail,ScheduleToggle,ScheduleOccurrences,ScheduleAdd/ScheduleEdit, and the sharedScheduleForm+DateTimePicker.The RRULE frequency/exception form is driven through real selects/inputs (frequency PF Select scoped by ouiaId, native selects by value); Add/Edit mock the shared form and assert the schedule + prompt-credential payload. Behaviour and assertions are preserved.
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
npm testforcomponents/Schedule: 13 suites, 124 passing (+1 pre-existing skip). ESLint clean on the converted files (--no-ignore); a couple of narrowly-scopedconsole.errorfilters silence benign PF Popper unmount warnings under jsdom. No production code changed — test-only.