Skip to content

Create ACCEPTED invites for seeded participant users - #912

Open
iamtanuj18 wants to merge 4 commits into
devfrom
890-create-invites-for-seed-users
Open

Create ACCEPTED invites for seeded participant users#912
iamtanuj18 wants to merge 4 commits into
devfrom
890-create-invites-for-seed-users

Conversation

@iamtanuj18

Copy link
Copy Markdown

Fixes #890.

Adds ACCEPTED Invite rows for PARTICIPANT_UNANSWERED, PARTICIPANT_COMPLETED, and GUARDIAN_2 in seed.ts, so seeded participants match the shape of production data (every participant has an accepted invite in their study). Fixes the alreadyAcceptedCount check in ParticipantsController returning 0 for seeded participants.

Two existing tests in ParticipantsController.test.ts were relying on findFirstOrThrow({ email }) to return the participant's single pre-existing PENDING invite. Now that seeded participants also have an ACCEPTED invite in TEST_STUDY, the query is ambiguous — the fix adds studyId: TEST_STUDY_2.id to those queries so they find the correct pending invite.

@ignatiusm ignatiusm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @iamtanuj18 ,

Thanks for your work on this. Nice one fixing the affected tests. Two requested changes:

  1. To make the ongoing maintenance of the seed data easier, can you look in to nested writes to see if you can create invites at the same time as the users are being created? I think this is easier to maintain as all records related to a user are linked in one transaction. For an example, look at lines 52 to 101 in application/backend/prisma/seed/seed.ts. You may need to do some experimenting to make sure this works. Let me know if you have any issues.

  2. Can you also apply a similar fix to any participants created in application/backend/prisma/seed/seed.ts ? This is a different set of seed data used for local dev. It is what initially alerted me to this issue as I was playing around with invites with local dev set up, when I realised that the participant users did not have associated invites.

@iamtanuj18

Copy link
Copy Markdown
Author

@ignatiusm requested changes are done and the PR is ready for review.

@iamtanuj18
iamtanuj18 requested a review from ignatiusm August 5, 2026 05:41

@ignatiusm ignatiusm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @iamtanuj18,

Really nice work tidying up the test seed data with nested writes!! Thanks for adding some more explanatory comments. I reckon that is much tidier - would be curious to hear your view.

For the invites, I realise I might have steered you in the wrong direction when I said:

To make the ongoing maintenance of the seed data easier, can you look in to nested writes to see if you can create invites at the same time as the users are being created?

Looking at application/backend/prisma/schema.prisma Invites are associated with Studies, not Users. So the nested writes need to happen with study creation, not User creation. I just implemented a test example locally to check. I think it is an improvement: creating the invites at study creation time, then sets up expectations for the number of participants that will be created.

Can you please have a go at implementing the invites using nested writes too? feel free to ask if you have any questions or concerns.

@iamtanuj18

iamtanuj18 commented Aug 6, 2026

Copy link
Copy Markdown
Author

@ignatiusm changes: invites now nested under study.create in both seed files.

@iamtanuj18
iamtanuj18 requested a review from ignatiusm August 7, 2026 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants