diff --git a/app/assets/javascripts/app/controllers/_channel/form.coffee b/app/assets/javascripts/app/controllers/_channel/form.coffee index f417f45f8..c5e6bad56 100644 --- a/app/assets/javascripts/app/controllers/_channel/form.coffee +++ b/app/assets/javascripts/app/controllers/_channel/form.coffee @@ -13,11 +13,12 @@ class App.ChannelForm extends App.ControllerContent constructor: -> super @title 'Form' - @subscribeId = App.Setting.subscribe(@render, initFetch: true, clear: false) + App.Setting.fetchFull( + @render + force: false + ) render: => - App.Setting.unsubscribe(@subscribeId) - setting = App.Setting.get('form_ticket_create') @html App.view('channel/form')( baseurl: window.location.origin @@ -29,9 +30,6 @@ class App.ChannelForm extends App.ControllerContent @updateParams() - release: => - App.Setting.unsubscribe(@subscribeId) - updateParams: -> quote = (string) -> string = string.replace('\'', '\\\'') diff --git a/app/assets/javascripts/app/controllers/_integration/_base.coffee b/app/assets/javascripts/app/controllers/_integration/_base.coffee index 07a9e02a5..246871882 100644 --- a/app/assets/javascripts/app/controllers/_integration/_base.coffee +++ b/app/assets/javascripts/app/controllers/_integration/_base.coffee @@ -1,7 +1,5 @@ class App.ControllerIntegrationBase extends App.Controller events: - 'click .js-submit': 'submit' - 'submit .js-form': 'submit' 'change .js-switch input': 'switch' featureIntegration: 'tbd_integration' @@ -17,7 +15,10 @@ class App.ControllerIntegrationBase extends App.Controller @initalRender = true - @subscribeId = App.Setting.subscribe(@render, initFetch: true, clear: false) + App.Setting.fetchFull( + @render + force: false + ) switch: => value = @$('.js-switch input').prop('checked') @@ -32,39 +33,3 @@ class App.ControllerIntegrationBase extends App.Controller featureEnabled: App.Setting.get(@featureIntegration) ) @initalRender = false - - submit: (e) => - e.preventDefault() - - params = @formParam(e.target) - - if @featureArea - count = 0 - for name, value of params - if App.Setting.findByAttribute('name', name) - count += 1 - App.Setting.set( - name, - value, - done: -> - count -= 1 - if count == 0 - App.Event.trigger 'notify', { - type: 'success' - msg: App.i18n.translateContent('Update successful!') - timeout: 2000 - } - App.Setting.preferencesPost(@) - - fail: (settings, details) -> - App.Event.trigger 'notify', { - type: 'error' - msg: App.i18n.translateContent(details.error_human || details.error || 'Unable to update object!') - timeout: 2000 - } - ) - return - - value = - items: [params] - App.Setting.set(@featureConfig, value, {notify: true}) diff --git a/app/assets/javascripts/app/controllers/_integration/clearbit.coffee b/app/assets/javascripts/app/controllers/_integration/clearbit.coffee index e13340953..e1c600150 100644 --- a/app/assets/javascripts/app/controllers/_integration/clearbit.coffee +++ b/app/assets/javascripts/app/controllers/_integration/clearbit.coffee @@ -28,11 +28,10 @@ class Form extends App.Controller constructor: -> super - - @subscribeId = App.Setting.subscribe(@render, initFetch: true, clear: false) + @render() currentConfig: -> - config = App.Setting.get('clearbit_config') + config = clone(App.Setting.get('clearbit_config')) if !config config = {} if config.organization_autocreate is undefined @@ -60,8 +59,8 @@ class Form extends App.Controller App.Setting.set('clearbit_config', value, {notify: true}) render: => - @config = @currentConfig() - + if !@config + @config = @currentConfig() settings = [ { name: 'api_key', display: 'API Key', tag: 'input', type: 'text', limit: 100, null: false, placeholder: '...', note: 'Your api key.' }, { name: 'organization_autocreate', display: 'Auto create', tag: 'boolean', type: 'boolean', null: false, note: 'Create organizations automatically if record has one.' }, @@ -125,8 +124,8 @@ class Form extends App.Controller element = $(e.currentTarget).closest('tr') source = @cleanupInput(element.find('input[name="source"]').val()) destination = @cleanupInput(element.find('input[name="destination"]').val()) + return if _.isEmpty(source) || _.isEmpty(destination) @config.user_sync[source] = destination - @setConfig(@config) @render() addOrganizationSync: (e) => @@ -135,8 +134,8 @@ class Form extends App.Controller element = $(e.currentTarget).closest('tr') source = @cleanupInput(element.find('input[name="source"]').val()) destination = @cleanupInput(element.find('input[name="destination"]').val()) + return if _.isEmpty(source) || _.isEmpty(destination) @config.organization_sync[source] = destination - @setConfig(@config) @render() removeRow: (e) => @@ -144,6 +143,7 @@ class Form extends App.Controller @updateCurrentConfig() element = $(e.currentTarget).closest('tr') element.remove() + @updateCurrentConfig() class State @current: -> diff --git a/app/assets/javascripts/app/controllers/_integration/sipgate_io.coffee b/app/assets/javascripts/app/controllers/_integration/sipgate_io.coffee index 5d3197de7..db8a71ede 100644 --- a/app/assets/javascripts/app/controllers/_integration/sipgate_io.coffee +++ b/app/assets/javascripts/app/controllers/_integration/sipgate_io.coffee @@ -28,7 +28,7 @@ class Form extends App.Controller constructor: -> super - @subscribeId = App.Setting.subscribe(@render, initFetch: true, clear: false) + @render() currentConfig: -> config = App.Setting.get('sipgate_config') @@ -101,11 +101,11 @@ class Form extends App.Controller element = $(e.currentTarget).closest('tr') caller_id = element.find('input[name="caller_id"]').val() note = element.find('input[name="note"]').val() + return if _.isEmpty(caller_id) || _.isEmpty(note) @config.inbound.block_caller_ids.push { caller_id: @cleanupInput(caller_id) note: note } - @setConfig(@config) @render() addOutboundRouting: (e) => @@ -115,12 +115,12 @@ class Form extends App.Controller dest = @cleanupInput(element.find('input[name="dest"]').val()) caller_id = @cleanupInput(element.find('input[name="caller_id"]').val()) note = element.find('input[name="note"]').val() + return if _.isEmpty(caller_id) || _.isEmpty(dest) || _.isEmpty(note) @config.outbound.routing_table.push { dest: dest caller_id: caller_id note: note } - @setConfig(@config) @render() removeInboundBlockCallerId: (e) => @@ -128,12 +128,14 @@ class Form extends App.Controller @updateCurrentConfig() element = $(e.currentTarget).closest('tr') element.remove() + @updateCurrentConfig() removeOutboundRouting: (e) => e.preventDefault() @updateCurrentConfig() element = $(e.currentTarget).closest('tr') element.remove() + @updateCurrentConfig() class State @current: -> diff --git a/app/assets/javascripts/app/controllers/_integration/slack.coffee b/app/assets/javascripts/app/controllers/_integration/slack.coffee index a34c01f6f..106303127 100644 --- a/app/assets/javascripts/app/controllers/_integration/slack.coffee +++ b/app/assets/javascripts/app/controllers/_integration/slack.coffee @@ -6,6 +6,10 @@ class Index extends App.ControllerIntegrationBase ['This service sends notifications to your %s channel.', 'Slack'] ['To setup this Service you need to create a new |"Incoming webhook"| in your %s integration panel, and enter the Webhook URL below.', 'Slack'] ] + events: + 'click .js-submit': 'update' + 'submit .js-form': 'update' + 'change .js-switch input': 'switch' render: => super @@ -63,6 +67,13 @@ class Index extends App.ControllerIntegrationBase facility: 'slack_webhook' ) + update: (e) => + e.preventDefault() + params = @formParam(e.target) + value = + items: [params] + App.Setting.set(@featureConfig, value, {notify: true}) + class State @current: -> App.Setting.get('slack_integration') diff --git a/app/assets/javascripts/app/controllers/_settings/area.coffee b/app/assets/javascripts/app/controllers/_settings/area.coffee index 97b58a5d8..7cb2e6bfe 100644 --- a/app/assets/javascripts/app/controllers/_settings/area.coffee +++ b/app/assets/javascripts/app/controllers/_settings/area.coffee @@ -4,11 +4,11 @@ class App.SettingsArea extends App.Controller # check authentication @authenticateCheckRedirect() - if App.Setting.count() is 0 - App.Setting.fetchFull(@render) - return - @render() - #@subscribeId = App.Setting.subscribe(@render, initFetch: true, clear: false) + + App.Setting.fetchFull( + @render + force: false + ) render: => diff --git a/app/assets/javascripts/app/controllers/_settings/form.coffee b/app/assets/javascripts/app/controllers/_settings/form.coffee index 9328d876c..0c7a6d6d0 100644 --- a/app/assets/javascripts/app/controllers/_settings/form.coffee +++ b/app/assets/javascripts/app/controllers/_settings/form.coffee @@ -8,7 +8,10 @@ class App.SettingsForm extends App.Controller # check authentication @authenticateCheckRedirect() - @subscribeId = App.Setting.subscribe(@render, initFetch: true, clear: false) + App.Setting.fetchFull( + @render + force: false + ) render: => @@ -51,6 +54,7 @@ class App.SettingsForm extends App.Controller update: (e) => e.preventDefault() + #e.stopPropagation() @formDisable(e) params = @formParam(e.target) diff --git a/app/assets/javascripts/app/models/_application_model.coffee b/app/assets/javascripts/app/models/_application_model.coffee index d6639a4da..c2f1259a8 100644 --- a/app/assets/javascripts/app/models/_application_model.coffee +++ b/app/assets/javascripts/app/models/_application_model.coffee @@ -494,6 +494,7 @@ class App.Model extends Spine.Model App.Model.fetchFull( @callback clear: true + force: false # only do server call if no record exsits ) @@ -501,6 +502,11 @@ class App.Model extends Spine.Model @fetchFull: (callback, params = {}) -> url = "#{@url}/?full=true" App.Log.debug('Model', "fetchFull collection #{@className}", url) + if params.force is false && App[@className].count() isnt 0 + if callback + callback(App[@className].all()) + return + App.Ajax.request( type: 'GET' url: url diff --git a/app/assets/javascripts/app/views/integration/clearbit.jst.eco b/app/assets/javascripts/app/views/integration/clearbit.jst.eco index 2ffb40f3d..6265fd38a 100644 --- a/app/assets/javascripts/app/views/integration/clearbit.jst.eco +++ b/app/assets/javascripts/app/views/integration/clearbit.jst.eco @@ -1,7 +1,7 @@
- +
+ +
<%- @T('Title') %> @@ -38,7 +38,7 @@
<%- @Icon('trash') %> <%- @T('Remove') %>
<% end %> -
<%- @Icon('plus-small') %> <%- @T('Add') %>
@@ -63,13 +63,12 @@
<%- @Icon('trash') %> <%- @T('Remove') %>
<% end %> -
<%- @Icon('plus-small') %> <%- @T('Add') %>
- - +
\ No newline at end of file diff --git a/app/assets/javascripts/app/views/integration/sipgate.jst.eco b/app/assets/javascripts/app/views/integration/sipgate.jst.eco index a21d2c380..9c3f5e98a 100644 --- a/app/assets/javascripts/app/views/integration/sipgate.jst.eco +++ b/app/assets/javascripts/app/views/integration/sipgate.jst.eco @@ -74,5 +74,5 @@ - + \ No newline at end of file diff --git a/app/assets/javascripts/app/views/settings/form.jst.eco b/app/assets/javascripts/app/views/settings/form.jst.eco index 8596311c9..021712101 100644 --- a/app/assets/javascripts/app/views/settings/form.jst.eco +++ b/app/assets/javascripts/app/views/settings/form.jst.eco @@ -17,5 +17,5 @@ - + \ No newline at end of file diff --git a/db/migrate/20120101000001_create_base.rb b/db/migrate/20120101000001_create_base.rb index 40a3be604..6ee31aaa6 100644 --- a/db/migrate/20120101000001_create_base.rb +++ b/db/migrate/20120101000001_create_base.rb @@ -344,11 +344,11 @@ class CreateBase < ActiveRecord::Migration t.string :area, limit: 100, null: false t.string :description, limit: 2000, null: false t.string :options, limit: 2000, null: true - t.string :state_current, limit: 2000, null: true + t.string :state_current, limit: 200.kilobytes + 1, null: true t.string :state_initial, limit: 2000, null: true t.boolean :frontend, null: false - t.string :preferences, limit: 2000, null: true - t.timestamps null: false + t.text :preferences, limit: 200.kilobytes + 1, null: true + t.timestamps null: false end add_index :settings, [:name], unique: true add_index :settings, [:area] diff --git a/db/migrate/20160815000001_update_setting_auth.rb b/db/migrate/20160815000001_update_setting_auth.rb index 217442334..dd41b9b76 100644 --- a/db/migrate/20160815000001_update_setting_auth.rb +++ b/db/migrate/20160815000001_update_setting_auth.rb @@ -4,125 +4,8 @@ class UpdateSettingAuth < ActiveRecord::Migration # return if it's a new setup return if !Setting.find_by(name: 'system_init_done') - Role.create_or_update( - id: 1, - name: 'Admin', - note: 'To configure your system.', - preferences: { - not: ['Customer'], - }, - default_at_signup: false, - updated_by_id: 1, - created_by_id: 1 - ) - Role.create_or_update( - id: 2, - name: 'Agent', - note: 'To work on Tickets.', - default_at_signup: false, - preferences: { - not: ['Customer'], - }, - updated_by_id: 1, - created_by_id: 1 - ) - Role.create_or_update( - id: 3, - name: 'Customer', - note: 'People who create Tickets ask for help.', - preferences: { - not: %w(Agent Admin), - }, - default_at_signup: true, - updated_by_id: 1, - created_by_id: 1 - ) - Role.create_or_update( - id: 4, - name: 'Report', - note: 'Access the report area.', - preferences: { - not: ['Customer'], - }, - default_at_signup: false, - created_by_id: 1, - updated_by_id: 1, - ) - - ObjectManager::Attribute.add( - force: true, - object: 'Organization', - name: 'shared', - display: 'Shared organization', - data_type: 'boolean', - data_option: { - null: true, - default: true, - note: 'Customers in the organization can view each other items.', - item_class: 'formGroup--halfSize', - translate: true, - options: { - true: 'yes', - false: 'no', - } - }, - editable: false, - active: true, - screens: { - edit: { - Admin: { - null: false, - }, - }, - view: { - '-all-' => { - shown: true, - }, - }, - }, - to_create: false, - to_migrate: false, - to_delete: false, - position: 1400, - ) - - ObjectManager::Attribute.add( - force: true, - object: 'User', - name: 'role_ids', - display: 'Permissions', - data_type: 'user_permission', - data_option: { - null: false, - item_class: 'checkbox', - }, - editable: false, - active: true, - screens: { - signup: {}, - invite_agent: { - '-all-' => { - null: false, - default: [Role.lookup(name: 'Agent').id], - }, - }, - invite_customer: {}, - edit: { - Admin: { - null: true, - }, - }, - view: { - '-all-' => { - shown: false, - }, - }, - }, - to_create: false, - to_migrate: false, - to_delete: false, - position: 1600, - ) + change_column :settings, :preferences, :text, limit: 200.kilobytes + 1, null: true + change_column :settings, :state_current, :text, limit: 200.kilobytes + 1, null: true Setting.create_if_not_exists( title: 'Authentication via %s', diff --git a/db/seeds.rb b/db/seeds.rb index 703205852..44966d059 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -110,7 +110,10 @@ Setting.create_if_not_exists( }, ], }, - preferences: { prio: 3, controller: 'SettingsAreaLogo' }, + preferences: { + prio: 3, + controller: 'SettingsAreaLogo', + }, state: 'logo.svg', frontend: true ) diff --git a/script/build/test_slice_tests.sh b/script/build/test_slice_tests.sh index 097832042..42bcb6ca5 100755 --- a/script/build/test_slice_tests.sh +++ b/script/build/test_slice_tests.sh @@ -37,6 +37,7 @@ if [ "$LEVEL" == '1' ]; then rm test/browser/customer_ticket_create_test.rb rm test/browser/first_steps_test.rb # test/browser/form_test.rb + rm test/browser/integration_test.rb rm test/browser/keyboard_shortcuts_test.rb # test/browser/maintenance_test.rb rm test/browser/preferences_test.rb @@ -80,6 +81,7 @@ elif [ "$LEVEL" == '2' ]; then rm test/browser/customer_ticket_create_test.rb rm test/browser/first_steps_test.rb rm test/browser/form_test.rb + rm test/browser/integration_test.rb rm test/browser/keyboard_shortcuts_test.rb rm test/browser/maintenance_test.rb rm test/browser/manage_test.rb @@ -124,6 +126,7 @@ elif [ "$LEVEL" == '3' ]; then rm test/browser/customer_ticket_create_test.rb rm test/browser/first_steps_test.rb rm test/browser/form_test.rb + rm test/browser/integration_test.rb rm test/browser/keyboard_shortcuts_test.rb rm test/browser/maintenance_test.rb rm test/browser/manage_test.rb @@ -168,6 +171,7 @@ elif [ "$LEVEL" == '4' ]; then # test/browser/customer_ticket_create_test.rb rm test/browser/first_steps_test.rb rm test/browser/form_test.rb + rm test/browser/integration_test.rb rm test/browser/keyboard_shortcuts_test.rb rm test/browser/maintenance_test.rb rm test/browser/manage_test.rb @@ -211,6 +215,7 @@ elif [ "$LEVEL" == '5' ]; then rm test/browser/customer_ticket_create_test.rb rm test/browser/first_steps_test.rb rm test/browser/form_test.rb + rm test/browser/integration_test.rb rm test/browser/keyboard_shortcuts_test.rb rm test/browser/maintenance_*.rb rm test/browser/manage_test.rb @@ -257,6 +262,7 @@ elif [ "$LEVEL" == '6' ]; then rm test/browser/customer_ticket_create_test.rb # test/browser/first_steps_test.rb rm test/browser/form_test.rb + # test/browser/integration_test.rb # test/browser/keyboard_shortcuts_test.rb rm test/browser/maintenance_*.rb rm test/browser/manage_test.rb diff --git a/test/browser/integration_test.rb b/test/browser/integration_test.rb new file mode 100644 index 000000000..75f5577ee --- /dev/null +++ b/test/browser/integration_test.rb @@ -0,0 +1,339 @@ +# encoding: utf-8 +require 'browser_test_helper' + +class IntegrationTest < TestCase + + def test_sipgate + @browser = browser_instance + login( + username: 'master@example.com', + password: 'test', + url: browser_url, + ) + tasks_close_all() + + # change settings + click(css: 'a[href="#manage"]') + click(css: 'a[href="#system/integration"]') + click(css: 'a[href="#system/integration/sipgate"]') + sleep 2 + switch( + css: '#content .main .js-switch', + type: 'on', + ) + set( + css: '#content .main .js-inboundBlockCallerId input[name=caller_id]', + value: '041 1234567', + ) + set( + css: '#content .main .js-inboundBlockCallerId input[name=note]', + value: 'block spam caller id', + ) + click(css: '#content .main .js-inboundBlockCallerId .js-add') + click(css: '#content .main .js-submit') + + exists( + css: '#content .main .js-inboundBlockCallerId [value="0411234567"]', + ) + exists( + css: '#content .main .js-inboundBlockCallerId [value="block spam caller id"]', + ) + + click(css: 'a[href="#dashboard"]') + click(css: 'a[href="#manage"]') + click(css: 'a[href="#system/integration"]') + click(css: 'a[href="#system/integration/sipgate"]') + + exists( + css: '#content .main .js-inboundBlockCallerId [value="0411234567"]', + ) + exists( + css: '#content .main .js-inboundBlockCallerId [value="block spam caller id"]', + ) + + reload() + exists( + css: '#content .main .js-inboundBlockCallerId [value="0411234567"]', + ) + exists( + css: '#content .main .js-inboundBlockCallerId [value="block spam caller id"]', + ) + click(css: '#content .main .js-inboundBlockCallerId .js-remove') + click(css: '#content .main .js-submit') + sleep 6 + switch( + css: '#content .main .js-switch', + type: 'off', + ) + + reload() + exists_not( + css: '#content .main .js-inboundBlockCallerId [value="0411234567"]', + ) + exists_not( + css: '#content .main .js-inboundBlockCallerId [value="block spam caller id"]', + ) + end + + def test_slack + @browser = browser_instance + login( + username: 'master@example.com', + password: 'test', + url: browser_url, + ) + tasks_close_all() + + # change settings + click(css: 'a[href="#manage"]') + click(css: 'a[href="#system/integration"]') + click(css: 'a[href="#system/integration/slack"]') + sleep 2 + switch( + css: '#content .main .js-switch', + type: 'on', + ) + click(css: '#content .main .checkbox-replacement') + select( + css: '#content .main select[name="group_id"]', + value: 'Users', + ) + set( + css: '#content .main input[name="webhook"]', + value: 'http://some_url/webhook/123', + ) + set( + css: '#content .main input[name="username"]', + value: 'someuser', + ) + + click(css: '#content .main .js-submit') + + match( + css: '#content .main select[name="group_id"]', + value: 'Users', + ) + match( + css: '#content .main input[name="webhook"]', + value: 'http://some_url/webhook/123', + ) + match( + css: '#content .main input[name="username"]', + value: 'someuser', + ) + + click(css: 'a[href="#dashboard"]') + click(css: 'a[href="#manage"]') + click(css: 'a[href="#system/integration"]') + click(css: 'a[href="#system/integration/slack"]') + + match( + css: '#content .main select[name="group_id"]', + value: 'Users', + ) + match( + css: '#content .main input[name="webhook"]', + value: 'http://some_url/webhook/123', + ) + match( + css: '#content .main input[name="username"]', + value: 'someuser', + ) + + reload() + + match( + css: '#content .main select[name="group_id"]', + value: 'Users', + ) + match( + css: '#content .main input[name="webhook"]', + value: 'http://some_url/webhook/123', + ) + match( + css: '#content .main input[name="username"]', + value: 'someuser', + ) + + switch( + css: '#content .main .js-switch', + type: 'off', + ) + end + + def test_clearbit + @browser = browser_instance + login( + username: 'master@example.com', + password: 'test', + url: browser_url, + ) + tasks_close_all() + + # change settings + click(css: 'a[href="#manage"]') + click(css: 'a[href="#system/integration"]') + click(css: 'a[href="#system/integration/clearbit"]') + sleep 2 + switch( + css: '#content .main .js-switch', + type: 'on', + ) + set( + css: '#content .main input[name="api_key"]', + value: 'some_api_key', + ) + set( + css: '#content .main .js-userSync .js-new [name="source"]', + value: 'source1', + ) + set( + css: '#content .main .js-userSync .js-new [name="destination"]', + value: 'destination1', + ) + click(css: '#content .main .js-userSync .js-add') + click(css: '#content .main .js-submit') + + click(css: 'a[href="#dashboard"]') + click(css: 'a[href="#manage"]') + click(css: 'a[href="#system/integration"]') + click(css: 'a[href="#system/integration/clearbit"]') + + match( + css: '#content .main input[name="api_key"]', + value: 'some_api_key', + ) + exists( + css: '#content .main .js-userSync [value="source1"]', + ) + exists( + css: '#content .main .js-userSync [value="destination1"]', + ) + + reload() + + match( + css: '#content .main input[name="api_key"]', + value: 'some_api_key', + ) + exists( + css: '#content .main .js-userSync [value="source1"]', + ) + exists( + css: '#content .main .js-userSync [value="destination1"]', + ) + + switch( + css: '#content .main .js-switch', + type: 'off', + ) + + set( + css: '#content .main input[name="api_key"]', + value: '-empty-', + ) + click(css: '#content .main .js-submit') + + reload() + match_not( + css: '#content .main input[name="api_key"]', + value: 'some_api_key', + ) + match( + css: '#content .main input[name="api_key"]', + value: '-empty-', + ) + exists( + css: '#content .main .js-userSync [value="source1"]', + ) + exists( + css: '#content .main .js-userSync [value="destination1"]', + ) + end + + def test_icinga + @browser = browser_instance + login( + username: 'master@example.com', + password: 'test', + url: browser_url, + ) + tasks_close_all() + + # change settings + click(css: 'a[href="#manage"]') + click(css: 'a[href="#system/integration"]') + click(css: 'a[href="#system/integration/icinga"]') + sleep 2 + switch( + css: '#content .main .js-switch', + type: 'on', + ) + set( + css: '#content .main input[name="icinga_sender"]', + value: 'some@othersender.com', + ) + select( + css: '#content .main select[name="icinga_auto_close"]', + value: 'no', + ) + click(css: '#content .main .js-submit') + + match( + css: '#content .main input[name="icinga_sender"]', + value: 'some@othersender.com', + ) + match( + css: '#content .main select[name="icinga_auto_close"]', + value: 'no', + ) + + click(css: 'a[href="#dashboard"]') + click(css: 'a[href="#manage"]') + click(css: 'a[href="#system/integration"]') + click(css: 'a[href="#system/integration/icinga"]') + + match( + css: '#content .main input[name="icinga_sender"]', + value: 'some@othersender.com', + ) + match( + css: '#content .main select[name="icinga_auto_close"]', + value: 'no', + ) + + reload() + + match( + css: '#content .main input[name="icinga_sender"]', + value: 'some@othersender.com', + ) + match( + css: '#content .main select[name="icinga_auto_close"]', + value: 'no', + ) + + switch( + css: '#content .main .js-switch', + type: 'off', + ) + set( + css: '#content .main input[name="icinga_sender"]', + value: 'icinga@monitoring.example.com', + ) + select( + css: '#content .main select[name="icinga_auto_close"]', + value: 'yes', + ) + click(css: '#content .main .js-submit') + + match( + css: '#content .main input[name="icinga_sender"]', + value: 'icinga@monitoring.example.com', + ) + match( + css: '#content .main select[name="icinga_auto_close"]', + value: 'yes', + ) + end +end diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 9d7c1a8cf..6a2496772 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -701,10 +701,18 @@ class TestCase < Test::Unit::TestCase if params[:type] == 'on' instance.find_elements(css: "#{params[:css]} label")[0].click sleep 2 + + element = instance.find_elements(css: "#{params[:css]} input[type=checkbox]")[0] + checked = element.attribute('checked') + raise 'Switch not on!' if !checked end elsif params[:type] == 'off' instance.find_elements(css: "#{params[:css]} label")[0].click sleep 2 + + element = instance.find_elements(css: "#{params[:css]} input[type=checkbox]")[0] + checked = element.attribute('checked') + raise 'Switch not off!' if checked end end