Make test actually work
This commit is contained in:
@@ -129,31 +129,20 @@ defmodule MusicLibraryWeb.ScrobbledTracksLiveTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "Pagination" do
|
describe "Pagination" do
|
||||||
test "shows pagination when more than one page", %{conn: conn} do
|
test "navigates to next page", %{conn: conn} do
|
||||||
# Create enough tracks to require pagination (more than 200)
|
|
||||||
create_test_tracks(201)
|
create_test_tracks(201)
|
||||||
|
|
||||||
{:ok, index_live, html} = live(conn, ~p"/scrobbled-tracks")
|
{:ok, index_live, html} = live(conn, ~p"/scrobbled-tracks")
|
||||||
|
|
||||||
# Should show pagination component
|
|
||||||
assert html =~ "Next"
|
assert html =~ "Next"
|
||||||
assert has_element?(index_live, "#bottom_pagination")
|
assert has_element?(index_live, "#bottom_pagination")
|
||||||
end
|
|
||||||
|
|
||||||
test "navigates to next page", %{conn: conn} do
|
html =
|
||||||
create_test_tracks(201)
|
index_live
|
||||||
|
|> element("a[href*='page=2']", "2")
|
||||||
|
|> render_click()
|
||||||
|
|
||||||
{:ok, index_live, _html} = live(conn, ~p"/scrobbled-tracks")
|
assert html =~ "Scrobbled Tracks"
|
||||||
|
|
||||||
# Click next page button (if visible)
|
|
||||||
if has_element?(index_live, "button[patch*='page=2']") do
|
|
||||||
html =
|
|
||||||
index_live
|
|
||||||
|> element("button[patch*='page=2']")
|
|
||||||
|> render_click()
|
|
||||||
|
|
||||||
assert html =~ "Scrobbled Tracks"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user