Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add 404 as valid audit type #97

Merged
merged 8 commits into from
Jan 23, 2024
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
Loading