chore: changes

This commit is contained in:
pit
2023-10-05 11:38:51 +03:00
parent 64dcd451e9
commit a3dce67117
5 changed files with 37 additions and 56 deletions

View File

@ -39,9 +39,9 @@ jobs:
- name: Install Prisma Client
run: npm install @prisma/client
- name: Generate Prisma Client
run: npx prisma generate --schema packages/prisma/schema.prisma
run: npm run prisma:generate -w @documenso/prisma
- name: Create the database
run: npx prisma migrate dev --schema packages/prisma/schema.prisma
run: npm run prisma:migrate-dev -w @documenso/prisma
- name: Run Playwright tests
run: npm run ci
- uses: actions/upload-artifact@v3

View File

@ -1,41 +0,0 @@
import { prisma } from '@documenso/prisma';
export const deleteUserAndItsData = async (name: string) => {
const user = await prisma.user.findFirst({
where: {
name: {
contains: name,
},
},
});
if (!user) {
throw new Error(`User with name ${name} not found`);
}
const document = await prisma.document.findMany({
where: {
userId: user.id,
},
select: {
documentData: {
select: {
data: true,
},
},
},
});
return prisma.$transaction([
prisma.user.delete({
where: {
id: user.id,
},
}),
prisma.documentData.deleteMany({
where: {
data: document[0]?.documentData.data,
},
}),
]);
};

View File

@ -0,0 +1,21 @@
import { prisma } from '@documenso/prisma';
export const deleteUser = async (name: string) => {
const user = await prisma.user.findFirst({
where: {
name: {
contains: name,
},
},
});
if (!user) {
throw new Error(`User with name ${name} not found`);
}
return await prisma.user.delete({
where: {
id: user.id,
},
});
};

View File

@ -1,5 +1,6 @@
generator client {
provider = "prisma-client-js"
output = "../../node_modules/.prisma/client"
}
datasource db {

View File

@ -1,6 +1,6 @@
import { type Page, expect, test } from '@playwright/test';
import { deleteUserAndItsData } from '@documenso/lib/server-only/user/delete-user-and-data';
import { deleteUser } from '@documenso/lib/server-only/user/delete-user';
test.use({ storageState: { cookies: [], origins: [] } });
@ -10,9 +10,9 @@ test.use({ storageState: { cookies: [], origins: [] } });
*/
test.describe.configure({ mode: 'serial' });
const username = E2E_TEST_AUTHENTICATE_USERNAME;
const email = E2E_TEST_AUTHENTICATE_USER_EMAIL;
const password = E2E_TEST_AUTHENTICATE_USER_PASSWORD;
const username = 'testuser';
const email = 'test-user@documenso.com';
const password = 'password';
test('user can sign up with email and password', async ({ page }: { page: Page }) => {
await page.goto('/signup');
@ -48,7 +48,7 @@ test('user can login with user and password', async ({ page }: { page: Page }) =
test.afterAll('Teardown', async () => {
try {
await deleteUserAndItsData(username);
await deleteUser(username);
} catch (e) {
throw new Error(`Error deleting user: ${e}`);
}