From 9a0718a03cc15a244991e2b1a79e73c5d7b73163 Mon Sep 17 00:00:00 2001 From: Juan Carlos Sigler Priego Date: Mon, 4 Nov 2024 19:32:29 -0500 Subject: [PATCH 1/4] tests de schedule mentorias --- src/__tests__/api/scheduleMentoria.test.ts | 33 ++++++++++ src/__tests__/api/upsertParticipation.test.ts | 65 +++++-------------- src/__tests__/api/upsertParticipationUtils.ts | 46 +++++++++++++ 3 files changed, 94 insertions(+), 50 deletions(-) create mode 100644 src/__tests__/api/scheduleMentoria.test.ts create mode 100644 src/__tests__/api/upsertParticipationUtils.ts diff --git a/src/__tests__/api/scheduleMentoria.test.ts b/src/__tests__/api/scheduleMentoria.test.ts new file mode 100644 index 0000000..14e42ca --- /dev/null +++ b/src/__tests__/api/scheduleMentoria.test.ts @@ -0,0 +1,33 @@ +import { describe, it, expect } from "vitest"; +import { createMocks, RequestMethod } from "node-mocks-http"; +import type { NextApiRequest, NextApiResponse } from "next"; + +type ApiRequest = NextApiRequest & ReturnType; +type APiResponse = NextApiResponse & ReturnType; + +describe("/api/ofmi/registerParticipation API Endpoint", () => { + function mockRequestResponse({ + method = "POST", + body, + }: { + method?: RequestMethod; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + body: any; + }): { + req: ApiRequest; + res: APiResponse; + } { + const { req, res } = createMocks({ + method, + headers: { + "Content-Type": "application/json", + }, + body: body, + }); + return { req, res }; + } + + it("should return a successful response", async () => { + expect(true).not.toBeNull(); + }); +}); diff --git a/src/__tests__/api/upsertParticipation.test.ts b/src/__tests__/api/upsertParticipation.test.ts index b4711cd..deacc95 100644 --- a/src/__tests__/api/upsertParticipation.test.ts +++ b/src/__tests__/api/upsertParticipation.test.ts @@ -12,20 +12,17 @@ import { emailReg } from "@/lib/validators"; import { prisma } from "@/lib/prisma"; import { hashPassword } from "@/lib/hashPassword"; import { toISOStringReg } from "@/lib/validators/date"; -import { ParticipationRole } from "@prisma/client"; +import { + validMailingAddressInput, + validOfmi, + validUserInput, + validUserParticipationInput, +} from "./upsertParticipationUtils"; type ApiRequest = NextApiRequest & ReturnType; type APiResponse = NextApiResponse & ReturnType; const dummyEmail = "upsertParticipation@test.com"; -const validOfmi = { - edition: 1, - birthDateRequirement: new Date("2005-07-01"), - year: 2024, - registrationOpenTime: new Date("2024-07-07"), - registrationCloseTime: new Date("2050-08-08"), -}; -const validRole: ParticipationRole = "CONTESTANT"; beforeAll(async () => { // ofmi is Needed @@ -83,43 +80,11 @@ describe("/api/ofmi/registerParticipation API Endpoint", () => { return { req, res }; } - const validMailingAddressInput = { - street: "Calle", - externalNumber: "#8Bis", - zipcode: "01234", - country: "MEX", - state: "Aguascalientes", - municipality: "Aguascalientes", - locality: "Aguascalientes", - phone: "5511223344", - references: "Hasta el fondo", - }; - - const validUserInput = { - email: dummyEmail, - firstName: "Juan Carlos", - lastName: "Sigler Priego", - preferredName: "Juanito", - birthDate: new Date("2006-11-24").toISOString(), - pronouns: "HE", - governmentId: "HEGG061124MVZRRL02", - shirtSize: "M", - shirtStyle: "STRAIGHT", - mailingAddress: validMailingAddressInput, - }; - - const validUserParticipationInput = { - role: validRole, - schoolName: "Colegio Carol Baur", - schoolStage: "HIGH", - schoolGrade: 3, - schoolCountry: "MEX", - schoolState: "Aguascalientes", - }; + const validUser = validUserInput(dummyEmail); const validRequest = { - ofmiEdition: 1, - user: validUserInput, + ofmiEdition: validOfmi.edition, + user: validUser, userParticipation: validUserParticipationInput, }; @@ -158,7 +123,7 @@ describe("/api/ofmi/registerParticipation API Endpoint", () => { body: { ...validRequest, user: { - ...validUserInput, + ...validUser, firstName: newFirstName, mailingAddress: { ...validMailingAddressInput, @@ -278,7 +243,7 @@ describe("/api/ofmi/registerParticipation API Endpoint", () => { body: { ...validRequest, user: { - ...validUserInput, + ...validUser, email: "juanito.omegaup.com", }, }, @@ -297,7 +262,7 @@ describe("/api/ofmi/registerParticipation API Endpoint", () => { body: { ...validRequest, user: { - ...validUserInput, + ...validUser, email: "dont@exist.com", }, }, @@ -317,7 +282,7 @@ describe("/api/ofmi/registerParticipation API Endpoint", () => { body: { ...validRequest, user: { - ...validUserInput, + ...validUser, birthDate: "0006-12-12", }, }, @@ -336,7 +301,7 @@ describe("/api/ofmi/registerParticipation API Endpoint", () => { body: { ...validRequest, user: { - ...validUserInput, + ...validUser, birthDate: new Date("2008-12-12").toISOString(), }, }, @@ -356,7 +321,7 @@ describe("/api/ofmi/registerParticipation API Endpoint", () => { body: { ...validRequest, user: { - ...validUserInput, + ...validUser, birthDate: new Date("2004-12-12").toISOString(), governmentId: "PELJ041212HDFXXX04", }, diff --git a/src/__tests__/api/upsertParticipationUtils.ts b/src/__tests__/api/upsertParticipationUtils.ts new file mode 100644 index 0000000..70a8fe4 --- /dev/null +++ b/src/__tests__/api/upsertParticipationUtils.ts @@ -0,0 +1,46 @@ +import { JSONValue } from "@/types/json"; +import { ParticipationRole } from "@prisma/client"; + +export const validOfmi = { + edition: 1, + birthDateRequirement: new Date("2005-07-01"), + year: 2024, + registrationOpenTime: new Date("2024-07-07"), + registrationCloseTime: new Date("2050-08-08"), +}; + +export const validMailingAddressInput = { + street: "Calle", + externalNumber: "#8Bis", + zipcode: "01234", + country: "MEX", + state: "Aguascalientes", + municipality: "Aguascalientes", + locality: "Aguascalientes", + phone: "5511223344", + references: "Hasta el fondo", +}; + +export const validUserInput = (email: string): object => { + return { + email, + firstName: "Juan Carlos", + lastName: "Sigler Priego", + preferredName: "Juanito", + birthDate: new Date("2006-11-24").toISOString(), + pronouns: "HE", + governmentId: "HEGG061124MVZRRL02", + shirtSize: "M", + shirtStyle: "STRAIGHT", + mailingAddress: validMailingAddressInput, + }; +}; + +export const validUserParticipationInput = { + role: ParticipationRole.CONTESTANT, + schoolName: "Colegio Carol Baur", + schoolStage: "HIGH", + schoolGrade: 3, + schoolCountry: "MEX", + schoolState: "Aguascalientes", +}; From dbacd5bbb5404b806b001cea1b09da58d01f49ca Mon Sep 17 00:00:00 2001 From: Juan Carlos Sigler Priego Date: Mon, 4 Nov 2024 19:50:07 -0500 Subject: [PATCH 2/4] test helpers --- package-lock.json | 12 +-- src/__tests__/api/scheduleMentoria.test.ts | 33 ------- src/__tests__/api/upsertParticipation.test.ts | 26 +++--- src/__tests__/api/upsertParticipationUtils.ts | 92 ++++++++++++++++++- 4 files changed, 109 insertions(+), 54 deletions(-) delete mode 100644 src/__tests__/api/scheduleMentoria.test.ts diff --git a/package-lock.json b/package-lock.json index 2ccc490..951b395 100644 --- a/package-lock.json +++ b/package-lock.json @@ -244,9 +244,9 @@ } }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.24.8.tgz", - "integrity": "sha512-FFWx5142D8h2Mgr/iPVGH5G7w6jDn4jUSpZTyDnQO0Yn7Ks2Kuz6Pci8H6MPCoUJegd/UZQ3tAvfLCxQSnWWwg==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.9.tgz", + "integrity": "sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw==", "dev": true, "engines": { "node": ">=6.9.0" @@ -12602,9 +12602,9 @@ } }, "@babel/helper-plugin-utils": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.24.8.tgz", - "integrity": "sha512-FFWx5142D8h2Mgr/iPVGH5G7w6jDn4jUSpZTyDnQO0Yn7Ks2Kuz6Pci8H6MPCoUJegd/UZQ3tAvfLCxQSnWWwg==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.9.tgz", + "integrity": "sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw==", "dev": true }, "@babel/helper-simple-access": { diff --git a/src/__tests__/api/scheduleMentoria.test.ts b/src/__tests__/api/scheduleMentoria.test.ts deleted file mode 100644 index 14e42ca..0000000 --- a/src/__tests__/api/scheduleMentoria.test.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { describe, it, expect } from "vitest"; -import { createMocks, RequestMethod } from "node-mocks-http"; -import type { NextApiRequest, NextApiResponse } from "next"; - -type ApiRequest = NextApiRequest & ReturnType; -type APiResponse = NextApiResponse & ReturnType; - -describe("/api/ofmi/registerParticipation API Endpoint", () => { - function mockRequestResponse({ - method = "POST", - body, - }: { - method?: RequestMethod; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - body: any; - }): { - req: ApiRequest; - res: APiResponse; - } { - const { req, res } = createMocks({ - method, - headers: { - "Content-Type": "application/json", - }, - body: body, - }); - return { req, res }; - } - - it("should return a successful response", async () => { - expect(true).not.toBeNull(); - }); -}); diff --git a/src/__tests__/api/upsertParticipation.test.ts b/src/__tests__/api/upsertParticipation.test.ts index deacc95..9a4cd90 100644 --- a/src/__tests__/api/upsertParticipation.test.ts +++ b/src/__tests__/api/upsertParticipation.test.ts @@ -1,3 +1,4 @@ +import { cascadeDelete } from "prisma-cascade-delete"; import { describe, it, expect, beforeEach, beforeAll } from "vitest"; import { mockEmailer } from "./mocks/emailer"; import { @@ -13,6 +14,8 @@ import { prisma } from "@/lib/prisma"; import { hashPassword } from "@/lib/hashPassword"; import { toISOStringReg } from "@/lib/validators/date"; import { + cleanParticipation, + insertAndCheckSuccessfullyDummyParticipation, validMailingAddressInput, validOfmi, validUserInput, @@ -44,16 +47,7 @@ beforeAll(async () => { }); beforeEach(async () => { - // Remove contestant participation of dummy email - await prisma.contestantParticipation.deleteMany({ - where: { - Participation: { every: { user: { UserAuth: { email: dummyEmail } } } }, - }, - }); - // Remove participation of dummy email - await prisma.participation.deleteMany({ - where: { user: { UserAuth: { email: dummyEmail } } }, - }); + await cleanParticipation(dummyEmail); // Remover contestant participation mockEmailer.resetMock(); }); @@ -109,11 +103,15 @@ describe("/api/ofmi/registerParticipation API Endpoint", () => { expect(participationModel).not.toBeNull(); }); + it("should register volunteer", async () => { + await insertAndCheckSuccessfullyDummyParticipation(dummyEmail, "VOLUNTEER"); + }); + it("should update", async () => { - const { req, res } = mockRequestResponse({ body: validRequest }); - await upsertParticipationHandler(req, res); - expect(res.statusCode).toBe(201); - expect(res.getHeaders()).toEqual({ "content-type": "application/json" }); + const res = await insertAndCheckSuccessfullyDummyParticipation( + dummyEmail, + "CONTESTANT", + ); const participation = res._getJSONData()["participation"]; const newFirstName = "Other Name"; diff --git a/src/__tests__/api/upsertParticipationUtils.ts b/src/__tests__/api/upsertParticipationUtils.ts index 70a8fe4..d2424c7 100644 --- a/src/__tests__/api/upsertParticipationUtils.ts +++ b/src/__tests__/api/upsertParticipationUtils.ts @@ -1,5 +1,17 @@ -import { JSONValue } from "@/types/json"; +import { + createMocks, + RequestMethod, + createRequest, + createResponse, +} from "node-mocks-http"; +import type { NextApiRequest, NextApiResponse } from "next"; +import { expect } from "vitest"; import { ParticipationRole } from "@prisma/client"; +import upsertParticipationHandler from "@/pages/api/ofmi/upsertParticipation"; +import { prisma } from "@/lib/prisma"; + +type ApiRequest = NextApiRequest & ReturnType; +type APiResponse = NextApiResponse & ReturnType; export const validOfmi = { edition: 1, @@ -44,3 +56,81 @@ export const validUserParticipationInput = { schoolCountry: "MEX", schoolState: "Aguascalientes", }; + +export const validVolunteerParticipationInput = { + role: ParticipationRole.VOLUNTEER, + educationalLinkageOptIn: true, + fundraisingOptIn: true, + communityOptIn: true, + trainerOptIn: true, + problemSetterOptIn: true, + mentorOptIn: true, +}; + +export function mockRequestResponse({ + method = "POST", + body, +}: { + method?: RequestMethod; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + body: any; +}): { + req: ApiRequest; + res: APiResponse; +} { + const { req, res } = createMocks({ + method, + headers: { + "Content-Type": "application/json", + }, + body: body, + }); + return { req, res }; +} + +export async function cleanParticipation(email: string): Promise { + // Remove contestant participation of dummy email + await prisma.contestantParticipation.deleteMany({ + where: { + Participation: { every: { user: { UserAuth: { email } } } }, + }, + }); + + // Remove volunteer participation + await prisma.volunteerParticipation.deleteMany({ + where: { + Participation: { every: { user: { UserAuth: { email } } } }, + }, + }); + + // Remove participation of dummy email + await prisma.participation.deleteMany({ + where: { user: { UserAuth: { email } } }, + }); + + // Remove user + await prisma.user.deleteMany({ + where: { UserAuth: { email } }, + }); +} + +export async function insertAndCheckSuccessfullyDummyParticipation( + email: string, + role: ParticipationRole, +): Promise { + const validRequest = { + ofmiEdition: validOfmi.edition, + user: validUserInput(email), + userParticipation: + role === "CONTESTANT" + ? validUserParticipationInput + : validVolunteerParticipationInput, + }; + const { req, res } = mockRequestResponse({ body: validRequest }); + await upsertParticipationHandler(req, res); + + console.log(res._getJSONData()); + expect(res.statusCode).toBe(201); + expect(res.getHeaders()).toEqual({ "content-type": "application/json" }); + return res; +} From c079d0c54eef8cc27a8882923d83f6f76bdc7e80 Mon Sep 17 00:00:00 2001 From: Juan Carlos Sigler Priego Date: Tue, 5 Nov 2024 01:23:54 -0500 Subject: [PATCH 3/4] restore --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 951b395..2ccc490 100644 --- a/package-lock.json +++ b/package-lock.json @@ -244,9 +244,9 @@ } }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.9.tgz", - "integrity": "sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw==", + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.24.8.tgz", + "integrity": "sha512-FFWx5142D8h2Mgr/iPVGH5G7w6jDn4jUSpZTyDnQO0Yn7Ks2Kuz6Pci8H6MPCoUJegd/UZQ3tAvfLCxQSnWWwg==", "dev": true, "engines": { "node": ">=6.9.0" @@ -12602,9 +12602,9 @@ } }, "@babel/helper-plugin-utils": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.9.tgz", - "integrity": "sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw==", + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.24.8.tgz", + "integrity": "sha512-FFWx5142D8h2Mgr/iPVGH5G7w6jDn4jUSpZTyDnQO0Yn7Ks2Kuz6Pci8H6MPCoUJegd/UZQ3tAvfLCxQSnWWwg==", "dev": true }, "@babel/helper-simple-access": { From c5708abbe6ae3500b95ff8a054c31b647ecd5123 Mon Sep 17 00:00:00 2001 From: Juan Carlos Sigler Priego Date: Tue, 5 Nov 2024 01:59:07 -0500 Subject: [PATCH 4/4] test schedule mentoria --- src/__tests__/api/scheduleMentoria.test.ts | 149 ++++++++++++++++++ src/__tests__/api/upsertParticipation.test.ts | 1 - src/__tests__/api/upsertParticipationUtils.ts | 8 +- 3 files changed, 153 insertions(+), 5 deletions(-) create mode 100644 src/__tests__/api/scheduleMentoria.test.ts diff --git a/src/__tests__/api/scheduleMentoria.test.ts b/src/__tests__/api/scheduleMentoria.test.ts new file mode 100644 index 0000000..ea2d0bc --- /dev/null +++ b/src/__tests__/api/scheduleMentoria.test.ts @@ -0,0 +1,149 @@ +import { describe, it, expect, beforeEach, beforeAll } from "vitest"; +import { mockEmailer } from "./mocks/emailer"; +import { + createMocks, + RequestMethod, + createRequest, + createResponse, +} from "node-mocks-http"; +import type { NextApiRequest, NextApiResponse } from "next"; +import scheduleMentoriaHandler from "@/pages/api/mentoria/schedule"; +import { prisma } from "@/lib/prisma"; +import { hashPassword } from "@/lib/hashPassword"; +import { + cleanParticipation, + insertAndCheckSuccessfullyDummyParticipation, + validOfmi, +} from "./upsertParticipationUtils"; +import { ParticipationRole } from "@prisma/client"; + +type ApiRequest = NextApiRequest & ReturnType; +type APiResponse = NextApiResponse & ReturnType; + +const dummyContestantEmail = "scheduleMentoria-contestant@test.com"; +const dummyVolunteerEmail = "scheduleMentoria-volunteer@test.com"; + +beforeAll(async () => { + // ofmi is Needed + await prisma.ofmi.upsert({ + where: { edition: validOfmi.edition }, + update: { + ...validOfmi, + }, + create: { + ...validOfmi, + }, + }); + // Upsert the valid user Auth + await prisma.userAuth.upsert({ + where: { email: dummyContestantEmail }, + update: {}, + create: { email: dummyContestantEmail, password: hashPassword("pass") }, + }); + await prisma.userAuth.upsert({ + where: { email: dummyVolunteerEmail }, + update: {}, + create: { email: dummyVolunteerEmail, password: hashPassword("pass") }, + }); +}); + +beforeEach(async () => { + // Clean mentorĂ­a + await prisma.mentoria.deleteMany({ + where: { + contestantParticipant: { + Participation: { + every: { user: { UserAuth: { email: dummyContestantEmail } } }, + }, + }, + }, + }); + await cleanParticipation(dummyContestantEmail); + await cleanParticipation(dummyVolunteerEmail); + + // Remover contestant participation + mockEmailer.resetMock(); +}); + +describe("/api/mentoria/schedule API Endpoint", () => { + function mockRequestResponse({ + method = "POST", + body, + }: { + method?: RequestMethod; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + body: any; + }): { + req: ApiRequest; + res: APiResponse; + } { + const { req, res } = createMocks({ + method, + headers: { + "Content-Type": "application/json", + }, + body: body, + }); + return { req, res }; + } + + async function createParticipations(): Promise<{ + contestantParticipationId: string; + volunteerParticipationId: string; + }> { + const contestant = ( + await insertAndCheckSuccessfullyDummyParticipation( + dummyContestantEmail, + ParticipationRole.CONTESTANT, + ) + )._getJSONData()["participation"]; + const contestantParticipationId = contestant.contestantParticipationId; + expect(contestantParticipationId.length).greaterThanOrEqual(1); + const volunteer = ( + await insertAndCheckSuccessfullyDummyParticipation( + dummyContestantEmail, + ParticipationRole.VOLUNTEER, + ) + )._getJSONData()["participation"]; + const volunteerParticipationId = volunteer.volunteerParticipationId; + expect(volunteerParticipationId.length).greaterThanOrEqual(1); + return { contestantParticipationId, volunteerParticipationId }; + } + + it("should return a successful response", async () => { + // Create contestant and volunteer participation + const { contestantParticipationId, volunteerParticipationId } = + await createParticipations(); + + const meetingTime = new Date("2024-11-24").toISOString(); + const { req, res } = mockRequestResponse({ + body: { + contestantParticipantId: contestantParticipationId, + volunteerAuthId: "3232", + volunteerParticipationId, + meetingTimeOpt: meetingTime, + calendlyPayload: { + event: { uri: "event_uri" }, + invitee: { uri: "invitee_uri" }, + }, + }, + }); + await scheduleMentoriaHandler(req, res); + + expect(res.statusCode).toBe(200); + expect(res.getHeaders()).toEqual({ "content-type": "application/json" }); + + // Check update in DB + const participationModel = await prisma.mentoria.findUnique({ + where: { + volunteerParticipationId_contestantParticipantId_meetingTime: { + contestantParticipantId: contestantParticipationId, + volunteerParticipationId: volunteerParticipationId, + meetingTime: meetingTime, + }, + }, + }); + + expect(participationModel).not.toBeNull(); + }); +}); diff --git a/src/__tests__/api/upsertParticipation.test.ts b/src/__tests__/api/upsertParticipation.test.ts index 9a4cd90..aac0dc1 100644 --- a/src/__tests__/api/upsertParticipation.test.ts +++ b/src/__tests__/api/upsertParticipation.test.ts @@ -1,4 +1,3 @@ -import { cascadeDelete } from "prisma-cascade-delete"; import { describe, it, expect, beforeEach, beforeAll } from "vitest"; import { mockEmailer } from "./mocks/emailer"; import { diff --git a/src/__tests__/api/upsertParticipationUtils.ts b/src/__tests__/api/upsertParticipationUtils.ts index d2424c7..30863f3 100644 --- a/src/__tests__/api/upsertParticipationUtils.ts +++ b/src/__tests__/api/upsertParticipationUtils.ts @@ -95,23 +95,24 @@ export async function cleanParticipation(email: string): Promise { Participation: { every: { user: { UserAuth: { email } } } }, }, }); - // Remove volunteer participation await prisma.volunteerParticipation.deleteMany({ where: { Participation: { every: { user: { UserAuth: { email } } } }, }, }); - // Remove participation of dummy email await prisma.participation.deleteMany({ where: { user: { UserAuth: { email } } }, }); - // Remove user await prisma.user.deleteMany({ where: { UserAuth: { email } }, }); + // Remove hanging address + await prisma.mailingAddress.deleteMany({ + where: { User: { every: { mailingAddressId: { equals: "" } } } }, + }); } export async function insertAndCheckSuccessfullyDummyParticipation( @@ -129,7 +130,6 @@ export async function insertAndCheckSuccessfullyDummyParticipation( const { req, res } = mockRequestResponse({ body: validRequest }); await upsertParticipationHandler(req, res); - console.log(res._getJSONData()); expect(res.statusCode).toBe(201); expect(res.getHeaders()).toEqual({ "content-type": "application/json" }); return res;