Skip to content

Commit

Permalink
feat: add 404 as valid audit type
Browse files Browse the repository at this point in the history
  • Loading branch information
alinarublea authored Jan 23, 2024
1 parent 99245b9 commit 62e0dec
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/spacecat-shared-data-access/src/models/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import { hasText, isIsoDate, isObject } from '@adobe/spacecat-shared-utils';
import { Base } from './base.js';

export const AUDIT_TYPE_404 = '404';
export const AUDIT_TYPE_BROKEN_BACKLINKS = 'broken-backlinks';
export const AUDIT_TYPE_CWV = 'cwv';
export const AUDIT_TYPE_LHS_DESKTOP = 'lhs-desktop';
Expand All @@ -21,6 +22,7 @@ export const AUDIT_TYPE_LHS_MOBILE = 'lhs-mobile';
const EXPIRES_IN_DAYS = 30;

const AUDIT_TYPE_PROPERTIES = {
[AUDIT_TYPE_404]: [],
[AUDIT_TYPE_BROKEN_BACKLINKS]: [],
[AUDIT_TYPE_CWV]: [],
[AUDIT_TYPE_LHS_DESKTOP]: ['performance', 'seo', 'accessibility', 'best-practices'],
Expand All @@ -38,7 +40,10 @@ const validateScores = (auditResult, auditType) => {
return true;
}

if (auditType !== AUDIT_TYPE_BROKEN_BACKLINKS && !isObject(auditResult.scores)) {
if ((auditType === AUDIT_TYPE_LHS_DESKTOP
|| auditType === AUDIT_TYPE_LHS_MOBILE
|| auditType === AUDIT_TYPE_CWV)
&& !isObject(auditResult.scores)) {
throw new Error(`Missing scores property for audit type '${auditType}'`);
}

Expand Down

0 comments on commit 62e0dec

Please sign in to comment.