Commit cf5fa183 authored by Florie Guibert's avatar Florie Guibert

Display Epics in Epic Board

Rename state and mutations from issues to be more generic
parent 9c8f090c
...@@ -36,11 +36,11 @@ export function formatIssue(issue) { ...@@ -36,11 +36,11 @@ export function formatIssue(issue) {
} }
export function formatListIssues(listIssues) { export function formatListIssues(listIssues) {
const issues = {}; const boardItems = {};
let listIssuesCount; let listItemsCount;
const listData = listIssues.nodes.reduce((map, list) => { const listData = listIssues.nodes.reduce((map, list) => {
listIssuesCount = list.issues.count; listItemsCount = list.issues.count;
let sortedIssues = list.issues.edges.map((issueNode) => ({ let sortedIssues = list.issues.edges.map((issueNode) => ({
...issueNode.node, ...issueNode.node,
})); }));
...@@ -58,14 +58,14 @@ export function formatListIssues(listIssues) { ...@@ -58,14 +58,14 @@ export function formatListIssues(listIssues) {
assignees: i.assignees?.nodes || [], assignees: i.assignees?.nodes || [],
}; };
issues[id] = listIssue; boardItems[id] = listIssue;
return id; return id;
}), }),
}; };
}, {}); }, {});
return { listData, issues, listIssuesCount }; return { listData, boardItems, listItemsCount };
} }
export function formatListsPageInfo(lists) { export function formatListsPageInfo(lists) {
......
...@@ -32,12 +32,12 @@ export default { ...@@ -32,12 +32,12 @@ export default {
}, },
computed: { computed: {
...mapState(['filterParams', 'highlightedLists']), ...mapState(['filterParams', 'highlightedLists']),
...mapGetters(['getIssuesByList']), ...mapGetters(['getBoardItemsByList']),
highlighted() { highlighted() {
return this.highlightedLists.includes(this.list.id); return this.highlightedLists.includes(this.list.id);
}, },
listIssues() { listItems() {
return this.getIssuesByList(this.list.id); return this.getBoardItemsByList(this.list.id);
}, },
isListDraggable() { isListDraggable() {
return isListDraggable(this.list); return isListDraggable(this.list);
...@@ -87,7 +87,7 @@ export default { ...@@ -87,7 +87,7 @@ export default {
<board-list <board-list
ref="board-list" ref="board-list"
:disabled="disabled" :disabled="disabled"
:issues="listIssues" :board-items="listItems"
:list="list" :list="list"
:can-admin-list="canAdminList" :can-admin-list="canAdminList"
/> />
......
...@@ -12,8 +12,8 @@ import BoardNewIssue from './board_new_issue.vue'; ...@@ -12,8 +12,8 @@ import BoardNewIssue from './board_new_issue.vue';
export default { export default {
name: 'BoardList', name: 'BoardList',
i18n: { i18n: {
loadingIssues: __('Loading issues'), loading: __('Loading'),
loadingMoreissues: __('Loading more issues'), loadingMoreboardItems: __('Loading more'),
showingAllIssues: __('Showing all issues'), showingAllIssues: __('Showing all issues'),
}, },
components: { components: {
...@@ -30,7 +30,7 @@ export default { ...@@ -30,7 +30,7 @@ export default {
type: Object, type: Object,
required: true, required: true,
}, },
issues: { boardItems: {
type: Array, type: Array,
required: true, required: true,
}, },
...@@ -51,11 +51,11 @@ export default { ...@@ -51,11 +51,11 @@ export default {
...mapState(['pageInfoByListId', 'listsFlags']), ...mapState(['pageInfoByListId', 'listsFlags']),
paginatedIssueText() { paginatedIssueText() {
return sprintf(__('Showing %{pageSize} of %{total} issues'), { return sprintf(__('Showing %{pageSize} of %{total} issues'), {
pageSize: this.issues.length, pageSize: this.boardItems.length,
total: this.list.issuesCount, total: this.list.issuesCount,
}); });
}, },
issuesSizeExceedsMax() { boardItemsSizeExceedsMax() {
return this.list.maxIssueCount > 0 && this.list.issuesCount > this.list.maxIssueCount; return this.list.maxIssueCount > 0 && this.list.issuesCount > this.list.maxIssueCount;
}, },
hasNextPage() { hasNextPage() {
...@@ -72,7 +72,7 @@ export default { ...@@ -72,7 +72,7 @@ export default {
return this.canAdminList ? this.$refs.list.$el : this.$refs.list; return this.canAdminList ? this.$refs.list.$el : this.$refs.list;
}, },
showingAllIssues() { showingAllIssues() {
return this.issues.length === this.list.issuesCount; return this.boardItems.length === this.list.issuesCount;
}, },
treeRootWrapper() { treeRootWrapper() {
return this.canAdminList ? Draggable : 'ul'; return this.canAdminList ? Draggable : 'ul';
...@@ -85,14 +85,14 @@ export default { ...@@ -85,14 +85,14 @@ export default {
tag: 'ul', tag: 'ul',
'ghost-class': 'board-card-drag-active', 'ghost-class': 'board-card-drag-active',
'data-list-id': this.list.id, 'data-list-id': this.list.id,
value: this.issues, value: this.boardItems,
}; };
return this.canAdminList ? options : {}; return this.canAdminList ? options : {};
}, },
}, },
watch: { watch: {
issues() { boardItems() {
this.$nextTick(() => { this.$nextTick(() => {
this.showCount = this.scrollHeight() > Math.ceil(this.listHeight()); this.showCount = this.scrollHeight() > Math.ceil(this.listHeight());
}); });
...@@ -201,7 +201,7 @@ export default { ...@@ -201,7 +201,7 @@ export default {
<div <div
v-if="loading" v-if="loading"
class="gl-mt-4 gl-text-center" class="gl-mt-4 gl-text-center"
:aria-label="$options.i18n.loadingIssues" :aria-label="$options.i18n.loading"
data-testid="board_list_loading" data-testid="board_list_loading"
> >
<gl-loading-icon /> <gl-loading-icon />
...@@ -214,25 +214,25 @@ export default { ...@@ -214,25 +214,25 @@ export default {
v-bind="treeRootOptions" v-bind="treeRootOptions"
:data-board="list.id" :data-board="list.id"
:data-board-type="list.listType" :data-board-type="list.listType"
:class="{ 'bg-danger-100': issuesSizeExceedsMax }" :class="{ 'bg-danger-100': boardItemsSizeExceedsMax }"
class="board-list gl-w-full gl-h-full gl-list-style-none gl-mb-0 gl-p-2 js-board-list" class="board-list gl-w-full gl-h-full gl-list-style-none gl-mb-0 gl-p-2 js-board-list"
data-testid="tree-root-wrapper" data-testid="tree-root-wrapper"
@start="handleDragOnStart" @start="handleDragOnStart"
@end="handleDragOnEnd" @end="handleDragOnEnd"
> >
<board-card <board-card
v-for="(issue, index) in issues" v-for="(item, index) in boardItems"
ref="issue" ref="issue"
:key="issue.id" :key="item.id"
:index="index" :index="index"
:list="list" :list="list"
:issue="issue" :issue="item"
:disabled="disabled" :disabled="disabled"
/> />
<li v-if="showCount" class="board-list-count gl-text-center" data-issue-id="-1"> <li v-if="showCount" class="board-list-count gl-text-center" data-issue-id="-1">
<gl-loading-icon <gl-loading-icon
v-if="loadingMore" v-if="loadingMore"
:label="$options.i18n.loadingMoreissues" :label="$options.i18n.loadingMoreboardItems"
data-testid="count-loading-icon" data-testid="count-loading-icon"
/> />
<span v-if="showingAllIssues">{{ $options.i18n.showingAllIssues }}</span> <span v-if="showingAllIssues">{{ $options.i18n.showingAllIssues }}</span>
......
...@@ -289,9 +289,9 @@ export default { ...@@ -289,9 +289,9 @@ export default {
}) })
.then(({ data }) => { .then(({ data }) => {
const { lists } = data[boardType]?.board; const { lists } = data[boardType]?.board;
const listIssues = formatListIssues(lists); const listItems = formatListIssues(lists);
const listPageInfo = formatListsPageInfo(lists); const listPageInfo = formatListsPageInfo(lists);
commit(types.RECEIVE_ITEMS_FOR_LIST_SUCCESS, { listIssues, listPageInfo, listId }); commit(types.RECEIVE_ITEMS_FOR_LIST_SUCCESS, { listItems, listPageInfo, listId });
}) })
.catch(() => commit(types.RECEIVE_ITEMS_FOR_LIST_FAILURE, listId)); .catch(() => commit(types.RECEIVE_ITEMS_FOR_LIST_FAILURE, listId));
}, },
...@@ -304,8 +304,8 @@ export default { ...@@ -304,8 +304,8 @@ export default {
{ state, commit }, { state, commit },
{ issueId, issueIid, issuePath, fromListId, toListId, moveBeforeId, moveAfterId }, { issueId, issueIid, issuePath, fromListId, toListId, moveBeforeId, moveAfterId },
) => { ) => {
const originalIssue = state.issues[issueId]; const originalIssue = state.boardItems[issueId];
const fromList = state.issuesByListId[fromListId]; const fromList = state.boardItemsByListId[fromListId];
const originalIndex = fromList.indexOf(Number(issueId)); const originalIndex = fromList.indexOf(Number(issueId));
commit(types.MOVE_ISSUE, { originalIssue, fromListId, toListId, moveBeforeId, moveAfterId }); commit(types.MOVE_ISSUE, { originalIssue, fromListId, toListId, moveBeforeId, moveAfterId });
......
...@@ -4,17 +4,17 @@ import { inactiveId } from '../constants'; ...@@ -4,17 +4,17 @@ import { inactiveId } from '../constants';
export default { export default {
isSidebarOpen: (state) => state.activeId !== inactiveId, isSidebarOpen: (state) => state.activeId !== inactiveId,
isSwimlanesOn: () => false, isSwimlanesOn: () => false,
getIssueById: (state) => (id) => { getBoardItemById: (state) => (id) => {
return state.issues[id] || {}; return state.boardItems[id] || {};
}, },
getIssuesByList: (state, getters) => (listId) => { getBoardItemsByList: (state, getters) => (listId) => {
const listIssueIds = state.issuesByListId[listId] || []; const listItemsIds = state.boardItemsByListId[listId] || [];
return listIssueIds.map((id) => getters.getIssueById(id)); return listItemsIds.map((id) => getters.getBoardItemById(id));
}, },
activeIssue: (state) => { activeIssue: (state) => {
return state.issues[state.activeId] || {}; return state.boardItems[state.activeId] || {};
}, },
groupPathForActiveIssue: (_, getters) => { groupPathForActiveIssue: (_, getters) => {
......
...@@ -11,13 +11,13 @@ const notImplemented = () => { ...@@ -11,13 +11,13 @@ const notImplemented = () => {
}; };
export const removeIssueFromList = ({ state, listId, issueId }) => { export const removeIssueFromList = ({ state, listId, issueId }) => {
Vue.set(state.issuesByListId, listId, pull(state.issuesByListId[listId], issueId)); Vue.set(state.boardItemsByListId, listId, pull(state.boardItemsByListId[listId], issueId));
const list = state.boardLists[listId]; const list = state.boardLists[listId];
Vue.set(state.boardLists, listId, { ...list, issuesCount: list.issuesCount - 1 }); Vue.set(state.boardLists, listId, { ...list, issuesCount: list.issuesCount - 1 });
}; };
export const addIssueToList = ({ state, listId, issueId, moveBeforeId, moveAfterId, atIndex }) => { export const addIssueToList = ({ state, listId, issueId, moveBeforeId, moveAfterId, atIndex }) => {
const listIssues = state.issuesByListId[listId]; const listIssues = state.boardItemsByListId[listId];
let newIndex = atIndex || 0; let newIndex = atIndex || 0;
if (moveBeforeId) { if (moveBeforeId) {
newIndex = listIssues.indexOf(moveBeforeId) + 1; newIndex = listIssues.indexOf(moveBeforeId) + 1;
...@@ -25,7 +25,7 @@ export const addIssueToList = ({ state, listId, issueId, moveBeforeId, moveAfter ...@@ -25,7 +25,7 @@ export const addIssueToList = ({ state, listId, issueId, moveBeforeId, moveAfter
newIndex = listIssues.indexOf(moveAfterId); newIndex = listIssues.indexOf(moveAfterId);
} }
listIssues.splice(newIndex, 0, issueId); listIssues.splice(newIndex, 0, issueId);
Vue.set(state.issuesByListId, listId, listIssues); Vue.set(state.boardItemsByListId, listId, listIssues);
const list = state.boardLists[listId]; const list = state.boardLists[listId];
Vue.set(state.boardLists, listId, { ...list, issuesCount: list.issuesCount + 1 }); Vue.set(state.boardLists, listId, { ...list, issuesCount: list.issuesCount + 1 });
}; };
...@@ -108,14 +108,13 @@ export default { ...@@ -108,14 +108,13 @@ export default {
Vue.set(state.listsFlags, listId, { [fetchNext ? 'isLoadingMore' : 'isLoading']: true }); Vue.set(state.listsFlags, listId, { [fetchNext ? 'isLoadingMore' : 'isLoading']: true });
}, },
[mutationTypes.RECEIVE_ITEMS_FOR_LIST_SUCCESS]: (state, { listIssues, listPageInfo, listId }) => { [mutationTypes.RECEIVE_ITEMS_FOR_LIST_SUCCESS]: (state, { listItems, listPageInfo, listId }) => {
const { listData, issues } = listIssues; const { listData, boardItems } = listItems;
Vue.set(state, 'issues', { ...state.issues, ...issues }); Vue.set(state, 'boardItems', { ...state.boardItems, ...boardItems });
Vue.set( Vue.set(
state.issuesByListId, state.boardItemsByListId,
listId, listId,
union(state.issuesByListId[listId] || [], listData[listId]), union(state.boardItemsByListId[listId] || [], listData[listId]),
); );
Vue.set(state.pageInfoByListId, listId, listPageInfo[listId]); Vue.set(state.pageInfoByListId, listId, listPageInfo[listId]);
Vue.set(state.listsFlags, listId, { isLoading: false, isLoadingMore: false }); Vue.set(state.listsFlags, listId, { isLoading: false, isLoadingMore: false });
...@@ -129,18 +128,18 @@ export default { ...@@ -129,18 +128,18 @@ export default {
}, },
[mutationTypes.RESET_ISSUES]: (state) => { [mutationTypes.RESET_ISSUES]: (state) => {
Object.keys(state.issuesByListId).forEach((listId) => { Object.keys(state.boardItemsByListId).forEach((listId) => {
Vue.set(state.issuesByListId, listId, []); Vue.set(state.boardItemsByListId, listId, []);
}); });
}, },
[mutationTypes.UPDATE_ISSUE_BY_ID]: (state, { issueId, prop, value }) => { [mutationTypes.UPDATE_ISSUE_BY_ID]: (state, { issueId, prop, value }) => {
if (!state.issues[issueId]) { if (!state.boardItems[issueId]) {
/* eslint-disable-next-line @gitlab/require-i18n-strings */ /* eslint-disable-next-line @gitlab/require-i18n-strings */
throw new Error('No issue found.'); throw new Error('No issue found.');
} }
Vue.set(state.issues[issueId], prop, value); Vue.set(state.boardItems[issueId], prop, value);
}, },
[mutationTypes.SET_ASSIGNEE_LOADING](state, isLoading) { [mutationTypes.SET_ASSIGNEE_LOADING](state, isLoading) {
...@@ -167,7 +166,7 @@ export default { ...@@ -167,7 +166,7 @@ export default {
const toList = state.boardLists[toListId]; const toList = state.boardLists[toListId];
const issue = moveIssueListHelper(originalIssue, fromList, toList); const issue = moveIssueListHelper(originalIssue, fromList, toList);
Vue.set(state.issues, issue.id, issue); Vue.set(state.boardItems, issue.id, issue);
removeIssueFromList({ state, listId: fromListId, issueId: issue.id }); removeIssueFromList({ state, listId: fromListId, issueId: issue.id });
addIssueToList({ state, listId: toListId, issueId: issue.id, moveBeforeId, moveAfterId }); addIssueToList({ state, listId: toListId, issueId: issue.id, moveBeforeId, moveAfterId });
...@@ -175,7 +174,7 @@ export default { ...@@ -175,7 +174,7 @@ export default {
[mutationTypes.MOVE_ISSUE_SUCCESS]: (state, { issue }) => { [mutationTypes.MOVE_ISSUE_SUCCESS]: (state, { issue }) => {
const issueId = getIdFromGraphQLId(issue.id); const issueId = getIdFromGraphQLId(issue.id);
Vue.set(state.issues, issueId, formatIssue({ ...issue, id: issueId })); Vue.set(state.boardItems, issueId, formatIssue({ ...issue, id: issueId }));
}, },
[mutationTypes.MOVE_ISSUE_FAILURE]: ( [mutationTypes.MOVE_ISSUE_FAILURE]: (
...@@ -183,7 +182,7 @@ export default { ...@@ -183,7 +182,7 @@ export default {
{ originalIssue, fromListId, toListId, originalIndex }, { originalIssue, fromListId, toListId, originalIndex },
) => { ) => {
state.error = s__('Boards|An error occurred while moving the issue. Please try again.'); state.error = s__('Boards|An error occurred while moving the issue. Please try again.');
Vue.set(state.issues, originalIssue.id, originalIssue); Vue.set(state.boardItems, originalIssue.id, originalIssue);
removeIssueFromList({ state, listId: toListId, issueId: originalIssue.id }); removeIssueFromList({ state, listId: toListId, issueId: originalIssue.id });
addIssueToList({ addIssueToList({
state, state,
...@@ -216,7 +215,7 @@ export default { ...@@ -216,7 +215,7 @@ export default {
issueId: issue.id, issueId: issue.id,
atIndex: position, atIndex: position,
}); });
Vue.set(state.issues, issue.id, issue); Vue.set(state.boardItems, issue.id, issue);
}, },
[mutationTypes.ADD_ISSUE_TO_LIST_FAILURE]: (state, { list, issueId }) => { [mutationTypes.ADD_ISSUE_TO_LIST_FAILURE]: (state, { list, issueId }) => {
...@@ -226,7 +225,7 @@ export default { ...@@ -226,7 +225,7 @@ export default {
[mutationTypes.REMOVE_ISSUE_FROM_LIST]: (state, { list, issue }) => { [mutationTypes.REMOVE_ISSUE_FROM_LIST]: (state, { list, issue }) => {
removeIssueFromList({ state, listId: list.id, issueId: issue.id }); removeIssueFromList({ state, listId: list.id, issueId: issue.id });
Vue.delete(state.issues, issue.id); Vue.delete(state.boardItems, issue.id);
}, },
[mutationTypes.SET_CURRENT_PAGE]: () => { [mutationTypes.SET_CURRENT_PAGE]: () => {
......
...@@ -9,10 +9,10 @@ export default () => ({ ...@@ -9,10 +9,10 @@ export default () => ({
sidebarType: '', sidebarType: '',
boardLists: {}, boardLists: {},
listsFlags: {}, listsFlags: {},
issuesByListId: {}, boardItemsByListId: {},
isSettingAssignees: false, isSettingAssignees: false,
pageInfoByListId: {}, pageInfoByListId: {},
issues: {}, boardItems: {},
filterParams: {}, filterParams: {},
boardConfig: {}, boardConfig: {},
labels: [], labels: [],
......
...@@ -32,12 +32,12 @@ export function fullEpicBoardId(epicBoardId) { ...@@ -32,12 +32,12 @@ export function fullEpicBoardId(epicBoardId) {
} }
export function formatListEpics(listEpics) { export function formatListEpics(listEpics) {
const epics = {}; const boardItems = {};
let listEpicsCount; let listItemsCount;
const listData = listEpics.nodes.reduce((map, list) => { const listData = listEpics.nodes.reduce((map, list) => {
// TODO update when list.epics.count is available: https://gitlab.com/gitlab-org/gitlab/-/issues/301017 // TODO update when list.epics.count is available: https://gitlab.com/gitlab-org/gitlab/-/issues/301017
listEpicsCount = list.epics.edges.length; listItemsCount = list.epics.edges.length;
let sortedEpics = list.epics.edges.map((epicNode) => ({ let sortedEpics = list.epics.edges.map((epicNode) => ({
...epicNode.node, ...epicNode.node,
})); }));
...@@ -55,14 +55,14 @@ export function formatListEpics(listEpics) { ...@@ -55,14 +55,14 @@ export function formatListEpics(listEpics) {
assignees: i.assignees?.nodes || [], assignees: i.assignees?.nodes || [],
}; };
epics[id] = listEpic; boardItems[id] = listEpic;
return id; return id;
}), }),
}; };
}, {}); }, {});
return { listData, epics, listEpicsCount }; return { listData, boardItems, listItemsCount };
} }
export function formatEpicListsPageInfo(lists) { export function formatEpicListsPageInfo(lists) {
......
...@@ -76,7 +76,7 @@ const fetchAndFormatListIssues = (state, extraVariables) => { ...@@ -76,7 +76,7 @@ const fetchAndFormatListIssues = (state, extraVariables) => {
}) })
.then(({ data }) => { .then(({ data }) => {
const { lists } = data[boardType]?.board; const { lists } = data[boardType]?.board;
return { listIssues: formatListIssues(lists), listPageInfo: formatListsPageInfo(lists) }; return { listItems: formatListIssues(lists), listPageInfo: formatListsPageInfo(lists) };
}); });
}; };
...@@ -100,7 +100,7 @@ const fetchAndFormatListEpics = (state, extraVariables) => { ...@@ -100,7 +100,7 @@ const fetchAndFormatListEpics = (state, extraVariables) => {
}) })
.then(({ data }) => { .then(({ data }) => {
const { lists } = data.group?.epicBoard; const { lists } = data.group?.epicBoard;
return { listEpics: formatListEpics(lists), listPageInfo: formatEpicListsPageInfo(lists) }; return { listItems: formatListEpics(lists), listPageInfo: formatEpicListsPageInfo(lists) };
}); });
}; };
...@@ -317,12 +317,10 @@ export default { ...@@ -317,12 +317,10 @@ export default {
}; };
if (state.isEpicBoard) { if (state.isEpicBoard) {
// This currently always fails. Epics will be loaded and displayed in the next iteration
// Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/233438
return fetchAndFormatListEpics(state, variables) return fetchAndFormatListEpics(state, variables)
.then(({ listEpics, listPageInfo }) => { .then(({ listItems, listPageInfo }) => {
commit(types.RECEIVE_ITEMS_FOR_LIST_SUCCESS, { commit(types.RECEIVE_ITEMS_FOR_LIST_SUCCESS, {
listEpics, listItems,
listPageInfo, listPageInfo,
listId, listId,
noEpicIssues, noEpicIssues,
...@@ -332,9 +330,9 @@ export default { ...@@ -332,9 +330,9 @@ export default {
} }
return fetchAndFormatListIssues(state, variables) return fetchAndFormatListIssues(state, variables)
.then(({ listIssues, listPageInfo }) => { .then(({ listItems, listPageInfo }) => {
commit(types.RECEIVE_ITEMS_FOR_LIST_SUCCESS, { commit(types.RECEIVE_ITEMS_FOR_LIST_SUCCESS, {
listIssues, listItems,
listPageInfo, listPageInfo,
listId, listId,
noEpicIssues, noEpicIssues,
...@@ -353,8 +351,8 @@ export default { ...@@ -353,8 +351,8 @@ export default {
}; };
return fetchAndFormatListIssues(state, variables) return fetchAndFormatListIssues(state, variables)
.then(({ listIssues }) => { .then(({ listItems }) => {
commit(types.RECEIVE_ISSUES_FOR_EPIC_SUCCESS, { ...listIssues, epicId }); commit(types.RECEIVE_ISSUES_FOR_EPIC_SUCCESS, { ...listItems, epicId });
}) })
.catch(() => commit(types.RECEIVE_ISSUES_FOR_EPIC_FAILURE, epicId)); .catch(() => commit(types.RECEIVE_ISSUES_FOR_EPIC_FAILURE, epicId));
}, },
...@@ -484,8 +482,8 @@ export default { ...@@ -484,8 +482,8 @@ export default {
{ state, commit }, { state, commit },
{ issueId, issueIid, issuePath, fromListId, toListId, moveBeforeId, moveAfterId, epicId }, { issueId, issueIid, issuePath, fromListId, toListId, moveBeforeId, moveAfterId, epicId },
) => { ) => {
const originalIssue = state.issues[issueId]; const originalIssue = state.boardItems[issueId];
const fromList = state.issuesByListId[fromListId]; const fromList = state.boardItemsByListId[fromListId];
const originalIndex = fromList.indexOf(Number(issueId)); const originalIndex = fromList.indexOf(Number(issueId));
commit(types.MOVE_ISSUE, { commit(types.MOVE_ISSUE, {
originalIssue, originalIssue,
......
...@@ -8,12 +8,12 @@ export default { ...@@ -8,12 +8,12 @@ export default {
}, },
getIssuesByEpic: (state, getters) => (listId, epicId) => { getIssuesByEpic: (state, getters) => (listId, epicId) => {
return getters return getters
.getIssuesByList(listId) .getBoardItemsByList(listId)
.filter((issue) => issue.epic && issue.epic.id === epicId); .filter((issue) => issue.epic && issue.epic.id === epicId);
}, },
getUnassignedIssues: (state, getters) => (listId) => { getUnassignedIssues: (state, getters) => (listId) => {
return getters.getIssuesByList(listId).filter((i) => Boolean(i.epic) === false); return getters.getBoardItemsByList(listId).filter((i) => Boolean(i.epic) === false);
}, },
shouldUseGraphQL: (state) => { shouldUseGraphQL: (state) => {
......
...@@ -65,33 +65,50 @@ export default { ...@@ -65,33 +65,50 @@ export default {
[mutationTypes.RECEIVE_ITEMS_FOR_LIST_SUCCESS]: ( [mutationTypes.RECEIVE_ITEMS_FOR_LIST_SUCCESS]: (
state, state,
{ listIssues, listPageInfo, listId, noEpicIssues }, { listItems, listPageInfo, listId, noEpicIssues },
) => { ) => {
const { listData, issues, listIssuesCount } = listIssues; const { listData, boardItems, listItemsCount } = listItems;
Vue.set(state, 'issues', { ...state.issues, ...issues }); Vue.set(state, 'boardItems', { ...state.boardItems, ...boardItems });
Vue.set( Vue.set(
state.issuesByListId, state.boardItemsByListId,
listId, listId,
union(state.issuesByListId[listId] || [], listData[listId]), union(state.boardItemsByListId[listId] || [], listData[listId]),
); );
Vue.set(state.pageInfoByListId, listId, listPageInfo[listId]); Vue.set(state.pageInfoByListId, listId, listPageInfo[listId]);
Vue.set(state.listsFlags, listId, { Vue.set(state.listsFlags, listId, {
isLoading: false, isLoading: false,
isLoadingMore: false, isLoadingMore: false,
unassignedIssuesCount: noEpicIssues ? listIssuesCount : undefined, unassignedIssuesCount: noEpicIssues ? listItemsCount : undefined,
}); });
}, },
[mutationTypes.RECEIVE_ITEMS_FOR_LIST_FAILURE]: (state, listId) => {
if (state.isEpicBoard) {
state.error = s__(
'Boards|An error occurred while fetching the board epics. Please reload the page.',
);
} else {
state.error = s__(
'Boards|An error occurred while fetching the board issues. Please reload the page.',
);
}
Vue.set(state.listsFlags, listId, { isLoading: false, isLoadingMore: false });
},
[mutationTypes.REQUEST_ISSUES_FOR_EPIC]: (state, epicId) => { [mutationTypes.REQUEST_ISSUES_FOR_EPIC]: (state, epicId) => {
Vue.set(state.epicsFlags, epicId, { isLoading: true }); Vue.set(state.epicsFlags, epicId, { isLoading: true });
}, },
[mutationTypes.RECEIVE_ISSUES_FOR_EPIC_SUCCESS]: (state, { listData, issues, epicId }) => { [mutationTypes.RECEIVE_ISSUES_FOR_EPIC_SUCCESS]: (state, { listData, boardItems, epicId }) => {
Object.entries(listData).forEach(([listId, list]) => { Object.entries(listData).forEach(([listId, list]) => {
Vue.set(state.issuesByListId, listId, union(state.issuesByListId[listId] || [], list)); Vue.set(
state.boardItemsByListId,
listId,
union(state.boardItemsByListId[listId] || [], list),
);
}); });
Vue.set(state, 'issues', { ...state.issues, ...issues }); Vue.set(state, 'boardItems', { ...state.boardItems, ...boardItems });
Vue.set(state.epicsFlags, epicId, { isLoading: false }); Vue.set(state.epicsFlags, epicId, { isLoading: false });
}, },
...@@ -157,9 +174,9 @@ export default { ...@@ -157,9 +174,9 @@ export default {
const issue = moveIssueListHelper(originalIssue, fromList, toList); const issue = moveIssueListHelper(originalIssue, fromList, toList);
if (epicId === null) { if (epicId === null) {
Vue.set(state.issues, issue.id, { ...issue, epic: null }); Vue.set(state.boardItems, issue.id, { ...issue, epic: null });
} else if (epicId !== undefined) { } else if (epicId !== undefined) {
Vue.set(state.issues, issue.id, { ...issue, epic: { id: epicId } }); Vue.set(state.boardItems, issue.id, { ...issue, epic: { id: epicId } });
} }
removeIssueFromList({ state, listId: fromListId, issueId: issue.id }); removeIssueFromList({ state, listId: fromListId, issueId: issue.id });
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'epic boards', :js do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group, :public) }
let_it_be(:epic_board) { create(:epic_board, group: group) }
let_it_be(:label) { create(:group_label, group: group, name: 'Label1') }
let_it_be(:label_list) { create(:epic_list, epic_board: epic_board, label: label, position: 0) }
let_it_be(:backlog_list) { create(:epic_list, epic_board: epic_board, list_type: :closed) }
let_it_be(:closed_list) { create(:epic_list, epic_board: epic_board, list_type: :backlog) }
let_it_be(:epic1) { create(:epic, group: group, labels: [label], title: 'Epic1') }
let_it_be(:epic2) { create(:epic, group: group, title: 'Epic2') }
context 'display epics in board' do
before do
stub_licensed_features(epics: true)
sign_in(user)
visit_epic_boards_page
end
it 'displays default lists and a label list' do
lists = %w[Open Label1 Closed]
wait_for_requests
expect(page).to have_selector('.board-header', count: 3)
page.all('.board-header').each_with_index do |list, i|
expect(list.find('.board-title')).to have_content(lists[i])
end
end
it 'displays one epic in Open list' do
page.within("[data-board-type='backlog']") do
expect(page).to have_selector('.board-card', count: 1)
page.within(first('.board-card')) do
expect(page).to have_content('Epic2')
end
end
end
it 'displays one epic in Label list' do
page.within("[data-board-type='label']") do
expect(page).to have_selector('.board-card', count: 1)
page.within(first('.board-card')) do
expect(page).to have_content('Epic1')
end
end
end
end
def visit_epic_boards_page
visit group_epic_boards_path(group)
wait_for_requests
end
end
...@@ -33,7 +33,7 @@ describe('formatListEpics', () => { ...@@ -33,7 +33,7 @@ describe('formatListEpics', () => {
const result = formatListEpics(rawEpicsInLists); const result = formatListEpics(rawEpicsInLists);
expect(result).toEqual({ expect(result).toEqual({
epics: { boardItems: {
1: { 1: {
assignees: [], assignees: [],
id: 1, id: 1,
...@@ -42,7 +42,7 @@ describe('formatListEpics', () => { ...@@ -42,7 +42,7 @@ describe('formatListEpics', () => {
}, },
}, },
listData: { [listId]: [1] }, listData: { [listId]: [1] },
listEpicsCount: 1, listItemsCount: 1,
}); });
}); });
}); });
......
...@@ -16,15 +16,15 @@ describe('EpicLane', () => { ...@@ -16,15 +16,15 @@ describe('EpicLane', () => {
const updateBoardEpicUserPreferencesSpy = jest.fn(); const updateBoardEpicUserPreferencesSpy = jest.fn();
const createStore = ({ isLoading = false, issuesByListId = mockIssuesByListId }) => { const createStore = ({ isLoading = false, boardItemsByListId = mockIssuesByListId }) => {
return new Vuex.Store({ return new Vuex.Store({
actions: { actions: {
fetchIssuesForEpic: jest.fn(), fetchIssuesForEpic: jest.fn(),
updateBoardEpicUserPreferences: updateBoardEpicUserPreferencesSpy, updateBoardEpicUserPreferences: updateBoardEpicUserPreferencesSpy,
}, },
state: { state: {
issuesByListId, boardItemsByListId,
issues, boardItems: issues,
epicsFlags: { epicsFlags: {
[mockEpic.id]: { isLoading }, [mockEpic.id]: { isLoading },
}, },
...@@ -36,9 +36,9 @@ describe('EpicLane', () => { ...@@ -36,9 +36,9 @@ describe('EpicLane', () => {
const createComponent = ({ const createComponent = ({
props = {}, props = {},
isLoading = false, isLoading = false,
issuesByListId = mockIssuesByListId, boardItemsByListId = mockIssuesByListId,
} = {}) => { } = {}) => {
const store = createStore({ isLoading, issuesByListId }); const store = createStore({ isLoading, boardItemsByListId });
const defaultProps = { const defaultProps = {
epic: mockEpic, epic: mockEpic,
...@@ -125,7 +125,7 @@ describe('EpicLane', () => { ...@@ -125,7 +125,7 @@ describe('EpicLane', () => {
}); });
it('does not render when issuesCount is 0', () => { it('does not render when issuesCount is 0', () => {
createComponent({ issuesByListId: {} }); createComponent({ boardItemsByListId: {} });
expect(findByTestId('board-epic-lane').exists()).toBe(false); expect(findByTestId('board-epic-lane').exists()).toBe(false);
}); });
}); });
......
...@@ -19,8 +19,8 @@ describe('EpicsSwimlanes', () => { ...@@ -19,8 +19,8 @@ describe('EpicsSwimlanes', () => {
return new Vuex.Store({ return new Vuex.Store({
state: { state: {
epics: mockEpics, epics: mockEpics,
issuesByListId: mockIssuesByListId, boardItemsByListId: mockIssuesByListId,
issues, boardItems: issues,
pageInfoByListId: { pageInfoByListId: {
'gid://gitlab/List/1': {}, 'gid://gitlab/List/1': {},
'gid://gitlab/List/2': {}, 'gid://gitlab/List/2': {},
......
...@@ -30,7 +30,7 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => { ...@@ -30,7 +30,7 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => {
const createStore = ({ const createStore = ({
initialState = { initialState = {
activeId: mockIssueWithoutEpic.id, activeId: mockIssueWithoutEpic.id,
issues: { [mockIssueWithoutEpic.id]: { ...mockIssueWithoutEpic } }, boardItems: { [mockIssueWithoutEpic.id]: { ...mockIssueWithoutEpic } },
epicsCacheById: {}, epicsCacheById: {},
epicFetchInProgress: false, epicFetchInProgress: false,
}, },
...@@ -120,7 +120,7 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => { ...@@ -120,7 +120,7 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => {
createStore({ createStore({
initialState: { initialState: {
activeId: mockIssueWithEpic.id, activeId: mockIssueWithEpic.id,
issues: { [mockIssueWithEpic.id]: { ...mockIssueWithEpic } }, boardItems: { [mockIssueWithEpic.id]: { ...mockIssueWithEpic } },
epicsCacheById: {}, epicsCacheById: {},
epicFetchInProgress: true, epicFetchInProgress: true,
}, },
...@@ -138,7 +138,7 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => { ...@@ -138,7 +138,7 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => {
createStore({ createStore({
initialState: { initialState: {
activeId: mockIssueWithEpic.id, activeId: mockIssueWithEpic.id,
issues: { [mockIssueWithEpic.id]: { ...mockIssueWithEpic } }, boardItems: { [mockIssueWithEpic.id]: { ...mockIssueWithEpic } },
epicsCacheById: {}, epicsCacheById: {},
epicFetchInProgress: true, epicFetchInProgress: true,
}, },
...@@ -163,7 +163,7 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => { ...@@ -163,7 +163,7 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => {
createStore({ createStore({
initialState: { initialState: {
activeId: mockIssueWithEpic.id, activeId: mockIssueWithEpic.id,
issues: { [mockIssueWithEpic.id]: { ...mockIssueWithEpic } }, boardItems: { [mockIssueWithEpic.id]: { ...mockIssueWithEpic } },
epicsCacheById: { [mockAssignedEpic.id]: { ...mockAssignedEpic } }, epicsCacheById: { [mockAssignedEpic.id]: { ...mockAssignedEpic } },
epicFetchInProgress: false, epicFetchInProgress: false,
}, },
...@@ -182,7 +182,7 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => { ...@@ -182,7 +182,7 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => {
createStore({ createStore({
initialState: { initialState: {
activeId: mockIssueWithoutEpic.id, activeId: mockIssueWithoutEpic.id,
issues: { [mockIssueWithoutEpic.id]: { ...mockIssueWithoutEpic } }, boardItems: { [mockIssueWithoutEpic.id]: { ...mockIssueWithoutEpic } },
epicsCacheById: {}, epicsCacheById: {},
epicFetchInProgress: false, epicFetchInProgress: false,
}, },
...@@ -193,7 +193,7 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => { ...@@ -193,7 +193,7 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => {
// 'setActiveIssueEpic' sets the active issue's epic to the selected epic // 'setActiveIssueEpic' sets the active issue's epic to the selected epic
// and stores the assigned epic's data in 'epicsCacheById' // and stores the assigned epic's data in 'epicsCacheById'
store.state.epicFetchInProgress = true; store.state.epicFetchInProgress = true;
store.state.issues[mockIssueWithoutEpic.id].epic = { ...mockAssignedEpic }; store.state.boardItems[mockIssueWithoutEpic.id].epic = { ...mockAssignedEpic };
store.state.epicsCacheById = { [mockAssignedEpic.id]: { ...mockAssignedEpic } }; store.state.epicsCacheById = { [mockAssignedEpic.id]: { ...mockAssignedEpic } };
store.state.epicFetchInProgress = false; store.state.epicFetchInProgress = false;
}); });
...@@ -236,7 +236,7 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => { ...@@ -236,7 +236,7 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => {
createStore({ createStore({
initialState: { initialState: {
activeId: mockIssueWithEpic.id, activeId: mockIssueWithEpic.id,
issues: { [mockIssueWithEpic.id]: { ...mockIssueWithEpic } }, boardItems: { [mockIssueWithEpic.id]: { ...mockIssueWithEpic } },
epicsCacheById: { [mockAssignedEpic.id]: { ...mockAssignedEpic } }, epicsCacheById: { [mockAssignedEpic.id]: { ...mockAssignedEpic } },
epicFetchInProgress: false, epicFetchInProgress: false,
}, },
...@@ -245,7 +245,7 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => { ...@@ -245,7 +245,7 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => {
jest.spyOn(wrapper.vm, 'setActiveIssueEpic').mockImplementation(async () => { jest.spyOn(wrapper.vm, 'setActiveIssueEpic').mockImplementation(async () => {
// Remove assigned epic from the active issue // Remove assigned epic from the active issue
store.state.issues[mockIssueWithoutEpic.id].epic = null; store.state.boardItems[mockIssueWithoutEpic.id].epic = null;
}); });
findEpicSelect().vm.$emit('epicSelect', null); findEpicSelect().vm.$emit('epicSelect', null);
......
...@@ -24,7 +24,7 @@ describe('BoardSidebarTimeTracker', () => { ...@@ -24,7 +24,7 @@ describe('BoardSidebarTimeTracker', () => {
beforeEach(() => { beforeEach(() => {
store = createStore(); store = createStore();
store.state.issues = { store.state.boardItems = {
1: { 1: {
timeEstimate: 3600, timeEstimate: 3600,
totalTimeSpent: 1800, totalTimeSpent: 1800,
......
...@@ -22,7 +22,7 @@ describe('ee/boards/components/sidebar/board_sidebar_weight_input.vue', () => { ...@@ -22,7 +22,7 @@ describe('ee/boards/components/sidebar/board_sidebar_weight_input.vue', () => {
const createWrapper = ({ weight = 0 } = {}) => { const createWrapper = ({ weight = 0 } = {}) => {
store = createStore(); store = createStore();
store.state.issues = { [TEST_ISSUE.id]: { ...TEST_ISSUE, weight } }; store.state.boardItems = { [TEST_ISSUE.id]: { ...TEST_ISSUE, weight } };
store.state.activeId = TEST_ISSUE.id; store.state.activeId = TEST_ISSUE.id;
wrapper = shallowMount(BoardSidebarWeightInput, { wrapper = shallowMount(BoardSidebarWeightInput, {
...@@ -58,7 +58,7 @@ describe('ee/boards/components/sidebar/board_sidebar_weight_input.vue', () => { ...@@ -58,7 +58,7 @@ describe('ee/boards/components/sidebar/board_sidebar_weight_input.vue', () => {
jest.spyOn(wrapper.vm, 'setActiveIssueWeight'); jest.spyOn(wrapper.vm, 'setActiveIssueWeight');
findWeightInput().vm.$emit('input', TEST_WEIGHT); findWeightInput().vm.$emit('input', TEST_WEIGHT);
findWeightForm().vm.$emit('submit', { preventDefault: () => {} }); findWeightForm().vm.$emit('submit', { preventDefault: () => {} });
store.state.issues[TEST_ISSUE.id].weight = TEST_WEIGHT; store.state.boardItems[TEST_ISSUE.id].weight = TEST_WEIGHT;
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
}); });
...@@ -82,7 +82,7 @@ describe('ee/boards/components/sidebar/board_sidebar_weight_input.vue', () => { ...@@ -82,7 +82,7 @@ describe('ee/boards/components/sidebar/board_sidebar_weight_input.vue', () => {
jest.spyOn(wrapper.vm, 'setActiveIssueWeight'); jest.spyOn(wrapper.vm, 'setActiveIssueWeight');
findWeightInput().vm.$emit('input', 0); findWeightInput().vm.$emit('input', 0);
findWeightForm().vm.$emit('submit', { preventDefault: () => {} }); findWeightForm().vm.$emit('submit', { preventDefault: () => {} });
store.state.issues[TEST_ISSUE.id].weight = 0; store.state.boardItems[TEST_ISSUE.id].weight = 0;
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
}); });
...@@ -98,7 +98,7 @@ describe('ee/boards/components/sidebar/board_sidebar_weight_input.vue', () => { ...@@ -98,7 +98,7 @@ describe('ee/boards/components/sidebar/board_sidebar_weight_input.vue', () => {
createWrapper({ weight: TEST_WEIGHT }); createWrapper({ weight: TEST_WEIGHT });
jest.spyOn(wrapper.vm, 'setActiveIssueWeight'); jest.spyOn(wrapper.vm, 'setActiveIssueWeight');
findResetButton().vm.$emit('click'); findResetButton().vm.$emit('click');
store.state.issues[TEST_ISSUE.id].weight = 0; store.state.boardItems[TEST_ISSUE.id].weight = 0;
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
}); });
......
...@@ -788,7 +788,7 @@ describe('setActiveIssueEpic', () => { ...@@ -788,7 +788,7 @@ describe('setActiveIssueEpic', () => {
}); });
describe('setActiveIssueWeight', () => { describe('setActiveIssueWeight', () => {
const state = { issues: { [mockIssue.id]: mockIssue } }; const state = { boardItems: { [mockIssue.id]: mockIssue } };
const getters = { activeIssue: mockIssue }; const getters = { activeIssue: mockIssue };
const testWeight = mockIssue.weight + 1; const testWeight = mockIssue.weight + 1;
const input = { const input = {
...@@ -857,8 +857,8 @@ describe('moveIssue', () => { ...@@ -857,8 +857,8 @@ describe('moveIssue', () => {
boardType: 'group', boardType: 'group',
disabled: false, disabled: false,
boardLists: mockLists, boardLists: mockLists,
issuesByListId: listIssues, boardItemsByListId: listIssues,
issues, boardItems: issues,
}; };
it('should commit MOVE_ISSUE mutation and MOVE_ISSUE_SUCCESS mutation when successful', (done) => { it('should commit MOVE_ISSUE mutation and MOVE_ISSUE_SUCCESS mutation when successful', (done) => {
......
...@@ -11,9 +11,9 @@ import { ...@@ -11,9 +11,9 @@ import {
describe('EE Boards Store Getters', () => { describe('EE Boards Store Getters', () => {
const boardsState = { const boardsState = {
issuesByListId: mockIssuesByListId, boardItemsByListId: mockIssuesByListId,
epics: mockEpics, epics: mockEpics,
issues, boardItems: issues,
}; };
describe('isSwimlanesOn', () => { describe('isSwimlanesOn', () => {
...@@ -72,9 +72,9 @@ describe('EE Boards Store Getters', () => { ...@@ -72,9 +72,9 @@ describe('EE Boards Store Getters', () => {
describe('getIssuesByEpic', () => { describe('getIssuesByEpic', () => {
it('returns issues for a given listId and epicId', () => { it('returns issues for a given listId and epicId', () => {
const getIssuesByList = () => mockIssues; const getBoardItemsByList = () => mockIssues;
expect( expect(
getters.getIssuesByEpic(boardsState, { getIssuesByList })( getters.getIssuesByEpic(boardsState, { getBoardItemsByList })(
'gid://gitlab/List/2', 'gid://gitlab/List/2',
'gid://gitlab/Epic/41', 'gid://gitlab/Epic/41',
), ),
...@@ -84,9 +84,9 @@ describe('EE Boards Store Getters', () => { ...@@ -84,9 +84,9 @@ describe('EE Boards Store Getters', () => {
describe('getUnassignedIssues', () => { describe('getUnassignedIssues', () => {
it('returns issues not assigned to an epic for a given listId', () => { it('returns issues not assigned to an epic for a given listId', () => {
const getIssuesByList = () => [mockIssue, mockIssue3, mockIssue4]; const getBoardItemsByList = () => [mockIssue, mockIssue3, mockIssue4];
expect( expect(
getters.getUnassignedIssues(boardsState, { getIssuesByList })('gid://gitlab/List/1'), getters.getUnassignedIssues(boardsState, { getBoardItemsByList })('gid://gitlab/List/1'),
).toEqual([mockIssue3, mockIssue4]); ).toEqual([mockIssue3, mockIssue4]);
}); });
}); });
......
...@@ -15,8 +15,8 @@ const initialBoardListsState = { ...@@ -15,8 +15,8 @@ const initialBoardListsState = {
}; };
let state = { let state = {
issuesByListId: {}, boardItemsByListId: {},
issues: {}, boardItems: {},
boardLists: initialBoardListsState, boardLists: initialBoardListsState,
epicsFlags: { epicsFlags: {
[epicId]: { isLoading: true }, [epicId]: { isLoading: true },
...@@ -92,7 +92,7 @@ describe('REQUEST_ISSUES_FOR_EPIC', () => { ...@@ -92,7 +92,7 @@ describe('REQUEST_ISSUES_FOR_EPIC', () => {
}); });
describe('RECEIVE_ISSUES_FOR_EPIC_SUCCESS', () => { describe('RECEIVE_ISSUES_FOR_EPIC_SUCCESS', () => {
it('sets issuesByListId and issues state for epic issues and loading state to false', () => { it('sets boardItemsByListId and issues state for epic issues and loading state to false', () => {
const listIssues = { const listIssues = {
'gid://gitlab/List/1': [mockIssue.id], 'gid://gitlab/List/1': [mockIssue.id],
'gid://gitlab/List/2': [mockIssue2.id], 'gid://gitlab/List/2': [mockIssue2.id],
...@@ -104,12 +104,12 @@ describe('RECEIVE_ISSUES_FOR_EPIC_SUCCESS', () => { ...@@ -104,12 +104,12 @@ describe('RECEIVE_ISSUES_FOR_EPIC_SUCCESS', () => {
mutations.RECEIVE_ISSUES_FOR_EPIC_SUCCESS(state, { mutations.RECEIVE_ISSUES_FOR_EPIC_SUCCESS(state, {
listData: listIssues, listData: listIssues,
issues, boardItems: issues,
epicId, epicId,
}); });
expect(state.issuesByListId).toEqual(listIssues); expect(state.boardItemsByListId).toEqual(listIssues);
expect(state.issues).toEqual(issues); expect(state.boardItems).toEqual(issues);
expect(state.epicsFlags[epicId].isLoading).toBe(false); expect(state.epicsFlags[epicId].isLoading).toBe(false);
}); });
}); });
...@@ -257,7 +257,7 @@ describe('RECEIVE_EPICS_SUCCESS', () => { ...@@ -257,7 +257,7 @@ describe('RECEIVE_EPICS_SUCCESS', () => {
}); });
describe('RESET_EPICS', () => { describe('RESET_EPICS', () => {
it('should remove issues from issuesByListId state', () => { it('should remove issues from boardItemsByListId state', () => {
state = { state = {
...state, ...state,
epics: mockEpics, epics: mockEpics,
...@@ -283,13 +283,13 @@ describe('MOVE_ISSUE', () => { ...@@ -283,13 +283,13 @@ describe('MOVE_ISSUE', () => {
state = { state = {
...state, ...state,
issuesByListId: listIssues, boardItemsByListId: listIssues,
issues, boardItems: issues,
}; };
}); });
it('updates issuesByListId, moving issue between lists and updating epic id on issue', () => { it('updates boardItemsByListId, moving issue between lists and updating epic id on issue', () => {
expect(state.issues['437'].epic.id).toEqual('gid://gitlab/Epic/40'); expect(state.boardItems['437'].epic.id).toEqual('gid://gitlab/Epic/40');
mutations.MOVE_ISSUE(state, { mutations.MOVE_ISSUE(state, {
originalIssue: mockIssue2, originalIssue: mockIssue2,
...@@ -303,12 +303,12 @@ describe('MOVE_ISSUE', () => { ...@@ -303,12 +303,12 @@ describe('MOVE_ISSUE', () => {
'gid://gitlab/List/2': [mockIssue2.id], 'gid://gitlab/List/2': [mockIssue2.id],
}; };
expect(state.issuesByListId).toEqual(updatedListIssues); expect(state.boardItemsByListId).toEqual(updatedListIssues);
expect(state.issues['437'].epic.id).toEqual(epicId); expect(state.boardItems['437'].epic.id).toEqual(epicId);
}); });
it('removes epic id from issue when epicId is null', () => { it('removes epic id from issue when epicId is null', () => {
expect(state.issues['437'].epic.id).toEqual('gid://gitlab/Epic/40'); expect(state.boardItems['437'].epic.id).toEqual('gid://gitlab/Epic/40');
mutations.MOVE_ISSUE(state, { mutations.MOVE_ISSUE(state, {
originalIssue: mockIssue2, originalIssue: mockIssue2,
...@@ -322,8 +322,8 @@ describe('MOVE_ISSUE', () => { ...@@ -322,8 +322,8 @@ describe('MOVE_ISSUE', () => {
'gid://gitlab/List/2': [mockIssue2.id], 'gid://gitlab/List/2': [mockIssue2.id],
}; };
expect(state.issuesByListId).toEqual(updatedListIssues); expect(state.boardItemsByListId).toEqual(updatedListIssues);
expect(state.issues['437'].epic).toEqual(null); expect(state.boardItems['437'].epic).toEqual(null);
}); });
}); });
......
...@@ -4808,6 +4808,9 @@ msgstr "" ...@@ -4808,6 +4808,9 @@ msgstr ""
msgid "Boards|An error occurred while fetching issues. Please reload the page." msgid "Boards|An error occurred while fetching issues. Please reload the page."
msgstr "" msgstr ""
msgid "Boards|An error occurred while fetching the board epics. Please reload the page."
msgstr ""
msgid "Boards|An error occurred while fetching the board issues. Please reload the page." msgid "Boards|An error occurred while fetching the board issues. Please reload the page."
msgstr "" msgstr ""
......
...@@ -29,8 +29,8 @@ const createComponent = ({ ...@@ -29,8 +29,8 @@ const createComponent = ({
state = {}, state = {},
} = {}) => { } = {}) => {
const store = createStore({ const store = createStore({
issuesByListId: mockIssuesByListId, boardItemsByListId: mockIssuesByListId,
issues, boardItems: issues,
pageInfoByListId: { pageInfoByListId: {
'gid://gitlab/List/1': { hasNextPage: true }, 'gid://gitlab/List/1': { hasNextPage: true },
'gid://gitlab/List/2': {}, 'gid://gitlab/List/2': {},
...@@ -65,7 +65,7 @@ const createComponent = ({ ...@@ -65,7 +65,7 @@ const createComponent = ({
propsData: { propsData: {
disabled: false, disabled: false,
list, list,
issues: [issue], boardItems: [issue],
canAdminList: true, canAdminList: true,
...componentProps, ...componentProps,
}, },
......
...@@ -24,7 +24,7 @@ describe('~/boards/components/sidebar/board_sidebar_due_date.vue', () => { ...@@ -24,7 +24,7 @@ describe('~/boards/components/sidebar/board_sidebar_due_date.vue', () => {
const createWrapper = ({ dueDate = null } = {}) => { const createWrapper = ({ dueDate = null } = {}) => {
store = createStore(); store = createStore();
store.state.issues = { [TEST_ISSUE.id]: { ...TEST_ISSUE, dueDate } }; store.state.boardItems = { [TEST_ISSUE.id]: { ...TEST_ISSUE, dueDate } };
store.state.activeId = TEST_ISSUE.id; store.state.activeId = TEST_ISSUE.id;
wrapper = shallowMount(BoardSidebarDueDate, { wrapper = shallowMount(BoardSidebarDueDate, {
...@@ -61,7 +61,7 @@ describe('~/boards/components/sidebar/board_sidebar_due_date.vue', () => { ...@@ -61,7 +61,7 @@ describe('~/boards/components/sidebar/board_sidebar_due_date.vue', () => {
createWrapper(); createWrapper();
jest.spyOn(wrapper.vm, 'setActiveIssueDueDate').mockImplementation(() => { jest.spyOn(wrapper.vm, 'setActiveIssueDueDate').mockImplementation(() => {
store.state.issues[TEST_ISSUE.id].dueDate = TEST_DUE_DATE; store.state.boardItems[TEST_ISSUE.id].dueDate = TEST_DUE_DATE;
}); });
findDatePicker().vm.$emit('input', TEST_PARSED_DATE); findDatePicker().vm.$emit('input', TEST_PARSED_DATE);
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
...@@ -86,7 +86,7 @@ describe('~/boards/components/sidebar/board_sidebar_due_date.vue', () => { ...@@ -86,7 +86,7 @@ describe('~/boards/components/sidebar/board_sidebar_due_date.vue', () => {
createWrapper(); createWrapper();
jest.spyOn(wrapper.vm, 'setActiveIssueDueDate').mockImplementation(() => { jest.spyOn(wrapper.vm, 'setActiveIssueDueDate').mockImplementation(() => {
store.state.issues[TEST_ISSUE.id].dueDate = null; store.state.boardItems[TEST_ISSUE.id].dueDate = null;
}); });
findDatePicker().vm.$emit('clear'); findDatePicker().vm.$emit('clear');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
...@@ -104,7 +104,7 @@ describe('~/boards/components/sidebar/board_sidebar_due_date.vue', () => { ...@@ -104,7 +104,7 @@ describe('~/boards/components/sidebar/board_sidebar_due_date.vue', () => {
createWrapper({ dueDate: TEST_DUE_DATE }); createWrapper({ dueDate: TEST_DUE_DATE });
jest.spyOn(wrapper.vm, 'setActiveIssueDueDate').mockImplementation(() => { jest.spyOn(wrapper.vm, 'setActiveIssueDueDate').mockImplementation(() => {
store.state.issues[TEST_ISSUE.id].dueDate = null; store.state.boardItems[TEST_ISSUE.id].dueDate = null;
}); });
findResetButton().vm.$emit('click'); findResetButton().vm.$emit('click');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
......
...@@ -34,7 +34,7 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => { ...@@ -34,7 +34,7 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => {
const createWrapper = (issue = TEST_ISSUE_A) => { const createWrapper = (issue = TEST_ISSUE_A) => {
store = createStore(); store = createStore();
store.state.issues = { [issue.id]: { ...issue } }; store.state.boardItems = { [issue.id]: { ...issue } };
store.dispatch('setActiveId', { id: issue.id }); store.dispatch('setActiveId', { id: issue.id });
wrapper = shallowMount(BoardSidebarIssueTitle, { wrapper = shallowMount(BoardSidebarIssueTitle, {
...@@ -74,7 +74,7 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => { ...@@ -74,7 +74,7 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => {
createWrapper(); createWrapper();
jest.spyOn(wrapper.vm, 'setActiveIssueTitle').mockImplementation(() => { jest.spyOn(wrapper.vm, 'setActiveIssueTitle').mockImplementation(() => {
store.state.issues[TEST_ISSUE_A.id].title = TEST_TITLE; store.state.boardItems[TEST_ISSUE_A.id].title = TEST_TITLE;
}); });
findFormInput().vm.$emit('input', TEST_TITLE); findFormInput().vm.$emit('input', TEST_TITLE);
findForm().vm.$emit('submit', { preventDefault: () => {} }); findForm().vm.$emit('submit', { preventDefault: () => {} });
...@@ -147,7 +147,7 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => { ...@@ -147,7 +147,7 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => {
createWrapper(TEST_ISSUE_B); createWrapper(TEST_ISSUE_B);
jest.spyOn(wrapper.vm, 'setActiveIssueTitle').mockImplementation(() => { jest.spyOn(wrapper.vm, 'setActiveIssueTitle').mockImplementation(() => {
store.state.issues[TEST_ISSUE_B.id].title = TEST_TITLE; store.state.boardItems[TEST_ISSUE_B.id].title = TEST_TITLE;
}); });
findFormInput().vm.$emit('input', TEST_TITLE); findFormInput().vm.$emit('input', TEST_TITLE);
findCancelButton().vm.$emit('click'); findCancelButton().vm.$emit('click');
......
...@@ -25,7 +25,7 @@ describe('~/boards/components/sidebar/board_sidebar_labels_select.vue', () => { ...@@ -25,7 +25,7 @@ describe('~/boards/components/sidebar/board_sidebar_labels_select.vue', () => {
const createWrapper = ({ labels = [] } = {}) => { const createWrapper = ({ labels = [] } = {}) => {
store = createStore(); store = createStore();
store.state.issues = { [TEST_ISSUE.id]: { ...TEST_ISSUE, labels } }; store.state.boardItems = { [TEST_ISSUE.id]: { ...TEST_ISSUE, labels } };
store.state.activeId = TEST_ISSUE.id; store.state.activeId = TEST_ISSUE.id;
wrapper = shallowMount(BoardSidebarLabelsSelect, { wrapper = shallowMount(BoardSidebarLabelsSelect, {
...@@ -66,7 +66,7 @@ describe('~/boards/components/sidebar/board_sidebar_labels_select.vue', () => { ...@@ -66,7 +66,7 @@ describe('~/boards/components/sidebar/board_sidebar_labels_select.vue', () => {
jest.spyOn(wrapper.vm, 'setActiveIssueLabels').mockImplementation(() => TEST_LABELS); jest.spyOn(wrapper.vm, 'setActiveIssueLabels').mockImplementation(() => TEST_LABELS);
findLabelsSelect().vm.$emit('updateSelectedLabels', TEST_LABELS_PAYLOAD); findLabelsSelect().vm.$emit('updateSelectedLabels', TEST_LABELS_PAYLOAD);
store.state.issues[TEST_ISSUE.id].labels = TEST_LABELS; store.state.boardItems[TEST_ISSUE.id].labels = TEST_LABELS;
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
}); });
......
...@@ -22,7 +22,7 @@ describe('~/boards/components/sidebar/board_sidebar_milestone_select.vue', () => ...@@ -22,7 +22,7 @@ describe('~/boards/components/sidebar/board_sidebar_milestone_select.vue', () =>
const createWrapper = ({ milestone = null, loading = false } = {}) => { const createWrapper = ({ milestone = null, loading = false } = {}) => {
store = createStore(); store = createStore();
store.state.issues = { [TEST_ISSUE.id]: { ...TEST_ISSUE, milestone } }; store.state.boardItems = { [TEST_ISSUE.id]: { ...TEST_ISSUE, milestone } };
store.state.activeId = TEST_ISSUE.id; store.state.activeId = TEST_ISSUE.id;
wrapper = shallowMount(BoardSidebarMilestoneSelect, { wrapper = shallowMount(BoardSidebarMilestoneSelect, {
...@@ -113,7 +113,7 @@ describe('~/boards/components/sidebar/board_sidebar_milestone_select.vue', () => ...@@ -113,7 +113,7 @@ describe('~/boards/components/sidebar/board_sidebar_milestone_select.vue', () =>
createWrapper(); createWrapper();
jest.spyOn(wrapper.vm, 'setActiveIssueMilestone').mockImplementation(() => { jest.spyOn(wrapper.vm, 'setActiveIssueMilestone').mockImplementation(() => {
store.state.issues[TEST_ISSUE.id].milestone = TEST_MILESTONE; store.state.boardItems[TEST_ISSUE.id].milestone = TEST_MILESTONE;
}); });
findDropdownItem().vm.$emit('click'); findDropdownItem().vm.$emit('click');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
...@@ -137,7 +137,7 @@ describe('~/boards/components/sidebar/board_sidebar_milestone_select.vue', () => ...@@ -137,7 +137,7 @@ describe('~/boards/components/sidebar/board_sidebar_milestone_select.vue', () =>
createWrapper({ milestone: TEST_MILESTONE }); createWrapper({ milestone: TEST_MILESTONE });
jest.spyOn(wrapper.vm, 'setActiveIssueMilestone').mockImplementation(() => { jest.spyOn(wrapper.vm, 'setActiveIssueMilestone').mockImplementation(() => {
store.state.issues[TEST_ISSUE.id].milestone = null; store.state.boardItems[TEST_ISSUE.id].milestone = null;
}); });
findUnsetMilestoneItem().vm.$emit('click'); findUnsetMilestoneItem().vm.$emit('click');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
......
...@@ -22,7 +22,7 @@ describe('~/boards/components/sidebar/board_sidebar_subscription_spec.vue', () = ...@@ -22,7 +22,7 @@ describe('~/boards/components/sidebar/board_sidebar_subscription_spec.vue', () =
const createComponent = (activeIssue = { ...mockActiveIssue }) => { const createComponent = (activeIssue = { ...mockActiveIssue }) => {
store = createStore(); store = createStore();
store.state.issues = { [activeIssue.id]: activeIssue }; store.state.boardItems = { [activeIssue.id]: activeIssue };
store.state.activeId = activeIssue.id; store.state.activeId = activeIssue.id;
wrapper = mount(BoardSidebarSubscription, { wrapper = mount(BoardSidebarSubscription, {
......
...@@ -573,7 +573,7 @@ describe('fetchItemsForList', () => { ...@@ -573,7 +573,7 @@ describe('fetchItemsForList', () => {
}, },
{ {
type: types.RECEIVE_ITEMS_FOR_LIST_SUCCESS, type: types.RECEIVE_ITEMS_FOR_LIST_SUCCESS,
payload: { listIssues: formattedIssues, listPageInfo, listId }, payload: { listItems: formattedIssues, listPageInfo, listId },
}, },
], ],
[], [],
...@@ -624,8 +624,8 @@ describe('moveIssue', () => { ...@@ -624,8 +624,8 @@ describe('moveIssue', () => {
boardType: 'group', boardType: 'group',
disabled: false, disabled: false,
boardLists: mockLists, boardLists: mockLists,
issuesByListId: listIssues, boardItemsByListId: listIssues,
issues, boardItems: issues,
}; };
it('should commit MOVE_ISSUE mutation and MOVE_ISSUE_SUCCESS mutation when successful', (done) => { it('should commit MOVE_ISSUE mutation and MOVE_ISSUE_SUCCESS mutation when successful', (done) => {
...@@ -905,7 +905,7 @@ describe('addListIssue', () => { ...@@ -905,7 +905,7 @@ describe('addListIssue', () => {
}); });
describe('setActiveIssueLabels', () => { describe('setActiveIssueLabels', () => {
const state = { issues: { [mockIssue.id]: mockIssue } }; const state = { boardItems: { [mockIssue.id]: mockIssue } };
const getters = { activeIssue: mockIssue }; const getters = { activeIssue: mockIssue };
const testLabelIds = labels.map((label) => label.id); const testLabelIds = labels.map((label) => label.id);
const input = { const input = {
...@@ -950,7 +950,7 @@ describe('setActiveIssueLabels', () => { ...@@ -950,7 +950,7 @@ describe('setActiveIssueLabels', () => {
}); });
describe('setActiveIssueDueDate', () => { describe('setActiveIssueDueDate', () => {
const state = { issues: { [mockIssue.id]: mockIssue } }; const state = { boardItems: { [mockIssue.id]: mockIssue } };
const getters = { activeIssue: mockIssue }; const getters = { activeIssue: mockIssue };
const testDueDate = '2020-02-20'; const testDueDate = '2020-02-20';
const input = { const input = {
...@@ -1001,7 +1001,7 @@ describe('setActiveIssueDueDate', () => { ...@@ -1001,7 +1001,7 @@ describe('setActiveIssueDueDate', () => {
}); });
describe('setActiveIssueSubscribed', () => { describe('setActiveIssueSubscribed', () => {
const state = { issues: { [mockActiveIssue.id]: mockActiveIssue } }; const state = { boardItems: { [mockActiveIssue.id]: mockActiveIssue } };
const getters = { activeIssue: mockActiveIssue }; const getters = { activeIssue: mockActiveIssue };
const subscribedState = true; const subscribedState = true;
const input = { const input = {
...@@ -1052,7 +1052,7 @@ describe('setActiveIssueSubscribed', () => { ...@@ -1052,7 +1052,7 @@ describe('setActiveIssueSubscribed', () => {
}); });
describe('setActiveIssueMilestone', () => { describe('setActiveIssueMilestone', () => {
const state = { issues: { [mockIssue.id]: mockIssue } }; const state = { boardItems: { [mockIssue.id]: mockIssue } };
const getters = { activeIssue: mockIssue }; const getters = { activeIssue: mockIssue };
const testMilestone = { const testMilestone = {
...mockMilestone, ...mockMilestone,
...@@ -1106,7 +1106,7 @@ describe('setActiveIssueMilestone', () => { ...@@ -1106,7 +1106,7 @@ describe('setActiveIssueMilestone', () => {
}); });
describe('setActiveIssueTitle', () => { describe('setActiveIssueTitle', () => {
const state = { issues: { [mockIssue.id]: mockIssue } }; const state = { boardItems: { [mockIssue.id]: mockIssue } };
const getters = { activeIssue: mockIssue }; const getters = { activeIssue: mockIssue };
const testTitle = 'Test Title'; const testTitle = 'Test Title';
const input = { const input = {
......
...@@ -38,15 +38,15 @@ describe('Boards - Getters', () => { ...@@ -38,15 +38,15 @@ describe('Boards - Getters', () => {
}); });
}); });
describe('getIssueById', () => { describe('getBoardItemById', () => {
const state = { issues: { 1: 'issue' } }; const state = { boardItems: { 1: 'issue' } };
it.each` it.each`
id | expected id | expected
${'1'} | ${'issue'} ${'1'} | ${'issue'}
${''} | ${{}} ${''} | ${{}}
`('returns $expected when $id is passed to state', ({ id, expected }) => { `('returns $expected when $id is passed to state', ({ id, expected }) => {
expect(getters.getIssueById(state)(id)).toEqual(expected); expect(getters.getBoardItemById(state)(id)).toEqual(expected);
}); });
}); });
...@@ -56,7 +56,7 @@ describe('Boards - Getters', () => { ...@@ -56,7 +56,7 @@ describe('Boards - Getters', () => {
${'1'} | ${'issue'} ${'1'} | ${'issue'}
${''} | ${{}} ${''} | ${{}}
`('returns $expected when $id is passed to state', ({ id, expected }) => { `('returns $expected when $id is passed to state', ({ id, expected }) => {
const state = { issues: { 1: 'issue' }, activeId: id }; const state = { boardItems: { 1: 'issue' }, activeId: id };
expect(getters.activeIssue(state)).toEqual(expected); expect(getters.activeIssue(state)).toEqual(expected);
}); });
...@@ -94,17 +94,18 @@ describe('Boards - Getters', () => { ...@@ -94,17 +94,18 @@ describe('Boards - Getters', () => {
}); });
}); });
describe('getIssuesByList', () => { describe('getBoardItemsByList', () => {
const boardsState = { const boardsState = {
issuesByListId: mockIssuesByListId, boardItemsByListId: mockIssuesByListId,
issues, boardItems: issues,
}; };
it('returns issues for a given listId', () => { it('returns issues for a given listId', () => {
const getIssueById = (issueId) => [mockIssue, mockIssue2].find(({ id }) => id === issueId); const getBoardItemById = (issueId) =>
[mockIssue, mockIssue2].find(({ id }) => id === issueId);
expect(getters.getIssuesByList(boardsState, { getIssueById })('gid://gitlab/List/2')).toEqual( expect(
mockIssues, getters.getBoardItemsByList(boardsState, { getBoardItemById })('gid://gitlab/List/2'),
); ).toEqual(mockIssues);
}); });
}); });
......
...@@ -222,24 +222,24 @@ describe('Board Store Mutations', () => { ...@@ -222,24 +222,24 @@ describe('Board Store Mutations', () => {
}); });
describe('RESET_ISSUES', () => { describe('RESET_ISSUES', () => {
it('should remove issues from issuesByListId state', () => { it('should remove issues from boardItemsByListId state', () => {
const issuesByListId = { const boardItemsByListId = {
'gid://gitlab/List/1': [mockIssue.id], 'gid://gitlab/List/1': [mockIssue.id],
}; };
state = { state = {
...state, ...state,
issuesByListId, boardItemsByListId,
}; };
mutations[types.RESET_ISSUES](state); mutations[types.RESET_ISSUES](state);
expect(state.issuesByListId).toEqual({ 'gid://gitlab/List/1': [] }); expect(state.boardItemsByListId).toEqual({ 'gid://gitlab/List/1': [] });
}); });
}); });
describe('RECEIVE_ITEMS_FOR_LIST_SUCCESS', () => { describe('RECEIVE_ITEMS_FOR_LIST_SUCCESS', () => {
it('updates issuesByListId and issues on state', () => { it('updates boardItemsByListId and issues on state', () => {
const listIssues = { const listIssues = {
'gid://gitlab/List/1': [mockIssue.id], 'gid://gitlab/List/1': [mockIssue.id],
}; };
...@@ -249,10 +249,10 @@ describe('Board Store Mutations', () => { ...@@ -249,10 +249,10 @@ describe('Board Store Mutations', () => {
state = { state = {
...state, ...state,
issuesByListId: { boardItemsByListId: {
'gid://gitlab/List/1': [], 'gid://gitlab/List/1': [],
}, },
issues: {}, boardItems: {},
boardLists: initialBoardListsState, boardLists: initialBoardListsState,
}; };
...@@ -264,13 +264,13 @@ describe('Board Store Mutations', () => { ...@@ -264,13 +264,13 @@ describe('Board Store Mutations', () => {
}; };
mutations.RECEIVE_ITEMS_FOR_LIST_SUCCESS(state, { mutations.RECEIVE_ITEMS_FOR_LIST_SUCCESS(state, {
listIssues: { listData: listIssues, issues }, listItems: { listData: listIssues, boardItems: issues },
listPageInfo, listPageInfo,
listId: 'gid://gitlab/List/1', listId: 'gid://gitlab/List/1',
}); });
expect(state.issuesByListId).toEqual(listIssues); expect(state.boardItemsByListId).toEqual(listIssues);
expect(state.issues).toEqual(issues); expect(state.boardItems).toEqual(issues);
}); });
}); });
...@@ -306,7 +306,7 @@ describe('Board Store Mutations', () => { ...@@ -306,7 +306,7 @@ describe('Board Store Mutations', () => {
state = { state = {
...state, ...state,
error: undefined, error: undefined,
issues: { boardItems: {
...issue, ...issue,
}, },
}; };
...@@ -320,7 +320,7 @@ describe('Board Store Mutations', () => { ...@@ -320,7 +320,7 @@ describe('Board Store Mutations', () => {
value, value,
}); });
expect(state.issues[issueId]).toEqual({ ...issue[issueId], id: '2' }); expect(state.boardItems[issueId]).toEqual({ ...issue[issueId], id: '2' });
}); });
}); });
...@@ -346,7 +346,7 @@ describe('Board Store Mutations', () => { ...@@ -346,7 +346,7 @@ describe('Board Store Mutations', () => {
}); });
describe('MOVE_ISSUE', () => { describe('MOVE_ISSUE', () => {
it('updates issuesByListId, moving issue between lists', () => { it('updates boardItemsByListId, moving issue between lists', () => {
const listIssues = { const listIssues = {
'gid://gitlab/List/1': [mockIssue.id, mockIssue2.id], 'gid://gitlab/List/1': [mockIssue.id, mockIssue2.id],
'gid://gitlab/List/2': [], 'gid://gitlab/List/2': [],
...@@ -359,9 +359,9 @@ describe('Board Store Mutations', () => { ...@@ -359,9 +359,9 @@ describe('Board Store Mutations', () => {
state = { state = {
...state, ...state,
issuesByListId: listIssues, boardItemsByListId: listIssues,
boardLists: initialBoardListsState, boardLists: initialBoardListsState,
issues, boardItems: issues,
}; };
mutations.MOVE_ISSUE(state, { mutations.MOVE_ISSUE(state, {
...@@ -375,7 +375,7 @@ describe('Board Store Mutations', () => { ...@@ -375,7 +375,7 @@ describe('Board Store Mutations', () => {
'gid://gitlab/List/2': [mockIssue2.id], 'gid://gitlab/List/2': [mockIssue2.id],
}; };
expect(state.issuesByListId).toEqual(updatedListIssues); expect(state.boardItemsByListId).toEqual(updatedListIssues);
}); });
}); });
...@@ -387,19 +387,19 @@ describe('Board Store Mutations', () => { ...@@ -387,19 +387,19 @@ describe('Board Store Mutations', () => {
state = { state = {
...state, ...state,
issues, boardItems: issues,
}; };
mutations.MOVE_ISSUE_SUCCESS(state, { mutations.MOVE_ISSUE_SUCCESS(state, {
issue: rawIssue, issue: rawIssue,
}); });
expect(state.issues).toEqual({ 436: { ...mockIssue, id: 436 } }); expect(state.boardItems).toEqual({ 436: { ...mockIssue, id: 436 } });
}); });
}); });
describe('MOVE_ISSUE_FAILURE', () => { describe('MOVE_ISSUE_FAILURE', () => {
it('updates issuesByListId, reverting moving issue between lists, and sets error message', () => { it('updates boardItemsByListId, reverting moving issue between lists, and sets error message', () => {
const listIssues = { const listIssues = {
'gid://gitlab/List/1': [mockIssue.id], 'gid://gitlab/List/1': [mockIssue.id],
'gid://gitlab/List/2': [mockIssue2.id], 'gid://gitlab/List/2': [mockIssue2.id],
...@@ -407,7 +407,7 @@ describe('Board Store Mutations', () => { ...@@ -407,7 +407,7 @@ describe('Board Store Mutations', () => {
state = { state = {
...state, ...state,
issuesByListId: listIssues, boardItemsByListId: listIssues,
boardLists: initialBoardListsState, boardLists: initialBoardListsState,
}; };
...@@ -423,7 +423,7 @@ describe('Board Store Mutations', () => { ...@@ -423,7 +423,7 @@ describe('Board Store Mutations', () => {
'gid://gitlab/List/2': [], 'gid://gitlab/List/2': [],
}; };
expect(state.issuesByListId).toEqual(updatedListIssues); expect(state.boardItemsByListId).toEqual(updatedListIssues);
expect(state.error).toEqual('An error occurred while moving the issue. Please try again.'); expect(state.error).toEqual('An error occurred while moving the issue. Please try again.');
}); });
}); });
...@@ -449,7 +449,7 @@ describe('Board Store Mutations', () => { ...@@ -449,7 +449,7 @@ describe('Board Store Mutations', () => {
}); });
describe('ADD_ISSUE_TO_LIST', () => { describe('ADD_ISSUE_TO_LIST', () => {
it('adds issue to issues state and issue id in list in issuesByListId', () => { it('adds issue to issues state and issue id in list in boardItemsByListId', () => {
const listIssues = { const listIssues = {
'gid://gitlab/List/1': [mockIssue.id], 'gid://gitlab/List/1': [mockIssue.id],
}; };
...@@ -459,8 +459,8 @@ describe('Board Store Mutations', () => { ...@@ -459,8 +459,8 @@ describe('Board Store Mutations', () => {
state = { state = {
...state, ...state,
issuesByListId: listIssues, boardItemsByListId: listIssues,
issues, boardItems: issues,
boardLists: initialBoardListsState, boardLists: initialBoardListsState,
}; };
...@@ -468,14 +468,14 @@ describe('Board Store Mutations', () => { ...@@ -468,14 +468,14 @@ describe('Board Store Mutations', () => {
mutations.ADD_ISSUE_TO_LIST(state, { list: mockLists[0], issue: mockIssue2 }); mutations.ADD_ISSUE_TO_LIST(state, { list: mockLists[0], issue: mockIssue2 });
expect(state.issuesByListId['gid://gitlab/List/1']).toContain(mockIssue2.id); expect(state.boardItemsByListId['gid://gitlab/List/1']).toContain(mockIssue2.id);
expect(state.issues[mockIssue2.id]).toEqual(mockIssue2); expect(state.boardItems[mockIssue2.id]).toEqual(mockIssue2);
expect(state.boardLists['gid://gitlab/List/1'].issuesCount).toBe(2); expect(state.boardLists['gid://gitlab/List/1'].issuesCount).toBe(2);
}); });
}); });
describe('ADD_ISSUE_TO_LIST_FAILURE', () => { describe('ADD_ISSUE_TO_LIST_FAILURE', () => {
it('removes issue id from list in issuesByListId and sets error message', () => { it('removes issue id from list in boardItemsByListId and sets error message', () => {
const listIssues = { const listIssues = {
'gid://gitlab/List/1': [mockIssue.id, mockIssue2.id], 'gid://gitlab/List/1': [mockIssue.id, mockIssue2.id],
}; };
...@@ -486,20 +486,20 @@ describe('Board Store Mutations', () => { ...@@ -486,20 +486,20 @@ describe('Board Store Mutations', () => {
state = { state = {
...state, ...state,
issuesByListId: listIssues, boardItemsByListId: listIssues,
issues, boardItems: issues,
boardLists: initialBoardListsState, boardLists: initialBoardListsState,
}; };
mutations.ADD_ISSUE_TO_LIST_FAILURE(state, { list: mockLists[0], issueId: mockIssue2.id }); mutations.ADD_ISSUE_TO_LIST_FAILURE(state, { list: mockLists[0], issueId: mockIssue2.id });
expect(state.issuesByListId['gid://gitlab/List/1']).not.toContain(mockIssue2.id); expect(state.boardItemsByListId['gid://gitlab/List/1']).not.toContain(mockIssue2.id);
expect(state.error).toBe('An error occurred while creating the issue. Please try again.'); expect(state.error).toBe('An error occurred while creating the issue. Please try again.');
}); });
}); });
describe('REMOVE_ISSUE_FROM_LIST', () => { describe('REMOVE_ISSUE_FROM_LIST', () => {
it('removes issue id from list in issuesByListId and deletes issue from state', () => { it('removes issue id from list in boardItemsByListId and deletes issue from state', () => {
const listIssues = { const listIssues = {
'gid://gitlab/List/1': [mockIssue.id, mockIssue2.id], 'gid://gitlab/List/1': [mockIssue.id, mockIssue2.id],
}; };
...@@ -510,15 +510,15 @@ describe('Board Store Mutations', () => { ...@@ -510,15 +510,15 @@ describe('Board Store Mutations', () => {
state = { state = {
...state, ...state,
issuesByListId: listIssues, boardItemsByListId: listIssues,
issues, boardItems: issues,
boardLists: initialBoardListsState, boardLists: initialBoardListsState,
}; };
mutations.ADD_ISSUE_TO_LIST_FAILURE(state, { list: mockLists[0], issueId: mockIssue2.id }); mutations.ADD_ISSUE_TO_LIST_FAILURE(state, { list: mockLists[0], issueId: mockIssue2.id });
expect(state.issuesByListId['gid://gitlab/List/1']).not.toContain(mockIssue2.id); expect(state.boardItemsByListId['gid://gitlab/List/1']).not.toContain(mockIssue2.id);
expect(state.issues).not.toContain(mockIssue2); expect(state.boardItems).not.toContain(mockIssue2);
}); });
}); });
......
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