feat: Implement tournament schedule tab and fix E2E tests (#27)
## Summary This PR implements the tournament schedule tab functionality and fixes all remaining E2E test failures. ### Changes Included 1. **Tournament Schedule Feature** - Added tournament schedule page at `/admin/tournaments/[id]/schedule` - Implemented "Generate Schedule" button functionality - Added schedule generation logic for round-robin tournaments 2. **E2E Test Fixes** - Fixed database connection issues in production builds - Improved test reliability with better error handling and debugging - Updated test infrastructure to use environment variables instead of hardcoded values 3. **CI/CD Updates** - Added E2E test job to PR workflow - Configured tests to run against development database - Moved database password to Gitea secrets 4. **Code Quality** - Removed hardcoded passwords from codebase - Improved Prisma client configuration - Enhanced authentication and navigation components ### Test Results All 16 E2E test scenarios are now passing: - Authentication tests: ✅ - Registration tests: ✅ - Tournament schedule tests: ✅ - Player schedule tests: ✅ - Admin navigation tests: ✅ ### Database Configuration - Tests run against `euchre_camp_dev` database - Production builds use environment variables for database configuration - Database password stored in Gitea secrets as `DB_PASSWORD` ### CI Pipeline The PR workflow now includes: 1. Unit tests 2. E2E tests (using production build) 3. Version bump analysis E2E tests must pass before PR can be merged. Reviewed-on: #27 Co-authored-by: David Gwilliam <dhgwilliam@gmail.com> Co-committed-by: David Gwilliam <dhgwilliam@gmail.com>
This commit was merged in pull request #27.
This commit is contained in:
+29
-19
@@ -177,10 +177,10 @@ export async function recalculateAllElo(prisma: PrismaClient) {
|
||||
const matches = await prisma.match.findMany({
|
||||
orderBy: { playedAt: 'asc' },
|
||||
include: {
|
||||
team1P1: true,
|
||||
team1P2: true,
|
||||
team2P1: true,
|
||||
team2P2: true,
|
||||
player1P1: true,
|
||||
player1P2: true,
|
||||
player2P1: true,
|
||||
player2P2: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -229,14 +229,24 @@ export async function recalculateAllElo(prisma: PrismaClient) {
|
||||
};
|
||||
|
||||
// Process each match in chronological order
|
||||
console.log('recalculateAllElo: Starting match processing loop');
|
||||
for (const match of matches) {
|
||||
const { team1P1, team1P2, team2P1, team2P2, team1Score, team2Score, id: matchId, playedAt } = match;
|
||||
console.log('recalculateAllElo: Processing match', match.id);
|
||||
const { player1P1, player1P2, player2P1, player2P2, team1Score, team2Score, id: matchId, playedAt } = match;
|
||||
|
||||
// Skip matches with missing players
|
||||
if (!player1P1 || !player1P2 || !player2P1 || !player2P2) {
|
||||
console.log('recalculateAllElo: Skipping match due to missing players');
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log('recalculateAllElo: Match has all players, processing...');
|
||||
|
||||
// Get current ratings for all players
|
||||
const p1Rating = getPlayerStats(team1P1.id).rating;
|
||||
const p2Rating = getPlayerStats(team1P2.id).rating;
|
||||
const p3Rating = getPlayerStats(team2P1.id).rating;
|
||||
const p4Rating = getPlayerStats(team2P2.id).rating;
|
||||
const p1Rating = getPlayerStats(player1P1.id).rating;
|
||||
const p2Rating = getPlayerStats(player1P2.id).rating;
|
||||
const p3Rating = getPlayerStats(player2P1.id).rating;
|
||||
const p4Rating = getPlayerStats(player2P2.id).rating;
|
||||
|
||||
// Calculate team ratings
|
||||
const team1Rating = calculateTeamElo(p1Rating, p2Rating);
|
||||
@@ -261,7 +271,7 @@ export async function recalculateAllElo(prisma: PrismaClient) {
|
||||
const isTie = team1Score === team2Score;
|
||||
|
||||
// Update Player 1 (team 1, player 1)
|
||||
const stats1 = getPlayerStats(team1P1.id);
|
||||
const stats1 = getPlayerStats(player1P1.id);
|
||||
stats1.rating += p1Change;
|
||||
stats1.gamesPlayed += 1;
|
||||
if (isTie) {
|
||||
@@ -273,7 +283,7 @@ export async function recalculateAllElo(prisma: PrismaClient) {
|
||||
}
|
||||
|
||||
// Update Player 2 (team 1, player 2)
|
||||
const stats2 = getPlayerStats(team1P2.id);
|
||||
const stats2 = getPlayerStats(player1P2.id);
|
||||
stats2.rating += p2Change;
|
||||
stats2.gamesPlayed += 1;
|
||||
if (isTie) {
|
||||
@@ -285,7 +295,7 @@ export async function recalculateAllElo(prisma: PrismaClient) {
|
||||
}
|
||||
|
||||
// Update Player 3 (team 2, player 1)
|
||||
const stats3 = getPlayerStats(team2P1.id);
|
||||
const stats3 = getPlayerStats(player2P1.id);
|
||||
stats3.rating += p3Change;
|
||||
stats3.gamesPlayed += 1;
|
||||
if (isTie) {
|
||||
@@ -297,7 +307,7 @@ export async function recalculateAllElo(prisma: PrismaClient) {
|
||||
}
|
||||
|
||||
// Update Player 4 (team 2, player 2)
|
||||
const stats4 = getPlayerStats(team2P2.id);
|
||||
const stats4 = getPlayerStats(player2P2.id);
|
||||
stats4.rating += p4Change;
|
||||
stats4.gamesPlayed += 1;
|
||||
if (isTie) {
|
||||
@@ -309,7 +319,7 @@ export async function recalculateAllElo(prisma: PrismaClient) {
|
||||
}
|
||||
|
||||
// Update partnership stats for team 1
|
||||
const partnership1 = getPartnershipStats(team1P1.id, team1P2.id);
|
||||
const partnership1 = getPartnershipStats(player1P1.id, player1P2.id);
|
||||
partnership1.gamesPlayed += 1;
|
||||
if (isTie) {
|
||||
// For ties, don't increment wins or losses (gamesPlayed is already incremented)
|
||||
@@ -324,7 +334,7 @@ export async function recalculateAllElo(prisma: PrismaClient) {
|
||||
}
|
||||
|
||||
// Update partnership stats for team 2
|
||||
const partnership2 = getPartnershipStats(team2P1.id, team2P2.id);
|
||||
const partnership2 = getPartnershipStats(player2P1.id, player2P2.id);
|
||||
partnership2.gamesPlayed += 1;
|
||||
if (isTie) {
|
||||
// For ties, don't increment wins or losses (gamesPlayed is already incremented)
|
||||
@@ -340,10 +350,10 @@ export async function recalculateAllElo(prisma: PrismaClient) {
|
||||
|
||||
// Create elo snapshots for all players
|
||||
const snapshotData = [
|
||||
{ playerId: team1P1.id, ratingBefore: p1Rating, ratingChange: p1Change },
|
||||
{ playerId: team1P2.id, ratingBefore: p2Rating, ratingChange: p2Change },
|
||||
{ playerId: team2P1.id, ratingBefore: p3Rating, ratingChange: p3Change },
|
||||
{ playerId: team2P2.id, ratingBefore: p4Rating, ratingChange: p4Change },
|
||||
{ playerId: player1P1.id, ratingBefore: p1Rating, ratingChange: p1Change },
|
||||
{ playerId: player1P2.id, ratingBefore: p2Rating, ratingChange: p2Change },
|
||||
{ playerId: player2P1.id, ratingBefore: p3Rating, ratingChange: p3Change },
|
||||
{ playerId: player2P2.id, ratingBefore: p4Rating, ratingChange: p4Change },
|
||||
];
|
||||
|
||||
for (const snapshot of snapshotData) {
|
||||
|
||||
Reference in New Issue
Block a user