diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-18 21:07:53 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-18 21:07:53 +0300 |
commit | e69b62ceed2f15335d9526923f8f72f5ca5ea6aa (patch) | |
tree | e36510511cb555865375117fd1c2208e09eea970 /spec/frontend/pipelines | |
parent | 493e288e6de17f2d85fe981f8bb0b9dfabdf9c6d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/pipelines')
-rw-r--r-- | spec/frontend/pipelines/pipeline_details_header_spec.js | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/spec/frontend/pipelines/pipeline_details_header_spec.js b/spec/frontend/pipelines/pipeline_details_header_spec.js new file mode 100644 index 00000000000..c049dad9e53 --- /dev/null +++ b/spec/frontend/pipelines/pipeline_details_header_spec.js @@ -0,0 +1,71 @@ +import { GlLoadingIcon } from '@gitlab/ui'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; +import VueApollo from 'vue-apollo'; +import createMockApollo from 'helpers/mock_apollo_helper'; +import waitForPromises from 'helpers/wait_for_promises'; +import PipelineDetailsHeader from '~/pipelines/components/pipeline_details_header.vue'; +import CiBadgeLink from '~/vue_shared/components/ci_badge_link.vue'; +import getPipelineDetailsQuery from '~/pipelines/graphql/queries/get_pipeline_header_data.query.graphql'; +import { mockSuccessfulPipelineHeader } from './mock_data'; + +Vue.use(VueApollo); + +describe('Pipeline details header', () => { + let wrapper; + + const successHandler = jest.fn().mockResolvedValue(mockSuccessfulPipelineHeader); + + const findStatus = () => wrapper.findComponent(CiBadgeLink); + const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon); + + const defaultHandlers = [[getPipelineDetailsQuery, successHandler]]; + + const defaultProvideOptions = { + pipelineId: '14', + pipelineIid: 1, + paths: { + pipelinesPath: '/namespace/my-project/-/pipelines', + fullProject: '/namespace/my-project', + }, + }; + + const createMockApolloProvider = (handlers) => { + return createMockApollo(handlers); + }; + + const createComponent = (handlers = defaultHandlers) => { + wrapper = shallowMount(PipelineDetailsHeader, { + provide: { + ...defaultProvideOptions, + }, + apolloProvider: createMockApolloProvider(handlers), + }); + }; + + describe('loading state', () => { + it('shows a loading state while graphQL is fetching initial data', () => { + createComponent(); + + expect(findLoadingIcon().exists()).toBe(true); + }); + }); + + describe('loaded state', () => { + it('does not display loading icon', async () => { + createComponent(); + + await waitForPromises(); + + expect(findLoadingIcon().exists()).toBe(false); + }); + + it('displays pipeline status', async () => { + createComponent(); + + await waitForPromises(); + + expect(findStatus().exists()).toBe(true); + }); + }); +}); |