mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Make OC edit warning modal cancel button redirect user to OC list [OFN-12774]
This commit is contained in:
committed by
Sigmund Petersen
parent
099da3fc6c
commit
a11873559b
@@ -11,8 +11,7 @@
|
||||
= t('.proceed')
|
||||
%button.button.secondary{ "ng-click": "submit($event, '#{main_app.admin_order_cycles_path}')", type: "button", style: "display: none;", data: { action: 'click->modal#close', 'trigger-action': 'saveAndBack' } }
|
||||
= t('.proceed')
|
||||
%button.button.primary{ type: "button", 'data-action': 'click->modal#close' }
|
||||
= t('.cancel')
|
||||
= link_to t('.cancel'), admin_order_cycles_path, id: 'cancel', class: 'button primary'
|
||||
|
||||
- if action == 'bulk_update'
|
||||
%button.button.secondary{ "ng-click": "saveAll($event)", type: "button", style: "display: none;", data: { action: 'click->modal#close', trigger_action: 'bulk_save' } }
|
||||
|
||||
@@ -59,6 +59,31 @@ RSpec.describe '
|
||||
expect(page).to have_field 'order_cycle_orders_close_at', with: '2024-03-30 00:00'
|
||||
expect(page).to have_content('Your order cycle has been updated.')
|
||||
end
|
||||
|
||||
it "it redirects user to oc list when modal cancel is clicked" do
|
||||
login_as_admin
|
||||
visit edit_admin_order_cycle_path(order_cycle)
|
||||
|
||||
# change date range field value
|
||||
find('#order_cycle_orders_close_at').click
|
||||
within(".flatpickr-calendar.open") do
|
||||
expect(page).to have_selector '.shortcut-buttons-flatpickr-buttons'
|
||||
select_datetime_from_datepicker Time.zone.parse("2024-03-30 00:00")
|
||||
find("button", text: "Close").click
|
||||
end
|
||||
|
||||
# click save to open warning modal
|
||||
click_button('Save')
|
||||
expect(page).to have_content('You have unsaved changes')
|
||||
expect(page).to have_content "Orders are linked to this order cycle."
|
||||
|
||||
# Now cancel modal
|
||||
within('.modal-actions') do
|
||||
click_link('Cancel')
|
||||
end
|
||||
expect(page).not_to have_content('You have unsaved changes')
|
||||
expect(page).to have_current_path admin_order_cycles_path
|
||||
end
|
||||
end
|
||||
|
||||
context 'with no attached order' do
|
||||
|
||||
Reference in New Issue
Block a user