From e66262edbbe25c1cd63d067ae574de32c77ad69c Mon Sep 17 00:00:00 2001
From: Domizio Demichelis
Date: Fri, 3 Jan 2025 17:56:20 +0700
Subject: [PATCH] Refactor test:
- Add ruby test for *nav_js helper with keyset_for_ui
- Add e2e test for keyset_for_ui
- Use pagy.js in all apps
- Skip data-pagy and hrefs from the snapshots
---
test/helpers/nav_tests.rb | 3 +
test/pagy/extras/bootstrap_test.rb.yaml | 115 +++++------
test/pagy/extras/bulma_test.rb.yaml | 4 +-
test/pagy/extras/pagy_test.rb.yaml | 259 ++++++++++++------------
4 files changed, 194 insertions(+), 187 deletions(-)
diff --git a/test/helpers/nav_tests.rb b/test/helpers/nav_tests.rb
index 14b72f9db..6ab23e53b 100644
--- a/test/helpers/nav_tests.rb
+++ b/test/helpers/nav_tests.rb
@@ -37,6 +37,9 @@ def nav_js_tests(prefix) # e.g. pagy_bootstrap_nav_js
# raise Pagy::VariableError for missing 0 step
pagy = Pagy.new(count: 1000, page: 20, steps: { 0 => 5, 600 => 7 })
_ { app.send(method, pagy, steps: { 600 => 7 }) }.must_raise Pagy::VariableError
+ pagyk = Pagy::KeysetForUI.new(Pet.order(:animal, :name, :id),
+ page: ['key', 2, 2, ["cat", "Ella", 18], nil])
+ _(app.send(method, pagyk)).must_rematch :keyset
end
def nav_js_countless_tests(prefix) # e.g. pagy_bootstrap_nav_js
diff --git a/test/pagy/extras/bootstrap_test.rb.yaml b/test/pagy/extras/bootstrap_test.rb.yaml
index 2eabc886c..861a5149a 100644
--- a/test/pagy/extras/bootstrap_test.rb.yaml
+++ b/test/pagy/extras/bootstrap_test.rb.yaml
@@ -1,4 +1,53 @@
---
+pagy/extras/bootstrap___pagy_bootstrap_combo_nav_js_test_0001_renders_first,_intermediate_and_last_pages:
+ :plain_1: ''
+ :extras_1: ''
+ :plain_3: ''
+ :extras_3: ''
+ :plain_6: ''
+ :extras_6: ''
pagy/extras/bootstrap___pagy_bootstrap_nav_test_0001_renders_first,_intermediate_and_last_pages:
:plain_1:
- :keyset:
-pagy/extras/bootstrap___pagy_bootstrap_combo_nav_js_test_0001_renders_first,_intermediate_and_last_pages:
- :plain_1: ''
- :extras_1: ''
- :plain_3: ''
- :extras_3: ''
- :plain_6: ''
- :extras_6: ''
-pagy/extras/bootstrap___pagy_bootstrap_nav_js_test_0001_renders_single_and_multiple_pages_when_used_with_Pagy__Countless:
- :plain_1_0:
- :extras_1_0:
- :plain_2_23:
- :extras_2_23:
pagy/extras/bootstrap___pagy_bootstrap_nav_js_test_0002_renders_first,_intermediate_and_last_pages_with_required_steps:
:plain_1:
:extras_1:
:extras_50:
+ :keyset:
+pagy/extras/bootstrap___pagy_bootstrap_nav_js_test_0001_renders_single_and_multiple_pages_when_used_with_Pagy__Countless:
+ :plain_1_0:
+ :extras_1_0:
+ :plain_2_23:
+ :extras_2_23:
diff --git a/test/pagy/extras/bulma_test.rb.yaml b/test/pagy/extras/bulma_test.rb.yaml
index fdcb4ca8e..63d506746 100644
--- a/test/pagy/extras/bulma_test.rb.yaml
+++ b/test/pagy/extras/bulma_test.rb.yaml
@@ -75,6 +75,8 @@ pagy/extras/bulma___pagy_bulma_nav_js_test_0002_renders_first,_intermediate_and_
data-pagy="WyJuaiIsWyI8YSBocmVmPVwiL2Zvbz9wYWdlPTQ5XCIgY2xhc3M9XCJwYWdpbmF0aW9uLXByZXZpb3VzXCIgYXJpYS1sYWJlbD1cIlByZXZpb3VzXCI+Jmx0OzwvYT48YSByb2xlPVwibGlua1wiIGNsYXNzPVwicGFnaW5hdGlvbi1uZXh0XCIgZGlzYWJsZWQgYXJpYS1kaXNhYmxlZD1cInRydWVcIiBhcmlhLWxhYmVsPVwiTmV4dFwiPiZndDs8L2E+PHVsIGNsYXNzPVwicGFnaW5hdGlvbi1saXN0XCI+IiwiPGxpPjxhIGhyZWY9XCIvZm9vP3BhZ2U9UCBcIiBjbGFzcz1cInBhZ2luYXRpb24tbGlua1wiPkw8L2E+PC9saT4iLCI8bGk+PGEgcm9sZT1cImxpbmtcIiBjbGFzcz1cInBhZ2luYXRpb24tbGluayBpcy1jdXJyZW50XCIgYXJpYS1jdXJyZW50PVwicGFnZVwiIGFyaWEtZGlzYWJsZWQ9XCJ0cnVlXCI+TDwvYT48L2xpPiIsIjxsaT48c3BhbiBjbGFzcz1cInBhZ2luYXRpb24tZWxsaXBzaXNcIj4maGVsbGlwOzwvc3Bhbj48L2xpPiIsIjwvdWw+Il0sWzBdLFtbMSwiZ2FwIiw0Niw0Nyw0OCw0OSwiNTAiXV0sbnVsbF0=">
:extras_50:
+ :keyset:
pagy/extras/bulma___pagy_bulma_nav_test_0001_renders_first,_intermediate_and_last_pages:
:plain_1:
- :keyset: