debian-mirror-gitlab/spec/frontend/boards/components/board_content_spec.js

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

109 lines
2.7 KiB
JavaScript
Raw Normal View History

2020-11-24 15:15:51 +05:30
import { GlAlert } from '@gitlab/ui';
2021-09-30 23:02:18 +05:30
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
2021-02-22 17:27:13 +05:30
import Draggable from 'vuedraggable';
2021-03-11 19:13:27 +05:30
import Vuex from 'vuex';
2020-11-24 15:15:51 +05:30
import EpicsSwimlanes from 'ee_component/boards/components/epics_swimlanes.vue';
import getters from 'ee_else_ce/boards/stores/getters';
2021-11-11 11:23:49 +05:30
import BoardColumn from '~/boards/components/board_column.vue';
2020-11-24 15:15:51 +05:30
import BoardContent from '~/boards/components/board_content.vue';
2021-11-11 11:23:49 +05:30
import BoardContentSidebar from '~/boards/components/board_content_sidebar.vue';
import { mockLists } from '../mock_data';
2020-11-24 15:15:51 +05:30
2021-09-30 23:02:18 +05:30
Vue.use(Vuex);
2020-11-24 15:15:51 +05:30
2021-02-22 17:27:13 +05:30
const actions = {
moveList: jest.fn(),
};
2020-11-24 15:15:51 +05:30
describe('BoardContent', () => {
let wrapper;
2021-03-08 18:12:59 +05:30
window.gon = {};
2020-11-24 15:15:51 +05:30
const defaultState = {
isShowingEpicsSwimlanes: false,
2021-02-22 17:27:13 +05:30
boardLists: mockLists,
2020-11-24 15:15:51 +05:30
error: undefined,
2021-11-11 11:23:49 +05:30
issuableType: 'issue',
2020-11-24 15:15:51 +05:30
};
const createStore = (state = defaultState) => {
return new Vuex.Store({
2021-02-22 17:27:13 +05:30
actions,
2020-11-24 15:15:51 +05:30
getters,
state,
});
};
2021-11-11 11:23:49 +05:30
const createComponent = ({ state, props = {}, canAdminList = true } = {}) => {
2020-11-24 15:15:51 +05:30
const store = createStore({
...defaultState,
...state,
});
wrapper = shallowMount(BoardContent, {
propsData: {
2021-11-11 11:23:49 +05:30
lists: mockLists,
2020-11-24 15:15:51 +05:30
disabled: false,
2021-02-22 17:27:13 +05:30
...props,
},
provide: {
2021-04-29 21:17:54 +05:30
canAdminList,
2020-11-24 15:15:51 +05:30
},
store,
});
};
afterEach(() => {
wrapper.destroy();
});
2021-11-11 11:23:49 +05:30
describe('default', () => {
beforeEach(() => {
createComponent();
});
2021-02-22 17:27:13 +05:30
2021-11-11 11:23:49 +05:30
it('renders a BoardColumn component per list', () => {
expect(wrapper.findAllComponents(BoardColumn)).toHaveLength(mockLists.length);
});
2020-11-24 15:15:51 +05:30
2021-11-11 11:23:49 +05:30
it('renders BoardContentSidebar', () => {
2022-08-27 11:52:29 +05:30
expect(wrapper.findComponent(BoardContentSidebar).exists()).toBe(true);
2021-11-11 11:23:49 +05:30
});
2021-02-22 17:27:13 +05:30
2021-11-11 11:23:49 +05:30
it('does not display EpicsSwimlanes component', () => {
2022-08-27 11:52:29 +05:30
expect(wrapper.findComponent(EpicsSwimlanes).exists()).toBe(false);
expect(wrapper.findComponent(GlAlert).exists()).toBe(false);
2021-11-11 11:23:49 +05:30
});
2020-11-24 15:15:51 +05:30
});
2021-02-22 17:27:13 +05:30
2021-11-11 11:23:49 +05:30
describe('when issuableType is not issue', () => {
2021-03-08 18:12:59 +05:30
beforeEach(() => {
2021-11-11 11:23:49 +05:30
createComponent({ state: { issuableType: 'foo' } });
2021-03-08 18:12:59 +05:30
});
2021-11-11 11:23:49 +05:30
it('does not render BoardContentSidebar', () => {
2022-08-27 11:52:29 +05:30
expect(wrapper.findComponent(BoardContentSidebar).exists()).toBe(false);
2021-02-22 17:27:13 +05:30
});
2021-11-11 11:23:49 +05:30
});
2021-02-22 17:27:13 +05:30
2021-11-11 11:23:49 +05:30
describe('can admin list', () => {
beforeEach(() => {
createComponent({ canAdminList: true });
});
2021-02-22 17:27:13 +05:30
2021-11-11 11:23:49 +05:30
it('renders draggable component', () => {
2022-08-27 11:52:29 +05:30
expect(wrapper.findComponent(Draggable).exists()).toBe(true);
2021-02-22 17:27:13 +05:30
});
});
2021-11-11 11:23:49 +05:30
describe('can not admin list', () => {
2021-02-22 17:27:13 +05:30
beforeEach(() => {
2021-11-11 11:23:49 +05:30
createComponent({ canAdminList: false });
2021-02-22 17:27:13 +05:30
});
it('does not render draggable component', () => {
2022-08-27 11:52:29 +05:30
expect(wrapper.findComponent(Draggable).exists()).toBe(false);
2021-02-22 17:27:13 +05:30
});
});
2020-11-24 15:15:51 +05:30
});