mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 03:32:06 +00:00
T8: the invalid-FEN flash is generic; the client message and FEN go to the log. A2: an expired confirmation link says so and lands on log-in, where an unconfirmed account resends the email. W3: the connection banner gains Reload and Home actions. D1: a failed export logs and redirects to the data tab with a support address instead of a bare 500. D2: an unknown export format renders the styled 404. H1: the empty-database home CTA points at the guest trainer instead of auth-gated /endgames. X2/X3: the importer hides inspect(reason) behind generic copy and logs it. Adds coverage for the T8 copy, A2 destination, D2 404 page, H1 CTA and the W3 actions; the H1 tests now restore the curated-code override so async page tests cannot poison each other.
This commit is contained in:
@@ -61,7 +61,7 @@ defmodule ChesstrainerWeb.PageControllerTest do
|
||||
assert html =~ "menu-button"
|
||||
assert html =~ ~s(class="site-footer")
|
||||
assert html =~ "© #{DateTime.utc_now().year} #{Branding.name()}"
|
||||
assert html =~ ~p"/endgames"
|
||||
assert html =~ ~p"/guest-train"
|
||||
assert html =~ "/assets/js/marketing.js"
|
||||
refute html =~ "/assets/js/app.js"
|
||||
|
||||
@@ -318,6 +318,9 @@ defmodule ChesstrainerWeb.PageControllerTest do
|
||||
end
|
||||
|
||||
test "renders without endgames", %{conn: conn} do
|
||||
previous = Application.get_env(:chesstrainer, :curated_endgame_codes)
|
||||
on_exit(fn -> Application.put_env(:chesstrainer, :curated_endgame_codes, previous) end)
|
||||
|
||||
Application.put_env(:chesstrainer, :curated_endgame_codes, [])
|
||||
|
||||
html = conn |> get(~p"/") |> html_response(200)
|
||||
@@ -327,8 +330,10 @@ defmodule ChesstrainerWeb.PageControllerTest do
|
||||
refute html =~ "puzzle-card"
|
||||
|
||||
assert LazyHTML.attribute(LazyHTML.query(document, ".hero-actions a"), "href") == [
|
||||
"/endgames"
|
||||
"/guest-train"
|
||||
]
|
||||
|
||||
assert html =~ "Start training"
|
||||
end
|
||||
|
||||
test "unknown routes render the branded 404 page", %{conn: conn} do
|
||||
|
||||
@@ -31,9 +31,9 @@ defmodule ChesstrainerWeb.UserConfirmationControllerTest do
|
||||
conn = get(conn, ~p"/users/confirm/oops")
|
||||
|
||||
assert Phoenix.Flash.get(conn.assigns.flash, :error) ==
|
||||
"User not found or token is invalid."
|
||||
"That confirmation link is invalid or has expired. Log in to request a new one."
|
||||
|
||||
assert redirected_to(conn) == ~p"/users/register"
|
||||
assert redirected_to(conn) == ~p"/users/log-in"
|
||||
end
|
||||
|
||||
test "confirms a linked mailing-list opt-in", %{conn: conn, user: user} do
|
||||
|
||||
@@ -21,6 +21,15 @@ defmodule ChesstrainerWeb.UserDataControllerTest do
|
||||
assert redirected_to(conn) == ~p"/users/log-in"
|
||||
end
|
||||
|
||||
test "returns the styled 404 page for an unknown format", %{conn: conn} do
|
||||
conn = get(conn, ~p"/users/profile/export/xml")
|
||||
|
||||
html = html_response(conn, 404)
|
||||
assert html =~ "This page isn't on the board"
|
||||
assert html =~ "Back to home"
|
||||
assert get_resp_header(conn, "content-type") == ["text/html; charset=utf-8"]
|
||||
end
|
||||
|
||||
test "downloads the user details and attempts as CSV", %{
|
||||
conn: conn,
|
||||
user: user,
|
||||
|
||||
@@ -326,6 +326,7 @@ defmodule ChesstrainerWeb.EndgameLive.PlayTest do
|
||||
end
|
||||
|
||||
describe "chess_fen_invalid" do
|
||||
@tag capture_log: true
|
||||
test "shows a flash when the chessground hook reports an unparseable FEN", %{conn: conn} do
|
||||
endgame = endgame_fixture()
|
||||
seed_tablebase(endgame.fen)
|
||||
@@ -339,8 +340,9 @@ defmodule ChesstrainerWeb.EndgameLive.PlayTest do
|
||||
})
|
||||
|
||||
html = render(view)
|
||||
assert html =~ "Endgame FEN is invalid"
|
||||
assert html =~ "move number must be a positive integer"
|
||||
assert html =~ "The board couldn't load this position. Reset to try again."
|
||||
refute html =~ "Endgame FEN is invalid"
|
||||
refute html =~ "move number must be a positive integer"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -88,6 +88,8 @@ defmodule ChesstrainerWeb.EndgameLive.TrainTest do
|
||||
assert has_element?(view, "#difficulty-hard")
|
||||
assert has_element?(view, "#close-difficulty[href='/']")
|
||||
assert has_element?(view, "a", "Return Home")
|
||||
assert has_element?(view, "#connection-actions")
|
||||
assert render(view) =~ ">Reload<"
|
||||
refute has_element?(view, "#puzzle-search")
|
||||
assert has_element?(view, "#rating-guide")
|
||||
assert render(view) =~ "Choose a difficulty"
|
||||
|
||||
Reference in New Issue
Block a user