From 1b5fa9c79956975b07365e783267caac4b316dde Mon Sep 17 00:00:00 2001 From: "Keith J. Grant" Date: Tue, 6 Jul 2021 12:31:27 -0700 Subject: [PATCH] fix errors logged in tests (scheduls/organization) --- awx/ui_next/src/components/Lookup/Lookup.jsx | 3 +- .../Schedule/ScheduleAdd/ScheduleAdd.test.jsx | 11 + .../ScheduleEdit/ScheduleEdit.test.jsx | 24 ++- .../components/Schedule/Schedules.test.jsx | 1 + .../Schedule/shared/ScheduleForm.jsx | 11 +- .../Schedule/shared/ScheduleForm.test.jsx | 197 +++++++++++------- .../OrganizationDetail/OrganizationDetail.jsx | 2 +- .../OrganizationEdit.test.jsx | 4 +- 8 files changed, 158 insertions(+), 95 deletions(-) diff --git a/awx/ui_next/src/components/Lookup/Lookup.jsx b/awx/ui_next/src/components/Lookup/Lookup.jsx index 6a8a4130ed..1114006c3e 100644 --- a/awx/ui_next/src/components/Lookup/Lookup.jsx +++ b/awx/ui_next/src/components/Lookup/Lookup.jsx @@ -7,6 +7,7 @@ import { number, oneOfType, shape, + node, } from 'prop-types'; import { withRouter } from 'react-router-dom'; import { useField } from 'formik'; @@ -206,7 +207,7 @@ const Item = shape({ Lookup.propTypes = { id: string, header: string, - modalDescription: string, + modalDescription: oneOfType([string, node]), onChange: func.isRequired, value: oneOfType([Item, arrayOf(Item)]), multiple: bool, diff --git a/awx/ui_next/src/components/Schedule/ScheduleAdd/ScheduleAdd.test.jsx b/awx/ui_next/src/components/Schedule/ScheduleAdd/ScheduleAdd.test.jsx index 6d115e00bc..a9bceda2dd 100644 --- a/awx/ui_next/src/components/Schedule/ScheduleAdd/ScheduleAdd.test.jsx +++ b/awx/ui_next/src/components/Schedule/ScheduleAdd/ScheduleAdd.test.jsx @@ -73,7 +73,9 @@ describe('', () => { /> ); }); + wrapper.update(); }); + test('Successfully creates a schedule with repeat frequency: None (run once)', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -95,6 +97,7 @@ describe('', () => { 'DTSTART;TZID=America/New_York:20200325T100000 RRULE:INTERVAL=1;COUNT=1;FREQ=MINUTELY', }); }); + test('Successfully creates a schedule with 10 minute repeat frequency after 10 occurrences', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -117,6 +120,7 @@ describe('', () => { 'DTSTART;TZID=America/New_York:20200325T103000 RRULE:INTERVAL=10;FREQ=MINUTELY;COUNT=10', }); }); + test('Successfully creates a schedule with hourly repeat frequency ending on a specific date/time', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -140,6 +144,7 @@ describe('', () => { 'DTSTART;TZID=America/New_York:20200325T104500 RRULE:INTERVAL=1;FREQ=HOURLY;UNTIL=20200326T104500', }); }); + test('Successfully creates a schedule with daily repeat frequency', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -161,6 +166,7 @@ describe('', () => { 'DTSTART;TZID=America/New_York:20200325T104500 RRULE:INTERVAL=1;FREQ=DAILY', }); }); + test('Successfully creates a schedule with weekly repeat frequency on mon/wed/fri', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -183,6 +189,7 @@ describe('', () => { rrule: `DTSTART;TZID=America/New_York:20200325T104500 RRULE:INTERVAL=1;FREQ=WEEKLY;BYDAY=${RRule.MO},${RRule.WE},${RRule.FR}`, }); }); + test('Successfully creates a schedule with monthly repeat frequency on the first day of the month', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -207,6 +214,7 @@ describe('', () => { 'DTSTART;TZID=America/New_York:20200401T104500 RRULE:INTERVAL=1;FREQ=MONTHLY;BYMONTHDAY=1', }); }); + test('Successfully creates a schedule with monthly repeat frequency on the last tuesday of the month', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -259,6 +267,7 @@ describe('', () => { 'DTSTART;TZID=America/New_York:20200301T000000 RRULE:INTERVAL=1;FREQ=YEARLY;BYMONTH=3;BYMONTHDAY=1', }); }); + test('Successfully creates a schedule with yearly repeat frequency on the second Friday in April', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -285,6 +294,7 @@ describe('', () => { 'DTSTART;TZID=America/New_York:20200410T111500 RRULE:INTERVAL=1;FREQ=YEARLY;BYSETPOS=2;BYDAY=FR;BYMONTH=4', }); }); + test('Successfully creates a schedule with yearly repeat frequency on the first weekday in October', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -464,6 +474,7 @@ describe('', () => { /> ); }); + scheduleSurveyWrapper.update(); await act(async () => { scheduleSurveyWrapper.find('Formik').invoke('onSubmit')({ description: 'test description', diff --git a/awx/ui_next/src/components/Schedule/ScheduleEdit/ScheduleEdit.test.jsx b/awx/ui_next/src/components/Schedule/ScheduleEdit/ScheduleEdit.test.jsx index faa505734c..39b77d5301 100644 --- a/awx/ui_next/src/components/Schedule/ScheduleEdit/ScheduleEdit.test.jsx +++ b/awx/ui_next/src/components/Schedule/ScheduleEdit/ScheduleEdit.test.jsx @@ -1,10 +1,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; import { RRule } from 'rrule'; -import { - mountWithContexts, - waitForElement, -} from '../../../../testUtils/enzymeHelpers'; +import { mountWithContexts } from '../../../../testUtils/enzymeHelpers'; import { SchedulesAPI, InventoriesAPI, @@ -191,12 +188,13 @@ describe('', () => { /> ); }); - await waitForElement(wrapper, 'ContentLoading', el => el.length === 0); + wrapper.update(); }); + afterEach(() => { - wrapper.unmount(); jest.clearAllMocks(); }); + test('Successfully creates a schedule with repeat frequency: None (run once)', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -210,6 +208,7 @@ describe('', () => { timezone: 'America/New_York', }); }); + expect(SchedulesAPI.update).toHaveBeenCalledWith(27, { description: 'test description', name: 'Run once schedule', @@ -218,6 +217,7 @@ describe('', () => { 'DTSTART;TZID=America/New_York:20200325T100000 RRULE:INTERVAL=1;COUNT=1;FREQ=MINUTELY', }); }); + test('Successfully creates a schedule with 10 minute repeat frequency after 10 occurrences', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -241,6 +241,7 @@ describe('', () => { 'DTSTART;TZID=America/New_York:20200325T103000 RRULE:INTERVAL=10;FREQ=MINUTELY;COUNT=10', }); }); + test('Successfully creates a schedule with hourly repeat frequency ending on a specific date/time', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -256,6 +257,7 @@ describe('', () => { timezone: 'America/New_York', }); }); + expect(SchedulesAPI.update).toHaveBeenCalledWith(27, { description: 'test description', name: 'Run every hour until date', @@ -264,6 +266,7 @@ describe('', () => { 'DTSTART;TZID=America/New_York:20200325T104500 RRULE:INTERVAL=1;FREQ=HOURLY;UNTIL=20200326T104500', }); }); + test('Successfully creates a schedule with daily repeat frequency', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -308,6 +311,7 @@ describe('', () => { rrule: `DTSTART;TZID=America/New_York:20200325T104500 RRULE:INTERVAL=1;FREQ=WEEKLY;BYDAY=${RRule.MO},${RRule.WE},${RRule.FR}`, }); }); + test('Successfully creates a schedule with monthly repeat frequency on the first day of the month', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -333,6 +337,7 @@ describe('', () => { 'DTSTART;TZID=America/New_York:20200401T104500 RRULE:INTERVAL=1;FREQ=MONTHLY;BYMONTHDAY=1', }); }); + test('Successfully creates a schedule with monthly repeat frequency on the last tuesday of the month', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -362,6 +367,7 @@ describe('', () => { 'DTSTART;TZID=America/New_York:20200331T110000 RRULE:INTERVAL=1;FREQ=MONTHLY;BYSETPOS=-1;BYDAY=TU', }); }); + test('Successfully creates a schedule with yearly repeat frequency on the first day of March', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -388,6 +394,7 @@ describe('', () => { 'DTSTART;TZID=America/New_York:20200301T000000 RRULE:INTERVAL=1;FREQ=YEARLY;BYMONTH=3;BYMONTHDAY=1', }); }); + test('Successfully creates a schedule with yearly repeat frequency on the second Friday in April', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -416,6 +423,7 @@ describe('', () => { 'DTSTART;TZID=America/New_York:20200410T111500 RRULE:INTERVAL=1;FREQ=YEARLY;BYSETPOS=2;BYDAY=FR;BYMONTH=4', }); }); + test('Successfully creates a schedule with yearly repeat frequency on the first weekday in October', async () => { await act(async () => { wrapper.find('Formik').invoke('onSubmit')({ @@ -653,6 +661,7 @@ describe('', () => { 'DTSTART;TZID=America/New_York:20200402T184500 RRULE:INTERVAL=1;COUNT=1;FREQ=MINUTELY', }); }); + test('should submit survey with default values properly, without opening prompt wizard', async () => { let scheduleSurveyWrapper; await act(async () => { @@ -741,6 +750,8 @@ describe('', () => { /> ); }); + scheduleSurveyWrapper.update(); + await act(async () => { scheduleSurveyWrapper.find('Formik').invoke('onSubmit')({ description: 'test description', @@ -753,6 +764,7 @@ describe('', () => { timezone: 'America/New_York', }); }); + expect(SchedulesAPI.update).toHaveBeenCalledWith(27, { description: 'test description', name: 'Run once schedule', diff --git a/awx/ui_next/src/components/Schedule/Schedules.test.jsx b/awx/ui_next/src/components/Schedule/Schedules.test.jsx index 3efd1a7754..937745dfee 100644 --- a/awx/ui_next/src/components/Schedule/Schedules.test.jsx +++ b/awx/ui_next/src/components/Schedule/Schedules.test.jsx @@ -19,6 +19,7 @@ describe('', () => { jobTemplate={jobTemplate} loadSchedules={() => {}} loadScheduleOptions={() => {}} + apiModel={{ createSchedule: () => {} }} />, { diff --git a/awx/ui_next/src/components/Schedule/shared/ScheduleForm.jsx b/awx/ui_next/src/components/Schedule/shared/ScheduleForm.jsx index 510b0c0a83..f3e6d3893e 100644 --- a/awx/ui_next/src/components/Schedule/shared/ScheduleForm.jsx +++ b/awx/ui_next/src/components/Schedule/shared/ScheduleForm.jsx @@ -178,7 +178,6 @@ function ScheduleForm({ hasDaysToKeepField, handleCancel, handleSubmit, - schedule, submitError, resource, @@ -234,8 +233,14 @@ function ScheduleForm({ { zonesOptions: [], credentials: [], + isLoading: true, } ); + + useEffect(() => { + loadScheduleData(); + }, [loadScheduleData]); + const missingRequiredInventory = useCallback(() => { let missingInventory = false; if ( @@ -357,10 +362,6 @@ function ScheduleForm({ hasCredentialsThatPrompt, ]); - useEffect(() => { - loadScheduleData(); - }, [loadScheduleData]); - let showPromptButton = false; if ( diff --git a/awx/ui_next/src/components/Schedule/shared/ScheduleForm.test.jsx b/awx/ui_next/src/components/Schedule/shared/ScheduleForm.test.jsx index 4f5aac69c4..a1f0573192 100644 --- a/awx/ui_next/src/components/Schedule/shared/ScheduleForm.test.jsx +++ b/awx/ui_next/src/components/Schedule/shared/ScheduleForm.test.jsx @@ -168,6 +168,7 @@ describe('', () => { expect(wrapper.find('ContentError').length).toBe(1); }); }); + describe('Cancel', () => { test('should make the appropriate callback', async () => { const handleCancel = jest.fn(); @@ -226,8 +227,10 @@ describe('', () => { expect(handleCancel).toHaveBeenCalledTimes(1); }); }); + describe('Prompted Schedule', () => { let promptWrapper; + beforeEach(async () => { SchedulesAPI.readZoneInfo.mockResolvedValue({ data: [ @@ -284,8 +287,8 @@ describe('', () => { el => el.length > 0 ); }); + afterEach(() => { - promptWrapper.unmount(); jest.clearAllMocks(); }); @@ -375,6 +378,7 @@ describe('', () => { promptWrapper.update(); expect(promptWrapper.find('Wizard').length).toBe(0); }); + test('should render prompt button with disabled save button', async () => { await act(async () => { wrapper = mountWithContexts( @@ -423,6 +427,7 @@ describe('', () => { ); }); }); + describe('Add', () => { beforeAll(async () => { SchedulesAPI.readZoneInfo.mockResolvedValue({ @@ -473,9 +478,7 @@ describe('', () => { }); await waitForElement(wrapper, 'ContentLoading', el => el.length === 0); }); - afterAll(() => { - wrapper.unmount(); - }); + test('initially renders expected fields and values', () => { const now = new Date(); const closestQuarterHour = new Date( @@ -503,6 +506,7 @@ describe('', () => { 'none' ); }); + test('correct frequency details fields and values shown when frequency changed to minute', async () => { const runFrequencySelect = wrapper.find( 'FormGroup[label="Run frequency"] FormSelect' @@ -526,6 +530,7 @@ describe('', () => { expect(wrapper.find('input#end-after').prop('checked')).toBe(false); expect(wrapper.find('input#end-on-date').prop('checked')).toBe(false); }); + test('correct frequency details fields and values shown when frequency changed to hour', async () => { const runFrequencySelect = wrapper.find( 'FormGroup[label="Run frequency"] FormSelect' @@ -549,6 +554,7 @@ describe('', () => { expect(wrapper.find('input#end-after').prop('checked')).toBe(false); expect(wrapper.find('input#end-on-date').prop('checked')).toBe(false); }); + test('correct frequency details fields and values shown when frequency changed to day', async () => { const runFrequencySelect = wrapper.find( 'FormGroup[label="Run frequency"] FormSelect' @@ -572,6 +578,7 @@ describe('', () => { expect(wrapper.find('input#end-after').prop('checked')).toBe(false); expect(wrapper.find('input#end-on-date').prop('checked')).toBe(false); }); + test('correct frequency details fields and values shown when frequency changed to week', async () => { const runFrequencySelect = wrapper.find( 'FormGroup[label="Run frequency"] FormSelect' @@ -595,6 +602,7 @@ describe('', () => { expect(wrapper.find('input#end-after').prop('checked')).toBe(false); expect(wrapper.find('input#end-on-date').prop('checked')).toBe(false); }); + test('correct frequency details fields and values shown when frequency changed to month', async () => { const runFrequencySelect = wrapper.find( 'FormGroup[label="Run frequency"] FormSelect' @@ -629,6 +637,7 @@ describe('', () => { expect(wrapper.find('select#schedule-run-on-day-month').length).toBe(0); expect(wrapper.find('select#schedule-run-on-the-month').length).toBe(0); }); + test('correct frequency details fields and values shown when frequency changed to year', async () => { const runFrequencySelect = wrapper.find( 'FormGroup[label="Run frequency"] FormSelect' @@ -663,6 +672,7 @@ describe('', () => { expect(wrapper.find('select#schedule-run-on-day-month').length).toBe(1); expect(wrapper.find('select#schedule-run-on-the-month').length).toBe(1); }); + test('occurrences field properly shown when end after selection is made', async () => { await act(async () => { wrapper @@ -690,6 +700,7 @@ describe('', () => { }); wrapper.update(); }); + test('error shown when end date/time comes before start date/time', async () => { await act(async () => { wrapper @@ -728,6 +739,7 @@ describe('', () => { 'Please select an end date/time that comes after the start date/time.' ); }); + test('error shown when on day number is not between 1 and 31', async () => { act(() => { wrapper.find('select[id="schedule-frequency"]').invoke('onChange')( @@ -761,6 +773,7 @@ describe('', () => { ); }); }); + describe('Edit', () => { beforeEach(async () => { SchedulesAPI.readZoneInfo.mockResolvedValue({ @@ -773,12 +786,12 @@ describe('', () => { SchedulesAPI.readCredentials.mockResolvedValue(credentials); }); + afterEach(() => { - wrapper.unmount(); jest.clearAllMocks(); }); - test('should make API calls to fetch credentials, launch configuration, and survey configuration', async () => { + test('should make API calls to fetch credentials, launch configuration, and survey configuration', async () => { await act(async () => { wrapper = mountWithContexts( ', () => { /> ); }); + wrapper.update(); expect(wrapper.find('ScheduleForm').length).toBe(1); defaultFieldsVisible(); expect(wrapper.find('FormGroup[label="Run every"]').length).toBe(0); @@ -920,6 +934,7 @@ describe('', () => { 'none' ); }); + test('initially renders expected fields and values with existing schedule that runs every 10 minutes', async () => { await act(async () => { wrapper = mountWithContexts( @@ -941,6 +956,8 @@ describe('', () => { /> ); }); + wrapper.update(); + expect(wrapper.find('ScheduleForm').length).toBe(1); defaultFieldsVisible(); expect(wrapper.find('FormGroup[label="End"]').length).toBe(1); @@ -959,6 +976,7 @@ describe('', () => { expect(wrapper.find('input#end-after').prop('checked')).toBe(false); expect(wrapper.find('input#end-on-date').prop('checked')).toBe(false); }); + test('initially renders expected fields and values with existing schedule that runs every hour 10 times', async () => { await act(async () => { wrapper = mountWithContexts( @@ -981,6 +999,8 @@ describe('', () => { /> ); }); + wrapper.update(); + expect(wrapper.find('ScheduleForm').length).toBe(1); defaultFieldsVisible(); expect(wrapper.find('FormGroup[label="End"]').length).toBe(1); @@ -1000,6 +1020,7 @@ describe('', () => { expect(wrapper.find('input#end-on-date').prop('checked')).toBe(false); expect(wrapper.find('input#schedule-occurrences').prop('value')).toBe(10); }); + test('initially renders expected fields and values with existing schedule that runs every day', async () => { await act(async () => { wrapper = mountWithContexts( @@ -1021,25 +1042,28 @@ describe('', () => { }} /> ); - expect(wrapper.find('ScheduleForm').length).toBe(1); - defaultFieldsVisible(); - expect(wrapper.find('FormGroup[label="Run every"]').length).toBe(1); - expect(wrapper.find('FormGroup[label="End"]').length).toBe(1); - expect(wrapper.find('FormGroup[label="On days"]').length).toBe(0); - expect(wrapper.find('FormGroup[label="Run on"]').length).toBe(0); - expect(wrapper.find('FormGroup[label="Occurrences"]').length).toBe(0); - expect(wrapper.find('FormGroup[label="End date/time"]').length).toBe(0); - - nonRRuleValuesMatch(); - expect(wrapper.find('select#schedule-frequency').prop('value')).toBe( - 'day' - ); - expect(wrapper.find('input#end-never').prop('checked')).toBe(true); - expect(wrapper.find('input#end-after').prop('checked')).toBe(false); - expect(wrapper.find('input#end-on-date').prop('checked')).toBe(false); - expect(wrapper.find('input#schedule-run-every').prop('value')).toBe(1); }); + wrapper.update(); + + expect(wrapper.find('ScheduleForm').length).toBe(1); + defaultFieldsVisible(); + expect(wrapper.find('FormGroup[label="Run every"]').length).toBe(1); + expect(wrapper.find('FormGroup[label="End"]').length).toBe(1); + expect(wrapper.find('FormGroup[label="On days"]').length).toBe(0); + expect(wrapper.find('FormGroup[label="Run on"]').length).toBe(0); + expect(wrapper.find('FormGroup[label="Occurrences"]').length).toBe(0); + expect(wrapper.find('FormGroup[label="End date/time"]').length).toBe(0); + + nonRRuleValuesMatch(); + expect(wrapper.find('select#schedule-frequency').prop('value')).toBe( + 'day' + ); + expect(wrapper.find('input#end-never').prop('checked')).toBe(true); + expect(wrapper.find('input#end-after').prop('checked')).toBe(false); + expect(wrapper.find('input#end-on-date').prop('checked')).toBe(false); + expect(wrapper.find('input#schedule-run-every').prop('value')).toBe(1); }); + test('initially renders expected fields and values with existing schedule that runs every week on m/w/f until Jan 1, 2020', async () => { await act(async () => { wrapper = mountWithContexts( @@ -1062,6 +1086,8 @@ describe('', () => { /> ); }); + wrapper.update(); + expect(wrapper.find('ScheduleForm').length).toBe(1); defaultFieldsVisible(); expect(wrapper.find('FormGroup[label="End"]').length).toBe(1); @@ -1107,6 +1133,7 @@ describe('', () => { wrapper.find('TimePicker[aria-label="End time"]').prop('value') ).toBe('1:00 AM'); }); + test('initially renders expected fields and values with existing schedule that runs every month on the last weekday', async () => { await act(async () => { wrapper = mountWithContexts( @@ -1128,37 +1155,43 @@ describe('', () => { }} /> ); - expect(wrapper.find('ScheduleForm').length).toBe(1); - defaultFieldsVisible(); - expect(wrapper.find('FormGroup[label="End"]').length).toBe(1); - expect(wrapper.find('FormGroup[label="Run every"]').length).toBe(1); - expect(wrapper.find('FormGroup[label="Run on"]').length).toBe(1); - expect(wrapper.find('FormGroup[label="End date/time"]').length).toBe(0); - expect(wrapper.find('FormGroup[label="On days"]').length).toBe(0); - expect(wrapper.find('FormGroup[label="Occurrences"]').length).toBe(0); - - nonRRuleValuesMatch(); - expect(wrapper.find('select#schedule-frequency').prop('value')).toBe( - 'month' - ); - expect(wrapper.find('input#end-never').prop('checked')).toBe(true); - expect(wrapper.find('input#end-after').prop('checked')).toBe(false); - expect(wrapper.find('input#end-on-date').prop('checked')).toBe(false); - expect(wrapper.find('input#schedule-run-every').prop('value')).toBe(1); - expect(wrapper.find('input#schedule-run-on-day').prop('checked')).toBe( - false - ); - expect(wrapper.find('input#schedule-run-on-the').prop('checked')).toBe( - true - ); - expect( - wrapper.find('select#schedule-run-on-the-occurrence').prop('value') - ).toBe(-1); - expect( - wrapper.find('select#schedule-run-on-the-day').prop('value') - ).toBe('weekday'); }); + wrapper.update(); + + expect(wrapper.find('ScheduleForm').length).toBe(1); + defaultFieldsVisible(); + + expect(wrapper.find('ScheduleForm').length).toBe(1); + defaultFieldsVisible(); + expect(wrapper.find('FormGroup[label="End"]').length).toBe(1); + expect(wrapper.find('FormGroup[label="Run every"]').length).toBe(1); + expect(wrapper.find('FormGroup[label="Run on"]').length).toBe(1); + expect(wrapper.find('FormGroup[label="End date/time"]').length).toBe(0); + expect(wrapper.find('FormGroup[label="On days"]').length).toBe(0); + expect(wrapper.find('FormGroup[label="Occurrences"]').length).toBe(0); + + nonRRuleValuesMatch(); + expect(wrapper.find('select#schedule-frequency').prop('value')).toBe( + 'month' + ); + expect(wrapper.find('input#end-never').prop('checked')).toBe(true); + expect(wrapper.find('input#end-after').prop('checked')).toBe(false); + expect(wrapper.find('input#end-on-date').prop('checked')).toBe(false); + expect(wrapper.find('input#schedule-run-every').prop('value')).toBe(1); + expect(wrapper.find('input#schedule-run-on-day').prop('checked')).toBe( + false + ); + expect(wrapper.find('input#schedule-run-on-the').prop('checked')).toBe( + true + ); + expect( + wrapper.find('select#schedule-run-on-the-occurrence').prop('value') + ).toBe(-1); + expect(wrapper.find('select#schedule-run-on-the-day').prop('value')).toBe( + 'weekday' + ); }); + test('initially renders expected fields and values with existing schedule that runs every year on the May 6', async () => { await act(async () => { wrapper = mountWithContexts( @@ -1180,36 +1213,38 @@ describe('', () => { }} /> ); - expect(wrapper.find('ScheduleForm').length).toBe(1); - defaultFieldsVisible(); - expect(wrapper.find('FormGroup[label="End"]').length).toBe(1); - expect(wrapper.find('FormGroup[label="Run every"]').length).toBe(1); - expect(wrapper.find('FormGroup[label="Run on"]').length).toBe(1); - expect(wrapper.find('FormGroup[label="End date/time"]').length).toBe(0); - expect(wrapper.find('FormGroup[label="On days"]').length).toBe(0); - expect(wrapper.find('FormGroup[label="Occurrences"]').length).toBe(0); - - nonRRuleValuesMatch(); - expect(wrapper.find('select#schedule-frequency').prop('value')).toBe( - 'year' - ); - expect(wrapper.find('input#end-never').prop('checked')).toBe(true); - expect(wrapper.find('input#end-after').prop('checked')).toBe(false); - expect(wrapper.find('input#end-on-date').prop('checked')).toBe(false); - expect(wrapper.find('input#schedule-run-every').prop('value')).toBe(1); - expect(wrapper.find('input#schedule-run-on-day').prop('checked')).toBe( - true - ); - expect(wrapper.find('input#schedule-run-on-the').prop('checked')).toBe( - false - ); - expect( - wrapper.find('select#schedule-run-on-day-month').prop('value') - ).toBe(5); - expect( - wrapper.find('input#schedule-run-on-day-number').prop('value') - ).toBe(6); }); + wrapper.update(); + + expect(wrapper.find('ScheduleForm').length).toBe(1); + defaultFieldsVisible(); + expect(wrapper.find('FormGroup[label="End"]').length).toBe(1); + expect(wrapper.find('FormGroup[label="Run every"]').length).toBe(1); + expect(wrapper.find('FormGroup[label="Run on"]').length).toBe(1); + expect(wrapper.find('FormGroup[label="End date/time"]').length).toBe(0); + expect(wrapper.find('FormGroup[label="On days"]').length).toBe(0); + expect(wrapper.find('FormGroup[label="Occurrences"]').length).toBe(0); + + nonRRuleValuesMatch(); + expect(wrapper.find('select#schedule-frequency').prop('value')).toBe( + 'year' + ); + expect(wrapper.find('input#end-never').prop('checked')).toBe(true); + expect(wrapper.find('input#end-after').prop('checked')).toBe(false); + expect(wrapper.find('input#end-on-date').prop('checked')).toBe(false); + expect(wrapper.find('input#schedule-run-every').prop('value')).toBe(1); + expect(wrapper.find('input#schedule-run-on-day').prop('checked')).toBe( + true + ); + expect(wrapper.find('input#schedule-run-on-the').prop('checked')).toBe( + false + ); + expect( + wrapper.find('select#schedule-run-on-day-month').prop('value') + ).toBe(5); + expect( + wrapper.find('input#schedule-run-on-day-number').prop('value') + ).toBe(6); }); }); }); diff --git a/awx/ui_next/src/screens/Organization/OrganizationDetail/OrganizationDetail.jsx b/awx/ui_next/src/screens/Organization/OrganizationDetail/OrganizationDetail.jsx index 83c2e9dc37..fe6667c56e 100644 --- a/awx/ui_next/src/screens/Organization/OrganizationDetail/OrganizationDetail.jsx +++ b/awx/ui_next/src/screens/Organization/OrganizationDetail/OrganizationDetail.jsx @@ -124,7 +124,7 @@ function OrganizationDetail({ organization }) { value={ {instanceGroups.map(ig => ( - + {ig.name} diff --git a/awx/ui_next/src/screens/Organization/OrganizationEdit/OrganizationEdit.test.jsx b/awx/ui_next/src/screens/Organization/OrganizationEdit/OrganizationEdit.test.jsx index a1fbdb0831..72c61b9f3b 100644 --- a/awx/ui_next/src/screens/Organization/OrganizationEdit/OrganizationEdit.test.jsx +++ b/awx/ui_next/src/screens/Organization/OrganizationEdit/OrganizationEdit.test.jsx @@ -39,7 +39,9 @@ describe('', () => { description: 'new description', default_environment: null, }; - wrapper.find('OrganizationForm').prop('onSubmit')(updatedOrgData, [], []); + await act(async () => { + wrapper.find('OrganizationForm').prop('onSubmit')(updatedOrgData, [], []); + }); expect(OrganizationsAPI.update).toHaveBeenCalledWith(1, updatedOrgData); });