From e055b8b16c3acdbbfecba0b473530f4e061e839b Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 6 Aug 2024 12:31:54 +1000 Subject: [PATCH] Stabilise spec by not relying on record ids A spec was referring to and input id: ``` "order_cycle_incoming_exchange_0_variants_#{new_product.variants.first.id}" ``` But sometimes the exchange would have the id 1 instead of 0 and the test would fail. Instead I opted to select the field by text visible to the user. --- .../complex_editing_multiple_product_pages_spec.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/system/admin/order_cycles/complex_editing_multiple_product_pages_spec.rb b/spec/system/admin/order_cycles/complex_editing_multiple_product_pages_spec.rb index ed0fc31b20..64a7b42611 100644 --- a/spec/system/admin/order_cycles/complex_editing_multiple_product_pages_spec.rb +++ b/spec/system/admin/order_cycles/complex_editing_multiple_product_pages_spec.rb @@ -46,10 +46,9 @@ RSpec.describe ' expect_all_products_loaded - expect(page).to have_checked_field( - "order_cycle_incoming_exchange_0_variants_#{new_product.variants.first.id}", - disabled: false - ) + within("div.exchange-product", text: "Z Last Product") do + expect(page).to have_checked_field "1g", disabled: false + end end def expect_all_products_loaded