2018-05-28 06:42:04 +00:00
|
|
|
require 'browser_test_helper'
|
|
|
|
|
|
|
|
class IntegrationCtiTest < TestCase
|
|
|
|
setup do
|
|
|
|
if !ENV['CTI_TOKEN']
|
|
|
|
raise "ERROR: Need CTI_TOKEN - hint CTI_TOKEN='some_token'"
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
# Regression test for #2017
|
|
|
|
def test_nav_menu_notification_badge_clears
|
|
|
|
id = rand(99_999_999)
|
|
|
|
|
|
|
|
@browser = browser_instance
|
|
|
|
login(
|
|
|
|
username: 'master@example.com',
|
|
|
|
password: 'test',
|
2018-12-19 17:31:51 +00:00
|
|
|
url: browser_url,
|
2018-05-28 06:42:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
click(css: 'a[href="#manage"]')
|
|
|
|
click(css: 'a[href="#system/integration"]')
|
|
|
|
click(css: 'a[href="#system/integration/cti"]')
|
|
|
|
|
|
|
|
switch(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.content.active .js-switch',
|
2018-05-28 06:42:04 +00:00
|
|
|
type: 'on'
|
|
|
|
)
|
|
|
|
|
2018-06-05 08:31:59 +00:00
|
|
|
watch_for(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: 'a[href="#cti"]',
|
2018-06-05 08:31:59 +00:00
|
|
|
timeout: 4,
|
|
|
|
)
|
2018-05-28 06:42:04 +00:00
|
|
|
|
|
|
|
click(css: 'a[href="#cti"]')
|
|
|
|
|
|
|
|
call_counter = @browser.find_elements(css: '.js-phoneMenuItem .counter')
|
|
|
|
.first&.text.to_i
|
|
|
|
|
|
|
|
# simulate cti callbacks
|
|
|
|
url = URI.join(browser_url, "api/v1/cti/#{ENV['CTI_TOKEN']}")
|
|
|
|
params = {
|
|
|
|
direction: 'in',
|
2018-12-19 17:31:51 +00:00
|
|
|
from: '491715000002',
|
|
|
|
to: '4930600000000',
|
|
|
|
callId: "4991155921769858278-#{id}",
|
|
|
|
cause: 'busy'
|
2018-05-28 06:42:04 +00:00
|
|
|
}
|
|
|
|
Net::HTTP.post_form(url, params.merge(event: 'newCall'))
|
|
|
|
Net::HTTP.post_form(url, params.merge(event: 'hangup'))
|
|
|
|
|
|
|
|
watch_for(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-phoneMenuItem .counter',
|
|
|
|
value: (call_counter + 1).to_s,
|
2018-06-05 08:31:59 +00:00
|
|
|
timeout: 4,
|
2018-05-28 06:42:04 +00:00
|
|
|
)
|
|
|
|
|
2018-06-05 08:31:59 +00:00
|
|
|
check(css: '.content.active .table-checkbox input')
|
2018-05-28 06:42:04 +00:00
|
|
|
|
|
|
|
watch_for_disappear(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-phoneMenuItem .counter',
|
2018-06-05 08:31:59 +00:00
|
|
|
timeout: 6,
|
2018-05-28 06:42:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
click(css: 'a[href="#manage"]')
|
|
|
|
click(css: 'a[href="#system/integration"]')
|
|
|
|
click(css: 'a[href="#system/integration/cti"]')
|
|
|
|
|
|
|
|
switch(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.content.active .js-switch',
|
2018-05-28 06:42:04 +00:00
|
|
|
type: 'off'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Regression test for #2018
|
|
|
|
def test_e164_numbers_displayed_in_prettified_format
|
|
|
|
id = rand(99_999_999)
|
|
|
|
|
|
|
|
@browser = browser_instance
|
|
|
|
login(
|
|
|
|
username: 'master@example.com',
|
|
|
|
password: 'test',
|
2018-12-19 17:31:51 +00:00
|
|
|
url: browser_url,
|
2018-05-28 06:42:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
click(css: 'a[href="#manage"]')
|
|
|
|
click(css: 'a[href="#system/integration"]')
|
|
|
|
click(css: 'a[href="#system/integration/cti"]')
|
|
|
|
|
|
|
|
switch(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.content.active .js-switch',
|
2018-05-28 06:42:04 +00:00
|
|
|
type: 'on'
|
|
|
|
)
|
|
|
|
|
|
|
|
watch_for(
|
|
|
|
css: 'a[href="#cti"]'
|
|
|
|
)
|
|
|
|
|
|
|
|
click(css: 'a[href="#cti"]')
|
|
|
|
|
|
|
|
# simulate cti callbacks...
|
|
|
|
url = URI.join(browser_url, "api/v1/cti/#{ENV['CTI_TOKEN']}")
|
|
|
|
|
|
|
|
# ...for private network number
|
|
|
|
params = {
|
|
|
|
direction: 'in',
|
2018-12-19 17:31:51 +00:00
|
|
|
from: '007',
|
|
|
|
to: '008',
|
|
|
|
callId: "4991155921769858278-#{id}",
|
|
|
|
cause: 'busy'
|
2018-05-28 06:42:04 +00:00
|
|
|
}
|
|
|
|
Net::HTTP.post_form(url, params.merge(event: 'newCall'))
|
|
|
|
Net::HTTP.post_form(url, params.merge(event: 'hangup'))
|
|
|
|
|
|
|
|
# ...for e164 number
|
|
|
|
params = {
|
|
|
|
direction: 'in',
|
2018-12-19 17:31:51 +00:00
|
|
|
from: '4930609854180',
|
|
|
|
to: '4930609811111',
|
|
|
|
callId: "4991155921769858278-#{id.next}",
|
|
|
|
cause: 'busy'
|
2018-05-28 06:42:04 +00:00
|
|
|
}
|
|
|
|
Net::HTTP.post_form(url, params.merge(event: 'newCall'))
|
|
|
|
Net::HTTP.post_form(url, params.merge(event: 'hangup'))
|
|
|
|
|
|
|
|
# view caller log
|
|
|
|
click(css: 'a[href="#cti"]')
|
|
|
|
|
|
|
|
# assertion: private network numbers appear verbatim
|
2018-06-05 08:31:59 +00:00
|
|
|
watch_for(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.content.active .js-callerLog',
|
|
|
|
value: '007',
|
2018-06-05 08:31:59 +00:00
|
|
|
timeout: 3,
|
2018-05-28 06:42:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
match(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.content.active .js-callerLog',
|
2018-05-28 06:42:04 +00:00
|
|
|
value: '008',
|
|
|
|
)
|
|
|
|
|
|
|
|
# assertion: E164 numbers appear prettified
|
|
|
|
match(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.content.active .js-callerLog',
|
2018-05-28 06:42:04 +00:00
|
|
|
value: '+49 30 609854180',
|
|
|
|
)
|
|
|
|
|
|
|
|
match(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.content.active .js-callerLog',
|
2018-05-28 06:42:04 +00:00
|
|
|
value: '+49 30 609811111',
|
|
|
|
)
|
|
|
|
end
|
2018-08-07 09:51:12 +00:00
|
|
|
|
|
|
|
# Regression test for #2096
|
|
|
|
def test_inactive_users_displayed_with_strikethrough_in_caller_log
|
|
|
|
id = rand(99_999_999)
|
|
|
|
|
|
|
|
@browser = browser_instance
|
|
|
|
login(
|
|
|
|
username: 'master@example.com',
|
|
|
|
password: 'test',
|
2018-12-19 17:31:51 +00:00
|
|
|
url: browser_url,
|
2018-08-07 09:51:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# create inactive user with phone number (via API)
|
|
|
|
user_create(
|
|
|
|
data: {
|
|
|
|
login: 'test_user',
|
|
|
|
firstname: 'John',
|
2018-08-20 09:13:18 +00:00
|
|
|
lastname: 'Doe',
|
|
|
|
phone: '1234567890',
|
|
|
|
active: false,
|
2018-08-07 09:51:12 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
# enable CTI
|
|
|
|
click(css: 'a[href="#manage"]')
|
|
|
|
click(css: 'a[href="#system/integration"]')
|
|
|
|
click(css: 'a[href="#system/integration/cti"]')
|
|
|
|
|
|
|
|
switch(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.content.active .js-switch',
|
2018-08-07 09:51:12 +00:00
|
|
|
type: 'on'
|
|
|
|
)
|
|
|
|
|
|
|
|
watch_for(
|
|
|
|
css: 'a[href="#cti"]'
|
|
|
|
)
|
|
|
|
|
|
|
|
click(css: 'a[href="#cti"]')
|
|
|
|
|
|
|
|
# simulate CTI callback to/from inactive user
|
|
|
|
url = URI.join(browser_url, "api/v1/cti/#{ENV['CTI_TOKEN']}")
|
|
|
|
params = {
|
|
|
|
direction: 'in',
|
2018-12-19 17:31:51 +00:00
|
|
|
from: '1234567890',
|
|
|
|
to: '1234567890',
|
|
|
|
callId: "4991155921769858278-#{id}",
|
|
|
|
cause: 'busy'
|
2018-08-07 09:51:12 +00:00
|
|
|
}
|
|
|
|
Net::HTTP.post_form(url, params.merge(event: 'newCall'))
|
|
|
|
Net::HTTP.post_form(url, params.merge(event: 'hangup'))
|
|
|
|
|
|
|
|
# view caller log
|
|
|
|
click(css: 'a[href="#cti"]')
|
|
|
|
|
|
|
|
# assertion: names appear in strikethrough
|
|
|
|
match(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: 'span.is-inactive',
|
2018-08-07 09:51:12 +00:00
|
|
|
value: 'John Doe',
|
|
|
|
)
|
|
|
|
end
|
2018-08-27 01:24:21 +00:00
|
|
|
|
|
|
|
# Regression test for #2075
|
|
|
|
def test_caller_ids_include_organization_names
|
|
|
|
id = rand(99_999_999)
|
|
|
|
|
|
|
|
@browser = browser_instance
|
|
|
|
login(
|
|
|
|
username: 'master@example.com',
|
|
|
|
password: 'test',
|
2018-12-19 17:31:51 +00:00
|
|
|
url: browser_url,
|
2018-08-27 01:24:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# create user with organization (via API)
|
|
|
|
user_create(
|
|
|
|
data: {
|
|
|
|
login: 'test_user',
|
|
|
|
firstname: 'John',
|
|
|
|
lastname: 'Doe',
|
|
|
|
phone: '1234567890',
|
|
|
|
organization: 'Zammad Foundation'
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
# enable CTI
|
|
|
|
click(css: 'a[href="#manage"]')
|
|
|
|
click(css: 'a[href="#system/integration"]')
|
|
|
|
click(css: 'a[href="#system/integration/cti"]')
|
|
|
|
|
|
|
|
switch(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.content.active .js-switch',
|
2018-08-27 01:24:21 +00:00
|
|
|
type: 'on'
|
|
|
|
)
|
|
|
|
|
|
|
|
watch_for(
|
|
|
|
css: 'a[href="#cti"]'
|
|
|
|
)
|
|
|
|
|
|
|
|
# view caller log
|
|
|
|
click(css: 'a[href="#cti"]')
|
|
|
|
|
|
|
|
# simulate CTI callbacks to/from target user
|
|
|
|
url = URI.join(browser_url, "api/v1/cti/#{ENV['CTI_TOKEN']}")
|
|
|
|
params = {
|
|
|
|
direction: 'out',
|
2018-12-19 17:31:51 +00:00
|
|
|
from: '1234567890',
|
|
|
|
to: '1234567890',
|
|
|
|
callId: "4991155921769858278-#{id}",
|
|
|
|
cause: 'busy'
|
2018-08-27 01:24:21 +00:00
|
|
|
}
|
|
|
|
Net::HTTP.post_form(url, params.merge(event: 'newCall'))
|
|
|
|
Net::HTTP.post_form(url, params.merge(event: 'hangup'))
|
|
|
|
|
|
|
|
params = {
|
|
|
|
direction: 'in',
|
2018-12-19 17:31:51 +00:00
|
|
|
from: '1234567890',
|
|
|
|
to: '1234567890',
|
|
|
|
callId: "4991155921769858278-#{id.next}",
|
|
|
|
cause: 'busy'
|
2018-08-27 01:24:21 +00:00
|
|
|
}
|
|
|
|
Net::HTTP.post_form(url, params.merge(event: 'newCall'))
|
|
|
|
Net::HTTP.post_form(url, params.merge(event: 'hangup'))
|
|
|
|
|
|
|
|
watch_for(
|
|
|
|
css: '.js-callerLog tr:nth-of-type(2)'
|
|
|
|
)
|
|
|
|
|
|
|
|
# assertions: Caller ID includes user organization
|
|
|
|
match(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-callerLog tr:first-of-type span.user-popover',
|
2018-08-27 01:24:21 +00:00
|
|
|
value: 'John Doe (Zammad Foundation)',
|
|
|
|
)
|
|
|
|
|
|
|
|
match(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-callerLog tr:last-of-type span.user-popover',
|
2018-08-27 01:24:21 +00:00
|
|
|
value: 'John Doe (Zammad Foundation)',
|
|
|
|
)
|
|
|
|
end
|
2018-05-28 06:42:04 +00:00
|
|
|
end
|