Release v2.18.0: template default content
This commit is contained in:
1 parent
48e8f3eb4b
commit
24f1603b43
54 files changed
+1421
-151
No files matched your search
@@ -185,6 +185,43 @@ test('fonts route sorts by format and status', async () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('template default font references mark fonts in use and block deletion', async () => {
|
||||
const originals = {
|
||||
loadFontLibrary: fontLibrary.loadFontLibrary,
|
||||
deleteFontFile: fontLibrary.deleteFontFile
|
||||
};
|
||||
const { app, handlers } = createHandlers();
|
||||
const font = { id: 'alpha.woff2', family: 'Alpha Sans', name: 'Alpha Sans', fileName: 'alpha.woff2', format: 'woff2', enabled: true };
|
||||
let deleteCount = 0;
|
||||
fontLibrary.loadFontLibrary = function () { return { fonts: [font], stylesheetHref: '' }; };
|
||||
fontLibrary.deleteFontFile = async function () { deleteCount += 1; return font; };
|
||||
registerFontRoutes(app, {
|
||||
pool: {
|
||||
async query(sql) {
|
||||
if (sql.includes('FROM c_template_regions')) return [[{ match_count: 1 }]];
|
||||
return [[{ match_count: 0 }]];
|
||||
}
|
||||
},
|
||||
pages: { renderFontsPage(data) { return JSON.stringify(data); } },
|
||||
upload: { single() { return function (_req, _res, next) { next(); }; } },
|
||||
uploadDir: 'unused',
|
||||
backgroundTaskQueue: null
|
||||
});
|
||||
|
||||
try {
|
||||
const response = { body: '', send(value) { this.body = value; return this; }, redirect(value) { this.location = value; return this; } };
|
||||
const req = { query: {}, currentUser: { permissions: ['fonts.read', 'fonts.delete'] }, params: { id: font.id } };
|
||||
await handlers['GET /settings/fonts'][1](req, response, error => { throw error; });
|
||||
assert.equal(JSON.parse(response.body).fonts[0].inUse, true);
|
||||
await handlers['POST /settings/fonts/:id/delete'].at(-1)(req, response, error => { throw error; });
|
||||
assert.match(decodeURIComponent(response.location), /font is still used by slides or template defaults/);
|
||||
assert.equal(deleteCount, 0);
|
||||
} finally {
|
||||
fontLibrary.loadFontLibrary = originals.loadFontLibrary;
|
||||
fontLibrary.deleteFontFile = originals.deleteFontFile;
|
||||
}
|
||||
});
|
||||
|
||||
test('fonts page renders the upload card above the table card', () => {
|
||||
const html = renderFontsPage({
|
||||
fonts: [
|
||||
|
||||
Reference in new issue
Block a user