-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): improve reliability and maintenance
- test: Remove redundant context cleanup code - test: Improve admin page assertions by replacing timeout waits with explicit checks - test: Split "can edit game settings" test into smaller cases - refactor: Migrate admin/settings/setup tests to TypeScript - refactor: Move admin page tests to dedicated directory
- Loading branch information
1 parent
a9724a9
commit 47bfbc3
Showing
8 changed files
with
211 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import type { Browser } from "@playwright/test"; | ||
import { Setup } from "../lib/Setup.js"; | ||
import { AdminPage } from "../models/AdminPage.js"; | ||
import { GamePage } from "../models/GamePage.js"; | ||
|
||
test("can edit title text", async ({ browser }: { browser: Browser }) => { | ||
const s = new Setup(browser); | ||
const host = await s.host(); | ||
const spectator = await s.addPlayer(true); | ||
const adminPage = new AdminPage(host.page); | ||
const gamePage = new GamePage(spectator.page); | ||
|
||
await adminPage.gameSelector.selectOption({ index: 1 }); | ||
await adminPage.titleTextInput.fill("New Game Title"); | ||
await expect(gamePage.titleLogoImg).toContainText("New Game Title"); | ||
}); | ||
|
||
test("can edit first team name text", async ({ browser }: { browser: Browser }) => { | ||
const s = new Setup(browser); | ||
const host = await s.host(); | ||
const spectator = await s.addPlayer(true); | ||
const adminPage = new AdminPage(host.page); | ||
const gamePage = new GamePage(spectator.page); | ||
|
||
await adminPage.gameSelector.selectOption({ index: 1 }); | ||
await adminPage.teamOneNameInput.fill("Team Alpha"); | ||
await expect(gamePage.getTeamNameByIndex(0)).toContainText("Team Alpha"); | ||
}); | ||
|
||
test("can edit second team name text", async ({ browser }: { browser: Browser }) => { | ||
const s = new Setup(browser); | ||
const host = await s.host(); | ||
const spectator = await s.addPlayer(true); | ||
const adminPage = new AdminPage(host.page); | ||
const gamePage = new GamePage(spectator.page); | ||
|
||
await adminPage.gameSelector.selectOption({ index: 1 }); | ||
await adminPage.teamTwoNameInput.fill("Team Beta"); | ||
await expect(gamePage.getTeamNameByIndex(1)).toContainText("Team Beta"); | ||
}); | ||
|
||
test("can switch themes", async ({ browser }: { browser: Browser }) => { | ||
const s = new Setup(browser); | ||
const host = await s.host(); | ||
const spectator = await s.addPlayer(true); | ||
const adminPage = new AdminPage(host.page); | ||
|
||
await adminPage.gameSelector.selectOption({ index: 1 }); | ||
const themeChanged = spectator.page.waitForFunction(() => document.body.classList.contains("darkTheme"), { | ||
timeout: 10000, | ||
}); | ||
await adminPage.themeSwitcherInput.selectOption({ index: 1 }); | ||
await themeChanged; | ||
await expect(spectator.page.locator("body")).toHaveClass("darkTheme bg-background"); | ||
}); | ||
|
||
test("can hide questions", async ({ browser }: { browser: Browser }) => { | ||
const s = new Setup(browser); | ||
const host = await s.host(); | ||
const spectator = await s.addPlayer(true); | ||
const adminPage = new AdminPage(host.page); | ||
const gamePage = new GamePage(spectator.page); | ||
|
||
await adminPage.gameSelector.selectOption({ index: 1 }); | ||
await adminPage.startRoundOneButton.click(); | ||
await adminPage.hideQuestionsInput.click(); | ||
await expect(gamePage.roundQuestionText).toBeVisible(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.