Commit 2186dc81 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch '231400-update-severity-counts-to-match-filters' into 'master'

Apply filters to vulnerability count list

See merge request gitlab-org/gitlab!41566
parents 69882367 d148c7d2
......@@ -61,7 +61,7 @@ export default {
<h4 class="flex-grow mt-0 mb-0">{{ __('Vulnerabilities') }}</h4>
<csv-export-button :vulnerabilities-export-endpoint="vulnerabilitiesExportEndpoint" />
</div>
<vulnerabilities-count-list :project-full-path="projectFullPath" />
<vulnerabilities-count-list :project-full-path="projectFullPath" :filters="filters" />
</template>
<template #sticky>
<filters @filterChange="handleFilterChange" />
......
......@@ -11,6 +11,11 @@ export default {
type: String,
required: true,
},
filters: {
type: Object,
required: false,
default: () => ({}),
},
},
data: () => ({
queryError: false,
......@@ -25,7 +30,10 @@ export default {
vulnerabilitiesCount: {
query: vulnerabilitySeveritiesCountQuery,
variables() {
return { fullPath: this.projectFullPath };
return {
fullPath: this.projectFullPath,
...this.filters,
};
},
update: ({ project }) => project.vulnerabilitySeveritiesCount,
result() {
......
query vulnerabilitySeveritiesCount($fullPath: ID!) {
query vulnerabilitySeveritiesCount(
$fullPath: ID!
$severity: [VulnerabilitySeverity!]
$reportType: [VulnerabilityReportType!]
$scanner: [String!]
$state: [VulnerabilityState!]
) {
project(fullPath: $fullPath) {
vulnerabilitySeveritiesCount {
vulnerabilitySeveritiesCount(
severity: $severity
reportType: $reportType
scanner: $scanner
state: $state
) {
critical
high
low
......
---
title: Apply filters to vulnerability count list
merge_request: 41566
author:
type: changed
......@@ -4,6 +4,7 @@ import FirstClassProjectSecurityDashboard from 'ee/security_dashboard/components
import Filters from 'ee/security_dashboard/components/first_class_vulnerability_filters.vue';
import SecurityDashboardLayout from 'ee/security_dashboard/components/security_dashboard_layout.vue';
import ProjectVulnerabilitiesApp from 'ee/security_dashboard/components/project_vulnerabilities.vue';
import VulnerabilityCountList from 'ee/security_dashboard/components/vulnerability_count_list.vue';
import ReportsNotConfigured from 'ee/security_dashboard/components/empty_states/reports_not_configured.vue';
import CsvExportButton from 'ee/security_dashboard/components/csv_export_button.vue';
......@@ -27,6 +28,7 @@ describe('First class Project Security Dashboard component', () => {
const findFilters = () => wrapper.find(Filters);
const findVulnerabilities = () => wrapper.find(ProjectVulnerabilitiesApp);
const findVulnerabilityCountList = () => wrapper.find(VulnerabilityCountList);
const findUnconfiguredState = () => wrapper.find(ReportsNotConfigured);
const findCsvExportButton = () => wrapper.find(CsvExportButton);
......@@ -49,15 +51,28 @@ describe('First class Project Security Dashboard component', () => {
describe('on render when there are vulnerabilities', () => {
beforeEach(() => {
createComponent({ props: { hasVulnerabilities: true } });
createComponent({
props: { hasVulnerabilities: true },
data: () => ({ filters }),
});
});
it('should render the vulnerabilities', () => {
expect(findVulnerabilities().exists()).toBe(true);
});
it('should pass down the "projectFullPath" prop to the vulnerabilities', () => {
expect(findVulnerabilities().props('projectFullPath')).toBe(props.projectFullPath);
it('should pass down the properties correctly to the vulnerabilities', () => {
expect(findVulnerabilities().props()).toEqual({
projectFullPath: props.projectFullPath,
filters,
});
});
it('should pass down the properties correctly to the vulnerability count list', () => {
expect(findVulnerabilityCountList().props()).toEqual({
projectFullPath: props.projectFullPath,
filters,
});
});
it('should render the filters component', () => {
......
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