From b013fdc43520f89051be0a25cb8db581278f3da0 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Mon, 27 Nov 2023 12:41:16 +0100 Subject: [PATCH] Extract row helpers form promotions and products --- admin/spec/features/products_spec.rb | 2 +- admin/spec/support/solidus_admin/feature_helpers.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/admin/spec/features/products_spec.rb b/admin/spec/features/products_spec.rb index 0a4cf7a6424..b390e4c24bb 100644 --- a/admin/spec/features/products_spec.rb +++ b/admin/spec/features/products_spec.rb @@ -25,7 +25,7 @@ create(:product, name: "Another product", price: 29.99) visit "/admin/products" - find('main tbody tr:nth-child(2)').find('input').check + select_row("Just a product") click_button "Delete" expect(page).to have_content("Products were successfully removed.", wait: 5) diff --git a/admin/spec/support/solidus_admin/feature_helpers.rb b/admin/spec/support/solidus_admin/feature_helpers.rb index 8754f33ee67..0f21093a108 100644 --- a/admin/spec/support/solidus_admin/feature_helpers.rb +++ b/admin/spec/support/solidus_admin/feature_helpers.rb @@ -16,5 +16,17 @@ def stub_authorization!(user) allow_any_instance_of(SolidusAdmin::BaseController).to receive(:current_ability).and_return(ability) allow_any_instance_of(Spree::Admin::BaseController).to receive(:current_ability).and_return(ability) end + + def find_row(text) + find('table tbody tr', text: text) + end + + def find_row_checkbox(text) + find_row(text).find('td:first-child input[type="checkbox"]') + end + + def select_row(text) + find_row_checkbox(text).check + end end end