diff --git a/src/web/pages/audits/__tests__/row.jsx b/src/web/pages/audits/__tests__/row.jsx
index 4430fe8237..d4599b2ac1 100644
--- a/src/web/pages/audits/__tests__/row.jsx
+++ b/src/web/pages/audits/__tests__/row.jsx
@@ -21,7 +21,10 @@ import Row from '../row';
setLocale('en');
const gmp = {settings: {}};
-const caps = new Capabilities(['everything']);
+const featureList = [
+ {name: 'COMPLIANCE_REPORTS', _enabled: 0},
+];
+const caps = new Capabilities(['everything'], featureList);
const lastReport = {
report: {
@@ -110,11 +113,11 @@ describe('Audit Row tests', () => {
const detailsLinks = getAllByTestId('details-link');
expect(detailsLinks[0]).toHaveTextContent('Done');
- expect(detailsLinks[0]).toHaveAttribute('href', '/auditreport/1234');
+ expect(detailsLinks[0]).toHaveAttribute('href', '/report/1234');
// Report
expect(detailsLinks[1]).toHaveTextContent('Wed, Jul 10, 2019 2:51 PM CEST');
- expect(detailsLinks[1]).toHaveAttribute('href', '/auditreport/1234');
+ expect(detailsLinks[1]).toHaveAttribute('href', '/report/1234');
// Compliance Status
expect(bars[1]).toHaveAttribute('title', '50%');
@@ -375,7 +378,7 @@ describe('Audit Row tests', () => {
const detailsLinks = getAllByTestId('details-link');
expect(detailsLinks[0]).toHaveTextContent('0 %');
- expect(detailsLinks[0]).toHaveAttribute('href', '/auditreport/5678');
+ expect(detailsLinks[0]).toHaveAttribute('href', '/report/5678');
// Report
expect(detailsLinks.length).toBe(1);
@@ -483,11 +486,11 @@ describe('Audit Row tests', () => {
const detailsLinks = getAllByTestId('details-link');
expect(detailsLinks[0]).toHaveTextContent('Stopped');
- expect(detailsLinks[0]).toHaveAttribute('href', '/auditreport/5678');
+ expect(detailsLinks[0]).toHaveAttribute('href', '/report/5678');
// Report
expect(detailsLinks[1]).toHaveTextContent('Wed, Jul 10, 2019 2:51 PM CEST');
- expect(detailsLinks[1]).toHaveAttribute('href', '/auditreport/1234');
+ expect(detailsLinks[1]).toHaveAttribute('href', '/report/1234');
// Compliance Status
expect(bars[1]).toHaveAttribute('title', '50%');
@@ -593,11 +596,11 @@ describe('Audit Row tests', () => {
const detailsLinks = getAllByTestId('details-link');
expect(detailsLinks[0]).toHaveTextContent('Done');
- expect(detailsLinks[0]).toHaveAttribute('href', '/auditreport/1234');
+ expect(detailsLinks[0]).toHaveAttribute('href', '/report/1234');
// Report
expect(detailsLinks[1]).toHaveTextContent('Wed, Jul 10, 2019 2:51 PM CEST');
- expect(detailsLinks[1]).toHaveAttribute('href', '/auditreport/1234');
+ expect(detailsLinks[1]).toHaveAttribute('href', '/report/1234');
// Compliance Status
expect(bars[1]).toHaveAttribute('title', '50%');
@@ -706,11 +709,11 @@ describe('Audit Row tests', () => {
const detailsLinks = getAllByTestId('details-link');
expect(detailsLinks[0]).toHaveTextContent('Done');
- expect(detailsLinks[0]).toHaveAttribute('href', '/auditreport/1234');
+ expect(detailsLinks[0]).toHaveAttribute('href', '/report/1234');
// Report
expect(detailsLinks[1]).toHaveTextContent('Wed, Jul 10, 2019 2:51 PM CEST');
- expect(detailsLinks[1]).toHaveAttribute('href', '/auditreport/1234');
+ expect(detailsLinks[1]).toHaveAttribute('href', '/report/1234');
// Compliance Status
expect(bars[1]).toHaveAttribute('title', '50%');
@@ -760,3 +763,104 @@ describe('Audit Row tests', () => {
console.warn = consoleError;
});
+
+describe('Audit Row tests - compliance reports enabled', () => {
+ // deactivate console.error for tests
+ // to make it possible to test a row without a table
+ console.error = () => {};
+ const featureList = [
+ {name: 'COMPLIANCE_REPORTS', _enabled: 1},
+ ];
+ const caps = new Capabilities(['everything'], featureList);
+
+ test('should render', () => {
+ const audit = Audit.fromElement({
+ _id: '314',
+ owner: {name: 'username'},
+ name: 'foo',
+ comment: 'bar',
+ status: AUDIT_STATUS.done,
+ alterable: '0',
+ last_report: lastReport,
+ permissions: {permission: [{name: 'everything'}]},
+ target: {_id: '5678', name: 'target'},
+ usage_type: 'audit',
+ });
+
+ const handleAuditClone = testing.fn();
+ const handleAuditDelete = testing.fn();
+ const handleAuditDownload = testing.fn();
+ const handleAuditEdit = testing.fn();
+ const handleAuditResume = testing.fn();
+ const handleAuditStart = testing.fn();
+ const handleAuditStop = testing.fn();
+ const handleReportDownload = testing.fn();
+ const handleToggleDetailsClick = testing.fn();
+
+ const {render, store} = rendererWith({
+ gmp,
+ capabilities: caps,
+ store: true,
+ router: true,
+ });
+
+ store.dispatch(setTimezone('CET'));
+ store.dispatch(setUsername('username'));
+
+ const {baseElement, getAllByTestId} = render(
+
,
+ );
+
+ expect(baseElement).toBeVisible();
+
+ // Name
+ expect(baseElement).toHaveTextContent('foo');
+ expect(baseElement).toHaveTextContent('(bar)');
+
+ // Status
+ const bars = getAllByTestId('progressbar-box');
+
+ expect(bars[0]).toHaveAttribute('title', AUDIT_STATUS.done);
+ expect(bars[0]).toHaveTextContent(AUDIT_STATUS.done);
+
+ const detailsLinks = getAllByTestId('details-link');
+
+ expect(detailsLinks[0]).toHaveTextContent('Done');
+ expect(detailsLinks[0]).toHaveAttribute('href', '/auditreport/1234');
+
+ // Report
+ expect(detailsLinks[1]).toHaveTextContent('Wed, Jul 10, 2019 2:51 PM CEST');
+ expect(detailsLinks[1]).toHaveAttribute('href', '/auditreport/1234');
+
+ // Compliance Status
+ expect(bars[1]).toHaveAttribute('title', '50%');
+ expect(bars[1]).toHaveTextContent('50%');
+
+ // Actions
+ const icons = getAllByTestId('svg-icon');
+
+ expect(icons[0]).toHaveAttribute('title', 'Start');
+ expect(icons[1]).toHaveAttribute('title', 'Audit is not stopped');
+ expect(icons[2]).toHaveAttribute('title', 'Move Audit to trashcan');
+ expect(icons[3]).toHaveAttribute('title', 'Edit Audit');
+ expect(icons[4]).toHaveAttribute('title', 'Clone Audit');
+ expect(icons[5]).toHaveAttribute('title', 'Export Audit');
+ expect(icons[6]).toHaveAttribute(
+ 'title',
+ 'Download Greenbone Compliance Report',
+ );
+ });
+});
\ No newline at end of file
diff --git a/src/web/pages/audits/row.jsx b/src/web/pages/audits/row.jsx
index ed4b9d445a..2633993139 100644
--- a/src/web/pages/audits/row.jsx
+++ b/src/web/pages/audits/row.jsx
@@ -36,8 +36,10 @@ import {GREENBONE_SENSOR_SCANNER_TYPE} from 'gmp/models/scanner';
import ComplianceStatusBar from 'web/components/bar/compliancestatusbar';
+import {renderReport} from 'web/pages/tasks/row';
import DateTime from 'web/components/date/datetime';
import DetailsLink from 'web/components/link/detailslink';
+import useCapabilities from 'web/hooks/useCapabilities';
const renderAuditReport = (report, links) => {
if (!isDefined(report)) {
@@ -83,8 +85,8 @@ const Row = ({
...props
}) => {
const {scanner, observers} = entity;
-
const obs = [];
+ const caps = useCapabilities();
if (isDefined(observers)) {
if (isDefined(observers.user)) {
@@ -143,9 +145,17 @@ const Row = ({
{entity.comment && ({entity.comment})}
-
+
+
+
+ {caps.featureEnabled('COMPLIANCE_REPORTS')
+ ? renderAuditReport(entity.last_report, links)
+ : renderReport(entity.last_report, links)
+ }
- {renderAuditReport(entity.last_report, links)}
{isDefined(entity.last_report) && (