Commit eb42531d authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch 'pb-fix-has-artifacts-computed-prop' into 'master'

Fix artifacts section from showing up

See merge request gitlab-org/gitlab!56784
parents 0d447785 8b27953a
......@@ -49,7 +49,8 @@ export default {
return this.job.status && this.job.recoverable ? 'primary' : 'secondary';
},
hasArtifact() {
return !isEmpty(this.job.artifact);
// the artifact object will always have a locked property
return Object.keys(this.job.artifact).length > 1;
},
hasTriggers() {
return !isEmpty(this.job.trigger);
......
---
title: Fix artifacts section from showing up when no artifacts are present
merge_request: 56784
author:
type: fixed
import { shallowMount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import ArtifactsBlock from '~/jobs/components/artifacts_block.vue';
import JobRetryForwardDeploymentModal from '~/jobs/components/job_retry_forward_deployment_modal.vue';
import JobRetryButton from '~/jobs/components/job_sidebar_retry_button.vue';
import JobsContainer from '~/jobs/components/jobs_container.vue';
......@@ -14,6 +15,7 @@ describe('Sidebar details block', () => {
const forwardDeploymentFailure = 'forward_deployment_failure';
const findModal = () => wrapper.find(JobRetryForwardDeploymentModal);
const findArtifactsBlock = () => wrapper.findComponent(ArtifactsBlock);
const findCancelButton = () => wrapper.findByTestId('cancel-button');
const findNewIssueButton = () => wrapper.findByTestId('job-new-issue');
const findRetryButton = () => wrapper.find(JobRetryButton);
......@@ -21,6 +23,9 @@ describe('Sidebar details block', () => {
const createWrapper = ({ props = {} } = {}) => {
store = createStore();
store.state.job = job;
wrapper = extendedWrapper(
shallowMount(Sidebar, {
...props,
......@@ -164,4 +169,29 @@ describe('Sidebar details block', () => {
});
});
});
describe('artifacts', () => {
beforeEach(() => {
createWrapper();
});
it('artifacts are not shown if there are no properties other than locked', () => {
expect(findArtifactsBlock().exists()).toBe(false);
});
it('artifacts are shown if present', async () => {
store.state.job.artifact = {
download_path: '/root/ci-project/-/jobs/1960/artifacts/download',
browse_path: '/root/ci-project/-/jobs/1960/artifacts/browse',
keep_path: '/root/ci-project/-/jobs/1960/artifacts/keep',
expire_at: '2021-03-23T17:57:11.211Z',
expired: false,
locked: false,
};
await wrapper.vm.$nextTick();
expect(findArtifactsBlock().exists()).toBe(true);
});
});
});
......@@ -911,6 +911,9 @@ export const stages = [
export default {
id: 4757,
artifact: {
locked: false,
},
name: 'test',
build_path: '/root/ci-mock/-/jobs/4757',
retry_path: '/root/ci-mock/-/jobs/4757/retry',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment