Commit a9593d19 authored by Simon Knox's avatar Simon Knox

Merge branch 'ss/fix-board-list-create-delete-issue' into 'master'

Add conditional to fix error when creating or deleting a board list

See merge request gitlab-org/gitlab!66297
parents 40735f54 5b348fb0
...@@ -173,8 +173,9 @@ export default { ...@@ -173,8 +173,9 @@ export default {
addList: ({ commit, dispatch, getters }, list) => { addList: ({ commit, dispatch, getters }, list) => {
commit(types.RECEIVE_ADD_LIST_SUCCESS, updateListPosition(list)); commit(types.RECEIVE_ADD_LIST_SUCCESS, updateListPosition(list));
dispatch('fetchItemsForList', { dispatch('fetchItemsForList', {
listId: getters.getListByTitle(ListTypeTitles.backlog).id, listId: getters.getListByTitle(ListTypeTitles.backlog)?.id,
}); });
}, },
...@@ -294,7 +295,7 @@ export default { ...@@ -294,7 +295,7 @@ export default {
commit(types.REMOVE_LIST_FAILURE, listsBackup); commit(types.REMOVE_LIST_FAILURE, listsBackup);
} else { } else {
dispatch('fetchItemsForList', { dispatch('fetchItemsForList', {
listId: getters.getListByTitle(ListTypeTitles.backlog).id, listId: getters.getListByTitle(ListTypeTitles.backlog)?.id,
}); });
} }
}, },
...@@ -305,6 +306,8 @@ export default { ...@@ -305,6 +306,8 @@ export default {
}, },
fetchItemsForList: ({ state, commit }, { listId, fetchNext = false }) => { fetchItemsForList: ({ state, commit }, { listId, fetchNext = false }) => {
if (!listId) return null;
if (!fetchNext) { if (!fetchNext) {
commit(types.RESET_ITEMS_FOR_LIST, listId); commit(types.RESET_ITEMS_FOR_LIST, listId);
} }
......
...@@ -262,6 +262,8 @@ export default { ...@@ -262,6 +262,8 @@ export default {
{ state, commit, getters }, { state, commit, getters },
{ listId, fetchNext = false, noEpicIssues = false }, { listId, fetchNext = false, noEpicIssues = false },
) => { ) => {
if (!listId) return null;
if (!fetchNext && !state.isShowingEpicsSwimlanes) { if (!fetchNext && !state.isShowingEpicsSwimlanes) {
commit(types.RESET_ITEMS_FOR_LIST, listId); commit(types.RESET_ITEMS_FOR_LIST, listId);
} }
......
...@@ -345,6 +345,19 @@ describe('fetchItemsForList', () => { ...@@ -345,6 +345,19 @@ describe('fetchItemsForList', () => {
[listId]: pageInfo, [listId]: pageInfo,
}; };
describe('when listId is undefined', () => {
it('does not call the query', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
await actions.fetchItemsForList(
{ state, getters: () => {}, commit: () => {} },
{ listId: undefined },
);
expect(gqlClient.query).toHaveBeenCalledTimes(0);
});
});
it('add epicWildcardId with NONE as value when noEpicIssues is true', () => { it('add epicWildcardId with NONE as value when noEpicIssues is true', () => {
state = { state = {
...state, ...state,
......
...@@ -291,7 +291,7 @@ export const setMockEndpoints = (opts = {}) => { ...@@ -291,7 +291,7 @@ export const setMockEndpoints = (opts = {}) => {
export const mockList = { export const mockList = {
id: 'gid://gitlab/List/1', id: 'gid://gitlab/List/1',
title: 'Backlog', title: 'Open',
position: -Infinity, position: -Infinity,
listType: 'backlog', listType: 'backlog',
collapsed: false, collapsed: false,
......
...@@ -715,6 +715,19 @@ describe('fetchItemsForList', () => { ...@@ -715,6 +715,19 @@ describe('fetchItemsForList', () => {
[listId]: pageInfo, [listId]: pageInfo,
}; };
describe('when list id is undefined', () => {
it('does not call the query', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
await actions.fetchItemsForList(
{ state, getters: () => {}, commit: () => {} },
{ listId: undefined },
);
expect(gqlClient.query).toHaveBeenCalledTimes(0);
});
});
it('should commit mutations REQUEST_ITEMS_FOR_LIST and RECEIVE_ITEMS_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); jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
......
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