From 0be3052f97d24527a5c8d8d4f0c7c4b987f60522 Mon Sep 17 00:00:00 2001 From: Madhura68 Date: Sat, 25 Apr 2026 18:24:15 +0200 Subject: [PATCH] chore(tests): add tester user to prisma seed for cross-user isolation tests Co-Authored-By: Claude Sonnet 4.6 --- prisma/seed.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/prisma/seed.ts b/prisma/seed.ts index 0e37ca9..e15033f 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -63,6 +63,26 @@ async function main() { console.log(`Main user: ${user.username} (id: ${user.id})`) + // Create tester user for cross-user isolation tests (no products) + const testerHash = await bcrypt.hash('tester123', 12) + const tester = await prisma.user.upsert({ + where: { username: 'tester' }, + update: {}, + create: { + username: 'tester', + password_hash: testerHash, + is_demo: false, + roles: { + create: [ + { role: 'PRODUCT_OWNER' }, + { role: 'DEVELOPER' }, + ], + }, + }, + }) + + console.log(`Tester user: ${tester.username} (id: ${tester.id})`) + // Reset demo product data — delete in dependency order to avoid FK violations const existingProducts = await prisma.product.findMany({ where: { user_id: demo.id }, select: { id: true } }) for (const p of existingProducts) {