Skip to content

Commit f0f8546

Browse files
committed
test(copi): align game live round-param expectations with fallback behavior
1 parent 4670cee commit f0f8546

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

copi.owasp.org/test/copi_web/live/game_live_test.exs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ defmodule CopiWeb.GameLiveTest do
148148
assert html =~ game.name
149149
end
150150

151-
test "redirects to error when round parameter is invalid", %{conn: conn, game: game} do
152-
assert {:error, {:redirect, %{to: "/error"}}} = live(conn, "/games/#{game.id}?round=abc")
151+
test "uses default round when round parameter is invalid", %{conn: conn, game: game} do
152+
{:ok, _show_live, html} = live(conn, "/games/#{game.id}?round=abc")
153+
assert html =~ game.name
153154
end
154155

155156
test "displays past round", %{conn: conn, game: game} do
@@ -207,12 +208,13 @@ defmodule CopiWeb.GameLiveTest do
207208
assert html =~ "At least 3 players are required"
208209
end
209210

210-
test "redirects to error on invalid round param", %{conn: conn, game: game} do
211+
test "uses default round on out-of-range round param", %{conn: conn, game: game} do
211212
{:ok, _} = Cornucopia.create_player(%{name: "P1", game_id: game.id})
212213
{:ok, game} = Cornucopia.update_game(game, %{started_at: DateTime.truncate(DateTime.utc_now(), :second)})
213214

214-
# round=999 is way beyond current_round, should redirect to /error
215-
assert {:error, {:redirect, %{to: "/error"}}} = live(conn, "/games/#{game.id}?round=999")
215+
# round=999 is way beyond current_round, so the current round is used.
216+
{:ok, _show_live, html} = live(conn, "/games/#{game.id}?round=999")
217+
assert html =~ game.name
216218
end
217219
end
218220

0 commit comments

Comments
 (0)