]> git.cworth.org Git - empires-server/commitdiff
Add new failing test case: Inactive players shouldn't impede phase advance
authorCarl Worth <cworth@cworth.org>
Sat, 27 Jun 2020 16:11:42 +0000 (09:11 -0700)
committerCarl Worth <cworth@cworth.org>
Sat, 27 Jun 2020 16:22:14 +0000 (09:22 -0700)
The current implementation is waiting for all registered players to
have submitted answers before auto-advance (prior to a majority vote
to move on without anyone).

That seems like reasonable logic, except for a player that the server
has already noticed is no longer active (event stream connection has
dropped and server has indicated the player is gone from the game). We
don't want such an inactive player impeding the progress of the game.

This commit adds a test case capturing the behavior we actually want,
(so this test is currently failing).

test

diff --git a/test b/test
index 48db90d117ca13a295f565984db5dc57c0aed463..f5f5eeb91e9b06869e96fb69438b388bdc40c6b2 100755 (executable)
--- a/test
+++ b/test
@@ -923,4 +923,51 @@ result=$(echo $(empathy_scores_names_numbers alice))
 test "$result" = '"alice" 1 "bob" 1 "charlie" 0'
 TEST_END
 
+TEST_SUBSECTION "Deactivated players don't block future game phase advances"
+
+TEST "New 3-player game, 2 submit right away"
+empathy_reset
+prompt_id=$(empathy_submit_prompt charlie 4 "2 legit 2 quit" | jq .id)
+empathy_start alice $prompt_id
+empathy_answer alice $prompt_id '"what", "gives?"' >/dev/null
+empathy_answer bob   $prompt_id '"so", "confused"' >/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 charlie $prompt_id '"best", "category"')
+test "$result" = '{"valid":true}'
+TEST_END
+
+TEST "Judging has started (don't need inactive players)"
+result=$(echo $(empathy_ambiguities alice))
+test "$result" != "null"
+TEST_END
+
+TEST "Submit word groups from 2 players"
+empathy_judged alice $prompt_id '[]' >/dev/null
+result=$(empathy_judged bob $prompt_id '[]')
+test "$result" = '{"valid":true}'
+TEST_END
+
+TEST "Scoring hasn't started with player unsubmitted"
+result=$(echo $(empathy_scores alice))
+test "$result" = "null"
+TEST_END
+
+TEST "Submit word groups from last answering player"
+result=$(empathy_judged charlie $prompt_id '[]')
+test "$result" = '{"valid":true}'
+TEST_END
+
+TEST "Scoring has now started"
+result=$(echo $(empathy_scores alice))
+test "$result" != "null"
+TEST_END
+
 cleanup_and_report