diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-18 09:10:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-18 09:10:20 +0300 |
commit | 3bce40cd27cae740c5de57dacb5ed19fba397007 (patch) | |
tree | 67890f5787bae757bd75af075c0dac3af05c5a8b /spec | |
parent | b7a1160154d52bad5af11a8155369de827df2f74 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/frontend/issues_list/components/issuables_list_app_spec.js | 4 | ||||
-rw-r--r-- | spec/frontend/notes/components/comment_form_spec.js | 14 | ||||
-rw-r--r-- | spec/frontend/notes/stores/actions_spec.js | 80 |
3 files changed, 52 insertions, 46 deletions
diff --git a/spec/frontend/issues_list/components/issuables_list_app_spec.js b/spec/frontend/issues_list/components/issuables_list_app_spec.js index a7f3dd81517..86112dad444 100644 --- a/spec/frontend/issues_list/components/issuables_list_app_spec.js +++ b/spec/frontend/issues_list/components/issuables_list_app_spec.js @@ -8,7 +8,7 @@ import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import { TEST_HOST } from 'helpers/test_constants'; import waitForPromises from 'helpers/wait_for_promises'; -import { deprecatedCreateFlash as flash } from '~/flash'; +import createFlash from '~/flash'; import Issuable from '~/issues_list/components/issuable.vue'; import IssuablesListApp from '~/issues_list/components/issuables_list_app.vue'; import { PAGE_SIZE, PAGE_SIZE_MANUAL, RELATIVE_POSITION } from '~/issues_list/constants'; @@ -104,7 +104,7 @@ describe('Issuables list component', () => { }); it('flashes an error', () => { - expect(flash).toHaveBeenCalledTimes(1); + expect(createFlash).toHaveBeenCalledTimes(1); }); }); diff --git a/spec/frontend/notes/components/comment_form_spec.js b/spec/frontend/notes/components/comment_form_spec.js index 537622b7918..bb79b43205b 100644 --- a/spec/frontend/notes/components/comment_form_spec.js +++ b/spec/frontend/notes/components/comment_form_spec.js @@ -7,7 +7,7 @@ import Vuex from 'vuex'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import batchComments from '~/batch_comments/stores/modules/batch_comments'; import { refreshUserMergeRequestCounts } from '~/commons/nav/user_merge_requests'; -import { deprecatedCreateFlash as flash } from '~/flash'; +import createFlash from '~/flash'; import axios from '~/lib/utils/axios_utils'; import CommentForm from '~/notes/components/comment_form.vue'; import * as constants from '~/notes/constants'; @@ -464,9 +464,9 @@ describe('issue_comment_form component', () => { await wrapper.vm.$nextTick; await wrapper.vm.$nextTick; - expect(flash).toHaveBeenCalledWith( - `Something went wrong while closing the ${type}. Please try again later.`, - ); + expect(createFlash).toHaveBeenCalledWith({ + message: `Something went wrong while closing the ${type}. Please try again later.`, + }); }); }); @@ -500,9 +500,9 @@ describe('issue_comment_form component', () => { await wrapper.vm.$nextTick; await wrapper.vm.$nextTick; - expect(flash).toHaveBeenCalledWith( - `Something went wrong while reopening the ${type}. Please try again later.`, - ); + expect(createFlash).toHaveBeenCalledWith({ + message: `Something went wrong while reopening the ${type}. Please try again later.`, + }); }); }); diff --git a/spec/frontend/notes/stores/actions_spec.js b/spec/frontend/notes/stores/actions_spec.js index 7eef2017dfb..d07ef8ef96a 100644 --- a/spec/frontend/notes/stores/actions_spec.js +++ b/spec/frontend/notes/stores/actions_spec.js @@ -2,7 +2,7 @@ import AxiosMockAdapter from 'axios-mock-adapter'; import testAction from 'helpers/vuex_action_helper'; import { TEST_HOST } from 'spec/test_constants'; import Api from '~/api'; -import { deprecatedCreateFlash as Flash } from '~/flash'; +import createFlash from '~/flash'; import { EVENT_ISSUABLE_VUE_APP_CHANGE } from '~/issuable/constants'; import axios from '~/lib/utils/axios_utils'; import * as notesConstants from '~/notes/constants'; @@ -33,10 +33,7 @@ jest.mock('~/flash', () => { }; }); - return { - createFlash: flash, - deprecatedCreateFlash: flash, - }; + return flash; }); describe('Actions Notes Store', () => { @@ -348,13 +345,13 @@ describe('Actions Notes Store', () => { await startPolling(); expect(axiosMock.history.get).toHaveLength(1); - expect(Flash).not.toHaveBeenCalled(); + expect(createFlash).not.toHaveBeenCalled(); await advanceXMoreIntervals(1); expect(axiosMock.history.get).toHaveLength(2); - expect(Flash).toHaveBeenCalled(); - expect(Flash).toHaveBeenCalledTimes(1); + expect(createFlash).toHaveBeenCalled(); + expect(createFlash).toHaveBeenCalledTimes(1); }); it('resets the failure counter on success', async () => { @@ -375,14 +372,14 @@ describe('Actions Notes Store', () => { await advanceXMoreIntervals(1); // Failure #2 // That was the first failure AFTER a success, so we should NOT see the error displayed - expect(Flash).not.toHaveBeenCalled(); + expect(createFlash).not.toHaveBeenCalled(); // Now we'll allow another failure await advanceXMoreIntervals(1); // Failure #3 // Since this is the second failure in a row, the error should happen - expect(Flash).toHaveBeenCalled(); - expect(Flash).toHaveBeenCalledTimes(1); + expect(createFlash).toHaveBeenCalled(); + expect(createFlash).toHaveBeenCalledTimes(1); }); it('hides the error display if it exists on success', async () => { @@ -393,8 +390,8 @@ describe('Actions Notes Store', () => { await advanceXMoreIntervals(2); // After two errors, the error should be displayed - expect(Flash).toHaveBeenCalled(); - expect(Flash).toHaveBeenCalledTimes(1); + expect(createFlash).toHaveBeenCalled(); + expect(createFlash).toHaveBeenCalledTimes(1); axiosMock.reset(); successMock(); @@ -906,7 +903,7 @@ describe('Actions Notes Store', () => { .then(() => done.fail('Expected error to be thrown!')) .catch((err) => { expect(err).toBe(error); - expect(Flash).not.toHaveBeenCalled(); + expect(createFlash).not.toHaveBeenCalled(); }) .then(done) .catch(done.fail); @@ -928,11 +925,11 @@ describe('Actions Notes Store', () => { ) .then((resp) => { expect(resp.hasFlash).toBe(true); - expect(Flash).toHaveBeenCalledWith( - 'Your comment could not be submitted because something went wrong', - 'alert', - flashContainer, - ); + expect(createFlash).toHaveBeenCalledWith({ + message: 'Your comment could not be submitted because something went wrong', + type: 'alert', + parent: flashContainer, + }); }) .catch(() => done.fail('Expected success response!')) .then(done) @@ -954,7 +951,7 @@ describe('Actions Notes Store', () => { ) .then((data) => { expect(data).toBe(res); - expect(Flash).not.toHaveBeenCalled(); + expect(createFlash).not.toHaveBeenCalled(); }) .then(done) .catch(done.fail); @@ -997,7 +994,7 @@ describe('Actions Notes Store', () => { ['resolveDiscussion', { discussionId }], ['restartPolling'], ]); - expect(Flash).not.toHaveBeenCalled(); + expect(createFlash).not.toHaveBeenCalled(); }); }); @@ -1012,7 +1009,11 @@ describe('Actions Notes Store', () => { [mutationTypes.SET_RESOLVING_DISCUSSION, false], ]); expect(dispatch.mock.calls).toEqual([['stopPolling'], ['restartPolling']]); - expect(Flash).toHaveBeenCalledWith(TEST_ERROR_MESSAGE, 'alert', flashContainer); + expect(createFlash).toHaveBeenCalledWith({ + message: TEST_ERROR_MESSAGE, + type: 'alert', + parent: flashContainer, + }); }); }); @@ -1027,11 +1028,11 @@ describe('Actions Notes Store', () => { [mutationTypes.SET_RESOLVING_DISCUSSION, false], ]); expect(dispatch.mock.calls).toEqual([['stopPolling'], ['restartPolling']]); - expect(Flash).toHaveBeenCalledWith( - 'Something went wrong while applying the suggestion. Please try again.', - 'alert', - flashContainer, - ); + expect(createFlash).toHaveBeenCalledWith({ + message: 'Something went wrong while applying the suggestion. Please try again.', + type: 'alert', + parent: flashContainer, + }); }); }); @@ -1039,7 +1040,7 @@ describe('Actions Notes Store', () => { dispatch.mockReturnValue(Promise.reject()); testSubmitSuggestion(done, () => { - expect(Flash).not.toHaveBeenCalled(); + expect(createFlash).not.toHaveBeenCalled(); }); }); }); @@ -1083,7 +1084,7 @@ describe('Actions Notes Store', () => { ['restartPolling'], ]); - expect(Flash).not.toHaveBeenCalled(); + expect(createFlash).not.toHaveBeenCalled(); }); }); @@ -1101,7 +1102,11 @@ describe('Actions Notes Store', () => { ]); expect(dispatch.mock.calls).toEqual([['stopPolling'], ['restartPolling']]); - expect(Flash).toHaveBeenCalledWith(TEST_ERROR_MESSAGE, 'alert', flashContainer); + expect(createFlash).toHaveBeenCalledWith({ + message: TEST_ERROR_MESSAGE, + type: 'alert', + parent: flashContainer, + }); }); }); @@ -1119,11 +1124,12 @@ describe('Actions Notes Store', () => { ]); expect(dispatch.mock.calls).toEqual([['stopPolling'], ['restartPolling']]); - expect(Flash).toHaveBeenCalledWith( - 'Something went wrong while applying the batch of suggestions. Please try again.', - 'alert', - flashContainer, - ); + expect(createFlash).toHaveBeenCalledWith({ + message: + 'Something went wrong while applying the batch of suggestions. Please try again.', + type: 'alert', + parent: flashContainer, + }); }); }); @@ -1139,7 +1145,7 @@ describe('Actions Notes Store', () => { [mutationTypes.SET_RESOLVING_DISCUSSION, false], ]); - expect(Flash).not.toHaveBeenCalled(); + expect(createFlash).not.toHaveBeenCalled(); }); }); }); @@ -1283,7 +1289,7 @@ describe('Actions Notes Store', () => { ) .then(() => done.fail('Expected error to be thrown')) .catch(() => { - expect(Flash).toHaveBeenCalled(); + expect(createFlash).toHaveBeenCalled(); done(); }); }); |