mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Removes the need for using overlapping_elements_helper
Improves the specs so we don't need to recurr to overlapping elements clicks, and removes the respective helper
This commit is contained in:
committed by
David Cook
parent
7d1cb0c957
commit
f7c47fecc4
@@ -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
|
||||
@@ -182,7 +182,7 @@ create(:enterprise)
|
||||
def navigate_to_enterprise_users
|
||||
scroll_to(:bottom)
|
||||
within ".side_menu" do
|
||||
trigger_click(:link, "Users")
|
||||
click_link "Users"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ RSpec.describe '
|
||||
.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 @@ RSpec.describe '
|
||||
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
|
||||
|
||||
@@ -10,24 +10,32 @@ RSpec.describe '
|
||||
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 @@ RSpec.describe '
|
||||
|
||||
# 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}"
|
||||
|
||||
|
||||
@@ -516,9 +516,7 @@ RSpec.describe '
|
||||
"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
|
||||
|
||||
@@ -129,7 +129,7 @@ RSpec.describe '
|
||||
|
||||
check 'order_use_billing'
|
||||
|
||||
trigger_click(:button, 'Update')
|
||||
click_button "Update"
|
||||
|
||||
expect(page).to have_content 'Customer Details updated'
|
||||
|
||||
@@ -156,7 +156,7 @@ RSpec.describe '
|
||||
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 @@ RSpec.describe '
|
||||
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 @@ RSpec.describe '
|
||||
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 @@ RSpec.describe '
|
||||
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 @@ RSpec.describe '
|
||||
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 @@ RSpec.describe '
|
||||
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)"]
|
||||
|
||||
Reference in New Issue
Block a user