diff --git a/spec/support/overlapping_elements_helper.rb b/spec/support/overlapping_elements_helper.rb deleted file mode 100644 index 4a2ff2ab437c..000000000000 --- a/spec/support/overlapping_elements_helper.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -def dismiss_warning - # Click dismiss on distributor warning - click_button 'Dismiss' -end - -def trigger_click(id, text) - # replace node buy the elements node, for example - page.find(id, text).trigger("click") -end diff --git a/spec/system/admin/enterprise_roles_spec.rb b/spec/system/admin/enterprise_roles_spec.rb index 4d4742bf9da2..43b08b17f6ff 100644 --- a/spec/system/admin/enterprise_roles_spec.rb +++ b/spec/system/admin/enterprise_roles_spec.rb @@ -182,7 +182,7 @@ def navigate_to_enterprise_users scroll_to(:bottom) within ".side_menu" do - trigger_click(:link, "Users") + click_link "Users" end end diff --git a/spec/system/admin/order_cycles/complex_editing_spec.rb b/spec/system/admin/order_cycles/complex_editing_spec.rb index e8e097d75d11..19b22ca465a2 100644 --- a/spec/system/admin/order_cycles/complex_editing_spec.rb +++ b/spec/system/admin/order_cycles/complex_editing_spec.rb @@ -32,7 +32,7 @@ .to eq(oc.orders_close_at.strftime("%Y-%m-%d %H:%M")) expect(page).to have_content "Coordinator #{oc.coordinator.name}" - trigger_click(:button, 'Next') + click_button "Next" # And I should see the suppliers expect(page).to have_selector 'td.supplier_name', text: oc.suppliers.first.name @@ -76,7 +76,7 @@ selected: supplier.enterprise_fees.first.name ) - trigger_click(:button, 'Next') + click_button "Next" # And I should see the distributors expect(page).to have_selector 'td.distributor_name', text: oc.distributors.first.name diff --git a/spec/system/admin/order_cycles/list_spec.rb b/spec/system/admin/order_cycles/list_spec.rb index ea71316afba8..9fba7e4ac1e6 100644 --- a/spec/system/admin/order_cycles/list_spec.rb +++ b/spec/system/admin/order_cycles/list_spec.rb @@ -10,24 +10,32 @@ include AuthenticationHelper include WebHelper + let(:hub) { create(:distributor_enterprise, with_payment_and_shipping: true) } + it "listing and filtering order cycles" do # Given some order cycles (created in an arbitrary order) oc4 = create(:simple_order_cycle, name: 'oc4', orders_open_at: 2.days.from_now, - orders_close_at: 1.month.from_now) - oc2 = create(:simple_order_cycle, name: 'oc2', orders_close_at: 1.month.from_now) + orders_close_at: 1.month.from_now, distributors: [hub]) + oc2 = create(:simple_order_cycle, name: 'oc2', + orders_close_at: 1.month.from_now, distributors: [hub]) oc6 = create(:simple_order_cycle, name: 'oc6', - orders_open_at: 1.month.ago, orders_close_at: 3.weeks.ago) + orders_open_at: 1.month.ago, orders_close_at: 3.weeks.ago, + distributors: [hub]) oc3 = create(:simple_order_cycle, name: 'oc3', orders_open_at: 1.day.from_now, - orders_close_at: 1.month.from_now) + orders_close_at: 1.month.from_now, + distributors: [hub]) oc5 = create(:simple_order_cycle, name: 'oc5', - orders_open_at: 1.month.ago, orders_close_at: 2.weeks.ago) - oc1 = create(:order_cycle, name: 'oc1') + orders_open_at: 1.month.ago, orders_close_at: 2.weeks.ago, + distributors: [hub]) + oc1 = create(:order_cycle, name: 'oc1', distributors: [hub]) oc0 = create(:simple_order_cycle, name: 'oc0', - orders_open_at: nil, orders_close_at: nil) + orders_open_at: nil, orders_close_at: nil, + distributors: [hub]) oc7 = create(:simple_order_cycle, name: 'oc7', - orders_open_at: 2.months.ago, orders_close_at: 5.weeks.ago) + orders_open_at: 2.months.ago, orders_close_at: 5.weeks.ago, + distributors: [hub]) schedule1 = create(:schedule, name: 'Schedule1', order_cycles: [oc1, oc3]) create(:proxy_order, subscription: create(:subscription, schedule: schedule1), order_cycle: oc1) @@ -73,7 +81,9 @@ # I can load more order_cycles expect(page).not_to have_selector "#listing_order_cycles tr.order-cycle-#{oc7.id}" - trigger_click(:button, "Show 30 more days") + # binding.pry + # trigger_click(:button, "Show 30 more days") + click_button "Show 30 more days" expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc7.id}" diff --git a/spec/system/admin/order_cycles/simple_spec.rb b/spec/system/admin/order_cycles/simple_spec.rb index 74f077de9bc9..841b4688a13b 100644 --- a/spec/system/admin/order_cycles/simple_spec.rb +++ b/spec/system/admin/order_cycles/simple_spec.rb @@ -516,9 +516,7 @@ "table.exchanges tr.distributor-#{distributor_managed.id} td.tags" ) - # When I save, any exchanges that I can't manage remain - # overlapping warning, we need to use 'node.trigger("click")' - page.find(:button, "Save").trigger("click") + click_button "Save" expect(page).to have_content "Your order cycle has been updated." oc.reload diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index bf77b56de6be..90c5028f393a 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -129,7 +129,7 @@ def new_order_with_distribution(distributor, order_cycle) check 'order_use_billing' - trigger_click(:button, 'Update') + click_button "Update" expect(page).to have_content 'Customer Details updated' @@ -156,7 +156,7 @@ def new_order_with_distribution(distributor, order_cycle) expect(page).to have_field 'order_email', with: customer3.email expect do - trigger_click(:button, 'Update') + click_button "Update" expect(page).to have_content 'Customer Details updated' end.to change { order.reload.customer }.from(customer2).to(customer3) end @@ -292,7 +292,7 @@ def new_order_with_distribution(distributor, order_cycle) login_as_admin visit spree.edit_admin_order_path(order) - dismiss_warning + click_button 'Dismiss' expect(page).to have_select2 "order_distributor_id", with_options: [d.name] select2_select d.name, from: 'order_distributor_id' @@ -778,7 +778,7 @@ def new_order_with_distribution(distributor, order_cycle) visit spree.edit_admin_order_path(order) expect(page).not_to have_content different_shipping_method_for_distributor1.name - dismiss_warning + click_button 'Dismiss' find('.edit-method').click @@ -1088,7 +1088,7 @@ def new_order_with_distribution(distributor, order_cycle) end # updates the order and verifies the warning disappears - trigger_click(:button, 'Update And Recalculate Fees') + click_button "Update And Recalculate Fees" expect(page).not_to have_content "Out of Stock" end end @@ -1099,7 +1099,7 @@ def new_order_with_distribution(distributor, order_cycle) expect(page).to have_selector 'h1', text: 'Customer Details' click_link "Order Details" - dismiss_warning + click_button 'Dismiss' expect(page).to have_content 'Add Product' select2_select product.name, from: 'add_variant_id', search: true @@ -1111,7 +1111,7 @@ def new_order_with_distribution(distributor, order_cycle) expect(page).to have_select2 'order_distributor_id', with_options: [distributor1.name] expect(page).not_to have_select2 'order_distributor_id', with_options: [distributor2.name] - dismiss_warning + click_button 'Dismiss' expect(page).to have_select2 'order_order_cycle_id', with_options: ["#{order_cycle1.name} (open)"]