mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 10:33:59 -05:00
Does some winter cleaning on the site-template stuff :)
1. Migrated away from the custom conf format to plain old yaml
2. Made the images and image files match with the name from the yaml
file. (It's not a problem to have spaces in file paths, nor urls so I
don't see why we shouldn't)
3. Updated the relevant documentation
There is a small breakage in the api response for the meta field. It now
returns `{"screenshot_dimensions":{"width":1000,"height":800}}` which I
believe is a lot more useful than
`{"meta.screenshot_dimensions":"1000x800"}`
Besides, I don't believe this endpoint has any third-party consumers
that rely on the metadata since it's a rarely known feature anyways
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
import express from 'express';
|
|
import request from 'supertest';
|
|
import {beforeAll, describe, expect, it} from 'vitest';
|
|
|
|
import {SiteTemplateController} from '../../lib/handlers/api/site-template-controller.js';
|
|
import {getSiteTemplates} from '../../lib/site-templates.js';
|
|
|
|
describe('Site Templates Backend', () => {
|
|
let app: express.Express;
|
|
beforeAll(() => {
|
|
app = express();
|
|
const controller = new SiteTemplateController();
|
|
app.use('/', controller.createRouter());
|
|
});
|
|
|
|
it('should load site templates properly', async () => {
|
|
const templates = await getSiteTemplates();
|
|
// not super comprehensive
|
|
expect(templates.meta.screenshot_dimensions).toHaveProperty('width');
|
|
expect(templates.meta.screenshot_dimensions).toHaveProperty('height');
|
|
expect(Object.entries(templates.templates).length).toBeTruthy();
|
|
});
|
|
|
|
it('should respond to plain site template requests', async () => {
|
|
await request(app).get('/api/siteTemplates').expect(200).expect('Content-Type', /json/);
|
|
});
|
|
});
|