Skip to content

Commit

Permalink
Removes the need for using overlapping_elements_helper
Browse files Browse the repository at this point in the history
Improves the specs so we don't need to recurr to overlapping elements clicks, and removes the respective helper
  • Loading branch information
filipefurtad0 committed Jul 10, 2024
1 parent 144c002 commit 48c501f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 33 deletions.
11 changes: 0 additions & 11 deletions spec/support/overlapping_elements_helper.rb

This file was deleted.

2 changes: 1 addition & 1 deletion spec/system/admin/enterprise_roles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/system/admin/order_cycles/complex_editing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
28 changes: 19 additions & 9 deletions spec/system/admin/order_cycles/list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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}"

Expand Down
4 changes: 1 addition & 3 deletions spec/system/admin/order_cycles/simple_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions spec/system/admin/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)"]
Expand Down

0 comments on commit 48c501f

Please sign in to comment.