diff --git a/awx/ui_next/src/screens/Template/shared/SurveyList.jsx b/awx/ui_next/src/screens/Template/shared/SurveyList.jsx index 3758dbdba9..f205c2b0cd 100644 --- a/awx/ui_next/src/screens/Template/shared/SurveyList.jsx +++ b/awx/ui_next/src/screens/Template/shared/SurveyList.jsx @@ -36,7 +36,7 @@ function SurveyList({ template, i18n }) { data: { spec = [], description: surveyDescription, name: surveyName }, } = await JobTemplatesAPI.readSurvey(template.id); return { - questions: spec.map((s, index) => ({ ...s, id: index })), + questions: spec?.map((s, index) => ({ ...s, id: index })), description: surveyDescription, name: surveyName, }; diff --git a/awx/ui_next/src/screens/Template/shared/SurveyList.test.jsx b/awx/ui_next/src/screens/Template/shared/SurveyList.test.jsx index c044eb9da4..bfd74023b3 100644 --- a/awx/ui_next/src/screens/Template/shared/SurveyList.test.jsx +++ b/awx/ui_next/src/screens/Template/shared/SurveyList.test.jsx @@ -36,6 +36,7 @@ describe('', () => { expect(JobTemplatesAPI.readSurvey).toBeCalledWith(7); wrapper.update(); + expect(wrapper.find('SurveyListItem').length).toBe(1); }); test('error in retrieving the survey throws an error', async () => { @@ -55,7 +56,11 @@ describe('', () => { JobTemplatesAPI.update.mockResolvedValue(); let wrapper; await act(async () => { +<<<<<<< HEAD wrapper = mountWithContexts( +======= + wrapper = await mountWithContexts( +>>>>>>> Adds SurveyList tool bar @@ -65,7 +70,11 @@ describe('', () => { expect(wrapper.find('Switch').length).toBe(1); expect(wrapper.find('Switch').prop('isChecked')).toBe(false); await act(async () => { +<<<<<<< HEAD wrapper.find('Switch').invoke('onChange')(true); +======= + await wrapper.find('Switch').invoke('onChange')(true); +>>>>>>> Adds SurveyList tool bar }); wrapper.update(); @@ -79,7 +88,11 @@ describe('', () => { test('selectAll enables delete button and calls the api to delete properly', async () => { let wrapper; await act(async () => { +<<<<<<< HEAD wrapper = mountWithContexts( +======= + wrapper = await mountWithContexts( +>>>>>>> Adds SurveyList tool bar @@ -126,7 +139,11 @@ describe('Survey with no questions', () => { JobTemplatesAPI.readSurvey.mockResolvedValue({}); let wrapper; await act(async () => { +<<<<<<< HEAD wrapper = mountWithContexts( +======= + wrapper = await mountWithContexts( +>>>>>>> Adds SurveyList tool bar ); }); diff --git a/awx/ui_next/src/util/useRequest.js b/awx/ui_next/src/util/useRequest.js index 64a62ebf45..ad8ed747ba 100644 --- a/awx/ui_next/src/util/useRequest.js +++ b/awx/ui_next/src/util/useRequest.js @@ -75,7 +75,9 @@ export function useDeleteItems( if (params.page > 1 && allItemsSelected) { const newParams = encodeNonDefaultQueryString( qsConfig, - replaceParams(params, { page: params.page - 1 }) + replaceParams(params, { + page: params.page - 1, + }) ); history.push(`${location.pathname}?${newParams}`); } else {