bdd tests

This commit is contained in:
2026-01-21 23:46:48 +01:00
parent 5ed958281d
commit 959b99cb58
59 changed files with 17493 additions and 0 deletions

View File

@@ -0,0 +1,145 @@
# Leaderboards BDD E2E Tests
This directory contains BDD (Behavior-Driven Development) E2E tests for the leaderboards functionality in GridPilot.
## Test Coverage
### 1. Global Leaderboards Page (`leaderboards-main.spec.ts`)
Tests the main leaderboards page at `/leaderboards` that displays:
- Global driver rankings (top performers)
- Global team rankings (top teams)
- Navigation to detailed driver/team leaderboards
- Leaderboard filtering and sorting options
- Leaderboard data accuracy and consistency
**Key Scenarios:**
- User sees global driver rankings
- User sees global team rankings
- User can navigate to detailed driver leaderboard
- User can navigate to detailed team leaderboard
- User can click on driver/team entries to view profiles
- Leaderboards display with consistent ranking order
- Leaderboards display with accurate data
- Leaderboards handle errors gracefully
- Leaderboards show loading states
- Leaderboards have proper SEO metadata
- Leaderboards are accessible
### 2. Driver Rankings Page (`leaderboards-drivers.spec.ts`)
Tests the detailed driver rankings page at `/leaderboards/drivers` that displays:
- Comprehensive list of all registered drivers
- Driver search and filtering functionality
- Driver sorting options (by rating, name, rank, etc.)
- Pagination for large driver lists
- Driver cards with detailed information
- Driver profile navigation
**Key Scenarios:**
- User sees a comprehensive list of all drivers
- User can search for drivers by name
- User can filter drivers by rating range
- User can filter drivers by team
- User can sort drivers by different criteria
- User sees pagination controls when there are many drivers
- User sees empty states when no drivers match search
- User sees empty states when no drivers exist
- User can clear search and filters
- User sees driver count information
- User sees driver cards with consistent information
- User can click on driver cards to view profiles
- User sees driver rankings with accurate data
- User sees driver rankings with proper error handling
- User sees driver rankings with loading states
- User sees driver rankings with SEO metadata
- User sees driver rankings with proper accessibility
### 3. Team Rankings Page (`leaderboards-teams.spec.ts`)
Tests the detailed team rankings page at `/leaderboards/teams` that displays:
- Comprehensive list of all registered teams
- Team search and filtering functionality
- Team sorting options (by rating, name, rank, member count, etc.)
- Pagination for large team lists
- Team cards with detailed information
- Team profile navigation
**Key Scenarios:**
- User sees a comprehensive list of all teams
- User can search for teams by name
- User can filter teams by rating range
- User can filter teams by member count
- User can sort teams by different criteria
- User sees pagination controls when there are many teams
- User sees empty states when no teams match search
- User sees empty states when no teams exist
- User can clear search and filters
- User sees team count information
- User sees team cards with consistent information
- User can click on team cards to view profiles
- User sees team rankings with accurate data
- User sees team rankings with proper error handling
- User sees team rankings with loading states
- User sees team rankings with SEO metadata
- User sees team rankings with proper accessibility
## Test Structure
All tests follow the BDD pattern:
- **Given**: Setup the initial state
- **When**: Perform the action
- **Then**: Verify the outcome
Each test file includes:
- Comprehensive test descriptions
- TODO comments indicating what needs to be implemented
- Proper Playwright test structure
- Focus on user outcomes, not visual implementation
## Implementation Notes
### What Needs to Be Implemented
Each test file contains TODO comments that need to be implemented:
1. Navigation setup in `beforeEach` hooks
2. Actual test logic for each scenario
3. Assertions to verify outcomes
4. Test data setup if needed
### Test Data Requirements
Tests may require:
- Registered drivers with various ratings and teams
- Registered teams with various ratings and member counts
- Searchable data for filtering tests
- Pagination data for large lists
### Environment Setup
Tests should run against:
- A running instance of the GridPilot website
- A database with test data
- The full stack (Docker containers)
## Running Tests
```bash
# Run all leaderboards tests
npx playwright test tests/e2e/bdd/leaderboards/
# Run specific test file
npx playwright test tests/e2e/bdd/leaderboards/leaderboards-main.spec.ts
# Run with UI
npx playwright test tests/e2e/bdd/leaderboards/ --ui
```
## Test Philosophy
These tests follow the BDD testing concept:
- **Focus on outcomes**: Tests validate what the user sees and can verify
- **Gherkin syntax**: Tests use Given/When/Then structure
- **User-centric**: Tests describe user journeys and acceptance criteria
- **Not visual**: Tests don't verify pixel-perfect implementation
- **End-to-end**: Tests validate the complete user flow
## Related Files
- [`plans/bdd_testing_concept.md`](../../../plans/bdd_testing_concept.md) - BDD testing philosophy and guidelines
- [`apps/website/app/leaderboards/`](../../../apps/website/app/leaderboards/) - Leaderboards implementation
- [`tests/e2e/bdd/`](../) - Other BDD E2E tests

