diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-07 12:09:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-07 12:09:10 +0300 |
commit | 9f99bf3b0e3516471806f3595e1619b8e9af2a80 (patch) | |
tree | dbea567a765fef90de4c2f1877e05eaa8d73aad0 /spec/frontend | |
parent | 95a6825e19809cae0cee779c0ca3667b233a58f4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/jobs/components/job/job_app_spec.js | 27 | ||||
-rw-r--r-- | spec/frontend/jobs/components/job/manual_variables_form_spec.js | 15 | ||||
-rw-r--r-- | spec/frontend/jobs/components/job/mock_data.js | 22 |
3 files changed, 64 insertions, 0 deletions
diff --git a/spec/frontend/jobs/components/job/job_app_spec.js b/spec/frontend/jobs/components/job/job_app_spec.js index a38616dad8d..cefedcd82fb 100644 --- a/spec/frontend/jobs/components/job/job_app_spec.js +++ b/spec/frontend/jobs/components/job/job_app_spec.js @@ -16,7 +16,9 @@ import UnmetPrerequisitesBlock from '~/jobs/components/job/unmet_prerequisites_b import createStore from '~/jobs/store'; import axios from '~/lib/utils/axios_utils'; import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; +import { MANUAL_STATUS } from '~/jobs/constants'; import job from '../../mock_data'; +import { mockPendingJobData } from './mock_data'; describe('Job App', () => { Vue.use(Vuex); @@ -311,4 +313,29 @@ describe('Job App', () => { expect(findJobLog().exists()).toBe(true); }); }); + + describe('job log polling', () => { + beforeEach(() => { + jest.spyOn(store, 'dispatch'); + }); + + it('should poll job log by default', async () => { + await setupAndMount({ + jobData: mockPendingJobData, + }); + + expect(store.dispatch).toHaveBeenCalledWith('fetchJobLog'); + }); + + it('should NOT poll job log for manual variables form empty state', async () => { + const manualPendingJobData = mockPendingJobData; + manualPendingJobData.status.group = MANUAL_STATUS; + + await setupAndMount({ + jobData: manualPendingJobData, + }); + + expect(store.dispatch).not.toHaveBeenCalledWith('fetchJobLog'); + }); + }); }); diff --git a/spec/frontend/jobs/components/job/manual_variables_form_spec.js b/spec/frontend/jobs/components/job/manual_variables_form_spec.js index 3040570df19..674812931c2 100644 --- a/spec/frontend/jobs/components/job/manual_variables_form_spec.js +++ b/spec/frontend/jobs/components/job/manual_variables_form_spec.js @@ -7,6 +7,7 @@ import createMockApollo from 'helpers/mock_apollo_helper'; import { convertToGraphQLId } from '~/graphql_shared/utils'; import { GRAPHQL_ID_TYPES } from '~/jobs/constants'; import waitForPromises from 'helpers/wait_for_promises'; +import { redirectTo } from '~/lib/utils/url_utility'; import ManualVariablesForm from '~/jobs/components/job/manual_variables_form.vue'; import getJobQuery from '~/jobs/components/job/graphql/queries/get_job.query.graphql'; import retryJobMutation from '~/jobs/components/job/graphql/mutations/job_retry_with_variables.mutation.graphql'; @@ -21,6 +22,11 @@ import { const localVue = createLocalVue(); localVue.use(VueApollo); +jest.mock('~/lib/utils/url_utility', () => ({ + ...jest.requireActual('~/lib/utils/url_utility'), + redirectTo: jest.fn(), +})); + const defaultProvide = { projectPath: mockFullPath, }; @@ -156,6 +162,15 @@ describe('Manual Variables Form', () => { }, }); }); + + // redirect to job after initial trigger assertion will be added in https://gitlab.com/gitlab-org/gitlab/-/issues/377268 + it('redirects to job properly after rerun', async () => { + findRerunBtn().vm.$emit('click'); + await waitForPromises(); + + expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledTimes(1); + expect(redirectTo).toHaveBeenCalledWith(mockJobMutationData.data.jobRetry.job.webPath); + }); }); describe('updating variables in UI', () => { diff --git a/spec/frontend/jobs/components/job/mock_data.js b/spec/frontend/jobs/components/job/mock_data.js index 9596e859475..8a838acca7a 100644 --- a/spec/frontend/jobs/components/job/mock_data.js +++ b/spec/frontend/jobs/components/job/mock_data.js @@ -74,3 +74,25 @@ export const mockJobMutationData = { }, }, }; + +export const mockPendingJobData = { + has_trace: false, + status: { + group: 'pending', + icon: 'status_pending', + label: 'pending', + text: 'pending', + details_path: 'path', + illustration: { + image: 'path', + size: '340', + title: '', + content: '', + }, + action: { + button_title: 'Retry job', + method: 'post', + path: '/path', + }, + }, +}; |