From b1ec8941d458321751468177e293974a75a44c38 Mon Sep 17 00:00:00 2001 From: Bola Ahmed Buari Date: Mon, 15 Mar 2021 08:55:33 +0000 Subject: [PATCH] Fixes #3421: Webhook action should display hint in Scheduler and Trigger. --- .../_ui_element/ticket_perform_action.coffee | 4 +- .../tests/form_ticket_perform_action.js | 72 +------------------ 2 files changed, 5 insertions(+), 71 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee b/app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee index 429c17d21..2b57a1eea 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee @@ -94,8 +94,7 @@ class App.UiElement.ticket_perform_action item.on('change', '.js-attributeSelector select', (e) => elementRow = $(e.target).closest('.js-filterElement') groupAndAttribute = elementRow.find('.js-attributeSelector option:selected').attr('value') - meta = params[attribute.name] && params[attribute.name][groupAndAttribute] || {} - @rebuildAttributeSelectors(item, elementRow, groupAndAttribute, elements, meta, attribute) + @rebuildAttributeSelectors(item, elementRow, groupAndAttribute, elements, {}, attribute) @updateAttributeSelectors(item) ) @@ -426,6 +425,7 @@ class App.UiElement.ticket_perform_action relation: 'Webhook' value: meta.webhook_id translate: false + nulloption: true ) else webhookSelection = App.view('generic/ticket_perform_action/webhook_not_available')( attribute: attribute ) diff --git a/public/assets/tests/form_ticket_perform_action.js b/public/assets/tests/form_ticket_perform_action.js index 166e8b388..8c7d43c53 100644 --- a/public/assets/tests/form_ticket_perform_action.js +++ b/public/assets/tests/form_ticket_perform_action.js @@ -692,74 +692,8 @@ test( "ticket_perform_action check when there's an available webhook", function( var testNoticeMessage = 'No available webhook, please create a new one or activate an existing one at "Manage > Webhook"' var noticeMessage = el.find('.controls.js-webhooks').text() - notEqual(noticeMessage, testNoticeMessage, 'form shows message when webhook is not available') + notEqual(noticeMessage, testNoticeMessage, 'form does not show notice message when webhook is available') - var noticeMessage = el.find('.controls.js-webhooks select option').first().text() - equal(noticeMessage, 'Webhook test (https://target.example.com/webhook)', 'form shows message when webhook is not available') -}); - -test( "ticket_perform_action check when there's no available webhook but an inactive is already selected", function() { - - $('#forms').append('

ticket_perform_action check when there\'s an available webhook

') - var el = $('#form8') - var defaults = { - ticket_perform_action8: { - 'notification.webhook': { - webhook_id: 'c-2' - } - } - } - - App.Webhook.refresh([ - { - name: 'Webhook test', - endpoint: 'https://target.example.com/webhook', - active: false, - id: 'c-2' - } - ], { clear: true }) - - new App.ControllerForm({ - el: el, - model: { - configure_attributes: [ - { - name: 'ticket_perform_action8', - display: 'TicketPerformAction8', - tag: 'ticket_perform_action', - null: true, - notification: true, - }, - ] - }, - params: defaults, - autofocus: true - }) - - var params = App.ControllerForm.params(el) - var test_params = { - 'ticket_perform_action8': { - 'notification.webhook': { - 'webhook_id': 'c-2' - } - } - } - deepEqual(params, test_params, 'form param check') - - var testNoticeMessage = 'No available webhook, please create a new one or activate an existing one at "Manage > Webhook"' - var noticeMessage = el.find('.controls.js-webhooks div').text() - notEqual(noticeMessage, testNoticeMessage, 'form does not show notice message when inactive webhook is previously selected') - - var noticeMessage = el.find('.controls.js-webhooks select option').first().text() - equal(noticeMessage, 'Webhook test (https://target.example.com/webhook) (inactive)', 'form shows previously selected inactive webhook') - - // when other option are changed - el.find('select:first').val('notification.email').trigger('change') - el.find('select:first').val('notification.webhook').trigger('change') - - var noticeMessage = el.find('.controls.js-webhooks div').text() - notEqual(noticeMessage, testNoticeMessage, 'form does not show notice message when inactive webhook is previously selected') - - var noticeMessage = el.find('.controls.js-webhooks select option').first().text() - equal(noticeMessage, 'Webhook test (https://target.example.com/webhook) (inactive)', 'form shows previously selected inactive webhook') + var noticeMessage = el.find('.controls.js-webhooks select option').eq(1).text() + equal(noticeMessage, 'Webhook test (https://target.example.com/webhook)', 'form shows available webhook when webhook is available') });