View File

@@ -0,0 +1,194 @@
/**
* BDD E2E Test: Driver Rankings Page
*
* Tests the detailed driver rankings page that displays:
* - Comprehensive list of all registered drivers
* - Driver search and filtering functionality
* - Driver sorting options (by rating, name, rank, etc.)
* - Pagination or infinite scroll for large driver lists
* - Driver cards with detailed information
* - Driver profile navigation
*
* Focus: Final user outcomes - what the driver sees and can verify
*/
import { test, expect } from '@playwright/test';
test.describe('Driver Rankings Page', () => {
test.beforeEach(async ({ page }) => {
// TODO: Implement navigation to driver rankings page
// - Navigate to /leaderboards/drivers page
// - Verify page loads successfully
// - Verify page title and metadata
});
test('User sees a comprehensive list of all drivers', async ({ page }) => {
// TODO: Implement test
// Scenario: User views all registered drivers
// Given I am on the "Driver Rankings" page
// Then I should see a list of all registered drivers
// And each driver entry should display the driver's rank
// And each driver entry should display the driver's name
// And each driver entry should display the driver's rating
// And each driver entry should display the driver's team affiliation
// And each driver entry should display the driver's race count
});
test('User can search for drivers by name', async ({ page }) => {
// TODO: Implement test
// Scenario: User searches for a specific driver
// Given I am on the "Driver Rankings" page
// When I enter "John" in the search field
// Then I should see drivers whose names contain "John"
// And I should not see drivers whose names do not contain "John"
// And the search results should update in real-time
});
test('User can filter drivers by rating range', async ({ page }) => {
// TODO: Implement test
// Scenario: User filters drivers by rating
// Given I am on the "Driver Rankings" page
// When I set the rating filter to show drivers with rating above 4.0
// Then I should only see drivers with rating >= 4.0
// And drivers with rating < 4.0 should not be visible
// And the filter should update the driver count
});
test('User can filter drivers by team', async ({ page }) => {
// TODO: Implement test
// Scenario: User filters drivers by team
// Given I am on the "Driver Rankings" page
// When I select a specific team from the team filter
// Then I should only see drivers from that team
// And drivers from other teams should not be visible
// And the filter should update the driver count
});
test('User can sort drivers by different criteria', async ({ page }) => {
// TODO: Implement test
// Scenario: User sorts drivers by different attributes
// Given I am on the "Driver Rankings" page
// When I select "Sort by Rating (High to Low)"
// Then the drivers should be displayed in descending order by rating
// When I select "Sort by Name (A-Z)"
// Then the drivers should be displayed in alphabetical order by name
// When I select "Sort by Rank (Low to High)"
// Then the drivers should be displayed in ascending order by rank
});
test('User sees pagination controls when there are many drivers', async ({ page }) => {
// TODO: Implement test
// Scenario: User navigates through multiple pages of drivers
// Given there are more than 20 drivers registered
// And I am on the "Driver Rankings" page
// Then I should see pagination controls
// And I should see the current page number
// And I should be able to navigate to the next page
// And I should see different drivers on the next page
});
test('User sees empty state when no drivers match the search', async ({ page }) => {
// TODO: Implement test
// Scenario: User searches for a non-existent driver
// Given I am on the "Driver Rankings" page
// When I search for "NonExistentDriver123"
// Then I should see an empty state message
// And I should see a message indicating no drivers were found
});
test('User sees empty state when no drivers exist in the system', async ({ page }) => {
// TODO: Implement test
// Scenario: System has no registered drivers
// Given the system has no registered drivers
// And I am on the "Driver Rankings" page
// Then I should see an empty state message
// And I should see a message indicating no drivers are registered
});
test('User can clear search and filters to see all drivers again', async ({ page }) => {
// TODO: Implement test
// Scenario: User clears search and filters
// Given I am on the "Driver Rankings" page
// And I have applied a search filter
// When I click the "Clear Filters" button
// Then I should see all drivers again
// And the search field should be empty
// And all filters should be reset
});
test('User sees driver count information', async ({ page }) => {
// TODO: Implement test
// Scenario: User views driver count
// Given I am on the "Driver Rankings" page
// Then I should see the total number of drivers
// And I should see the number of drivers currently displayed
// And I should see the number of drivers matching any active filters
});
test('User sees driver cards with consistent information', async ({ page }) => {
// TODO: Implement test
// Scenario: User verifies driver card consistency
// Given I am on the "Driver Rankings" page
// Then all driver cards should have the same structure
// And each card should show rank, name, rating, team, and race count
// And all cards should be clickable to navigate to profile
// And all cards should have proper accessibility attributes
});
test('User can click on a driver card to view their profile', async ({ page }) => {
// TODO: Implement test
// Scenario: User navigates to a driver's profile
// Given I am on the "Driver Rankings" page
// When I click on a driver card
// Then I should be redirected to the driver's profile page
// And the URL should contain the driver's ID
});
test('User sees driver rankings with accurate data', async ({ page }) => {
// TODO: Implement test
// Scenario: User verifies driver ranking data accuracy
// Given I am on the "Driver Rankings" page
// Then all driver ratings should be valid numbers
// And all driver ranks should be sequential
// And all driver names should be non-empty strings
// And all team affiliations should be valid
});
test('User sees driver rankings with proper error handling', async ({ page }) => {
// TODO: Implement test
// Scenario: Driver rankings page handles errors gracefully
// Given the driver rankings API returns an error
// When I navigate to the "Driver Rankings" page
// Then I should see an appropriate error message
// And I should see a way to retry loading the rankings
});
test('User sees driver rankings with loading state', async ({ page }) => {
// TODO: Implement test
// Scenario: Driver rankings page shows loading state
// Given I am navigating to the "Driver Rankings" page
// When the page is loading
// Then I should see a loading indicator
// And I should see placeholder content
// And the page should eventually display the rankings
});
test('User sees driver rankings with SEO metadata', async ({ page }) => {
// TODO: Implement test
// Scenario: Driver rankings page has proper SEO
// Given I am on the "Driver Rankings" page
// Then the page title should be "Driver Rankings"
// And the page description should mention driver rankings
// And the page should have proper JSON-LD structured data
});
test('User sees driver rankings with proper accessibility', async ({ page }) => {
// TODO: Implement test
// Scenario: Driver rankings page is accessible
// Given I am on the "Driver Rankings" page
// Then all leaderboards should have proper ARIA labels
// And all interactive elements should be keyboard accessible
// And all images should have alt text
// And the page should have proper heading hierarchy
});
});

