From d8b094dd158e91396db8a435915395d78c4f489c Mon Sep 17 00:00:00 2001 From: Anna Headley <845363+hackartisan@users.noreply.github.com> Date: Thu, 9 Jan 2025 16:59:37 -0500 Subject: [PATCH] Fix tests --- .../controllers/error_html_test.exs | 2 +- .../live/item_live_test.exs | 21 +++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/test/dpul_collections_web/controllers/error_html_test.exs b/test/dpul_collections_web/controllers/error_html_test.exs index 7ec3ed47..2030ac4d 100644 --- a/test/dpul_collections_web/controllers/error_html_test.exs +++ b/test/dpul_collections_web/controllers/error_html_test.exs @@ -5,7 +5,7 @@ defmodule DpulCollectionsWeb.ErrorHTMLTest do import Phoenix.Template test "renders 404.html" do - assert render_to_string(DpulCollectionsWeb.ErrorHTML, "404", "html", []) == "Not Found" + assert render_to_string(DpulCollectionsWeb.ErrorHTML, "404", "html", []) =~ "not found" end test "renders 500.html" do diff --git a/test/dpul_collections_web/live/item_live_test.exs b/test/dpul_collections_web/live/item_live_test.exs index 76f3908e..72ae8873 100644 --- a/test/dpul_collections_web/live/item_live_test.exs +++ b/test/dpul_collections_web/live/item_live_test.exs @@ -54,11 +54,6 @@ defmodule DpulCollectionsWeb.ItemLiveTest do assert redirected_to(conn, 302) == "/i/învăţămîntul-trebuie-urmărească-dez/item/1" end - test "/item/{:id} does not redirect with a bad id", %{conn: conn} do - conn = get(conn, "/item/badid1") - assert conn.status == 200 - end - test "/i/{:slug}/item/{:id} redirects when slug is incorrect", %{conn: conn} do conn = get(conn, "/i/not-a-real-slug/item/1") @@ -131,15 +126,15 @@ defmodule DpulCollectionsWeb.ItemLiveTest do assert response =~ "زلزلہ" end - test "/i/{:slug}/item/{:id} does not redirect with a bad id", %{conn: conn} do - conn = get(conn, "/i/not-a-real-slug/item/badid1") - response = html_response(conn, 200) - assert response =~ "Item not found" + test "/i/{:slug}/item/{:id} 404s with a bad id", %{conn: conn} do + assert_error_sent 404, fn -> + get(conn, "/i/not-a-real-slug/item/badid1") + end end - test "GET /item/{:id} response whith a bad id", %{conn: conn} do - conn = get(conn, "/item/badid1") - response = html_response(conn, 200) - assert response =~ "Item not found" + test "GET /item/{:id} 404s with a bad id", %{conn: conn} do + assert_error_sent 404, fn -> + get(conn, "/item/badid1") + end end end