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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

115 lines
2.5 KiB
JavaScript
Raw Normal View History

2022-04-04 11:22:00 +05:30
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
2022-01-26 12:08:38 +05:30
import VueApollo from 'vue-apollo';
2021-09-30 23:02:18 +05:30
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';
2022-01-26 12:08:38 +05:30
import createMockApollo from 'helpers/mock_apollo_helper';
import listQuery from 'ee_else_ce/boards/graphql/board_lists_deferred.query.graphql';
import {
mockList,
mockIssuesByListId,
issues,
mockGroupProjects,
boardListQueryResponse,
} 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 = {},
2022-01-26 12:08:38 +05:30
data = {},
2021-09-30 23:02:18 +05:30
state = defaultState,
stubs = {
BoardNewIssue,
2021-10-27 15:23:28 +05:30
BoardNewItem,
2021-09-30 23:02:18 +05:30
BoardCard,
},
2022-01-26 12:08:38 +05:30
issuesCount,
2021-09-30 23:02:18 +05:30
} = {}) {
2022-04-04 11:22:00 +05:30
Vue.use(VueApollo);
Vue.use(Vuex);
2019-07-31 22:56:46 +05:30
2022-01-26 12:08:38 +05:30
const fakeApollo = createMockApollo([
[listQuery, jest.fn().mockResolvedValue(boardListQueryResponse(issuesCount))],
]);
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, {
2022-01-26 12:08:38 +05:30
apolloProvider: fakeApollo,
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,
2022-01-26 12:08:38 +05:30
data() {
return {
...data,
};
},
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
}