mirror of
https://github.com/ansible/awx.git
synced 2026-03-25 04:45:03 -02:30
Remove sleep from tests
This commit is contained in:
committed by
jakemcdermott
parent
1b0fca8026
commit
03277513a9
@@ -6,7 +6,6 @@ import {
|
|||||||
shallowWithContexts,
|
shallowWithContexts,
|
||||||
waitForElement,
|
waitForElement,
|
||||||
} from '../../../testUtils/enzymeHelpers';
|
} from '../../../testUtils/enzymeHelpers';
|
||||||
import { sleep } from '../../../testUtils/testUtils';
|
|
||||||
import SelectResourceStep from './SelectResourceStep';
|
import SelectResourceStep from './SelectResourceStep';
|
||||||
|
|
||||||
describe('<SelectResourceStep />', () => {
|
describe('<SelectResourceStep />', () => {
|
||||||
@@ -114,7 +113,6 @@ describe('<SelectResourceStep />', () => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
await sleep(0);
|
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
const checkboxListItemWrapper = wrapper.find('CheckboxListItem');
|
const checkboxListItemWrapper = wrapper.find('CheckboxListItem');
|
||||||
expect(checkboxListItemWrapper.length).toBe(2);
|
expect(checkboxListItemWrapper.length).toBe(2);
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
WorkflowJobTemplatesAPI,
|
WorkflowJobTemplatesAPI,
|
||||||
} from 'api';
|
} from 'api';
|
||||||
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
||||||
import { sleep } from '../../../testUtils/testUtils';
|
|
||||||
|
|
||||||
import LaunchButton from './LaunchButton';
|
import LaunchButton from './LaunchButton';
|
||||||
|
|
||||||
@@ -74,7 +73,6 @@ describe('LaunchButton', () => {
|
|||||||
const button = wrapper.find('button');
|
const button = wrapper.find('button');
|
||||||
await act(() => button.prop('onClick')());
|
await act(() => button.prop('onClick')());
|
||||||
expect(JobTemplatesAPI.readLaunch).toHaveBeenCalledWith(1);
|
expect(JobTemplatesAPI.readLaunch).toHaveBeenCalledWith(1);
|
||||||
await sleep(0);
|
|
||||||
expect(JobTemplatesAPI.launch).toHaveBeenCalledWith(1, {});
|
expect(JobTemplatesAPI.launch).toHaveBeenCalledWith(1, {});
|
||||||
expect(history.location.pathname).toEqual('/jobs/9000/output');
|
expect(history.location.pathname).toEqual('/jobs/9000/output');
|
||||||
});
|
});
|
||||||
@@ -111,7 +109,6 @@ describe('LaunchButton', () => {
|
|||||||
const button = wrapper.find('button');
|
const button = wrapper.find('button');
|
||||||
await act(() => button.prop('onClick')());
|
await act(() => button.prop('onClick')());
|
||||||
expect(WorkflowJobTemplatesAPI.readLaunch).toHaveBeenCalledWith(1);
|
expect(WorkflowJobTemplatesAPI.readLaunch).toHaveBeenCalledWith(1);
|
||||||
await sleep(0);
|
|
||||||
expect(WorkflowJobTemplatesAPI.launch).toHaveBeenCalledWith(1, {});
|
expect(WorkflowJobTemplatesAPI.launch).toHaveBeenCalledWith(1, {});
|
||||||
expect(history.location.pathname).toEqual('/jobs/9000/output');
|
expect(history.location.pathname).toEqual('/jobs/9000/output');
|
||||||
});
|
});
|
||||||
@@ -128,7 +125,7 @@ describe('LaunchButton', () => {
|
|||||||
WorkflowJobTemplatesAPI.launch.mockImplementation(async () => {
|
WorkflowJobTemplatesAPI.launch.mockImplementation(async () => {
|
||||||
// return asynchronously so isLaunching isn't set back to false in the
|
// return asynchronously so isLaunching isn't set back to false in the
|
||||||
// same tick
|
// same tick
|
||||||
await sleep(10);
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
id: 9000,
|
id: 9000,
|
||||||
@@ -190,7 +187,6 @@ describe('LaunchButton', () => {
|
|||||||
const button = wrapper.find('button');
|
const button = wrapper.find('button');
|
||||||
await act(() => button.prop('onClick')());
|
await act(() => button.prop('onClick')());
|
||||||
expect(JobsAPI.readRelaunch).toHaveBeenCalledWith(1);
|
expect(JobsAPI.readRelaunch).toHaveBeenCalledWith(1);
|
||||||
await sleep(0);
|
|
||||||
expect(JobsAPI.relaunch).toHaveBeenCalledWith(1, {});
|
expect(JobsAPI.relaunch).toHaveBeenCalledWith(1, {});
|
||||||
expect(history.location.pathname).toEqual('/jobs/9000/output');
|
expect(history.location.pathname).toEqual('/jobs/9000/output');
|
||||||
});
|
});
|
||||||
@@ -227,7 +223,6 @@ describe('LaunchButton', () => {
|
|||||||
const button = wrapper.find('button');
|
const button = wrapper.find('button');
|
||||||
await act(() => button.prop('onClick')());
|
await act(() => button.prop('onClick')());
|
||||||
expect(WorkflowJobsAPI.readRelaunch).toHaveBeenCalledWith(1);
|
expect(WorkflowJobsAPI.readRelaunch).toHaveBeenCalledWith(1);
|
||||||
await sleep(0);
|
|
||||||
expect(WorkflowJobsAPI.relaunch).toHaveBeenCalledWith(1);
|
expect(WorkflowJobsAPI.relaunch).toHaveBeenCalledWith(1);
|
||||||
expect(history.location.pathname).toEqual('/jobs/9000/output');
|
expect(history.location.pathname).toEqual('/jobs/9000/output');
|
||||||
});
|
});
|
||||||
@@ -265,7 +260,6 @@ describe('LaunchButton', () => {
|
|||||||
const button = wrapper.find('button');
|
const button = wrapper.find('button');
|
||||||
await act(() => button.prop('onClick')());
|
await act(() => button.prop('onClick')());
|
||||||
expect(ProjectsAPI.readLaunchUpdate).toHaveBeenCalledWith(5);
|
expect(ProjectsAPI.readLaunchUpdate).toHaveBeenCalledWith(5);
|
||||||
await sleep(0);
|
|
||||||
expect(ProjectsAPI.launchUpdate).toHaveBeenCalledWith(5);
|
expect(ProjectsAPI.launchUpdate).toHaveBeenCalledWith(5);
|
||||||
expect(history.location.pathname).toEqual('/jobs/9000/output');
|
expect(history.location.pathname).toEqual('/jobs/9000/output');
|
||||||
});
|
});
|
||||||
@@ -303,7 +297,6 @@ describe('LaunchButton', () => {
|
|||||||
const button = wrapper.find('button');
|
const button = wrapper.find('button');
|
||||||
await act(() => button.prop('onClick')());
|
await act(() => button.prop('onClick')());
|
||||||
expect(InventorySourcesAPI.readLaunchUpdate).toHaveBeenCalledWith(5);
|
expect(InventorySourcesAPI.readLaunchUpdate).toHaveBeenCalledWith(5);
|
||||||
await sleep(0);
|
|
||||||
expect(InventorySourcesAPI.launchUpdate).toHaveBeenCalledWith(5);
|
expect(InventorySourcesAPI.launchUpdate).toHaveBeenCalledWith(5);
|
||||||
expect(history.location.pathname).toEqual('/jobs/9000/output');
|
expect(history.location.pathname).toEqual('/jobs/9000/output');
|
||||||
});
|
});
|
||||||
@@ -326,11 +319,9 @@ describe('LaunchButton', () => {
|
|||||||
);
|
);
|
||||||
expect(wrapper.find('Modal').length).toBe(0);
|
expect(wrapper.find('Modal').length).toBe(0);
|
||||||
await act(() => wrapper.find('button').prop('onClick')());
|
await act(() => wrapper.find('button').prop('onClick')());
|
||||||
await sleep(0);
|
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
expect(wrapper.find('Modal').length).toBe(1);
|
expect(wrapper.find('Modal').length).toBe(1);
|
||||||
wrapper.find('ModalBoxCloseButton').simulate('click');
|
wrapper.find('ModalBoxCloseButton').simulate('click');
|
||||||
await sleep(0);
|
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
expect(wrapper.find('Modal').length).toBe(0);
|
expect(wrapper.find('Modal').length).toBe(0);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
mountWithContexts,
|
mountWithContexts,
|
||||||
waitForElement,
|
waitForElement,
|
||||||
} from '../../../../testUtils/enzymeHelpers';
|
} from '../../../../testUtils/enzymeHelpers';
|
||||||
import { sleep } from '../../../../testUtils/testUtils';
|
|
||||||
|
|
||||||
import InventoryAdd from './InventoryAdd';
|
import InventoryAdd from './InventoryAdd';
|
||||||
|
|
||||||
@@ -43,7 +42,6 @@ describe('<InventoryAdd />', () => {
|
|||||||
instanceGroups,
|
instanceGroups,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
await sleep(1);
|
|
||||||
expect(InventoriesAPI.create).toHaveBeenCalledWith({
|
expect(InventoriesAPI.create).toHaveBeenCalledWith({
|
||||||
name: 'new Foo',
|
name: 'new Foo',
|
||||||
organization: 2,
|
organization: 2,
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
mountWithContexts,
|
mountWithContexts,
|
||||||
waitForElement,
|
waitForElement,
|
||||||
} from '../../../../testUtils/enzymeHelpers';
|
} from '../../../../testUtils/enzymeHelpers';
|
||||||
import { sleep } from '../../../../testUtils/testUtils';
|
|
||||||
|
|
||||||
import InventoryEdit from './InventoryEdit';
|
import InventoryEdit from './InventoryEdit';
|
||||||
|
|
||||||
@@ -105,7 +104,6 @@ describe('<InventoryEdit />', () => {
|
|||||||
instanceGroups,
|
instanceGroups,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
await sleep(0);
|
|
||||||
expect(InventoriesAPI.orderInstanceGroups).toHaveBeenCalledWith(
|
expect(InventoriesAPI.orderInstanceGroups).toHaveBeenCalledWith(
|
||||||
mockInventory.id,
|
mockInventory.id,
|
||||||
instanceGroups,
|
instanceGroups,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { act } from 'react-dom/test-utils';
|
|||||||
import { createMemoryHistory } from 'history';
|
import { createMemoryHistory } from 'history';
|
||||||
import { JobsAPI, ProjectUpdatesAPI } from 'api';
|
import { JobsAPI, ProjectUpdatesAPI } from 'api';
|
||||||
import { mountWithContexts } from '../../../../testUtils/enzymeHelpers';
|
import { mountWithContexts } from '../../../../testUtils/enzymeHelpers';
|
||||||
import { sleep } from '../../../../testUtils/testUtils';
|
|
||||||
import JobDetail from './JobDetail';
|
import JobDetail from './JobDetail';
|
||||||
import mockJobData from '../shared/data.job.json';
|
import mockJobData from '../shared/data.job.json';
|
||||||
|
|
||||||
@@ -249,7 +248,6 @@ describe('<JobDetail />', () => {
|
|||||||
test('should properly delete job', async () => {
|
test('should properly delete job', async () => {
|
||||||
wrapper = mountWithContexts(<JobDetail job={mockJobData} />);
|
wrapper = mountWithContexts(<JobDetail job={mockJobData} />);
|
||||||
wrapper.find('button[aria-label="Delete"]').simulate('click');
|
wrapper.find('button[aria-label="Delete"]').simulate('click');
|
||||||
await sleep(1);
|
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
const modal = wrapper.find('Modal[aria-label="Alert modal"]');
|
const modal = wrapper.find('Modal[aria-label="Alert modal"]');
|
||||||
expect(modal.length).toBe(1);
|
expect(modal.length).toBe(1);
|
||||||
@@ -296,7 +294,6 @@ describe('<JobDetail />', () => {
|
|||||||
const detail = wrapper.find('JobDetail');
|
const detail = wrapper.find('JobDetail');
|
||||||
async function assertMissingDetail(label) {
|
async function assertMissingDetail(label) {
|
||||||
expect(detail.length).toBe(1);
|
expect(detail.length).toBe(1);
|
||||||
await sleep(0);
|
|
||||||
expect(detail.find(`Detail[label="${label}"] dt`).text()).toBe(label);
|
expect(detail.find(`Detail[label="${label}"] dt`).text()).toBe(label);
|
||||||
expect(detail.find(`Detail[label="${label}"] dd`).text()).toBe('DELETED');
|
expect(detail.find(`Detail[label="${label}"] dd`).text()).toBe('DELETED');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
mountWithContexts,
|
mountWithContexts,
|
||||||
waitForElement,
|
waitForElement,
|
||||||
} from '../../../../testUtils/enzymeHelpers';
|
} from '../../../../testUtils/enzymeHelpers';
|
||||||
import { sleep } from '../../../../testUtils/testUtils';
|
|
||||||
|
|
||||||
import OrganizationTeamList from './OrganizationTeamList';
|
import OrganizationTeamList from './OrganizationTeamList';
|
||||||
|
|
||||||
@@ -100,7 +99,6 @@ describe('<OrganizationTeamList />', () => {
|
|||||||
<OrganizationTeamList id={1} searchString="" />
|
<OrganizationTeamList id={1} searchString="" />
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
await sleep(0);
|
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
|
|
||||||
const list = wrapper.find('PaginatedTable');
|
const list = wrapper.find('PaginatedTable');
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import React from 'react';
|
|||||||
import { act } from 'react-dom/test-utils';
|
import { act } from 'react-dom/test-utils';
|
||||||
import { ProjectsAPI } from 'api';
|
import { ProjectsAPI } from 'api';
|
||||||
import { mountWithContexts } from '../../../../testUtils/enzymeHelpers';
|
import { mountWithContexts } from '../../../../testUtils/enzymeHelpers';
|
||||||
import { sleep } from '../../../../testUtils/testUtils';
|
|
||||||
|
|
||||||
import ProjectSyncButton from './ProjectSyncButton';
|
import ProjectSyncButton from './ProjectSyncButton';
|
||||||
|
|
||||||
@@ -89,13 +88,11 @@ describe('ProjectSyncButton', () => {
|
|||||||
await act(async () => {
|
await act(async () => {
|
||||||
wrapper.find('button').prop('onClick')();
|
wrapper.find('button').prop('onClick')();
|
||||||
});
|
});
|
||||||
await sleep(0);
|
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
expect(wrapper.find('Modal').length).toBe(1);
|
expect(wrapper.find('Modal').length).toBe(1);
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
wrapper.find('ModalBoxCloseButton').simulate('click');
|
wrapper.find('ModalBoxCloseButton').simulate('click');
|
||||||
});
|
});
|
||||||
await sleep(0);
|
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
expect(wrapper.find('Modal').length).toBe(0);
|
expect(wrapper.find('Modal').length).toBe(0);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import {
|
|||||||
mountWithContexts,
|
mountWithContexts,
|
||||||
waitForElement,
|
waitForElement,
|
||||||
} from '../../../../testUtils/enzymeHelpers';
|
} from '../../../../testUtils/enzymeHelpers';
|
||||||
import { sleep } from '../../../../testUtils/testUtils';
|
|
||||||
import JobTemplateForm from './JobTemplateForm';
|
import JobTemplateForm from './JobTemplateForm';
|
||||||
|
|
||||||
jest.mock('../../../api');
|
jest.mock('../../../api');
|
||||||
@@ -420,7 +419,6 @@ describe('<JobTemplateForm />', () => {
|
|||||||
await act(async () => {
|
await act(async () => {
|
||||||
wrapper.find('button[aria-label="Save"]').simulate('click');
|
wrapper.find('button[aria-label="Save"]').simulate('click');
|
||||||
});
|
});
|
||||||
await sleep(1);
|
|
||||||
expect(handleSubmit).toBeCalled();
|
expect(handleSubmit).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import {
|
|||||||
ExecutionEnvironmentsAPI,
|
ExecutionEnvironmentsAPI,
|
||||||
CredentialsAPI,
|
CredentialsAPI,
|
||||||
} from 'api';
|
} from 'api';
|
||||||
import { sleep } from '../../../../testUtils/testUtils';
|
|
||||||
|
|
||||||
import { mountWithContexts } from '../../../../testUtils/enzymeHelpers';
|
import { mountWithContexts } from '../../../../testUtils/enzymeHelpers';
|
||||||
import WorkflowJobTemplateForm from './WorkflowJobTemplateForm';
|
import WorkflowJobTemplateForm from './WorkflowJobTemplateForm';
|
||||||
@@ -310,7 +309,6 @@ describe('<WorkflowJobTemplateForm/>', () => {
|
|||||||
wrapper.find('Formik').prop('onSubmit')({});
|
wrapper.find('Formik').prop('onSubmit')({});
|
||||||
});
|
});
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
sleep(0);
|
|
||||||
expect(handleSubmit).toBeCalled();
|
expect(handleSubmit).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
waitForElement,
|
waitForElement,
|
||||||
} from '../../../../testUtils/enzymeHelpers';
|
} from '../../../../testUtils/enzymeHelpers';
|
||||||
import UserTokenForm from './UserTokenForm';
|
import UserTokenForm from './UserTokenForm';
|
||||||
import { sleep } from '../../../../testUtils/testUtils';
|
|
||||||
|
|
||||||
jest.mock('../../../api');
|
jest.mock('../../../api');
|
||||||
const applications = {
|
const applications = {
|
||||||
@@ -102,7 +101,6 @@ describe('<UserTokenForm />', () => {
|
|||||||
await act(async () => {
|
await act(async () => {
|
||||||
wrapper.find('button[aria-label="Save"]').prop('onClick')();
|
wrapper.find('button[aria-label="Save"]').prop('onClick')();
|
||||||
});
|
});
|
||||||
await sleep(1);
|
|
||||||
|
|
||||||
expect(handleSubmit).toBeCalled();
|
expect(handleSubmit).toBeCalled();
|
||||||
});
|
});
|
||||||
@@ -132,7 +130,6 @@ describe('<UserTokenForm />', () => {
|
|||||||
await act(async () => {
|
await act(async () => {
|
||||||
wrapper.find('button[aria-label="Save"]').prop('onClick')();
|
wrapper.find('button[aria-label="Save"]').prop('onClick')();
|
||||||
});
|
});
|
||||||
await sleep(1);
|
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
expect(
|
expect(
|
||||||
wrapper.find('FormGroup[name="scope"]').prop('helperTextInvalid')
|
wrapper.find('FormGroup[name="scope"]').prop('helperTextInvalid')
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
|
|
||||||
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
||||||
/* eslint-disable-next-line import/prefer-default-export */
|
|
||||||
export { sleep };
|
|
||||||
Reference in New Issue
Block a user