Release v2.15.4
This commit is contained in:
1 parent
64aeb1b47e
commit
05c9341b08
25 files changed
+595
-31
No files matched your search
@@ -226,4 +226,52 @@ test('fonts page renders the upload card above the table card', () => {
|
||||
assert.match(html, /data-table-sort-key="file"/);
|
||||
assert.match(html, /data-table-sort-key="format"/);
|
||||
assert.match(html, /data-table-sort-key="status"/);
|
||||
});
|
||||
|
||||
test('font upload, status changes, and deletion are audited', async () => {
|
||||
const originals = {
|
||||
loadFontLibrary: fontLibrary.loadFontLibrary,
|
||||
addFontFile: fontLibrary.addFontFile,
|
||||
setFontEnabled: fontLibrary.setFontEnabled,
|
||||
deleteFontFile: fontLibrary.deleteFontFile
|
||||
};
|
||||
const { app, handlers } = createHandlers();
|
||||
const events = [];
|
||||
const font = { id: 'alpha.woff2', family: 'Alpha Sans', name: 'Alpha Sans', fileName: 'alpha.woff2', format: 'woff2', enabled: true };
|
||||
fontLibrary.loadFontLibrary = function () { return { fonts: [font], stylesheetHref: '' }; };
|
||||
fontLibrary.addFontFile = async function () { return { font: font, fonts: [font] }; };
|
||||
fontLibrary.setFontEnabled = async function (_dir, _id, enabled) { return Object.assign({}, font, { enabled: enabled }); };
|
||||
fontLibrary.deleteFontFile = async function () { return font; };
|
||||
|
||||
try {
|
||||
registerFontRoutes(app, {
|
||||
pool: { async query() { return [[{ match_count: 0 }]]; } },
|
||||
pages: { renderFontsPage() { return ''; } },
|
||||
upload: { single() { return function (_req, _res, next) { next(); }; } },
|
||||
uploadDir: 'unused',
|
||||
backgroundTaskQueue: null,
|
||||
recordRequestAuditEvent(_pool, _req, event) { events.push(event); }
|
||||
});
|
||||
const response = { redirect() { return this; } };
|
||||
const next = function (error) { if (error) throw error; };
|
||||
const currentUser = { id: 12, permissionKeys: ['fonts.create', 'fonts.update', 'fonts.delete'] };
|
||||
|
||||
await handlers['POST /settings/fonts'].at(-1)(
|
||||
{ currentUser: currentUser, body: { font_family: 'Alpha Sans' }, file: { path: 'unused' } }, response, next
|
||||
);
|
||||
await handlers['POST /settings/fonts/:id/toggle'].at(-1)(
|
||||
{ currentUser: currentUser, params: { id: font.id }, body: { enabled: '0' } }, response, next
|
||||
);
|
||||
await handlers['POST /settings/fonts/:id/delete'].at(-1)(
|
||||
{ currentUser: currentUser, params: { id: font.id } }, response, next
|
||||
);
|
||||
|
||||
assert.deepEqual(events.map(function (event) { return event.eventType; }), ['font.uploaded', 'font.disabled', 'font.deleted']);
|
||||
assert.ok(events.every(function (event) { return event.category === 'media-assets' && event.actorUserId === 12; }));
|
||||
} finally {
|
||||
fontLibrary.loadFontLibrary = originals.loadFontLibrary;
|
||||
fontLibrary.addFontFile = originals.addFontFile;
|
||||
fontLibrary.setFontEnabled = originals.setFontEnabled;
|
||||
fontLibrary.deleteFontFile = originals.deleteFontFile;
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user