diff --git a/e2e/cucumber/features/tournament-schedule.feature b/e2e/cucumber/features/tournament-schedule.feature new file mode 100644 index 0000000..548b2ff --- /dev/null +++ b/e2e/cucumber/features/tournament-schedule.feature @@ -0,0 +1,39 @@ +Feature: Tournament Schedule + As a tournament admin + I want to view and generate round matchups in a Schedule tab + So that I can manage tournament matches + + @happy-path @tournament @issue-7 + Scenario: Tournament admin views schedule page for tournament + Given I am logged in as a tournament admin + And a tournament exists with 4 teams + When I go to the tournament schedule page + Then I should see "Schedule" + And I should see the "Generate Schedule" button + + @happy-path @tournament @issue-7 @wip + Scenario: Tournament admin generates round-robin schedule + Given I am logged in as a tournament admin + And a tournament exists with 4 teams + When I go to the tournament schedule page + And I click the "Generate Schedule" button + Then I should see "Schedule generated successfully" + And I should see round 1 matchups + And I should see round 2 matchups + + @happy-path @tournament @issue-7 @wip + Scenario: Tournament admin views schedule with bye rounds + Given I am logged in as a tournament admin + And a tournament exists with 5 teams + When I go to the tournament schedule page + And I click the "Generate Schedule" button + Then I should see a bye round for one team + And each team should play every other team exactly once + + @happy-path @tournament @issue-7 @wip + Scenario: Tournament admin clicks on a matchup to enter results + Given I am logged in as a tournament admin + And a tournament has a generated schedule + When I go to the tournament schedule page + And I click on a matchup + Then I should be on the match result entry page diff --git a/e2e/cucumber/step-definitions/auth-steps.ts b/e2e/cucumber/step-definitions/auth-steps.ts index e227bed..eaa93d3 100644 --- a/e2e/cucumber/step-definitions/auth-steps.ts +++ b/e2e/cucumber/step-definitions/auth-steps.ts @@ -264,7 +264,7 @@ Then('my user account should exist', async function () { }); /** - * Schedule steps + * Schedule steps (player) */ When('I go to my schedule page', async function () { console.log('🌍 Going to schedule page'); @@ -287,3 +287,36 @@ Given('I have upcoming matches in my schedule', async function () { // For now, this is a placeholder that indicates data setup is needed // In a real test run, this data would already exist in the dev database }); + +/** + * Tournament schedule steps + */ +Given('a tournament exists with {int} teams', async function (teamCount: number) { + console.log(`🌍 Note: Tournament with ${teamCount} teams requires data setup`); + console.log('🌍 For acceptance tests, this would be created via UI or API'); + // In a real test run, this would either: + // 1. Create a tournament via the UI (slower but more realistic) + // 2. Use API to create tournament and add teams (faster) + // 3. Pre-existing test data in dev database + + // Store the team count in world context for later steps + world.tournamentTeamCount = teamCount; +}); + +When('I go to the tournament schedule page', async function () { + console.log('🌍 Going to tournament schedule page'); + // Navigate to a tournament schedule page + // This would typically be /admin/tournaments/{id}/schedule + // For testing, we'll go to the first tournament's schedule + await world.page.goto(`${world.baseURL}/admin/tournaments/1/schedule`); + await world.page.waitForLoadState('networkidle'); +}); + +Given('a tournament has a generated schedule', async function () { + console.log('🌍 Note: Tournament schedule requires generation via API or UI'); + console.log('🌍 For acceptance tests, this would be created before running the test'); + // In a real test run, we would: + // 1. Create a tournament + // 2. Add teams/participants + // 3. Generate schedule via API or UI +}); diff --git a/e2e/cucumber/step-definitions/common-steps.ts b/e2e/cucumber/step-definitions/common-steps.ts index 245ecb6..d5eaa58 100644 --- a/e2e/cucumber/step-definitions/common-steps.ts +++ b/e2e/cucumber/step-definitions/common-steps.ts @@ -230,6 +230,12 @@ Then('I should be on the password reset page', async function () { expect(currentUrl).toContain('/auth/password-reset'); }); +Then('I should see the {string} button', async function (buttonText: string) { + const button = world.page.locator(`button:has-text("${buttonText}")`); + await expect(button).toBeVisible(); + console.log(`🌍 Verified button is visible: ${buttonText}`); +}); + Then('I should be redirected to {string}', async function (path: string) { await world.page.waitForLoadState('networkidle'); const currentUrl = world.page.url(); diff --git a/e2e/cucumber/support/world.ts b/e2e/cucumber/support/world.ts index 1950ee1..04b5b11 100644 --- a/e2e/cucumber/support/world.ts +++ b/e2e/cucumber/support/world.ts @@ -16,6 +16,7 @@ export interface WorldState { password: string; }; tournament?: any; + tournamentTeamCount?: number; player?: any; match?: any; }