Commit 17aa74e4 authored by Alexander Turinske's avatar Alexander Turinske

Conditionally render report type on dashboards

- conditionally show the report type column on the project-leve
  security dashboard and not on the group/instance-level security
  dashboards
- add tests
parent 433d959c
...@@ -109,6 +109,7 @@ export default { ...@@ -109,6 +109,7 @@ export default {
:empty-state-svg-path="emptyStateSvgPath" :empty-state-svg-path="emptyStateSvgPath"
:filters="filters" :filters="filters"
:vulnerabilities="vulnerabilities" :vulnerabilities="vulnerabilities"
should-show-report-type
@refetch-vulnerabilities="refetchVulnerabilities" @refetch-vulnerabilities="refetchVulnerabilities"
> >
<template #emptyState> <template #emptyState>
......
...@@ -35,6 +35,11 @@ export default { ...@@ -35,6 +35,11 @@ export default {
required: false, required: false,
default: null, default: null,
}, },
shouldShowReportType: {
type: Boolean,
required: false,
default: false,
},
shouldShowSelection: { shouldShowSelection: {
type: Boolean, type: Boolean,
required: false, required: false,
...@@ -76,6 +81,9 @@ export default { ...@@ -76,6 +81,9 @@ export default {
theadClass() { theadClass() {
return this.shouldShowSelectionSummary ? 'below-selection-summary' : ''; return this.shouldShowSelectionSummary ? 'below-selection-summary' : '';
}, },
reportTypeClass() {
return this.shouldShowReportType ? '' : 'gl-display-none';
},
fields() { fields() {
const commonThClass = ['table-th-transparent', 'original-gl-th', 'gl-bg-white!'].join(' '); const commonThClass = ['table-th-transparent', 'original-gl-th', 'gl-bg-white!'].join(' ');
return [ return [
...@@ -102,6 +110,7 @@ export default { ...@@ -102,6 +110,7 @@ export default {
}, },
{ {
key: 'reportType', key: 'reportType',
class: this.reportTypeClass,
label: s__('Reports|Scanner'), label: s__('Reports|Scanner'),
thClass: `${commonThClass}`, thClass: `${commonThClass}`,
}, },
......
...@@ -52,6 +52,7 @@ describe('First Class Group Dashboard Vulnerabilities Component', () => { ...@@ -52,6 +52,7 @@ describe('First Class Group Dashboard Vulnerabilities Component', () => {
emptyStateSvgPath, emptyStateSvgPath,
filters: null, filters: null,
isLoading: true, isLoading: true,
shouldShowReportType: false,
shouldShowSelection: true, shouldShowSelection: true,
shouldShowProjectNamespace: true, shouldShowProjectNamespace: true,
vulnerabilities: [], vulnerabilities: [],
...@@ -143,6 +144,7 @@ describe('First Class Group Dashboard Vulnerabilities Component', () => { ...@@ -143,6 +144,7 @@ describe('First Class Group Dashboard Vulnerabilities Component', () => {
emptyStateSvgPath, emptyStateSvgPath,
filters: null, filters: null,
isLoading: false, isLoading: false,
shouldShowReportType: false,
shouldShowSelection: true, shouldShowSelection: true,
shouldShowProjectNamespace: true, shouldShowProjectNamespace: true,
vulnerabilities, vulnerabilities,
......
...@@ -77,6 +77,7 @@ describe('First Class Instance Dashboard Vulnerabilities Component', () => { ...@@ -77,6 +77,7 @@ describe('First Class Instance Dashboard Vulnerabilities Component', () => {
emptyStateSvgPath, emptyStateSvgPath,
filters: null, filters: null,
isLoading: true, isLoading: true,
shouldShowReportType: false,
shouldShowSelection: true, shouldShowSelection: true,
shouldShowProjectNamespace: true, shouldShowProjectNamespace: true,
vulnerabilities: [], vulnerabilities: [],
...@@ -159,6 +160,7 @@ describe('First Class Instance Dashboard Vulnerabilities Component', () => { ...@@ -159,6 +160,7 @@ describe('First Class Instance Dashboard Vulnerabilities Component', () => {
emptyStateSvgPath, emptyStateSvgPath,
filters: null, filters: null,
isLoading: false, isLoading: false,
shouldShowReportType: false,
shouldShowSelection: true, shouldShowSelection: true,
shouldShowProjectNamespace: true, shouldShowProjectNamespace: true,
vulnerabilities, vulnerabilities,
......
...@@ -64,14 +64,6 @@ describe('Vulnerability list component', () => { ...@@ -64,14 +64,6 @@ describe('Vulnerability list component', () => {
expect(cell.text().toLowerCase()).toBe(newVulnerabilities[0].severity); expect(cell.text().toLowerCase()).toBe(newVulnerabilities[0].severity);
}); });
it('should correctly render the scanner type', () => {
const cells = findCells('reportType');
expect(cells.wrappers[0].text()).toBe('SAST');
expect(cells.wrappers[1].text()).toBe('Dependency Scanning');
expect(cells.wrappers[2].text()).toBe('custom scanner without translation');
expect(cells.wrappers[3].text()).toBe('');
});
it('should correctly render the description', () => { it('should correctly render the description', () => {
const cell = findCell('description'); const cell = findCell('description');
...@@ -163,6 +155,15 @@ describe('Vulnerability list component', () => { ...@@ -163,6 +155,15 @@ describe('Vulnerability list component', () => {
); );
expect(findLocation(vulnerabilityWithoutLocation[0].id).findAll('div').length).toBe(2); expect(findLocation(vulnerabilityWithoutLocation[0].id).findAll('div').length).toBe(2);
}); });
it('should not display the vulnerability report type', () => {
const newVulnerabilities = generateVulnerabilities();
wrapper = createWrapper({
props: { vulnerabilities: newVulnerabilities, shouldShowProjectNamespace: true },
});
const scannerCell = findRow().find('[data-label="Scanner"');
expect(scannerCell.classes('gl-display-none')).toBe(true);
});
}); });
describe('when displayed on a project level dashboard', () => { describe('when displayed on a project level dashboard', () => {
...@@ -170,7 +171,7 @@ describe('Vulnerability list component', () => { ...@@ -170,7 +171,7 @@ describe('Vulnerability list component', () => {
beforeEach(() => { beforeEach(() => {
newVulnerabilities = generateVulnerabilities(); newVulnerabilities = generateVulnerabilities();
wrapper = createWrapper({ wrapper = createWrapper({
props: { vulnerabilities: newVulnerabilities }, props: { vulnerabilities: newVulnerabilities, shouldShowReportType: true },
}); });
}); });
...@@ -188,6 +189,14 @@ describe('Vulnerability list component', () => { ...@@ -188,6 +189,14 @@ describe('Vulnerability list component', () => {
'src/main/java/com/gitlab/security_products/tests/App.java', 'src/main/java/com/gitlab/security_products/tests/App.java',
); );
}); });
it('should display the vulnerability report type', () => {
const cells = findCells('reportType');
expect(cells.wrappers[0].text()).toBe('SAST');
expect(cells.wrappers[1].text()).toBe('Dependency Scanning');
expect(cells.wrappers[2].text()).toBe('custom scanner without translation');
expect(cells.wrappers[3].text()).toBe('');
});
}); });
describe('when has an issue associated', () => { describe('when has an issue associated', () => {
......
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