diff --git a/packages/e2e/smoke-tests/homepage.spec.ts b/packages/e2e/smoke-tests/homepage.spec.ts index 8e1ac488..f58352a6 100644 --- a/packages/e2e/smoke-tests/homepage.spec.ts +++ b/packages/e2e/smoke-tests/homepage.spec.ts @@ -1,14 +1,16 @@ import { expect, test } from 'test' test.describe('Homepage', () => { - test.beforeEach(async ({ page }) => { - await page.goto('/') - }) + test.describe('when logged out', () => { + test.beforeEach(async ({ page }) => { + await page.goto('/') + }) - test('basic content', async ({ page }) => { - await expect(page.getByRole('heading', { level: 1 })).toHaveText( - "The cookbook industry's new digital home." - ) + test('basic content', async ({ page }) => { + await expect(page.getByRole('heading', { level: 1 })).toHaveText( + "The cookbook industry's new digital home." + ) + }) }) test.describe('when logged in', () => { diff --git a/packages/e2e/test.ts b/packages/e2e/test.ts index 0fe9a2a8..9dc3715b 100644 --- a/packages/e2e/test.ts +++ b/packages/e2e/test.ts @@ -2,10 +2,19 @@ import { encode } from '@auth/core/jwt' import prisma from '@books-about-food/database' import { BrowserContext, Page, test as base } from '@playwright/test' -const helpers = ({ context }: { page: Page; context: BrowserContext }) => ({ +const helpers = ({ + context, + page +}: { + page: Page + context: BrowserContext +}) => ({ async login() { + await page.goto('/', { waitUntil: 'commit' }) const cookies = await context.cookies() - const authCookie = cookies.find((cookie) => cookie.name.includes('authjs')) + const authCookie = cookies.find( + ({ name }) => name.includes('authjs') && name.endsWith('callback-url') + ) if (!authCookie) throw new Error('No auth cookie found') const prefix = authCookie.name.split('.')[0]