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: introduce fixed URLs in audit type config #272

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const AuditConfigType = (data = {}) => {
disabled: data.disabled || false,
excludedURLs: data.excludedURLs || [],
manualOverwrites: data.manualOverwrites || [],
fixedURLs: data.fixedURLs || [],
};

const self = {
Expand All @@ -27,6 +28,10 @@ const AuditConfigType = (data = {}) => {
updateManualOverwrites: (manualOverwrites) => {
state.manualOverwrites = manualOverwrites;
},
getFixedURLs: () => state.fixedURLs,
updateFixedURLs: (fixedURLs) => {
state.fixedURLs = fixedURLs;
},
updateDisabled: (newValue) => {
state.disabled = newValue;
},
Expand All @@ -40,6 +45,7 @@ AuditConfigType.fromDynamoItem = (dynamoItem) => {
disabled: dynamoItem.disabled,
excludedURLs: dynamoItem.excludedURLs,
manualOverwrites: dynamoItem.manualOverwrites,
fixedURLs: dynamoItem.fixedURLs,
};
return AuditConfigType(auditConfigTypeData);
};
Expand All @@ -48,6 +54,7 @@ AuditConfigType.toDynamoItem = (auditConfigType) => ({
disabled: auditConfigType.disabled(),
excludedURLs: auditConfigType.getExcludedURLs(),
manualOverwrites: auditConfigType.getManualOverwrites(),
fixedURLs: auditConfigType.getFixedURLs(),
});

export default AuditConfigType;
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export const configSchema = Joi.object({
brokenTargetURL: Joi.string().optional(),
targetURL: Joi.string().optional(),
})).optional(),
fixedURLs: Joi.array().items(Joi.object({
brokenTargetURL: Joi.string().optional(),
targetURL: Joi.string().optional(),
})).optional(),
}).unknown(true),
).unknown(true),
}).unknown(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,26 @@ describe('AuditConfigType Tests', () => {
expect(auditConfigType.getManualOverwrites()).to.be.an('array').that.is.empty;
});
});

describe('updateFixedURLs Method', () => {
it('updates the updateFixedURLs array', () => {
const auditConfigType = AuditConfigType();
const newFixedURLs = [
{ brokenTargetURL: 'https://broken.co', targetURL: 'https://fixed.co' },
{ brokenTargetURL: 'https://broken.link.co', targetURL: 'https://fixed.link.co' },
];
auditConfigType.updateFixedURLs(newFixedURLs);
expect(auditConfigType.getFixedURLs()).to.eql(newFixedURLs);
});

it('updates the fixedURLs array to an empty array', () => {
const fixedURLs = [
{ brokenTargetURL: 'https://broken.co', targetURL: 'https://fixed.co' },
{ brokenTargetURL: 'https://broken.link.co', targetURL: 'https://fixed.link.co' },
];
const auditConfigType = AuditConfigType({ fixedURLs });
auditConfigType.updateFixedURLs([]);
expect(auditConfigType.getFixedURLs()).to.be.an('array').that.is.empty;
});
});
});
Loading