From 585fc8427fe13bc86265ab514d97f36c1f573118 Mon Sep 17 00:00:00 2001 From: sylph Date: Wed, 16 Apr 2025 21:10:07 -0700 Subject: [PATCH 1/2] Fix admin action page filtering - Adds a system test for filters - Properly symbolize filter params keys before passing to query object --- .../admin/action_pages_controller.rb | 2 +- spec/system/admin/action_index_spec.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 spec/system/admin/action_index_spec.rb diff --git a/app/controllers/admin/action_pages_controller.rb b/app/controllers/admin/action_pages_controller.rb index f1dd5592..29ceaff9 100644 --- a/app/controllers/admin/action_pages_controller.rb +++ b/app/controllers/admin/action_pages_controller.rb @@ -226,6 +226,6 @@ def filter_action_pages pages = pages.search(filter_params[:q]) if filter_params[:q].present? filters = filter_params[:action_filters].to_h || {} filters[:date_range] = filter_params[:date_range] - ActionPageFilters.run(relation: pages, **filters.transform_keys(&:to_sym)) + ActionPageFilters.run(relation: pages, **filters.deep_symbolize_keys.to_h) end end diff --git a/spec/system/admin/action_index_spec.rb b/spec/system/admin/action_index_spec.rb new file mode 100644 index 00000000..ba4accf9 --- /dev/null +++ b/spec/system/admin/action_index_spec.rb @@ -0,0 +1,17 @@ +require "rails_helper" + +RSpec.describe "Admin action page index", type: :system, js: true do + before { warden_sign_in(FactoryBot.create(:admin_user)) } + + it "can filter actions" do + basic = FactoryBot.create(:action_page, title: "Filtered out") + email_action = FactoryBot.create(:action_page, enable_email: true) + + visit admin_action_pages_path + fill_in_select2("#action_filters_type", with: "email") + click_on "Search" + + expect(page).to have_content(email_action.title) + expect(page).not_to have_content(basic.title) + end +end From 228842dcf40df5361def076aec83f1f62338a591 Mon Sep 17 00:00:00 2001 From: Christa Hartsock Date: Tue, 22 Apr 2025 17:12:15 -0700 Subject: [PATCH 2/2] Fix test selector --- spec/support/javascript_helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/javascript_helpers.rb b/spec/support/javascript_helpers.rb index 77426e65..611d3946 100644 --- a/spec/support/javascript_helpers.rb +++ b/spec/support/javascript_helpers.rb @@ -14,6 +14,6 @@ def fill_in_editor(locator, with:) def fill_in_select2(locator, with:) find(locator).sibling(".select2-container").click - find("li.select2-results__option[role=treeitem]", text: with).click + find("li.select2-results__option[role=option]", text: with).click end end