mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
Add public codes for player URLs and admin endgame search
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
This commit is contained in:
@@ -23,11 +23,22 @@ defmodule ChesstrainerWeb.EndgameLive.PlayerIndexTest do
|
||||
view |> element("#key-group-K-v-K button") |> render_click()
|
||||
|
||||
html = render(view)
|
||||
assert html =~ ~p"/endgames/#{endgame}/play"
|
||||
assert html =~ ~p"/endgames/#{other}/play"
|
||||
assert html =~ ~p"/endgames/#{endgame.public_code}/play"
|
||||
assert html =~ ~p"/endgames/#{other.public_code}/play"
|
||||
assert html =~ "Lucena"
|
||||
end
|
||||
|
||||
test "links to the public code, never the database id", %{conn: conn} do
|
||||
endgame = endgame_fixture()
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/endgames")
|
||||
view |> element("#key-group-K-v-K button") |> render_click()
|
||||
|
||||
html = render(view)
|
||||
assert html =~ ~s{/endgames/#{endgame.public_code}/play}
|
||||
refute html =~ endgame.id
|
||||
end
|
||||
|
||||
test "filters by theme", %{conn: conn} do
|
||||
lucena = theme_fixture(%{name: "Lucena"})
|
||||
philidor = theme_fixture(%{name: "Philidor"})
|
||||
@@ -49,7 +60,7 @@ defmodule ChesstrainerWeb.EndgameLive.PlayerIndexTest do
|
||||
test "navigating to a play page renders the board", %{conn: conn} do
|
||||
endgame = endgame_fixture()
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/endgames/#{endgame}/play")
|
||||
{:ok, view, _html} = live(conn, ~p"/endgames/#{endgame.public_code}/play")
|
||||
|
||||
assert has_element?(view, "#endgame-board")
|
||||
assert has_element?(view, ~s{a[href="/endgames"]})
|
||||
|
||||
Reference in New Issue
Block a user