Skip to content

Commit

Permalink
Merge branch 'main' into SITES-17354
Browse files Browse the repository at this point in the history
  • Loading branch information
alinarublea authored Jan 29, 2024
2 parents 002f3d8 + 78bcc1d commit 348f640
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 deletions.
7 changes: 7 additions & 0 deletions packages/spacecat-shared-data-access/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [@adobe/spacecat-shared-data-access-v1.11.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.10.5...@adobe/spacecat-shared-data-access-v1.11.0) (2024-01-29)


### Features

* default value for disabled property of audit config ([#114](https://github.com/adobe/spacecat-shared/issues/114)) ([daf9b80](https://github.com/adobe/spacecat-shared/commit/daf9b8039a6fe567e283dc07eef156bfd13edc4f))

# [@adobe/spacecat-shared-data-access-v1.10.5](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.10.4...@adobe/spacecat-shared-data-access-v1.10.5) (2024-01-27)


Expand Down
2 changes: 1 addition & 1 deletion packages/spacecat-shared-data-access/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/spacecat-shared-data-access",
"version": "1.10.5",
"version": "1.11.0",
"description": "Shared modules of the Spacecat Services - Data Access",
"type": "module",
"main": "src/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,27 @@
*/

import AuditConfigType from './audit-config-type.js';
import { AUDIT_TYPE_BROKEN_BACKLINKS } from '../audit.js';

const AUDIT_TYPE_DISABLED_DEFAULTS = {
[AUDIT_TYPE_BROKEN_BACKLINKS]: true,
};

function getAuditTypeConfigs(auditTypeConfigs, auditsDisabled) {
if (!auditTypeConfigs || Object.keys(auditTypeConfigs).length === 0) {
return {
[AUDIT_TYPE_BROKEN_BACKLINKS]: AuditConfigType({ disabled: true }),
};
}
return Object.entries(auditTypeConfigs || {}).reduce((acc, [key, value]) => {
acc[key] = AuditConfigType(value, auditsDisabled);
const disabled = value.disabled !== undefined
? value.disabled : (AUDIT_TYPE_DISABLED_DEFAULTS[key] || auditsDisabled || false);
acc[key] = AuditConfigType(
{
...value,
disabled,
},
);
return acc;
}, {});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ describe('Site Model Tests', () => {
expect(auditConfig).to.be.an('object');
expect(auditConfig.auditsDisabled()).to.be.true;
expect(auditConfig.getAuditTypeConfig('type1')).to.be.an('object');
expect(auditConfig.getAuditTypeConfig('type1').disabled()).to.be.false;
expect(auditConfig.getAuditTypeConfig('type1').disabled()).to.be.true;
expect(auditConfig.getAuditTypeConfig('type2')).to.be.an('object');
expect(auditConfig.getAuditTypeConfig('type2').disabled()).to.be.false;
expect(auditConfig.getAuditTypeConfig('type2').disabled()).to.be.true;
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,30 @@
import { expect } from 'chai';

import AuditConfig from '../../../../src/models/site/audit-config.js';
import { AUDIT_TYPE_BROKEN_BACKLINKS } from '../../../../src/models/audit.js';

describe('AuditConfig Tests', () => {
describe('AuditConfig Creation', () => {
it('creates an AuditConfig with defaults when no data is provided', () => {
const auditConfig = AuditConfig();
expect(auditConfig.auditsDisabled()).to.be.false;
expect(auditConfig.getAuditTypeConfigs()).to.be.empty;
const auditTypeConfigs = auditConfig.getAuditTypeConfigs();
expect(auditTypeConfigs[AUDIT_TYPE_BROKEN_BACKLINKS]).to.be.an('object');
expect(auditTypeConfigs[AUDIT_TYPE_BROKEN_BACKLINKS].disabled()).to.be.true;
});

it('creates an AuditConfig with provided data', () => {
const data = {
auditsDisabled: true,
auditTypeConfigs: {
type1: { disabled: true },
type2: { disabled: false },
[AUDIT_TYPE_BROKEN_BACKLINKS]: { disabled: false },
},
};
const auditConfig = AuditConfig(data);
expect(auditConfig.auditsDisabled()).to.be.true;
expect(auditConfig.getAuditTypeConfig('type1').disabled()).to.be.true;
expect(auditConfig.getAuditTypeConfig('type2').disabled()).to.be.false;
expect(auditConfig.getAuditTypeConfig(AUDIT_TYPE_BROKEN_BACKLINKS).disabled()).to.be.false;
});
});

Expand Down Expand Up @@ -75,15 +78,6 @@ describe('AuditConfig Tests', () => {
const typeConfigs = auditConfig.getAuditTypeConfigs();
expect(typeConfigs).to.have.keys(['type1', 'type2']);
});

it('returns no audit type configurations', () => {
const data = {
auditTypeConfigs: {},
};
const auditConfig = AuditConfig(data);
const typeConfigs = auditConfig.getAuditTypeConfigs();
expect(typeConfigs).to.be.an('object').that.is.empty;
});
});

describe('updateAuditsDisabled Method', () => {
Expand Down

0 comments on commit 348f640

Please sign in to comment.