From be1e39f0cb6c1bcfa346dab7227d96e5b267459e Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 7 Jul 2020 10:31:54 +0200 Subject: [PATCH 1/3] Ensure next page has loaded before interacting with form elements --- .../admin/order_cycles/complex_updating_specific_time_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/features/admin/order_cycles/complex_updating_specific_time_spec.rb b/spec/features/admin/order_cycles/complex_updating_specific_time_spec.rb index 258caa1080..fb90552e88 100644 --- a/spec/features/admin/order_cycles/complex_updating_specific_time_spec.rb +++ b/spec/features/admin/order_cycles/complex_updating_specific_time_spec.rb @@ -87,6 +87,7 @@ feature ' select 'Supplier fee 2', from: 'order_cycle_incoming_exchange_2_enterprise_fees_0_enterprise_fee_id' click_button 'Save and Next' + expect(page).to have_content 'Your order cycle has been updated.' # And I add a distributor and some products select 'My distributor', from: 'new_distributor_id' From c8254b833886f84deed2c3532cd6a65cc8fa3e9d Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 7 Jul 2020 10:38:06 +0200 Subject: [PATCH 2/3] Adjust exchange_row assertion to use slightly more specific criteria --- .../order_cycles/complex_updating_specific_time_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/features/admin/order_cycles/complex_updating_specific_time_spec.rb b/spec/features/admin/order_cycles/complex_updating_specific_time_spec.rb index fb90552e88..52c7d45f78 100644 --- a/spec/features/admin/order_cycles/complex_updating_specific_time_spec.rb +++ b/spec/features/admin/order_cycles/complex_updating_specific_time_spec.rb @@ -109,8 +109,10 @@ feature ' exchange_rows = page.all("table.exchanges tbody") exchange_rows.each do |exchange_row| exchange_row.find("td.products").click - # Wait for the products panel to be visible. - expect(exchange_row).to have_selector "tr", count: 2 + within(exchange_row) do + # Wait for the products panel to be visible. + expect(page).to have_selector ".exchange-distributed-products" + end end uncheck "order_cycle_outgoing_exchange_2_variants_#{v1.id}" From e74206995900757182bd17423e3b03e582312eae Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 7 Jul 2020 12:10:43 +0200 Subject: [PATCH 3/3] Refactor UI interactions for opening exchange product tabs in OC edit --- .../complex_updating_specific_time_spec.rb | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/spec/features/admin/order_cycles/complex_updating_specific_time_spec.rb b/spec/features/admin/order_cycles/complex_updating_specific_time_spec.rb index 52c7d45f78..2094a83f7e 100644 --- a/spec/features/admin/order_cycles/complex_updating_specific_time_spec.rb +++ b/spec/features/admin/order_cycles/complex_updating_specific_time_spec.rb @@ -69,7 +69,8 @@ feature ' select 'My supplier', from: 'new_supplier_id' click_button 'Add supplier' expect(page).to have_selector("table.exchanges tr.supplier", text: "My supplier") - page.all("table.exchanges tr.supplier td.products").each(&:click) + + open_all_exchange_product_tabs expect(page).to have_selector "#order_cycle_incoming_exchange_1_variants_#{initial_variants.last.id}", visible: true page.find("#order_cycle_incoming_exchange_1_variants_#{initial_variants.last.id}", visible: true).click # uncheck (with visible:true filter) @@ -106,14 +107,7 @@ feature ' find(:css, "tags-input .tags input").set "wholesale\n" end - exchange_rows = page.all("table.exchanges tbody") - exchange_rows.each do |exchange_row| - exchange_row.find("td.products").click - within(exchange_row) do - # Wait for the products panel to be visible. - expect(page).to have_selector ".exchange-distributed-products" - end - end + open_all_exchange_product_tabs uncheck "order_cycle_outgoing_exchange_2_variants_#{v1.id}" check "order_cycle_outgoing_exchange_2_variants_#{v2.id}" @@ -168,4 +162,15 @@ feature ' def wait_for_edit_form_to_load_order_cycle(order_cycle) expect(page).to have_field "order_cycle_name", with: order_cycle.name end + + def open_all_exchange_product_tabs + exchange_rows = page.all("table.exchanges tbody") + exchange_rows.each do |exchange_row| + exchange_row.find("td.products").click + within(exchange_row) do + # Wait for the products panel to be visible. + expect(page).to have_selector ".exchange-products" + end + end + end end