debian-mirror-gitlab/spec/frontend/boards/board_list_helper.js

94 lines
2.1 KiB
JavaScript
Raw Normal View History

2021-09-30 23:02:18 +05:30
import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex';
2019-07-31 22:56:46 +05:30
2021-09-30 23:02:18 +05:30
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-10-27 15:23:28 +05:30
import BoardNewItem from '~/boards/components/board_new_item.vue';
2021-09-30 23:02:18 +05:30
import defaultState from '~/boards/stores/state';
2021-10-27 15:23:28 +05:30
import { mockList, mockIssuesByListId, issues, mockGroupProjects } from './mock_data';
2019-07-31 22:56:46 +05:30
2019-12-26 22:10:19 +05:30
export default function createComponent({
listIssueProps = {},
componentProps = {},
listProps = {},
2021-09-30 23:02:18 +05:30
actions = {},
getters = {},
provide = {},
state = defaultState,
stubs = {
BoardNewIssue,
2021-10-27 15:23:28 +05:30
BoardNewItem,
2021-09-30 23:02:18 +05:30
BoardCard,
},
} = {}) {
const localVue = createLocalVue();
localVue.use(Vuex);
2019-07-31 22:56:46 +05:30
2021-09-30 23:02:18 +05:30
const store = new Vuex.Store({
state: {
2021-10-27 15:23:28 +05:30
selectedProject: mockGroupProjects[0],
2021-09-30 23:02:18 +05:30
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-07-31 22:56:46 +05:30
2021-09-30 23:02:18 +05:30
const list = {
...mockList,
...listProps,
};
const issue = {
2019-07-31 22:56:46 +05:30
title: 'Testing',
id: 1,
iid: 1,
confidential: false,
labels: [],
assignees: [],
...listIssueProps,
2021-09-30 23:02:18 +05:30
};
if (!Object.prototype.hasOwnProperty.call(listProps, 'issuesCount')) {
list.issuesCount = 1;
2019-12-26 22:10:19 +05:30
}
2019-07-31 22:56:46 +05:30
2021-09-30 23:02:18 +05:30
const component = shallowMount(BoardList, {
localVue,
2019-12-26 22:10:19 +05:30
store,
2019-07-31 22:56:46 +05:30
propsData: {
disabled: false,
list,
2021-09-30 23:02:18 +05:30
boardItems: [issue],
canAdminList: true,
2019-07-31 22:56:46 +05:30
...componentProps,
},
2020-11-24 15:15:51 +05:30
provide: {
groupId: null,
rootPath: '/',
2021-10-27 15:23:28 +05:30
boardId: '1',
2021-09-30 23:02:18 +05:30
weightFeatureAvailable: false,
boardWeight: null,
canAdminList: true,
...provide,
2020-11-24 15:15:51 +05:30
},
2021-09-30 23:02:18 +05:30
stubs,
2019-07-31 22:56:46 +05:30
});
2021-09-30 23:02:18 +05:30
return component;
2019-07-31 22:56:46 +05:30
}