feat: register font/dfont converters in the app and worker

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-31 12:59:19 +02:00
co-authored by Claude Sonnet 5
parent be50f1f076
commit e7c30202f5
3 changed files with 50 additions and 0 deletions
+42
View File
@@ -179,6 +179,48 @@ describe('POST /api/jobs', () => {
expect(response.body.jobs[0].error).toMatch(/Invalid quality/);
});
it('creates a pending job converting an OTF upload to ttf', async () => {
const fixturePath = path.join(import.meta.dirname, '..', 'fixtures', 'sample.otf');
const response = await request(app)
.post('/api/jobs')
.field('targetFormats', JSON.stringify(['ttf']))
.attach('files', fixturePath, 'font.otf');
expect(response.status).toBe(201);
expect(response.body.jobs[0].status).toBe('pending');
const job = await getJobByUuid(prisma, response.body.jobs[0].id);
expect(job.sourceFormat).toBe('otf');
expect(job.targetFormat).toBe('ttf');
expect(job.family).toBe('font');
expect(job.inputMimeType).toBe('font/otf');
});
it('creates a pending job converting a dfont upload despite file-type misidentifying its content as ico', async () => {
const fixturePath = path.join(import.meta.dirname, '..', 'fixtures', 'sample.dfont');
const response = await request(app)
.post('/api/jobs')
.field('targetFormats', JSON.stringify(['ttf']))
.attach('files', fixturePath, 'font.dfont');
expect(response.status).toBe(201);
expect(response.body.jobs[0].status).toBe('pending');
const job = await getJobByUuid(prisma, response.body.jobs[0].id);
expect(job.sourceFormat).toBe('dfont');
expect(job.inputMimeType).toBe('application/x-dfont');
});
it('lists ttf/otf/woff as targets for each other via GET /api/formats, and never lists dfont as a target', async () => {
const ttfTargets = await request(app).get('/api/formats').query({ source: 'ttf' });
expect(ttfTargets.body.targets).toEqual(expect.arrayContaining(['otf', 'woff']));
const otfTargets = await request(app).get('/api/formats').query({ source: 'otf' });
expect(otfTargets.body.targets).not.toContain('dfont');
});
it('creates a pending job converting a HEIC upload to jpg', async () => {
const fixturePath = path.join(import.meta.dirname, '..', 'fixtures', 'sample.heic');