Added integration browser tests.

This commit is contained in:
Martin Edenhofer 2016-08-16 02:10:41 +02:00
parent 8d1a90acde
commit e5af892abb
17 changed files with 415 additions and 191 deletions

View file

@ -13,11 +13,12 @@ class App.ChannelForm extends App.ControllerContent
constructor: -> constructor: ->
super super
@title 'Form' @title 'Form'
@subscribeId = App.Setting.subscribe(@render, initFetch: true, clear: false) App.Setting.fetchFull(
@render
force: false
)
render: => render: =>
App.Setting.unsubscribe(@subscribeId)
setting = App.Setting.get('form_ticket_create') setting = App.Setting.get('form_ticket_create')
@html App.view('channel/form')( @html App.view('channel/form')(
baseurl: window.location.origin baseurl: window.location.origin
@ -29,9 +30,6 @@ class App.ChannelForm extends App.ControllerContent
@updateParams() @updateParams()
release: =>
App.Setting.unsubscribe(@subscribeId)
updateParams: -> updateParams: ->
quote = (string) -> quote = (string) ->
string = string.replace('\'', '\\\'') string = string.replace('\'', '\\\'')

View file

@ -1,7 +1,5 @@
class App.ControllerIntegrationBase extends App.Controller class App.ControllerIntegrationBase extends App.Controller
events: events:
'click .js-submit': 'submit'
'submit .js-form': 'submit'
'change .js-switch input': 'switch' 'change .js-switch input': 'switch'
featureIntegration: 'tbd_integration' featureIntegration: 'tbd_integration'
@ -17,7 +15,10 @@ class App.ControllerIntegrationBase extends App.Controller
@initalRender = true @initalRender = true
@subscribeId = App.Setting.subscribe(@render, initFetch: true, clear: false) App.Setting.fetchFull(
@render
force: false
)
switch: => switch: =>
value = @$('.js-switch input').prop('checked') value = @$('.js-switch input').prop('checked')
@ -32,39 +33,3 @@ class App.ControllerIntegrationBase extends App.Controller
featureEnabled: App.Setting.get(@featureIntegration) featureEnabled: App.Setting.get(@featureIntegration)
) )
@initalRender = false @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})

View file

