Compare commits
4 Commits
v0.1.7
..
98e7b5c462
| Author | SHA1 | Date | |
|---|---|---|---|
| 98e7b5c462 | |||
| 36339d7914 | |||
| 2759c08a96 | |||
| efd1c0e975 |
@@ -1,3 +1,9 @@
|
|||||||
|
## [0.1.8] - 2026-04-27
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- test: migrate rankings and home-page tests from Playwright to Cucumber
|
||||||
|
|
||||||
## [0.1.7] - 2026-04-27
|
## [0.1.7] - 2026-04-27
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
Feature: Home Page
|
||||||
|
As a visitor
|
||||||
|
I want to see the home page
|
||||||
|
So that I can learn about the club and view player rankings
|
||||||
|
|
||||||
|
@happy-path @public @home
|
||||||
|
Scenario: Home page displays Top 10 Players
|
||||||
|
Given I am on the home page
|
||||||
|
Then I should see "Top 10 Players"
|
||||||
|
And I should see a rankings table
|
||||||
|
|
||||||
|
@happy-path @public @home
|
||||||
|
Scenario: Home page displays club information
|
||||||
|
Given I am on the home page
|
||||||
|
Then I should see "Club Information"
|
||||||
|
And I should see "Club President"
|
||||||
|
|
||||||
|
@happy-path @public @home
|
||||||
|
Scenario: Home page displays most recent tournament
|
||||||
|
Given I am on the home page
|
||||||
|
Then I should see "Most Recent Tournament"
|
||||||
|
|
||||||
|
@happy-path @public @home
|
||||||
|
Scenario: Home page has sign in and create account links
|
||||||
|
Given I am on the home page
|
||||||
|
Then I should see "Sign In"
|
||||||
|
And I should see "Create Account"
|
||||||
@@ -9,7 +9,7 @@ Feature: Player Schedule
|
|||||||
When I go to my schedule page
|
When I go to my schedule page
|
||||||
Then I should see "No upcoming matches"
|
Then I should see "No upcoming matches"
|
||||||
|
|
||||||
@happy-path @player-features @issue-9 @wip
|
@happy-path @player-features @issue-9
|
||||||
Scenario: Player views schedule with upcoming matches
|
Scenario: Player views schedule with upcoming matches
|
||||||
Given I am logged in as a player
|
Given I am logged in as a player
|
||||||
And I have upcoming matches in my schedule
|
And I have upcoming matches in my schedule
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
Feature: Rankings Page
|
||||||
|
As a visitor
|
||||||
|
I want to view player rankings
|
||||||
|
So that I can see top players and their statistics
|
||||||
|
|
||||||
|
@happy-path @public @rankings
|
||||||
|
Scenario: Rankings page loads and displays rankings table
|
||||||
|
When I go to the rankings page
|
||||||
|
Then I should see "Player Rankings" in the page heading
|
||||||
|
And I should see a rankings table
|
||||||
|
|
||||||
|
@happy-path @public @rankings
|
||||||
|
Scenario: Rankings table displays player columns
|
||||||
|
When I go to the rankings page
|
||||||
|
Then I should see a rankings table with columns
|
||||||
|
And the table should have column headers
|
||||||
|
|
||||||
|
@happy-path @public @rankings
|
||||||
|
Scenario: Rankings page is publicly accessible (no login required)
|
||||||
|
Given I am not logged in
|
||||||
|
When I go to the rankings page
|
||||||
|
Then I should be on the rankings page
|
||||||
|
And I should see the rankings table
|
||||||
@@ -337,16 +337,67 @@ When('I go to my schedule page', async function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Given('I have upcoming matches in my schedule', async function () {
|
Given('I have upcoming matches in my schedule', async function () {
|
||||||
console.log('🌍 Note: This step requires database setup via API or UI');
|
console.log('🌍 Setting up upcoming matches in schedule');
|
||||||
console.log('🌍 For acceptance tests, this would be set up before running the test');
|
const prisma = await world.getPrisma();
|
||||||
// For true acceptance testing, we would:
|
const timestamp = Date.now();
|
||||||
// 1. Create a tournament
|
|
||||||
// 2. Add the player as a participant
|
|
||||||
// 3. Generate a schedule
|
|
||||||
// 4. The match would then appear in the player's schedule
|
|
||||||
|
|
||||||
// For now, this is a placeholder that indicates data setup is needed
|
// Get the current player
|
||||||
// In a real test run, this data would already exist in the dev database
|
if (!world.playerId) {
|
||||||
|
throw new Error('No player ID found. Make sure user is logged in as a player first.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentPlayerId = parseInt(world.playerId, 10);
|
||||||
|
|
||||||
|
// Create 3 other players for the match
|
||||||
|
const opponent1 = await prisma.player.create({
|
||||||
|
data: {
|
||||||
|
name: `Opponent ${timestamp} 1`,
|
||||||
|
normalizedName: `opponent ${timestamp} 1`,
|
||||||
|
currentElo: 1000,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const opponent2 = await prisma.player.create({
|
||||||
|
data: {
|
||||||
|
name: `Opponent ${timestamp} 2`,
|
||||||
|
normalizedName: `opponent ${timestamp} 2`,
|
||||||
|
currentElo: 1000,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const partner1 = await prisma.player.create({
|
||||||
|
data: {
|
||||||
|
name: `Partner ${timestamp}`,
|
||||||
|
normalizedName: `partner ${timestamp}`,
|
||||||
|
currentElo: 1000,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a tournament
|
||||||
|
const tournament = await prisma.event.create({
|
||||||
|
data: {
|
||||||
|
name: `Test Schedule Tournament ${timestamp}`,
|
||||||
|
eventDate: new Date(Date.now() + 86400000), // Tomorrow
|
||||||
|
status: 'planned',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a match with the current player as player1P1 (played tomorrow)
|
||||||
|
await prisma.match.create({
|
||||||
|
data: {
|
||||||
|
eventId: tournament.id,
|
||||||
|
player1P1Id: currentPlayerId,
|
||||||
|
player1P2Id: partner1.id,
|
||||||
|
player2P1Id: opponent1.id,
|
||||||
|
player2P2Id: opponent2.id,
|
||||||
|
team1Score: 10,
|
||||||
|
team2Score: 5,
|
||||||
|
status: 'completed',
|
||||||
|
playedAt: new Date(Date.now() + 86400000), // Tomorrow
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`🌍 Created tournament "${tournament.name}" with 1 match for player ${currentPlayerId}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -551,3 +551,98 @@ Then('the settings should be saved successfully', async function () {
|
|||||||
await expect(world.page.locator('text=Settings saved successfully')).toBeVisible();
|
await expect(world.page.locator('text=Settings saved successfully')).toBeVisible();
|
||||||
console.log('🌍 Verified settings were saved successfully');
|
console.log('🌍 Verified settings were saved successfully');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Rankings Page Steps
|
||||||
|
When('I go to the rankings page', async function () {
|
||||||
|
console.log('🌍 Going to rankings page');
|
||||||
|
await world.page.goto(`${world.baseURL}/rankings`);
|
||||||
|
await world.page.waitForLoadState('domcontentloaded');
|
||||||
|
});
|
||||||
|
|
||||||
|
Then('I should see {string} in the page heading', async function (heading: string) {
|
||||||
|
// Use a more flexible selector that matches text content
|
||||||
|
await expect(world.page.locator(`text=${heading}`)).toBeVisible();
|
||||||
|
console.log(`🌍 Verified heading "${heading}" is visible`);
|
||||||
|
});
|
||||||
|
|
||||||
|
Then('I should see a rankings table', async function () {
|
||||||
|
await expect(world.page.locator('table')).toBeVisible();
|
||||||
|
console.log('🌍 Verified rankings table is visible');
|
||||||
|
});
|
||||||
|
|
||||||
|
Then('I should see a rankings table with columns', async function () {
|
||||||
|
const table = world.page.locator('table');
|
||||||
|
await expect(table).toBeVisible();
|
||||||
|
const headerCount = await world.page.locator('th').count();
|
||||||
|
expect(headerCount).toBeGreaterThan(0);
|
||||||
|
console.log(`🌍 Verified rankings table has ${headerCount} columns`);
|
||||||
|
});
|
||||||
|
|
||||||
|
Then('the table should have column headers', async function () {
|
||||||
|
const headerCount = await world.page.locator('th').count();
|
||||||
|
expect(headerCount).toBeGreaterThan(0);
|
||||||
|
console.log(`🌍 Verified table has ${headerCount} column headers`);
|
||||||
|
});
|
||||||
|
|
||||||
|
Given('I am not logged in', async function () {
|
||||||
|
// This is just a documentation step - the test environment starts fresh
|
||||||
|
console.log('🌍 User is not logged in (fresh session)');
|
||||||
|
});
|
||||||
|
|
||||||
|
Then('I should be on the rankings page', async function () {
|
||||||
|
const currentUrl = world.page.url();
|
||||||
|
console.log(`🌍 Checking current URL: ${currentUrl}`);
|
||||||
|
expect(currentUrl).toContain('/rankings');
|
||||||
|
});
|
||||||
|
|
||||||
|
Then('I should see the rankings table', async function () {
|
||||||
|
await expect(world.page.locator('table')).toBeVisible();
|
||||||
|
console.log('🌍 Verified rankings table is visible');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Player Schedule Steps
|
||||||
|
Then('I should see the match date', async function () {
|
||||||
|
// Check for a date-like pattern on the page
|
||||||
|
const content = await world.page.content();
|
||||||
|
const hasDate = content.match(/\d{1,2}\/\d{1,2}\/\d{4}/) || content.match(/\w+ \d{1,2}, \d{4}/);
|
||||||
|
expect(hasDate).toBeTruthy();
|
||||||
|
console.log('🌍 Verified match date is visible');
|
||||||
|
});
|
||||||
|
|
||||||
|
Then('I should see my opponent\'s name', async function () {
|
||||||
|
// Check for opponent text on the page
|
||||||
|
const content = await world.page.content();
|
||||||
|
const hasOpponent = content.includes('Opponent');
|
||||||
|
expect(hasOpponent).toBe(true);
|
||||||
|
console.log('🌍 Verified opponent name is visible');
|
||||||
|
});
|
||||||
|
|
||||||
|
Then('I should see my partner\'s name', async function () {
|
||||||
|
// Check for partner text on the page
|
||||||
|
const content = await world.page.content();
|
||||||
|
const hasPartner = content.includes('Partner');
|
||||||
|
expect(hasPartner).toBe(true);
|
||||||
|
console.log('🌍 Verified partner name is visible');
|
||||||
|
});
|
||||||
|
|
||||||
|
Then('I should see the tournament name', async function () {
|
||||||
|
// Check for tournament name on the page
|
||||||
|
const content = await world.page.content();
|
||||||
|
const hasTournament = content.includes('Test Schedule Tournament');
|
||||||
|
expect(hasTournament).toBe(true);
|
||||||
|
console.log('🌍 Verified tournament name is visible');
|
||||||
|
});
|
||||||
|
|
||||||
|
When('I click on a match', async function () {
|
||||||
|
// Click on the first match link
|
||||||
|
const matchLink = world.page.locator('a[href*="/matches/"]').first();
|
||||||
|
await matchLink.click();
|
||||||
|
await world.page.waitForLoadState('domcontentloaded');
|
||||||
|
console.log('🌍 Clicked on match');
|
||||||
|
});
|
||||||
|
|
||||||
|
Then('I should be on the match detail page', async function () {
|
||||||
|
const currentUrl = world.page.url();
|
||||||
|
console.log(`🌍 Checking current URL: ${currentUrl}`);
|
||||||
|
expect(currentUrl).toMatch(/\/matches\/\d+/);
|
||||||
|
});
|
||||||
|
|||||||
@@ -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();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -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] } },
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "euchre_camp",
|
"name": "euchre_camp",
|
||||||
"version": "0.1.7",
|
"version": "0.1.8",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "NEXT_PUBLIC_GIT_COMMIT=$(git rev-parse --short HEAD) next dev",
|
"dev": "NEXT_PUBLIC_GIT_COMMIT=$(git rev-parse --short HEAD) next dev",
|
||||||
|
|||||||
Reference in New Issue
Block a user