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 {
addList: ({ commit, dispatch, getters }, list) => {
commit(types.RECEIVE_ADD_LIST_SUCCESS, updateListPosition(list));
dispatch('fetchItemsForList', {
listId: getters.getListByTitle(ListTypeTitles.backlog).id,
listId: getters.getListByTitle(ListTypeTitles.backlog)?.id,
});
},
......@@ -294,7 +295,7 @@ export default {
commit(types.REMOVE_LIST_FAILURE, listsBackup);
} else {
dispatch('fetchItemsForList', {
listId: getters.getListByTitle(ListTypeTitles.backlog).id,
listId: getters.getListByTitle(ListTypeTitles.backlog)?.id,
});
}
},
......@@ -305,6 +306,8 @@ export default {
},
fetchItemsForList: ({ state, commit }, { listId, fetchNext = false }) => {
if (!listId) return null;
if (!fetchNext) {
commit(types.RESET_ITEMS_FOR_LIST, listId);
}
......
......@@ -262,6 +262,8 @@ export default {
{ state, commit, getters },
{ listId, fetchNext = false, noEpicIssues = false },
) => {
if (!listId) return null;
if (!fetchNext && !state.isShowingEpicsSwimlanes) {
commit(types.RESET_ITEMS_FOR_LIST, listId);
}
......
......@@ -345,6 +345,19 @@ describe('fetchItemsForList', () => {
[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', () => {
state = {
...state,
......
......@@ -291,7 +291,7 @@ export const setMockEndpoints = (opts = {}) => {
export const mockList = {
id: 'gid://gitlab/List/1',
title: 'Backlog',
title: 'Open',
position: -Infinity,
listType: 'backlog',
collapsed: false,
......
......@@ -715,6 +715,19 @@ describe('fetchItemsForList', () => {
[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) => {
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