diff --git a/tests/e2e/auth-smoke.spec.ts b/tests/e2e/auth-smoke.spec.ts index d876caff..b62bdd44 100644 --- a/tests/e2e/auth-smoke.spec.ts +++ b/tests/e2e/auth-smoke.spec.ts @@ -18,9 +18,9 @@ async function createEventWithPhotos(page: Page, adminToken?: string, attempt = }, }); expect(loginResponse.ok()).toBeTruthy(); - const loginData = await loginResponse.json(); - token = loginData.token; - expect(token).toBeTruthy(); + const cookies = await page.context().cookies(); + token = cookies.find((c) => c.name === 'admin_token')?.value; + expect(token, 'admin_token cookie missing from the login response').toBeTruthy(); } const eventName = `Playwright Smoke ${Date.now()}`; diff --git a/tests/e2e/customer-portal-flow.spec.ts b/tests/e2e/customer-portal-flow.spec.ts index b50a3c96..f6f90381 100644 --- a/tests/e2e/customer-portal-flow.spec.ts +++ b/tests/e2e/customer-portal-flow.spec.ts @@ -40,9 +40,14 @@ async function adminLogin(page: Page): Promise { failOnStatusCode: false, }); expect(res.ok()).toBeTruthy(); - const json = await res.json(); - expect(json.token).toBeTruthy(); - return json.token; + // The admin JWT is delivered as the httpOnly `admin_token` cookie, not in + // the response body. Server-side the cookie and an Authorization: Bearer + // header are interchangeable, so read it back out of the context jar and + // keep threading it as a Bearer — every downstream call stays as it was. + const cookies = await page.context().cookies(); + const token = cookies.find((c) => c.name === 'admin_token')?.value; + expect(token, 'admin_token cookie missing from the login response').toBeTruthy(); + return token as string; } async function setCustomerPortalEnabled(page: Page, adminToken: string, enabled: boolean) { diff --git a/tests/e2e/optional-email-event-creation.spec.ts b/tests/e2e/optional-email-event-creation.spec.ts index 641a1bf2..56e018df 100644 --- a/tests/e2e/optional-email-event-creation.spec.ts +++ b/tests/e2e/optional-email-event-creation.spec.ts @@ -8,9 +8,14 @@ async function getAdminToken(page: Page): Promise { data: { username: ADMIN_EMAIL, password: ADMIN_PASSWORD }, }); expect(res.ok()).toBeTruthy(); - const body = await res.json(); - expect(body.token).toBeTruthy(); - return body.token; + // The admin JWT is delivered as the httpOnly `admin_token` cookie, not in + // the response body. Server-side the cookie and an Authorization: Bearer + // header are interchangeable, so read it back out of the context jar and + // keep threading it as a Bearer — every downstream call stays as it was. + const cookies = await page.context().cookies(); + const token = cookies.find((c) => c.name === 'admin_token')?.value; + expect(token, 'admin_token cookie missing from the login response').toBeTruthy(); + return token as string; } async function updateEventSettings(