feat: add organisations (#1820)

This commit is contained in:
David Nguyen
2025-06-10 11:49:52 +10:00
committed by GitHub
parent 0b37f19641
commit e6dc237ad2
631 changed files with 37616 additions and 25695 deletions

View File

@ -1,6 +1,6 @@
import { type Page, expect, test } from '@playwright/test';
import { alphaid } from '@documenso/lib/universal/id';
import { prisma } from '@documenso/prisma';
import {
extractUserVerificationToken,
seedTestEmail,
@ -23,17 +23,26 @@ test('[USER] can sign up with email and password', async ({ page }: { page: Page
await signSignaturePad(page);
await page.getByRole('button', { name: 'Next', exact: true }).click();
await page.getByLabel('Public profile username').fill(alphaid(10));
await page.getByLabel('Public profile username').blur();
await page.getByRole('button', { name: 'Complete' }).click();
await page.getByRole('button', { name: 'Complete', exact: true }).click();
await page.waitForURL('/unverified-account');
const { token } = await extractUserVerificationToken(email);
const team = await prisma.team.findFirstOrThrow({
where: {
organisation: {
members: {
some: {
user: {
email,
},
},
},
},
},
});
await page.goto(`/verify-email/${token}`);
await expect(page.getByRole('heading')).toContainText('Email Confirmed!');
@ -41,19 +50,19 @@ test('[USER] can sign up with email and password', async ({ page }: { page: Page
// We now automatically redirect to the home page
await page.getByRole('link', { name: 'Continue' }).click();
await page.waitForURL('/documents');
await expect(page).toHaveURL('/documents');
// Expect to be redirected to their only team.
await page.waitForURL(`/t/${team.url}/documents`);
await expect(page).toHaveURL(`/t/${team.url}/documents`);
});
test('[USER] can sign in using email and password', async ({ page }: { page: Page }) => {
const user = await seedUser();
const { user, team } = await seedUser();
await page.goto('/signin');
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');
await page.waitForURL(`/t/${team.url}/documents`);
await expect(page).toHaveURL(`/t/${team.url}/documents`);
});

View File

@ -7,7 +7,7 @@ import { seedUser } from '@documenso/prisma/seed/users';
import { apiSignin } from '../fixtures/authentication';
test('[USER] delete account', async ({ page }) => {
const user = await seedUser();
const { user } = await seedUser();
await apiSignin({ page, email: user.email, redirectPath: '/settings' });

View File

@ -11,7 +11,7 @@ test('[USER] can reset password via forgot password', async ({ page }: { page: P
const oldPassword = 'Test123!';
const newPassword = 'Test124!';
const user = await seedUser({
const { user } = await seedUser({
password: oldPassword,
});
@ -51,17 +51,18 @@ test('[USER] can reset password via forgot password', async ({ page }: { page: P
page,
email: user.email,
password: newPassword,
redirectPath: '/settings/profile',
});
await page.waitForURL('/documents');
await expect(page).toHaveURL('/documents');
await page.waitForURL('/settings/profile');
await expect(page).toHaveURL('/settings/profile');
});
test('[USER] can reset password via user settings', async ({ page }: { page: Page }) => {
const oldPassword = 'Test123!';
const newPassword = 'Test124!';
const user = await seedUser({
const { user } = await seedUser({
password: oldPassword,
});
@ -87,8 +88,9 @@ test('[USER] can reset password via user settings', async ({ page }: { page: Pag
page,
email: user.email,
password: newPassword,
redirectPath: '/settings/profile',
});
await page.waitForURL('/documents');
await expect(page).toHaveURL('/documents');
await page.waitForURL('/settings/profile');
await expect(page).toHaveURL('/settings/profile');
});

View File

@ -7,7 +7,7 @@ import { apiSignin } from '../fixtures/authentication';
import { signSignaturePad } from '../fixtures/signature';
test('[USER] update full name', async ({ page }) => {
const user = await seedUser();
const { user } = await seedUser();
await apiSignin({ page, email: user.email, redirectPath: '/settings/profile' });