Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion application/backend/prisma/seed/seed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PrismaClient } from '@prisma/client'
import { InviteStatus, PrismaClient } from '@prisma/client'
import { hashPassword } from '../../src/authentication'
import { SurveyStep } from '../../../common/types/survey'
import { createDefaultAnswers, recalculateAnswers } from '../../src/utils/answers'
Expand Down Expand Up @@ -99,6 +99,16 @@ const main = async () => {
},
},
})
// Invite for Michael (kept separate because Invite has no direct relation to User in the schema)
await prisma.invite.create({
data: {
email: 'michaelwilson@example.com',
status: InviteStatus.ACCEPTED,
studyId: shortStudy.id,
expiresAt: new Date('2026-01-01'),
sentAt: new Date('2025-12-15'),
},
})

await prisma.user.upsert({
where: { email: 'sallywilson@example.com' },
Expand Down Expand Up @@ -150,6 +160,15 @@ const main = async () => {
},
},
})
await prisma.invite.create({
data: {
email: 'sallywilson@example.com',
status: InviteStatus.ACCEPTED,
studyId: shortStudy.id,
expiresAt: new Date('2026-01-01'),
sentAt: new Date('2025-12-15'),
},
})

await prisma.participantProfile.upsert({
where: {
Expand Down Expand Up @@ -245,6 +264,15 @@ const main = async () => {
},
},
})
await prisma.invite.create({
data: {
email: 'alicejohnson@example.com',
status: InviteStatus.ACCEPTED,
studyId: shortStudy.id,
expiresAt: new Date('2026-01-01'),
sentAt: new Date('2025-12-15'),
},
})

// Ensure a Study record exists
const defaultStudy = await prisma.study.create({
Expand Down Expand Up @@ -411,6 +439,24 @@ const main = async () => {
},
},
})
await prisma.invite.create({
data: {
email: String(process.env.EXAMPLE_PARTICIPANT_EMAIL),
status: InviteStatus.ACCEPTED,
studyId: defaultStudy.id,
expiresAt: new Date('2026-01-01'),
sentAt: new Date('2025-12-15'),
},
})
await prisma.invite.create({
data: {
email: String(process.env.EXAMPLE_PARTICIPANT_EMAIL),
status: InviteStatus.ACCEPTED,
studyId: shortStudy.id,
expiresAt: new Date('2026-01-01'),
sentAt: new Date('2025-12-15'),
},
})
console.log('Added the following users:', exampleUser)

const judithShortAnswers = await prisma.surveyVersionAnswers.findFirstOrThrow({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ describe('InvitesController', () => {
const invite = await prisma.invite.findFirstOrThrow({
where: {
email: TestUsers.PARTICIPANT_UNANSWERED.email,
studyId: TestStudies.TEST_STUDY_2.id,
},
})

Expand Down Expand Up @@ -805,6 +806,7 @@ describe('InvitesController', () => {
const invite = await prisma.invite.findFirstOrThrow({
where: {
email: TestUsers.PARTICIPANT_UNANSWERED.email,
studyId: TestStudies.TEST_STUDY_2.id,
},
})

Expand Down
Loading
Loading