From e76d6ad3df2ed6b018efc614d2c14ab74d2e1c24 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 5 Dec 2024 16:57:29 +1100 Subject: [PATCH] Spec current order cancellation amending backorder The cancellation happens async in Javascript. Therefore we need to wait for and outcome on the page to know that the action finished. The expectation needs to be around that whole block. We actually want only one job enqueued if the same backorder is affected. Time to fix that. --- spec/system/admin/orders/bulk_actions_spec.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/spec/system/admin/orders/bulk_actions_spec.rb b/spec/system/admin/orders/bulk_actions_spec.rb index cb77f6d414..c8b1a66553 100644 --- a/spec/system/admin/orders/bulk_actions_spec.rb +++ b/spec/system/admin/orders/bulk_actions_spec.rb @@ -467,18 +467,21 @@ RSpec.describe ' }.not_to enqueue_mail end + expect(page).not_to have_content "This will cancel the current order." + page.find("span.icon-reorder", text: "Actions").click within ".ofn-drop-down .menu" do page.find("span", text: "Cancel Orders").click end - within ".reveal-modal" do - expect { + expect { + within ".reveal-modal" do click_on "Confirm" # Confirms the cancel action - }.not_to enqueue_mail - end - - expect(page).to have_content("CANCELLED", count: 2) + end + expect(page).to have_content("CANCELLED", count: 2) + }.to enqueue_job(AmendBackorderJob).exactly(:twice) + # You can't combine negative matchers. + .and enqueue_mail.exactly(0).times end end