diff options
Diffstat (limited to 'spec/frontend/pipelines/graph/job_item_spec.js')
-rw-r--r-- | spec/frontend/pipelines/graph/job_item_spec.js | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/spec/frontend/pipelines/graph/job_item_spec.js b/spec/frontend/pipelines/graph/job_item_spec.js index 3224c87ab6b..5cc2c76f3dd 100644 --- a/spec/frontend/pipelines/graph/job_item_spec.js +++ b/spec/frontend/pipelines/graph/job_item_spec.js @@ -1,10 +1,11 @@ import MockAdapter from 'axios-mock-adapter'; -import { mount } from '@vue/test-utils'; -import { nextTick } from 'vue'; -import { GlBadge, GlModal } from '@gitlab/ui'; +import { shallowMount, mount } from '@vue/test-utils'; +import Vue, { nextTick } from 'vue'; +import { GlBadge, GlModal, GlToast } from '@gitlab/ui'; import JobItem from '~/pipelines/components/graph/job_item.vue'; import axios from '~/lib/utils/axios_utils'; import { useLocalStorageSpy } from 'helpers/local_storage_helper'; +import ActionComponent from '~/pipelines/components/jobs_shared/action_component.vue'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { @@ -19,12 +20,14 @@ import { describe('pipeline graph job item', () => { useLocalStorageSpy(); + Vue.use(GlToast); let wrapper; let mockAxios; const findJobWithoutLink = () => wrapper.findByTestId('job-without-link'); const findJobWithLink = () => wrapper.findByTestId('job-with-link'); + const findActionVueComponent = () => wrapper.findComponent(ActionComponent); const findActionComponent = () => wrapper.findByTestId('ci-action-component'); const findBadge = () => wrapper.findComponent(GlBadge); const findJobLink = () => wrapper.findByTestId('job-with-link'); @@ -41,9 +44,9 @@ describe('pipeline graph job item', () => { job: mockJob, }; - const createWrapper = ({ props, data } = {}) => { + const createWrapper = ({ props, data, mountFn = mount, mocks = {} } = {}) => { wrapper = extendedWrapper( - mount(JobItem, { + mountFn(JobItem, { data() { return { ...data, @@ -53,6 +56,9 @@ describe('pipeline graph job item', () => { ...defaultProps, ...props, }, + mocks: { + ...mocks, + }, }), ); }; @@ -238,6 +244,37 @@ describe('pipeline graph job item', () => { }); }); + describe('when retrying', () => { + const mockToastShow = jest.fn(); + + beforeEach(async () => { + createWrapper({ + mountFn: shallowMount, + data: { + currentSkipModalValue: true, + }, + props: { + skipRetryModal: true, + job: triggerJobWithRetryAction, + }, + mocks: { + $toast: { + show: mockToastShow, + }, + }, + }); + + jest.spyOn(wrapper.vm.$toast, 'show'); + + await findActionVueComponent().vm.$emit('pipelineActionRequestComplete'); + await nextTick(); + }); + + it('shows a toast message that the downstream is being created', () => { + expect(mockToastShow).toHaveBeenCalledTimes(1); + }); + }); + describe('highlighting', () => { it.each` job | jobName | expanded | link |