@ -28,11 +28,10 @@ class Form extends App.Controller
constructor: -> constructor: ->
super super
@render()
@subscribeId = App.Setting.subscribe(@render, initFetch: true, clear: false)
currentConfig: -> currentConfig: ->
config = App.Setting.get('clearbit_config') config = clone(App.Setting.get('clearbit_config'))
if !config if !config
config = {} config = {}
if config.organization_autocreate is undefined if config.organization_autocreate is undefined
@ -60,8 +59,8 @@ class Form extends App.Controller
App.Setting.set('clearbit_config', value, {notify: true}) App.Setting.set('clearbit_config', value, {notify: true})
render: => render: =>
if !@config
@config = @currentConfig() @config = @currentConfig()
settings = [ settings = [
{ name: 'api_key', display: 'API Key', tag: 'input', type: 'text', limit: 100, null: false, placeholder: '...', note: 'Your api key.' }, { 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.' }, { 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') element = $(e.currentTarget).closest('tr')
source = @cleanupInput(element.find('input[name="source"]').val()) source = @cleanupInput(element.find('input[name="source"]').val())
destination = @cleanupInput(element.find('input[name="destination"]').val()) destination = @cleanupInput(element.find('input[name="destination"]').val())
return if _.isEmpty(source) || _.isEmpty(destination)
@config.user_sync[source] = destination @config.user_sync[source] = destination
@setConfig(@config)
@render() @render()
addOrganizationSync: (e) => addOrganizationSync: (e) =>
@ -135,8 +134,8 @@ class Form extends App.Controller
element = $(e.currentTarget).closest('tr') element = $(e.currentTarget).closest('tr')
source = @cleanupInput(element.find('input[name="source"]').val()) source = @cleanupInput(element.find('input[name="source"]').val())
destination = @cleanupInput(element.find('input[name="destination"]').val()) destination = @cleanupInput(element.find('input[name="destination"]').val())
return if _.isEmpty(source) || _.isEmpty(destination)
@config.organization_sync[source] = destination @config.organization_sync[source] = destination
@setConfig(@config)
@render() @render()
removeRow: (e) => removeRow: (e) =>
@ -144,6 +143,7 @@ class Form extends App.Controller
@updateCurrentConfig() @updateCurrentConfig()
element = $(e.currentTarget).closest('tr') element = $(e.currentTarget).closest('tr')
element.remove() element.remove()
@updateCurrentConfig()
class State class State
@current: -> @current: ->

View file

@ -28,7 +28,7 @@ class Form extends App.Controller
constructor: -> constructor: ->
super super
@subscribeId = App.Setting.subscribe(@render, initFetch: true, clear: false) @render()
currentConfig: -> currentConfig: ->
config = App.Setting.get('sipgate_config') config = App.Setting.get('sipgate_config')
@ -101,11 +101,11 @@ class Form extends App.Controller
element = $(e.currentTarget).closest('tr') element = $(e.currentTarget).closest('tr')
caller_id = element.find('input[name="caller_id"]').val() caller_id = element.find('input[name="caller_id"]').val()
note = element.find('input[name="note"]').val() note = element.find('input[name="note"]').val()
return if _.isEmpty(caller_id) || _.isEmpty(note)
@config.inbound.block_caller_ids.push { @config.inbound.block_caller_ids.push {
caller_id: @cleanupInput(caller_id) caller_id: @cleanupInput(caller_id)
note: note note: note
} }
@setConfig(@config)
@render() @render()
addOutboundRouting: (e) => addOutboundRouting: (e) =>
@ -115,12 +115,12 @@ class Form extends App.Controller
dest = @cleanupInput(element.find('input[name="dest"]').val()) dest = @cleanupInput(element.find('input[name="dest"]').val())
caller_id = @cleanupInput(element.find('input[name="caller_id"]').val()) caller_id = @cleanupInput(element.find('input[name="caller_id"]').val())
note = element.find('input[name="note"]').val() note = element.find('input[name="note"]').val()
return if _.isEmpty(caller_id) || _.isEmpty(dest) || _.isEmpty(note)
@config.outbound.routing_table.push { @config.outbound.routing_table.push {
dest: dest dest: dest
caller_id: caller_id caller_id: caller_id
note: note note: note
} }
@setConfig(@config)
@render() @render()
removeInboundBlockCallerId: (e) => removeInboundBlockCallerId: (e) =>
@ -128,12 +128,14 @@ class Form extends App.Controller
@updateCurrentConfig() @updateCurrentConfig()
element = $(e.currentTarget).closest('tr') element = $(e.currentTarget).closest('tr')
element.remove() element.remove()
@updateCurrentConfig()
removeOutboundRouting: (e) => removeOutboundRouting: (e) =>
e.preventDefault() e.preventDefault()
@updateCurrentConfig() @updateCurrentConfig()
element = $(e.currentTarget).closest('tr') element = $(e.currentTarget).closest('tr')
element.remove() element.remove()
@updateCurrentConfig()
class State class State
@current: -> @current: ->

View file

@ -6,6 +6,10 @@ class Index extends App.ControllerIntegrationBase
['This service sends notifications to your %s channel.', 'Slack'] ['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'] ['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: => render: =>
super super
@ -63,6 +67,13 @@ class Index extends App.ControllerIntegrationBase
facility: 'slack_webhook' facility: 'slack_webhook'
) )
update: (e) =>
e.preventDefault()
params = @formParam(e.target)
value =
items: [params]
App.Setting.set(@featureConfig, value, {notify: true})
class State class State
@current: -> @current: ->
App.Setting.get('slack_integration') App.Setting.get('slack_integration')

View file

@ -4,11 +4,11 @@ class App.SettingsArea extends App.Controller
# check authentication # check authentication
@authenticateCheckRedirect() @authenticateCheckRedirect()
if App.Setting.count() is 0
App.Setting.fetchFull(@render) App.Setting.fetchFull(
return @render
@render() force: false
#@subscribeId = App.Setting.subscribe(@render, initFetch: true, clear: false) )
render: => render: =>

View file

@ -8,7 +8,10 @@ class App.SettingsForm extends App.Controller
# check authentication # check authentication
@authenticateCheckRedirect() @authenticateCheckRedirect()
@subscribeId = App.Setting.subscribe(@render, initFetch: true, clear: false) App.Setting.fetchFull(
@render
force: false
)
render: => render: =>
@ -51,6 +54,7 @@ class App.SettingsForm extends App.Controller
update: (e) => update: (e) =>
e.preventDefault() e.preventDefault()
#e.stopPropagation()
@formDisable(e) @formDisable(e)
params = @formParam(e.target) params = @formParam(e.target)

View file

@ -494,6 +494,7 @@ class App.Model extends Spine.Model
App.Model.fetchFull( App.Model.fetchFull(
@callback @callback
clear: true 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 = {}) -> @fetchFull: (callback, params = {}) ->
url = "#{@url}/?full=true" url = "#{@url}/?full=true"
App.Log.debug('Model', "fetchFull collection #{@className}", url) 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( App.Ajax.request(
type: 'GET' type: 'GET'
url: url url: url

View file

@ -1,7 +1,7 @@
<form> <form>
<div class="settings-entry"> <div class="settings-entry">
<table class="settings-list" style="width: 100%;"> <table class="settings-list js-baseSync" style="width: 100%;">
<thead> <thead>
<tr> <tr>
<th width="15%"><%- @T('Title') %> <th width="15%"><%- @T('Title') %>
@ -38,7 +38,7 @@
<td class="settings-list-control-cell"><input name="destination" value="<%= destination %>" class="form-control form-control--small js-summary"> <td class="settings-list-control-cell"><input name="destination" value="<%= destination %>" class="form-control form-control--small js-summary">
<td class="settings-list-row-control"><div class="btn btn--text js-remove"><%- @Icon('trash') %> <%- @T('Remove') %></div> <td class="settings-list-row-control"><div class="btn btn--text js-remove"><%- @Icon('trash') %> <%- @T('Remove') %></div>
<% end %> <% end %>
<tr> <tr class="js-new">
<td class="settings-list-control-cell"><input name="source" value="" placeholder="person.attribute" class="form-control form-control--small js-summary"> <td class="settings-list-control-cell"><input name="source" value="" placeholder="person.attribute" class="form-control form-control--small js-summary">
<td class="settings-list-control-cell"><input name="destination" value="" placeholder="user.attribute" class="form-control form-control--small js-summary"> <td class="settings-list-control-cell"><input name="destination" value="" placeholder="user.attribute" class="form-control form-control--small js-summary">
<td class="settings-list-row-control"><div class="btn btn--text btn--create js-add"><%- @Icon('plus-small') %> <%- @T('Add') %></div> <td class="settings-list-row-control"><div class="btn btn--text btn--create js-add"><%- @Icon('plus-small') %> <%- @T('Add') %></div>
@ -63,13 +63,12 @@
<td class="settings-list-control-cell"><input name="destination" value="<%= destination %>" class="form-control form-control--small js-summary"> <td class="settings-list-control-cell"><input name="destination" value="<%= destination %>" class="form-control form-control--small js-summary">
<td class="settings-list-row-control"><div class="btn btn--text js-remove"><%- @Icon('trash') %> <%- @T('Remove') %></div> <td class="settings-list-row-control"><div class="btn btn--text js-remove"><%- @Icon('trash') %> <%- @T('Remove') %></div>
<% end %> <% end %>
<tr> <tr class="js-new">
<td class="settings-list-control-cell"><input name="source" value="" placeholder="company.attribute" class="form-control form-control--small js-summary"> <td class="settings-list-control-cell"><input name="source" value="" placeholder="company.attribute" class="form-control form-control--small js-summary">
<td class="settings-list-control-cell"><input name="destination" value="" placeholder="organization.attribute" class="form-control form-control--small js-summary"> <td class="settings-list-control-cell"><input name="destination" value="" placeholder="organization.attribute" class="form-control form-control--small js-summary">
<td class="settings-list-row-control"><div class="btn btn--text btn--create js-add"><%- @Icon('plus-small') %> <%- @T('Add') %></div> <td class="settings-list-row-control"><div class="btn btn--text btn--create js-add"><%- @Icon('plus-small') %> <%- @T('Add') %></div>
</tbody> </tbody>
</table> </table>
</div> </div>
<button type="submit" class="btn btn--primary js-submit"><%- @T('Save') %></button>
<button type="submit" class="btn btn--primary"><%- @T('Save') %></button>
</form> </form>

View file

@ -74,5 +74,5 @@
</table> </table>
</div> </div>
<button type="submit" class="btn btn--primary"><%- @T('Save') %></button> <button type="submit" class="btn btn--primary js-submit"><%- @T('Save') %></button>
</form> </form>

View file

@ -17,5 +17,5 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<button type="submit" class="btn btn--primary"><%- @T('Submit') %></button> <button type="submit" class="btn btn--primary js-submit"><%- @T('Submit') %></button>
</form> </form>

View file

@ -344,10 +344,10 @@ class CreateBase < ActiveRecord::Migration
t.string :area, limit: 100, null: false t.string :area, limit: 100, null: false
t.string :description, limit: 2000, null: false t.string :description, limit: 2000, null: false
t.string :options, limit: 2000, null: true 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.string :state_initial, limit: 2000, null: true
t.boolean :frontend, null: false t.boolean :frontend, null: false
t.string :preferences, limit: 2000, null: true t.text :preferences, limit: 200.kilobytes + 1, null: true
t.timestamps null: false t.timestamps null: false
end end
add_index :settings, [:name], unique: true add_index :settings, [:name], unique: true

View file

@ -4,125 +4,8 @@ class UpdateSettingAuth < ActiveRecord::Migration
# return if it's a new setup # return if it's a new setup
return if !Setting.find_by(name: 'system_init_done') return if !Setting.find_by(name: 'system_init_done')
Role.create_or_update( change_column :settings, :preferences, :text, limit: 200.kilobytes + 1, null: true
id: 1, change_column :settings, :state_current, :text, limit: 200.kilobytes + 1, null: true
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,
)
Setting.create_if_not_exists( Setting.create_if_not_exists(
title: 'Authentication via %s', title: 'Authentication via %s',

View file

@ -110,7 +110,10 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
preferences: { prio: 3, controller: 'SettingsAreaLogo' }, preferences: {
prio: 3,
controller: 'SettingsAreaLogo',
},
state: 'logo.svg', state: 'logo.svg',
frontend: true frontend: true
) )

View file

@ -37,6 +37,7 @@ if [ "$LEVEL" == '1' ]; then
rm test/browser/customer_ticket_create_test.rb rm test/browser/customer_ticket_create_test.rb
rm test/browser/first_steps_test.rb rm test/browser/first_steps_test.rb
# test/browser/form_test.rb # test/browser/form_test.rb
rm test/browser/integration_test.rb
rm test/browser/keyboard_shortcuts_test.rb rm test/browser/keyboard_shortcuts_test.rb
# test/browser/maintenance_test.rb # test/browser/maintenance_test.rb
rm test/browser/preferences_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/customer_ticket_create_test.rb
rm test/browser/first_steps_test.rb rm test/browser/first_steps_test.rb
rm test/browser/form_test.rb rm test/browser/form_test.rb
rm test/browser/integration_test.rb
rm test/browser/keyboard_shortcuts_test.rb rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/maintenance_test.rb rm test/browser/maintenance_test.rb
rm test/browser/manage_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/customer_ticket_create_test.rb
rm test/browser/first_steps_test.rb rm test/browser/first_steps_test.rb
rm test/browser/form_test.rb rm test/browser/form_test.rb
rm test/browser/integration_test.rb
rm test/browser/keyboard_shortcuts_test.rb rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/maintenance_test.rb rm test/browser/maintenance_test.rb
rm test/browser/manage_test.rb rm test/browser/manage_test.rb
@ -168,6 +171,7 @@ elif [ "$LEVEL" == '4' ]; then
# test/browser/customer_ticket_create_test.rb # test/browser/customer_ticket_create_test.rb
rm test/browser/first_steps_test.rb rm test/browser/first_steps_test.rb
rm test/browser/form_test.rb rm test/browser/form_test.rb
rm test/browser/integration_test.rb
rm test/browser/keyboard_shortcuts_test.rb rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/maintenance_test.rb rm test/browser/maintenance_test.rb
rm test/browser/manage_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/customer_ticket_create_test.rb
rm test/browser/first_steps_test.rb rm test/browser/first_steps_test.rb
rm test/browser/form_test.rb rm test/browser/form_test.rb
rm test/browser/integration_test.rb
rm test/browser/keyboard_shortcuts_test.rb rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/maintenance_*.rb rm test/browser/maintenance_*.rb
rm test/browser/manage_test.rb rm test/browser/manage_test.rb
@ -257,6 +262,7 @@ elif [ "$LEVEL" == '6' ]; then
rm test/browser/customer_ticket_create_test.rb rm test/browser/customer_ticket_create_test.rb
# test/browser/first_steps_test.rb # test/browser/first_steps_test.rb
rm test/browser/form_test.rb rm test/browser/form_test.rb
# test/browser/integration_test.rb
# test/browser/keyboard_shortcuts_test.rb # test/browser/keyboard_shortcuts_test.rb
rm test/browser/maintenance_*.rb rm test/browser/maintenance_*.rb
rm test/browser/manage_test.rb rm test/browser/manage_test.rb

View file

@ -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

View file

@ -701,10 +701,18 @@ class TestCase < Test::Unit::TestCase
if params[:type] == 'on' if params[:type] == 'on'
instance.find_elements(css: "#{params[:css]} label")[0].click instance.find_elements(css: "#{params[:css]} label")[0].click
sleep 2 sleep 2
element = instance.find_elements(css: "#{params[:css]} input[type=checkbox]")[0]
checked = element.attribute('checked')
raise 'Switch not on!' if !checked
end end
elsif params[:type] == 'off' elsif params[:type] == 'off'
instance.find_elements(css: "#{params[:css]} label")[0].click instance.find_elements(css: "#{params[:css]} label")[0].click
sleep 2 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
end end