- Add 17 missing @spec annotations (layouts, error_json, error_html, skewt_svg) - Move 12+ nested alias/import/require to module top level - Add phx-change/id attributes to 11 raw HTML <form> tags - Remove 4 unused LiveView assigns (:bounds, :data_provider) - Add 3 missing doctest references (HrrrNativeClient, BulkFetch, Accounts) - Break 2 long lines (path_compute.ex:382) - Strengthen weak test assertions (is_binary→byte_size, is_list→!=[]) - Replace Module.concat with Module.safe_concat (2 occurrences) - Replace length/1 > 0 with list != [] (9 occurrences) - Remove no-op assert true, fix no-assertion tests Remaining: 24 socket.assigns introspection warnings (deliberate test pattern for observable behavior testing), 1 formatter-resistant long line, 3 app-code usage warnings.
61 lines
1.9 KiB
Elixir
61 lines
1.9 KiB
Elixir
defmodule MicrowavepropWeb.UserRegistrationControllerTest do
|
|
use MicrowavepropWeb.ConnCase, async: true
|
|
|
|
import Microwaveprop.AccountsFixtures
|
|
|
|
describe "GET /users/register" do
|
|
test "renders registration page", %{conn: conn} do
|
|
conn = get(conn, ~p"/users/register")
|
|
response = html_response(conn, 200)
|
|
assert response =~ "Register"
|
|
assert response =~ ~p"/users/log-in"
|
|
assert response =~ ~p"/users/register"
|
|
assert response =~ "Callsign"
|
|
assert response =~ "Name"
|
|
assert response =~ "Confirm password"
|
|
end
|
|
|
|
test "redirects if already logged in", %{conn: conn} do
|
|
conn = conn |> log_in_user(user_fixture()) |> get(~p"/users/register")
|
|
|
|
assert redirected_to(conn) == ~p"/"
|
|
end
|
|
end
|
|
|
|
describe "POST /users/register" do
|
|
test "creates account, sends confirmation email, does not log in", %{conn: conn} do
|
|
email = unique_user_email()
|
|
|
|
conn =
|
|
post(conn, ~p"/users/register", %{
|
|
"user" => valid_user_attributes(email: email)
|
|
})
|
|
|
|
refute get_session(conn, :user_token)
|
|
assert redirected_to(conn) == ~p"/users/log-in"
|
|
|
|
assert Phoenix.Flash.get(conn.assigns.flash, :info) =~
|
|
~r/Please check .* for a confirmation link/
|
|
|
|
# An unconfirmed user and a confirmation token should exist
|
|
user = Microwaveprop.Accounts.get_user_by_email(email)
|
|
assert %{confirmed_at: nil} = user
|
|
|
|
assert Microwaveprop.Repo.get_by(Microwaveprop.Accounts.UserToken,
|
|
user_id: user.id,
|
|
context: "confirm"
|
|
)
|
|
end
|
|
|
|
test "renders errors when required fields are missing", %{conn: conn} do
|
|
conn =
|
|
post(conn, ~p"/users/register", %{
|
|
"user" => %{"email" => "with spaces"}
|
|
})
|
|
|
|
response = html_response(conn, 200)
|
|
assert response =~ "Register"
|
|
assert response =~ "must have the @ sign and no spaces"
|
|
end
|
|
end
|
|
end
|