Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

video-live.spec.ts

61 lines1.7 KB

1import { test, expect } from './fixtures'
2​
3test.describe('generateLiveVideo activity', () => {
4 test('mints a Reactor session token through reactorVideo', async ({
5 request,
6 }) => {
7 const res = await request.post('/api/video-live', {
8 data: { prompt: 'A neon cyberpunk city at night', model: 'helios' },
9 })
10 expect(res.ok()).toBe(true)
11​
12 const body = (await res.json()) as {
13 ok: boolean
14 token?: string
15 model?: string
16 prompt?: string
17 status?: string
18 expiresAt?: number
19 error?: string
20 }
21​
22 expect(body.error ?? null).toBeNull()
23 expect(body.ok).toBe(true)
24 expect(body.token).toBe('jwt-e2e')
25 expect(body.model).toBe('reactor/helios')
26 expect(body.prompt).toBe('A neon cyberpunk city at night')
27 expect(body.status).toBe('ready')
28 expect(body.expiresAt).toBe(1_800_000_000 * 1000)
29 })
30​
31 test('mints a fal realtime token through falLiveVideo', async ({
32 request,
33 }) => {
34 const before = Date.now()
35 const res = await request.post('/api/video-live', {
36 data: {
37 prompt: 'Live shopping stream: a host holds up a gold watch',
38 model: 'minimax/h3-max/director',
39 },
40 })
41 expect(res.ok()).toBe(true)
42​
43 const body = (await res.json()) as {
44 ok: boolean
45 token?: string
46 model?: string
47 prompt?: string
48 status?: string
49 expiresAt?: number
50 error?: string
51 }
52​
53 expect(body.error ?? null).toBeNull()
54 expect(body.ok).toBe(true)
55 expect(body.token).toBe('jwt-fal-e2e')
56 expect(body.model).toBe('fal-ai/minimax-h3-max-director')
57 expect(body.status).toBe('ready')
58 expect(body.expiresAt).toBeGreaterThan(before + 290_000)
59 expect(body.expiresAt).toBeLessThan(before + 310_000)
60 })
61})