View File

@@ -0,0 +1,143 @@
/**
* BDD E2E Test: Global Leaderboards Page
*
* Tests the main leaderboards page that displays:
* - Global driver rankings (top performers)
* - Global team rankings (top teams)
* - Navigation to detailed driver/team leaderboards
* - Leaderboard filtering and sorting options
* - Leaderboard data accuracy and consistency
*
* Focus: Final user outcomes - what the user sees and can verify
*/
import { test, expect } from '@playwright/test';
test.describe('Global Leaderboards Page', () => {
test.beforeEach(async ({ page }) => {
// TODO: Implement navigation to leaderboards page
// - Navigate to /leaderboards page
// - Verify page loads successfully
// - Verify page title and metadata
});
test('User sees global driver rankings on the leaderboards page', async ({ page }) => {
// TODO: Implement test
// Scenario: User views global driver rankings
// Given I am on the "Global Leaderboards" page
// Then I should see a list of top drivers
// And each driver entry should display the driver's rank
// And each driver entry should display the driver's name
// And each driver entry should display the driver's rating
// And each driver entry should display the driver's team affiliation
// And the top 10 drivers should be visible by default
});
test('User sees global team rankings on the leaderboards page', async ({ page }) => {
// TODO: Implement test
// Scenario: User views global team rankings
// Given I am on the "Global Leaderboards" page
// Then I should see a list of top teams
// And each team entry should display the team's rank
// And each team entry should display the team's name
// And each team entry should display the team's rating
// And each team entry should display the team's member count
// And the top 10 teams should be visible by default
});
test('User can navigate to detailed driver leaderboard', async ({ page }) => {
// TODO: Implement test
// Scenario: User navigates to detailed driver rankings
// Given I am on the "Global Leaderboards" page
// When I click on "View All Drivers" or navigate to the drivers section
// Then I should be redirected to the driver rankings page
// And the URL should be /leaderboards/drivers
// And I should see a comprehensive list of all drivers
});
test('User can navigate to detailed team leaderboard', async ({ page }) => {
// TODO: Implement test
// Scenario: User navigates to detailed team rankings
// Given I am on the "Global Leaderboards" page
// When I click on "View All Teams" or navigate to the teams section
// Then I should be redirected to the team rankings page
// And the URL should be /leaderboards/teams
// And I should see a comprehensive list of all teams
});
test('User can click on a driver entry to view their profile', async ({ page }) => {
// TODO: Implement test
// Scenario: User navigates to a driver's profile from leaderboards
// Given I am on the "Global Leaderboards" page
// When I click on a driver entry
// Then I should be redirected to the driver's profile page
// And the URL should contain the driver's ID
});
test('User can click on a team entry to view their profile', async ({ page }) => {
// TODO: Implement test
// Scenario: User navigates to a team's profile from leaderboards
// Given I am on the "Global Leaderboards" page
// When I click on a team entry
// Then I should be redirected to the team's profile page
// And the URL should contain the team's ID
});
test('User sees leaderboards with consistent ranking order', async ({ page }) => {
// TODO: Implement test
// Scenario: User verifies leaderboard ranking consistency
// Given I am on the "Global Leaderboards" page
// Then driver entries should be sorted by rank (1, 2, 3...)
// And team entries should be sorted by rank (1, 2, 3...)
// And no duplicate ranks should appear
// And all ranks should be sequential
});
test('User sees leaderboards with accurate data', async ({ page }) => {
// TODO: Implement test
// Scenario: User verifies leaderboard data accuracy
// Given I am on the "Global Leaderboards" page
// Then all driver ratings should be valid numbers
// And all team ratings should be valid numbers
// And all team member counts should be valid numbers
// And all names should be non-empty strings
});
test('User sees leaderboards with proper error handling', async ({ page }) => {
// TODO: Implement test
// Scenario: Leaderboards page handles errors gracefully
// Given the leaderboards API returns an error
// When I navigate to the "Global Leaderboards" page
// Then I should see an appropriate error message
// And I should see a way to retry loading the leaderboards
});
test('User sees leaderboards with loading state', async ({ page }) => {
// TODO: Implement test
// Scenario: Leaderboards page shows loading state
// Given I am navigating to the "Global Leaderboards" page
// When the page is loading
// Then I should see a loading indicator
// And I should see placeholder content
// And the page should eventually display the leaderboards
});
test('User sees leaderboards with SEO metadata', async ({ page }) => {
// TODO: Implement test
// Scenario: Leaderboards page has proper SEO
// Given I am on the "Global Leaderboards" page
// Then the page title should be "Global Leaderboards"
// And the page description should mention driver and team rankings
// And the page should have proper JSON-LD structured data
});
test('User sees leaderboards with proper accessibility', async ({ page }) => {
// TODO: Implement test
// Scenario: Leaderboards page is accessible
// Given I am on the "Global Leaderboards" page
// Then all leaderboards should have proper ARIA labels
// And all interactive elements should be keyboard accessible
// And all images should have alt text
// And the page should have proper heading hierarchy
});
});

