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

Merge branch '331300-fuzzing-artifact-download-fix' into 'master'

Only show coverage fuzzing artifact download when the job exists

See merge request gitlab-org/gitlab!63957
parents ea2eade5 7d462536
......@@ -35,7 +35,7 @@ export default {
<template>
<gl-dropdown
v-gl-tooltip
:title="s__('SecurityReports|Download results')"
:text="s__('SecurityReports|Download results')"
:loading="loading"
icon="download"
size="small"
......
......@@ -38,6 +38,11 @@ export default {
required: false,
default: null,
},
securityReportSummary: {
type: Object,
required: false,
default: () => ({}),
},
loadingErrorIllustrations: {
type: Object,
required: false,
......@@ -57,7 +62,7 @@ export default {
...mapState('filters', ['filters']),
...mapGetters('vulnerabilities', ['loadingVulnerabilitiesFailedWithRecognizedErrorCode']),
shouldShowDownloadGuidance() {
return this.projectFullPath && this.pipelineIid;
return this.projectFullPath && this.pipelineIid && this.securityReportSummary.coverageFuzzing;
},
canCreateIssue() {
const path = this.vulnerability.create_vulnerability_feedback_issue_path;
......
import { FUZZING_STAGE } from './constants';
export const hasFuzzingArtifacts = (state) => {
return state.pipelineJobs.some((job) => {
return job.stage === FUZZING_STAGE && job.artifacts.length > 0;
});
};
export const fuzzingJobsWithArtifact = (state) => {
return state.pipelineJobs.filter((job) => {
return job.stage === FUZZING_STAGE && job.artifacts.length > 0;
});
};
import * as actions from './actions';
import * as getters from './getters';
import mutations from './mutations';
import state from './state';
......@@ -7,6 +6,5 @@ export default {
namespaced: true,
state,
mutations,
getters,
actions,
};
import { shallowMount } from '@vue/test-utils';
import { mount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter';
import { merge } from 'lodash';
import { nextTick } from 'vue';
......@@ -7,8 +7,8 @@ import Filters from 'ee/security_dashboard/components/pipeline/filters.vue';
import LoadingError from 'ee/security_dashboard/components/pipeline/loading_error.vue';
import SecurityDashboardTable from 'ee/security_dashboard/components/pipeline/security_dashboard_table.vue';
import SecurityDashboard from 'ee/security_dashboard/components/pipeline/security_dashboard_vuex.vue';
import VulnerabilityReportLayout from 'ee/security_dashboard/components/shared/vulnerability_report_layout.vue';
import { getStoreConfig } from 'ee/security_dashboard/store';
import PipelineArtifactDownload from 'ee/vue_shared/security_reports/components/artifact_downloads/pipeline_artifact_download.vue';
import { VULNERABILITY_MODAL_ID } from 'ee/vue_shared/security_reports/components/constants';
import IssueModal from 'ee/vue_shared/security_reports/components/modal.vue';
import { TEST_HOST } from 'helpers/test_constants';
......@@ -16,6 +16,7 @@ import axios from '~/lib/utils/axios_utils';
import { BV_HIDE_MODAL } from '~/lib/utils/constants';
const pipelineId = 123;
const pipelineIid = 12;
const vulnerabilitiesEndpoint = `${TEST_HOST}/vulnerabilities`;
jest.mock('~/lib/utils/url_utility', () => ({
......@@ -45,16 +46,17 @@ describe('Security Dashboard component', () => {
}),
);
wrapper = shallowMount(SecurityDashboard, {
wrapper = mount(SecurityDashboard, {
store,
stubs: {
VulnerabilityReportLayout,
PipelineArtifactDownload: true,
},
propsData: {
dashboardDocumentation: '',
projectFullPath: '/path',
vulnerabilitiesEndpoint,
pipelineId,
pipelineIid,
...props,
},
});
......@@ -95,6 +97,10 @@ describe('Security Dashboard component', () => {
expect(wrapper.find(IssueModal).exists()).toBe(true);
});
it('does not render coverage fuzzing artifact download', () => {
expect(wrapper.find(PipelineArtifactDownload).exists()).toBe(false);
});
it.each`
emittedModalEvent | eventPayload | expectedDispatchedAction | expectedActionPayload
${'addDismissalComment'} | ${'foo'} | ${'vulnerabilities/addDismissalComment'} | ${{ comment: 'foo', vulnerability: 'bar' }}
......@@ -131,6 +137,18 @@ describe('Security Dashboard component', () => {
});
});
describe('with coverage fuzzing', () => {
beforeEach(() => {
createComponent({
props: { securityReportSummary: { coverageFuzzing: { scannedResourcesCount: 1 } } },
});
});
it('renders coverage fuzzing artifact download', () => {
expect(wrapper.find(PipelineArtifactDownload).exists()).toBe(true);
});
});
describe('issue modal', () => {
it.each`
givenState | expectedProps
......
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