2020-08-24 02:10:15 -04:00
|
|
|
import Vuex from 'vuex';
|
|
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
|
|
import { GlAlert } from '@gitlab/ui';
|
2020-11-30 07:09:21 -05:00
|
|
|
import Draggable from 'vuedraggable';
|
2020-08-24 02:10:15 -04:00
|
|
|
import EpicsSwimlanes from 'ee_component/boards/components/epics_swimlanes.vue';
|
2020-08-25 02:10:18 -04:00
|
|
|
import getters from 'ee_else_ce/boards/stores/getters';
|
2021-01-18 04:11:05 -05:00
|
|
|
import BoardColumnDeprecated from '~/boards/components/board_column_deprecated.vue';
|
2020-12-14 16:09:47 -05:00
|
|
|
import { mockLists, mockListsWithModel } from '../mock_data';
|
2020-08-24 02:10:15 -04:00
|
|
|
import BoardContent from '~/boards/components/board_content.vue';
|
|
|
|
|
|
|
|
const localVue = createLocalVue();
|
|
|
|
localVue.use(Vuex);
|
|
|
|
|
2020-11-30 07:09:21 -05:00
|
|
|
const actions = {
|
|
|
|
moveList: jest.fn(),
|
|
|
|
};
|
|
|
|
|
2020-08-24 02:10:15 -04:00
|
|
|
describe('BoardContent', () => {
|
|
|
|
let wrapper;
|
2021-01-18 04:11:05 -05:00
|
|
|
window.gon = {};
|
2020-08-24 02:10:15 -04:00
|
|
|
|
|
|
|
const defaultState = {
|
|
|
|
isShowingEpicsSwimlanes: false,
|
2020-12-14 16:09:47 -05:00
|
|
|
boardLists: mockLists,
|
2020-08-24 02:10:15 -04:00
|
|
|
error: undefined,
|
|
|
|
};
|
|
|
|
|
|
|
|
const createStore = (state = defaultState) => {
|
|
|
|
return new Vuex.Store({
|
2020-11-30 07:09:21 -05:00
|
|
|
actions,
|
2020-08-25 02:10:18 -04:00
|
|
|
getters,
|
2020-08-24 02:10:15 -04:00
|
|
|
state,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-11-30 07:09:21 -05:00
|
|
|
const createComponent = ({ state, props = {}, graphqlBoardListsEnabled = false } = {}) => {
|
2020-08-24 02:10:15 -04:00
|
|
|
const store = createStore({
|
|
|
|
...defaultState,
|
|
|
|
...state,
|
|
|
|
});
|
|
|
|
wrapper = shallowMount(BoardContent, {
|
|
|
|
localVue,
|
|
|
|
propsData: {
|
|
|
|
lists: mockListsWithModel,
|
|
|
|
canAdminList: true,
|
|
|
|
disabled: false,
|
2020-11-30 07:09:21 -05:00
|
|
|
...props,
|
|
|
|
},
|
|
|
|
provide: {
|
|
|
|
glFeatures: { graphqlBoardLists: graphqlBoardListsEnabled },
|
2020-08-24 02:10:15 -04:00
|
|
|
},
|
|
|
|
store,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
2021-01-18 04:11:05 -05:00
|
|
|
it('renders a BoardColumnDeprecated component per list', () => {
|
2020-11-30 07:09:21 -05:00
|
|
|
createComponent();
|
|
|
|
|
2021-01-18 04:11:05 -05:00
|
|
|
expect(wrapper.findAllComponents(BoardColumnDeprecated)).toHaveLength(
|
|
|
|
mockListsWithModel.length,
|
|
|
|
);
|
2020-08-24 02:10:15 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('does not display EpicsSwimlanes component', () => {
|
2020-11-30 07:09:21 -05:00
|
|
|
createComponent();
|
|
|
|
|
2020-08-28 08:10:37 -04:00
|
|
|
expect(wrapper.find(EpicsSwimlanes).exists()).toBe(false);
|
|
|
|
expect(wrapper.find(GlAlert).exists()).toBe(false);
|
2020-08-24 02:10:15 -04:00
|
|
|
});
|
2020-11-30 07:09:21 -05:00
|
|
|
|
|
|
|
describe('graphqlBoardLists feature flag enabled', () => {
|
2021-01-18 04:11:05 -05:00
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({ graphqlBoardListsEnabled: true });
|
|
|
|
gon.features = {
|
|
|
|
graphqlBoardLists: true,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2020-11-30 07:09:21 -05:00
|
|
|
describe('can admin list', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({ graphqlBoardListsEnabled: true, props: { canAdminList: true } });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders draggable component', () => {
|
|
|
|
expect(wrapper.find(Draggable).exists()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('can not admin list', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({ graphqlBoardListsEnabled: true, props: { canAdminList: false } });
|
|
|
|
});
|
|
|
|
|
2021-01-18 04:11:05 -05:00
|
|
|
it('does not render draggable component', () => {
|
2020-11-30 07:09:21 -05:00
|
|
|
expect(wrapper.find(Draggable).exists()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('graphqlBoardLists feature flag disabled', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({ graphqlBoardListsEnabled: false });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render draggable component', () => {
|
|
|
|
expect(wrapper.find(Draggable).exists()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
2020-08-24 02:10:15 -04:00
|
|
|
});
|