From: Carl Worth Date: Sat, 27 Jun 2020 14:27:41 +0000 (-0700) Subject: test: Add failing test case for unnecessary delay for end-judging voting X-Git-Url: https://git.cworth.org/git?p=lmno-server;a=commitdiff_plain;h=c343c36604caa05d96082ec07922914fb9bf2636 test: Add failing test case for unnecessary delay for end-judging voting 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). --- diff --git a/test b/test index 12da35f..45dbbe3 100755 --- 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