Skip to content

Commit

Permalink
test(acceptance): stuttering judge acceptance tests (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinezanardi authored Sep 6, 2023
1 parent 3e908ee commit 8a759c3
Show file tree
Hide file tree
Showing 6 changed files with 53,857 additions and 55,385 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20
20.5.1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GamePhases } from "@/modules/game/enums/game.enum";
import type { GameOptions } from "@/modules/game/schemas/game-options/game-options.schema";

const DEFAULT_GAME_OPTIONS: GameOptions = Object.freeze({
const DEFAULT_GAME_OPTIONS: Readonly<GameOptions> = Object.freeze({
composition: { isHidden: false },
votes: { canBeSkipped: true },
roles: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"roles": {
"stutteringJudge": {
"voteRequestsCount": 2
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
@stuttering-judge-role

Feature: ⚖️ Stuttering Judge Role

Scenario: ⚖️ Stuttering Judge chooses his sign and can ask for another vote when all voted
Given a created game with options described in file no-sheriff-option.json and with the following players
| name | role |
| Antoine | stuttering-judge |
| Olivia | werewolf |
| JB | villager |
| Camille | villager |
| Thomas | villager |
Then the game's current play should be stuttering-judge to choose-sign

When the stuttering judge chooses his sign
Then the game's current play should be werewolves to eat

When the werewolves eat the player named JB
Then the player named JB should be murdered by werewolves from eaten
And the game's current play should be all to vote

When all vote with the following votes and the stuttering judge does his sign
| voter | target |
| Olivia | Antoine |
| Camille | Antoine |
Then the player named Antoine should be murdered by all from vote
And the game's current play should be all to vote because stuttering-judge-request


Scenario: ⚖️ Stuttering Judge chooses his sign and can ask for another vote even if all did not vote
Given a created game with options described in file no-sheriff-option.json and with the following players
| name | role |
| Antoine | stuttering-judge |
| Olivia | werewolf |
| JB | villager |
| Camille | villager |
| Thomas | villager |
Then the game's current play should be stuttering-judge to choose-sign

When the stuttering judge chooses his sign
Then the game's current play should be werewolves to eat

When the werewolves eat the player named JB
Then the player named JB should be murdered by werewolves from eaten
And the game's current play should be all to vote

When nobody vote and the stuttering judge does his sign
Then the game's current play should be all to vote because stuttering-judge-request

Scenario: ⚖️ Stuttering Judge can request more votes if options allow him
Given a created game with options described in file no-sheriff-option.json, stuttering-judge-two-vote-requests-option.json and with the following players
| name | role |
| Antoine | stuttering-judge |
| Olivia | werewolf |
| JB | villager |
| Camille | villager |
| Thomas | villager |
Then the game's current play should be stuttering-judge to choose-sign

When the stuttering judge chooses his sign
Then the game's current play should be werewolves to eat

When the werewolves eat the player named JB
Then the player named JB should be murdered by werewolves from eaten
And the game's current play should be all to vote

When all vote with the following votes and the stuttering judge does his sign
| voter | target |
| Olivia | Antoine |
| Camille | Olivia |
Then the game's current play should be all to vote because previous-votes-were-in-ties

When nobody vote and the stuttering judge does his sign
Then the game's current play should be all to vote because stuttering-judge-request

When the player or group skips his turn
Then the game's current play should be all to vote because stuttering-judge-request
10 changes: 10 additions & 0 deletions tests/acceptance/features/game/step-definitions/game.when-steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ When(
},
);

When(
/^nobody vote and the stuttering judge does his sign$/u,
async function(this: CustomWorld): Promise<void> {
const makeGamePlayDto: MakeGamePlayDto = { doesJudgeRequestAnotherVote: true };

this.response = await makeGamePlayRequest(makeGamePlayDto, this.game, this.app);
this.game = this.response.json<Game>();
},
);

When(/^the sheriff delegates his role to the player named (?<name>.+)$/u, async function(this: CustomWorld, targetName: string): Promise<void> {
const target = getPlayerWithNameOrThrow(targetName, this.game, new Error("Player name not found"));
const makeGamePlayDto: MakeGamePlayDto = { targets: [{ playerId: target._id }] };
Expand Down
Loading

0 comments on commit 8a759c3

Please sign in to comment.