Fixes #3453 - Removal of referenced webhooks does not provide error toast within UI

This commit is contained in:
Mantas 2021-03-24 11:40:16 +02:00 committed by Thorsten Eckel
parent 95a6625f05
commit 89c3a5e9c9
3 changed files with 28 additions and 4 deletions

View file

@ -15,9 +15,9 @@ class App.ControllerGenericDestroyConfirm extends App.ControllerModal
@close() @close()
if @callback if @callback
@callback() @callback()
options.fail = => options.fail = (xhr, data) =>
@log 'errors' @log 'errors'
@close() @showAlert(data.human_error || data.error)
@item.destroy(options) @item.destroy(options)
class App.ControllerConfirm extends App.ControllerModal class App.ControllerConfirm extends App.ControllerModal

View file

@ -248,12 +248,13 @@ module CommonActions
# Executes action inside of modal. Makes sure modal has opened and closes # Executes action inside of modal. Makes sure modal has opened and closes
# #
# @param timeout [Integer] seconds to wait # @param timeout [Integer] seconds to wait
def in_modal(timeout: 4, &block) # @param wait_for_disappear [Bool] wait for modal to close
def in_modal(timeout: 4, disappears: true, &block)
modal_ready(timeout: timeout) modal_ready(timeout: timeout)
within('.modal', &block) within('.modal', &block)
modal_disappear(timeout: timeout) modal_disappear(timeout: timeout) if disappears
end end
end end

View file

@ -0,0 +1,23 @@
require 'rails_helper'
RSpec.describe 'Manage > Webhook', type: :system do
context 'deleting' do
let!(:webhook) { create(:webhook) }
let!(:trigger) { create(:trigger, perform: { 'notification.webhook' => { 'webhook_id' => webhook.id.to_s } }) }
it 'referenced webhook shows error message' do
visit '/#manage/webhook'
within :active_content do
click '.js-action'
click '.js-delete'
end
in_modal disappears: false do
click '.js-submit'
expect(page).to have_text('Cannot delete').and(have_text("##{trigger.id}"))
end
end
end
end