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>
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';
const SEVERITIES = [CRITICAL, HIGH, MEDIUM, LOW];
export default {
components: {
VulnerabilityCount,
......
......@@ -5,6 +5,8 @@ query vulnerabilitySeveritiesCount($fullPath: ID!) {
high
low
medium
info
unknown
}
}
}
......@@ -4,6 +4,9 @@ export const CRITICAL = 'critical';
export const HIGH = 'high';
export const MEDIUM = 'medium';
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;
......
---
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', () => {
});
});
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', () => {
const vulnerabilitiesCount = { critical: 5, medium: 3 };
const vulnerabilitiesCount = { critical: 5, medium: 3, info: 1, unknown: 2, low: 3, high: 8 };
beforeEach(() => {
wrapper = createWrapper({ propsData: { vulnerabilitiesCount } });
......@@ -45,20 +65,18 @@ describe('Vulnerabilities count list component', () => {
});
});
it('shows the counts', () => {
const vulnerabilites = findVulnerability();
const critical = vulnerabilites.at(0);
const high = vulnerabilites.at(1);
const medium = vulnerabilites.at(2);
expect(critical.props('severity')).toBe('critical');
expect(critical.props('count')).toBe(5);
expect(high.props('severity')).toBe('high');
expect(high.props('count')).toBe(0);
expect(medium.props('severity')).toBe('medium');
expect(medium.props('count')).toBe(3);
it.each`
index | count | name
${0} | ${vulnerabilitiesCount.critical} | ${'critical'}
${1} | ${vulnerabilitiesCount.high} | ${'high'}
${2} | ${vulnerabilitiesCount.medium} | ${'medium'}
${3} | ${vulnerabilitiesCount.low} | ${'low'}
${4} | ${vulnerabilitiesCount.info} | ${'info'}
${5} | ${vulnerabilitiesCount.unknown} | ${'unknown'}
`('shows count for $name correctly', ({ index, count, name }) => {
const vulnerability = findVulnerability().at(index);
expect(vulnerability.props('severity')).toBe(name);
expect(vulnerability.props('count')).toBe(count);
});
});
......
......@@ -37,6 +37,9 @@ describe('Vulnerabilities count list component', () => {
critical: 5,
high: 3,
low: 19,
info: 4,
medium: 2,
unknown: 4,
},
});
});
......@@ -50,6 +53,9 @@ describe('Vulnerabilities count list component', () => {
critical: 5,
high: 3,
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