2021-06-17 15:10:03 +00:00
|
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
2021-12-09 09:11:03 +00:00
|
|
|
import VueApollo from 'vue-apollo';
|
2021-06-17 15:10:03 +00:00
|
|
|
import Vuex from 'vuex';
|
2019-04-19 04:43:51 +00:00
|
|
|
|
2021-06-17 15:10:03 +00:00
|
|
|
import BoardCard from '~/boards/components/board_card.vue';
|
|
|
|
import BoardList from '~/boards/components/board_list.vue';
|
|
|
|
import BoardNewIssue from '~/boards/components/board_new_issue.vue';
|
2021-07-21 00:09:07 +00:00
|
|
|
import BoardNewItem from '~/boards/components/board_new_item.vue';
|
2021-06-17 15:10:03 +00:00
|
|
|
import defaultState from '~/boards/stores/state';
|
2021-12-09 09:11:03 +00:00
|
|
|
import createMockApollo from 'helpers/mock_apollo_helper';
|
|
|
|
import listQuery from '~/boards/graphql/board_lists_deferred.query.graphql';
|
|
|
|
import {
|
|
|
|
mockList,
|
|
|
|
mockIssuesByListId,
|
|
|
|
issues,
|
|
|
|
mockGroupProjects,
|
|
|
|
boardListQueryResponse,
|
|
|
|
} from './mock_data';
|
2019-04-19 04:43:51 +00:00
|
|
|
|
2019-11-12 15:06:26 +00:00
|
|
|
export default function createComponent({
|
|
|
|
listIssueProps = {},
|
|
|
|
componentProps = {},
|
|
|
|
listProps = {},
|
2021-06-17 15:10:03 +00:00
|
|
|
actions = {},
|
|
|
|
getters = {},
|
|
|
|
provide = {},
|
2021-12-09 09:11:03 +00:00
|
|
|
data = {},
|
2021-06-17 15:10:03 +00:00
|
|
|
state = defaultState,
|
|
|
|
stubs = {
|
|
|
|
BoardNewIssue,
|
2021-07-21 00:09:07 +00:00
|
|
|
BoardNewItem,
|
2021-06-17 15:10:03 +00:00
|
|
|
BoardCard,
|
|
|
|
},
|
2021-12-09 09:11:03 +00:00
|
|
|
issuesCount,
|
2021-06-17 15:10:03 +00:00
|
|
|
} = {}) {
|
|
|
|
const localVue = createLocalVue();
|
2021-12-09 09:11:03 +00:00
|
|
|
localVue.use(VueApollo);
|
2021-06-17 15:10:03 +00:00
|
|
|
localVue.use(Vuex);
|
2019-04-19 04:43:51 +00:00
|
|
|
|
2021-12-09 09:11:03 +00:00
|
|
|
const fakeApollo = createMockApollo([
|
|
|
|
[listQuery, jest.fn().mockResolvedValue(boardListQueryResponse(issuesCount))],
|
|
|
|
]);
|
|
|
|
|
2021-06-17 15:10:03 +00:00
|
|
|
const store = new Vuex.Store({
|
|
|
|
state: {
|
2021-07-21 00:09:07 +00:00
|
|
|
selectedProject: mockGroupProjects[0],
|
2021-06-17 15:10:03 +00:00
|
|
|
boardItemsByListId: mockIssuesByListId,
|
|
|
|
boardItems: issues,
|
|
|
|
pageInfoByListId: {
|
|
|
|
'gid://gitlab/List/1': { hasNextPage: true },
|
|
|
|
'gid://gitlab/List/2': {},
|
|
|
|
},
|
|
|
|
listsFlags: {
|
|
|
|
'gid://gitlab/List/1': {},
|
|
|
|
'gid://gitlab/List/2': {},
|
|
|
|
},
|
|
|
|
selectedBoardItems: [],
|
|
|
|
...state,
|
|
|
|
},
|
|
|
|
getters: {
|
|
|
|
isGroupBoard: () => false,
|
|
|
|
isProjectBoard: () => true,
|
|
|
|
isEpicBoard: () => false,
|
|
|
|
...getters,
|
|
|
|
},
|
|
|
|
actions,
|
|
|
|
});
|
2019-04-19 04:43:51 +00:00
|
|
|
|
2021-06-17 15:10:03 +00:00
|
|
|
const list = {
|
|
|
|
...mockList,
|
|
|
|
...listProps,
|
|
|
|
};
|
|
|
|
const issue = {
|
2019-04-19 04:43:51 +00:00
|
|
|
title: 'Testing',
|
|
|
|
id: 1,
|
|
|
|
iid: 1,
|
|
|
|
confidential: false,
|
|
|
|
labels: [],
|
|
|
|
assignees: [],
|
|
|
|
...listIssueProps,
|
2021-06-17 15:10:03 +00:00
|
|
|
};
|
|
|
|
if (!Object.prototype.hasOwnProperty.call(listProps, 'issuesCount')) {
|
|
|
|
list.issuesCount = 1;
|
2019-11-12 15:06:26 +00:00
|
|
|
}
|
2019-04-19 04:43:51 +00:00
|
|
|
|
2021-06-17 15:10:03 +00:00
|
|
|
const component = shallowMount(BoardList, {
|
2021-12-09 09:11:03 +00:00
|
|
|
apolloProvider: fakeApollo,
|
2021-06-17 15:10:03 +00:00
|
|
|
localVue,
|
2019-10-28 15:05:58 +00:00
|
|
|
store,
|
2019-04-19 04:43:51 +00:00
|
|
|
propsData: {
|
|
|
|
disabled: false,
|
|
|
|
list,
|
2021-06-17 15:10:03 +00:00
|
|
|
boardItems: [issue],
|
|
|
|
canAdminList: true,
|
2019-04-19 04:43:51 +00:00
|
|
|
...componentProps,
|
|
|
|
},
|
2020-09-17 09:09:32 +00:00
|
|
|
provide: {
|
|
|
|
groupId: null,
|
|
|
|
rootPath: '/',
|
2021-07-21 00:09:07 +00:00
|
|
|
boardId: '1',
|
2021-06-17 15:10:03 +00:00
|
|
|
weightFeatureAvailable: false,
|
|
|
|
boardWeight: null,
|
|
|
|
canAdminList: true,
|
|
|
|
...provide,
|
2020-09-17 09:09:32 +00:00
|
|
|
},
|
2021-06-17 15:10:03 +00:00
|
|
|
stubs,
|
2021-12-09 09:11:03 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
...data,
|
|
|
|
};
|
|
|
|
},
|
2019-04-19 04:43:51 +00:00
|
|
|
});
|
|
|
|
|
2021-06-17 15:10:03 +00:00
|
|
|
return component;
|
2019-04-19 04:43:51 +00:00
|
|
|
}
|