# Leagues BDD E2E Tests

This directory contains BDD (Behavior-Driven Development) E2E tests for the GridPilot leagues functionality.

## Test Coverage

### 1. Leagues Discovery (`leagues-discovery.spec.ts`)
Tests the leagues discovery page where drivers can find and filter leagues.

**Scenarios:**
- Driver sees list of available leagues
- Driver can search for leagues by name or description
- Driver can filter leagues by category
- Driver can navigate to league details
- Driver can initiate league creation

### 2. League Detail (`league-detail.spec.ts`)
Tests the main league overview page.

**Scenarios:**
- Driver sees league information and statistics
- Driver can join or leave a league
- Driver can navigate to sub-pages (roster, schedule, etc.)
- Admin can access management pages (settings, wallet, etc.)

### 3. League Roster (`league-roster.spec.ts`)
Tests the league member list and management.

**Scenarios:**
- Driver sees list of members and their roles
- Admin can promote/demote members
- Admin can manage membership requests

### 4. League Schedule (`league-schedule.spec.ts`)
Tests the league race schedule and registration.

**Scenarios:**
- Driver sees upcoming and completed races
- Driver can register for or unregister from races
- Admin can manage the race schedule and import results

### 5. League Standings (`league-standings.spec.ts`)
Tests the championship standings and driver statistics.

**Scenarios:**
- Driver sees ranked list of drivers by points
- Driver can sort and filter standings
- Driver sees standings history and trends

### 6. League Creation (`league-create.spec.ts`)
Tests the multi-step league creation wizard.

**Scenarios:**
- Driver can configure basic info, structure, schedule, scoring, and stewarding
- Driver can review and confirm league creation
- Validation of required fields and settings

### 7. League Settings (`league-settings.spec.ts`)
Tests the league administration and configuration.

**Scenarios:**
- Admin can update league info and visibility
- Admin can configure scoring, penalties, and stewarding rules
- Admin can manage the stewarding team
- Admin can archive or delete the league

### 8. League Wallet (`league-wallet.spec.ts`)
Tests the financial management of a league.

**Scenarios:**
- Admin sees balance, revenue, and fees
- Admin views transaction history and filters
- Admin manages payouts and deposits

### 9. League Sponsorships (`league-sponsorships.spec.ts`)
Tests the sponsorship management for leagues.

**Scenarios:**
- Admin manages sponsorship slots and requests
- Admin tracks sponsorship revenue

### 10. League Stewarding (`league-stewarding.spec.ts`)
Tests the protest and penalty management system.

**Scenarios:**
- Steward reviews protests and issues decisions
- Steward manages penalties and appeals
- Steward communicates with drivers regarding incidents

## Test Philosophy

These tests follow the BDD testing concept defined in `plans/bdd_testing_concept.md`:

1. **Focus on Outcomes**: Tests validate final user outcomes, not visual implementation.
2. **Gherkin Syntax**: Tests use Given/When/Then structure in comments.
3. **Acceptance Criteria**: Tests serve as the final source of truth for league functionality.
4. **Playwright**: Tests use Playwright for E2E testing.

## Implementation Notes

- All test files are placeholders with TODO comments.
- Tests should be implemented using Playwright.
- Authentication setup should be shared across tests.
- Tests should validate final user outcomes, not implementation details.
- Tests should be independent and can run in any order.

## Directory Structure

```
tests/e2e/bdd/leagues/
├── leagues-discovery.spec.ts
├── league-detail.spec.ts
├── league-roster.spec.ts
├── league-schedule.spec.ts
├── league-standings.spec.ts
├── league-create.spec.ts
├── league-settings.spec.ts
├── league-wallet.spec.ts
├── league-sponsorships.spec.ts
├── league-stewarding.spec.ts
└── README.md
```
