mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 03:32:06 +00:00
show logged-in player count in landing hero
Count distinct users with a session token valid within the 14-day window and use it for the hero players-training stat. The learning strip keeps the total player count. Also load the split seed modules in seeds_test and drop an invalid 8-piece seed FEN so precommit passes.
This commit is contained in:
@@ -4,6 +4,7 @@ defmodule ChesstrainerWeb.PageControllerTest do
|
||||
import Chesstrainer.AccountsFixtures
|
||||
import Chesstrainer.EndgamesFixtures
|
||||
|
||||
alias Chesstrainer.Accounts
|
||||
alias Chesstrainer.Accounts.Scope
|
||||
alias Chesstrainer.Attempts
|
||||
alias Chesstrainer.Branding
|
||||
@@ -158,7 +159,17 @@ defmodule ChesstrainerWeb.PageControllerTest do
|
||||
assert html =~ ~s(content="Test Brand")
|
||||
end
|
||||
|
||||
test "hero shows the number of players with at least one attempt", %{conn: conn} do
|
||||
test "hero shows the number of users with a valid session", %{conn: conn} do
|
||||
user = user_fixture()
|
||||
_token = Accounts.generate_user_session_token(user)
|
||||
|
||||
html = conn |> get(~p"/") |> html_response(200)
|
||||
document = LazyHTML.from_document(html)
|
||||
|
||||
assert LazyHTML.text(LazyHTML.query(document, ".rating-note strong")) == "1"
|
||||
end
|
||||
|
||||
test "hero does not count users who have only trained", %{conn: conn} do
|
||||
user = user_fixture()
|
||||
endgame = endgame_fixture()
|
||||
{:ok, _} = Attempts.record_attempt(Scope.for_user(user), endgame, :solved)
|
||||
@@ -166,7 +177,7 @@ defmodule ChesstrainerWeb.PageControllerTest do
|
||||
html = conn |> get(~p"/") |> html_response(200)
|
||||
document = LazyHTML.from_document(html)
|
||||
|
||||
assert LazyHTML.text(LazyHTML.query(document, ".rating-note strong")) == "1"
|
||||
assert LazyHTML.text(LazyHTML.query(document, ".rating-note strong")) == "0"
|
||||
end
|
||||
|
||||
test "guest navbar links to log in and register", %{conn: conn} do
|
||||
@@ -211,11 +222,10 @@ defmodule ChesstrainerWeb.PageControllerTest do
|
||||
|
||||
assert LazyHTML.text(LazyHTML.query(document, ".board-topline")) =~ "White"
|
||||
assert html =~ "Try today's puzzle"
|
||||
assert html =~ "Begin with the basics"
|
||||
assert html =~ "<span>puzzles</span>"
|
||||
end
|
||||
|
||||
test "hero and progress CTAs link to the daily puzzle", %{conn: conn} do
|
||||
test "hero CTA links to the daily puzzle", %{conn: conn} do
|
||||
curated!()
|
||||
daily = DailyPuzzles.today()
|
||||
|
||||
@@ -225,10 +235,6 @@ defmodule ChesstrainerWeb.PageControllerTest do
|
||||
|
||||
assert LazyHTML.attribute(LazyHTML.query(document, ".hero-actions a"), "href") == [play_path]
|
||||
|
||||
assert LazyHTML.attribute(LazyHTML.query(document, ".progress-banner a"), "href") == [
|
||||
play_path
|
||||
]
|
||||
|
||||
refute html =~ "/endgames//play"
|
||||
end
|
||||
|
||||
@@ -258,10 +264,6 @@ defmodule ChesstrainerWeb.PageControllerTest do
|
||||
assert LazyHTML.attribute(LazyHTML.query(document, ".hero-actions a"), "href") == [
|
||||
"/endgames"
|
||||
]
|
||||
|
||||
assert LazyHTML.attribute(LazyHTML.query(document, ".progress-banner a"), "href") == [
|
||||
"/endgames"
|
||||
]
|
||||
end
|
||||
|
||||
test "unknown routes render the branded 404 page", %{conn: conn} do
|
||||
|
||||
Reference in New Issue
Block a user