mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
Adds SurveyList tool bar
This commit is contained in:
@@ -36,7 +36,7 @@ function SurveyList({ template, i18n }) {
|
|||||||
data: { spec = [], description: surveyDescription, name: surveyName },
|
data: { spec = [], description: surveyDescription, name: surveyName },
|
||||||
} = await JobTemplatesAPI.readSurvey(template.id);
|
} = await JobTemplatesAPI.readSurvey(template.id);
|
||||||
return {
|
return {
|
||||||
questions: spec.map((s, index) => ({ ...s, id: index })),
|
questions: spec?.map((s, index) => ({ ...s, id: index })),
|
||||||
description: surveyDescription,
|
description: surveyDescription,
|
||||||
name: surveyName,
|
name: surveyName,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ describe('<SurveyList />', () => {
|
|||||||
expect(JobTemplatesAPI.readSurvey).toBeCalledWith(7);
|
expect(JobTemplatesAPI.readSurvey).toBeCalledWith(7);
|
||||||
|
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
|
|
||||||
expect(wrapper.find('SurveyListItem').length).toBe(1);
|
expect(wrapper.find('SurveyListItem').length).toBe(1);
|
||||||
});
|
});
|
||||||
test('error in retrieving the survey throws an error', async () => {
|
test('error in retrieving the survey throws an error', async () => {
|
||||||
@@ -55,7 +56,11 @@ describe('<SurveyList />', () => {
|
|||||||
JobTemplatesAPI.update.mockResolvedValue();
|
JobTemplatesAPI.update.mockResolvedValue();
|
||||||
let wrapper;
|
let wrapper;
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
|
<<<<<<< HEAD
|
||||||
wrapper = mountWithContexts(
|
wrapper = mountWithContexts(
|
||||||
|
=======
|
||||||
|
wrapper = await mountWithContexts(
|
||||||
|
>>>>>>> Adds SurveyList tool bar
|
||||||
<SurveyList
|
<SurveyList
|
||||||
template={{ ...mockJobTemplateData, survey_enabled: false }}
|
template={{ ...mockJobTemplateData, survey_enabled: false }}
|
||||||
/>
|
/>
|
||||||
@@ -65,7 +70,11 @@ describe('<SurveyList />', () => {
|
|||||||
expect(wrapper.find('Switch').length).toBe(1);
|
expect(wrapper.find('Switch').length).toBe(1);
|
||||||
expect(wrapper.find('Switch').prop('isChecked')).toBe(false);
|
expect(wrapper.find('Switch').prop('isChecked')).toBe(false);
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
|
<<<<<<< HEAD
|
||||||
wrapper.find('Switch').invoke('onChange')(true);
|
wrapper.find('Switch').invoke('onChange')(true);
|
||||||
|
=======
|
||||||
|
await wrapper.find('Switch').invoke('onChange')(true);
|
||||||
|
>>>>>>> Adds SurveyList tool bar
|
||||||
});
|
});
|
||||||
|
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
@@ -79,7 +88,11 @@ describe('<SurveyList />', () => {
|
|||||||
test('selectAll enables delete button and calls the api to delete properly', async () => {
|
test('selectAll enables delete button and calls the api to delete properly', async () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
|
<<<<<<< HEAD
|
||||||
wrapper = mountWithContexts(
|
wrapper = mountWithContexts(
|
||||||
|
=======
|
||||||
|
wrapper = await mountWithContexts(
|
||||||
|
>>>>>>> Adds SurveyList tool bar
|
||||||
<SurveyList
|
<SurveyList
|
||||||
template={{ ...mockJobTemplateData, survey_enabled: false }}
|
template={{ ...mockJobTemplateData, survey_enabled: false }}
|
||||||
/>
|
/>
|
||||||
@@ -126,7 +139,11 @@ describe('Survey with no questions', () => {
|
|||||||
JobTemplatesAPI.readSurvey.mockResolvedValue({});
|
JobTemplatesAPI.readSurvey.mockResolvedValue({});
|
||||||
let wrapper;
|
let wrapper;
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
|
<<<<<<< HEAD
|
||||||
wrapper = mountWithContexts(
|
wrapper = mountWithContexts(
|
||||||
|
=======
|
||||||
|
wrapper = await mountWithContexts(
|
||||||
|
>>>>>>> Adds SurveyList tool bar
|
||||||
<SurveyList template={mockJobTemplateData} />
|
<SurveyList template={mockJobTemplateData} />
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -75,7 +75,9 @@ export function useDeleteItems(
|
|||||||
if (params.page > 1 && allItemsSelected) {
|
if (params.page > 1 && allItemsSelected) {
|
||||||
const newParams = encodeNonDefaultQueryString(
|
const newParams = encodeNonDefaultQueryString(
|
||||||
qsConfig,
|
qsConfig,
|
||||||
replaceParams(params, { page: params.page - 1 })
|
replaceParams(params, {
|
||||||
|
page: params.page - 1,
|
||||||
|
})
|
||||||
);
|
);
|
||||||
history.push(`${location.pathname}?${newParams}`);
|
history.push(`${location.pathname}?${newParams}`);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user