Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(e2e): create test for hiding player's screens #116

Merged
merged 1 commit into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ dev-down:
docker compose -p famf -f ./docker/${COMPOSE_FILE} down

e2e: dev-background
npm install
cd e2e
npx playwright test
cd -
$(MAKE) dev-down

e2e-ui: dev-background
npm install
cd e2e
npx playwright test --ui
cd -
Expand Down
1 change: 1 addition & 0 deletions components/Admin/players.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function Players(props) {
{/* Toggle visibility button */}
<button
className={`border-4 ${x.hidden ? 'bg-secondary-300' : 'bg-success-300'} hover:opacity-80 p-2 rounded-lg`}
id={`player${i}Team${teamNumber}HideGameButton`}
onClick={() => {
game.registeredPlayers[x.id].hidden = !game.registeredPlayers[x.id].hidden;
props.setGame((prv) => ({ ...prv }));
Expand Down
2 changes: 1 addition & 1 deletion components/buzzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export default function Buzzer(props) {
const currentPlayer = game.registeredPlayers[props.id];
if (currentPlayer?.hidden) return (
<div className="flex flex-col justify-center items-center min-h-screen">
<h1>{t("You have been blindfolded...")}</h1>
<h1 id="playerBlindFoldedText">{t("You have been blindfolded...")}</h1>
</div>
);

Expand Down
14 changes: 14 additions & 0 deletions e2e/tests/admin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,17 @@ test("can track points between rounds", async ({ browser }) => {
expect (await gamePage.roundPointsTeamtotal.textContent()).toBe(pointsTotal.toString())
}).toPass({ timeout: 2000 });
});

test('can hide game board from player', async ({ browser }) => {
const s = new Setup(browser);
const host = await s.host();
const player1 = await s.addPlayer();
const buzzerPage1 = new BuzzerPage(player1.page);

const adminPage = new AdminPage(host.page);
await adminPage.gameSelector.selectOption({ index: 1 });
await adminPage.startRoundOneButton.click();
expect(buzzerPage1.playerBlindFoldedText).not.toBeVisible();
await adminPage.player0Team1HideGameButton.click();
expect(buzzerPage1.playerBlindFoldedText).toBeVisible();
});
10 changes: 10 additions & 0 deletions e2e/tests/models/AdminPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ class AdminPage {
this.player2Team2QuitButton = page.getByTestId("player2Team2QuitButton")
this.player3Team2QuitButton = page.getByTestId("player3Team2QuitButton")

this.player0Team1HideGameButton = page.getByTestId("player0Team1HideGameButton")
this.player1Team1HideGameButton = page.getByTestId("player1Team1HideGameButton")
this.player2Team1HideGameButton = page.getByTestId("player2Team1HideGameButton")
this.player3Team1HideGameButton = page.getByTestId("player3Team1HideGameButton")

this.player0Team2HideGameButton = page.getByTestId("player0Team2HideGameButton")
this.player1Team2HideGameButton = page.getByTestId("player1Team2HideGameButton")
this.player2Team2HideGameButton = page.getByTestId("player2Team2HideGameButton")
this.player3Team2HideGameButton = page.getByTestId("player3Team2HideGameButton")

this.team0MistakeButton = page.getByTestId("team0MistakeButton")
this.team1MistakeButton = page.getByTestId("team1MistakeButton")
this.team0GivePointsButton = page.getByTestId("team0GivePointsButton")
Expand Down
1 change: 1 addition & 0 deletions e2e/tests/models/BuzzerPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class BuzzerPage {
this.titleLogoUserUploaded = page.getByTestId("titleLogoUserUploaded");
this.waitingForHostText = page.getByTestId("waitingForHostText");
this.xImg = page.getByTestId("xImg");
this.playerBlindFoldedText = page.getByTestId("playerBlindFoldedText")
}
}

Expand Down