diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-04 21:10:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-04 21:10:03 +0300 |
commit | 24f8aa38dc0ddd3489f0c98d5dd0517096caf05e (patch) | |
tree | eaa46caaad6cb5b0e3f4b59ac930c7c2d36396ce /spec/frontend/pipeline_editor | |
parent | be4b3134a282f7a8812306777abd2d3150deecdc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/pipeline_editor')
4 files changed, 44 insertions, 11 deletions
diff --git a/spec/frontend/pipeline_editor/components/ui/pipeline_editor_empty_state_spec.js b/spec/frontend/pipeline_editor/components/ui/pipeline_editor_empty_state_spec.js index b444d9dcfea..76c68e21180 100644 --- a/spec/frontend/pipeline_editor/components/ui/pipeline_editor_empty_state_spec.js +++ b/spec/frontend/pipeline_editor/components/ui/pipeline_editor_empty_state_spec.js @@ -1,11 +1,13 @@ import { GlButton, GlSprintf } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; +import PipelineEditorFileNav from '~/pipeline_editor/components/file_nav/pipeline_editor_file_nav.vue'; import PipelineEditorEmptyState from '~/pipeline_editor/components/ui/pipeline_editor_empty_state.vue'; describe('Pipeline editor empty state', () => { let wrapper; const defaultProvide = { glFeatures: { + pipelineEditorBranchSwitcher: true, pipelineEditorEmptyStateAction: false, }, emptyStateIllustrationPath: 'my/svg/path', @@ -17,6 +19,7 @@ describe('Pipeline editor empty state', () => { }); }; + const findFileNav = () => wrapper.findComponent(PipelineEditorFileNav); const findSvgImage = () => wrapper.find('img'); const findTitle = () => wrapper.find('h1'); const findConfirmButton = () => wrapper.findComponent(GlButton); @@ -45,6 +48,10 @@ describe('Pipeline editor empty state', () => { expect(findDescription().html()).toContain(wrapper.vm.$options.i18n.body); }); + it('renders the file nav', () => { + expect(findFileNav().exists()).toBe(true); + }); + describe('with feature flag off', () => { it('does not renders a CTA button', () => { expect(findConfirmButton().exists()).toBe(false); @@ -75,5 +82,17 @@ describe('Pipeline editor empty state', () => { await findConfirmButton().vm.$emit('click'); expect(wrapper.emitted(expectedEvent)).toHaveLength(1); }); + + describe('with branch switcher feature flag OFF', () => { + it('does not render the file nav', () => { + createComponent({ + provide: { + glFeatures: { pipelineEditorBranchSwitcher: false }, + }, + }); + + expect(findFileNav().exists()).toBe(false); + }); + }); }); }); diff --git a/spec/frontend/pipeline_editor/graphql/__snapshots__/resolvers_spec.js.snap b/spec/frontend/pipeline_editor/graphql/__snapshots__/resolvers_spec.js.snap index 8670c44f6f6..ee5a3cb288f 100644 --- a/spec/frontend/pipeline_editor/graphql/__snapshots__/resolvers_spec.js.snap +++ b/spec/frontend/pipeline_editor/graphql/__snapshots__/resolvers_spec.js.snap @@ -17,7 +17,7 @@ Object { "environment": "prd", "except": Object { "refs": Array [ - "master@gitlab-org/gitlab", + "main@gitlab-org/gitlab", "/^release/.*$/@gitlab-org/gitlab", ], }, @@ -44,7 +44,7 @@ Object { "environment": "stg", "except": Object { "refs": Array [ - "master@gitlab-org/gitlab", + "main@gitlab-org/gitlab", "/^release/.*$/@gitlab-org/gitlab", ], }, diff --git a/spec/frontend/pipeline_editor/mock_data.js b/spec/frontend/pipeline_editor/mock_data.js index 7f651a42231..d13ac2780ca 100644 --- a/spec/frontend/pipeline_editor/mock_data.js +++ b/spec/frontend/pipeline_editor/mock_data.js @@ -4,7 +4,7 @@ import { unwrapStagesWithNeeds } from '~/pipelines/components/unwrapping_utils'; export const mockProjectNamespace = 'user1'; export const mockProjectPath = 'project1'; export const mockProjectFullPath = `${mockProjectNamespace}/${mockProjectPath}`; -export const mockDefaultBranch = 'master'; +export const mockDefaultBranch = 'main'; export const mockNewMergeRequestPath = '/-/merge_requests/new'; export const mockCommitSha = 'aabbccdd'; export const mockCommitNextSha = 'eeffgghh'; @@ -143,7 +143,6 @@ export const mockProjectBranches = { repository: { __typename: 'Repository', branches: [ - { __typename: 'Branch', name: 'master' }, { __typename: 'Branch', name: 'main' }, { __typename: 'Branch', name: 'develop' }, { __typename: 'Branch', name: 'production' }, @@ -186,7 +185,7 @@ export const mockLintResponse = { when: 'on_success', allow_failure: false, only: null, - except: { refs: ['master@gitlab-org/gitlab', '/^release/.*$/@gitlab-org/gitlab'] }, + except: { refs: ['main@gitlab-org/gitlab', '/^release/.*$/@gitlab-org/gitlab'] }, }, { name: 'job_2', @@ -199,7 +198,7 @@ export const mockLintResponse = { when: 'on_success', allow_failure: true, only: { refs: ['web', 'chat', 'pushes'] }, - except: { refs: ['master@gitlab-org/gitlab', '/^release/.*$/@gitlab-org/gitlab'] }, + except: { refs: ['main@gitlab-org/gitlab', '/^release/.*$/@gitlab-org/gitlab'] }, }, ], }; @@ -242,7 +241,7 @@ export const mockJobs = [ when: 'on_success', allowFailure: false, only: { refs: ['branches@gitlab-org/gitlab'] }, - except: { refs: ['master@gitlab-org/gitlab', '/^release/.*$/@gitlab-org/gitlab'] }, + except: { refs: ['main@gitlab-org/gitlab', '/^release/.*$/@gitlab-org/gitlab'] }, }, ]; diff --git a/spec/frontend/pipeline_editor/pipeline_editor_app_spec.js b/spec/frontend/pipeline_editor/pipeline_editor_app_spec.js index b3cc1a1479e..c88fe159c0d 100644 --- a/spec/frontend/pipeline_editor/pipeline_editor_app_spec.js +++ b/spec/frontend/pipeline_editor/pipeline_editor_app_spec.js @@ -301,20 +301,35 @@ describe('Pipeline editor app component', () => { }); describe('when refetching content', () => { - beforeEach(async () => { + it('refetches blob content', async () => { await createComponentWithApollo(); - jest .spyOn(wrapper.vm.$apollo.queries.initialCiFileContent, 'refetch') .mockImplementation(jest.fn()); - }); - it('refetches blob content', async () => { expect(wrapper.vm.$apollo.queries.initialCiFileContent.refetch).toHaveBeenCalledTimes(0); await wrapper.vm.refetchContent(); expect(wrapper.vm.$apollo.queries.initialCiFileContent.refetch).toHaveBeenCalledTimes(1); }); + + it('hides start screen when refetch fetches CI file', async () => { + mockBlobContentData.mockRejectedValue({ + response: { + status: httpStatusCodes.NOT_FOUND, + }, + }); + await createComponentWithApollo(); + + expect(findEmptyState().exists()).toBe(true); + expect(findEditorHome().exists()).toBe(false); + + mockBlobContentData.mockResolvedValue(mockCiYml); + await wrapper.vm.$apollo.queries.initialCiFileContent.refetch(); + + expect(findEmptyState().exists()).toBe(false); + expect(findEditorHome().exists()).toBe(true); + }); }); }); |