mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
chore: changes
This commit is contained in:
4
.github/workflows/e2e-tests.yml
vendored
4
.github/workflows/e2e-tests.yml
vendored
@ -39,9 +39,9 @@ jobs:
|
|||||||
- name: Install Prisma Client
|
- name: Install Prisma Client
|
||||||
run: npm install @prisma/client
|
run: npm install @prisma/client
|
||||||
- name: Generate 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
|
- 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
|
- name: Run Playwright tests
|
||||||
run: npm run ci
|
run: npm run ci
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
|
|||||||
@ -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,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
21
packages/lib/server-only/user/delete-user.ts
Normal file
21
packages/lib/server-only/user/delete-user.ts
Normal 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,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
@ -1,5 +1,6 @@
|
|||||||
generator client {
|
generator client {
|
||||||
provider = "prisma-client-js"
|
provider = "prisma-client-js"
|
||||||
|
output = "../../node_modules/.prisma/client"
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
@ -110,10 +111,10 @@ model Document {
|
|||||||
Field Field[]
|
Field Field[]
|
||||||
ShareLink DocumentShareLink[]
|
ShareLink DocumentShareLink[]
|
||||||
documentDataId String
|
documentDataId String
|
||||||
documentData DocumentData @relation(fields: [documentDataId], references: [id], onDelete: Cascade)
|
documentData DocumentData @relation(fields: [documentDataId], references: [id], onDelete: Cascade)
|
||||||
documentMeta DocumentMeta?
|
documentMeta DocumentMeta?
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @default(now()) @updatedAt
|
updatedAt DateTime @default(now()) @updatedAt
|
||||||
|
|
||||||
@@unique([documentDataId])
|
@@unique([documentDataId])
|
||||||
}
|
}
|
||||||
@ -133,11 +134,11 @@ model DocumentData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model DocumentMeta {
|
model DocumentMeta {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
subject String?
|
subject String?
|
||||||
message String?
|
message String?
|
||||||
documentId Int @unique
|
documentId Int @unique
|
||||||
document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)
|
document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ReadStatus {
|
enum ReadStatus {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { type Page, expect, test } from '@playwright/test';
|
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: [] } });
|
test.use({ storageState: { cookies: [], origins: [] } });
|
||||||
|
|
||||||
@ -10,9 +10,9 @@ test.use({ storageState: { cookies: [], origins: [] } });
|
|||||||
*/
|
*/
|
||||||
test.describe.configure({ mode: 'serial' });
|
test.describe.configure({ mode: 'serial' });
|
||||||
|
|
||||||
const username = E2E_TEST_AUTHENTICATE_USERNAME;
|
const username = 'testuser';
|
||||||
const email = E2E_TEST_AUTHENTICATE_USER_EMAIL;
|
const email = 'test-user@documenso.com';
|
||||||
const password = E2E_TEST_AUTHENTICATE_USER_PASSWORD;
|
const password = 'password';
|
||||||
|
|
||||||
test('user can sign up with email and password', async ({ page }: { page: Page }) => {
|
test('user can sign up with email and password', async ({ page }: { page: Page }) => {
|
||||||
await page.goto('/signup');
|
await page.goto('/signup');
|
||||||
@ -48,7 +48,7 @@ test('user can login with user and password', async ({ page }: { page: Page }) =
|
|||||||
|
|
||||||
test.afterAll('Teardown', async () => {
|
test.afterAll('Teardown', async () => {
|
||||||
try {
|
try {
|
||||||
await deleteUserAndItsData(username);
|
await deleteUser(username);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(`Error deleting user: ${e}`);
|
throw new Error(`Error deleting user: ${e}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user