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