Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/notes/stores/actions_spec.js')
-rw-r--r--spec/frontend/notes/stores/actions_spec.js66
1 files changed, 2 insertions, 64 deletions
diff --git a/spec/frontend/notes/stores/actions_spec.js b/spec/frontend/notes/stores/actions_spec.js
index 1852108b39f..f972ff0d2e4 100644
--- a/spec/frontend/notes/stores/actions_spec.js
+++ b/spec/frontend/notes/stores/actions_spec.js
@@ -3,6 +3,7 @@ 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 { EVENT_ISSUABLE_VUE_APP_CHANGE } from '~/issuable/constants';
import axios from '~/lib/utils/axios_utils';
import * as notesConstants from '~/notes/constants';
import createStore from '~/notes/stores';
@@ -10,7 +11,6 @@ import * as actions from '~/notes/stores/actions';
import * as mutationTypes from '~/notes/stores/mutation_types';
import mutations from '~/notes/stores/mutations';
import * as utils from '~/notes/stores/utils';
-import updateIssueConfidentialMutation from '~/sidebar/components/confidential/mutations/update_issue_confidential.mutation.graphql';
import updateIssueLockMutation from '~/sidebar/components/lock/mutations/update_issue_lock.mutation.graphql';
import updateMergeRequestLockMutation from '~/sidebar/components/lock/mutations/update_merge_request_lock.mutation.graphql';
import mrWidgetEventHub from '~/vue_merge_request_widget/event_hub';
@@ -203,7 +203,7 @@ describe('Actions Notes Store', () => {
describe('emitStateChangedEvent', () => {
it('emits an event on the document', () => {
- document.addEventListener('issuable_vue_app:change', (event) => {
+ document.addEventListener(EVENT_ISSUABLE_VUE_APP_CHANGE, (event) => {
expect(event.detail.data).toEqual({ id: '1', state: 'closed' });
expect(event.detail.isClosed).toEqual(false);
});
@@ -1276,68 +1276,6 @@ describe('Actions Notes Store', () => {
});
});
- describe('updateConfidentialityOnIssuable', () => {
- state = { noteableData: { confidential: false } };
- const iid = '1';
- const projectPath = 'full/path';
- const getters = { getNoteableData: { iid } };
- const actionArgs = { fullPath: projectPath, confidential: true };
- const confidential = true;
-
- beforeEach(() => {
- jest
- .spyOn(utils.gqClient, 'mutate')
- .mockResolvedValue({ data: { issueSetConfidential: { issue: { confidential } } } });
- });
-
- it('calls gqClient mutation one time', () => {
- actions.updateConfidentialityOnIssuable({ commit: () => {}, state, getters }, actionArgs);
-
- expect(utils.gqClient.mutate).toHaveBeenCalledTimes(1);
- });
-
- it('calls gqClient mutation with the correct values', () => {
- actions.updateConfidentialityOnIssuable({ commit: () => {}, state, getters }, actionArgs);
-
- expect(utils.gqClient.mutate).toHaveBeenCalledWith({
- mutation: updateIssueConfidentialMutation,
- variables: { input: { iid, projectPath, confidential } },
- });
- });
-
- describe('on success of mutation', () => {
- it('calls commit with the correct values', () => {
- const commitSpy = jest.fn();
-
- return actions
- .updateConfidentialityOnIssuable({ commit: commitSpy, state, getters }, actionArgs)
- .then(() => {
- expect(Flash).not.toHaveBeenCalled();
- expect(commitSpy).toHaveBeenCalledWith(
- mutationTypes.SET_ISSUE_CONFIDENTIAL,
- confidential,
- );
- });
- });
- });
-
- describe('on user recoverable error', () => {
- it('sends the error to Flash', () => {
- const error = 'error';
-
- jest
- .spyOn(utils.gqClient, 'mutate')
- .mockResolvedValue({ data: { issueSetConfidential: { errors: [error] } } });
-
- return actions
- .updateConfidentialityOnIssuable({ commit: () => {}, state, getters }, actionArgs)
- .then(() => {
- expect(Flash).toHaveBeenCalledWith(error, 'alert');
- });
- });
- });
- });
-
describe.each`
issuableType
${'issue'} | ${'merge_request'}