4.0 KiB
4.0 KiB
League Pages Testing Strategy
1. API Tests
League Discovery (/leagues/all-with-capacity-and-scoring)
- Data Returned: List of leagues with capacity, scoring summary, and basic info.
- Validation Rules:
totalCountmust match array length.usedSlotsmust be <=maxDrivers.scoringobject must containgameIdandscoringPresetId.
- Edge Cases:
- Empty league list.
- Leagues with 0 capacity.
- Leagues with missing scoring config.
League Detail (/leagues/{leagueId})
- Data Returned: Comprehensive league details including stats and status.
- Validation Rules:
idmust match requested ID.ratingshould be a number between 0-100 (if present).seasonStatusmust be one of the valid enum values.
- Edge Cases:
- Invalid
leagueId. - Private league access (should return 403/404).
- Invalid
League Schedule (/leagues/{leagueId}/schedule)
- Data Returned: List of races for the current/specified season.
- Validation Rules:
- Races must be sorted by
scheduledAt. - Each race must have a
trackandcar.
- Races must be sorted by
- Edge Cases:
- Season with no races.
- Unpublished schedule (check visibility for non-admins).
League Standings (/leagues/{leagueId}/standings)
- Data Returned: Driver standings with points, positions, and stats.
- Validation Rules:
positionmust be sequential starting from 1.pointsmust be non-negative.racescount must be <= total completed races in league.
- Edge Cases:
- Tie in points (check tie-breaking logic).
- Drivers with 0 points.
- Empty standings (new season).
League Roster (/leagues/{leagueId}/memberships)
- Data Returned: List of members and their roles.
- Validation Rules:
- At least one 'owner' must exist.
joinedAtmust be a valid ISO date.
- Edge Cases:
- League with only an owner.
2. E2E Tests for League Pages
/leagues (Discovery)
- Click Path: Home -> "Leagues" in Nav.
- Validation:
- Verify league cards display correct
usedSlotsvsmaxDrivers. - Verify "Join" button visibility based on capacity and membership status.
- Verify league cards display correct
/leagues/[id] (Overview)
- Click Path: League Card -> Click Title.
- Validation:
- Verify "Stats" (Members, Races, Avg SOF) match API values.
- Verify "Next Race" widget shows the correct upcoming race.
- Verify "Season Progress" bar reflects completed vs total races.
/leagues/[id]/schedule (Schedule)
- Click Path: League Detail -> "Schedule" Tab.
- Validation:
- Verify race list matches API
/scheduleendpoint. - Verify "Register" button state for upcoming races.
- Verify race list matches API
/leagues/[id]/standings (Standings)
- Click Path: League Detail -> "Standings" Tab.
- Validation:
- Verify table rows match API
/standingsdata. - Verify current user is highlighted (if logged in and in standings).
- Critical: Cross-check total points in UI with sum of race points (if available).
- Verify table rows match API
3. Unit Tests for ViewDataBuilders
LeagueDetailViewDataBuilder
- Transformations: Aggregates league, owner, and race data into a flat view model.
- Validation:
avgSOFcalculation logic (ignoring 0/null SOF).seasonProgresspercentage calculation.- Role badge assignment (Owner vs Admin vs Steward).
- Edge Cases:
- Missing owner data.
- No races scheduled.
LeagueStandingsViewDataBuilder
- Transformations: Maps
LeagueStandingDTOtoStandingEntryData. - Validation:
- Correct mapping of
pointstototalPoints. - Handling of
positionChange(up/down/stable). - Driver metadata mapping (name, country).
- Correct mapping of
- Edge Cases:
- Missing driver objects in standings DTO.
- Empty standings array.
LeagueScheduleViewDataBuilder
- Transformations: Groups races by status or month.
- Validation:
- Date formatting for UI.
- "Live" status detection based on current time.
- Edge Cases:
- Races exactly at "now".