chore(tests): add tester user to prisma seed for cross-user isolation tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Janpeter Visser 2026-04-25 18:24:15 +02:00
parent db85d4b49e
commit 0be3052f97

View file

@ -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) {