Skip to content

enzyme -> RTL: convert the Schedule component suites - #457

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

enzyme -> RTL: convert the Schedule component suites#457
cigamit merged 2 commits into
ctrliq:mainfrom
blaipr:feature/rtl-components-schedule

Conversation

@blaipr

@blaipr blaipr commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
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 onto renderWithContexts: Schedule/Schedules, ScheduleList(+item), ScheduleDetail, ScheduleToggle, ScheduleOccurrences, ScheduleAdd/ScheduleEdit, and the shared ScheduleForm + 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
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • UI
ADDITIONAL INFORMATION

npm test for components/Schedule: 13 suites, 124 passing (+1 pre-existing skip). ESLint clean on the converted files (--no-ignore); a couple of narrowly-scoped console.error filters silence benign PF Popper unmount warnings under jsdom. No production code changed — test-only.

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.

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 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 mountWithContexts to RTL renderWithContexts across 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.
@blaipr

blaipr commented Jun 17, 2026

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