fix: hooked up python API for templates

This commit is contained in:
2026-02-27 20:31:25 +01:00
parent f3364999ee
commit 6c2d2c48bf
7 changed files with 764 additions and 3 deletions

View File

@@ -343,4 +343,50 @@ describe('TemplateEngine', () => {
expect(created.slug).toBe('my_custom_slug');
});
});
describe('getTemplateBySlug', () => {
it('retrieves an enabled template by exact slug', async () => {
await templateEngine.createTemplate({
title: 'Custom Post',
kind: 'post',
content: '<main>Post</main>',
enabled: true,
});
const found = await templateEngine.getTemplateBySlug('custom_post');
expect(found).not.toBeNull();
expect(found?.slug).toBe('custom_post');
expect(found?.title).toBe('Custom Post');
});
it('matches slugs case-insensitively', async () => {
await templateEngine.createTemplate({
title: 'Custom Post',
kind: 'post',
content: '<main>Post</main>',
enabled: true,
});
const found = await templateEngine.getTemplateBySlug('CUSTOM_POST');
expect(found).not.toBeNull();
expect(found?.slug).toBe('custom_post');
});
it('returns null for non-existent slug', async () => {
const found = await templateEngine.getTemplateBySlug('does_not_exist');
expect(found).toBeNull();
});
it('does not return disabled templates', async () => {
await templateEngine.createTemplate({
title: 'Disabled Template',
kind: 'post',
content: '<main>Disabled</main>',
enabled: false,
});
const found = await templateEngine.getTemplateBySlug('disabled_template');
expect(found).toBeNull();
});
});
});