]> git.cworth.org Git - lmno-server/commitdiff
Add new failing test case for a reactivated player
authorCarl Worth <cworth@cworth.org>
Sat, 27 Jun 2020 16:35:59 +0000 (09:35 -0700)
committerCarl Worth <cworth@cworth.org>
Sat, 27 Jun 2020 16:44:01 +0000 (09:44 -0700)
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

diff --git a/test b/test
index f5f5eeb91e9b06869e96fb69438b388bdc40c6b2..f62d6824315253edd01758f443ca946a393e2947 100755 (executable)
--- 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 <player_name>
 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