mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
show live player count on landing page
This commit is contained in:
@@ -54,23 +54,23 @@ defmodule ChesstrainerWeb.LandingComponentsTest do
|
||||
assert html =~ "currentColor"
|
||||
end
|
||||
|
||||
describe "puzzle_count_label/1" do
|
||||
describe "count_label/1" do
|
||||
test "shows counts below 100 exactly" do
|
||||
assert LandingComponents.puzzle_count_label(0) == "0"
|
||||
assert LandingComponents.puzzle_count_label(47) == "47"
|
||||
assert LandingComponents.puzzle_count_label(99) == "99"
|
||||
assert LandingComponents.count_label(0) == "0"
|
||||
assert LandingComponents.count_label(47) == "47"
|
||||
assert LandingComponents.count_label(99) == "99"
|
||||
end
|
||||
|
||||
test "floors counts of 100 or more to hundreds" do
|
||||
assert LandingComponents.puzzle_count_label(100) == "100+"
|
||||
assert LandingComponents.puzzle_count_label(199) == "100+"
|
||||
assert LandingComponents.puzzle_count_label(999) == "900+"
|
||||
assert LandingComponents.count_label(100) == "100+"
|
||||
assert LandingComponents.count_label(199) == "100+"
|
||||
assert LandingComponents.count_label(999) == "900+"
|
||||
end
|
||||
|
||||
test "floors counts of 1000 or more to thousands" do
|
||||
assert LandingComponents.puzzle_count_label(1000) == "1000+"
|
||||
assert LandingComponents.puzzle_count_label(1999) == "1000+"
|
||||
assert LandingComponents.puzzle_count_label(2400) == "2000+"
|
||||
assert LandingComponents.count_label(1000) == "1000+"
|
||||
assert LandingComponents.count_label(1999) == "1000+"
|
||||
assert LandingComponents.count_label(2400) == "2000+"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,10 @@ defmodule ChesstrainerWeb.PageControllerTest do
|
||||
use ChesstrainerWeb.ConnCase
|
||||
|
||||
import Chesstrainer.AccountsFixtures
|
||||
import Chesstrainer.EndgamesFixtures
|
||||
|
||||
alias Chesstrainer.Accounts.Scope
|
||||
alias Chesstrainer.Attempts
|
||||
alias Chesstrainer.DailyPuzzles
|
||||
alias Chesstrainer.Endgames
|
||||
alias Chesstrainer.Themes
|
||||
@@ -89,6 +92,17 @@ defmodule ChesstrainerWeb.PageControllerTest do
|
||||
end
|
||||
end
|
||||
|
||||
test "hero shows the number of players with at least one attempt", %{conn: conn} do
|
||||
user = user_fixture()
|
||||
endgame = endgame_fixture()
|
||||
{:ok, _} = Attempts.record_attempt(Scope.for_user(user), endgame, :solved)
|
||||
|
||||
html = conn |> get(~p"/") |> html_response(200)
|
||||
document = LazyHTML.from_document(html)
|
||||
|
||||
assert LazyHTML.text(LazyHTML.query(document, ".rating-note strong")) == "1"
|
||||
end
|
||||
|
||||
test "guest navbar links to log in and register", %{conn: conn} do
|
||||
html = conn |> get(~p"/") |> html_response(200)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user