diff --git a/e2e/epic3-rankings.test.ts b/e2e/epic3-rankings.test.ts deleted file mode 100644 index d3d6afd..0000000 --- a/e2e/epic3-rankings.test.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Epic 3: Rankings & Public Data - * Acceptance Test: Player Rankings Page - * - * User Story: As a visitor, I want to view player rankings so that I can see top players - * - * Acceptance Criteria: - * - Sortable rankings table - * - Columns: Rank, Name, Elo, Win Rate, Games Played - * - Search/filter functionality - * - Pagination - */ - -import { test, expect } from '@playwright/test'; - -test.describe('Epic 3: Rankings Page', () => { - test('Rankings page loads and displays rankings table', async ({ page }) => { - await page.goto('http://localhost:3000/rankings'); - - // Check page title or heading - await expect(page.locator('h1, h2')).toContainText(/rankings?/i); - - // Check for rankings table - await expect(page.locator('table')).toBeVisible(); - }); - - test('Rankings table displays player columns', async ({ page }) => { - await page.goto('http://localhost:3000/rankings'); - - // Check for expected column headers - const table = page.locator('table'); - await expect(table).toBeVisible(); - - // Check for column headers (may vary based on implementation) - const headerCount = await page.locator('th').count(); - expect(headerCount).toBeGreaterThan(0); - }); - - test('Rankings page is publicly accessible (no login required)', async ({ page }) => { - // Navigate directly to rankings without logging in - await page.goto('http://localhost:3000/rankings'); - - // Page should load without redirecting to login - await expect(page).toHaveURL(/.*rankings.*/); - await expect(page.locator('body')).toBeVisible(); - }); -}); diff --git a/e2e/home-page.test.ts b/e2e/home-page.test.ts deleted file mode 100644 index a81ad8e..0000000 --- a/e2e/home-page.test.ts +++ /dev/null @@ -1,126 +0,0 @@ -import { test, expect } from '@playwright/test' -import { prisma } from '@/lib/prisma' -import { createTestPlayer, cleanupTestRecords, getCreatedRecordCounts } from '@/__tests__/test-utils' - -test.describe('Home Page', () => { - test.beforeEach(async () => { - // Clean up any existing test records before each test - await cleanupTestRecords(); - }); - - test.afterEach(async () => { - // Clean up test records after each test - await cleanupTestRecords(); - }); - - test('should display top 10 players', async ({ page }) => { - // Create some test players with unique names and very high Elo to ensure they're in top 10 - const timestamp = Date.now() - const players = [] - for (let i = 0; i < 3; i++) { - const playerName = `Home Test Player ${timestamp} ${i + 1}` - const player = await createTestPlayer({ - name: playerName, - currentElo: 2000 - i * 10, - }) - players.push(player) - } - - // Navigate to home page - await page.goto('/') - - // Check that the page loads - await expect(page.locator('text=Top 10 Players')).toBeVisible() - - // Check that at least one of our test players is displayed - // Use a more specific locator to avoid multiple matches - await expect( - page.locator(`a:has-text("Home Test Player ${timestamp} 1")`) - ).toBeVisible() - - // Verify cleanup will work - const counts = getCreatedRecordCounts(); - expect(counts.players).toBe(3); - }) - - test('should display club president', async ({ page }) => { - const timestamp = Date.now() - // Create a club admin user - const clubAdmin = await prisma.user.create({ - data: { - email: `president-${timestamp}@example.com`, - name: `Club President ${timestamp}`, - role: 'club_admin', - }, - }) - - // Navigate to home page - await page.goto('/') - - // Check that the club president section is visible - await expect(page.locator('text=Club President')).toBeVisible() - - // Clean up - await prisma.user.delete({ where: { id: clubAdmin.id } }) - }) - - test('should display most recent tournament', async ({ page }) => { - const timestamp = Date.now() - // Create a tournament with a future date to ensure it's the most recent - const tournament = await prisma.event.create({ - data: { - name: `Recent Tournament ${timestamp}`, - eventType: 'tournament', - eventDate: new Date(Date.now() + 86400000), // Tomorrow - status: 'completed', - }, - }) - - // Create players for the match - const player1Name = `Home Match Player 1 ${timestamp}` - const player1 = await prisma.player.create({ - data: { name: player1Name, normalizedName: player1Name.toLowerCase(), currentElo: 1500 }, - }) - const player2Name = `Home Match Player 2 ${timestamp}` - const player2 = await prisma.player.create({ - data: { name: player2Name, normalizedName: player2Name.toLowerCase(), currentElo: 1480 }, - }) - const player3Name = `Home Match Player 3 ${timestamp}` - const player3 = await prisma.player.create({ - data: { name: player3Name, normalizedName: player3Name.toLowerCase(), currentElo: 1450 }, - }) - const player4Name = `Home Match Player 4 ${timestamp}` - const player4 = await prisma.player.create({ - data: { name: player4Name, normalizedName: player4Name.toLowerCase(), currentElo: 1420 }, - }) - - // Create a match in the tournament - await prisma.match.create({ - data: { - eventId: tournament.id, - player1P1Id: player1.id, - player1P2Id: player2.id, - player2P1Id: player3.id, - player2P2Id: player4.id, - team1Score: 10, - team2Score: 5, - status: 'completed', - playedAt: new Date(), - }, - }) - - // Navigate to home page - await page.goto('/') - - // Check that the tournament section is visible - await expect(page.locator('text=Most Recent Tournament')).toBeVisible() - await expect(page.locator(`text=Recent Tournament ${timestamp}`)).toBeVisible() - - // Clean up - await prisma.match.deleteMany({ where: { eventId: tournament.id } }) - await prisma.event.delete({ where: { id: tournament.id } }) - await prisma.player.deleteMany({ - where: { id: { in: [player1.id, player2.id, player3.id, player4.id] } }, - }) - }) -})