View File

@@ -0,0 +1,196 @@
/**
* BDD E2E Test: Team Rankings Page
*
* Tests the detailed team rankings page that displays:
* - Comprehensive list of all registered teams
* - Team search and filtering functionality
* - Team sorting options (by rating, name, rank, member count, etc.)
* - Pagination or infinite scroll for large team lists
* - Team cards with detailed information
* - Team profile navigation
*
* Focus: Final user outcomes - what the user sees and can verify
*/
import { test, expect } from '@playwright/test';
test.describe('Team Rankings Page', () => {
test.beforeEach(async ({ page }) => {
// TODO: Implement navigation to team rankings page
// - Navigate to /leaderboards/teams page
// - Verify page loads successfully
// - Verify page title and metadata
});
test('User sees a comprehensive list of all teams', async ({ page }) => {
// TODO: Implement test
// Scenario: User views all registered teams
// Given I am on the "Team Rankings" page
// Then I should see a list of all registered teams
// And each team entry should display the team's rank
// And each team entry should display the team's name
// And each team entry should display the team's rating
// And each team entry should display the team's member count
// And each team entry should display the team's race count
});
test('User can search for teams by name', async ({ page }) => {
// TODO: Implement test
// Scenario: User searches for a specific team
// Given I am on the "Team Rankings" page
// When I enter "Racing" in the search field
// Then I should see teams whose names contain "Racing"
// And I should not see teams whose names do not contain "Racing"
// And the search results should update in real-time
});
test('User can filter teams by rating range', async ({ page }) => {
// TODO: Implement test
// Scenario: User filters teams by rating
// Given I am on the "Team Rankings" page
// When I set the rating filter to show teams with rating above 4.0
// Then I should only see teams with rating >= 4.0
// And teams with rating < 4.0 should not be visible
// And the filter should update the team count
});
test('User can filter teams by member count', async ({ page }) => {
// TODO: Implement test
// Scenario: User filters teams by member count
// Given I am on the "Team Rankings" page
// When I set the member count filter to show teams with 5 or more members
// Then I should only see teams with member count >= 5
// And teams with fewer members should not be visible
// And the filter should update the team count
});
test('User can sort teams by different criteria', async ({ page }) => {
// TODO: Implement test
// Scenario: User sorts teams by different attributes
// Given I am on the "Team Rankings" page
// When I select "Sort by Rating (High to Low)"
// Then the teams should be displayed in descending order by rating
// When I select "Sort by Name (A-Z)"
// Then the teams should be displayed in alphabetical order by name
// When I select "Sort by Rank (Low to High)"
// Then the teams should be displayed in ascending order by rank
// When I select "Sort by Member Count (High to Low)"
// Then the teams should be displayed in descending order by member count
});
test('User sees pagination controls when there are many teams', async ({ page }) => {
// TODO: Implement test
// Scenario: User navigates through multiple pages of teams
// Given there are more than 20 teams registered
// And I am on the "Team Rankings" page
// Then I should see pagination controls
// And I should see the current page number
// And I should be able to navigate to the next page
// And I should see different teams on the next page
});
test('User sees empty state when no teams match the search', async ({ page }) => {
// TODO: Implement test
// Scenario: User searches for a non-existent team
// Given I am on the "Team Rankings" page
// When I search for "NonExistentTeam123"
// Then I should see an empty state message
// And I should see a message indicating no teams were found
});
test('User sees empty state when no teams exist in the system', async ({ page }) => {
// TODO: Implement test
// Scenario: System has no registered teams
// Given the system has no registered teams
// And I am on the "Team Rankings" page
// Then I should see an empty state message
// And I should see a message indicating no teams are registered
});
test('User can clear search and filters to see all teams again', async ({ page }) => {
// TODO: Implement test
// Scenario: User clears search and filters
// Given I am on the "Team Rankings" page
// And I have applied a search filter
// When I click the "Clear Filters" button
// Then I should see all teams again
// And the search field should be empty
// And all filters should be reset
});
test('User sees team count information', async ({ page }) => {
// TODO: Implement test
// Scenario: User views team count
// Given I am on the "Team Rankings" page
// Then I should see the total number of teams
// And I should see the number of teams currently displayed
// And I should see the number of teams matching any active filters
});
test('User sees team cards with consistent information', async ({ page }) => {
// TODO: Implement test
// Scenario: User verifies team card consistency
// Given I am on the "Team Rankings" page
// Then all team cards should have the same structure
// And each card should show rank, name, rating, member count, and race count
// And all cards should be clickable to navigate to profile
// And all cards should have proper accessibility attributes
});
test('User can click on a team card to view their profile', async ({ page }) => {
// TODO: Implement test
// Scenario: User navigates to a team's profile
// Given I am on the "Team Rankings" page
// When I click on a team card
// Then I should be redirected to the team's profile page
// And the URL should contain the team's ID
});
test('User sees team rankings with accurate data', async ({ page }) => {
// TODO: Implement test
// Scenario: User verifies team ranking data accuracy
// Given I am on the "Team Rankings" page
// Then all team ratings should be valid numbers
// And all team ranks should be sequential
// And all team names should be non-empty strings
// And all member counts should be valid numbers
});
test('User sees team rankings with proper error handling', async ({ page }) => {
// TODO: Implement test
// Scenario: Team rankings page handles errors gracefully
// Given the team rankings API returns an error
// When I navigate to the "Team Rankings" page
// Then I should see an appropriate error message
// And I should see a way to retry loading the rankings
});
test('User sees team rankings with loading state', async ({ page }) => {
// TODO: Implement test
// Scenario: Team rankings page shows loading state
// Given I am navigating to the "Team Rankings" page
// When the page is loading
// Then I should see a loading indicator
// And I should see placeholder content
// And the page should eventually display the rankings
});
test('User sees team rankings with SEO metadata', async ({ page }) => {
// TODO: Implement test
// Scenario: Team rankings page has proper SEO
// Given I am on the "Team Rankings" page
// Then the page title should be "Team Rankings"
// And the page description should mention team rankings
// And the page should have proper JSON-LD structured data
});
test('User sees team rankings with proper accessibility', async ({ page }) => {
// TODO: Implement test
// Scenario: Team rankings page is accessible
// Given I am on the "Team Rankings" page
// Then all leaderboards should have proper ARIA labels
// And all interactive elements should be keyboard accessible
// And all images should have alt text
// And the page should have proper heading hierarchy
});
});