The Open Source DocuSign Alternative.
TypeScript digital-signaturedocument-signingdocusign-alternativee-signatureesignesignaturenext-authnextjsopen-sourcepades-standardpdfpdf-signpdf-signaturepostgresqlprismaself-hostedsigningtypescript
fix: e2e tests
David Nguyena58fee2da65c
diff --git a/packages/app-tests/e2e/pr-713-add-document-search-to-command-menu.spec.ts b/packages/app-tests/e2e/pr-713-add-document-search-to-command-menu.spec.tsindex 160113f95..44cfe1e37 100644--- a/packages/app-tests/e2e/pr-713-add-document-search-to-command-menu.spec.ts+++ b/packages/app-tests/e2e/pr-713-add-document-search-to-command-menu.spec.ts@@ -15,7 +15,7 @@ test('[PR-713]: should see sent documents', async ({ page }) => {await page.keyboard.press('Meta+K');- await page.getByPlaceholder('Type a command or search...').fill('sent');+ await page.getByPlaceholder('Type a command or search...').first().fill('sent');await expect(page.getByRole('option', { name: '[713] Document - Sent' })).toBeVisible();});@@ -32,7 +32,7 @@ test('[PR-713]: should see received documents', async ({ page }) => {await page.keyboard.press('Meta+K');- await page.getByPlaceholder('Type a command or search...').fill('received');+ await page.getByPlaceholder('Type a command or search...').first().fill('received');await expect(page.getByRole('option', { name: '[713] Document - Received' })).toBeVisible();});@@ -49,6 +49,6 @@ test('[PR-713]: should be able to search by recipient', async ({ page }) => {await page.keyboard.press('Meta+K');- await page.getByPlaceholder('Type a command or search...').fill(recipient.email);+ await page.getByPlaceholder('Type a command or search...').first().fill(recipient.email);await expect(page.getByRole('option', { name: '[713] Document - Sent' })).toBeVisible();});diff --git a/packages/app-tests/e2e/test-auth-flow.spec.ts b/packages/app-tests/e2e/test-auth-flow.spec.tsindex 40ee5e768..57c25bb26 100644--- a/packages/app-tests/e2e/test-auth-flow.spec.ts+++ b/packages/app-tests/e2e/test-auth-flow.spec.ts@@ -1,20 +1,19 @@import { type Page, expect, test } from '@playwright/test';-import { deleteUser } from '@documenso/lib/server-only/user/delete-user';+import {+ extractUserVerificationToken,+ seedUser,+ unseedUser,+ unseedUserByEmail,+} from '@documenso/prisma/seed/users';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 = 'Test User';-const email = '[email protected]';-const password = 'Password123#';-test('user can sign up with email and password', async ({ page }: { page: Page }) => {+ const username = 'Test User';+ const email = `test-user-${Date.now()}@auth-flow.documenso.com`;+ const password = 'Password123#';+await page.goto('/signup');await page.getByLabel('Name').fill(username);await page.getByLabel('Email').fill(email);@@ -31,25 +30,33 @@ test('user can sign up with email and password', async ({ page }: { page: Page }}await page.getByRole('button', { name: 'Sign Up', exact: true }).click();++ await page.waitForURL('/unverified-account');++ const { token } = await extractUserVerificationToken(email);++ await page.goto(`/verify-email/${token}`);++ await expect(page.getByRole('heading')).toContainText('Email Confirmed!');++ await page.getByRole('link', { name: 'Go back home' }).click();+await page.waitForURL('/documents');await expect(page).toHaveURL('/documents');+ await unseedUserByEmail(email);});test('user can login with user and password', async ({ page }: { page: Page }) => {+ const user = await seedUser();+await page.goto('/signin');- await page.getByLabel('Email').fill(email);- await page.getByLabel('Password', { exact: true }).fill(password);+ await page.getByLabel('Email').fill(user.email);+ await page.getByLabel('Password', { exact: true }).fill('password');await page.getByRole('button', { name: 'Sign In' }).click();await page.waitForURL('/documents');await expect(page).toHaveURL('/documents');-});-test.afterAll('Teardown', async () => {- try {- await deleteUser({ email });- } catch (e) {- throw new Error(`Error deleting user: ${e}`);- }+ await unseedUser(user.id);});diff --git a/packages/prisma/seed/users.ts b/packages/prisma/seed/users.tsindex ce3858bc6..f4dd714ed 100644--- a/packages/prisma/seed/users.ts+++ b/packages/prisma/seed/users.ts@@ -32,3 +32,22 @@ export const unseedUser = async (userId: number) => {},});};++export const unseedUserByEmail = async (email: string) => {+ await prisma.user.delete({+ where: {+ email,+ },+ });+};++export const extractUserVerificationToken = async (email: string) => {+ return await prisma.verificationToken.findFirstOrThrow({+ where: {+ identifier: 'confirmation-email',+ user: {+ email,+ },+ },+ });+};