refactor: rename Recipient to Person, remove username, add userId FK

This commit is contained in:
2026-06-16 10:04:24 +02:00
parent befe1f3f82
commit d67f31cf54
27 changed files with 751 additions and 628 deletions
@@ -2,7 +2,7 @@ import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest"
import type { PrismaClient } from "@/generated/prisma/client"
import {
createTestItem,
createTestRecipient,
createTestPerson,
createTestUser,
} from "../helpers/factories"
import {
@@ -38,7 +38,7 @@ afterAll(async () => {
describe("assignment use-cases", () => {
it("creates an assignment, decrements stock, and records an ASSIGNMENT movement", async () => {
const actor = await createTestUser(prisma)
const recipient = await createTestRecipient(prisma)
const recipient = await createTestPerson(prisma)
const item = await createTestItem(prisma, { stock: 5 })
const assignmentDate = new Date("2026-01-01T00:00:00.000Z")
@@ -88,7 +88,7 @@ describe("assignment use-cases", () => {
it("rejects assignment creation when item stock is insufficient", async () => {
const actor = await createTestUser(prisma)
const recipient = await createTestRecipient(prisma)
const recipient = await createTestPerson(prisma)
const item = await createTestItem(prisma, { stock: 1 })
const result = await createAssignmentUseCase({
@@ -114,7 +114,7 @@ describe("assignment use-cases", () => {
it("returns an assignment, restores stock, closes it, and records a RETURN movement", async () => {
const actor = await createTestUser(prisma)
const recipient = await createTestRecipient(prisma)
const recipient = await createTestPerson(prisma)
const item = await createTestItem(prisma, { stock: 4 })
const created = await createAssignmentUseCase({
@@ -172,7 +172,7 @@ describe("assignment use-cases", () => {
it("rejects returning the same assignment twice", async () => {
const actor = await createTestUser(prisma)
const recipient = await createTestRecipient(prisma)
const recipient = await createTestPerson(prisma)
const item = await createTestItem(prisma, { stock: 2 })
const created = await createAssignmentUseCase({