mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
chore: add initial tests
This commit is contained in:
74
packages/app-tests/e2e/document-flow/settings-step.spec.ts
Normal file
74
packages/app-tests/e2e/document-flow/settings-step.spec.ts
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
import { expect, test } from '@playwright/test';
|
||||||
|
|
||||||
|
import {
|
||||||
|
seedBlankDocument,
|
||||||
|
seedDraftDocument,
|
||||||
|
seedPendingDocument,
|
||||||
|
} from '@documenso/prisma/seed/documents';
|
||||||
|
import { seedUser, unseedUser } from '@documenso/prisma/seed/users';
|
||||||
|
|
||||||
|
import { apiSignin } from '../fixtures/authentication';
|
||||||
|
|
||||||
|
test.describe.configure({ mode: 'parallel' });
|
||||||
|
|
||||||
|
test('[DOCUMENT_FLOW]: add settings', async ({ page }) => {
|
||||||
|
const user = await seedUser();
|
||||||
|
const document = await seedBlankDocument(user);
|
||||||
|
|
||||||
|
await apiSignin({
|
||||||
|
page,
|
||||||
|
email: user.email,
|
||||||
|
redirectPath: `/documents/${document.id}/edit`,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Set title.
|
||||||
|
await page.getByLabel('Title').fill('New Title');
|
||||||
|
|
||||||
|
// Set access auth.
|
||||||
|
await page.getByTestId('documentAccessSelectValue').click();
|
||||||
|
await page.getByLabel('Require account').getByText('Require account').click();
|
||||||
|
await expect(page.getByTestId('documentAccessSelectValue')).toContainText('Require account');
|
||||||
|
|
||||||
|
// Set action auth.
|
||||||
|
await page.getByTestId('documentActionSelectValue').click();
|
||||||
|
await page.getByLabel('Require account').getByText('Require account').click();
|
||||||
|
await expect(page.getByTestId('documentActionSelectValue')).toContainText('Require account');
|
||||||
|
|
||||||
|
// Save the settings by going to the next step.
|
||||||
|
await page.getByRole('button', { name: 'Continue' }).click();
|
||||||
|
await expect(page.getByRole('heading', { name: 'Add Signers' })).toBeVisible();
|
||||||
|
|
||||||
|
// Return to the settings step to check that the results are saved correctly.
|
||||||
|
await page.getByRole('button', { name: 'Go Back' }).click();
|
||||||
|
await expect(page.getByRole('heading', { name: 'General' })).toBeVisible();
|
||||||
|
|
||||||
|
// Todo: Verify that the values are correct once we fix the issue where going back
|
||||||
|
// does not show the updated values.
|
||||||
|
// await expect(page.getByLabel('Title')).toContainText('New Title');
|
||||||
|
// await expect(page.getByTestId('documentAccessSelectValue')).toContainText('Require account');
|
||||||
|
// await expect(page.getByTestId('documentActionSelectValue')).toContainText('Require account');
|
||||||
|
|
||||||
|
await unseedUser(user.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('[DOCUMENT_FLOW]: title should be disabled depending on document status', async ({ page }) => {
|
||||||
|
const user = await seedUser();
|
||||||
|
|
||||||
|
const pendingDocument = await seedPendingDocument(user, []);
|
||||||
|
const draftDocument = await seedDraftDocument(user, []);
|
||||||
|
|
||||||
|
await apiSignin({
|
||||||
|
page,
|
||||||
|
email: user.email,
|
||||||
|
redirectPath: `/documents/${pendingDocument.id}/edit`,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Should be disabled for pending documents.
|
||||||
|
await expect(page.getByLabel('Title')).toBeDisabled();
|
||||||
|
|
||||||
|
// Should be enabled for draft documents.
|
||||||
|
await page.goto(`/documents/${draftDocument.id}/edit`);
|
||||||
|
await expect(page.getByLabel('Title')).toBeEnabled();
|
||||||
|
|
||||||
|
await unseedUser(user.id);
|
||||||
|
});
|
||||||
63
packages/app-tests/e2e/document-flow/signers-step.spec.ts
Normal file
63
packages/app-tests/e2e/document-flow/signers-step.spec.ts
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import { expect, test } from '@playwright/test';
|
||||||
|
|
||||||
|
import { seedBlankDocument } from '@documenso/prisma/seed/documents';
|
||||||
|
import { seedUser, unseedUser } from '@documenso/prisma/seed/users';
|
||||||
|
|
||||||
|
import { apiSignin } from '../fixtures/authentication';
|
||||||
|
|
||||||
|
test.describe.configure({ mode: 'parallel' });
|
||||||
|
|
||||||
|
// Note: Not complete yet due to issue with back button.
|
||||||
|
test('[DOCUMENT_FLOW]: add signers', async ({ page }) => {
|
||||||
|
const user = await seedUser();
|
||||||
|
const document = await seedBlankDocument(user);
|
||||||
|
|
||||||
|
await apiSignin({
|
||||||
|
page,
|
||||||
|
email: user.email,
|
||||||
|
redirectPath: `/documents/${document.id}/edit`,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Save the settings by going to the next step.
|
||||||
|
await page.getByRole('button', { name: 'Continue' }).click();
|
||||||
|
await expect(page.getByRole('heading', { name: 'Add Signers' })).toBeVisible();
|
||||||
|
|
||||||
|
// Add 2 signers.
|
||||||
|
await page.getByPlaceholder('Email').fill('recipient1@documenso.com');
|
||||||
|
await page.getByPlaceholder('Name').fill('Recipient 1');
|
||||||
|
await page.getByRole('button', { name: 'Add Signer' }).click();
|
||||||
|
await page.getByRole('textbox', { name: 'Email', exact: true }).fill('recipient2@documenso.com');
|
||||||
|
await page.getByRole('textbox', { name: 'Name', exact: true }).fill('Recipient 2');
|
||||||
|
|
||||||
|
// Display advanced settings.
|
||||||
|
await page.getByLabel('Show advanced settings').click();
|
||||||
|
|
||||||
|
// Navigate to the next step and back.
|
||||||
|
await page.getByRole('button', { name: 'Continue' }).click();
|
||||||
|
await expect(page.getByRole('heading', { name: 'Add Fields' })).toBeVisible();
|
||||||
|
await page.getByRole('button', { name: 'Go Back' }).click();
|
||||||
|
await expect(page.getByRole('heading', { name: 'Add Signers' })).toBeVisible();
|
||||||
|
|
||||||
|
// Todo: Fix stepper component back issue before finishing test.
|
||||||
|
|
||||||
|
// // Expect that the advanced settings is unchecked, since no advanced settings were applied.
|
||||||
|
// await expect(page.getByLabel('Show advanced settings')).toBeChecked({ checked: false });
|
||||||
|
|
||||||
|
// // Add advanced settings for a single recipient.
|
||||||
|
// await page.getByLabel('Show advanced settings').click();
|
||||||
|
// await page.getByRole('combobox').first().click();
|
||||||
|
// await page.getByLabel('Require account').click();
|
||||||
|
|
||||||
|
// // Navigate to the next step and back.
|
||||||
|
// await page.getByRole('button', { name: 'Continue' }).click();
|
||||||
|
// await expect(page.getByRole('heading', { name: 'Add Fields' })).toBeVisible();
|
||||||
|
// await page.getByRole('button', { name: 'Go Back' }).click();
|
||||||
|
// await expect(page.getByRole('heading', { name: 'Add Signers' })).toBeVisible();
|
||||||
|
|
||||||
|
// Expect that the advanced settings is visible, and the checkbox is hidden. Since advanced
|
||||||
|
// settings were applied.
|
||||||
|
|
||||||
|
// Todo: Fix stepper component back issue before finishing test.
|
||||||
|
|
||||||
|
await unseedUser(user.id);
|
||||||
|
});
|
||||||
@ -1,8 +1,8 @@
|
|||||||
import type { Page } from '@playwright/test';
|
import { type Page } from '@playwright/test';
|
||||||
|
|
||||||
import { WEBAPP_BASE_URL } from '@documenso/lib/constants/app';
|
import { WEBAPP_BASE_URL } from '@documenso/lib/constants/app';
|
||||||
|
|
||||||
type ManualLoginOptions = {
|
type LoginOptions = {
|
||||||
page: Page;
|
page: Page;
|
||||||
email?: string;
|
email?: string;
|
||||||
password?: string;
|
password?: string;
|
||||||
@ -18,7 +18,7 @@ export const manualLogin = async ({
|
|||||||
email = 'example@documenso.com',
|
email = 'example@documenso.com',
|
||||||
password = 'password',
|
password = 'password',
|
||||||
redirectPath,
|
redirectPath,
|
||||||
}: ManualLoginOptions) => {
|
}: LoginOptions) => {
|
||||||
await page.goto(`${WEBAPP_BASE_URL}/signin`);
|
await page.goto(`${WEBAPP_BASE_URL}/signin`);
|
||||||
|
|
||||||
await page.getByLabel('Email').click();
|
await page.getByLabel('Email').click();
|
||||||
@ -33,9 +33,63 @@ export const manualLogin = async ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const manualSignout = async ({ page }: ManualLoginOptions) => {
|
export const manualSignout = async ({ page }: LoginOptions) => {
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
await page.getByTestId('menu-switcher').click();
|
await page.getByTestId('menu-switcher').click();
|
||||||
await page.getByRole('menuitem', { name: 'Sign Out' }).click();
|
await page.getByRole('menuitem', { name: 'Sign Out' }).click();
|
||||||
await page.waitForURL(`${WEBAPP_BASE_URL}/signin`);
|
await page.waitForURL(`${WEBAPP_BASE_URL}/signin`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const apiSignin = async ({
|
||||||
|
page,
|
||||||
|
email = 'example@documenso.com',
|
||||||
|
password = 'password',
|
||||||
|
redirectPath,
|
||||||
|
}: LoginOptions) => {
|
||||||
|
const { request } = page.context();
|
||||||
|
|
||||||
|
const csrfToken = await getCsrfToken(page);
|
||||||
|
|
||||||
|
await request.post(`${WEBAPP_BASE_URL}/api/auth/callback/credentials`, {
|
||||||
|
form: {
|
||||||
|
email,
|
||||||
|
password,
|
||||||
|
json: true,
|
||||||
|
csrfToken,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (redirectPath) {
|
||||||
|
await page.goto(`${WEBAPP_BASE_URL}${redirectPath}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const apiSignout = async ({ page }: { page: Page }) => {
|
||||||
|
const { request } = page.context();
|
||||||
|
|
||||||
|
const csrfToken = await getCsrfToken(page);
|
||||||
|
|
||||||
|
await request.post(`${WEBAPP_BASE_URL}/api/auth/signout`, {
|
||||||
|
form: {
|
||||||
|
csrfToken,
|
||||||
|
json: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.goto(`${WEBAPP_BASE_URL}/signin`);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getCsrfToken = async (page: Page) => {
|
||||||
|
const { request } = page.context();
|
||||||
|
|
||||||
|
const response = await request.fetch(`${WEBAPP_BASE_URL}/api/auth/csrf`, {
|
||||||
|
method: 'get',
|
||||||
|
});
|
||||||
|
|
||||||
|
const { csrfToken } = await response.json();
|
||||||
|
if (!csrfToken) {
|
||||||
|
throw new Error('Invalid session');
|
||||||
|
}
|
||||||
|
|
||||||
|
return csrfToken;
|
||||||
|
};
|
||||||
|
|||||||
@ -28,8 +28,8 @@ test(`[PR-718]: should be able to create a document`, async ({ page }) => {
|
|||||||
// Wait to be redirected to the edit page
|
// Wait to be redirected to the edit page
|
||||||
await page.waitForURL(/\/documents\/\d+/);
|
await page.waitForURL(/\/documents\/\d+/);
|
||||||
|
|
||||||
// Set title
|
// Set general settings
|
||||||
await expect(page.getByRole('heading', { name: 'Add Title' })).toBeVisible();
|
await expect(page.getByRole('heading', { name: 'General' })).toBeVisible();
|
||||||
|
|
||||||
await page.getByLabel('Title').fill(documentTitle);
|
await page.getByLabel('Title').fill(documentTitle);
|
||||||
|
|
||||||
|
|||||||
@ -4,14 +4,14 @@ import { WEBAPP_BASE_URL } from '@documenso/lib/constants/app';
|
|||||||
import { seedTeam, unseedTeam } from '@documenso/prisma/seed/teams';
|
import { seedTeam, unseedTeam } from '@documenso/prisma/seed/teams';
|
||||||
import { seedUser } from '@documenso/prisma/seed/users';
|
import { seedUser } from '@documenso/prisma/seed/users';
|
||||||
|
|
||||||
import { manualLogin } from '../fixtures/authentication';
|
import { apiSignin } from '../fixtures/authentication';
|
||||||
|
|
||||||
test.describe.configure({ mode: 'parallel' });
|
test.describe.configure({ mode: 'parallel' });
|
||||||
|
|
||||||
test('[TEAMS]: create team', async ({ page }) => {
|
test('[TEAMS]: create team', async ({ page }) => {
|
||||||
const user = await seedUser();
|
const user = await seedUser();
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
redirectPath: '/settings/teams',
|
redirectPath: '/settings/teams',
|
||||||
@ -38,7 +38,7 @@ test('[TEAMS]: create team', async ({ page }) => {
|
|||||||
test('[TEAMS]: delete team', async ({ page }) => {
|
test('[TEAMS]: delete team', async ({ page }) => {
|
||||||
const team = await seedTeam();
|
const team = await seedTeam();
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: team.owner.email,
|
email: team.owner.email,
|
||||||
redirectPath: `/t/${team.url}/settings`,
|
redirectPath: `/t/${team.url}/settings`,
|
||||||
@ -56,7 +56,7 @@ test('[TEAMS]: delete team', async ({ page }) => {
|
|||||||
test('[TEAMS]: update team', async ({ page }) => {
|
test('[TEAMS]: update team', async ({ page }) => {
|
||||||
const team = await seedTeam();
|
const team = await seedTeam();
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: team.owner.email,
|
email: team.owner.email,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { seedDocuments, seedTeamDocuments } from '@documenso/prisma/seed/documen
|
|||||||
import { seedTeamEmail, unseedTeam, unseedTeamEmail } from '@documenso/prisma/seed/teams';
|
import { seedTeamEmail, unseedTeam, unseedTeamEmail } from '@documenso/prisma/seed/teams';
|
||||||
import { seedUser } from '@documenso/prisma/seed/users';
|
import { seedUser } from '@documenso/prisma/seed/users';
|
||||||
|
|
||||||
import { manualLogin, manualSignout } from '../fixtures/authentication';
|
import { apiSignin, apiSignout } from '../fixtures/authentication';
|
||||||
|
|
||||||
test.describe.configure({ mode: 'parallel' });
|
test.describe.configure({ mode: 'parallel' });
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ test('[TEAMS]: check team documents count', async ({ page }) => {
|
|||||||
|
|
||||||
// Run the test twice, once with the team owner and once with a team member to ensure the counts are the same.
|
// Run the test twice, once with the team owner and once with a team member to ensure the counts are the same.
|
||||||
for (const user of [team.owner, teamMember2]) {
|
for (const user of [team.owner, teamMember2]) {
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
redirectPath: `/t/${team.url}/documents`,
|
redirectPath: `/t/${team.url}/documents`,
|
||||||
@ -55,7 +55,7 @@ test('[TEAMS]: check team documents count', async ({ page }) => {
|
|||||||
await checkDocumentTabCount(page, 'Draft', 1);
|
await checkDocumentTabCount(page, 'Draft', 1);
|
||||||
await checkDocumentTabCount(page, 'All', 3);
|
await checkDocumentTabCount(page, 'All', 3);
|
||||||
|
|
||||||
await manualSignout({ page });
|
await apiSignout({ page });
|
||||||
}
|
}
|
||||||
|
|
||||||
await unseedTeam(team.url);
|
await unseedTeam(team.url);
|
||||||
@ -126,7 +126,7 @@ test('[TEAMS]: check team documents count with internal team email', async ({ pa
|
|||||||
|
|
||||||
// Run the test twice, one with the team owner and once with the team member email to ensure the counts are the same.
|
// Run the test twice, one with the team owner and once with the team member email to ensure the counts are the same.
|
||||||
for (const user of [team.owner, teamEmailMember]) {
|
for (const user of [team.owner, teamEmailMember]) {
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
redirectPath: `/t/${team.url}/documents`,
|
redirectPath: `/t/${team.url}/documents`,
|
||||||
@ -151,7 +151,7 @@ test('[TEAMS]: check team documents count with internal team email', async ({ pa
|
|||||||
await checkDocumentTabCount(page, 'Draft', 1);
|
await checkDocumentTabCount(page, 'Draft', 1);
|
||||||
await checkDocumentTabCount(page, 'All', 3);
|
await checkDocumentTabCount(page, 'All', 3);
|
||||||
|
|
||||||
await manualSignout({ page });
|
await apiSignout({ page });
|
||||||
}
|
}
|
||||||
|
|
||||||
await unseedTeamEmail({ teamId: team.id });
|
await unseedTeamEmail({ teamId: team.id });
|
||||||
@ -216,7 +216,7 @@ test('[TEAMS]: check team documents count with external team email', async ({ pa
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: teamMember2.email,
|
email: teamMember2.email,
|
||||||
redirectPath: `/t/${team.url}/documents`,
|
redirectPath: `/t/${team.url}/documents`,
|
||||||
@ -248,7 +248,7 @@ test('[TEAMS]: check team documents count with external team email', async ({ pa
|
|||||||
test('[TEAMS]: delete pending team document', async ({ page }) => {
|
test('[TEAMS]: delete pending team document', async ({ page }) => {
|
||||||
const { team, teamMember2: currentUser } = await seedTeamDocuments();
|
const { team, teamMember2: currentUser } = await seedTeamDocuments();
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: currentUser.email,
|
email: currentUser.email,
|
||||||
redirectPath: `/t/${team.url}/documents?status=PENDING`,
|
redirectPath: `/t/${team.url}/documents?status=PENDING`,
|
||||||
@ -266,7 +266,7 @@ test('[TEAMS]: delete pending team document', async ({ page }) => {
|
|||||||
test('[TEAMS]: resend pending team document', async ({ page }) => {
|
test('[TEAMS]: resend pending team document', async ({ page }) => {
|
||||||
const { team, teamMember2: currentUser } = await seedTeamDocuments();
|
const { team, teamMember2: currentUser } = await seedTeamDocuments();
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: currentUser.email,
|
email: currentUser.email,
|
||||||
redirectPath: `/t/${team.url}/documents?status=PENDING`,
|
redirectPath: `/t/${team.url}/documents?status=PENDING`,
|
||||||
|
|||||||
@ -4,14 +4,14 @@ import { WEBAPP_BASE_URL } from '@documenso/lib/constants/app';
|
|||||||
import { seedTeam, seedTeamEmailVerification, unseedTeam } from '@documenso/prisma/seed/teams';
|
import { seedTeam, seedTeamEmailVerification, unseedTeam } from '@documenso/prisma/seed/teams';
|
||||||
import { seedUser, unseedUser } from '@documenso/prisma/seed/users';
|
import { seedUser, unseedUser } from '@documenso/prisma/seed/users';
|
||||||
|
|
||||||
import { manualLogin } from '../fixtures/authentication';
|
import { apiSignin } from '../fixtures/authentication';
|
||||||
|
|
||||||
test.describe.configure({ mode: 'parallel' });
|
test.describe.configure({ mode: 'parallel' });
|
||||||
|
|
||||||
test('[TEAMS]: send team email request', async ({ page }) => {
|
test('[TEAMS]: send team email request', async ({ page }) => {
|
||||||
const team = await seedTeam();
|
const team = await seedTeam();
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: team.owner.email,
|
email: team.owner.email,
|
||||||
password: 'password',
|
password: 'password',
|
||||||
@ -57,7 +57,7 @@ test('[TEAMS]: delete team email', async ({ page }) => {
|
|||||||
createTeamEmail: true,
|
createTeamEmail: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: team.owner.email,
|
email: team.owner.email,
|
||||||
redirectPath: `/t/${team.url}/settings`,
|
redirectPath: `/t/${team.url}/settings`,
|
||||||
@ -86,7 +86,7 @@ test('[TEAMS]: team email owner removes access', async ({ page }) => {
|
|||||||
email: team.teamEmail.email,
|
email: team.teamEmail.email,
|
||||||
});
|
});
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: teamEmailOwner.email,
|
email: teamEmailOwner.email,
|
||||||
redirectPath: `/settings/teams`,
|
redirectPath: `/settings/teams`,
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { WEBAPP_BASE_URL } from '@documenso/lib/constants/app';
|
|||||||
import { seedTeam, seedTeamInvite, unseedTeam } from '@documenso/prisma/seed/teams';
|
import { seedTeam, seedTeamInvite, unseedTeam } from '@documenso/prisma/seed/teams';
|
||||||
import { seedUser } from '@documenso/prisma/seed/users';
|
import { seedUser } from '@documenso/prisma/seed/users';
|
||||||
|
|
||||||
import { manualLogin } from '../fixtures/authentication';
|
import { apiSignin } from '../fixtures/authentication';
|
||||||
|
|
||||||
test.describe.configure({ mode: 'parallel' });
|
test.describe.configure({ mode: 'parallel' });
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ test('[TEAMS]: update team member role', async ({ page }) => {
|
|||||||
createTeamMembers: 1,
|
createTeamMembers: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: team.owner.email,
|
email: team.owner.email,
|
||||||
password: 'password',
|
password: 'password',
|
||||||
@ -75,7 +75,7 @@ test('[TEAMS]: member can leave team', async ({ page }) => {
|
|||||||
|
|
||||||
const teamMember = team.members[1];
|
const teamMember = team.members[1];
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: teamMember.user.email,
|
email: teamMember.user.email,
|
||||||
password: 'password',
|
password: 'password',
|
||||||
@ -97,7 +97,7 @@ test('[TEAMS]: owner cannot leave team', async ({ page }) => {
|
|||||||
createTeamMembers: 1,
|
createTeamMembers: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: team.owner.email,
|
email: team.owner.email,
|
||||||
password: 'password',
|
password: 'password',
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';
|
|||||||
import { WEBAPP_BASE_URL } from '@documenso/lib/constants/app';
|
import { WEBAPP_BASE_URL } from '@documenso/lib/constants/app';
|
||||||
import { seedTeam, seedTeamTransfer, unseedTeam } from '@documenso/prisma/seed/teams';
|
import { seedTeam, seedTeamTransfer, unseedTeam } from '@documenso/prisma/seed/teams';
|
||||||
|
|
||||||
import { manualLogin } from '../fixtures/authentication';
|
import { apiSignin } from '../fixtures/authentication';
|
||||||
|
|
||||||
test.describe.configure({ mode: 'parallel' });
|
test.describe.configure({ mode: 'parallel' });
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ test('[TEAMS]: initiate and cancel team transfer', async ({ page }) => {
|
|||||||
|
|
||||||
const teamMember = team.members[1];
|
const teamMember = team.members[1];
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: team.owner.email,
|
email: team.owner.email,
|
||||||
password: 'password',
|
password: 'password',
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { WEBAPP_BASE_URL } from '@documenso/lib/constants/app';
|
|||||||
import { seedTeam, unseedTeam } from '@documenso/prisma/seed/teams';
|
import { seedTeam, unseedTeam } from '@documenso/prisma/seed/teams';
|
||||||
import { seedTemplate } from '@documenso/prisma/seed/templates';
|
import { seedTemplate } from '@documenso/prisma/seed/templates';
|
||||||
|
|
||||||
import { manualLogin } from '../fixtures/authentication';
|
import { apiSignin } from '../fixtures/authentication';
|
||||||
|
|
||||||
test.describe.configure({ mode: 'parallel' });
|
test.describe.configure({ mode: 'parallel' });
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ test('[TEMPLATES]: view templates', async ({ page }) => {
|
|||||||
teamId: team.id,
|
teamId: team.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: owner.email,
|
email: owner.email,
|
||||||
redirectPath: '/templates',
|
redirectPath: '/templates',
|
||||||
@ -81,7 +81,7 @@ test('[TEMPLATES]: delete template', async ({ page }) => {
|
|||||||
teamId: team.id,
|
teamId: team.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: owner.email,
|
email: owner.email,
|
||||||
redirectPath: '/templates',
|
redirectPath: '/templates',
|
||||||
@ -135,7 +135,7 @@ test('[TEMPLATES]: duplicate template', async ({ page }) => {
|
|||||||
teamId: team.id,
|
teamId: team.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: owner.email,
|
email: owner.email,
|
||||||
redirectPath: '/templates',
|
redirectPath: '/templates',
|
||||||
@ -181,7 +181,7 @@ test('[TEMPLATES]: use template', async ({ page }) => {
|
|||||||
teamId: team.id,
|
teamId: team.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
await manualLogin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: owner.email,
|
email: owner.email,
|
||||||
redirectPath: '/templates',
|
redirectPath: '/templates',
|
||||||
|
|||||||
@ -33,19 +33,19 @@ export const seedDocuments = async (documents: DocumentToSeed[]) => {
|
|||||||
documents.map(async (document, i) =>
|
documents.map(async (document, i) =>
|
||||||
match(document.type)
|
match(document.type)
|
||||||
.with(DocumentStatus.DRAFT, async () =>
|
.with(DocumentStatus.DRAFT, async () =>
|
||||||
createDraftDocument(document.sender, document.recipients, {
|
seedDraftDocument(document.sender, document.recipients, {
|
||||||
key: i,
|
key: i,
|
||||||
createDocumentOptions: document.documentOptions,
|
createDocumentOptions: document.documentOptions,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.with(DocumentStatus.PENDING, async () =>
|
.with(DocumentStatus.PENDING, async () =>
|
||||||
createPendingDocument(document.sender, document.recipients, {
|
seedPendingDocument(document.sender, document.recipients, {
|
||||||
key: i,
|
key: i,
|
||||||
createDocumentOptions: document.documentOptions,
|
createDocumentOptions: document.documentOptions,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.with(DocumentStatus.COMPLETED, async () =>
|
.with(DocumentStatus.COMPLETED, async () =>
|
||||||
createCompletedDocument(document.sender, document.recipients, {
|
seedCompletedDocument(document.sender, document.recipients, {
|
||||||
key: i,
|
key: i,
|
||||||
createDocumentOptions: document.documentOptions,
|
createDocumentOptions: document.documentOptions,
|
||||||
}),
|
}),
|
||||||
@ -55,7 +55,37 @@ export const seedDocuments = async (documents: DocumentToSeed[]) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const createDraftDocument = async (
|
export const seedBlankDocument = async (owner: User, options: CreateDocumentOptions = {}) => {
|
||||||
|
const { key, createDocumentOptions = {} } = options;
|
||||||
|
|
||||||
|
const documentData = await prisma.documentData.create({
|
||||||
|
data: {
|
||||||
|
type: DocumentDataType.BYTES_64,
|
||||||
|
data: examplePdf,
|
||||||
|
initialData: examplePdf,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return await prisma.document.create({
|
||||||
|
data: {
|
||||||
|
title: `[TEST] Document ${key} - Draft`,
|
||||||
|
status: DocumentStatus.DRAFT,
|
||||||
|
documentDataId: documentData.id,
|
||||||
|
userId: owner.id,
|
||||||
|
...createDocumentOptions,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const unseedDocument = async (documentId: number) => {
|
||||||
|
await prisma.document.delete({
|
||||||
|
where: {
|
||||||
|
id: documentId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const seedDraftDocument = async (
|
||||||
sender: User,
|
sender: User,
|
||||||
recipients: (User | string)[],
|
recipients: (User | string)[],
|
||||||
options: CreateDocumentOptions = {},
|
options: CreateDocumentOptions = {},
|
||||||
@ -114,6 +144,8 @@ const createDraftDocument = async (
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return document;
|
||||||
};
|
};
|
||||||
|
|
||||||
type CreateDocumentOptions = {
|
type CreateDocumentOptions = {
|
||||||
@ -121,7 +153,7 @@ type CreateDocumentOptions = {
|
|||||||
createDocumentOptions?: Partial<Prisma.DocumentUncheckedCreateInput>;
|
createDocumentOptions?: Partial<Prisma.DocumentUncheckedCreateInput>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const createPendingDocument = async (
|
export const seedPendingDocument = async (
|
||||||
sender: User,
|
sender: User,
|
||||||
recipients: (User | string)[],
|
recipients: (User | string)[],
|
||||||
options: CreateDocumentOptions = {},
|
options: CreateDocumentOptions = {},
|
||||||
@ -180,9 +212,11 @@ const createPendingDocument = async (
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return document;
|
||||||
};
|
};
|
||||||
|
|
||||||
const createCompletedDocument = async (
|
export const seedCompletedDocument = async (
|
||||||
sender: User,
|
sender: User,
|
||||||
recipients: (User | string)[],
|
recipients: (User | string)[],
|
||||||
options: CreateDocumentOptions = {},
|
options: CreateDocumentOptions = {},
|
||||||
@ -241,6 +275,8 @@ const createCompletedDocument = async (
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return document;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -160,7 +160,7 @@ export const AddSettingsFormPartial = ({
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Select {...field} onValueChange={field.onChange}>
|
<Select {...field} onValueChange={field.onChange}>
|
||||||
<SelectTrigger className="bg-background text-muted-foreground">
|
<SelectTrigger className="bg-background text-muted-foreground">
|
||||||
<SelectValue placeholder="None" />
|
<SelectValue data-testid="documentAccessSelectValue" placeholder="None" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
|
|
||||||
<SelectContent position="popper">
|
<SelectContent position="popper">
|
||||||
@ -216,7 +216,7 @@ export const AddSettingsFormPartial = ({
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Select {...field} onValueChange={field.onChange}>
|
<Select {...field} onValueChange={field.onChange}>
|
||||||
<SelectTrigger className="bg-background text-muted-foreground">
|
<SelectTrigger className="bg-background text-muted-foreground">
|
||||||
<SelectValue placeholder="None" />
|
<SelectValue data-testid="documentActionSelectValue" placeholder="None" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
|
|
||||||
<SelectContent position="popper">
|
<SelectContent position="popper">
|
||||||
|
|||||||
Reference in New Issue
Block a user