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

azure-openai-wire.spec.ts

31 lines1.0 KB

1import { test, expect } from './fixtures'
2​
3test('azure openai -- sends the Azure path, api-key, and deployment name', async ({
4 request,
5 aimockPort,
6 testId,
7}) => {
8 const response = await request.post('/api/azure-openai-wire', {
9 data: { testId },
10 })
11 expect(response.ok()).toBe(true)
12 expect(await response.text()).toContain('Stratocaster')
13​
14 const journal = await request.get(
15 `http://127.0.0.1:${aimockPort}/v1/_requests`,
16 )
17 const entries = (await journal.json()) as Array<{
18 path?: string
19 headers?: Record<string, string>
20 body?: Record<string, unknown> | null
21 }>
22 const calls = entries.filter(
23 (entry) => entry.headers?.['x-test-id'] === testId,
24 )
25 expect(calls).toHaveLength(1)
26 expect(calls[0]?.path).toBe('/openai/v1/responses?api-version=v1')
27 // aimock redacts the value of the key header in its journal.
28 expect(calls[0]?.headers).toHaveProperty('api-key')
29 expect(calls[0]?.headers).not.toHaveProperty('authorization')
30 expect(calls[0]?.body?.model).toBe('e2e-deployment')
31})