mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-29 22:27:25 +02:00
🐛 Fix user test utils (#1824)
This commit is contained in:
parent
1284b0ac04
commit
d93615befe
1 changed files with 28 additions and 9 deletions
|
@ -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 }) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue