wip: Tournament schedule tests - 27/30 passing
Pull Request / unit-tests (pull_request) Successful in 57s
Pull Request / e2e-tests (pull_request) Failing after 1m49s
Pull Request / analyze-bump-type (pull_request) Has been skipped

Progress on issue #7 - tournament schedule e2e tests:
- Created ScheduleDisplay component with clickthrough to matches
- Updated ScheduleGenerator to use router.refresh() instead of window.location.reload()
- Fixed step definitions to handle page hydration and reloads
- Fixed database cleanup hook to use Prisma API instead of raw SQL
- Added test IDs and logging for debugging
- Updated feature file to match actual UI behavior

27/30 scenarios passing:
- All auth and navigation scenarios pass
- Scenario 1 (view schedule page) passes
- Scenarios 2-4 (generate schedule, view rounds, click matchup) need investigation

Remaining issues:
1. Page refresh not picking up newly generated schedule data
2. Round data not visible after 'Generated' message
3. Matchup elements not found after refresh
4. Database cleanup hook needs proper handling of foreign keys

Next steps:
1. Investigate why router.refresh() and explicit reload don't show new data
2. Check if there's a caching issue in the production build
3. Verify database transactions are committing correctly
4. Add more logging to trace data flow
This commit is contained in:
2026-04-27 00:29:38 -07:00
parent 799f5e1c63
commit 9353ab1edc
9 changed files with 223 additions and 53 deletions
+86 -17
View File
@@ -357,19 +357,33 @@ Given('a tournament exists with {int} teams', async function (teamCount: number)
// Get Prisma client
const prisma = await world.getPrisma();
const timestamp = Date.now();
// Find or create a tournament
let tournament = await prisma.event.findFirst({
orderBy: { createdAt: 'desc' },
// Always create a new tournament for test isolation
const tournament = await prisma.event.create({
data: {
name: `Test Tournament ${timestamp}`,
createdAt: new Date(),
},
});
if (!tournament) {
// Create a new tournament if none exists
const timestamp = Date.now();
tournament = await prisma.event.create({
// Create players and add them as participants
for (let i = 1; i <= teamCount; i++) {
const player = await prisma.player.create({
data: {
name: `Test Tournament ${timestamp}`,
createdAt: new Date(),
name: `Tournament Player ${i} ${timestamp}`,
normalizedName: `tournament player ${i} ${timestamp}`,
currentElo: 1000,
gamesPlayed: 0,
wins: 0,
losses: 0,
},
});
await prisma.eventParticipant.create({
data: {
eventId: tournament.id,
playerId: player.id,
},
});
}
@@ -377,23 +391,78 @@ Given('a tournament exists with {int} teams', async function (teamCount: number)
world.tournament = tournament;
world.tournamentTeamCount = teamCount;
console.log(`🌍 Using tournament: ${tournament.name} (ID: ${tournament.id})`);
console.log(`🌍 Created tournament: ${tournament.name} (ID: ${tournament.id}) with ${teamCount} teams`);
});
When('I go to the tournament schedule page', async function () {
console.log('🌍 Going to tournament schedule page');
const tournamentId = world.tournament?.id || 1;
await world.page.goto(`${world.baseURL}/admin/tournaments/${tournamentId}/schedule`);
await world.page.waitForLoadState('domcontentloaded');
await world.page.waitForLoadState('load');
// Wait for client components to hydrate
await world.page.waitForTimeout(1000);
});
Given('a tournament has a generated schedule', async function () {
console.log('🌍 Note: Tournament schedule requires generation via API or UI');
console.log('🌍 For acceptance tests, this would be created before running the test');
// In a real test run, we would:
// 1. Create a tournament
// 2. Add teams/participants
// 3. Generate schedule via API or UI
console.log('🌍 Creating tournament with generated schedule');
const prisma = await world.getPrisma();
const timestamp = Date.now();
// Create a tournament
const tournament = await prisma.event.create({
data: {
name: `Test Schedule Tournament ${timestamp}`,
createdAt: new Date(),
},
});
// Create 4 players and add them as participants
const players = [];
for (let i = 1; i <= 4; i++) {
const player = await prisma.player.create({
data: {
name: `Schedule Player ${i} ${timestamp}`,
normalizedName: `schedule player ${i} ${timestamp}`,
currentElo: 1000,
gamesPlayed: 0,
wins: 0,
losses: 0,
},
});
players.push(player);
await prisma.eventParticipant.create({
data: {
eventId: tournament.id,
playerId: player.id,
},
});
}
// Generate schedule via API
const response = await fetch(`${world.baseURL}/api/tournaments/${tournament.id}/schedule`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
});
if (!response.ok) {
console.log('🌍 Failed to generate schedule:', response.status, response.statusText);
// Try to get error details
try {
const errorData = await response.json();
console.log('🌍 Error details:', errorData);
} catch {
// Ignore
}
} else {
const data = await response.json();
console.log('🌍 Schedule generated:', data);
}
world.tournament = tournament;
world.tournamentTeamCount = 4;
console.log(`🌍 Tournament with schedule created: ${tournament.name} (ID: ${tournament.id})`);
});
Given('there are recent activities in the system', async function () {