From 372743433eb9b56951aee70c1fdd7d26ef50f69a Mon Sep 17 00:00:00 2001 From: Jessica Ho Date: Sun, 25 Feb 2024 05:40:15 +0000 Subject: [PATCH] fix profile test --- package.json | 2 +- prisma/seed.ts | 2 +- prisma/utils.ts | 29 ++++++++------ src/routes/profile/+page.svelte | 69 ++++++++++++++++++++------------- tests/profile.spec.ts | 24 ++++++++---- 5 files changed, 76 insertions(+), 50 deletions(-) diff --git a/package.json b/package.json index cfa8f36..6131627 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "build": "vite build", "nodebuild": "NODE_MODE_ADAPTER=1 vite build", "preview": "vite preview", - "test": "playwright test", + "test": "rm -f screenshot.png && playwright test", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "test:unit": "vitest", diff --git a/prisma/seed.ts b/prisma/seed.ts index 0f71430..23d8467 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -12,7 +12,7 @@ async function main() { ...[3, 4].map((userInd) => utils.createUserWithEmptyHousehold(userInd)), ...[2, 4, 6].map((userInd) => utils.createActiveSession(userInd)), utils.createUserWithEmptyHousehold(5), - utils.createUserWithKid(6) + utils.createUserWithKid(6), ]); await Promise.all([ diff --git a/prisma/utils.ts b/prisma/utils.ts index 8bfdf41..ce62c55 100644 --- a/prisma/utils.ts +++ b/prisma/utils.ts @@ -1,4 +1,4 @@ -import { PrismaClient, Pronoun } from '@prisma/client'; +import { Prisma, PrismaClient, Pronoun } from '@prisma/client'; export default class SeedUtils { #now: Date; @@ -11,10 +11,10 @@ export default class SeedUtils { '+12015550125', '+12015550126' ]; - + constructor(now: Date, prisma: PrismaClient) { this.#now = now; - this.#prisma = prisma + this.#prisma = prisma; } permsYes(phone: string) { @@ -117,7 +117,7 @@ export default class SeedUtils { async createUserWithNothing(userInd: number) { const phone = this.PHONES[userInd - 1]; - + await this.#prisma.user.upsert({ where: { phone @@ -132,10 +132,10 @@ export default class SeedUtils { async createActiveSession(userInd: number) { const phone = this.PHONES[userInd - 1]; - + const expires = new Date(this.#now); expires.setHours(expires.getHours() + 1); - + const userSessionToken = `user${userInd}session`; const session = { token: userSessionToken, @@ -157,7 +157,7 @@ export default class SeedUtils { ...this.basicUser(userInd), ...this.emptyHousehold(userInd) }; - + await this.#prisma.user.upsert({ where: { phone @@ -177,7 +177,7 @@ export default class SeedUtils { fromHouseholdId: fromUserInd, fromUserId: fromUserInd }; - + await this.#prisma.friendRequest.upsert({ where: { id: toUserInd @@ -210,7 +210,7 @@ export default class SeedUtils { householdId: fromUserInd, fromUserId: fromUserInd }; - + await this.#prisma.joinHouseholdRequest.upsert({ where: { id: toUserInd @@ -225,9 +225,9 @@ export default class SeedUtils { ...this.basicUser(userInd), ...this.householdWithKid(userInd, 1) }; - + const phone = this.PHONES[userInd - 1]; - + await this.#prisma.user.upsert({ where: { phone @@ -239,5 +239,10 @@ export default class SeedUtils { } }); } - + + async deleteUsers(where: Prisma.UserWhereUniqueInput) { + await this.#prisma.user.deleteMany({ + where + }); + } } diff --git a/src/routes/profile/+page.svelte b/src/routes/profile/+page.svelte index d571a31..7fcf95c 100644 --- a/src/routes/profile/+page.svelte +++ b/src/routes/profile/+page.svelte @@ -139,34 +139,44 @@ {/if}
- - - - - - - - - - - - - - + + + + + + + + + @@ -235,6 +245,9 @@