Skip to content
Snippets Groups Projects
Commit 9e2c486d authored by Vitaly Slobodin's avatar Vitaly Slobodin :crystal_ball:
Browse files

Merge branch 'xanf-remove-extra-spins' into 'master'

Remove extra waiting on promises

See merge request gitlab-org/gitlab!137660



Merged-by: default avatarVitaly Slobodin <vslobodin@gitlab.com>
Approved-by: default avatarVitaly Slobodin <vslobodin@gitlab.com>
Reviewed-by: default avatarIllya Klymov <xanf@xanf.me>
Co-authored-by: Illya Klymov's avatarIllya Klymov <iklymov@gitlab.com>
parents 3968202b 86879798
No related branches found
No related tags found
No related merge requests found
Showing with 42 additions and 28 deletions
......@@ -229,15 +229,15 @@ describe('ListMemberRoles', () => {
};
it('sorts columns by name', () => {
expectSortableColumn('name');
return expectSortableColumn('name');
});
it('sorts columns by ID', () => {
expectSortableColumn('id');
return expectSortableColumn('id');
});
it('sorts columns by base role', () => {
expectSortableColumn('base_access_level');
return expectSortableColumn('base_access_level');
});
it('shows list of standard permissions', async () => {
......
......@@ -186,7 +186,7 @@ describe('ee/security_dashboard/components/pipeline/vulnerability_finding_modal.
});
it('contains a "cancel" button that will hide the modal', () => {
expectModalToBeHiddenAfter({
return expectModalToBeHiddenAfter({
action: () => {
findCancelButton().vm.$emit('click');
},
......@@ -368,7 +368,7 @@ describe('ee/security_dashboard/components/pipeline/vulnerability_finding_modal.
});
it('hides the modal', () => {
expectModalToBeHiddenAfter({
return expectModalToBeHiddenAfter({
action: async () => {
findUndoDismissButton().vm.$emit('click');
await waitForFindingToBeDismissed();
......@@ -471,7 +471,7 @@ describe('ee/security_dashboard/components/pipeline/vulnerability_finding_modal.
});
it('hides the modal', () => {
expectModalToBeHiddenAfter({
return expectModalToBeHiddenAfter({
action: async () => {
await dismissWithReason();
},
......
......@@ -6,6 +6,22 @@ import axios from '~/lib/utils/axios_utils';
import SourceEditor from '~/vue_shared/components/source_editor.vue';
import { EDITOR_READY_EVENT } from '~/editor/constants';
jest.mock('ee/security_orchestration/components/policy_editor_schema_ext', () => {
const { PolicySchemaExtension } = jest.requireActual(
'ee/security_orchestration/components/policy_editor_schema_ext',
);
return {
PolicySchemaExtension: class extends PolicySchemaExtension {
// eslint-disable-next-line class-methods-use-this
provides() {
return {
registerSecurityPolicySchema() {},
};
}
},
};
});
describe('YamlEditor component', () => {
let wrapper;
......
......@@ -736,7 +736,7 @@ describe('Api', () => {
it('rejects the Promise', () => {
mock.onGet(expectedUrl).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR);
Api.issueTemplates(namespace, project, templateType, () => {
return Api.issueTemplates(namespace, project, templateType, () => {
expect(mock.history.get).toHaveLength(1);
});
});
......
......@@ -300,9 +300,12 @@ describe('content_editor/extensions/attachment', () => {
it('emits an alert event that includes an error message', () => {
tiptapEditor.commands.uploadAttachment({ file: attachmentFile });
eventHub.$on('alert', ({ message, variant }) => {
expect(variant).toBe(VARIANT_DANGER);
expect(message).toBe('An error occurred while uploading the file. Please try again.');
return new Promise((resolve) => {
eventHub.$on('alert', ({ message, variant }) => {
expect(variant).toBe(VARIANT_DANGER);
expect(message).toBe('An error occurred while uploading the file. Please try again.');
resolve();
});
});
});
});
......
......@@ -662,7 +662,7 @@ describe('DiffFileHeader component', () => {
},
);
it('removes the property that forces a file to be shown when the file review is toggled', () => {
it('removes the property that forces a file to be shown when the file review is toggled', async () => {
createComponent({
props: {
diffFile: {
......@@ -681,7 +681,7 @@ describe('DiffFileHeader component', () => {
findReviewFileCheckbox().vm.$emit('change', true);
testAction(
await testAction(
setFileForcedOpen,
{ filePath: diffFile.file_path, forced: false },
{},
......@@ -691,7 +691,7 @@ describe('DiffFileHeader component', () => {
findReviewFileCheckbox().vm.$emit('change', false);
testAction(
await testAction(
setFileForcedOpen,
{ filePath: diffFile.file_path, forced: false },
{},
......
......@@ -97,10 +97,11 @@ describe('ide/lib/mirror', () => {
connection = mirror.connect(TEST_PATH);
});
it('waits before creating web socket', () => {
// ignore error when test suite terminates
connection.catch(() => {});
afterEach(() => {
mirror.disconnect();
});
it('waits before creating web socket', () => {
return waitForConnection(SERVICE_DELAY - 10).then(() => {
expect(global.WebSocket).not.toHaveBeenCalled();
});
......
......@@ -96,6 +96,10 @@ describe('Issuable output', () => {
afterEach(() => {
document.body.classList?.remove('issuable-sticky-header-visible');
// Consume any pending requests
jest.advanceTimersToNextTimer();
return waitForPromises();
});
describe('update', () => {
......
......@@ -38,7 +38,7 @@ describe('axios_utils', () => {
it('waits for requests on a specific URL', () => {
const handler = jest.fn();
axios.get('/ok').finally(handler);
axios.waitFor('/err').finally(() => {
axios.waitFor('/err').catch(() => {
throw new Error('waitFor on /err should not be called');
});
return axios.waitFor('/ok');
......
......@@ -58,6 +58,7 @@ describe('common_utils', () => {
afterEach(() => {
window.history.pushState({}, null, '');
jest.runAllTimers();
});
function expectGetElementIdToHaveBeenCalledWith(elementId) {
......
/* Setup for unit test environment */
// eslint-disable-next-line no-restricted-syntax
import { setImmediate } from 'timers';
import Dexie from 'dexie';
import { IDBKeyRange, IDBFactory } from 'fake-indexeddb';
import 'helpers/shared_test_setup';
......@@ -10,15 +8,6 @@ const indexedDB = new IDBFactory();
Dexie.dependencies.indexedDB = indexedDB;
Dexie.dependencies.IDBKeyRange = IDBKeyRange;
afterEach(() =>
// give Promises a bit more time so they fail the right test
// eslint-disable-next-line no-restricted-syntax
new Promise(setImmediate).then(() => {
// wait for pending setTimeout()s
jest.runOnlyPendingTimers();
}),
);
afterEach(async () => {
const dbs = await indexedDB.databases();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment