]> git.cworth.org Git - empires-server/blobdiff - test
Add failing test for list of judging players when judging phase begins
[empires-server] / test
diff --git a/test b/test
index 12da35fa8f7ce2b71ffc7f62a68d730a9d9923b0..703f005cfce3ec707f237b5df74321214eae8c25 100755 (executable)
--- a/test
+++ b/test
@@ -742,6 +742,18 @@ result=$(echo $(empathy_ambiguities alice))
 test "$result" != "null"
 TEST_END
 
+# Usage: empathy_players_judging <player_name>
+empathy_players_judging()
+{
+    empathy_get_event $1 game-state | jq .players_judging[]
+}
+
+TEST "Verify active players listed as judging"
+# echo here is to strip newlines
+result=$(echo $(empathy_players_judging alice))
+test "$result" = '"alice" "bob" "charlie"'
+TEST_END
+
 TEST "Submit word groups from majority"
 empathy_judged alice $prompt_id '[]' >/dev/null
 result=$(empathy_judged bob $prompt_id '[]')
@@ -779,6 +791,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