Skip to content

Commit

Permalink
Ensure the customer returns specs leverages time outs
Browse files Browse the repository at this point in the history
This is the most probable cause of previous flakyness.
  • Loading branch information
elia committed Dec 27, 2023
1 parent d9cb1e1 commit a14176f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions backend/spec/features/admin/orders/customer_returns_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -76,18 +76,18 @@ 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

context 'when creating a return with state "In Transit" and then marking it as "Received"' 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('Returned')
expect_order_state_label_to_eq('Returned')
end
end
end
Expand Down

0 comments on commit a14176f

Please sign in to comment.