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