From b8c5b24c17f1b134808888c3c803f1fddce54c9a Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 10 Jan 2025 09:54:50 +1100 Subject: [PATCH] Fix flaky admin order spec We were trying to assert values in the database withou waiting for he update to finish. First expecting the changed values on the screen ensures that Capybara waits for the action to finish. Then we can check the database. --- spec/system/admin/order_spec.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index 61a056e9c7..643c73d585 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -189,12 +189,13 @@ RSpec.describe ' expect { select2_select product.name, from: 'add_variant_id', search: true + find('button.add_variant').click + + expect(page).to have_css("#order_adjustments", text: 15.00) + expect(page).to have_css(".order-total", text: 63.99) }.to change { order_with_fees.payments.first.adjustment.amount }.from(10.00).to(15.00) .and change { order_with_fees.reload.total }.from(36.00).to(63.99) - - expect(page).to have_css("#order_adjustments", text: 15.00) - expect(page).to have_css(".order-total", text: 63.99) end end