From 4392cb0a23937000419a88011f5388462b727263 Mon Sep 17 00:00:00 2001 From: Sean Brydon Date: Tue, 19 Sep 2023 16:12:53 +0100 Subject: [PATCH] Fix token cleanup --- apps/web/playwright/signup.e2e.ts | 37 ++++++++++++++++--------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/apps/web/playwright/signup.e2e.ts b/apps/web/playwright/signup.e2e.ts index 5b8a9b9d54..558c2f4e21 100644 --- a/apps/web/playwright/signup.e2e.ts +++ b/apps/web/playwright/signup.e2e.ts @@ -18,6 +18,25 @@ test.describe("Signup Flow Test", async () => { await users.deleteByEmail("rick@example.com"); await users.deleteByEmail("rick-jones@example.com"); }); + test.afterEach(async ({ users }) => { + // Clean up the user and token + await prisma.user.deleteMany({ + where: { + email: "rick-team@example.com", + }, + }); + await prisma.verificationToken.deleteMany({ + where: { + identifier: "rick-team@example.com", + }, + }); + + await prisma.team.deleteMany({ + where: { + name: "Rick's Team", + }, + }); + }); test("Username is taken", async ({ page, users }) => { // log in trail user await test.step("Sign up", async () => { @@ -172,23 +191,5 @@ test.describe("Signup Flow Test", async () => { expect(await usernameField.inputValue()).toBe("rick-team"); expect(await emailField.inputValue()).toBe("rick-team@example.com"); - - // Clean up the user and token - await prisma.user.delete({ - where: { - id: rickTeamUser.id, - }, - }); - await prisma.verificationToken.delete({ - where: { - id: createdtoken.id, - }, - }); - - await prisma.team.delete({ - where: { - id: createdtoken.teamId ?? -1, - }, - }); }); });