2021-02-03 21:09:17 +00:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2021-02-14 18:09:20 +00:00
|
|
|
import { nextTick } from 'vue';
|
2021-02-03 21:09:17 +00:00
|
|
|
|
|
|
|
import CommitSection from '~/pipeline_editor/components/commit/commit_section.vue';
|
2021-05-05 15:10:05 +00:00
|
|
|
import PipelineEditorDrawer from '~/pipeline_editor/components/drawer/pipeline_editor_drawer.vue';
|
2021-04-09 18:09:24 +00:00
|
|
|
import PipelineEditorFileNav from '~/pipeline_editor/components/file_nav/pipeline_editor_file_nav.vue';
|
2021-02-03 21:09:17 +00:00
|
|
|
import PipelineEditorHeader from '~/pipeline_editor/components/header/pipeline_editor_header.vue';
|
2021-02-14 18:09:20 +00:00
|
|
|
import PipelineEditorTabs from '~/pipeline_editor/components/pipeline_editor_tabs.vue';
|
2021-02-12 18:08:59 +00:00
|
|
|
import { MERGED_TAB, VISUALIZE_TAB } from '~/pipeline_editor/constants';
|
2021-02-14 18:09:20 +00:00
|
|
|
import PipelineEditorHome from '~/pipeline_editor/pipeline_editor_home.vue';
|
2021-02-03 21:09:17 +00:00
|
|
|
|
|
|
|
import { mockLintResponse, mockCiYml } from './mock_data';
|
|
|
|
|
|
|
|
describe('Pipeline editor home wrapper', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2021-05-05 15:10:05 +00:00
|
|
|
const createComponent = ({ props = {}, glFeatures = {} } = {}) => {
|
2021-02-03 21:09:17 +00:00
|
|
|
wrapper = shallowMount(PipelineEditorHome, {
|
|
|
|
propsData: {
|
|
|
|
ciConfigData: mockLintResponse,
|
|
|
|
ciFileContent: mockCiYml,
|
|
|
|
isCiConfigDataLoading: false,
|
2021-03-26 18:09:16 +00:00
|
|
|
isNewCiConfigFile: false,
|
2021-02-03 21:09:17 +00:00
|
|
|
...props,
|
|
|
|
},
|
2021-05-05 15:10:05 +00:00
|
|
|
provide: {
|
|
|
|
glFeatures: {
|
|
|
|
...glFeatures,
|
|
|
|
},
|
|
|
|
},
|
2021-02-03 21:09:17 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2021-02-12 18:08:59 +00:00
|
|
|
const findCommitSection = () => wrapper.findComponent(CommitSection);
|
2021-04-09 18:09:24 +00:00
|
|
|
const findFileNav = () => wrapper.findComponent(PipelineEditorFileNav);
|
2021-05-05 15:10:05 +00:00
|
|
|
const findPipelineEditorDrawer = () => wrapper.findComponent(PipelineEditorDrawer);
|
|
|
|
const findPipelineEditorHeader = () => wrapper.findComponent(PipelineEditorHeader);
|
|
|
|
const findPipelineEditorTabs = () => wrapper.findComponent(PipelineEditorTabs);
|
2021-02-03 21:09:17 +00:00
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('renders', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
2021-04-09 18:09:24 +00:00
|
|
|
it('shows the file nav', () => {
|
|
|
|
expect(findFileNav().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
2021-02-03 21:09:17 +00:00
|
|
|
it('shows the pipeline editor header', () => {
|
|
|
|
expect(findPipelineEditorHeader().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows the pipeline editor tabs', () => {
|
|
|
|
expect(findPipelineEditorTabs().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
2021-02-12 18:08:59 +00:00
|
|
|
it('shows the commit section by default', () => {
|
|
|
|
expect(findCommitSection().exists()).toBe(true);
|
|
|
|
});
|
2021-05-05 15:10:05 +00:00
|
|
|
|
|
|
|
it('show the pipeline drawer', () => {
|
|
|
|
expect(findPipelineEditorDrawer().exists()).toBe(true);
|
|
|
|
});
|
2021-02-12 18:08:59 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('commit form toggle', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('hides the commit form when in the merged tab', async () => {
|
|
|
|
expect(findCommitSection().exists()).toBe(true);
|
|
|
|
|
|
|
|
findPipelineEditorTabs().vm.$emit('set-current-tab', MERGED_TAB);
|
|
|
|
await nextTick();
|
|
|
|
expect(findCommitSection().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows the form again when leaving the merged tab', async () => {
|
|
|
|
expect(findCommitSection().exists()).toBe(true);
|
|
|
|
|
|
|
|
findPipelineEditorTabs().vm.$emit('set-current-tab', MERGED_TAB);
|
|
|
|
await nextTick();
|
|
|
|
expect(findCommitSection().exists()).toBe(false);
|
|
|
|
|
|
|
|
findPipelineEditorTabs().vm.$emit('set-current-tab', VISUALIZE_TAB);
|
|
|
|
await nextTick();
|
2021-02-03 21:09:17 +00:00
|
|
|
expect(findCommitSection().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|