diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/frontend/jobs | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) | |
download | gitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/frontend/jobs')
-rw-r--r-- | spec/frontend/jobs/components/artifacts_block_spec.js | 150 | ||||
-rw-r--r-- | spec/frontend/jobs/components/job_log_spec.js | 2 | ||||
-rw-r--r-- | spec/frontend/jobs/components/log/mock_data.js | 2 |
3 files changed, 98 insertions, 56 deletions
diff --git a/spec/frontend/jobs/components/artifacts_block_spec.js b/spec/frontend/jobs/components/artifacts_block_spec.js index 9cb56737f3e..11bd645916e 100644 --- a/spec/frontend/jobs/components/artifacts_block_spec.js +++ b/spec/frontend/jobs/components/artifacts_block_spec.js @@ -1,20 +1,32 @@ -import Vue from 'vue'; +import { mount } from '@vue/test-utils'; import { getTimeago } from '~/lib/utils/datetime_utility'; -import component from '~/jobs/components/artifacts_block.vue'; -import mountComponent from '../../helpers/vue_mount_component_helper'; +import ArtifactsBlock from '~/jobs/components/artifacts_block.vue'; import { trimText } from '../../helpers/text_helper'; describe('Artifacts block', () => { - const Component = Vue.extend(component); - let vm; + let wrapper; + + const createWrapper = propsData => + mount(ArtifactsBlock, { + propsData, + }); + + const findArtifactRemoveElt = () => wrapper.find('[data-testid="artifacts-remove-timeline"]'); + const findJobLockedElt = () => wrapper.find('[data-testid="job-locked-message"]'); + const findKeepBtn = () => wrapper.find('[data-testid="keep-artifacts"]'); + const findDownloadBtn = () => wrapper.find('[data-testid="download-artifacts"]'); + const findBrowseBtn = () => wrapper.find('[data-testid="browse-artifacts"]'); const expireAt = '2018-08-14T09:38:49.157Z'; const timeago = getTimeago(); const formattedDate = timeago.format(expireAt); + const lockedText = + 'These artifacts are the latest. They will not be deleted (even if expired) until newer artifacts are available.'; const expiredArtifact = { expire_at: expireAt, expired: true, + locked: false, }; const nonExpiredArtifact = { @@ -23,97 +35,127 @@ describe('Artifacts block', () => { keep_path: '/gitlab-org/gitlab-foss/-/jobs/98314558/artifacts/keep', expire_at: expireAt, expired: false, + locked: false, + }; + + const lockedExpiredArtifact = { + ...expiredArtifact, + download_path: '/gitlab-org/gitlab-foss/-/jobs/98314558/artifacts/download', + browse_path: '/gitlab-org/gitlab-foss/-/jobs/98314558/artifacts/browse', + expired: true, + locked: true, + }; + + const lockedNonExpiredArtifact = { + ...nonExpiredArtifact, + keep_path: undefined, + locked: true, }; afterEach(() => { - vm.$destroy(); + wrapper.destroy(); + wrapper = null; }); - describe('with expired artifacts', () => { - it('renders expired artifact date and info', () => { - vm = mountComponent(Component, { + describe('with expired artifacts that are not locked', () => { + beforeEach(() => { + wrapper = createWrapper({ artifact: expiredArtifact, }); + }); - expect(vm.$el.querySelector('.js-artifacts-removed')).not.toBeNull(); - expect(vm.$el.querySelector('.js-artifacts-will-be-removed')).toBeNull(); - expect(trimText(vm.$el.querySelector('.js-artifacts-removed').textContent)).toEqual( + it('renders expired artifact date and info', () => { + expect(trimText(findArtifactRemoveElt().text())).toBe( `The artifacts were removed ${formattedDate}`, ); }); + + it('does not show the keep button', () => { + expect(findKeepBtn().exists()).toBe(false); + }); + + it('does not show the download button', () => { + expect(findDownloadBtn().exists()).toBe(false); + }); + + it('does not show the browse button', () => { + expect(findBrowseBtn().exists()).toBe(false); + }); }); describe('with artifacts that will expire', () => { - it('renders will expire artifact date and info', () => { - vm = mountComponent(Component, { + beforeEach(() => { + wrapper = createWrapper({ artifact: nonExpiredArtifact, }); + }); - expect(vm.$el.querySelector('.js-artifacts-removed')).toBeNull(); - expect(vm.$el.querySelector('.js-artifacts-will-be-removed')).not.toBeNull(); - expect(trimText(vm.$el.querySelector('.js-artifacts-will-be-removed').textContent)).toEqual( + it('renders will expire artifact date and info', () => { + expect(trimText(findArtifactRemoveElt().text())).toBe( `The artifacts will be removed ${formattedDate}`, ); }); - }); - describe('with keep path', () => { it('renders the keep button', () => { - vm = mountComponent(Component, { - artifact: nonExpiredArtifact, - }); - - expect(vm.$el.querySelector('.js-keep-artifacts')).not.toBeNull(); + expect(findKeepBtn().exists()).toBe(true); }); - }); - describe('without keep path', () => { - it('does not render the keep button', () => { - vm = mountComponent(Component, { - artifact: expiredArtifact, - }); + it('renders the download button', () => { + expect(findDownloadBtn().exists()).toBe(true); + }); - expect(vm.$el.querySelector('.js-keep-artifacts')).toBeNull(); + it('renders the browse button', () => { + expect(findBrowseBtn().exists()).toBe(true); }); }); - describe('with download path', () => { - it('renders the download button', () => { - vm = mountComponent(Component, { - artifact: nonExpiredArtifact, + describe('with expired locked artifacts', () => { + beforeEach(() => { + wrapper = createWrapper({ + artifact: lockedExpiredArtifact, }); + }); - expect(vm.$el.querySelector('.js-download-artifacts')).not.toBeNull(); + it('renders the information that the artefacts are locked', () => { + expect(findArtifactRemoveElt().exists()).toBe(false); + expect(trimText(findJobLockedElt().text())).toBe(lockedText); }); - }); - describe('without download path', () => { it('does not render the keep button', () => { - vm = mountComponent(Component, { - artifact: expiredArtifact, - }); + expect(findKeepBtn().exists()).toBe(false); + }); - expect(vm.$el.querySelector('.js-download-artifacts')).toBeNull(); + it('renders the download button', () => { + expect(findDownloadBtn().exists()).toBe(true); + }); + + it('renders the browse button', () => { + expect(findBrowseBtn().exists()).toBe(true); }); }); - describe('with browse path', () => { - it('does not render the browse button', () => { - vm = mountComponent(Component, { - artifact: nonExpiredArtifact, + describe('with non expired locked artifacts', () => { + beforeEach(() => { + wrapper = createWrapper({ + artifact: lockedNonExpiredArtifact, }); + }); - expect(vm.$el.querySelector('.js-browse-artifacts')).not.toBeNull(); + it('renders the information that the artefacts are locked', () => { + expect(findArtifactRemoveElt().exists()).toBe(false); + expect(trimText(findJobLockedElt().text())).toBe(lockedText); }); - }); - describe('without browse path', () => { - it('does not render the browse button', () => { - vm = mountComponent(Component, { - artifact: expiredArtifact, - }); + it('does not render the keep button', () => { + expect(findKeepBtn().exists()).toBe(false); + }); + + it('renders the download button', () => { + expect(findDownloadBtn().exists()).toBe(true); + }); - expect(vm.$el.querySelector('.js-browse-artifacts')).toBeNull(); + it('renders the browse button', () => { + expect(findBrowseBtn().exists()).toBe(true); }); }); }); diff --git a/spec/frontend/jobs/components/job_log_spec.js b/spec/frontend/jobs/components/job_log_spec.js index 2bb1e0af3a2..a167fe8a134 100644 --- a/spec/frontend/jobs/components/job_log_spec.js +++ b/spec/frontend/jobs/components/job_log_spec.js @@ -10,7 +10,7 @@ describe('Job Log', () => { let vm; const trace = - '<span>Running with gitlab-runner 12.1.0 (de7731dd)<br/></span><span> on docker-auto-scale-com d5ae8d25<br/></span><div class="append-right-8" data-timestamp="1565502765" data-section="prepare-executor" role="button"></div><span class="section section-header js-s-prepare-executor">Using Docker executor with image ruby:2.6 ...<br/></span>'; + '<span>Running with gitlab-runner 12.1.0 (de7731dd)<br/></span><span> on docker-auto-scale-com d5ae8d25<br/></span><div class="gl-mr-3" data-timestamp="1565502765" data-section="prepare-executor" role="button"></div><span class="section section-header js-s-prepare-executor">Using Docker executor with image ruby:2.6 ...<br/></span>'; beforeEach(() => { store = createStore(); diff --git a/spec/frontend/jobs/components/log/mock_data.js b/spec/frontend/jobs/components/log/mock_data.js index d92c009756a..a6a767f7921 100644 --- a/spec/frontend/jobs/components/log/mock_data.js +++ b/spec/frontend/jobs/components/log/mock_data.js @@ -34,7 +34,7 @@ export const utilsMockData = [ content: [ { text: - 'Using Docker executor with image dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.6.5-golang-1.12-git-2.26-lfs-2.9-chrome-73.0-node-12.x-yarn-1.16-postgresql-9.6-graphicsmagick-1.3.34', + 'Using Docker executor with image dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.6.6-golang-1.14-git-2.27-lfs-2.9-chrome-83-node-12.x-yarn-1.21-postgresql-11-graphicsmagick-1.3.34', }, ], section: 'prepare-executor', |