74 lines
2.1 KiB
TypeScript
74 lines
2.1 KiB
TypeScript
import { Given, After } from '@cucumber/cucumber';
|
|
import { world } from '../support/world';
|
|
|
|
Given('there are top players in the system', async function () {
|
|
const prisma = await world.getPrisma();
|
|
const timestamp = Date.now();
|
|
|
|
for (let i = 0; i < 3; i++) {
|
|
await prisma.player.create({
|
|
data: {
|
|
name: `Home Test Player ${timestamp} ${i + 1}`,
|
|
normalizedName: `home_test_player_${timestamp}_${i + 1}`.toLowerCase(),
|
|
currentElo: 2000 - i * 10,
|
|
gamesPlayed: 10,
|
|
wins: 7,
|
|
},
|
|
});
|
|
}
|
|
});
|
|
|
|
Given('there is a club president', async function () {
|
|
const prisma = await world.getPrisma();
|
|
const timestamp = Date.now();
|
|
|
|
await prisma.user.create({
|
|
data: {
|
|
email: `president-${timestamp}@example.com`,
|
|
name: `Club President ${timestamp}`,
|
|
role: 'club_admin',
|
|
},
|
|
});
|
|
});
|
|
|
|
Given('there is a recent tournament', async function () {
|
|
const prisma = await world.getPrisma();
|
|
const timestamp = Date.now();
|
|
|
|
const tournament = await prisma.event.create({
|
|
data: {
|
|
name: `Recent Tournament ${timestamp}`,
|
|
eventType: 'tournament',
|
|
eventDate: new Date(Date.now() + 86400000),
|
|
status: 'completed',
|
|
},
|
|
});
|
|
|
|
const p1 = await prisma.player.create({
|
|
data: { name: `HP1 ${timestamp}`, normalizedName: `hp1_${timestamp}`.toLowerCase(), currentElo: 1500 },
|
|
});
|
|
const p2 = await prisma.player.create({
|
|
data: { name: `HP2 ${timestamp}`, normalizedName: `hp2_${timestamp}`.toLowerCase(), currentElo: 1480 },
|
|
});
|
|
const p3 = await prisma.player.create({
|
|
data: { name: `HP3 ${timestamp}`, normalizedName: `hp3_${timestamp}`.toLowerCase(), currentElo: 1450 },
|
|
});
|
|
const p4 = await prisma.player.create({
|
|
data: { name: `HP4 ${timestamp}`, normalizedName: `hp4_${timestamp}`.toLowerCase(), currentElo: 1420 },
|
|
});
|
|
|
|
await prisma.match.create({
|
|
data: {
|
|
eventId: tournament.id,
|
|
player1P1Id: p1.id,
|
|
player1P2Id: p2.id,
|
|
player2P1Id: p3.id,
|
|
player2P2Id: p4.id,
|
|
team1Score: 10,
|
|
team2Score: 5,
|
|
status: 'completed',
|
|
playedAt: new Date(),
|
|
},
|
|
});
|
|
});
|