diff options
author | Mike Lewis <mlewis@gitlab.com> | 2019-06-07 20:13:17 +0000 |
---|---|---|
committer | Mike Lewis <mlewis@gitlab.com> | 2019-06-07 20:13:17 +0000 |
commit | 99df0218f82b851b017bd0eea1b8351dc89df6ed (patch) | |
tree | b01f884fbd1418dd5465fc1741f1620061ae8c5c /spec/javascripts/jobs | |
parent | 3eea6906747d10bea501426febaf15d2c209e06a (diff) | |
parent | e07b2b277f79bc25cdce22ca2defba1ba80791aa (diff) | |
download | gitlab-ce-99df0218f82b851b017bd0eea1b8351dc89df6ed.tar.gz |
Merge branch 'master' into 'docs/fix-example-dot-net'
# Conflicts:
# doc/user/project/clusters/serverless/index.md
Diffstat (limited to 'spec/javascripts/jobs')
-rw-r--r-- | spec/javascripts/jobs/components/artifacts_block_spec.js | 2 | ||||
-rw-r--r-- | spec/javascripts/jobs/components/commit_block_spec.js | 3 | ||||
-rw-r--r-- | spec/javascripts/jobs/components/empty_state_spec.js | 93 | ||||
-rw-r--r-- | spec/javascripts/jobs/components/erased_block_spec.js | 56 | ||||
-rw-r--r-- | spec/javascripts/jobs/components/job_app_spec.js | 41 | ||||
-rw-r--r-- | spec/javascripts/jobs/components/sidebar_detail_row_spec.js | 61 | ||||
-rw-r--r-- | spec/javascripts/jobs/components/sidebar_spec.js | 16 | ||||
-rw-r--r-- | spec/javascripts/jobs/components/stages_dropdown_spec.js | 189 | ||||
-rw-r--r-- | spec/javascripts/jobs/components/stuck_block_spec.js | 81 | ||||
-rw-r--r-- | spec/javascripts/jobs/components/unmet_prerequisites_block_spec.js | 37 | ||||
-rw-r--r-- | spec/javascripts/jobs/mock_data.js | 302 | ||||
-rw-r--r-- | spec/javascripts/jobs/store/actions_spec.js | 105 | ||||
-rw-r--r-- | spec/javascripts/jobs/store/getters_spec.js | 188 | ||||
-rw-r--r-- | spec/javascripts/jobs/store/mutations_spec.js | 230 |
14 files changed, 396 insertions, 1008 deletions
diff --git a/spec/javascripts/jobs/components/artifacts_block_spec.js b/spec/javascripts/jobs/components/artifacts_block_spec.js index 27d480ef2ea..58998d038e5 100644 --- a/spec/javascripts/jobs/components/artifacts_block_spec.js +++ b/spec/javascripts/jobs/components/artifacts_block_spec.js @@ -2,7 +2,7 @@ import Vue from 'vue'; import { getTimeago } from '~/lib/utils/datetime_utility'; import component from '~/jobs/components/artifacts_block.vue'; import mountComponent from '../../helpers/vue_mount_component_helper'; -import { trimText } from '../../helpers/vue_component_helper'; +import { trimText } from '../../helpers/text_helper'; describe('Artifacts block', () => { const Component = Vue.extend(component); diff --git a/spec/javascripts/jobs/components/commit_block_spec.js b/spec/javascripts/jobs/components/commit_block_spec.js index 98eba3ac976..c02f564d01a 100644 --- a/spec/javascripts/jobs/components/commit_block_spec.js +++ b/spec/javascripts/jobs/components/commit_block_spec.js @@ -9,6 +9,7 @@ describe('Commit block', () => { const props = { commit: { short_id: '1f0fb84f', + id: '1f0fb84fb6770d74d97eee58118fd3909cd4f48c', commit_path: 'commit/1f0fb84fb6770d74d97eee58118fd3909cd4f48c', title: 'Update README.md', }, @@ -42,7 +43,7 @@ describe('Commit block', () => { it('renders clipboard button', () => { expect(vm.$el.querySelector('button').getAttribute('data-clipboard-text')).toEqual( - props.commit.short_id, + props.commit.id, ); }); }); diff --git a/spec/javascripts/jobs/components/empty_state_spec.js b/spec/javascripts/jobs/components/empty_state_spec.js deleted file mode 100644 index a2df79bdda0..00000000000 --- a/spec/javascripts/jobs/components/empty_state_spec.js +++ /dev/null @@ -1,93 +0,0 @@ -import Vue from 'vue'; -import component from '~/jobs/components/empty_state.vue'; -import mountComponent from '../../helpers/vue_mount_component_helper'; - -describe('Empty State', () => { - const Component = Vue.extend(component); - let vm; - - const props = { - illustrationPath: 'illustrations/pending_job_empty.svg', - illustrationSizeClass: 'svg-430', - title: 'This job has not started yet', - }; - - const content = 'This job is in pending state and is waiting to be picked by a runner'; - - afterEach(() => { - vm.$destroy(); - }); - - describe('renders image and title', () => { - beforeEach(() => { - vm = mountComponent(Component, { - ...props, - content, - }); - }); - - it('renders img with provided path and size', () => { - expect(vm.$el.querySelector('img').getAttribute('src')).toEqual(props.illustrationPath); - expect(vm.$el.querySelector('.svg-content').classList).toContain(props.illustrationSizeClass); - }); - - it('renders provided title', () => { - expect(vm.$el.querySelector('.js-job-empty-state-title').textContent.trim()).toEqual( - props.title, - ); - }); - }); - - describe('with content', () => { - it('renders content', () => { - vm = mountComponent(Component, { - ...props, - content, - }); - - expect(vm.$el.querySelector('.js-job-empty-state-content').textContent.trim()).toEqual( - content, - ); - }); - }); - - describe('without content', () => { - it('does not render content', () => { - vm = mountComponent(Component, { - ...props, - }); - - expect(vm.$el.querySelector('.js-job-empty-state-content')).toBeNull(); - }); - }); - - describe('with action', () => { - it('renders action', () => { - vm = mountComponent(Component, { - ...props, - content, - action: { - path: 'runner', - button_title: 'Check runner', - method: 'post', - }, - }); - - expect(vm.$el.querySelector('.js-job-empty-state-action').getAttribute('href')).toEqual( - 'runner', - ); - }); - }); - - describe('without action', () => { - it('does not render action', () => { - vm = mountComponent(Component, { - ...props, - content, - action: null, - }); - - expect(vm.$el.querySelector('.js-job-empty-state-action')).toBeNull(); - }); - }); -}); diff --git a/spec/javascripts/jobs/components/erased_block_spec.js b/spec/javascripts/jobs/components/erased_block_spec.js deleted file mode 100644 index 8e0433d3fb7..00000000000 --- a/spec/javascripts/jobs/components/erased_block_spec.js +++ /dev/null @@ -1,56 +0,0 @@ -import Vue from 'vue'; -import { getTimeago } from '~/lib/utils/datetime_utility'; -import component from '~/jobs/components/erased_block.vue'; -import mountComponent from '../../helpers/vue_mount_component_helper'; - -describe('Erased block', () => { - const Component = Vue.extend(component); - let vm; - - const erasedAt = '2016-11-07T11:11:16.525Z'; - const timeago = getTimeago(); - const formatedDate = timeago.format(erasedAt); - - afterEach(() => { - vm.$destroy(); - }); - - describe('with job erased by user', () => { - beforeEach(() => { - vm = mountComponent(Component, { - user: { - username: 'root', - web_url: 'gitlab.com/root', - }, - erasedAt, - }); - }); - - it('renders username and link', () => { - expect(vm.$el.querySelector('a').getAttribute('href')).toEqual('gitlab.com/root'); - - expect(vm.$el.textContent).toContain('Job has been erased by'); - expect(vm.$el.textContent).toContain('root'); - }); - - it('renders erasedAt', () => { - expect(vm.$el.textContent).toContain(formatedDate); - }); - }); - - describe('with erased job', () => { - beforeEach(() => { - vm = mountComponent(Component, { - erasedAt, - }); - }); - - it('renders username and link', () => { - expect(vm.$el.textContent).toContain('Job has been erased'); - }); - - it('renders erasedAt', () => { - expect(vm.$el.textContent).toContain(formatedDate); - }); - }); -}); diff --git a/spec/javascripts/jobs/components/job_app_spec.js b/spec/javascripts/jobs/components/job_app_spec.js index ba5d672f189..f28d2c2a882 100644 --- a/spec/javascripts/jobs/components/job_app_spec.js +++ b/spec/javascripts/jobs/components/job_app_spec.js @@ -17,6 +17,7 @@ describe('Job App ', () => { const props = { endpoint: `${gl.TEST_HOST}jobs/123.json`, runnerHelpUrl: 'help/runner', + deploymentHelpUrl: 'help/deployment', runnerSettingsUrl: 'settings/ci-cd/runners', terminalPath: 'jobs/123/terminal', pagePath: `${gl.TEST_HOST}jobs/123`, @@ -89,9 +90,12 @@ describe('Job App ', () => { describe('triggered job', () => { beforeEach(() => { + const aYearAgo = new Date(); + aYearAgo.setFullYear(aYearAgo.getFullYear() - 1); + mock .onGet(props.endpoint) - .replyOnce(200, Object.assign({}, job, { started: '2017-05-24T10:59:52.000+01:00' })); + .replyOnce(200, Object.assign({}, job, { started: aYearAgo.toISOString() })); vm = mountComponentWithStore(Component, { props, store }); }); @@ -253,6 +257,41 @@ describe('Job App ', () => { }); }); + describe('unmet prerequisites block', () => { + it('renders unmet prerequisites block when there is an unmet prerequisites failure', done => { + mock.onGet(props.endpoint).replyOnce( + 200, + Object.assign({}, job, { + status: { + group: 'failed', + icon: 'status_failed', + label: 'failed', + text: 'failed', + details_path: 'path', + illustration: { + content: 'Retry this job in order to create the necessary resources.', + image: 'path', + size: 'svg-430', + title: 'Failed to create resources', + }, + }, + failure_reason: 'unmet_prerequisites', + has_trace: false, + runners: { + available: true, + }, + tags: [], + }), + ); + vm = mountComponentWithStore(Component, { props, store }); + + setTimeout(() => { + expect(vm.$el.querySelector('.js-job-failed')).not.toBeNull(); + done(); + }, 0); + }); + }); + describe('environments block', () => { it('renders environment block when job has environment', done => { mock.onGet(props.endpoint).replyOnce( diff --git a/spec/javascripts/jobs/components/sidebar_detail_row_spec.js b/spec/javascripts/jobs/components/sidebar_detail_row_spec.js deleted file mode 100644 index 42d11266dad..00000000000 --- a/spec/javascripts/jobs/components/sidebar_detail_row_spec.js +++ /dev/null @@ -1,61 +0,0 @@ -import Vue from 'vue'; -import sidebarDetailRow from '~/jobs/components/sidebar_detail_row.vue'; - -describe('Sidebar detail row', () => { - let SidebarDetailRow; - let vm; - - beforeEach(() => { - SidebarDetailRow = Vue.extend(sidebarDetailRow); - }); - - afterEach(() => { - vm.$destroy(); - }); - - it('should render no title', () => { - vm = new SidebarDetailRow({ - propsData: { - value: 'this is the value', - }, - }).$mount(); - - expect(vm.$el.textContent.replace(/\s+/g, ' ').trim()).toEqual('this is the value'); - }); - - beforeEach(() => { - vm = new SidebarDetailRow({ - propsData: { - title: 'this is the title', - value: 'this is the value', - }, - }).$mount(); - }); - - it('should render provided title and value', () => { - expect(vm.$el.textContent.replace(/\s+/g, ' ').trim()).toEqual( - 'this is the title: this is the value', - ); - }); - - describe('when helpUrl not provided', () => { - it('should not render help', () => { - expect(vm.$el.querySelector('.help-button')).toBeNull(); - }); - }); - - describe('when helpUrl provided', () => { - beforeEach(() => { - vm = new SidebarDetailRow({ - propsData: { - helpUrl: 'help url', - value: 'foo', - }, - }).$mount(); - }); - - it('should render help', () => { - expect(vm.$el.querySelector('.help-button a').getAttribute('href')).toEqual('help url'); - }); - }); -}); diff --git a/spec/javascripts/jobs/components/sidebar_spec.js b/spec/javascripts/jobs/components/sidebar_spec.js index 3a02351460c..740bc3d0491 100644 --- a/spec/javascripts/jobs/components/sidebar_spec.js +++ b/spec/javascripts/jobs/components/sidebar_spec.js @@ -1,9 +1,9 @@ import Vue from 'vue'; import sidebarDetailsBlock from '~/jobs/components/sidebar.vue'; import createStore from '~/jobs/store'; -import job, { stages, jobsInStage } from '../mock_data'; +import job, { jobsInStage } from '../mock_data'; import { mountComponentWithStore } from '../../helpers/vue_mount_component_helper'; -import { trimText } from '../../helpers/vue_component_helper'; +import { trimText } from '../../helpers/text_helper'; describe('Sidebar details block', () => { const SidebarComponent = Vue.extend(sidebarDetailsBlock); @@ -131,18 +131,8 @@ describe('Sidebar details block', () => { store.dispatch('receiveJobSuccess', job); }); - describe('while fetching stages', () => { - it('it does not render dropdown', () => { - store.dispatch('requestStages'); - vm = mountComponentWithStore(SidebarComponent, { store }); - - expect(vm.$el.querySelector('.js-selected-stage')).toBeNull(); - }); - }); - describe('with stages', () => { beforeEach(() => { - store.dispatch('receiveStagesSuccess', stages); vm = mountComponentWithStore(SidebarComponent, { store }); }); @@ -156,7 +146,6 @@ describe('Sidebar details block', () => { describe('without jobs for stages', () => { beforeEach(() => { store.dispatch('receiveJobSuccess', job); - store.dispatch('receiveStagesSuccess', stages); vm = mountComponentWithStore(SidebarComponent, { store }); }); @@ -168,7 +157,6 @@ describe('Sidebar details block', () => { describe('with jobs for stages', () => { beforeEach(() => { store.dispatch('receiveJobSuccess', job); - store.dispatch('receiveStagesSuccess', stages); store.dispatch('receiveJobsForStageSuccess', jobsInStage.latest_statuses); vm = mountComponentWithStore(SidebarComponent, { store }); }); diff --git a/spec/javascripts/jobs/components/stages_dropdown_spec.js b/spec/javascripts/jobs/components/stages_dropdown_spec.js index 9c731ae2f68..e98639bf21e 100644 --- a/spec/javascripts/jobs/components/stages_dropdown_spec.js +++ b/spec/javascripts/jobs/components/stages_dropdown_spec.js @@ -1,59 +1,168 @@ import Vue from 'vue'; import component from '~/jobs/components/stages_dropdown.vue'; +import { trimText } from 'spec/helpers/text_helper'; import mountComponent from '../../helpers/vue_mount_component_helper'; describe('Stages Dropdown', () => { const Component = Vue.extend(component); let vm; - beforeEach(() => { - vm = mountComponent(Component, { - pipeline: { - id: 28029444, - details: { - status: { - details_path: '/gitlab-org/gitlab-ce/pipelines/28029444', - group: 'success', - has_details: true, - icon: 'status_success', - label: 'passed', - text: 'passed', - tooltip: 'passed', - }, - }, - path: 'pipeline/28029444', + const mockPipelineData = { + id: 28029444, + iid: 123, + details: { + status: { + details_path: '/gitlab-org/gitlab-ce/pipelines/28029444', + group: 'success', + has_details: true, + icon: 'status_success', + label: 'passed', + text: 'passed', + tooltip: 'passed', }, - stages: [ - { - name: 'build', - }, - { - name: 'test', - }, - ], - selectedStage: 'deploy', + }, + path: 'pipeline/28029444', + flags: { + merge_request_pipeline: true, + detached_merge_request_pipeline: false, + }, + merge_request: { + iid: 1234, + path: '/root/detached-merge-request-pipelines/merge_requests/1', + title: 'Update README.md', + source_branch: 'feature-1234', + source_branch_path: '/root/detached-merge-request-pipelines/branches/feature-1234', + target_branch: 'master', + target_branch_path: '/root/detached-merge-request-pipelines/branches/master', + }, + ref: { + name: 'test-branch', + }, + }; + + describe('without a merge request pipeline', () => { + let pipeline; + + beforeEach(() => { + pipeline = JSON.parse(JSON.stringify(mockPipelineData)); + delete pipeline.merge_request; + delete pipeline.flags.merge_request_pipeline; + delete pipeline.flags.detached_merge_request_pipeline; + + vm = mountComponent(Component, { + pipeline, + stages: [{ name: 'build' }, { name: 'test' }], + selectedStage: 'deploy', + }); }); - }); - afterEach(() => { - vm.$destroy(); - }); + afterEach(() => { + vm.$destroy(); + }); - it('renders pipeline status', () => { - expect(vm.$el.querySelector('.js-ci-status-icon-success')).not.toBeNull(); - }); + it('renders pipeline status', () => { + expect(vm.$el.querySelector('.js-ci-status-icon-success')).not.toBeNull(); + }); + + it('renders pipeline link', () => { + expect(vm.$el.querySelector('.js-pipeline-path').getAttribute('href')).toEqual( + 'pipeline/28029444', + ); + }); + + it('renders dropdown with stages', () => { + expect(vm.$el.querySelector('.dropdown .js-stage-item').textContent).toContain('build'); + }); + + it('rendes selected stage', () => { + expect(vm.$el.querySelector('.dropdown .js-selected-stage').textContent).toContain('deploy'); + }); - it('renders pipeline link', () => { - expect(vm.$el.querySelector('.js-pipeline-path').getAttribute('href')).toEqual( - 'pipeline/28029444', - ); + it(`renders the pipeline info text like "Pipeline #123 (#12) for source_branch"`, () => { + const expected = `Pipeline #${pipeline.id} (#${pipeline.iid}) for ${pipeline.ref.name}`; + const actual = trimText(vm.$el.querySelector('.js-pipeline-info').innerText); + + expect(actual).toBe(expected); + }); }); - it('renders dropdown with stages', () => { - expect(vm.$el.querySelector('.dropdown .js-stage-item').textContent).toContain('build'); + describe('with an "attached" merge request pipeline', () => { + let pipeline; + + beforeEach(() => { + pipeline = JSON.parse(JSON.stringify(mockPipelineData)); + pipeline.flags.merge_request_pipeline = true; + pipeline.flags.detached_merge_request_pipeline = false; + + vm = mountComponent(Component, { + pipeline, + stages: [], + selectedStage: 'deploy', + }); + }); + + it(`renders the pipeline info text like "Pipeline #123 (#12) for !456 with source_branch into target_branch"`, () => { + const expected = `Pipeline #${pipeline.id} (#${pipeline.iid}) for !${ + pipeline.merge_request.iid + } with ${pipeline.merge_request.source_branch} into ${pipeline.merge_request.target_branch}`; + const actual = trimText(vm.$el.querySelector('.js-pipeline-info').innerText); + + expect(actual).toBe(expected); + }); + + it(`renders the correct merge request link`, () => { + const actual = vm.$el.querySelector('.js-mr-link').href; + + expect(actual).toContain(pipeline.merge_request.path); + }); + + it(`renders the correct source branch link`, () => { + const actual = vm.$el.querySelector('.js-source-branch-link').href; + + expect(actual).toContain(pipeline.merge_request.source_branch_path); + }); + + it(`renders the correct target branch link`, () => { + const actual = vm.$el.querySelector('.js-target-branch-link').href; + + expect(actual).toContain(pipeline.merge_request.target_branch_path); + }); }); - it('rendes selected stage', () => { - expect(vm.$el.querySelector('.dropdown .js-selected-stage').textContent).toContain('deploy'); + describe('with a detached merge request pipeline', () => { + let pipeline; + + beforeEach(() => { + pipeline = JSON.parse(JSON.stringify(mockPipelineData)); + pipeline.flags.merge_request_pipeline = false; + pipeline.flags.detached_merge_request_pipeline = true; + + vm = mountComponent(Component, { + pipeline, + stages: [], + selectedStage: 'deploy', + }); + }); + + it(`renders the pipeline info like "Pipeline #123 (#12) for !456 with source_branch"`, () => { + const expected = `Pipeline #${pipeline.id} (#${pipeline.iid}) for !${ + pipeline.merge_request.iid + } with ${pipeline.merge_request.source_branch}`; + const actual = trimText(vm.$el.querySelector('.js-pipeline-info').innerText); + + expect(actual).toBe(expected); + }); + + it(`renders the correct merge request link`, () => { + const actual = vm.$el.querySelector('.js-mr-link').href; + + expect(actual).toContain(pipeline.merge_request.path); + }); + + it(`renders the correct source branch link`, () => { + const actual = vm.$el.querySelector('.js-source-branch-link').href; + + expect(actual).toContain(pipeline.merge_request.source_branch_path); + }); }); }); diff --git a/spec/javascripts/jobs/components/stuck_block_spec.js b/spec/javascripts/jobs/components/stuck_block_spec.js deleted file mode 100644 index c320793b2be..00000000000 --- a/spec/javascripts/jobs/components/stuck_block_spec.js +++ /dev/null @@ -1,81 +0,0 @@ -import Vue from 'vue'; -import component from '~/jobs/components/stuck_block.vue'; -import mountComponent from '../../helpers/vue_mount_component_helper'; - -describe('Stuck Block Job component', () => { - const Component = Vue.extend(component); - let vm; - - afterEach(() => { - vm.$destroy(); - }); - - describe('with no runners for project', () => { - beforeEach(() => { - vm = mountComponent(Component, { - hasNoRunnersForProject: true, - runnersPath: '/root/project/runners#js-runners-settings', - }); - }); - - it('renders only information about project not having runners', () => { - expect(vm.$el.querySelector('.js-stuck-no-runners')).not.toBeNull(); - expect(vm.$el.querySelector('.js-stuck-with-tags')).toBeNull(); - expect(vm.$el.querySelector('.js-stuck-no-active-runner')).toBeNull(); - }); - - it('renders link to runners page', () => { - expect(vm.$el.querySelector('.js-runners-path').getAttribute('href')).toEqual( - '/root/project/runners#js-runners-settings', - ); - }); - }); - - describe('with tags', () => { - beforeEach(() => { - vm = mountComponent(Component, { - hasNoRunnersForProject: false, - tags: ['docker', 'gitlab-org'], - runnersPath: '/root/project/runners#js-runners-settings', - }); - }); - - it('renders information about the tags not being set', () => { - expect(vm.$el.querySelector('.js-stuck-no-runners')).toBeNull(); - expect(vm.$el.querySelector('.js-stuck-with-tags')).not.toBeNull(); - expect(vm.$el.querySelector('.js-stuck-no-active-runner')).toBeNull(); - }); - - it('renders tags', () => { - expect(vm.$el.textContent).toContain('docker'); - expect(vm.$el.textContent).toContain('gitlab-org'); - }); - - it('renders link to runners page', () => { - expect(vm.$el.querySelector('.js-runners-path').getAttribute('href')).toEqual( - '/root/project/runners#js-runners-settings', - ); - }); - }); - - describe('without active runners', () => { - beforeEach(() => { - vm = mountComponent(Component, { - hasNoRunnersForProject: false, - runnersPath: '/root/project/runners#js-runners-settings', - }); - }); - - it('renders information about project not having runners', () => { - expect(vm.$el.querySelector('.js-stuck-no-runners')).toBeNull(); - expect(vm.$el.querySelector('.js-stuck-with-tags')).toBeNull(); - expect(vm.$el.querySelector('.js-stuck-no-active-runner')).not.toBeNull(); - }); - - it('renders link to runners page', () => { - expect(vm.$el.querySelector('.js-runners-path').getAttribute('href')).toEqual( - '/root/project/runners#js-runners-settings', - ); - }); - }); -}); diff --git a/spec/javascripts/jobs/components/unmet_prerequisites_block_spec.js b/spec/javascripts/jobs/components/unmet_prerequisites_block_spec.js new file mode 100644 index 00000000000..68fcb321214 --- /dev/null +++ b/spec/javascripts/jobs/components/unmet_prerequisites_block_spec.js @@ -0,0 +1,37 @@ +import Vue from 'vue'; +import component from '~/jobs/components/unmet_prerequisites_block.vue'; +import mountComponent from '../../helpers/vue_mount_component_helper'; + +describe('Unmet Prerequisites Block Job component', () => { + const Component = Vue.extend(component); + let vm; + const helpPath = '/user/project/clusters/index.html#troubleshooting-failed-deployment-jobs'; + + beforeEach(() => { + vm = mountComponent(Component, { + hasNoRunnersForProject: true, + helpPath, + }); + }); + + afterEach(() => { + vm.$destroy(); + }); + + it('renders an alert with the correct message', () => { + const container = vm.$el.querySelector('.js-failed-unmet-prerequisites'); + const alertMessage = + 'This job failed because the necessary resources were not successfully created.'; + + expect(container).not.toBeNull(); + expect(container.innerHTML).toContain(alertMessage); + }); + + it('renders link to help page', () => { + const helpLink = vm.$el.querySelector('.js-help-path'); + + expect(helpLink).not.toBeNull(); + expect(helpLink.innerHTML).toContain('More information'); + expect(helpLink.getAttribute('href')).toEqual(helpPath); + }); +}); diff --git a/spec/javascripts/jobs/mock_data.js b/spec/javascripts/jobs/mock_data.js index 0398f184c0a..88b0bb206ee 100644 --- a/spec/javascripts/jobs/mock_data.js +++ b/spec/javascripts/jobs/mock_data.js @@ -3,140 +3,6 @@ import { TEST_HOST } from 'spec/test_constants'; const threeWeeksAgo = new Date(); threeWeeksAgo.setDate(threeWeeksAgo.getDate() - 21); -export default { - id: 4757, - name: 'test', - build_path: '/root/ci-mock/-/jobs/4757', - retry_path: '/root/ci-mock/-/jobs/4757/retry', - cancel_path: '/root/ci-mock/-/jobs/4757/cancel', - new_issue_path: '/root/ci-mock/issues/new', - playable: false, - created_at: threeWeeksAgo.toISOString(), - updated_at: threeWeeksAgo.toISOString(), - finished_at: threeWeeksAgo.toISOString(), - queued: 9.54, - status: { - icon: 'status_success', - text: 'passed', - label: 'passed', - group: 'success', - has_details: true, - details_path: `${TEST_HOST}/root/ci-mock/-/jobs/4757`, - favicon: - '/assets/ci_favicons/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.png', - action: { - icon: 'retry', - title: 'Retry', - path: '/root/ci-mock/-/jobs/4757/retry', - method: 'post', - }, - }, - coverage: 20, - erased_at: threeWeeksAgo.toISOString(), - erased: false, - duration: 6.785563, - tags: ['tag'], - user: { - name: 'Root', - username: 'root', - id: 1, - state: 'active', - avatar_url: - 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon', - web_url: 'http://localhost:3000/root', - }, - erase_path: '/root/ci-mock/-/jobs/4757/erase', - artifacts: [null], - runner: { - id: 1, - description: 'local ci runner', - edit_path: '/root/ci-mock/runners/1/edit', - }, - pipeline: { - id: 140, - user: { - name: 'Root', - username: 'root', - id: 1, - state: 'active', - avatar_url: - 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon', - web_url: 'http://localhost:3000/root', - }, - active: false, - coverage: null, - source: 'unknown', - created_at: '2017-05-24T09:59:58.634Z', - updated_at: '2017-06-01T17:32:00.062Z', - path: '/root/ci-mock/pipelines/140', - flags: { - latest: true, - stuck: false, - yaml_errors: false, - retryable: false, - cancelable: false, - }, - details: { - status: { - icon: 'status_success', - text: 'passed', - label: 'passed', - group: 'success', - has_details: true, - details_path: '/root/ci-mock/pipelines/140', - favicon: - '/assets/ci_favicons/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.png', - }, - duration: 6, - finished_at: '2017-06-01T17:32:00.042Z', - }, - ref: { - name: 'abc', - path: '/root/ci-mock/commits/abc', - tag: false, - branch: true, - }, - commit: { - id: 'c58647773a6b5faf066d4ad6ff2c9fbba5f180f6', - short_id: 'c5864777', - title: 'Add new file', - created_at: '2017-05-24T10:59:52.000+01:00', - parent_ids: ['798e5f902592192afaba73f4668ae30e56eae492'], - message: 'Add new file', - author_name: 'Root', - author_email: 'admin@example.com', - authored_date: '2017-05-24T10:59:52.000+01:00', - committer_name: 'Root', - committer_email: 'admin@example.com', - committed_date: '2017-05-24T10:59:52.000+01:00', - author: { - name: 'Root', - username: 'root', - id: 1, - state: 'active', - avatar_url: - 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon', - web_url: 'http://localhost:3000/root', - }, - author_gravatar_url: - 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon', - commit_url: - 'http://localhost:3000/root/ci-mock/commit/c58647773a6b5faf066d4ad6ff2c9fbba5f180f6', - commit_path: '/root/ci-mock/commit/c58647773a6b5faf066d4ad6ff2c9fbba5f180f6', - }, - }, - metadata: { - timeout_human_readable: '1m 40s', - timeout_source: 'runner', - }, - merge_request: { - iid: 2, - path: '/root/ci-mock/merge_requests/2', - }, - raw_path: '/root/ci-mock/builds/4757/raw', - has_trace: true, -}; - export const stages = [ { name: 'build', @@ -678,7 +544,7 @@ export const stages = [ icon: 'status_warning', text: 'failed', label: 'failed (allowed to fail)', - group: 'failed_with_warnings', + group: 'failed-with-warnings', tooltip: 'failed - (unknown failure) (allowed to fail)', has_details: true, details_path: '/gitlab-org/gitlab-shell/-/jobs/454', @@ -710,7 +576,7 @@ export const stages = [ icon: 'status_warning', text: 'failed', label: 'failed (allowed to fail)', - group: 'failed_with_warnings', + group: 'failed-with-warnings', tooltip: 'failed - (unknown failure) (allowed to fail)', has_details: true, details_path: '/gitlab-org/gitlab-shell/-/jobs/454', @@ -738,7 +604,7 @@ export const stages = [ icon: 'status_warning', text: 'passed', label: 'passed with warnings', - group: 'success_with_warnings', + group: 'success-with-warnings', tooltip: 'passed', has_details: true, details_path: '/gitlab-org/gitlab-shell/pipelines/27#test', @@ -1043,6 +909,168 @@ export const stages = [ }, ]; +export default { + id: 4757, + name: 'test', + build_path: '/root/ci-mock/-/jobs/4757', + retry_path: '/root/ci-mock/-/jobs/4757/retry', + cancel_path: '/root/ci-mock/-/jobs/4757/cancel', + new_issue_path: '/root/ci-mock/issues/new', + playable: false, + created_at: threeWeeksAgo.toISOString(), + updated_at: threeWeeksAgo.toISOString(), + finished_at: threeWeeksAgo.toISOString(), + queued: 9.54, + status: { + icon: 'status_success', + text: 'passed', + label: 'passed', + group: 'success', + has_details: true, + details_path: `${TEST_HOST}/root/ci-mock/-/jobs/4757`, + favicon: + '/assets/ci_favicons/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.png', + action: { + icon: 'retry', + title: 'Retry', + path: '/root/ci-mock/-/jobs/4757/retry', + method: 'post', + }, + }, + coverage: 20, + erased_at: threeWeeksAgo.toISOString(), + erased: false, + duration: 6.785563, + tags: ['tag'], + user: { + name: 'Root', + username: 'root', + id: 1, + state: 'active', + avatar_url: + 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon', + web_url: 'http://localhost:3000/root', + }, + erase_path: '/root/ci-mock/-/jobs/4757/erase', + artifacts: [null], + runner: { + id: 1, + description: 'local ci runner', + edit_path: '/root/ci-mock/runners/1/edit', + }, + pipeline: { + id: 140, + iid: 13, + user: { + name: 'Root', + username: 'root', + id: 1, + state: 'active', + avatar_url: + 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon', + web_url: 'http://localhost:3000/root', + }, + active: false, + coverage: null, + source: 'unknown', + created_at: '2017-05-24T09:59:58.634Z', + updated_at: '2017-06-01T17:32:00.062Z', + path: '/root/ci-mock/pipelines/140', + flags: { + latest: true, + stuck: false, + yaml_errors: false, + retryable: false, + cancelable: false, + }, + details: { + status: { + icon: 'status_success', + text: 'passed', + label: 'passed', + group: 'success', + has_details: true, + details_path: '/root/ci-mock/pipelines/140', + favicon: + '/assets/ci_favicons/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.png', + }, + duration: 6, + finished_at: '2017-06-01T17:32:00.042Z', + stages: [ + { + dropdown_path: '/jashkenas/underscore/pipelines/16/stage.json?stage=build', + name: 'build', + path: '/jashkenas/underscore/pipelines/16#build', + status: { + icon: 'status_success', + text: 'passed', + label: 'passed', + group: 'success', + tooltip: 'passed', + }, + title: 'build: passed', + }, + { + dropdown_path: '/jashkenas/underscore/pipelines/16/stage.json?stage=test', + name: 'test', + path: '/jashkenas/underscore/pipelines/16#test', + status: { + icon: 'status_warning', + text: 'passed', + label: 'passed with warnings', + group: 'success-with-warnings', + }, + title: 'test: passed with warnings', + }, + ], + }, + ref: { + name: 'abc', + path: '/root/ci-mock/commits/abc', + tag: false, + branch: true, + }, + commit: { + id: 'c58647773a6b5faf066d4ad6ff2c9fbba5f180f6', + short_id: 'c5864777', + title: 'Add new file', + created_at: '2017-05-24T10:59:52.000+01:00', + parent_ids: ['798e5f902592192afaba73f4668ae30e56eae492'], + message: 'Add new file', + author_name: 'Root', + author_email: 'admin@example.com', + authored_date: '2017-05-24T10:59:52.000+01:00', + committer_name: 'Root', + committer_email: 'admin@example.com', + committed_date: '2017-05-24T10:59:52.000+01:00', + author: { + name: 'Root', + username: 'root', + id: 1, + state: 'active', + avatar_url: + 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon', + web_url: 'http://localhost:3000/root', + }, + author_gravatar_url: + 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon', + commit_url: + 'http://localhost:3000/root/ci-mock/commit/c58647773a6b5faf066d4ad6ff2c9fbba5f180f6', + commit_path: '/root/ci-mock/commit/c58647773a6b5faf066d4ad6ff2c9fbba5f180f6', + }, + }, + metadata: { + timeout_human_readable: '1m 40s', + timeout_source: 'runner', + }, + merge_request: { + iid: 2, + path: '/root/ci-mock/merge_requests/2', + }, + raw_path: '/root/ci-mock/builds/4757/raw', + has_trace: true, +}; + export const jobsInStage = { name: 'build', title: 'build: running', diff --git a/spec/javascripts/jobs/store/actions_spec.js b/spec/javascripts/jobs/store/actions_spec.js index 77b44995b12..7b96df85b82 100644 --- a/spec/javascripts/jobs/store/actions_spec.js +++ b/spec/javascripts/jobs/store/actions_spec.js @@ -16,10 +16,6 @@ import { stopPollingTrace, receiveTraceSuccess, receiveTraceError, - requestStages, - fetchStages, - receiveStagesSuccess, - receiveStagesError, requestJobsForStage, fetchJobsForStage, receiveJobsForStageSuccess, @@ -307,107 +303,6 @@ describe('Job State actions', () => { }); }); - describe('requestStages', () => { - it('should commit REQUEST_STAGES mutation ', done => { - testAction(requestStages, null, mockedState, [{ type: types.REQUEST_STAGES }], [], done); - }); - }); - - describe('fetchStages', () => { - let mock; - - beforeEach(() => { - mockedState.job.pipeline = { - path: `${TEST_HOST}/endpoint`, - }; - mockedState.selectedStage = 'deploy'; - mock = new MockAdapter(axios); - }); - - afterEach(() => { - mock.restore(); - }); - - describe('success', () => { - it('dispatches requestStages and receiveStagesSuccess, fetchJobsForStage ', done => { - mock - .onGet(`${TEST_HOST}/endpoint.json`) - .replyOnce(200, { details: { stages: [{ name: 'build' }, { name: 'deploy' }] } }); - - testAction( - fetchStages, - null, - mockedState, - [], - [ - { - type: 'requestStages', - }, - { - payload: [{ name: 'build' }, { name: 'deploy' }], - type: 'receiveStagesSuccess', - }, - { - payload: { name: 'deploy' }, - type: 'fetchJobsForStage', - }, - ], - done, - ); - }); - }); - - describe('error', () => { - beforeEach(() => { - mock.onGet(`${TEST_HOST}/endpoint.json`).reply(500); - }); - - it('dispatches requestStages and receiveStagesError ', done => { - testAction( - fetchStages, - null, - mockedState, - [], - [ - { - type: 'requestStages', - }, - { - type: 'receiveStagesError', - }, - ], - done, - ); - }); - }); - }); - - describe('receiveStagesSuccess', () => { - it('should commit RECEIVE_STAGES_SUCCESS mutation ', done => { - testAction( - receiveStagesSuccess, - {}, - mockedState, - [{ type: types.RECEIVE_STAGES_SUCCESS, payload: {} }], - [], - done, - ); - }); - }); - - describe('receiveStagesError', () => { - it('should commit RECEIVE_STAGES_ERROR mutation ', done => { - testAction( - receiveStagesError, - null, - mockedState, - [{ type: types.RECEIVE_STAGES_ERROR }], - [], - done, - ); - }); - }); - describe('requestJobsForStage', () => { it('should commit REQUEST_JOBS_FOR_STAGE mutation ', done => { testAction( diff --git a/spec/javascripts/jobs/store/getters_spec.js b/spec/javascripts/jobs/store/getters_spec.js deleted file mode 100644 index 7931b2af79f..00000000000 --- a/spec/javascripts/jobs/store/getters_spec.js +++ /dev/null @@ -1,188 +0,0 @@ -import * as getters from '~/jobs/store/getters'; -import state from '~/jobs/store/state'; - -describe('Job Store Getters', () => { - let localState; - - beforeEach(() => { - localState = state(); - }); - - describe('headerTime', () => { - describe('when the job has started key', () => { - it('returns started key', () => { - const started = '2018-08-31T16:20:49.023Z'; - localState.job.started = started; - - expect(getters.headerTime(localState)).toEqual(started); - }); - }); - - describe('when the job does not have started key', () => { - it('returns created_at key', () => { - const created = '2018-08-31T16:20:49.023Z'; - localState.job.created_at = created; - - expect(getters.headerTime(localState)).toEqual(created); - }); - }); - }); - - describe('shouldRenderCalloutMessage', () => { - describe('with status and callout message', () => { - it('returns true', () => { - localState.job.callout_message = 'Callout message'; - localState.job.status = { icon: 'passed' }; - - expect(getters.shouldRenderCalloutMessage(localState)).toEqual(true); - }); - }); - - describe('without status & with callout message', () => { - it('returns false', () => { - localState.job.callout_message = 'Callout message'; - - expect(getters.shouldRenderCalloutMessage(localState)).toEqual(false); - }); - }); - - describe('with status & without callout message', () => { - it('returns false', () => { - localState.job.status = { icon: 'passed' }; - - expect(getters.shouldRenderCalloutMessage(localState)).toEqual(false); - }); - }); - }); - - describe('shouldRenderTriggeredLabel', () => { - describe('when started equals null', () => { - it('returns false', () => { - localState.job.started = null; - - expect(getters.shouldRenderTriggeredLabel(localState)).toEqual(false); - }); - }); - - describe('when started equals string', () => { - it('returns true', () => { - localState.job.started = '2018-08-31T16:20:49.023Z'; - - expect(getters.shouldRenderTriggeredLabel(localState)).toEqual(true); - }); - }); - }); - - describe('hasEnvironment', () => { - describe('without `deployment_status`', () => { - it('returns false', () => { - expect(getters.hasEnvironment(localState)).toEqual(false); - }); - }); - - describe('with an empty object for `deployment_status`', () => { - it('returns false', () => { - localState.job.deployment_status = {}; - - expect(getters.hasEnvironment(localState)).toEqual(false); - }); - }); - - describe('when `deployment_status` is defined and not empty', () => { - it('returns true', () => { - localState.job.deployment_status = { - status: 'creating', - environment: { - last_deployment: {}, - }, - }; - - expect(getters.hasEnvironment(localState)).toEqual(true); - }); - }); - }); - - describe('hasTrace', () => { - describe('when has_trace is true', () => { - it('returns true', () => { - localState.job.has_trace = true; - localState.job.status = {}; - - expect(getters.hasTrace(localState)).toEqual(true); - }); - }); - - describe('when job is running', () => { - it('returns true', () => { - localState.job.has_trace = false; - localState.job.status = { group: 'running' }; - - expect(getters.hasTrace(localState)).toEqual(true); - }); - }); - - describe('when has_trace is false and job is not running', () => { - it('returns false', () => { - localState.job.has_trace = false; - localState.job.status = { group: 'pending' }; - - expect(getters.hasTrace(localState)).toEqual(false); - }); - }); - }); - - describe('emptyStateIllustration', () => { - describe('with defined illustration', () => { - it('returns the state illustration object', () => { - localState.job.status = { - illustration: { - path: 'foo', - }, - }; - - expect(getters.emptyStateIllustration(localState)).toEqual({ path: 'foo' }); - }); - }); - - describe('when illustration is not defined', () => { - it('returns an empty object', () => { - expect(getters.emptyStateIllustration(localState)).toEqual({}); - }); - }); - }); - - describe('hasRunnersForProject', () => { - describe('with available and offline runners', () => { - it('returns true', () => { - localState.job.runners = { - available: true, - online: false, - }; - - expect(getters.hasRunnersForProject(localState)).toEqual(true); - }); - }); - - describe('with non available runners', () => { - it('returns false', () => { - localState.job.runners = { - available: false, - online: false, - }; - - expect(getters.hasRunnersForProject(localState)).toEqual(false); - }); - }); - - describe('with online runners', () => { - it('returns false', () => { - localState.job.runners = { - available: false, - online: true, - }; - - expect(getters.hasRunnersForProject(localState)).toEqual(false); - }); - }); - }); -}); diff --git a/spec/javascripts/jobs/store/mutations_spec.js b/spec/javascripts/jobs/store/mutations_spec.js deleted file mode 100644 index d7908efcf13..00000000000 --- a/spec/javascripts/jobs/store/mutations_spec.js +++ /dev/null @@ -1,230 +0,0 @@ -import state from '~/jobs/store/state'; -import mutations from '~/jobs/store/mutations'; -import * as types from '~/jobs/store/mutation_types'; - -describe('Jobs Store Mutations', () => { - let stateCopy; - - const html = - 'I, [2018-08-17T22:57:45.707325 #1841] INFO -- : Writing /builds/ab89e95b0fa0b9272ea0c797b76908f24d36992630e9325273a4ce3.png<br>I'; - - beforeEach(() => { - stateCopy = state(); - }); - - describe('SET_JOB_ENDPOINT', () => { - it('should set jobEndpoint', () => { - mutations[types.SET_JOB_ENDPOINT](stateCopy, 'job/21312321.json'); - - expect(stateCopy.jobEndpoint).toEqual('job/21312321.json'); - }); - }); - - describe('HIDE_SIDEBAR', () => { - it('should set isSidebarOpen to false', () => { - mutations[types.HIDE_SIDEBAR](stateCopy); - - expect(stateCopy.isSidebarOpen).toEqual(false); - }); - }); - - describe('SHOW_SIDEBAR', () => { - it('should set isSidebarOpen to true', () => { - mutations[types.SHOW_SIDEBAR](stateCopy); - - expect(stateCopy.isSidebarOpen).toEqual(true); - }); - }); - - describe('RECEIVE_TRACE_SUCCESS', () => { - describe('when trace has state', () => { - it('sets traceState', () => { - const stateLog = - 'eyJvZmZzZXQiOjczNDQ1MSwibl9vcGVuX3RhZ3MiOjAsImZnX2NvbG9yIjpudWxsLCJiZ19jb2xvciI6bnVsbCwic3R5bGVfbWFzayI6MH0='; - mutations[types.RECEIVE_TRACE_SUCCESS](stateCopy, { - state: stateLog, - }); - - expect(stateCopy.traceState).toEqual(stateLog); - }); - }); - - describe('when traceSize is smaller than the total size', () => { - it('sets isTraceSizeVisible to true', () => { - mutations[types.RECEIVE_TRACE_SUCCESS](stateCopy, { total: 51184600, size: 1231 }); - - expect(stateCopy.isTraceSizeVisible).toEqual(true); - }); - }); - - describe('when traceSize is bigger than the total size', () => { - it('sets isTraceSizeVisible to false', () => { - const copy = Object.assign({}, stateCopy, { traceSize: 5118460, size: 2321312 }); - - mutations[types.RECEIVE_TRACE_SUCCESS](copy, { total: 511846 }); - - expect(copy.isTraceSizeVisible).toEqual(false); - }); - }); - - it('sets trace, trace size and isTraceComplete', () => { - mutations[types.RECEIVE_TRACE_SUCCESS](stateCopy, { - append: true, - html, - size: 511846, - complete: true, - }); - - expect(stateCopy.trace).toEqual(html); - expect(stateCopy.traceSize).toEqual(511846); - expect(stateCopy.isTraceComplete).toEqual(true); - }); - }); - - describe('STOP_POLLING_TRACE', () => { - it('sets isTraceComplete to true', () => { - mutations[types.STOP_POLLING_TRACE](stateCopy); - - expect(stateCopy.isTraceComplete).toEqual(true); - }); - }); - - describe('RECEIVE_TRACE_ERROR', () => { - it('resets trace state and sets error to true', () => { - mutations[types.RECEIVE_TRACE_ERROR](stateCopy); - - expect(stateCopy.isTraceComplete).toEqual(true); - }); - }); - - describe('REQUEST_JOB', () => { - it('sets isLoading to true', () => { - mutations[types.REQUEST_JOB](stateCopy); - - expect(stateCopy.isLoading).toEqual(true); - }); - }); - - describe('RECEIVE_JOB_SUCCESS', () => { - it('sets is loading to false', () => { - mutations[types.RECEIVE_JOB_SUCCESS](stateCopy, { id: 1312321 }); - - expect(stateCopy.isLoading).toEqual(false); - }); - - it('sets hasError to false', () => { - mutations[types.RECEIVE_JOB_SUCCESS](stateCopy, { id: 1312321 }); - - expect(stateCopy.hasError).toEqual(false); - }); - - it('sets job data', () => { - mutations[types.RECEIVE_JOB_SUCCESS](stateCopy, { id: 1312321 }); - - expect(stateCopy.job).toEqual({ id: 1312321 }); - }); - - it('sets selectedStage when the selectedStage is empty', () => { - expect(stateCopy.selectedStage).toEqual(''); - mutations[types.RECEIVE_JOB_SUCCESS](stateCopy, { id: 1312321, stage: 'deploy' }); - - expect(stateCopy.selectedStage).toEqual('deploy'); - }); - - it('does not set selectedStage when the selectedStage is not More', () => { - stateCopy.selectedStage = 'notify'; - - expect(stateCopy.selectedStage).toEqual('notify'); - mutations[types.RECEIVE_JOB_SUCCESS](stateCopy, { id: 1312321, stage: 'deploy' }); - - expect(stateCopy.selectedStage).toEqual('notify'); - }); - }); - - describe('RECEIVE_JOB_ERROR', () => { - it('resets job data', () => { - mutations[types.RECEIVE_JOB_ERROR](stateCopy); - - expect(stateCopy.isLoading).toEqual(false); - expect(stateCopy.job).toEqual({}); - }); - }); - - describe('REQUEST_STAGES', () => { - it('sets isLoadingStages to true', () => { - mutations[types.REQUEST_STAGES](stateCopy); - - expect(stateCopy.isLoadingStages).toEqual(true); - }); - }); - - describe('RECEIVE_STAGES_SUCCESS', () => { - beforeEach(() => { - mutations[types.RECEIVE_STAGES_SUCCESS](stateCopy, [{ name: 'build' }]); - }); - - it('sets isLoadingStages to false', () => { - expect(stateCopy.isLoadingStages).toEqual(false); - }); - - it('sets stages', () => { - expect(stateCopy.stages).toEqual([{ name: 'build' }]); - }); - }); - - describe('RECEIVE_STAGES_ERROR', () => { - beforeEach(() => { - mutations[types.RECEIVE_STAGES_ERROR](stateCopy); - }); - - it('sets isLoadingStages to false', () => { - expect(stateCopy.isLoadingStages).toEqual(false); - }); - - it('resets stages', () => { - expect(stateCopy.stages).toEqual([]); - }); - }); - - describe('REQUEST_JOBS_FOR_STAGE', () => { - it('sets isLoadingStages to true', () => { - mutations[types.REQUEST_JOBS_FOR_STAGE](stateCopy, { name: 'deploy' }); - - expect(stateCopy.isLoadingJobs).toEqual(true); - }); - - it('sets selectedStage', () => { - mutations[types.REQUEST_JOBS_FOR_STAGE](stateCopy, { name: 'deploy' }); - - expect(stateCopy.selectedStage).toEqual('deploy'); - }); - }); - - describe('RECEIVE_JOBS_FOR_STAGE_SUCCESS', () => { - beforeEach(() => { - mutations[types.RECEIVE_JOBS_FOR_STAGE_SUCCESS](stateCopy, [{ name: 'karma' }]); - }); - - it('sets isLoadingJobs to false', () => { - expect(stateCopy.isLoadingJobs).toEqual(false); - }); - - it('sets jobs', () => { - expect(stateCopy.jobs).toEqual([{ name: 'karma' }]); - }); - }); - - describe('RECEIVE_JOBS_FOR_STAGE_ERROR', () => { - beforeEach(() => { - mutations[types.RECEIVE_JOBS_FOR_STAGE_ERROR](stateCopy); - }); - - it('sets isLoadingJobs to false', () => { - expect(stateCopy.isLoadingJobs).toEqual(false); - }); - - it('resets jobs', () => { - expect(stateCopy.jobs).toEqual([]); - }); - }); -}); |