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.
This commit is contained in:
Maikel Linke
2024-12-05 16:57:29 +11:00
parent e1febc6e00
commit e76d6ad3df

View File

@@ -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