From 3df7aff190fb3a06ddc0d3364fd6d9f358d7af8d Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 2 Sep 2025 15:46:58 +0200 Subject: [PATCH 1/2] test on page content not page nav content --- priv/templates/phx.gen.auth/confirmation_live_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv/templates/phx.gen.auth/confirmation_live_test.exs b/priv/templates/phx.gen.auth/confirmation_live_test.exs index cfd9ed1c8e..da7a551baa 100644 --- a/priv/templates/phx.gen.auth/confirmation_live_test.exs +++ b/priv/templates/phx.gen.auth/confirmation_live_test.exs @@ -29,7 +29,7 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web {:ok, _lv, html} = live(conn, ~p"<%= schema.route_prefix %>/log-in/#{token}") refute html =~ "Confirm my account" - assert html =~ "Log in" + assert html =~ "Keep me logged in on this device" end test "confirms the given token once", %{conn: conn, unconfirmed_<%= schema.singular %>: <%= schema.singular %>} do From 76ecfbb812ca297b32cf2cfadb55c1e68d350b36 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 2 Sep 2025 16:02:06 +0200 Subject: [PATCH 2/2] test confirmation live for already logged in users --- .../phx.gen.auth/confirmation_live_test.exs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/priv/templates/phx.gen.auth/confirmation_live_test.exs b/priv/templates/phx.gen.auth/confirmation_live_test.exs index da7a551baa..f4dda1c1d3 100644 --- a/priv/templates/phx.gen.auth/confirmation_live_test.exs +++ b/priv/templates/phx.gen.auth/confirmation_live_test.exs @@ -32,6 +32,19 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web assert html =~ "Keep me logged in on this device" end + test "renders login page for already logged in <%= schema.singular %>", %{conn: conn, confirmed_<%= schema.singular %>: <%= schema.singular %>} do + conn = log_in_<%= schema.singular %>(conn, <%= schema.singular %>) + + token = + extract_<%= schema.singular %>_token(fn url -> + <%= inspect context.alias %>.deliver_login_instructions(<%= schema.singular %>, url) + end) + + {:ok, _lv, html} = live(conn, ~p"<%= schema.route_prefix %>/log-in/#{token}") + refute html =~ "Confirm my account" + assert html =~ "Log in" + end + test "confirms the given token once", %{conn: conn, unconfirmed_<%= schema.singular %>: <%= schema.singular %>} do token = extract_<%= schema.singular %>_token(fn url ->