]> git.cworth.org Git - empires-server/commitdiff
test: Add failing test case for unnecessary delay for end-judging voting
authorCarl Worth <cworth@cworth.org>
Sat, 27 Jun 2020 14:27:41 +0000 (07:27 -0700)
committerCarl Worth <cworth@cworth.org>
Sat, 27 Jun 2020 14:28:44 +0000 (07:28 -0700)
If all of the players that submitted answers have also all completed
judging, then there's nobody left to wait for and it's pointless to
wait for the idle timer to fire and to force everyone to vote to end
judging. Yet, that's what the implementation currently does.

This commit adds a new test case, which fails, showing the point at
which the game should automatically advance to scoring, (once every
player who submitted an answer has also voted).

test

diff --git a/test b/test
index 12da35fa8f7ce2b71ffc7f62a68d730a9d9923b0..45dbbe32fbdfc943e445d77b387b279b4c0de252 100755 (executable)
--- a/test
+++ b/test
@@ -779,6 +779,42 @@ result=$(echo $(empathy_scores alice))
 test "$result" != "null"
 TEST_END
 
+TEST_SUBSECTION "New game (no voting needed when all answered players judge)"
+
+TEST "Start 4-player game, 3 submissions"
+empathy_reset
+prompt_id=$(empathy_submit_prompt alice 4 "1 truth or dare" | jq .id)
+empathy_start alice $prompt_id
+empathy_answer alice   $prompt_id '"truth"' >/dev/null
+empathy_answer bob     $prompt_id '"truth"' >/dev/null
+empathy_answer charlie $prompt_id '"dare"' >/dev/null
+empathy_end_answers alice $prompt_id
+empathy_end_answers bob $prompt_id
+empathy_end_answers charlie $prompt_id
+test "$?" = "0"
+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
+
 pkill -P $alice_pid
 pkill -P $bob_pid
 pkill -P $charlie_pid