From e0c883bbfea0dc5cd4053a9a993d76a3df232468 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Tue, 11 Jun 2024 16:27:37 +0200 Subject: [PATCH] Allow Capybara to search for ARIA labels It's cumbersome to find elements by CSS selectors to click them, and the new admin has a few instances where we have no standalone label. --- .../spec/features/solidus_admin/orders/index_spec.rb | 4 +++- legacy_promotions/spec/rails_helper.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/legacy_promotions/spec/features/solidus_admin/orders/index_spec.rb b/legacy_promotions/spec/features/solidus_admin/orders/index_spec.rb index 00e0adbb5c..3dec15fffc 100644 --- a/legacy_promotions/spec/features/solidus_admin/orders/index_spec.rb +++ b/legacy_promotions/spec/features/solidus_admin/orders/index_spec.rb @@ -11,7 +11,9 @@ it "lists products", :js do visit "/admin/orders" - find("button[aria-label=Filter]").click + + click_button "Filter" + within("div[role=search]") do expect(page).to have_content("Promotions") find(:xpath, "//summary[normalize-space(text())='Promotions']").click diff --git a/legacy_promotions/spec/rails_helper.rb b/legacy_promotions/spec/rails_helper.rb index 6ed9b93cd5..dd9797bbaa 100644 --- a/legacy_promotions/spec/rails_helper.rb +++ b/legacy_promotions/spec/rails_helper.rb @@ -75,6 +75,7 @@ require 'axe-capybara' Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym +Capybara.enable_aria_label = true RSpec.configure do |config| config.fixture_path = File.join(__dir__, "fixtures")