Phase 1–3 of unit test fixes complete. All 65 test suites, 642 tests passing (integration + unit).
Replaced the 1532-line in-memory PrismaService fake with a real PrismaClient using @prisma/adapter-pg (Prisma v7 driver adapter). This removes all Map-based stores and delegates all queries to PostgreSQL.
src/prisma/prisma.service.ts— extendsPrismaClientinstead of in-memory Map stores- Constructor accepts optional
databaseUrl(falls back toprocess.env.DATABASE_URL) - Creates
PrismaPgadapter with connection string internally - Applies
statement_timeoutandconnect_timeoutto URL onModuleInit()calls$connect()and registers slow-query logger via$on('query')onModuleDestroy()calls$disconnect()reset()executesTRUNCATE TABLE ... CASCADEon all public tables (skips_prisma_migrations)- All custom type exports preserved for backward compatibility
- Constructor accepts optional
src/prisma/prisma.module.ts— comment-only update.github/workflows/test.yml— added Postgres 16 service (matched fromtest.yml)
src/escrow/buyer-dispute.service.ts—openDispute()now explicitly callsescrowRepository.updateState(escrowId, 'DISPUTED')after creating a dispute (in-memory fake auto-transitioned escrow as side-effect; real DB does not)test/integration/vendor-analytics.integration-spec.ts— removed(prisma as any).escrows.set(...); now passescreatedAtdirectly toprisma.escrow.create()src/prisma/prisma.service.spec.ts,test/unit/prisma-schema-parity.spec.ts,src/prisma/escrow-event-logging.spec.ts— updated for real PrismaClient API
prisma.escrow.findMany()no longer auto-filters CANCELLED records (remove CANCELLED-hiding behavior). All records are returned unless astatefilter is provided.prisma.escrow.create()/prisma.escrow.update()no longer auto-createEscrowEventrows — event logging must be done explicitly.prisma.dispute.create()no longer auto-transitions escrow to DISPUTED — handled byBuyerDisputeService.amountfields arePrisma.Decimalat runtime (notnumber). UsetoEqual()instead oftoBe()for comparisons, or callNumber(escrow.amount)for arithmetic.
- PostgreSQL must be running on
localhost:5432withtrustlink_testdatabase DATABASE_URLin.env.testpoints topostgresql://postgres:postgres@localhost:5432/trustlink_test
All 24 integration test suites (182 tests) passing after:
- CI Node v20→v22, baseline migration,
SENTRY_DSNfix, Stellar addresses,Idempotency-Keyheader markAutoReleaseSubmittingrace condition → atomicupdateManyPrismaServicein-memory mock additions (updateMany,CacheService.del, etc.)
src/prisma/prisma.service.ts— full rewrite (extends PrismaClient + PrismaPg adapter)src/prisma/prisma.module.ts— comment updatesrc/escrow/buyer-dispute.service.ts— explicit escrow state transitionsrc/prisma/prisma.service.spec.ts— updated for real DBsrc/prisma/escrow-event-logging.spec.ts— updated for real DBtest/unit/prisma-schema-parity.spec.ts— updated for real DBtest/integration/vendor-analytics.integration-spec.ts— removed direct store access.github/workflows/test.yml— added Postgres service
jest-integration.json:testTimeout: 60000- Unit tests use default Jest config (standalone files, no
AppModule)