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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-04 12:09:59 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-04 12:09:59 +0300
commite2c471038ab2b4f09487c1feb74520f74f834986 (patch)
tree21d8ea3ce88222c1419adaa2f79012326f29621e /spec/frontend/boards/stores/actions_spec.js
parent04a893be75405b262c0899bd09eb79438210e632 (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.js81
1 files changed, 58 insertions, 23 deletions
diff --git a/spec/frontend/boards/stores/actions_spec.js b/spec/frontend/boards/stores/actions_spec.js
index afc8f20b507..34e24fe0a1c 100644
--- a/spec/frontend/boards/stores/actions_spec.js
+++ b/spec/frontend/boards/stores/actions_spec.js
@@ -1,15 +1,21 @@
import * as Sentry from '@sentry/browser';
+import {
+ inactiveId,
+ ISSUABLE,
+ ListType,
+ issuableTypes,
+ BoardType,
+ listsQuery,
+} from 'ee_else_ce/boards/constants';
import issueMoveListMutation from 'ee_else_ce/boards/graphql/issue_move_list.mutation.graphql';
import testAction from 'helpers/vuex_action_helper';
import {
- fullBoardId,
formatListIssues,
formatBoardLists,
formatIssueInput,
formatIssue,
getMoveData,
} from '~/boards/boards_util';
-import { inactiveId, ISSUABLE, ListType, issuableTypes } from '~/boards/constants';
import destroyBoardListMutation from '~/boards/graphql/board_list_destroy.mutation.graphql';
import issueCreateMutation from '~/boards/graphql/issue_create.mutation.graphql';
import actions, { gqlClient } from '~/boards/stores/actions';
@@ -132,20 +138,12 @@ describe('setActiveId', () => {
});
describe('fetchLists', () => {
- it('should dispatch fetchIssueLists action', () => {
- testAction({
- action: actions.fetchLists,
- expectedActions: [{ type: 'fetchIssueLists' }],
- });
- });
-});
-
-describe('fetchIssueLists', () => {
- const state = {
+ let state = {
fullPath: 'gitlab-org',
- boardId: '1',
+ fullBoardId: 'gid://gitlab/Board/1',
filterParams: {},
boardType: 'group',
+ issuableType: 'issue',
};
let queryResponse = {
@@ -167,7 +165,7 @@ describe('fetchIssueLists', () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction(
- actions.fetchIssueLists,
+ actions.fetchLists,
{},
state,
[
@@ -185,7 +183,7 @@ describe('fetchIssueLists', () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(Promise.reject());
testAction(
- actions.fetchIssueLists,
+ actions.fetchLists,
{},
state,
[
@@ -214,7 +212,7 @@ describe('fetchIssueLists', () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction(
- actions.fetchIssueLists,
+ actions.fetchLists,
{},
state,
[
@@ -227,6 +225,43 @@ describe('fetchIssueLists', () => {
done,
);
});
+
+ it.each`
+ issuableType | boardType | fullBoardId | isGroup | isProject
+ ${issuableTypes.issue} | ${BoardType.group} | ${'gid://gitlab/Board/1'} | ${true} | ${false}
+ ${issuableTypes.issue} | ${BoardType.project} | ${'gid://gitlab/Board/1'} | ${false} | ${true}
+ `(
+ 'calls $issuableType query with correct variables',
+ async ({ issuableType, boardType, fullBoardId, isGroup, isProject }) => {
+ const commit = jest.fn();
+ const dispatch = jest.fn();
+
+ state = {
+ fullPath: 'gitlab-org',
+ fullBoardId,
+ filterParams: {},
+ boardType,
+ issuableType,
+ };
+
+ const variables = {
+ query: listsQuery[issuableType].query,
+ variables: {
+ fullPath: 'gitlab-org',
+ boardId: fullBoardId,
+ filters: {},
+ isGroup,
+ isProject,
+ },
+ };
+
+ jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
+
+ await actions.fetchLists({ commit, state, dispatch });
+
+ expect(gqlClient.query).toHaveBeenCalledWith(variables);
+ },
+ );
});
describe('createList', () => {
@@ -248,7 +283,7 @@ describe('createIssueList', () => {
beforeEach(() => {
state = {
fullPath: 'gitlab-org',
- boardId: '1',
+ fullBoardId: 'gid://gitlab/Board/1',
boardType: 'group',
disabled: false,
boardLists: [{ type: 'closed' }],
@@ -378,7 +413,7 @@ describe('moveList', () => {
const state = {
fullPath: 'gitlab-org',
- boardId: '1',
+ fullBoardId: 'gid://gitlab/Board/1',
boardType: 'group',
disabled: false,
boardLists: initialBoardListsState,
@@ -421,7 +456,7 @@ describe('moveList', () => {
const state = {
fullPath: 'gitlab-org',
- boardId: '1',
+ fullBoardId: 'gid://gitlab/Board/1',
boardType: 'group',
disabled: false,
boardLists: initialBoardListsState,
@@ -455,7 +490,7 @@ describe('updateList', () => {
const state = {
fullPath: 'gitlab-org',
- boardId: '1',
+ fullBoardId: 'gid://gitlab/Board/1',
boardType: 'group',
disabled: false,
boardLists: [{ type: 'closed' }],
@@ -573,7 +608,7 @@ describe('fetchItemsForList', () => {
const state = {
fullPath: 'gitlab-org',
- boardId: '1',
+ fullBoardId: 'gid://gitlab/Board/1',
filterParams: {},
boardType: 'group',
};
@@ -960,7 +995,7 @@ describe('updateIssueOrder', () => {
const state = {
boardItems: issues,
- boardId: 'gid://gitlab/Board/1',
+ fullBoardId: 'gid://gitlab/Board/1',
};
const moveData = {
@@ -974,7 +1009,7 @@ describe('updateIssueOrder', () => {
mutation: issueMoveListMutation,
variables: {
projectPath: getProjectPath(mockIssue.referencePath),
- boardId: fullBoardId(state.boardId),
+ boardId: state.fullBoardId,
iid: mockIssue.iid,
fromListId: 1,
toListId: 2,