From 676ad79d68cfe4ee9c24ea80549aa01f4d7d865a Mon Sep 17 00:00:00 2001 From: Mathias Polligkeit Date: Fri, 20 Oct 2023 06:21:08 +0900 Subject: [PATCH 1/2] fix: wrap links to first and last page in li as well --- lib/flop_phoenix.ex | 48 ++++++++++++++++-------------- test/flop_phoenix_test.exs | 60 +++++++++++++++++++------------------- 2 files changed, 56 insertions(+), 52 deletions(-) diff --git a/lib/flop_phoenix.ex b/lib/flop_phoenix.ex index 633b7fd..649730c 100644 --- a/lib/flop_phoenix.ex +++ b/lib/flop_phoenix.ex @@ -487,17 +487,19 @@ defmodule Flop.Phoenix do ~H""" """ end diff --git a/test/flop_phoenix_test.exs b/test/flop_phoenix_test.exs index 2254566..6685a67 100644 --- a/test/flop_phoenix_test.exs +++ b/test/flop_phoenix_test.exs @@ -544,7 +544,7 @@ defmodule Flop.PhoenixTest do """) - assert [link] = Floki.find(html, "a[aria-label='Go to page 1']") + assert [link] = Floki.find(html, "li a[aria-label='Go to page 1']") assert Floki.attribute(link, "href") == ["#"] assert Floki.attribute(link, "phx-click") == ["paginate"] assert Floki.attribute(link, "phx-value-page") == ["1"] @@ -559,7 +559,7 @@ defmodule Flop.PhoenixTest do """) - assert [link] = Floki.find(html, "a[aria-label='Go to page 1']") + assert [link] = Floki.find(html, "li a[aria-label='Go to page 1']") assert Floki.attribute(link, "phx-target") == ["here"] end @@ -617,12 +617,12 @@ defmodule Flop.PhoenixTest do /> """) - assert [link] = Floki.find(html, "a[aria-label='Go to page 1']") + assert [link] = Floki.find(html, "li a[aria-label='Go to page 1']") assert Floki.attribute(link, "beep") == ["boop"] assert Floki.attribute(link, "class") == ["p-link"] # current link attributes are unchanged - assert [link] = Floki.find(html, "a[aria-label='Go to page 2']") + assert [link] = Floki.find(html, "li a[aria-label='Go to page 2']") assert Floki.attribute(link, "beep") == [] assert Floki.attribute(link, "class") == ["pagination-link is-current"] end @@ -639,14 +639,14 @@ defmodule Flop.PhoenixTest do /> """) - assert [link] = Floki.find(html, "a[aria-label='Go to page 1']") + assert [link] = Floki.find(html, "li a[aria-label='Go to page 1']") assert Floki.attribute(link, "class") == ["pagination-link"] assert Floki.attribute(link, "data-phx-link") == ["patch"] assert Floki.attribute(link, "data-phx-link-state") == ["push"] assert Floki.attribute(link, "href") == ["/pets?page_size=10"] assert String.trim(Floki.text(link)) == "1" - assert [link] = Floki.find(html, "a[aria-label='Go to page 2']") + assert [link] = Floki.find(html, "li a[aria-label='Go to page 2']") assert Floki.attribute(link, "beep") == ["boop"] assert Floki.attribute(link, "class") == ["link is-active"] assert Floki.attribute(link, "data-phx-link") == ["patch"] @@ -721,7 +721,7 @@ defmodule Flop.PhoenixTest do assert [href] = Floki.attribute(previous, "href") assert_urls_match(href, "/pets", expected_query.(1)) - assert [one] = Floki.find(html, "a[aria-label='Go to page 1']") + assert [one] = Floki.find(html, "li a[aria-label='Go to page 1']") assert Floki.attribute(one, "class") == ["pagination-link"] assert Floki.attribute(one, "data-phx-link") == ["patch"] assert Floki.attribute(one, "data-phx-link-state") == ["push"] @@ -842,7 +842,7 @@ defmodule Flop.PhoenixTest do assert [href] = Floki.attribute(previous, "href") assert_urls_match(href, "/pets", expected_query.(1)) - assert [one] = Floki.find(html, "a[aria-label='Go to page 1']") + assert [one] = Floki.find(html, "li a[aria-label='Go to page 1']") assert Floki.attribute(one, "class") == ["pagination-link"] assert Floki.attribute(one, "data-phx-link") == ["patch"] assert Floki.attribute(one, "data-phx-link-state") == ["push"] @@ -898,13 +898,13 @@ defmodule Flop.PhoenixTest do """) - assert html |> Floki.find(".pagination-ellipsis") |> length() == 1 - assert html |> Floki.find(".pagination-link") |> length() == 6 + assert html |> Floki.find("li .pagination-ellipsis") |> length() == 1 + assert html |> Floki.find("li .pagination-link") |> length() == 6 - assert Floki.find(html, "a[aria-label='Go to page 20']") + assert Floki.find(html, "li a[aria-label='Go to page 20']") for i <- 1..5 do - assert Floki.find(html, "a[aria-label='Go to page #{i}']") + assert Floki.find(html, "li a[aria-label='Go to page #{i}']") end end @@ -922,10 +922,10 @@ defmodule Flop.PhoenixTest do assert html |> Floki.find(".pagination-ellipsis") |> length() == 1 assert html |> Floki.find(".pagination-link") |> length() == 6 - assert Floki.find(html, "a[aria-label='Go to page 1']") + assert Floki.find(html, "li a[aria-label='Go to page 1']") for i <- 16..20 do - assert Floki.find(html, "a[aria-label='Go to page #{i}']") + assert Floki.find(html, "li a[aria-label='Go to page #{i}']") end end @@ -943,11 +943,11 @@ defmodule Flop.PhoenixTest do assert html |> Floki.find(".pagination-ellipsis") |> length() == 2 assert html |> Floki.find(".pagination-link") |> length() == 8 - assert Floki.find(html, "a[aria-label='Go to page 1']") - assert Floki.find(html, "a[aria-label='Go to page 20']") + assert Floki.find(html, "li a[aria-label='Go to page 1']") + assert Floki.find(html, "li a[aria-label='Go to page 20']") for i <- 10..15 do - assert Floki.find(html, ".a[aria-label='Go to page #{i}']") + assert Floki.find(html, "li a[aria-label='Go to page #{i}']") end end @@ -965,11 +965,11 @@ defmodule Flop.PhoenixTest do assert html |> Floki.find(".pagination-ellipsis") |> length() == 2 assert html |> Floki.find(".pagination-link") |> length() == 7 - assert Floki.find(html, "a[aria-label='Go to page 1']") - assert Floki.find(html, "a[aria-label='Go to page 20']") + assert Floki.find(html, "li a[aria-label='Go to page 1']") + assert Floki.find(html, "li a[aria-label='Go to page 20']") for i <- 9..13 do - assert Floki.find(html, "a[aria-label='Go to page #{i}']") + assert Floki.find(html, "li a[aria-label='Go to page #{i}']") end end @@ -987,11 +987,11 @@ defmodule Flop.PhoenixTest do assert html |> Floki.find(".pagination-ellipsis") |> length() == 2 assert html |> Floki.find(".pagination-link") |> length() == 7 - assert Floki.find(html, "a[aria-label='Go to page 1']") - assert Floki.find(html, "a[aria-label='Go to page 20']") + assert Floki.find(html, "li a[aria-label='Go to page 1']") + assert Floki.find(html, "li a[aria-label='Go to page 20']") for i <- 8..12 do - assert Floki.find(html, "a[aria-label='Go to page #{i}']") + assert Floki.find(html, "li a[aria-label='Go to page #{i}']") end end @@ -1009,11 +1009,11 @@ defmodule Flop.PhoenixTest do assert html |> Floki.find(".pagination-ellipsis") |> length() == 2 assert html |> Floki.find(".pagination-link") |> length() == 7 - assert Floki.find(html, "a[aria-label='Go to page 1']") - assert Floki.find(html, "a[aria-label='Go to page 20']") + assert Floki.find(html, "li a[aria-label='Go to page 1']") + assert Floki.find(html, "li a[aria-label='Go to page 20']") for i <- 9..13 do - assert Floki.find(html, "a[aria-label='Go to page #{i}']") + assert Floki.find(html, "li a[aria-label='Go to page #{i}']") end end @@ -1031,10 +1031,10 @@ defmodule Flop.PhoenixTest do assert html |> Floki.find(".pagination-ellipsis") |> length() == 1 assert html |> Floki.find(".pagination-link") |> length() == 6 - assert Floki.find(html, "a[aria-label='Go to page 20']") + assert Floki.find(html, "li a[aria-label='Go to page 20']") for i <- 1..5 do - assert Floki.find(html, "a[aria-label='Go to page #{i}']") + assert Floki.find(html, "li a[aria-label='Go to page #{i}']") end end @@ -1052,10 +1052,10 @@ defmodule Flop.PhoenixTest do assert html |> Floki.find(".pagination-ellipsis") |> length() == 1 assert html |> Floki.find(".pagination-link") |> length() == 6 - assert Floki.find(html, "a[aria-label='Go to page 1']") + assert Floki.find(html, "li a[aria-label='Go to page 1']") for i <- 16..20 do - assert Floki.find(html, "a[aria-label='Go to page #{i}']") + assert Floki.find(html, "li a[aria-label='Go to page #{i}']") end end From 7df1fd798d3151e697585d3752e17320108896ef Mon Sep 17 00:00:00 2001 From: Mathias Polligkeit Date: Fri, 20 Oct 2023 06:22:15 +0900 Subject: [PATCH 2/2] chore: update dependencies --- mix.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mix.lock b/mix.lock index fb1fc29..818e34a 100644 --- a/mix.lock +++ b/mix.lock @@ -4,14 +4,14 @@ "credo": {:hex, :credo, "1.7.1", "6e26bbcc9e22eefbff7e43188e69924e78818e2fe6282487d0703652bc20fd62", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "e9871c6095a4c0381c89b6aa98bc6260a8ba6addccf7f6a53da8849c748a58a2"}, "decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"}, "dialyxir": {:hex, :dialyxir, "1.4.1", "a22ed1e7bd3a3e3f197b68d806ef66acb61ee8f57b3ac85fc5d57354c5482a93", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "84b795d6d7796297cca5a3118444b80c7d94f7ce247d49886e7c291e1ae49801"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.33", "3c3fd9673bb5dcc9edc28dd90f50c87ce506d1f71b70e3de69aa8154bc695d44", [:mix], [], "hexpm", "2d526833729b59b9fdb85785078697c72ac5e5066350663e5be6a1182da61b8f"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.37", "2ad73550e27c8946648b06905a57e4d454e4d7229c2dafa72a0348c99d8be5f7", [:mix], [], "hexpm", "6b19783f2802f039806f375610faa22da130b8edc21209d0bff47918bb48360e"}, "ecto": {:hex, :ecto, "3.10.3", "eb2ae2eecd210b4eb8bece1217b297ad4ff824b4384c0e3fdd28aaf96edd6135", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "44bec74e2364d491d70f7e42cd0d690922659d329f6465e89feb8a34e8cd3433"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, - "ex_doc": {:hex, :ex_doc, "0.30.6", "5f8b54854b240a2b55c9734c4b1d0dd7bdd41f71a095d42a70445c03cf05a281", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "bd48f2ddacf4e482c727f9293d9498e0881597eae6ddc3d9562bd7923375109f"}, + "ex_doc": {:hex, :ex_doc, "0.30.8", "cf3eb2eb32137966aab0929bb3af42773b2d08e2f785a5fee9caabf664082cb3", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "bfb981d8e0a8ab23857e502d611c612ae2c24536dd3b530e741d1d94ea44e6e2"}, "ex_machina": {:hex, :ex_machina, "2.7.0", "b792cc3127fd0680fecdb6299235b4727a4944a09ff0fa904cc639272cd92dc7", [:mix], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: true]}], "hexpm", "419aa7a39bde11894c87a615c4ecaa52d8f107bbdd81d810465186f783245bf8"}, "excoveralls": {:hex, :excoveralls, "0.18.0", "b92497e69465dc51bc37a6422226ee690ab437e4c06877e836f1c18daeb35da9", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "1109bb911f3cb583401760be49c02cbbd16aed66ea9509fc5479335d284da60b"}, "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, - "floki": {:hex, :floki, "0.35.0", "b24a4f416738d08e468531fe2950305a2c0582f555992dfbefc925462d24e2ea", [:mix], [], "hexpm", "381d8030f708be55380de1202872172600b00d65a62072f0e5eda5976b9de7b4"}, + "floki": {:hex, :floki, "0.35.1", "b21cf592ed38c1207c5ea52120a2e81d6ecba11337a633a3f29ec17a64033178", [:mix], [], "hexpm", "f126e3eb814f131c21befeeeb773d2c4e2331ce05214c1a9844a3edde5c69003"}, "flop": {:hex, :flop, "0.23.0", "68b07840df6dc6fc53682097f3838c8ea5b6806642c41651a2d5da85f7e676b1", [:mix], [{:ecto, "~> 3.10.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:nimble_options, "~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}], "hexpm", "0521d0cbd58433607b9e9c77e065cc00eeb6ffdacd8fa1ed009366386f72d6c0"}, "jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"}, "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},