Skip to content

Commit

Permalink
test(scapegoat): acceptance tests (#884)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a new project run configuration for Cucumber.js testing,
enhancing acceptance test execution.
- Added narrative elements to the Scapegoat role, enriching player
engagement and game dynamics.
- Implemented functionality for the Scapegoat to ban players from
voting, affecting game strategy.

- **Bug Fixes**
  - Removed outdated step definitions to streamline game-play testing.

- **Documentation**
- Updated localization strings for consistency and improved storytelling
in both English and French.

- **Tests**
- Expanded acceptance tests to cover new functionalities related to the
Scapegoat role.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
antoinezanardi authored Sep 17, 2024
1 parent aacb761 commit add895e
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 15 deletions.
12 changes: 12 additions & 0 deletions .run/Scapegoat Role.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Scapegoat Role" type="cucumber.js" factoryName="Cucumber.js" folderName="Tags">
<option name="myFilePath" value="$PROJECT_DIR$/tests/acceptance" />
<option name="myNameFilter" value="" />
<option name="cucumberJsArguments" value="--config config/cucumber/cucumber.json --parallel 1 --tags @scapegoat-role" />
<option name="workingDirectory" value="$PROJECT_DIR$" />
<envs>
<env name="NODE_OPTIONS" value="--import tsx/esm" />
</envs>
<method v="2" />
</configuration>
</component>
4 changes: 2 additions & 2 deletions modules/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@
"unknownPlayerAttribute": "Unknown player attribute.",
"actingByActor": "The player is acting, he's playing another role for the current turn.",
"cantVoteBySurvivors": "The survivors decided that this player can't vote.",
"cantVoteByScapegoat": "The scapegoat decided that this player can't vote.",
"cantVoteByScapegoat": "The Scapegoat decided that this player can't vote.",
"charmedByPiedPiper": "The Pied Piper charmed this player.",
"contaminatedByRustySwordKnight": "The Rusty Sword Knight contaminated this player, he'll be eliminated the next night.",
"drankDeathPotionByWitch": "The Witch gave a death potion to this player, he'll die the next morning.",
Expand Down Expand Up @@ -1352,7 +1352,7 @@
"playerWillHavePenaltyForNextVotes": "The player marked with a feather will have one more vote against him the next vote. | The player marked with a feather will have {penalty} more votes against him the next vote."
},
"GameScapegoatTurnStartsEvent": {
"scapegoatCanBanPlayerFromVoting": "The Scapegoat wakes up and can ban one or more players from voting in the votes of the next day."
"scapegoatCanBanPlayerFromVoting": "In his last breath, the Scapegoat takes his revenge and can ban one or more players from voting in the votes of the next day."
},
"GameSeerTurnStartsEvent": {
"seerSeesRoles": "The Seer wakes up and will look at a player's role.",
Expand Down
2 changes: 1 addition & 1 deletion modules/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@
"playerWillHavePenaltyForNextVotes": "Le joueur marqué d'une plume aura un vote supplémentaire contre lui lors du prochain vote. | Le joueur marqué d'une plume aura {penalty} votes supplémentaires contre lui lors du prochain vote."
},
"GameScapegoatTurnStartsEvent": {
"scapegoatCanBanPlayerFromVoting": "Le Bouc Émissaire se réveille et peut interdire à un ou plusieurs joueurs de voter lors des votes du jour suivant."
"scapegoatCanBanPlayerFromVoting": "Dans son dernier souffle, le Bouc Émissaire se réveille et peut interdire à un ou plusieurs joueurs de voter lors des votes du jour suivant."
},
"GameSeerTurnStartsEvent": {
"seerSeesRoles": "La Voyante se réveille et va regarder le rôle d'un joueur.",
Expand Down
46 changes: 46 additions & 0 deletions tests/acceptance/features/game/features/role/scapegoat.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@scapegoat-role
@shard-4
Feature: 🐐 Scapegoat role

Scenario: 🐐 Scapegoat bans some players from votes if he is killed by a tie in votes
Given the user disables the sheriff in game options
And the user creates a game with the players with name and role
| name | role |
| Antoine | Scapegoat |
| Bob | Werewolf |
| Charlie | Idiot |
| David | Angel |

When the user closes the toast
And the user skips all game events
Then the game's current play title should be "Survivors vote"

When the survivors vote with the votes
| name | vote |
| Antoine | Charlie |
| Bob | Charlie |
| Charlie | Bob |
| David | Bob |
Then the player with name "Antoine" should be dead in the game

When the user skips the game event
Then the game's event should display the text "In his last breath, the Scapegoat takes his revenge and can ban one or more players from voting in the votes of the next day."
And the game's event player card should have the name "Antoine"

When the user goes to the next game event text
Then the game's current play title should be "Scapegoat bans voting"
And the game's current play question should be "Does the Scapegoat want to ban one or more players from voting?"
And the game's phase name should be "Twilight"
And the game's current play should have the following targets
| name |
| Bob |
| Charlie |
| David |
And the page should match or creates the missing snapshot with name "Scapegoat bans voting Playground"

When the scapegoat bans from voting the players
| name |
| Bob |
Then the following players should have the attribute cant-vote by scapegoat in the game
| name |
| Bob |
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@ Then(/^the witch should be out of potions$/u, async function(this: CustomWorld):
await expect(this.page.getByRole("heading", { name: "The Witch has used both potions, the game can proceed" })).toBeVisible();
});

