Spaces:
Paused
Paused
Download apps/prevision-api/test/rendering.e2e-spec.ts from modventures/prevision: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/spaces/modventures/prevision/resolve/main/apps/prevision-api/test/rendering.e2e-spec.ts
- Command line
-
hf download hf://spaces/modventures/prevision/apps/prevision-api/test/rendering.e2e-spec.ts
-
curl -L -o rendering.e2e-spec.ts https://huggingface.co/spaces/modventures/prevision/resolve/main/apps/prevision-api/test/rendering.e2e-spec.ts
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' } }); | |
| }); | |
| }); | |