Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test: exercise native Response cookies in Desktop transport

Josuéa5d8c7801be4
diff --git a/desktop-app/src/desktopWindow.transport.test.ts b/desktop-app/src/desktopWindow.transport.test.ts
index 745951794..03e0fe414 100644
--- a/desktop-app/src/desktopWindow.transport.test.ts
+++ b/desktop-app/src/desktopWindow.transport.test.ts
@@ -28,16 +28,16 @@ afterEach(() => {
})
it('exchanges, installs cookies and navigates through the same effective RPC URL', async () => {
- const fetch = vi.fn().mockResolvedValue({
- ok: true,
- json: async () => ({ ok: true, hostRef: 'transport-host' }),
+ const response = new Response(JSON.stringify({ ok: true, hostRef: 'transport-host' }), {
+ status: 200,
headers: {
- get: (name: string) =>
- name === 'set-cookie'
- ? 'clerum_desktop_session=fixture-cookie; Path=/api/v1/desktop/transport-host; HttpOnly'
- : null,
+ 'content-type': 'application/json',
+ 'set-cookie':
+ 'clerum_desktop_session=fixture-cookie; Path=/api/v1/desktop/transport-host; HttpOnly',
},
})
+ const getSetCookie = vi.spyOn(response.headers, 'getSetCookie')
+ const fetch = vi.fn().mockResolvedValue(response)
vi.stubGlobal('fetch', fetch)
const { openDesktopWindow } = await import('./desktopWindow.js')
await openDesktopWindow({
@@ -49,9 +49,13 @@ it('exchanges, installs cookies and navigates through the same effective RPC URL
'https://effective-rpc.example.test/api/v1/desktop/transport-host/session',
expect.objectContaining({ method: 'POST' })
)
+ expect(getSetCookie).toHaveBeenCalledOnce()
expect(mocks.setCookie).toHaveBeenCalledWith(
expect.objectContaining({
url: 'https://effective-rpc.example.test/api/v1/desktop/transport-host',
+ name: 'clerum_desktop_session',
+ value: 'fixture-cookie',
+ httpOnly: true,
})
)
expect(mocks.loadURL).toHaveBeenCalledWith(