mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
update JT form tests
This commit is contained in:
parent
554a63d8fc
commit
ba4e79fd3a
@ -693,7 +693,7 @@ exports[`<OrganizationAccessItem /> initially renders succesfully 1`] = `
|
||||
isReadOnly={false}
|
||||
onClick={[Function]}
|
||||
>
|
||||
<Chip
|
||||
<PFChip
|
||||
className="Chip-sc-1rzr8oo-0 dgUGLg"
|
||||
closeBtnAriaLabel="close"
|
||||
component="li"
|
||||
@ -771,7 +771,7 @@ exports[`<OrganizationAccessItem /> initially renders succesfully 1`] = `
|
||||
</ChipButton>
|
||||
</li>
|
||||
</GenerateId>
|
||||
</Chip>
|
||||
</PFChip>
|
||||
</StyledComponent>
|
||||
</Chip>
|
||||
</ul>
|
||||
|
||||
@ -385,10 +385,6 @@ exports[`<OrganizationNotifications /> initially renders succesfully 1`] = `
|
||||
onSort={[Function]}
|
||||
qsConfig={
|
||||
Object {
|
||||
"dateFields": Array [
|
||||
"modified",
|
||||
"created",
|
||||
],
|
||||
"defaultParams": Object {
|
||||
"order_by": "name",
|
||||
"page": 1,
|
||||
@ -443,10 +439,6 @@ exports[`<OrganizationNotifications /> initially renders succesfully 1`] = `
|
||||
onSort={[Function]}
|
||||
qsConfig={
|
||||
Object {
|
||||
"dateFields": Array [
|
||||
"modified",
|
||||
"created",
|
||||
],
|
||||
"defaultParams": Object {
|
||||
"order_by": "name",
|
||||
"page": 1,
|
||||
@ -626,24 +618,6 @@ exports[`<OrganizationNotifications /> initially renders succesfully 1`] = `
|
||||
]
|
||||
}
|
||||
onSearch={[Function]}
|
||||
qsConfig={
|
||||
Object {
|
||||
"dateFields": Array [
|
||||
"modified",
|
||||
"created",
|
||||
],
|
||||
"defaultParams": Object {
|
||||
"order_by": "name",
|
||||
"page": 1,
|
||||
"page_size": 5,
|
||||
},
|
||||
"integerFields": Array [
|
||||
"page",
|
||||
"page_size",
|
||||
],
|
||||
"namespace": "notification",
|
||||
}
|
||||
}
|
||||
sortedColumnKey="name"
|
||||
>
|
||||
<I18n
|
||||
@ -675,24 +649,6 @@ exports[`<OrganizationNotifications /> initially renders succesfully 1`] = `
|
||||
}
|
||||
i18n={"/i18n/"}
|
||||
onSearch={[Function]}
|
||||
qsConfig={
|
||||
Object {
|
||||
"dateFields": Array [
|
||||
"modified",
|
||||
"created",
|
||||
],
|
||||
"defaultParams": Object {
|
||||
"order_by": "name",
|
||||
"page": 1,
|
||||
"page_size": 5,
|
||||
},
|
||||
"integerFields": Array [
|
||||
"page",
|
||||
"page_size",
|
||||
],
|
||||
"namespace": "notification",
|
||||
}
|
||||
}
|
||||
sortedColumnKey="name"
|
||||
>
|
||||
<Form
|
||||
|
||||
@ -27,6 +27,8 @@ const jobTemplateData = {
|
||||
host_config_key: '',
|
||||
};
|
||||
|
||||
// TODO: Needs React/React-router upgrade to remove `act()` warnings
|
||||
// See https://github.com/ansible/awx/issues/4817
|
||||
describe('<JobTemplateAdd />', () => {
|
||||
const defaultProps = {
|
||||
description: '',
|
||||
@ -94,7 +96,10 @@ describe('<JobTemplateAdd />', () => {
|
||||
const changeState = new Promise(resolve => {
|
||||
formik.setState(
|
||||
{
|
||||
values: jobTemplateData,
|
||||
values: {
|
||||
...jobTemplateData,
|
||||
labels: [],
|
||||
}
|
||||
},
|
||||
() => resolve()
|
||||
);
|
||||
|
||||
@ -34,6 +34,9 @@ const mockJobTemplate = {
|
||||
labels: {
|
||||
results: [{ name: 'Sushi', id: 1 }, { name: 'Major', id: 2 }],
|
||||
},
|
||||
inventory: {
|
||||
organization_id: 1,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@ -170,16 +173,12 @@ describe('<JobTemplateEdit />', () => {
|
||||
description: 'new description',
|
||||
job_type: 'check',
|
||||
};
|
||||
const newLabels = [
|
||||
{ associate: true, id: 3 },
|
||||
{ associate: true, id: 3 },
|
||||
{ name: 'Maple', organization: 1 },
|
||||
{ name: 'Tree', organization: 1 },
|
||||
];
|
||||
const removedLabels = [
|
||||
{ disassociate: true, id: 1 },
|
||||
{ disassociate: true, id: 2 },
|
||||
];
|
||||
const labels = [
|
||||
{ id: 3, name: 'Foo', isNew: true },
|
||||
{ id: 4, name: 'Bar', isNew: true },
|
||||
{ id: 5, name: 'Maple' },
|
||||
{ id: 6, name: 'Tree' },
|
||||
]
|
||||
JobTemplatesAPI.update.mockResolvedValue({
|
||||
data: { ...updatedTemplateData },
|
||||
});
|
||||
@ -190,8 +189,7 @@ describe('<JobTemplateEdit />', () => {
|
||||
values: {
|
||||
...mockJobTemplate,
|
||||
...updatedTemplateData,
|
||||
newLabels,
|
||||
removedLabels,
|
||||
labels,
|
||||
},
|
||||
},
|
||||
() => resolve()
|
||||
|
||||
@ -588,7 +588,7 @@ const FormikApp = withFormik({
|
||||
inventory: template.inventory || '',
|
||||
project: template.project || '',
|
||||
playbook: template.playbook || '',
|
||||
labels: summary_fields.labels.results,
|
||||
labels: summary_fields.labels.results || [],
|
||||
forks: template.forks || 0,
|
||||
limit: template.limit || '',
|
||||
verbosity: template.verbosity || '0',
|
||||
|
||||
@ -70,7 +70,7 @@ describe('<JobTemplateForm />', () => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
test('should render labels MultiSelect', async () => {
|
||||
test('should render LabelsSelect', async () => {
|
||||
const wrapper = mountWithContexts(
|
||||
<JobTemplateForm
|
||||
template={mockData}
|
||||
@ -82,11 +82,11 @@ describe('<JobTemplateForm />', () => {
|
||||
expect(LabelsAPI.read).toHaveBeenCalled();
|
||||
expect(JobTemplatesAPI.readInstanceGroups).toHaveBeenCalled();
|
||||
wrapper.update();
|
||||
expect(
|
||||
wrapper
|
||||
.find('FormGroup[fieldId="template-labels"] MultiSelect')
|
||||
.prop('associatedItems')
|
||||
).toEqual(mockData.summary_fields.labels.results);
|
||||
const select = wrapper.find('LabelSelect');
|
||||
expect(select).toHaveLength(1);
|
||||
expect(select.prop('value')).toEqual(
|
||||
mockData.summary_fields.labels.results
|
||||
);
|
||||
});
|
||||
|
||||
test('should update form values on input changes', async () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user