diff options
Diffstat (limited to 'spec/frontend/pipeline_editor/pipeline_editor_home_spec.js')
-rw-r--r-- | spec/frontend/pipeline_editor/pipeline_editor_home_spec.js | 118 |
1 files changed, 60 insertions, 58 deletions
diff --git a/spec/frontend/pipeline_editor/pipeline_editor_home_spec.js b/spec/frontend/pipeline_editor/pipeline_editor_home_spec.js index bf0f7fd8c9f..c6964f190b4 100644 --- a/spec/frontend/pipeline_editor/pipeline_editor_home_spec.js +++ b/spec/frontend/pipeline_editor/pipeline_editor_home_spec.js @@ -2,6 +2,7 @@ import { shallowMount } from '@vue/test-utils'; import { nextTick } from 'vue'; import { GlButton, GlDrawer, GlModal } from '@gitlab/ui'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; +import setWindowLocation from 'helpers/set_window_location_helper'; import CiEditorHeader from '~/pipeline_editor/components/editor/ci_editor_header.vue'; import CommitSection from '~/pipeline_editor/components/commit/commit_section.vue'; import PipelineEditorDrawer from '~/pipeline_editor/components/drawer/pipeline_editor_drawer.vue'; @@ -11,11 +12,12 @@ import BranchSwitcher from '~/pipeline_editor/components/file_nav/branch_switche import PipelineEditorHeader from '~/pipeline_editor/components/header/pipeline_editor_header.vue'; import PipelineEditorTabs from '~/pipeline_editor/components/pipeline_editor_tabs.vue'; import { - MERGED_TAB, - VISUALIZE_TAB, CREATE_TAB, - LINT_TAB, FILE_TREE_DISPLAY_KEY, + LINT_TAB, + MERGED_TAB, + TABS_INDEX, + VISUALIZE_TAB, } from '~/pipeline_editor/constants'; import PipelineEditorHome from '~/pipeline_editor/pipeline_editor_home.vue'; @@ -162,6 +164,24 @@ describe('Pipeline editor home wrapper', () => { await nextTick(); expect(findCommitSection().exists()).toBe(true); }); + + describe('rendering with tab params', () => { + it.each` + tab | shouldShow + ${MERGED_TAB} | ${false} + ${VISUALIZE_TAB} | ${false} + ${LINT_TAB} | ${false} + ${CREATE_TAB} | ${true} + `( + 'when the tab query param is $tab the commit form is shown: $shouldShow', + async ({ tab, shouldShow }) => { + setWindowLocation(`https://gitlab.test/ci/editor/?tab=${TABS_INDEX[tab]}`); + await createComponent({ stubs: { PipelineEditorTabs } }); + + expect(findCommitSection().exists()).toBe(shouldShow); + }, + ); + }); }); describe('WalkthroughPopover events', () => { @@ -247,81 +267,63 @@ describe('Pipeline editor home wrapper', () => { await nextTick(); }; - describe('with pipelineEditorFileTree feature flag OFF', () => { + describe('button toggle', () => { beforeEach(() => { - createComponent(); + createComponent({ + stubs: { + GlButton, + PipelineEditorFileNav, + }, + }); }); - it('hides the file tree', () => { - expect(findFileTreeBtn().exists()).toBe(false); - expect(findPipelineEditorFileTree().exists()).toBe(false); + it('shows button toggle', () => { + expect(findFileTreeBtn().exists()).toBe(true); }); - }); - - describe('with pipelineEditorFileTree feature flag ON', () => { - describe('button toggle', () => { - beforeEach(() => { - createComponent({ - glFeatures: { - pipelineEditorFileTree: true, - }, - stubs: { - GlButton, - PipelineEditorFileNav, - }, - }); - }); - - it('shows button toggle', () => { - expect(findFileTreeBtn().exists()).toBe(true); - }); - it('toggles the drawer on button click', async () => { - await toggleFileTree(); + it('toggles the drawer on button click', async () => { + await toggleFileTree(); - expect(findPipelineEditorFileTree().exists()).toBe(true); + expect(findPipelineEditorFileTree().exists()).toBe(true); - await toggleFileTree(); + await toggleFileTree(); - expect(findPipelineEditorFileTree().exists()).toBe(false); - }); + expect(findPipelineEditorFileTree().exists()).toBe(false); + }); - it('sets the display state in local storage', async () => { - await toggleFileTree(); + it('sets the display state in local storage', async () => { + await toggleFileTree(); - expect(localStorage.getItem(FILE_TREE_DISPLAY_KEY)).toBe('true'); + expect(localStorage.getItem(FILE_TREE_DISPLAY_KEY)).toBe('true'); - await toggleFileTree(); + await toggleFileTree(); - expect(localStorage.getItem(FILE_TREE_DISPLAY_KEY)).toBe('false'); - }); + expect(localStorage.getItem(FILE_TREE_DISPLAY_KEY)).toBe('false'); }); + }); - describe('when file tree display state is saved in local storage', () => { - beforeEach(() => { - localStorage.setItem(FILE_TREE_DISPLAY_KEY, 'true'); - createComponent({ - glFeatures: { pipelineEditorFileTree: true }, - stubs: { PipelineEditorFileNav }, - }); + describe('when file tree display state is saved in local storage', () => { + beforeEach(() => { + localStorage.setItem(FILE_TREE_DISPLAY_KEY, 'true'); + createComponent({ + stubs: { PipelineEditorFileNav }, }); + }); - it('shows the file tree by default', () => { - expect(findPipelineEditorFileTree().exists()).toBe(true); - }); + it('shows the file tree by default', () => { + expect(findPipelineEditorFileTree().exists()).toBe(true); }); + }); - describe('when file tree display state is not saved in local storage', () => { - beforeEach(() => { - createComponent({ - glFeatures: { pipelineEditorFileTree: true }, - stubs: { PipelineEditorFileNav }, - }); + describe('when file tree display state is not saved in local storage', () => { + beforeEach(() => { + createComponent({ + stubs: { PipelineEditorFileNav }, }); + }); - it('hides the file tree by default', () => { - expect(findPipelineEditorFileTree().exists()).toBe(false); - }); + it('hides the file tree by default', () => { + expect(findPipelineEditorFileTree().exists()).toBe(false); }); }); }); |