diff --git a/backend/spec/features/admin/orders/customer_returns_spec.rb b/backend/spec/features/admin/orders/customer_returns_spec.rb index 0ebb2e8d99d..bd09e7128b1 100644 --- a/backend/spec/features/admin/orders/customer_returns_spec.rb +++ b/backend/spec/features/admin/orders/customer_returns_spec.rb @@ -12,8 +12,8 @@ def create_customer_return(value) click_button 'Create' end - def order_state_label - find('dd.order-state').text + def expect_order_state_label_to_eq(text) + within('dd.order-state') { expect(page).to have_content(text) } end before do @@ -29,7 +29,7 @@ def order_state_label expect(page).to have_content 'Customer Return has been successfully created' - expect(order_state_label).to eq('Returned') + expect_order_state_label_to_eq('Returned') end end @@ -54,16 +54,16 @@ def order_state_label end end - it 'marks the order as returned', :js, :flaky do + it 'marks the order as returned', :js do create_customer_return('in_transit') expect(page).to have_content 'Customer Return has been successfully created' - expect(order_state_label).to eq('Complete') + expect_order_state_label_to_eq('Complete') within('[data-hook="rejected_return_items"] tbody tr:nth-child(1)') { click_button('Receive') } - expect(order_state_label).to eq('Complete') + expect_order_state_label_to_eq('Complete') within('[data-hook="rejected_return_items"] tbody tr:nth-child(2)') { click_button('Receive') } - expect(order_state_label).to eq('Returned') + expect_order_state_label_to_eq('Returned') end end end @@ -76,7 +76,7 @@ def order_state_label create_customer_return('receive') expect(page).to have_content 'Customer Return has been successfully created' - expect(order_state_label).to eq('Returned') + expect_order_state_label_to_eq('Returned') end end @@ -84,10 +84,10 @@ def order_state_label it 'marks the order as returned', :js do create_customer_return('in_transit') expect(page).to have_content 'Customer Return has been successfully created' - expect(order_state_label).to eq('Complete') + expect_order_state_label_to_eq('Complete') within('[data-hook="rejected_return_items"] tbody tr:nth-child(1)') { click_button('Receive') } - expect(order_state_label).to eq('Returned') + expect_order_state_label_to_eq('Returned') end end end