diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-10 12:08:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-10 12:08:27 +0300 |
commit | 1385b54a3e44a90a463d4975bd639089be056778 (patch) | |
tree | 4ba1fbd8e29115ba21472d5ebc88dfa6d9d637a4 /spec/frontend/boards/stores/actions_spec.js | |
parent | 8d8b960cece096fb6af9ada2ca8c88fc48b5476c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/boards/stores/actions_spec.js')
-rw-r--r-- | spec/frontend/boards/stores/actions_spec.js | 112 |
1 files changed, 110 insertions, 2 deletions
diff --git a/spec/frontend/boards/stores/actions_spec.js b/spec/frontend/boards/stores/actions_spec.js index 17792a8f597..4eb1a370a9f 100644 --- a/spec/frontend/boards/stores/actions_spec.js +++ b/spec/frontend/boards/stores/actions_spec.js @@ -1,5 +1,13 @@ import testAction from 'helpers/vuex_action_helper'; -import { mockListsWithModel, mockLists, mockIssue } from '../mock_data'; +import { + mockListsWithModel, + mockLists, + mockIssue, + mockIssue2, + mockIssueWithModel, + mockIssue2WithModel, + rawIssue, +} from '../mock_data'; import actions, { gqlClient } from '~/boards/stores/actions'; import * as types from '~/boards/stores/mutation_types'; import { inactiveId, ListType } from '~/boards/constants'; @@ -229,7 +237,107 @@ describe('fetchIssuesForList', () => { }); describe('moveIssue', () => { - expectNotImplemented(actions.moveIssue); + const listIssues = { + 'gid://gitlab/List/1': [mockIssue.id, mockIssue2.id], + 'gid://gitlab/List/2': [], + }; + + const issues = { + '1': mockIssueWithModel, + '2': mockIssue2WithModel, + }; + + const state = { + endpoints: { fullPath: 'gitlab-org', boardId: '1' }, + boardType: 'group', + disabled: false, + boardLists: mockListsWithModel, + issuesByListId: listIssues, + issues, + }; + + it('should commit MOVE_ISSUE mutation and MOVE_ISSUE_SUCCESS mutation when successful', done => { + jest.spyOn(gqlClient, 'mutate').mockResolvedValue({ + data: { + issueMoveList: { + issue: rawIssue, + errors: [], + }, + }, + }); + + testAction( + actions.moveIssue, + { + issueId: mockIssue.id, + issueIid: mockIssue.iid, + issuePath: mockIssue.referencePath, + fromListId: 'gid://gitlab/List/1', + toListId: 'gid://gitlab/List/2', + }, + state, + [ + { + type: types.MOVE_ISSUE, + payload: { + originalIssue: mockIssueWithModel, + fromListId: 'gid://gitlab/List/1', + toListId: 'gid://gitlab/List/2', + }, + }, + { + type: types.MOVE_ISSUE_SUCCESS, + payload: { issue: rawIssue }, + }, + ], + [], + done, + ); + }); + + it('should commit MOVE_ISSUE mutation and MOVE_ISSUE_FAILURE mutation when unsuccessful', done => { + jest.spyOn(gqlClient, 'mutate').mockResolvedValue({ + data: { + issueMoveList: { + issue: {}, + errors: [{ foo: 'bar' }], + }, + }, + }); + + testAction( + actions.moveIssue, + { + issueId: mockIssue.id, + issueIid: mockIssue.iid, + issuePath: mockIssue.referencePath, + fromListId: 'gid://gitlab/List/1', + toListId: 'gid://gitlab/List/2', + }, + state, + [ + { + type: types.MOVE_ISSUE, + payload: { + originalIssue: mockIssueWithModel, + fromListId: 'gid://gitlab/List/1', + toListId: 'gid://gitlab/List/2', + }, + }, + { + type: types.MOVE_ISSUE_FAILURE, + payload: { + originalIssue: mockIssueWithModel, + fromListId: 'gid://gitlab/List/1', + toListId: 'gid://gitlab/List/2', + originalIndex: 0, + }, + }, + ], + [], + done, + ); + }); }); describe('createNewIssue', () => { |