From 66b333239bd232c60cc1093aefc55c585af293cc Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sat, 27 Jun 2020 09:35:59 -0700 Subject: [PATCH] Add new failing test case for a reactivated player I noticed that when a player is reactivated, (that is, by starting a new event stream by means of a cookie associated with a pre-existing cookie for a player that had been deactivated), the server was not properly activating the player. This commit adds a new failing test case that demonstrates the bug. We reactivate dale for a 4-player game, but then the server advances the game out of the answering phase when only 3 players have submitted an answer. This demonstrates that dale isn't being considered active. --- test | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test b/test index f5f5eeb..f62d682 100755 --- a/test +++ b/test @@ -481,6 +481,15 @@ empathy_player_activate() empathy_players+=($player) } +empathy_player_reactivate() +{ + player="$1" + player_pid=${player}_pid + + empathy_get $player events >/dev/null 2>&1 & + eval ${player_pid}=$! +} + # Usage: empathy_player_deactivate empathy_player_deactivate() { @@ -970,4 +979,40 @@ result=$(echo $(empathy_scores alice)) test "$result" != "null" TEST_END +TEST_SUBSECTION "Reactivated player is fully active" + +TEST "The dale player is currently deactivated" +test "$dale_pid" = "" +TEST_END + +TEST "Reactivate dale" +empathy_player_reactivate dale +test "$dale_pid" != "" +TEST_END + +TEST "New 4-player game, 3 submit right away" +empathy_reset +prompt_id=$(empathy_submit_prompt alice 1 "favorite letter" | jq .id) +empathy_start alice $prompt_id +empathy_answer alice $prompt_id '"A"' >/dev/null +empathy_answer bob $prompt_id '"B"' >/dev/null +empathy_answer charlie $prompt_id '"C"' >/dev/null +test "$?" = "0" +TEST_END + +TEST "Judging hasn't started with player unsubmitted" +result=$(echo $(empathy_ambiguities alice)) +test "$result" = "null" +TEST_END + +TEST "Final active player submits" +result=$(empathy_answer dale $prompt_id '"D"') +test "$result" = '{"valid":true}' +TEST_END + +TEST "Judging has started now" +result=$(echo $(empathy_ambiguities alice)) +test "$result" != "null" +TEST_END + cleanup_and_report -- 2.43.0