Then(/^the following players can't be targeted in game's playground$/u, async function(this: CustomWorld, dataTable: DataTable): Promise<void> {
const names = dataTable.hashes();

await Promise.all(names.map(async player => {
const targetCard = this.page.getByTestId(`game-playground-player-card-${player.name}`);
const targetButton = targetCard.getByRole("button");

return expect(targetButton).toBeDisabled();
}));
});

Then(/^the game's current play should have a countdown of (?<minutes>\d+) minutes and (?<seconds>\d+) seconds$/u, async function(this: CustomWorld, minutes: string, seconds: string): Promise<void> {
const maxSecondsLength = 2;
const paddedSeconds = seconds.padStart(maxSecondsLength, "0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,10 @@ When(/^the stuttering judge requests another vote$/u, async function(this: Custo
When(/^the wild child chooses the player with name "(?<name>.+)" as a model$/u, async function(this: CustomWorld, name: string): Promise<void> {
await targetPlayerInPlayground(this, name);
await makePlayInPlayground(this);
});

When(/^the scapegoat bans from voting the players$/u, async function(this: CustomWorld, players: DataTable): Promise<void> {
const playersData = players.rows().map(([name]) => name);
await targetPlayersInPlayground(this, playersData);
await makePlayInPlayground(this);
});
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,12 @@ Then(/^the following players should have the attribute powerless by elder in the
const powerlessByElderAttribute = await getPlayerAttributeByRoleNameInGameTeamSide(this, name, roleName);
await expect(powerlessByElderAttribute).toBeVisible();
}
});

Then(/^the following players should have the attribute cant-vote by scapegoat in the game$/u, async function(this: CustomWorld, playersDatatable: DataTable): Promise<void> {
const players = playersDatatable.rows();
for (const [name] of players) {
const cantVoteByScapegoatAttribute = await getPlayerAttributeByRoleNameInGameTeamSide(this, name, "The Scapegoat decided that this player can't vote.");
await expect(cantVoteByScapegoatAttribute).toBeVisible();
}
});
1 change: 0 additions & 1 deletion tests/acceptance/features/support/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type { CustomWorld } from "@tests/acceptance/shared/types/word.types";

const { beforeEach, afterEach, afterAll, setup } = createTest({
runner: "cucumber",
buildDir: ".nuxt-test-cucumber",
server: true,
browserOptions: {
type: "chromium",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit add895e

Please sign in to comment.