Skip to content

Commit

Permalink
test(acceptance): pied piper acceptance tests (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinezanardi committed Aug 14, 2023
1 parent 8c4b89e commit ac1702b
Show file tree
Hide file tree
Showing 10 changed files with 221 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"roles": {
"piedPiper": {
"charmedPeopleCountPerNight": 3
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"roles": {
"piedPiper": {
"isPowerlessIfInfected": false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Feature: 🏆 Game Victory
| name |

Scenario: 💞Lovers win the game
Given a created game with options described in file no-sheriff-options.json and with the following players
Given a created game with options described in file no-sheriff-option.json and with the following players
| name | role |
| Antoine | witch |
| JB | werewolf |
Expand Down Expand Up @@ -239,7 +239,7 @@ Feature: 🏆 Game Victory
| Olivia |

Scenario: 👼 Angel wins the game with the first votes
Given a created game with options described in file no-sheriff-options.json and with the following players
Given a created game with options described in file no-sheriff-option.json and with the following players
| name | role |
| Antoine | witch |
| JB | werewolf |
Expand All @@ -259,7 +259,7 @@ Feature: 🏆 Game Victory
| Thomas |

Scenario: 👼 Angel wins the game with first murder of wolves
Given a created game with options described in file no-sheriff-options.json and with the following players
Given a created game with options described in file no-sheriff-option.json and with the following players
| name | role |
| Antoine | witch |
| JB | werewolf |
Expand Down Expand Up @@ -287,7 +287,7 @@ Feature: 🏆 Game Victory
| Thomas |

Scenario: 🐺🦴 White werewolf wins the game
Given a created game with options described in file no-sheriff-options.json and with the following players
Given a created game with options described in file no-sheriff-option.json and with the following players
| name | role |
| Antoine | witch |
| JB | werewolf |
Expand Down Expand Up @@ -316,7 +316,7 @@ Feature: 🏆 Game Victory
| Thomas |

Scenario: 🪈Pied Piper wins the game
Given a created game with options described in file no-sheriff-options.json and with the following players
Given a created game with options described in file no-sheriff-option.json and with the following players
| name | role |
| Antoine | witch |
| JB | werewolf |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: 🐺👹 Big Bad Wolf role

Scenario: 🐺👹Big Bad Wolf eats every night but powerless if one werewolf dies
Given a created game with options described in file no-sheriff-options.json and with the following players
Given a created game with options described in file no-sheriff-option.json and with the following players
| name | role |
| Antoine | witch |
| JB | werewolf |
Expand Down Expand Up @@ -55,7 +55,7 @@ Feature: 🐺👹 Big Bad Wolf role
| Olivia |

Scenario: 🐺👹Big Bad Wolf eats every night and not powerless if one werewolf dies
Given a created game with options described in file no-sheriff-options.json, big-bad-wolf-not-powerless-if-werewolf-dies-option.json and with the following players
Given a created game with options described in file no-sheriff-option.json, big-bad-wolf-not-powerless-if-werewolf-dies-option.json and with the following players
| name | role |
| Antoine | witch |
| JB | werewolf |
Expand Down Expand Up @@ -113,7 +113,7 @@ Feature: 🐺👹 Big Bad Wolf role
| Olivia |

Scenario: 🐺👹Big Bad Wolf eats every night but his role is skipped if no targets
Given a created game with options described in file no-sheriff-options.json, skip-roles-call-if-no-target-option.json and with the following players
Given a created game with options described in file no-sheriff-option.json, skip-roles-call-if-no-target-option.json and with the following players
| name | role |
| Antoine | witch |
| JB | werewolf |
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/features/game/features/role/cupid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Feature: 💘 Cupid role

Scenario: 💘 Cupid makes two people fall in love and they die if one of them dies

Given a created game with options described in file no-sheriff-options.json and with the following players
Given a created game with options described in file no-sheriff-option.json and with the following players
| name | role |
| Antoine | cupid |
| Olivia | werewolf |
Expand Down
171 changes: 171 additions & 0 deletions tests/acceptance/features/game/features/role/pied-piper.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
Feature: 🪈 Pied Piper role

Scenario: 🪈 Pied Piper charms but not call anymore nor doesn't win because he's infected
Given a created game with options described in file no-sheriff-option.json and with the following players
| name | role |
| Antoine | pied-piper |
| Olivia | vile-father-of-wolves |
| JB | villager |
| Thomas | villager |
| Dad | villager |
| Mom | villager |

When the werewolves eat the player named Thomas
Then the player named Thomas should have the eaten from werewolves attribute
And the game's current play should be pied-piper to charm

When the pied piper charms the following players
| name |
| Thomas |
| Olivia |
Then 2 of the following players should have the charmed from pied-piper attribute
| name |
| Olivia |
| Thomas |
And the game's current play should be charmed to meet-each-other
And the game's current play should be played by the following players
| name |
| Olivia |
| Thomas |

When the player or group skips his turn
Then the game's current play should be all to vote

When the player or group skips his turn
Then the game's current play should be werewolves to eat

When the werewolves eat the player named Dad
Then the player named Dad should have the eaten from werewolves attribute
And the game's current play should be pied-piper to charm

When the pied piper charms the following players
| name |
| Dad |
| Mom |
Then 3 of the following players should have the charmed from pied-piper attribute
| name |
| Olivia |
| Dad |
| Mom |
And the game's current play should be charmed to meet-each-other
And the game's current play should be played by the following players
| name |
| Olivia |
| Dad |
| Mom |

When the player or group skips his turn
Then the game's current play should be all to vote

When the player or group skips his turn
Then the game's current play should be werewolves to eat

When the vile father of wolves infects the player named Antoine
Then the player named Antoine should be on werewolves current side and originally be on villagers side
And the game's current play should be all to vote

When all vote with the following votes
| source | target |
| Antoine | Olivia |
| JB | Olivia |
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 status should be playing

Scenario: 🪈 Pied Piper charms 3 people by night and can win even if he's infected
Given a created game with options described in file no-sheriff-option.json, pied-piper-charms-three-people-per-night-option.json, pied-piper-not-powerless-if-infected-option.json and with the following players
| name | role |
| Antoine | pied-piper |
| Olivia | vile-father-of-wolves |
| JB | villager |
| Thomas | villager |
| Dad | villager |

When the vile father of wolves infects the player named Antoine
Then the player named Antoine should be on werewolves current side and originally be on villagers side
And the game's current play should be pied-piper to charm

When the pied piper charms the following players
| name |
| Thomas |
| Olivia |
| JB |
Then 3 of the following players should have the charmed from pied-piper attribute
| name |
| Olivia |
| JB |
| Thomas |
And the game's current play should be charmed to meet-each-other
And the game's current play should be played by the following players
| name |
| Olivia |
| JB |
| Thomas |

When the player or group skips his turn
Then the game's current play should be all to vote

When the player or group skips his turn
Then the game's current play should be werewolves to eat

When the werewolves eat the player named Thomas
Then the player named Thomas should have the eaten from werewolves attribute
And the game's current play should be pied-piper to charm

When the pied piper charms the following players
| name |
| Dad |
Then 3 of the following players should have the charmed from pied-piper attribute
| name |
| Olivia |
| JB |
| Dad |
And the game's status should be over
And the game's winners should be pied-piper with the following players
| name |
| Antoine |

Scenario: 🪈 Pied Piper charms everybody but is dead so he doesn't win

Given a created game with options described in file no-sheriff-option.json, pied-piper-charms-three-people-per-night-option.json and with the following players
| name | role |
| Antoine | pied-piper |
| Olivia | werewolf |
| JB | villager |
| Thomas | villager |
| Dad | villager |

When the werewolves eat the player named Antoine
Then the player named Antoine should have the eaten from werewolves attribute
And the game's current play should be pied-piper to charm

When the pied piper charms the following players
| name |
| Thomas |
| Olivia |
| JB |
Then 3 of the following players should have the charmed from pied-piper attribute
| name |
| Olivia |
| JB |
| Thomas |
And the game's current play should be charmed to meet-each-other
And the game's current play should be played by the following players
| name |
| Olivia |
| JB |
| Thomas |

When the player or group skips his turn
Then the game's current play should be all to vote

When all vote with the following votes
| source | target |
| Olivia | Dad |
| JB | Olivia |
| Thomas | Dad |
Then the player named Dad should be murdered by all from vote
And the game's current play should be werewolves to eat
And the game's status should be playing
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: 🐺🦴White Werewolf role

Scenario: 🐺🦴White Werewolf can eat or skip every other night an ally
Given a created game with options described in file no-sheriff-options.json and with the following players
Given a created game with options described in file no-sheriff-option.json and with the following players
| name | role |
| Antoine | villager |
| JB | werewolf |
Expand Down Expand Up @@ -91,7 +91,7 @@ Feature: 🐺🦴White Werewolf role
| Olivia |

Scenario: 🐺🦴White Werewolf can eat or skip every night an ally and his role is skipped if no targets
Given a created game with options described in file no-sheriff-options.json, white-werewolf-waking-up-every-night-option.json, skip-roles-call-if-no-target-option.json and with the following players
Given a created game with options described in file no-sheriff-option.json, white-werewolf-waking-up-every-night-option.json, skip-roles-call-if-no-target-option.json and with the following players
| name | role |
| Antoine | villager |
| JB | werewolf |
Expand Down
23 changes: 17 additions & 6 deletions tests/acceptance/features/game/step-definitions/game.then-steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getPlayerWithNameOrThrow } from "../../../../../src/modules/game/helper
import { doesPlayerHaveAttributeWithName, doesPlayerHaveAttributeWithNameAndSource } from "../../../../../src/modules/game/helpers/player/player-attribute/player-attribute.helper";
import type { Player } from "../../../../../src/modules/game/schemas/player/player.schema";
import type { GameSource } from "../../../../../src/modules/game/types/game.type";
import type { ROLE_SIDES } from "../../../../../src/modules/role/enums/role.enum";
import type { CustomWorld } from "../../../shared/types/world.types";
import { convertDatatableToPlayers } from "../helpers/game-datatable.helper";

Expand Down Expand Up @@ -48,6 +49,17 @@ Then(
},
);

Then(
/^the game's winners should be (?<winners>villagers|werewolves|lovers|angel|white-werewolf|pied-piper|none) with the following players$/u,
function(this: CustomWorld, victoryType: GAME_VICTORY_TYPES, winnersDatable: DataTable): void {
const players = convertDatatableToPlayers(winnersDatable.rows(), this.game);
const expectedWinners = players.length ? players : undefined;

expect(this.game.victory?.type).toBe(victoryType);
expect(this.game.victory?.winners).toStrictEqual(expectedWinners);
},
);

Then(
/^the player named (?<name>.+?) should have the (?<attributeName>\S+)(?: from (?<attributeSource>\S+))? attribute$/u,
function(this: CustomWorld, playerName: string, attributeName: PLAYER_ATTRIBUTE_NAMES, attributeSource: GameSource | null): void {
Expand Down Expand Up @@ -112,12 +124,11 @@ Then(
);

Then(
/^the game's winners should be (?<winners>villagers|werewolves|lovers|angel|white-werewolf|pied-piper|none) with the following players$/u,
function(this: CustomWorld, victoryType: GAME_VICTORY_TYPES, winnersDatable: DataTable): void {
const players = convertDatatableToPlayers(winnersDatable.rows(), this.game);
const expectedWinners = players.length ? players : undefined;
/^the player named (?<name>.+?) should be on (?<currentSide>villagers|werewolves) current side and originally be on (?<originalSide>villagers|werewolves) side$/u,
function(this: CustomWorld, playerName: string, currentSide: ROLE_SIDES, originalSide: ROLE_SIDES): void {
const player = getPlayerWithNameOrThrow(playerName, this.game, new Error("Player name not found"));

expect(this.game.victory?.type).toBe(victoryType);
expect(this.game.victory?.winners).toStrictEqual(expectedWinners);
expect(player.side.current).toBe(currentSide);
expect(player.side.original).toBe(originalSide);
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ When(/^the werewolves eat the player named (?<name>.+)$/u, async function(this:
this.game = this.response.json<Game>();
});

When(/^the vile father of wolves infects 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, isInfected: true }] };

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

When(/^the big bad wolf eats 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

0 comments on commit ac1702b

Please sign in to comment.