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/boards/stores/actions_spec.js')
-rw-r--r--spec/frontend/boards/stores/actions_spec.js127
1 files changed, 107 insertions, 20 deletions
diff --git a/spec/frontend/boards/stores/actions_spec.js b/spec/frontend/boards/stores/actions_spec.js
index 32d0e7ae886..80d98c5eb6b 100644
--- a/spec/frontend/boards/stores/actions_spec.js
+++ b/spec/frontend/boards/stores/actions_spec.js
@@ -5,7 +5,7 @@ import {
formatBoardLists,
formatIssueInput,
} from '~/boards/boards_util';
-import { inactiveId } from '~/boards/constants';
+import { inactiveId, ISSUABLE } from '~/boards/constants';
import destroyBoardListMutation from '~/boards/graphql/board_list_destroy.mutation.graphql';
import issueCreateMutation from '~/boards/graphql/issue_create.mutation.graphql';
import issueMoveListMutation from '~/boards/graphql/issue_move_list.mutation.graphql';
@@ -112,6 +112,15 @@ describe('setActiveId', () => {
});
describe('fetchLists', () => {
+ it('should dispatch fetchIssueLists action', () => {
+ testAction({
+ action: actions.fetchLists,
+ expectedActions: [{ type: 'fetchIssueLists' }],
+ });
+ });
+});
+
+describe('fetchIssueLists', () => {
const state = {
fullPath: 'gitlab-org',
boardId: '1',
@@ -138,7 +147,7 @@ describe('fetchLists', () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction(
- actions.fetchLists,
+ actions.fetchIssueLists,
{},
state,
[
@@ -152,6 +161,23 @@ describe('fetchLists', () => {
);
});
+ it('should commit mutations RECEIVE_BOARD_LISTS_FAILURE on failure', (done) => {
+ jest.spyOn(gqlClient, 'query').mockResolvedValue(Promise.reject());
+
+ testAction(
+ actions.fetchIssueLists,
+ {},
+ state,
+ [
+ {
+ type: types.RECEIVE_BOARD_LISTS_FAILURE,
+ },
+ ],
+ [],
+ done,
+ );
+ });
+
it('dispatch createList action when backlog list does not exist and is not hidden', (done) => {
queryResponse = {
data: {
@@ -168,7 +194,7 @@ describe('fetchLists', () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction(
- actions.fetchLists,
+ actions.fetchIssueLists,
{},
state,
[
@@ -490,7 +516,7 @@ describe('removeList', () => {
});
});
-describe('fetchIssuesForList', () => {
+describe('fetchItemsForList', () => {
const listId = mockLists[0].id;
const state = {
@@ -533,21 +559,21 @@ describe('fetchIssuesForList', () => {
[listId]: pageInfo,
};
- it('should commit mutations REQUEST_ISSUES_FOR_LIST and RECEIVE_ISSUES_FOR_LIST_SUCCESS on success', (done) => {
+ it('should commit mutations REQUEST_ITEMS_FOR_LIST and RECEIVE_ITEMS_FOR_LIST_SUCCESS on success', (done) => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction(
- actions.fetchIssuesForList,
+ actions.fetchItemsForList,
{ listId },
state,
[
{
- type: types.REQUEST_ISSUES_FOR_LIST,
+ type: types.REQUEST_ITEMS_FOR_LIST,
payload: { listId, fetchNext: false },
},
{
- type: types.RECEIVE_ISSUES_FOR_LIST_SUCCESS,
- payload: { listIssues: formattedIssues, listPageInfo, listId },
+ type: types.RECEIVE_ITEMS_FOR_LIST_SUCCESS,
+ payload: { listItems: formattedIssues, listPageInfo, listId },
},
],
[],
@@ -555,19 +581,19 @@ describe('fetchIssuesForList', () => {
);
});
- it('should commit mutations REQUEST_ISSUES_FOR_LIST and RECEIVE_ISSUES_FOR_LIST_FAILURE on failure', (done) => {
+ it('should commit mutations REQUEST_ITEMS_FOR_LIST and RECEIVE_ITEMS_FOR_LIST_FAILURE on failure', (done) => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(Promise.reject());
testAction(
- actions.fetchIssuesForList,
+ actions.fetchItemsForList,
{ listId },
state,
[
{
- type: types.REQUEST_ISSUES_FOR_LIST,
+ type: types.REQUEST_ITEMS_FOR_LIST,
payload: { listId, fetchNext: false },
},
- { type: types.RECEIVE_ISSUES_FOR_LIST_FAILURE, payload: listId },
+ { type: types.RECEIVE_ITEMS_FOR_LIST_FAILURE, payload: listId },
],
[],
done,
@@ -598,8 +624,8 @@ describe('moveIssue', () => {
boardType: 'group',
disabled: false,
boardLists: mockLists,
- issuesByListId: listIssues,
- issues,
+ boardItemsByListId: listIssues,
+ boardItems: issues,
};
it('should commit MOVE_ISSUE mutation and MOVE_ISSUE_SUCCESS mutation when successful', (done) => {
@@ -879,7 +905,7 @@ describe('addListIssue', () => {
});
describe('setActiveIssueLabels', () => {
- const state = { issues: { [mockIssue.id]: mockIssue } };
+ const state = { boardItems: { [mockIssue.id]: mockIssue } };
const getters = { activeIssue: mockIssue };
const testLabelIds = labels.map((label) => label.id);
const input = {
@@ -924,7 +950,7 @@ describe('setActiveIssueLabels', () => {
});
describe('setActiveIssueDueDate', () => {
- const state = { issues: { [mockIssue.id]: mockIssue } };
+ const state = { boardItems: { [mockIssue.id]: mockIssue } };
const getters = { activeIssue: mockIssue };
const testDueDate = '2020-02-20';
const input = {
@@ -975,7 +1001,7 @@ describe('setActiveIssueDueDate', () => {
});
describe('setActiveIssueSubscribed', () => {
- const state = { issues: { [mockActiveIssue.id]: mockActiveIssue } };
+ const state = { boardItems: { [mockActiveIssue.id]: mockActiveIssue } };
const getters = { activeIssue: mockActiveIssue };
const subscribedState = true;
const input = {
@@ -1026,7 +1052,7 @@ describe('setActiveIssueSubscribed', () => {
});
describe('setActiveIssueMilestone', () => {
- const state = { issues: { [mockIssue.id]: mockIssue } };
+ const state = { boardItems: { [mockIssue.id]: mockIssue } };
const getters = { activeIssue: mockIssue };
const testMilestone = {
...mockMilestone,
@@ -1080,7 +1106,7 @@ describe('setActiveIssueMilestone', () => {
});
describe('setActiveIssueTitle', () => {
- const state = { issues: { [mockIssue.id]: mockIssue } };
+ const state = { boardItems: { [mockIssue.id]: mockIssue } };
const getters = { activeIssue: mockIssue };
const testTitle = 'Test Title';
const input = {
@@ -1220,6 +1246,7 @@ describe('setSelectedProject', () => {
describe('toggleBoardItemMultiSelection', () => {
const boardItem = mockIssue;
+ const boardItem2 = mockIssue2;
it('should commit mutation ADD_BOARD_ITEM_TO_SELECTION if item is not on selection state', () => {
testAction(
@@ -1250,6 +1277,66 @@ describe('toggleBoardItemMultiSelection', () => {
[],
);
});
+
+ it('should additionally commit mutation ADD_BOARD_ITEM_TO_SELECTION for active issue and dispatch unsetActiveId', () => {
+ testAction(
+ actions.toggleBoardItemMultiSelection,
+ boardItem2,
+ { activeId: mockActiveIssue.id, activeIssue: mockActiveIssue, selectedBoardItems: [] },
+ [
+ {
+ type: types.ADD_BOARD_ITEM_TO_SELECTION,
+ payload: mockActiveIssue,
+ },
+ {
+ type: types.ADD_BOARD_ITEM_TO_SELECTION,
+ payload: boardItem2,
+ },
+ ],
+ [{ type: 'unsetActiveId' }],
+ );
+ });
+});
+
+describe('resetBoardItemMultiSelection', () => {
+ it('should commit mutation RESET_BOARD_ITEM_SELECTION', () => {
+ testAction({
+ action: actions.resetBoardItemMultiSelection,
+ state: { selectedBoardItems: [mockIssue] },
+ expectedMutations: [
+ {
+ type: types.RESET_BOARD_ITEM_SELECTION,
+ },
+ ],
+ });
+ });
+});
+
+describe('toggleBoardItem', () => {
+ it('should dispatch resetBoardItemMultiSelection and unsetActiveId when boardItem is the active item', () => {
+ testAction({
+ action: actions.toggleBoardItem,
+ payload: { boardItem: mockIssue },
+ state: {
+ activeId: mockIssue.id,
+ },
+ expectedActions: [{ type: 'resetBoardItemMultiSelection' }, { type: 'unsetActiveId' }],
+ });
+ });
+
+ it('should dispatch resetBoardItemMultiSelection and setActiveId when boardItem is not the active item', () => {
+ testAction({
+ action: actions.toggleBoardItem,
+ payload: { boardItem: mockIssue },
+ state: {
+ activeId: inactiveId,
+ },
+ expectedActions: [
+ { type: 'resetBoardItemMultiSelection' },
+ { type: 'setActiveId', payload: { id: mockIssue.id, sidebarType: ISSUABLE } },
+ ],
+ });
+ });
});
describe('fetchBacklog', () => {