From 91fddeaa8b62cf4d88d621dfb4cd2a9ea5e72076 Mon Sep 17 00:00:00 2001 From: wandji20 Date: Tue, 9 Jul 2024 23:16:46 +0100 Subject: [PATCH] Fix failing spec [OFN-11613] --- app/webpacker/controllers/mixins/useOpenAndCloseAsAModal.js | 3 +++ spec/system/admin/subscriptions/smoke_tests_spec.rb | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/webpacker/controllers/mixins/useOpenAndCloseAsAModal.js b/app/webpacker/controllers/mixins/useOpenAndCloseAsAModal.js index 3c9e3d7b3d..7648563791 100644 --- a/app/webpacker/controllers/mixins/useOpenAndCloseAsAModal.js +++ b/app/webpacker/controllers/mixins/useOpenAndCloseAsAModal.js @@ -12,6 +12,9 @@ export const useOpenAndCloseAsAModal = (controller) => { }.bind(controller), close: function (_event, remove = false) { + // Only execute close if there is an open modal + if (!document.querySelector("body").classList.contains('modal-open')) return; + this.modalTarget.classList.remove("in"); this.backgroundTarget.classList.remove("in"); document.querySelector("body").classList.remove("modal-open"); diff --git a/spec/system/admin/subscriptions/smoke_tests_spec.rb b/spec/system/admin/subscriptions/smoke_tests_spec.rb index 19f224f41d..837555b9ff 100644 --- a/spec/system/admin/subscriptions/smoke_tests_spec.rb +++ b/spec/system/admin/subscriptions/smoke_tests_spec.rb @@ -125,8 +125,9 @@ RSpec.describe 'Subscriptions' do select_datetime_from_datepicker Time.zone.at(1.month.from_now) find("body").send_keys(:escape) - click_button 'Save' - + # Click save and comfirm in warning modal (because date time range value was changed) + click_button('Save') + click_button('Proceed anyway') visit edit_admin_subscription_path(subscription) click_button 'edit-products'