From 51272eef0079e47260e1d2c4f88d75879bb5bb9d Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Mon, 13 Feb 2023 13:38:57 +0100 Subject: [PATCH] Actually, those two tests are in the same context The diff is pretty hard to read, but i've put the two tests "removes it from the product list" and "keeps the line item on the order (admin)" under the same context and the same `before` block --- spec/system/admin/products_spec.rb | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/spec/system/admin/products_spec.rb b/spec/system/admin/products_spec.rb index fa7d73d442..dd9777cda1 100644 --- a/spec/system/admin/products_spec.rb +++ b/spec/system/admin/products_spec.rb @@ -190,24 +190,25 @@ describe ' let!(:order) { create(:shipped_order, line_items_count: 1) } let!(:line_item) { order.reload.line_items.first } - before do - login_as_admin_and_visit spree.admin_products_path - - within "#p_#{order.variants.first.product_id}" do - accept_alert { page.find("[data-powertip=Remove]").click } - end - visit current_path - end - it 'removes it from the product list' do - expect(page).to have_selector "#p_#{product1.id}" - expect(page).not_to have_selector "#p_#{order.variants.first.product_id}" - end - context "a deleted line item from a shipped order" do before do - login_as_admin_and_visit spree.edit_admin_order_path(order) + login_as_admin_and_visit spree.admin_products_path + + within "#p_#{order.variants.first.product_id}" do + accept_alert { page.find("[data-powertip=Remove]").click } + end end + + it 'removes it from the product list' do + visit spree.admin_products_path + + expect(page).to have_selector "#p_#{product1.id}" + expect(page).not_to have_selector "#p_#{order.variants.first.product_id}" + end + it 'keeps the line item on the order (admin)' do + visit spree.edit_admin_order_path(order) + expect(page).to have_content(line_item.product.name.to_s) end end