mirror of
https://github.com/ansible/awx.git
synced 2026-02-23 14:05:59 -03:30
Fixes console errors thrown about React state updates being be wrapped into act(...) on the inventory form
This commit is contained in:
@@ -51,11 +51,13 @@ describe('<InventoryAdd />', () => {
|
|||||||
];
|
];
|
||||||
await waitForElement(wrapper, 'isLoading', el => el.length === 0);
|
await waitForElement(wrapper, 'isLoading', el => el.length === 0);
|
||||||
|
|
||||||
wrapper.find('InventoryForm').prop('onSubmit')({
|
await act(async () => {
|
||||||
name: 'new Foo',
|
wrapper.find('InventoryForm').prop('onSubmit')({
|
||||||
organization: { id: 2 },
|
name: 'new Foo',
|
||||||
insights_credential: { id: 47 },
|
organization: { id: 2 },
|
||||||
instanceGroups,
|
insights_credential: { id: 47 },
|
||||||
|
instanceGroups,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
await sleep(1);
|
await sleep(1);
|
||||||
expect(InventoriesAPI.create).toHaveBeenCalledWith({
|
expect(InventoriesAPI.create).toHaveBeenCalledWith({
|
||||||
@@ -74,7 +76,9 @@ describe('<InventoryAdd />', () => {
|
|||||||
|
|
||||||
test('handleCancel should return the user back to the inventories list', async () => {
|
test('handleCancel should return the user back to the inventories list', async () => {
|
||||||
await waitForElement(wrapper, 'isLoading', el => el.length === 0);
|
await waitForElement(wrapper, 'isLoading', el => el.length === 0);
|
||||||
wrapper.find('Button[aria-label="Cancel"]').simulate('click');
|
await act(async () => {
|
||||||
|
wrapper.find('Button[aria-label="Cancel"]').simulate('click');
|
||||||
|
});
|
||||||
expect(history.location.pathname).toEqual('/inventories');
|
expect(history.location.pathname).toEqual('/inventories');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -102,7 +102,9 @@ describe('<InventoryEdit />', () => {
|
|||||||
|
|
||||||
test('handleCancel returns the user to inventory detail', async () => {
|
test('handleCancel returns the user to inventory detail', async () => {
|
||||||
await waitForElement(wrapper, 'isLoading', el => el.length === 0);
|
await waitForElement(wrapper, 'isLoading', el => el.length === 0);
|
||||||
wrapper.find('Button[aria-label="Cancel"]').simulate('click');
|
await act(async () => {
|
||||||
|
wrapper.find('Button[aria-label="Cancel"]').simulate('click');
|
||||||
|
});
|
||||||
expect(history.location.pathname).toEqual(
|
expect(history.location.pathname).toEqual(
|
||||||
'/inventories/inventory/1/details'
|
'/inventories/inventory/1/details'
|
||||||
);
|
);
|
||||||
@@ -114,12 +116,14 @@ describe('<InventoryEdit />', () => {
|
|||||||
{ name: 'Bizz', id: 2 },
|
{ name: 'Bizz', id: 2 },
|
||||||
{ name: 'Buzz', id: 3 },
|
{ name: 'Buzz', id: 3 },
|
||||||
];
|
];
|
||||||
wrapper.find('InventoryForm').prop('onSubmit')({
|
await act(async () => {
|
||||||
name: 'Foo',
|
wrapper.find('InventoryForm').prop('onSubmit')({
|
||||||
id: 13,
|
name: 'Foo',
|
||||||
organization: { id: 1 },
|
id: 13,
|
||||||
insights_credential: { id: 13 },
|
organization: { id: 1 },
|
||||||
instanceGroups,
|
insights_credential: { id: 13 },
|
||||||
|
instanceGroups,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
await sleep(0);
|
await sleep(0);
|
||||||
instanceGroups.map(IG =>
|
instanceGroups.map(IG =>
|
||||||
|
|||||||
Reference in New Issue
Block a user