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 {
:empty-state-svg-path="emptyStateSvgPath"
:filters="filters"
:vulnerabilities="vulnerabilities"
should-show-report-type
@refetch-vulnerabilities="refetchVulnerabilities"
>
<template #emptyState>
......
......@@ -35,6 +35,11 @@ export default {
required: false,
default: null,
},
shouldShowReportType: {
type: Boolean,
required: false,
default: false,
},
shouldShowSelection: {
type: Boolean,
required: false,
......@@ -76,6 +81,9 @@ export default {
theadClass() {
return this.shouldShowSelectionSummary ? 'below-selection-summary' : '';
},
reportTypeClass() {
return this.shouldShowReportType ? '' : 'gl-display-none';
},
fields() {
const commonThClass = ['table-th-transparent', 'original-gl-th', 'gl-bg-white!'].join(' ');
return [
......@@ -102,6 +110,7 @@ export default {
},
{
key: 'reportType',
class: this.reportTypeClass,
label: s__('Reports|Scanner'),
thClass: `${commonThClass}`,
},
......
......@@ -52,6 +52,7 @@ describe('First Class Group Dashboard Vulnerabilities Component', () => {
emptyStateSvgPath,
filters: null,
isLoading: true,
shouldShowReportType: false,
shouldShowSelection: true,
shouldShowProjectNamespace: true,
vulnerabilities: [],
......@@ -143,6 +144,7 @@ describe('First Class Group Dashboard Vulnerabilities Component', () => {
emptyStateSvgPath,
filters: null,
isLoading: false,
shouldShowReportType: false,
shouldShowSelection: true,
shouldShowProjectNamespace: true,
vulnerabilities,
......
......@@ -77,6 +77,7 @@ describe('First Class Instance Dashboard Vulnerabilities Component', () => {
emptyStateSvgPath,
filters: null,
isLoading: true,
shouldShowReportType: false,
shouldShowSelection: true,
shouldShowProjectNamespace: true,
vulnerabilities: [],
......@@ -159,6 +160,7 @@ describe('First Class Instance Dashboard Vulnerabilities Component', () => {
emptyStateSvgPath,
filters: null,
isLoading: false,
shouldShowReportType: false,
shouldShowSelection: true,
shouldShowProjectNamespace: true,
vulnerabilities,
......
......@@ -64,14 +64,6 @@ describe('Vulnerability list component', () => {
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', () => {
const cell = findCell('description');
......@@ -163,6 +155,15 @@ describe('Vulnerability list component', () => {
);
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', () => {
......@@ -170,7 +171,7 @@ describe('Vulnerability list component', () => {
beforeEach(() => {
newVulnerabilities = generateVulnerabilities();
wrapper = createWrapper({
props: { vulnerabilities: newVulnerabilities },
props: { vulnerabilities: newVulnerabilities, shouldShowReportType: true },
});
});
......@@ -188,6 +189,14 @@ describe('Vulnerability list component', () => {
'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', () => {
......
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