diff --git a/apps/web/src/test/integration/_helpers/auth.ts b/apps/web/src/test/integration/_helpers/auth.ts index a03b597..b31fb0b 100644 --- a/apps/web/src/test/integration/_helpers/auth.ts +++ b/apps/web/src/test/integration/_helpers/auth.ts @@ -43,11 +43,21 @@ export function getTestAuthContext(): TestAuthContext { /** * Create a fetch function with session cookie authentication + * + * Note: better-auth uses different cookie names for HTTP vs HTTPS: + * - HTTP: better-auth.session_token + * - HTTPS: __Secure-better-auth.session_token + * + * We send both to ensure compatibility. */ export function createSessionFetch(sessionToken: string): typeof fetch { return (input: RequestInfo | URL, init?: RequestInit) => { const headers = new Headers(init?.headers); - headers.set('Cookie', `better-auth.session_token=${sessionToken}`); + // Send both cookie formats to work with both HTTP and HTTPS + headers.set( + 'Cookie', + `better-auth.session_token=${sessionToken}; __Secure-better-auth.session_token=${sessionToken}` + ); return fetch(input, { ...init, diff --git a/apps/web/src/test/integration/_helpers/factories/agent.factory.ts b/apps/web/src/test/integration/_helpers/factories/agent.factory.ts index 4425c9d..b65c435 100644 --- a/apps/web/src/test/integration/_helpers/factories/agent.factory.ts +++ b/apps/web/src/test/integration/_helpers/factories/agent.factory.ts @@ -64,7 +64,10 @@ export function createAgentFactory(api: ApiClient, tracker: TestDataTracker) { }); if (!result.ok) { - throw new Error(`Failed to create agent: ${(result as { error: string }).error}`); + const errorResult = result as { error: string; status: number }; + throw new Error( + `Failed to create agent: ${errorResult.error} (status: ${errorResult.status})` + ); } const agent = result.data.data; diff --git a/apps/web/src/test/integration/_helpers/factories/collection.factory.ts b/apps/web/src/test/integration/_helpers/factories/collection.factory.ts index 68029b8..6ae9c88 100644 --- a/apps/web/src/test/integration/_helpers/factories/collection.factory.ts +++ b/apps/web/src/test/integration/_helpers/factories/collection.factory.ts @@ -53,7 +53,10 @@ export function createCollectionFactory(api: ApiClient, tracker: TestDataTracker ); if (!result.ok) { - throw new Error(`Failed to create collection: ${(result as { error: string }).error}`); + const errorResult = result as { error: string; status: number }; + throw new Error( + `Failed to create collection: ${errorResult.error} (status: ${errorResult.status})` + ); } const collection = result.data.data;