Description
createMembershipRegistration (in the member repository) converts a validated MemberRegistration into a Prisma .create() call against the Member table, handling per-path field mapping (returning member, current UoA student, non-UoA student) and translating a P2002 unique-constraint violation into a distinct duplicate error, versus a generic database error for anything else. It currently has no test coverage.
Requirements
- Mock
getPrisma() entirely - no real database connection should be required to run this suite
- Cover the successful-creation path
- Cover field mapping for all three
MemberRegistration variants: what gets included/omitted per branch (e.g. a returning member should not receive programme/primaryAffiliation; a current UoA student should receive faculty/programme/yearLevel; a non-UoA student should receive an empty faculty array and primaryAffiliation)
- Cover optional field pass-through (
discordUsername)
- Cover error translation: a Prisma error with code
P2002 → { type: "duplicate" }; any other Prisma error code → { type: "database" }; a non-Prisma error → also { type: "database" }
Acceptance Criteria
Notes
This is a self-contained unit test task with no dependency on the faculty/major redesign - the repository's field-mapping logic for faculty/programme will need a small update once that redesign lands, but the mocking setup and most of the file structure won't change.
Description
createMembershipRegistration(in the member repository) converts a validatedMemberRegistrationinto a Prisma.create()call against theMembertable, handling per-path field mapping (returning member, current UoA student, non-UoA student) and translating aP2002unique-constraint violation into a distinctduplicateerror, versus a genericdatabaseerror for anything else. It currently has no test coverage.Requirements
getPrisma()entirely - no real database connection should be required to run this suiteMemberRegistrationvariants: what gets included/omitted per branch (e.g. a returning member should not receiveprogramme/primaryAffiliation; a current UoA student should receivefaculty/programme/yearLevel; a non-UoA student should receive an emptyfacultyarray andprimaryAffiliation)discordUsername)P2002→{ type: "duplicate" }; any other Prisma error code →{ type: "database" }; a non-Prisma error → also{ type: "database" }Acceptance Criteria
memberRepository.test.tsexists, withgetPrismamocked, no live database required to runvi.mock, spy call inspection via.mock.calls) for anyone unfamiliar with itNotes
This is a self-contained unit test task with no dependency on the faculty/major redesign - the repository's field-mapping logic for
faculty/programmewill need a small update once that redesign lands, but the mocking setup and most of the file structure won't change.