prevision / apps /prevision-api /test /rendering.e2e-spec.ts
github-actions[bot]
Automated Deploy: 23110475c742a5d4f03930b55bca09042215c1dd
1fe7075
Raw History Blame Contribute Delete
1.14 kB
import type { INestApplication } from '@nestjs/common';
import { jwtVerify } from 'jose';
import { api, createApp, resetDatabase, signIn } from './helpers.js';
const SECRET = new TextEncoder().encode('test-processing-secret-0123456789abcdef012');
describe('Rendering (e2e)', () => {
let app: INestApplication;
beforeAll(async () => {
app = await createApp();
});
afterAll(() => app.close());
beforeEach(resetDatabase);
it('issues a renderer token for the signed-in account', async () => {
const headers = await signIn('user_r');
const userId = (await api(app).get('/api/me').set(headers)).body.data.user.id;
const response = await api(app).post('/api/processing-token').set(headers).expect(200);
const { payload } = await jwtVerify(response.body.data.token, SECRET, { audience: 'prevision-processing', issuer: 'prevision-api' });
expect(payload.sub).toBe(userId);
});
it('serves health checks outside /api', async () => {
await api(app).get('/health').expect(200);
expect((await api(app).get('/ready').expect(200)).body).toEqual({ success: true, data: { status: 'ready' } });
});
});