Commit a567eb8a authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch '230384-add-counters-for-severities-on-security-dashboards' into 'master'

Add info and unknown counts

See merge request gitlab-org/gitlab!37763
parents 87534fe8 7eba40d3
<script> <script>
import { GlAlert } from '@gitlab/ui'; import { GlAlert } from '@gitlab/ui';
import { CRITICAL, HIGH, MEDIUM, LOW } from '../store/modules/vulnerabilities/constants'; import { SEVERITIES } from '../store/modules/vulnerabilities/constants';
import VulnerabilityCount from './vulnerability_count.vue'; import VulnerabilityCount from './vulnerability_count.vue';
const SEVERITIES = [CRITICAL, HIGH, MEDIUM, LOW];
export default { export default {
components: { components: {
VulnerabilityCount, VulnerabilityCount,
......
...@@ -5,6 +5,8 @@ query vulnerabilitySeveritiesCount($fullPath: ID!) { ...@@ -5,6 +5,8 @@ query vulnerabilitySeveritiesCount($fullPath: ID!) {
high high
low low
medium medium
info
unknown
} }
} }
} }
...@@ -4,6 +4,9 @@ export const CRITICAL = 'critical'; ...@@ -4,6 +4,9 @@ export const CRITICAL = 'critical';
export const HIGH = 'high'; export const HIGH = 'high';
export const MEDIUM = 'medium'; export const MEDIUM = 'medium';
export const LOW = 'low'; export const LOW = 'low';
export const INFO = 'info';
export const UNKNOWN = 'unknown';
export const SEVERITIES = [CRITICAL, HIGH, MEDIUM, LOW, INFO, UNKNOWN];
export const DAY_IN_MS = 1000 * 60 * 60 * 24; export const DAY_IN_MS = 1000 * 60 * 60 * 24;
......
---
title: Add info and unknown counts along other severity counts
merge_request: 37763
author:
type: added
...@@ -32,8 +32,28 @@ describe('Vulnerabilities count list component', () => { ...@@ -32,8 +32,28 @@ describe('Vulnerabilities count list component', () => {
}); });
}); });
describe('when there are no counts', () => {
beforeEach(() => {
wrapper = createWrapper({ propsData: { vulnerabilitiesCount: {} } });
});
it.each`
index | name
${0} | ${'critical'}
${1} | ${'high'}
${2} | ${'medium'}
${3} | ${'low'}
${4} | ${'info'}
${5} | ${'unknown'}
`('shows 0 count for $name', ({ index, name }) => {
const vulnerability = findVulnerability().at(index);
expect(vulnerability.props('severity')).toBe(name);
expect(vulnerability.props('count')).toBe(0);
});
});
describe('when loaded and has a list of vulnerability counts', () => { describe('when loaded and has a list of vulnerability counts', () => {
const vulnerabilitiesCount = { critical: 5, medium: 3 }; const vulnerabilitiesCount = { critical: 5, medium: 3, info: 1, unknown: 2, low: 3, high: 8 };
beforeEach(() => { beforeEach(() => {
wrapper = createWrapper({ propsData: { vulnerabilitiesCount } }); wrapper = createWrapper({ propsData: { vulnerabilitiesCount } });
...@@ -45,20 +65,18 @@ describe('Vulnerabilities count list component', () => { ...@@ -45,20 +65,18 @@ describe('Vulnerabilities count list component', () => {
}); });
}); });
it('shows the counts', () => { it.each`
const vulnerabilites = findVulnerability(); index | count | name
const critical = vulnerabilites.at(0); ${0} | ${vulnerabilitiesCount.critical} | ${'critical'}
const high = vulnerabilites.at(1); ${1} | ${vulnerabilitiesCount.high} | ${'high'}
const medium = vulnerabilites.at(2); ${2} | ${vulnerabilitiesCount.medium} | ${'medium'}
${3} | ${vulnerabilitiesCount.low} | ${'low'}
expect(critical.props('severity')).toBe('critical'); ${4} | ${vulnerabilitiesCount.info} | ${'info'}
expect(critical.props('count')).toBe(5); ${5} | ${vulnerabilitiesCount.unknown} | ${'unknown'}
`('shows count for $name correctly', ({ index, count, name }) => {
expect(high.props('severity')).toBe('high'); const vulnerability = findVulnerability().at(index);
expect(high.props('count')).toBe(0); expect(vulnerability.props('severity')).toBe(name);
expect(vulnerability.props('count')).toBe(count);
expect(medium.props('severity')).toBe('medium');
expect(medium.props('count')).toBe(3);
}); });
}); });
......
...@@ -37,6 +37,9 @@ describe('Vulnerabilities count list component', () => { ...@@ -37,6 +37,9 @@ describe('Vulnerabilities count list component', () => {
critical: 5, critical: 5,
high: 3, high: 3,
low: 19, low: 19,
info: 4,
medium: 2,
unknown: 4,
}, },
}); });
}); });
...@@ -50,6 +53,9 @@ describe('Vulnerabilities count list component', () => { ...@@ -50,6 +53,9 @@ describe('Vulnerabilities count list component', () => {
critical: 5, critical: 5,
high: 3, high: 3,
low: 19, low: 19,
info: 4,
medium: 2,
unknown: 4,
}); });
}); });
}); });
......
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