Commit e7fe5027 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'refactor-alert-flash' into 'master'

Use gl-alert instead of Flash

See merge request gitlab-org/gitlab!61969
parents 0ea64f98 76c6c753
<script> <script>
import { GlModal } from '@gitlab/ui'; import { GlModal, GlAlert } from '@gitlab/ui';
import { mapGetters } from 'vuex'; import { mapGetters, mapActions, mapState } from 'vuex';
import { deprecatedCreateFlash as Flash } from '~/flash';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import { getParameterByName } from '~/lib/utils/common_utils'; import { getParameterByName } from '~/lib/utils/common_utils';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
...@@ -44,6 +43,7 @@ export default { ...@@ -44,6 +43,7 @@ export default {
BoardScope: () => import('ee_component/boards/components/board_scope.vue'), BoardScope: () => import('ee_component/boards/components/board_scope.vue'),
GlModal, GlModal,
BoardConfigurationOptions, BoardConfigurationOptions,
GlAlert,
}, },
inject: { inject: {
fullPath: { fullPath: {
...@@ -107,6 +107,7 @@ export default { ...@@ -107,6 +107,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapState(['error']),
...mapGetters(['isIssueBoard', 'isGroupBoard', 'isProjectBoard']), ...mapGetters(['isIssueBoard', 'isGroupBoard', 'isProjectBoard']),
isNewForm() { isNewForm() {
return this.currentPage === formType.new; return this.currentPage === formType.new;
...@@ -222,6 +223,7 @@ export default { ...@@ -222,6 +223,7 @@ export default {
} }
}, },
methods: { methods: {
...mapActions(['setError', 'unsetError']),
setIteration(iterationId) { setIteration(iterationId) {
this.board.iteration_id = iterationId; this.board.iteration_id = iterationId;
}, },
...@@ -263,7 +265,7 @@ export default { ...@@ -263,7 +265,7 @@ export default {
await this.deleteBoard(); await this.deleteBoard();
visitUrl(this.rootPath); visitUrl(this.rootPath);
} catch { } catch {
Flash(this.$options.i18n.deleteErrorMessage); this.setError({ message: this.$options.i18n.deleteErrorMessage });
} finally { } finally {
this.isLoading = false; this.isLoading = false;
} }
...@@ -272,7 +274,7 @@ export default { ...@@ -272,7 +274,7 @@ export default {
const url = await this.createOrUpdateBoard(); const url = await this.createOrUpdateBoard();
visitUrl(url); visitUrl(url);
} catch { } catch {
Flash(this.$options.i18n.saveErrorMessage); this.setError({ message: this.$options.i18n.saveErrorMessage });
} finally { } finally {
this.isLoading = false; this.isLoading = false;
} }
...@@ -308,6 +310,15 @@ export default { ...@@ -308,6 +310,15 @@ export default {
@close="cancel" @close="cancel"
@hide.prevent @hide.prevent
> >
<gl-alert
v-if="error"
class="gl-mb-3"
variant="danger"
:dismissible="true"
@dismiss="unsetError"
>
{{ error }}
</gl-alert>
<p v-if="isDeleteForm" data-testid="delete-confirmation-message"> <p v-if="isDeleteForm" data-testid="delete-confirmation-message">
{{ $options.i18n.deleteConfirmationMessage }} {{ $options.i18n.deleteConfirmationMessage }}
</p> </p>
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
import { GlButton, GlDatepicker } from '@gitlab/ui'; import { GlButton, GlDatepicker } from '@gitlab/ui';
import { mapGetters, mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue'; import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue';
import createFlash from '~/flash';
import { dateInWords, formatDate, parsePikadayDate } from '~/lib/utils/datetime_utility'; import { dateInWords, formatDate, parsePikadayDate } from '~/lib/utils/datetime_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -38,7 +37,7 @@ export default { ...@@ -38,7 +37,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(['setActiveIssueDueDate']), ...mapActions(['setActiveIssueDueDate', 'setError']),
async openDatePicker() { async openDatePicker() {
await this.$nextTick(); await this.$nextTick();
this.$refs.datePicker.calendar.show(); this.$refs.datePicker.calendar.show();
...@@ -51,7 +50,7 @@ export default { ...@@ -51,7 +50,7 @@ export default {
const dueDate = date ? formatDate(date, 'yyyy-mm-dd') : null; const dueDate = date ? formatDate(date, 'yyyy-mm-dd') : null;
await this.setActiveIssueDueDate({ dueDate, projectPath: this.projectPathForActiveIssue }); await this.setActiveIssueDueDate({ dueDate, projectPath: this.projectPathForActiveIssue });
} catch (e) { } catch (e) {
createFlash({ message: this.$options.i18n.updateDueDateError }); this.setError({ message: this.$options.i18n.updateDueDateError });
} finally { } finally {
this.loading = false; this.loading = false;
} }
......
...@@ -3,7 +3,6 @@ import { GlLabel } from '@gitlab/ui'; ...@@ -3,7 +3,6 @@ import { GlLabel } from '@gitlab/ui';
import { mapGetters, mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import Api from '~/api'; import Api from '~/api';
import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue'; import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue';
import createFlash from '~/flash';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { isScopedLabel } from '~/lib/utils/common_utils'; import { isScopedLabel } from '~/lib/utils/common_utils';
import { mergeUrlParams } from '~/lib/utils/url_utility'; import { mergeUrlParams } from '~/lib/utils/url_utility';
...@@ -50,10 +49,10 @@ export default { ...@@ -50,10 +49,10 @@ export default {
/* /*
Labels fetched in epic boards are always group-level labels Labels fetched in epic boards are always group-level labels
and the correct path are passed from the backend (injected through labelsFetchPath) and the correct path are passed from the backend (injected through labelsFetchPath)
For issue boards, we should always include project-level labels and use a different endpoint. For issue boards, we should always include project-level labels and use a different endpoint.
(it requires knowing the project path of a selected issue.) (it requires knowing the project path of a selected issue.)
Note 1. that we will be using GraphQL to fetch labels when we create a labels select widget. Note 1. that we will be using GraphQL to fetch labels when we create a labels select widget.
And this component will be removed _wholesale_ https://gitlab.com/gitlab-org/gitlab/-/issues/300653. And this component will be removed _wholesale_ https://gitlab.com/gitlab-org/gitlab/-/issues/300653.
...@@ -74,7 +73,7 @@ export default { ...@@ -74,7 +73,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(['setActiveBoardItemLabels']), ...mapActions(['setActiveBoardItemLabels', 'setError']),
async setLabels(payload) { async setLabels(payload) {
this.loading = true; this.loading = true;
this.$refs.sidebarItem.collapse(); this.$refs.sidebarItem.collapse();
...@@ -88,7 +87,7 @@ export default { ...@@ -88,7 +87,7 @@ export default {
const input = { addLabelIds, removeLabelIds, projectPath: this.projectPathForActiveIssue }; const input = { addLabelIds, removeLabelIds, projectPath: this.projectPathForActiveIssue };
await this.setActiveBoardItemLabels(input); await this.setActiveBoardItemLabels(input);
} catch (e) { } catch (e) {
createFlash({ message: __('An error occurred while updating labels.') }); this.setError({ error: e, message: __('An error occurred while updating labels.') });
} finally { } finally {
this.loading = false; this.loading = false;
} }
...@@ -101,7 +100,7 @@ export default { ...@@ -101,7 +100,7 @@ export default {
const input = { removeLabelIds, projectPath: this.projectPathForActiveIssue }; const input = { removeLabelIds, projectPath: this.projectPathForActiveIssue };
await this.setActiveBoardItemLabels(input); await this.setActiveBoardItemLabels(input);
} catch (e) { } catch (e) {
createFlash({ message: __('An error occurred when removing the label.') }); this.setError({ error: e, message: __('An error occurred when removing the label.') });
} finally { } finally {
this.loading = false; this.loading = false;
} }
......
...@@ -9,7 +9,6 @@ import { ...@@ -9,7 +9,6 @@ import {
} from '@gitlab/ui'; } from '@gitlab/ui';
import { mapGetters, mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue'; import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue';
import createFlash from '~/flash';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
import projectMilestones from '../../graphql/project_milestones.query.graphql'; import projectMilestones from '../../graphql/project_milestones.query.graphql';
...@@ -50,8 +49,8 @@ export default { ...@@ -50,8 +49,8 @@ export default {
const edges = data?.project?.milestones?.edges ?? []; const edges = data?.project?.milestones?.edges ?? [];
return edges.map((item) => item.node); return edges.map((item) => item.node);
}, },
error() { error(error) {
createFlash({ message: this.$options.i18n.fetchMilestonesError }); this.setError({ error, message: this.$options.i18n.fetchMilestonesError });
}, },
}, },
}, },
...@@ -73,7 +72,7 @@ export default { ...@@ -73,7 +72,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(['setActiveIssueMilestone']), ...mapActions(['setActiveIssueMilestone', 'setError']),
handleOpen() { handleOpen() {
this.edit = true; this.edit = true;
this.$refs.dropdown.show(); this.$refs.dropdown.show();
...@@ -91,7 +90,7 @@ export default { ...@@ -91,7 +90,7 @@ export default {
const input = { milestoneId, projectPath: this.projectPath }; const input = { milestoneId, projectPath: this.projectPath };
await this.setActiveIssueMilestone(input); await this.setActiveIssueMilestone(input);
} catch (e) { } catch (e) {
createFlash({ message: this.$options.i18n.updateMilestoneError }); this.setError({ error: e, message: this.$options.i18n.updateMilestoneError });
} finally { } finally {
this.loading = false; this.loading = false;
} }
......
<script> <script>
import { GlToggle } from '@gitlab/ui'; import { GlToggle } from '@gitlab/ui';
import { mapGetters, mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import createFlash from '~/flash';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
export default { export default {
...@@ -39,17 +38,16 @@ export default { ...@@ -39,17 +38,16 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(['setActiveItemSubscribed']), ...mapActions(['setActiveItemSubscribed', 'setError']),
async handleToggleSubscription() { async handleToggleSubscription() {
this.loading = true; this.loading = true;
try { try {
await this.setActiveItemSubscribed({ await this.setActiveItemSubscribed({
subscribed: !this.activeBoardItem.subscribed, subscribed: !this.activeBoardItem.subscribed,
projectPath: this.projectPathForActiveIssue, projectPath: this.projectPathForActiveIssue,
}); });
} catch (error) { } catch (error) {
createFlash({ message: this.$options.i18n.updateSubscribedErrorMessage }); this.setError({ error, message: this.$options.i18n.updateSubscribedErrorMessage });
} finally { } finally {
this.loading = false; this.loading = false;
} }
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
import { GlAlert, GlButton, GlForm, GlFormGroup, GlFormInput } from '@gitlab/ui'; import { GlAlert, GlButton, GlForm, GlFormGroup, GlFormInput } from '@gitlab/ui';
import { mapGetters, mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue'; import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue';
import createFlash from '~/flash';
import { joinPaths } from '~/lib/utils/url_utility'; import { joinPaths } from '~/lib/utils/url_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
import autofocusonshow from '~/vue_shared/directives/autofocusonshow'; import autofocusonshow from '~/vue_shared/directives/autofocusonshow';
...@@ -53,7 +52,7 @@ export default { ...@@ -53,7 +52,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(['setActiveItemTitle']), ...mapActions(['setActiveItemTitle', 'setError']),
getPendingChangesKey(item) { getPendingChangesKey(item) {
if (!item) { if (!item) {
return ''; return '';
...@@ -97,7 +96,7 @@ export default { ...@@ -97,7 +96,7 @@ export default {
this.showChangesAlert = false; this.showChangesAlert = false;
} catch (e) { } catch (e) {
this.title = this.item.title; this.title = this.item.title;
createFlash({ message: this.$options.i18n.updateTitleError }); this.setError({ error: e, message: this.$options.i18n.updateTitleError });
} finally { } finally {
this.loading = false; this.loading = false;
} }
......
...@@ -27,7 +27,6 @@ import FilteredSearchBoards from '~/boards/filtered_search_boards'; ...@@ -27,7 +27,6 @@ import FilteredSearchBoards from '~/boards/filtered_search_boards';
import store from '~/boards/stores'; import store from '~/boards/stores';
import boardsStore from '~/boards/stores/boards_store'; import boardsStore from '~/boards/stores/boards_store';
import toggleFocusMode from '~/boards/toggle_focus'; import toggleFocusMode from '~/boards/toggle_focus';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createDefaultClient from '~/lib/graphql'; import createDefaultClient from '~/lib/graphql';
import { import {
NavigationType, NavigationType,
...@@ -196,7 +195,7 @@ export default () => { ...@@ -196,7 +195,7 @@ export default () => {
} }
}, },
methods: { methods: {
...mapActions(['setInitialBoardData', 'performSearch']), ...mapActions(['setInitialBoardData', 'performSearch', 'setError']),
initialBoardLoad() { initialBoardLoad() {
boardsStore boardsStore
.all() .all()
...@@ -205,8 +204,11 @@ export default () => { ...@@ -205,8 +204,11 @@ export default () => {
lists.forEach((list) => boardsStore.addList(list)); lists.forEach((list) => boardsStore.addList(list));
this.loading = false; this.loading = false;
}) })
.catch(() => { .catch((error) => {
Flash(__('An error occurred while fetching the board lists. Please try again.')); this.setError({
error,
message: __('An error occurred while fetching the board lists. Please try again.'),
});
}); });
}, },
updateTokens() { updateTokens() {
...@@ -250,7 +252,7 @@ export default () => { ...@@ -250,7 +252,7 @@ export default () => {
.catch(() => { .catch(() => {
newIssue.setFetchingState('subscriptions', false); newIssue.setFetchingState('subscriptions', false);
setWeightFetchingState(newIssue, false); setWeightFetchingState(newIssue, false);
Flash(__('An error occurred while fetching sidebar data')); this.setError({ message: __('An error occurred while fetching sidebar data') });
}); });
} }
...@@ -287,7 +289,9 @@ export default () => { ...@@ -287,7 +289,9 @@ export default () => {
}) })
.catch(() => { .catch(() => {
issue.setFetchingState('subscriptions', false); issue.setFetchingState('subscriptions', false);
Flash(__('An error occurred when toggling the notification subscription')); this.setError({
message: __('An error occurred when toggling the notification subscription'),
});
}); });
} }
}, },
......
...@@ -726,7 +726,7 @@ export default { ...@@ -726,7 +726,7 @@ export default {
} }
}, },
setError: ({ commit }, { message, error, captureError = false }) => { setError: ({ commit }, { message, error, captureError = true }) => {
commit(types.SET_ERROR, message); commit(types.SET_ERROR, message);
if (captureError) { if (captureError) {
......
...@@ -3,7 +3,6 @@ import { GlButton, GlFormInput } from '@gitlab/ui'; ...@@ -3,7 +3,6 @@ import { GlButton, GlFormInput } from '@gitlab/ui';
import { mapActions, mapGetters, mapState } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
import boardsStoreEE from 'ee/boards/stores/boards_store_ee'; import boardsStoreEE from 'ee/boards/stores/boards_store_ee';
import { inactiveId } from '~/boards/constants'; import { inactiveId } from '~/boards/constants';
import createFlash from '~/flash';
import { __, n__ } from '~/locale'; import { __, n__ } from '~/locale';
import autofocusonshow from '~/vue_shared/directives/autofocusonshow'; import autofocusonshow from '~/vue_shared/directives/autofocusonshow';
...@@ -49,7 +48,7 @@ export default { ...@@ -49,7 +48,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(['unsetActiveId', 'updateListWipLimit']), ...mapActions(['unsetActiveId', 'updateListWipLimit', 'setError']),
showInput() { showInput() {
this.edit = true; this.edit = true;
this.currentWipLimit = this.maxIssueCount > 0 ? this.maxIssueCount : null; this.currentWipLimit = this.maxIssueCount > 0 ? this.maxIssueCount : null;
...@@ -84,7 +83,7 @@ export default { ...@@ -84,7 +83,7 @@ export default {
}) })
.catch(() => { .catch(() => {
this.unsetActiveId(); this.unsetActiveId();
createFlash({ this.setError({
message: __('Something went wrong while updating your list settings'), message: __('Something went wrong while updating your list settings'),
}); });
}) })
...@@ -104,7 +103,7 @@ export default { ...@@ -104,7 +103,7 @@ export default {
}) })
.catch(() => { .catch(() => {
this.unsetActiveId(); this.unsetActiveId();
createFlash({ this.setError({
message: __('Something went wrong while updating your list settings'), message: __('Something went wrong while updating your list settings'),
}); });
}) })
......
<script> <script>
import { GlButton, GlIcon, GlLink, GlPopover, GlTooltipDirective } from '@gitlab/ui'; import { GlButton, GlIcon, GlLink, GlPopover, GlTooltipDirective } from '@gitlab/ui';
import { mapActions, mapGetters, mapState } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
import createFlash from '~/flash';
import { formatDate } from '~/lib/utils/datetime_utility'; import { formatDate } from '~/lib/utils/datetime_utility';
import { __, n__, sprintf } from '~/locale'; import { __, n__, sprintf } from '~/locale';
import timeagoMixin from '~/vue_shared/mixins/timeago'; import timeagoMixin from '~/vue_shared/mixins/timeago';
...@@ -86,7 +85,7 @@ export default { ...@@ -86,7 +85,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(['updateBoardEpicUserPreferences']), ...mapActions(['updateBoardEpicUserPreferences', 'setError']),
toggleCollapsed() { toggleCollapsed() {
this.isCollapsed = !this.isCollapsed; this.isCollapsed = !this.isCollapsed;
...@@ -94,7 +93,7 @@ export default { ...@@ -94,7 +93,7 @@ export default {
collapsed: this.isCollapsed, collapsed: this.isCollapsed,
epicId: this.epic.id, epicId: this.epic.id,
}).catch(() => { }).catch(() => {
createFlash({ message: __('Unable to save your preference'), captureError: true }); this.setError({ message: __('Unable to save your preference'), captureError: true });
}); });
}, },
}, },
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
import { GlButton, GlForm, GlFormInput } from '@gitlab/ui'; import { GlButton, GlForm, GlFormInput } from '@gitlab/ui';
import { mapGetters, mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue'; import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue';
import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import autofocusonshow from '~/vue_shared/directives/autofocusonshow'; import autofocusonshow from '~/vue_shared/directives/autofocusonshow';
...@@ -37,7 +36,7 @@ export default { ...@@ -37,7 +36,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(['setActiveIssueWeight']), ...mapActions(['setActiveIssueWeight', 'setError']),
handleFormSubmit() { handleFormSubmit() {
this.$refs.sidebarItem.collapse({ emitEvent: false }); this.$refs.sidebarItem.collapse({ emitEvent: false });
this.setWeight(); this.setWeight();
...@@ -56,7 +55,7 @@ export default { ...@@ -56,7 +55,7 @@ export default {
this.weight = weight; this.weight = weight;
} catch (e) { } catch (e) {
this.weight = this.activeBoardItem.weight; this.weight = this.activeBoardItem.weight;
createFlash({ message: __('An error occurred when updating the issue weight') }); this.setError({ message: __('An error occurred when updating the issue weight') });
} finally { } finally {
this.loading = false; this.loading = false;
} }
......
...@@ -12,14 +12,12 @@ import { TEST_HOST } from 'helpers/test_constants'; ...@@ -12,14 +12,12 @@ import { TEST_HOST } from 'helpers/test_constants';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import { formType } from '~/boards/constants'; import { formType } from '~/boards/constants';
import { deprecatedCreateFlash as createFlash } from '~/flash';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
jest.mock('~/lib/utils/url_utility', () => ({ jest.mock('~/lib/utils/url_utility', () => ({
visitUrl: jest.fn().mockName('visitUrlMock'), visitUrl: jest.fn().mockName('visitUrlMock'),
stripFinalUrlSegment: jest.requireActual('~/lib/utils/url_utility').stripFinalUrlSegment, stripFinalUrlSegment: jest.requireActual('~/lib/utils/url_utility').stripFinalUrlSegment,
})); }));
jest.mock('~/flash');
Vue.use(Vuex); Vue.use(Vuex);
...@@ -168,9 +166,10 @@ describe('BoardForm', () => { ...@@ -168,9 +166,10 @@ describe('BoardForm', () => {
expect(visitUrl).toHaveBeenCalledWith('test-path'); expect(visitUrl).toHaveBeenCalledWith('test-path');
}); });
it('shows an error flash if GraphQL mutation fails', async () => { it('shows a GlAlert if GraphQL mutation fails', async () => {
mutate = jest.fn().mockRejectedValue('Houston, we have a problem'); mutate = jest.fn().mockRejectedValue('Houston, we have a problem');
createComponent({ canAdminBoard: true, currentPage: formType.new }); createComponent({ canAdminBoard: true, currentPage: formType.new });
jest.spyOn(wrapper.vm, 'setError').mockImplementation(() => {});
fillForm(); fillForm();
await waitForPromises(); await waitForPromises();
...@@ -179,7 +178,7 @@ describe('BoardForm', () => { ...@@ -179,7 +178,7 @@ describe('BoardForm', () => {
await waitForPromises(); await waitForPromises();
expect(visitUrl).not.toHaveBeenCalled(); expect(visitUrl).not.toHaveBeenCalled();
expect(createFlash).toHaveBeenCalled(); expect(wrapper.vm.setError).toHaveBeenCalled();
}); });
}); });
}); });
...@@ -213,9 +212,10 @@ describe('BoardForm', () => { ...@@ -213,9 +212,10 @@ describe('BoardForm', () => {
expect(visitUrl).toHaveBeenCalledWith('test-path'); expect(visitUrl).toHaveBeenCalledWith('test-path');
}); });
it('shows an error flash if GraphQL mutation fails', async () => { it('shows a GlAlert if GraphQL mutation fails', async () => {
mutate = jest.fn().mockRejectedValue('Houston, we have a problem'); mutate = jest.fn().mockRejectedValue('Houston, we have a problem');
createComponent({ canAdminBoard: true, currentPage: formType.edit }); createComponent({ canAdminBoard: true, currentPage: formType.edit });
jest.spyOn(wrapper.vm, 'setError').mockImplementation(() => {});
findInput().trigger('keyup.enter', { metaKey: true }); findInput().trigger('keyup.enter', { metaKey: true });
await waitForPromises(); await waitForPromises();
...@@ -224,7 +224,7 @@ describe('BoardForm', () => { ...@@ -224,7 +224,7 @@ describe('BoardForm', () => {
await waitForPromises(); await waitForPromises();
expect(visitUrl).not.toHaveBeenCalled(); expect(visitUrl).not.toHaveBeenCalled();
expect(createFlash).toHaveBeenCalled(); expect(wrapper.vm.setError).toHaveBeenCalled();
}); });
}); });
...@@ -258,9 +258,10 @@ describe('BoardForm', () => { ...@@ -258,9 +258,10 @@ describe('BoardForm', () => {
expect(visitUrl).toHaveBeenCalledWith('root'); expect(visitUrl).toHaveBeenCalledWith('root');
}); });
it('shows an error flash if GraphQL mutation fails', async () => { it('shows a GlAlert if GraphQL mutation fails', async () => {
mutate = jest.fn().mockRejectedValue('Houston, we have a problem'); mutate = jest.fn().mockRejectedValue('Houston, we have a problem');
createComponent({ canAdminBoard: true, currentPage: formType.delete }); createComponent({ canAdminBoard: true, currentPage: formType.delete });
jest.spyOn(wrapper.vm, 'setError').mockImplementation(() => {});
findModal().vm.$emit('primary'); findModal().vm.$emit('primary');
await waitForPromises(); await waitForPromises();
...@@ -269,7 +270,7 @@ describe('BoardForm', () => { ...@@ -269,7 +270,7 @@ describe('BoardForm', () => {
await waitForPromises(); await waitForPromises();
expect(visitUrl).not.toHaveBeenCalled(); expect(visitUrl).not.toHaveBeenCalled();
expect(createFlash).toHaveBeenCalled(); expect(wrapper.vm.setError).toHaveBeenCalled();
}); });
}); });
}); });
...@@ -8,9 +8,6 @@ import Vuex from 'vuex'; ...@@ -8,9 +8,6 @@ import Vuex from 'vuex';
import BoardSettingsWipLimit from 'ee_component/boards/components/board_settings_wip_limit.vue'; import BoardSettingsWipLimit from 'ee_component/boards/components/board_settings_wip_limit.vue';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import boardsStore from '~/boards/stores/boards_store'; import boardsStore from '~/boards/stores/boards_store';
import createFlash from '~/flash';
jest.mock('~/flash');
const localVue = createLocalVue(); const localVue = createLocalVue();
...@@ -185,7 +182,6 @@ describe('BoardSettingsWipLimit', () => { ...@@ -185,7 +182,6 @@ describe('BoardSettingsWipLimit', () => {
}); });
afterEach(() => { afterEach(() => {
createFlash.mockReset();
boardsStore.removeList(listId); boardsStore.removeList(listId);
}); });
...@@ -289,6 +285,7 @@ describe('BoardSettingsWipLimit', () => { ...@@ -289,6 +285,7 @@ describe('BoardSettingsWipLimit', () => {
actions: { updateListWipLimit: spy, unsetActiveId: noop }, actions: { updateListWipLimit: spy, unsetActiveId: noop },
localState: { edit: true, currentWipLimit }, localState: { edit: true, currentWipLimit },
}); });
jest.spyOn(wrapper.vm, 'setError').mockImplementation(() => {});
triggerBlur(blurMethod); triggerBlur(blurMethod);
...@@ -296,7 +293,7 @@ describe('BoardSettingsWipLimit', () => { ...@@ -296,7 +293,7 @@ describe('BoardSettingsWipLimit', () => {
}); });
it('calls flash with expected error', () => { it('calls flash with expected error', () => {
expect(createFlash).toHaveBeenCalledTimes(1); expect(wrapper.vm.setError).toHaveBeenCalledTimes(1);
}); });
}); });
}); });
......
...@@ -3,13 +3,10 @@ import { shallowMount } from '@vue/test-utils'; ...@@ -3,13 +3,10 @@ import { shallowMount } from '@vue/test-utils';
import BoardSidebarWeightInput from 'ee/boards/components/sidebar/board_sidebar_weight_input.vue'; import BoardSidebarWeightInput from 'ee/boards/components/sidebar/board_sidebar_weight_input.vue';
import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue'; import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue';
import { createStore } from '~/boards/stores'; import { createStore } from '~/boards/stores';
import createFlash from '~/flash';
const TEST_WEIGHT = 1; const TEST_WEIGHT = 1;
const TEST_ISSUE = { id: 'gid://gitlab/Issue/1', iid: 9, weight: 0, referencePath: 'h/b#2' }; const TEST_ISSUE = { id: 'gid://gitlab/Issue/1', iid: 9, weight: 0, referencePath: 'h/b#2' };
jest.mock('~/flash');
describe('ee/boards/components/sidebar/board_sidebar_weight_input.vue', () => { describe('ee/boards/components/sidebar/board_sidebar_weight_input.vue', () => {
let wrapper; let wrapper;
let store; let store;
...@@ -115,6 +112,7 @@ describe('ee/boards/components/sidebar/board_sidebar_weight_input.vue', () => { ...@@ -115,6 +112,7 @@ describe('ee/boards/components/sidebar/board_sidebar_weight_input.vue', () => {
jest.spyOn(wrapper.vm, 'setActiveIssueWeight').mockImplementation(() => { jest.spyOn(wrapper.vm, 'setActiveIssueWeight').mockImplementation(() => {
throw new Error(['failed mutation']); throw new Error(['failed mutation']);
}); });
jest.spyOn(wrapper.vm, 'setError').mockImplementation(() => {});
findWeightInput().vm.$emit('input', -1); findWeightInput().vm.$emit('input', -1);
findWeightForm().vm.$emit('submit', { preventDefault: () => {} }); findWeightForm().vm.$emit('submit', { preventDefault: () => {} });
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
...@@ -123,7 +121,7 @@ describe('ee/boards/components/sidebar/board_sidebar_weight_input.vue', () => { ...@@ -123,7 +121,7 @@ describe('ee/boards/components/sidebar/board_sidebar_weight_input.vue', () => {
it('collapses sidebar and renders former issue weight', () => { it('collapses sidebar and renders former issue weight', () => {
expect(findCollapsed().isVisible()).toBe(true); expect(findCollapsed().isVisible()).toBe(true);
expect(findCollapsed().text()).toContain(TEST_WEIGHT); expect(findCollapsed().text()).toContain(TEST_WEIGHT);
expect(createFlash).toHaveBeenCalled(); expect(wrapper.vm.setError).toHaveBeenCalled();
}); });
}); });
}); });
...@@ -9,14 +9,12 @@ import createBoardMutation from '~/boards/graphql/board_create.mutation.graphql' ...@@ -9,14 +9,12 @@ import createBoardMutation from '~/boards/graphql/board_create.mutation.graphql'
import destroyBoardMutation from '~/boards/graphql/board_destroy.mutation.graphql'; import destroyBoardMutation from '~/boards/graphql/board_destroy.mutation.graphql';
import updateBoardMutation from '~/boards/graphql/board_update.mutation.graphql'; import updateBoardMutation from '~/boards/graphql/board_update.mutation.graphql';
import { createStore } from '~/boards/stores'; import { createStore } from '~/boards/stores';
import { deprecatedCreateFlash as createFlash } from '~/flash';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
jest.mock('~/lib/utils/url_utility', () => ({ jest.mock('~/lib/utils/url_utility', () => ({
visitUrl: jest.fn().mockName('visitUrlMock'), visitUrl: jest.fn().mockName('visitUrlMock'),
stripFinalUrlSegment: jest.requireActual('~/lib/utils/url_utility').stripFinalUrlSegment, stripFinalUrlSegment: jest.requireActual('~/lib/utils/url_utility').stripFinalUrlSegment,
})); }));
jest.mock('~/flash');
const currentBoard = { const currentBoard = {
id: 1, id: 1,
...@@ -194,9 +192,11 @@ describe('BoardForm', () => { ...@@ -194,9 +192,11 @@ describe('BoardForm', () => {
expect(visitUrl).toHaveBeenCalledWith('test-path'); expect(visitUrl).toHaveBeenCalledWith('test-path');
}); });
it('shows an error flash if GraphQL mutation fails', async () => { it('shows a GlAlert if GraphQL mutation fails', async () => {
mutate = jest.fn().mockRejectedValue('Houston, we have a problem'); mutate = jest.fn().mockRejectedValue('Houston, we have a problem');
createComponent({ canAdminBoard: true, currentPage: formType.new }); createComponent({ canAdminBoard: true, currentPage: formType.new });
jest.spyOn(wrapper.vm, 'setError').mockImplementation(() => {});
fillForm(); fillForm();
await waitForPromises(); await waitForPromises();
...@@ -205,7 +205,7 @@ describe('BoardForm', () => { ...@@ -205,7 +205,7 @@ describe('BoardForm', () => {
await waitForPromises(); await waitForPromises();
expect(visitUrl).not.toHaveBeenCalled(); expect(visitUrl).not.toHaveBeenCalled();
expect(createFlash).toHaveBeenCalled(); expect(wrapper.vm.setError).toHaveBeenCalled();
}); });
}); });
}); });
...@@ -290,9 +290,11 @@ describe('BoardForm', () => { ...@@ -290,9 +290,11 @@ describe('BoardForm', () => {
expect(visitUrl).toHaveBeenCalledWith('test-path?group_by=epic'); expect(visitUrl).toHaveBeenCalledWith('test-path?group_by=epic');
}); });
it('shows an error flash if GraphQL mutation fails', async () => { it('shows a GlAlert if GraphQL mutation fails', async () => {
mutate = jest.fn().mockRejectedValue('Houston, we have a problem'); mutate = jest.fn().mockRejectedValue('Houston, we have a problem');
createComponent({ canAdminBoard: true, currentPage: formType.edit }); createComponent({ canAdminBoard: true, currentPage: formType.edit });
jest.spyOn(wrapper.vm, 'setError').mockImplementation(() => {});
findInput().trigger('keyup.enter', { metaKey: true }); findInput().trigger('keyup.enter', { metaKey: true });
await waitForPromises(); await waitForPromises();
...@@ -301,7 +303,7 @@ describe('BoardForm', () => { ...@@ -301,7 +303,7 @@ describe('BoardForm', () => {
await waitForPromises(); await waitForPromises();
expect(visitUrl).not.toHaveBeenCalled(); expect(visitUrl).not.toHaveBeenCalled();
expect(createFlash).toHaveBeenCalled(); expect(wrapper.vm.setError).toHaveBeenCalled();
}); });
}); });
...@@ -335,9 +337,11 @@ describe('BoardForm', () => { ...@@ -335,9 +337,11 @@ describe('BoardForm', () => {
expect(visitUrl).toHaveBeenCalledWith('root'); expect(visitUrl).toHaveBeenCalledWith('root');
}); });
it('shows an error flash if GraphQL mutation fails', async () => { it('dispatches `setError` action when GraphQL mutation fails', async () => {
mutate = jest.fn().mockRejectedValue('Houston, we have a problem'); mutate = jest.fn().mockRejectedValue('Houston, we have a problem');
createComponent({ canAdminBoard: true, currentPage: formType.delete }); createComponent({ canAdminBoard: true, currentPage: formType.delete });
jest.spyOn(wrapper.vm, 'setError').mockImplementation(() => {});
findModal().vm.$emit('primary'); findModal().vm.$emit('primary');
await waitForPromises(); await waitForPromises();
...@@ -346,7 +350,7 @@ describe('BoardForm', () => { ...@@ -346,7 +350,7 @@ describe('BoardForm', () => {
await waitForPromises(); await waitForPromises();
expect(visitUrl).not.toHaveBeenCalled(); expect(visitUrl).not.toHaveBeenCalled();
expect(createFlash).toHaveBeenCalled(); expect(wrapper.vm.setError).toHaveBeenCalled();
}); });
}); });
}); });
...@@ -3,15 +3,12 @@ import { shallowMount } from '@vue/test-utils'; ...@@ -3,15 +3,12 @@ import { shallowMount } from '@vue/test-utils';
import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue'; import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue';
import BoardSidebarDueDate from '~/boards/components/sidebar/board_sidebar_due_date.vue'; import BoardSidebarDueDate from '~/boards/components/sidebar/board_sidebar_due_date.vue';
import { createStore } from '~/boards/stores'; import { createStore } from '~/boards/stores';
import createFlash from '~/flash';
const TEST_DUE_DATE = '2020-02-20'; const TEST_DUE_DATE = '2020-02-20';
const TEST_FORMATTED_DUE_DATE = 'Feb 20, 2020'; const TEST_FORMATTED_DUE_DATE = 'Feb 20, 2020';
const TEST_PARSED_DATE = new Date(2020, 1, 20); const TEST_PARSED_DATE = new Date(2020, 1, 20);
const TEST_ISSUE = { id: 'gid://gitlab/Issue/1', iid: 9, dueDate: null, referencePath: 'h/b#2' }; const TEST_ISSUE = { id: 'gid://gitlab/Issue/1', iid: 9, dueDate: null, referencePath: 'h/b#2' };
jest.mock('~/flash');
describe('~/boards/components/sidebar/board_sidebar_due_date.vue', () => { describe('~/boards/components/sidebar/board_sidebar_due_date.vue', () => {
let wrapper; let wrapper;
let store; let store;
...@@ -124,6 +121,7 @@ describe('~/boards/components/sidebar/board_sidebar_due_date.vue', () => { ...@@ -124,6 +121,7 @@ describe('~/boards/components/sidebar/board_sidebar_due_date.vue', () => {
jest.spyOn(wrapper.vm, 'setActiveIssueDueDate').mockImplementation(() => { jest.spyOn(wrapper.vm, 'setActiveIssueDueDate').mockImplementation(() => {
throw new Error(['failed mutation']); throw new Error(['failed mutation']);
}); });
jest.spyOn(wrapper.vm, 'setError').mockImplementation(() => {});
findDatePicker().vm.$emit('input', 'Invalid date'); findDatePicker().vm.$emit('input', 'Invalid date');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
}); });
...@@ -131,7 +129,7 @@ describe('~/boards/components/sidebar/board_sidebar_due_date.vue', () => { ...@@ -131,7 +129,7 @@ describe('~/boards/components/sidebar/board_sidebar_due_date.vue', () => {
it('collapses sidebar and renders former issue due date', () => { it('collapses sidebar and renders former issue due date', () => {
expect(findCollapsed().isVisible()).toBe(true); expect(findCollapsed().isVisible()).toBe(true);
expect(findCollapsed().text()).toContain(TEST_FORMATTED_DUE_DATE); expect(findCollapsed().text()).toContain(TEST_FORMATTED_DUE_DATE);
expect(createFlash).toHaveBeenCalled(); expect(wrapper.vm.setError).toHaveBeenCalled();
}); });
}); });
}); });
...@@ -9,11 +9,8 @@ import { ...@@ -9,11 +9,8 @@ import {
import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue'; import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue';
import BoardSidebarLabelsSelect from '~/boards/components/sidebar/board_sidebar_labels_select.vue'; import BoardSidebarLabelsSelect from '~/boards/components/sidebar/board_sidebar_labels_select.vue';
import { createStore } from '~/boards/stores'; import { createStore } from '~/boards/stores';
import createFlash from '~/flash';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
jest.mock('~/flash');
const TEST_LABELS_PAYLOAD = TEST_LABELS.map((label) => ({ ...label, set: true })); const TEST_LABELS_PAYLOAD = TEST_LABELS.map((label) => ({ ...label, set: true }));
const TEST_LABELS_TITLES = TEST_LABELS.map((label) => label.title); const TEST_LABELS_TITLES = TEST_LABELS.map((label) => label.title);
...@@ -154,6 +151,7 @@ describe('~/boards/components/sidebar/board_sidebar_labels_select.vue', () => { ...@@ -154,6 +151,7 @@ describe('~/boards/components/sidebar/board_sidebar_labels_select.vue', () => {
jest.spyOn(wrapper.vm, 'setActiveBoardItemLabels').mockImplementation(() => { jest.spyOn(wrapper.vm, 'setActiveBoardItemLabels').mockImplementation(() => {
throw new Error(['failed mutation']); throw new Error(['failed mutation']);
}); });
jest.spyOn(wrapper.vm, 'setError').mockImplementation(() => {});
findLabelsSelect().vm.$emit('updateSelectedLabels', [{ id: '?' }]); findLabelsSelect().vm.$emit('updateSelectedLabels', [{ id: '?' }]);
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
}); });
...@@ -161,7 +159,7 @@ describe('~/boards/components/sidebar/board_sidebar_labels_select.vue', () => { ...@@ -161,7 +159,7 @@ describe('~/boards/components/sidebar/board_sidebar_labels_select.vue', () => {
it('collapses sidebar and renders former issue weight', () => { it('collapses sidebar and renders former issue weight', () => {
expect(findCollapsed().isVisible()).toBe(true); expect(findCollapsed().isVisible()).toBe(true);
expect(findLabelsTitles()).toEqual(TEST_LABELS_TITLES); expect(findLabelsTitles()).toEqual(TEST_LABELS_TITLES);
expect(createFlash).toHaveBeenCalled(); expect(wrapper.vm.setError).toHaveBeenCalled();
}); });
}); });
}); });
...@@ -4,12 +4,9 @@ import { mockMilestone as TEST_MILESTONE } from 'jest/boards/mock_data'; ...@@ -4,12 +4,9 @@ import { mockMilestone as TEST_MILESTONE } from 'jest/boards/mock_data';
import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue'; import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue';
import BoardSidebarMilestoneSelect from '~/boards/components/sidebar/board_sidebar_milestone_select.vue'; import BoardSidebarMilestoneSelect from '~/boards/components/sidebar/board_sidebar_milestone_select.vue';
import { createStore } from '~/boards/stores'; import { createStore } from '~/boards/stores';
import createFlash from '~/flash';
const TEST_ISSUE = { id: 'gid://gitlab/Issue/1', iid: 9, referencePath: 'h/b#2' }; const TEST_ISSUE = { id: 'gid://gitlab/Issue/1', iid: 9, referencePath: 'h/b#2' };
jest.mock('~/flash');
describe('~/boards/components/sidebar/board_sidebar_milestone_select.vue', () => { describe('~/boards/components/sidebar/board_sidebar_milestone_select.vue', () => {
let wrapper; let wrapper;
let store; let store;
...@@ -165,6 +162,7 @@ describe('~/boards/components/sidebar/board_sidebar_milestone_select.vue', () => ...@@ -165,6 +162,7 @@ describe('~/boards/components/sidebar/board_sidebar_milestone_select.vue', () =>
jest.spyOn(wrapper.vm, 'setActiveIssueMilestone').mockImplementation(() => { jest.spyOn(wrapper.vm, 'setActiveIssueMilestone').mockImplementation(() => {
throw new Error(['failed mutation']); throw new Error(['failed mutation']);
}); });
jest.spyOn(wrapper.vm, 'setError').mockImplementation(() => {});
findDropdownItem().vm.$emit('click'); findDropdownItem().vm.$emit('click');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
}); });
...@@ -172,7 +170,7 @@ describe('~/boards/components/sidebar/board_sidebar_milestone_select.vue', () => ...@@ -172,7 +170,7 @@ describe('~/boards/components/sidebar/board_sidebar_milestone_select.vue', () =>
it('collapses sidebar and renders former milestone', () => { it('collapses sidebar and renders former milestone', () => {
expect(findCollapsed().isVisible()).toBe(true); expect(findCollapsed().isVisible()).toBe(true);
expect(findCollapsed().text()).toContain(testMilestone.title); expect(findCollapsed().text()).toContain(testMilestone.title);
expect(createFlash).toHaveBeenCalled(); expect(wrapper.vm.setError).toHaveBeenCalled();
}); });
}); });
}); });
...@@ -5,11 +5,8 @@ import Vuex from 'vuex'; ...@@ -5,11 +5,8 @@ import Vuex from 'vuex';
import BoardSidebarSubscription from '~/boards/components/sidebar/board_sidebar_subscription.vue'; import BoardSidebarSubscription from '~/boards/components/sidebar/board_sidebar_subscription.vue';
import { createStore } from '~/boards/stores'; import { createStore } from '~/boards/stores';
import * as types from '~/boards/stores/mutation_types'; import * as types from '~/boards/stores/mutation_types';
import createFlash from '~/flash';
import { mockActiveIssue } from '../../mock_data'; import { mockActiveIssue } from '../../mock_data';
jest.mock('~/flash.js');
Vue.use(Vuex); Vue.use(Vuex);
describe('~/boards/components/sidebar/board_sidebar_subscription_spec.vue', () => { describe('~/boards/components/sidebar/board_sidebar_subscription_spec.vue', () => {
...@@ -153,13 +150,15 @@ describe('~/boards/components/sidebar/board_sidebar_subscription_spec.vue', () = ...@@ -153,13 +150,15 @@ describe('~/boards/components/sidebar/board_sidebar_subscription_spec.vue', () =
jest.spyOn(wrapper.vm, 'setActiveItemSubscribed').mockImplementation(async () => { jest.spyOn(wrapper.vm, 'setActiveItemSubscribed').mockImplementation(async () => {
throw new Error(); throw new Error();
}); });
jest.spyOn(wrapper.vm, 'setError').mockImplementation(() => {});
findToggle().trigger('click'); findToggle().trigger('click');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(createFlash).toHaveBeenNthCalledWith(1, { expect(wrapper.vm.setError).toHaveBeenCalled();
message: wrapper.vm.$options.i18n.updateSubscribedErrorMessage, expect(wrapper.vm.setError.mock.calls[0][0].message).toBe(
}); wrapper.vm.$options.i18n.updateSubscribedErrorMessage,
);
}); });
}); });
}); });
...@@ -3,7 +3,6 @@ import { shallowMount } from '@vue/test-utils'; ...@@ -3,7 +3,6 @@ import { shallowMount } from '@vue/test-utils';
import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue'; import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue';
import BoardSidebarTitle from '~/boards/components/sidebar/board_sidebar_title.vue'; import BoardSidebarTitle from '~/boards/components/sidebar/board_sidebar_title.vue';
import { createStore } from '~/boards/stores'; import { createStore } from '~/boards/stores';
import createFlash from '~/flash';
const TEST_TITLE = 'New item title'; const TEST_TITLE = 'New item title';
const TEST_ISSUE_A = { const TEST_ISSUE_A = {
...@@ -19,8 +18,6 @@ const TEST_ISSUE_B = { ...@@ -19,8 +18,6 @@ const TEST_ISSUE_B = {
referencePath: 'h/b#2', referencePath: 'h/b#2',
}; };
jest.mock('~/flash');
describe('~/boards/components/sidebar/board_sidebar_title.vue', () => { describe('~/boards/components/sidebar/board_sidebar_title.vue', () => {
let wrapper; let wrapper;
let store; let store;
...@@ -168,6 +165,7 @@ describe('~/boards/components/sidebar/board_sidebar_title.vue', () => { ...@@ -168,6 +165,7 @@ describe('~/boards/components/sidebar/board_sidebar_title.vue', () => {
jest.spyOn(wrapper.vm, 'setActiveItemTitle').mockImplementation(() => { jest.spyOn(wrapper.vm, 'setActiveItemTitle').mockImplementation(() => {
throw new Error(['failed mutation']); throw new Error(['failed mutation']);
}); });
jest.spyOn(wrapper.vm, 'setError').mockImplementation(() => {});
findFormInput().vm.$emit('input', 'Invalid title'); findFormInput().vm.$emit('input', 'Invalid title');
findForm().vm.$emit('submit', { preventDefault: () => {} }); findForm().vm.$emit('submit', { preventDefault: () => {} });
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
...@@ -176,7 +174,7 @@ describe('~/boards/components/sidebar/board_sidebar_title.vue', () => { ...@@ -176,7 +174,7 @@ describe('~/boards/components/sidebar/board_sidebar_title.vue', () => {
it('collapses sidebar and renders former item title', () => { it('collapses sidebar and renders former item title', () => {
expect(findCollapsed().isVisible()).toBe(true); expect(findCollapsed().isVisible()).toBe(true);
expect(findTitle().text()).toContain(TEST_ISSUE_B.title); expect(findTitle().text()).toContain(TEST_ISSUE_B.title);
expect(createFlash).toHaveBeenCalled(); expect(wrapper.vm.setError).toHaveBeenCalled();
}); });
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment