Playwright re-established. 54 test cases generated.
This commit is contained in:
Binary file not shown.
64
server/test_user.js
Normal file
64
server/test_user.js
Normal file
@@ -0,0 +1,64 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import bcrypt from 'bcryptjs';
|
||||
|
||||
async function createTestUsers() {
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
// Create a regular user
|
||||
const user1Email = 'user1@gymflow.ai';
|
||||
const user1Password = 'user1pass';
|
||||
const hashedUser1Password = await bcrypt.hash(user1Password, 10);
|
||||
await prisma.user.upsert({
|
||||
where: { email: user1Email },
|
||||
update: { password: hashedUser1Password },
|
||||
create: {
|
||||
email: user1Email,
|
||||
password: hashedUser1Password,
|
||||
role: 'USER',
|
||||
profile: { create: { weight: 70 } },
|
||||
},
|
||||
});
|
||||
|
||||
// Create another regular user
|
||||
const user2Email = 'user2@gymflow.ai';
|
||||
const user2Password = 'user2pass';
|
||||
const hashedUser2Password = await bcrypt.hash(user2Password, 10);
|
||||
await prisma.user.upsert({
|
||||
where: { email: user2Email },
|
||||
update: { password: hashedUser2Password },
|
||||
create: {
|
||||
email: user2Email,
|
||||
password: hashedUser2Password,
|
||||
role: 'USER',
|
||||
profile: { create: { weight: 75 } },
|
||||
},
|
||||
});
|
||||
|
||||
// Create a user that will be blocked
|
||||
const blockedUserEmail = 'blocked@gymflow.ai';
|
||||
const blockedUserPassword = 'blockedpass';
|
||||
const hashedBlockedUserPassword = await bcrypt.hash(blockedUserPassword, 10);
|
||||
await prisma.user.upsert({
|
||||
where: { email: blockedUserEmail },
|
||||
update: { password: hashedBlockedUserPassword, isBlocked: true },
|
||||
create: {
|
||||
email: blockedUserEmail,
|
||||
password: hashedBlockedUserPassword,
|
||||
role: 'USER',
|
||||
isBlocked: true,
|
||||
profile: { create: { weight: 80 } },
|
||||
},
|
||||
});
|
||||
|
||||
console.log('Test users created or updated successfully.');
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
|
||||
createTestUsers()
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
// This script is meant to be run once to seed data, so we don't need to keep it running.
|
||||
});
|
||||
Reference in New Issue
Block a user