mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
back home button on daily puzzle
This commit is contained in:
@@ -211,6 +211,50 @@ defmodule ChesstrainerWeb.EndgameLive.PlayTest do
|
||||
end
|
||||
end
|
||||
|
||||
describe "back link" do
|
||||
test "points home for an anonymous visitor", %{conn: conn} do
|
||||
endgame = endgame_fixture()
|
||||
seed_tablebase(endgame.fen)
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/endgames/#{endgame.public_code}/play")
|
||||
|
||||
assert has_element?(view, ~s{a[href="/"]}, "Back home")
|
||||
refute has_element?(view, ~s{a[href="/endgames"]})
|
||||
end
|
||||
|
||||
test "points home for a signed-in free user", %{conn: conn} do
|
||||
user = Chesstrainer.AccountsFixtures.user_fixture()
|
||||
endgame = endgame_fixture()
|
||||
seed_tablebase(endgame.fen)
|
||||
|
||||
{:ok, view, _html} =
|
||||
conn
|
||||
|> log_in_user(user)
|
||||
|> live(~p"/endgames/#{endgame.public_code}/play")
|
||||
|
||||
assert has_element?(view, ~s{a[href="/"]}, "Back home")
|
||||
refute has_element?(view, ~s{a[href="/endgames"]})
|
||||
end
|
||||
|
||||
test "points to the endgame index for a premium user", %{conn: conn} do
|
||||
{:ok, user} =
|
||||
Chesstrainer.AccountsFixtures.user_fixture()
|
||||
|> Ecto.Changeset.change(plan: :premium)
|
||||
|> Repo.update()
|
||||
|
||||
endgame = endgame_fixture()
|
||||
seed_tablebase(endgame.fen)
|
||||
|
||||
{:ok, view, _html} =
|
||||
conn
|
||||
|> log_in_user(user)
|
||||
|> live(~p"/endgames/#{endgame.public_code}/play")
|
||||
|
||||
assert has_element?(view, ~s{a[href="/endgames"]}, "Back to endgames")
|
||||
refute has_element?(view, ~s{a[href="/"]}, "Back home")
|
||||
end
|
||||
end
|
||||
|
||||
describe "tablebase availability" do
|
||||
test "blocks the attempt when the tablebase is cooling down", %{conn: conn} do
|
||||
# Six pieces routes to Lichess, so the cooldown applies (five or fewer
|
||||
|
||||
@@ -67,6 +67,6 @@ defmodule ChesstrainerWeb.EndgameLive.PlayerIndexTest do
|
||||
{: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"]})
|
||||
assert has_element?(view, ~s{a[href="/"]})
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user