diff --git a/apps/web/src/tests/e2e/auth.setup.ts b/apps/web/src/tests/e2e/auth.setup.ts index d0be72abb..eef5bd67f 100644 --- a/apps/web/src/tests/e2e/auth.setup.ts +++ b/apps/web/src/tests/e2e/auth.setup.ts @@ -2,10 +2,31 @@ import { type Page, expect, test as setup } from '@playwright/test'; import { STORAGE_STATE } from '../../../../../playwright.config'; +const username = process.env.E2E_TEST_USERNAME || ''; +const email = process.env.E2E_TEST_USER_EMAIL || ''; +const password = process.env.E2E_TEST_USER_PASSWORD || ''; + setup('authenticate', async ({ page }: { page: Page }) => { + await page.goto('/signup'); + await page.getByLabel('Name').fill(username); + await page.getByLabel('Email').fill(email); + await page.getByLabel('Password').fill(password); + + const canvas = page.locator('canvas'); + const box = await canvas.boundingBox(); + + if (box) { + await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2); + await page.mouse.down(); + await page.mouse.move(box.x + box.width / 4, box.y + box.height / 4); + await page.mouse.up(); + } + + await page.getByRole('button', { name: 'Sign Up' }).click(); + await page.goto('/'); - await page.getByLabel('Email').fill('example@documenso.com'); - await page.getByLabel('Password').fill('123456'); + await page.getByLabel('Email').fill(email); + await page.getByLabel('Password').fill(password); await page.getByRole('button', { name: 'Sign In' }).click(); await page.waitForURL('/documents'); await expect(page).toHaveURL('/documents'); diff --git a/apps/web/src/tests/e2e/test-auth-flow.unauthenticated.spec.ts b/apps/web/src/tests/e2e/test-auth-flow.unauthenticated.spec.ts index 53a7e1815..cdceda253 100644 --- a/apps/web/src/tests/e2e/test-auth-flow.unauthenticated.spec.ts +++ b/apps/web/src/tests/e2e/test-auth-flow.unauthenticated.spec.ts @@ -2,11 +2,21 @@ import { type Page, expect, test } from '@playwright/test'; test.use({ storageState: { cookies: [], origins: [] } }); +/* + Using them sequentially so the 2nd test + uses the details from the 1st (registration) test +*/ +test.describe.configure({ mode: 'serial' }); + +const username = process.env.E2E_TEST_USERNAME || ''; +const email = process.env.E2E_TEST_USER_EMAIL || ''; +const password = process.env.E2E_TEST_USER_PASSWORD || ''; + test('user can sign up with email and password', async ({ page }: { page: Page }) => { await page.goto('/signup'); - await page.getByLabel('Name').fill(process.env.E2E_TEST_USERNAME); - await page.getByLabel('Email').fill(process.env.E2E_TEST_USER_EMAIL); - await page.getByLabel('Password').fill(process.env.E2E_TEST_USER_PASSWORD); + await page.getByLabel('Name').fill(username); + await page.getByLabel('Email').fill(email); + await page.getByLabel('Password').fill(password); const canvas = page.locator('canvas'); const box = await canvas.boundingBox(); @@ -23,8 +33,8 @@ test('user can sign up with email and password', async ({ page }: { page: Page } test('user can login with user and password', async ({ page }: { page: Page }) => { await page.goto('/signin'); - await page.getByLabel('Email').fill(process.env.E2E_TEST_USER_EMAIL); - await page.getByLabel('Password').fill(process.env.E2E_TEST_USER_PASSWORD); + await page.getByLabel('Email').fill(email); + await page.getByLabel('Password').fill(password); await page.getByRole('button', { name: 'Sign In' }).click(); await expect(page).toHaveURL('/documents'); diff --git a/turbo.json b/turbo.json index f7d3d342c..b93b071ea 100644 --- a/turbo.json +++ b/turbo.json @@ -2,13 +2,8 @@ "$schema": "https://turbo.build/schema.json", "pipeline": { "build": { - "dependsOn": [ - "^build" - ], - "outputs": [ - ".next/**", - "!.next/cache/**" - ] + "dependsOn": ["^build"], + "outputs": [".next/**", "!.next/cache/**"] }, "lint": {}, "dev": { @@ -16,10 +11,11 @@ "persistent": true } }, - "globalDependencies": [ - "**/.env.*local" - ], + "globalDependencies": ["**/.env.*local"], "globalEnv": [ + "E2E_TEST_USERNAME", + "E2E_TEST_USER_EMAIL", + "E2E_TEST_USER_PASSWORD", "NEXTAUTH_URL", "NEXTAUTH_SECRET", "NEXT_PUBLIC_APP_URL",