mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
Player-facing endgame links now use a 10-character Crockford base32 public code instead of the database UUID; admin routes keep the UUID. Existing rows are backfilled by migration, and the admin Show page displays and copies the code. The admin endgame index gains its own search box: exact database id, exact public code, or a FEN / FEN fragment. A single match opens the endgame; multiple matches list below; nothing found says so. Closes #44 Closes #45
27 lines
817 B
Elixir
27 lines
817 B
Elixir
defmodule ChesstrainerWeb.EndgameLive.ShowTest do
|
|
use ChesstrainerWeb.ConnCase
|
|
|
|
import Phoenix.LiveViewTest
|
|
import Chesstrainer.EndgamesFixtures
|
|
|
|
setup :register_and_log_in_admin
|
|
|
|
test "shows the public code alongside the database id", %{conn: conn} do
|
|
endgame = endgame_fixture()
|
|
|
|
{:ok, view, _html} = live(conn, ~p"/admin/endgames/#{endgame.id}")
|
|
|
|
assert has_element?(view, "li.list-row", "Public code")
|
|
assert has_element?(view, "li.list-row", endgame.public_code)
|
|
assert has_element?(view, "h1", endgame.id)
|
|
end
|
|
|
|
test "links to the player surface by public code", %{conn: conn} do
|
|
endgame = endgame_fixture()
|
|
|
|
{:ok, view, _html} = live(conn, ~p"/admin/endgames/#{endgame.id}")
|
|
|
|
assert has_element?(view, ~s{a[href="/endgames/#{endgame.public_code}/play"]})
|
|
end
|
|
end
|