🐛 Fix user test utils (#1824)

This commit is contained in:
Luke Vella 2025-07-15 10:17:22 +01:00 committed by GitHub
parent 1284b0ac04
commit d93615befe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,7 +11,8 @@ export async function createUserInDb({
name: string;
role?: UserRole;
}) {
return prisma.user.create({
return await prisma.$transaction(async (tx) => {
const user = await tx.user.create({
data: {
email,
name,
@ -21,6 +22,24 @@ export async function createUserInDb({
emailVerified: new Date(),
},
});
const space = await tx.space.create({
data: {
name: "Personal",
ownerId: user.id,
},
});
await tx.spaceMember.create({
data: {
spaceId: space.id,
userId: user.id,
role: "OWNER",
},
});
return user;
});
}
export async function loginWithEmail(page: Page, { email }: { email: string }) {