Open History to see the last commit
1import { test, expect } from './fixtures'
2
3type JournalEntry = {
4 headers?: Record<string, string>
5}
6
7test.describe('cloudflare — binding defaultHeaders on the wire', () => {
8 test('sends x-session-affinity and drops OpenAI SDK headers', async ({
9 request,
10 aimockPort,
11 testId,
12 }) => {
13 const response = await request.post(
14 `/api/cloudflare-binding-headers-wire?testId=${encodeURIComponent(testId)}`,
15 )
16 expect(response.ok()).toBe(true)
17 expect(await response.json()).toEqual({ ok: true })
18
19 const journalResponse = await request.get(
20 `http://127.0.0.1:${aimockPort}/v1/_requests`,
21 )
22 const entries = (await journalResponse.json()) as Array<JournalEntry>
23 const captured = entries.find(
24 (entry) => entry.headers?.['x-test-id'] === testId,
25 )
26 expect(captured).toBeDefined()
27 expect(captured?.headers?.['x-session-affinity']).toBe('ses_e2e')
28 expect(captured?.headers).not.toHaveProperty('authorization')
29 expect(
30 Object.keys(captured?.headers ?? {}).filter((name) =>
31 name.startsWith('x-stainless-'),
32 ),
33 ).toEqual([])
34 })
35})