Commit dbeea6c3 authored by Savas Vedova's avatar Savas Vedova

Add info and unknown counts

- Update tests
parent 36f595bb
<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
...@@ -33,7 +33,7 @@ describe('Vulnerabilities count list component', () => { ...@@ -33,7 +33,7 @@ describe('Vulnerabilities count list component', () => {
}); });
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: 0, high: 0 };
beforeEach(() => { beforeEach(() => {
wrapper = createWrapper({ propsData: { vulnerabilitiesCount } }); wrapper = createWrapper({ propsData: { vulnerabilitiesCount } });
...@@ -45,20 +45,18 @@ describe('Vulnerabilities count list component', () => { ...@@ -45,20 +45,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,7 @@ describe('Vulnerabilities count list component', () => { ...@@ -37,6 +37,7 @@ describe('Vulnerabilities count list component', () => {
critical: 5, critical: 5,
high: 3, high: 3,
low: 19, low: 19,
info: 4,
}, },
}); });
}); });
...@@ -50,6 +51,7 @@ describe('Vulnerabilities count list component', () => { ...@@ -50,6 +51,7 @@ describe('Vulnerabilities count list component', () => {
critical: 5, critical: 5,
high: 3, high: 3,
low: 19, low: 19,
info: 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