2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2018-07-26 14:24:31 +00:00
|
|
|
require 'browser_test_helper'
|
|
|
|
|
|
|
|
class IntegrationIdoitTest < TestCase
|
|
|
|
|
|
|
|
def test_idoit_objects_corrects_saves_on_ticket_creation
|
2018-07-27 07:37:27 +00:00
|
|
|
# Read i-doit credentials from ENV
|
2018-07-26 14:24:31 +00:00
|
|
|
if !ENV['IDOIT_API_TOKEN']
|
|
|
|
raise "ERROR: Need IDOIT_API_TOKEN - hint IDOIT_API_TOKEN='1234'"
|
|
|
|
end
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2018-07-26 14:24:31 +00:00
|
|
|
api_token = ENV['IDOIT_API_TOKEN']
|
|
|
|
if !ENV['IDOIT_API_ENDPOINT']
|
|
|
|
raise "ERROR: Need IDOIT_API_ENDPOINT - hint IDOIT_API_ENDPOINT='1234'"
|
|
|
|
end
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2018-07-26 14:24:31 +00:00
|
|
|
api_endpoint = ENV['IDOIT_API_ENDPOINT']
|
|
|
|
if !ENV['IDOIT_API_CATEGORY']
|
|
|
|
raise "ERROR: Need IDOIT_API_CATEGORY - hint IDOIT_API_CATEGORY='Building'"
|
|
|
|
end
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2018-07-26 14:24:31 +00:00
|
|
|
api_category = ENV['IDOIT_API_CATEGORY']
|
|
|
|
|
2018-07-27 07:37:27 +00:00
|
|
|
@browser = browser_instance
|
2018-07-26 14:24:31 +00:00
|
|
|
login(
|
2021-08-17 12:10:02 +00:00
|
|
|
username: 'admin@example.com',
|
2018-12-19 17:31:51 +00:00
|
|
|
password: 'test',
|
|
|
|
url: browser_url,
|
2018-07-27 07:37:27 +00:00
|
|
|
auto_wizard: true,
|
2018-07-26 14:24:31 +00:00
|
|
|
)
|
|
|
|
|
2018-07-27 07:37:27 +00:00
|
|
|
# turn on i-doit integration
|
2018-07-26 14:24:31 +00:00
|
|
|
click(css: 'a[href="#manage"]')
|
|
|
|
click(css: 'a[href="#system/integration"]')
|
|
|
|
click(css: 'a[href="#system/integration/idoit"]')
|
|
|
|
switch(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.content.active .js-switch',
|
2018-07-26 14:24:31 +00:00
|
|
|
type: 'on'
|
|
|
|
)
|
|
|
|
|
2018-07-27 07:37:27 +00:00
|
|
|
# fill in i-doit login details
|
2018-07-26 14:24:31 +00:00
|
|
|
set(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.content.active .main input[name="api_token"]',
|
2018-07-26 14:24:31 +00:00
|
|
|
value: api_token,
|
|
|
|
)
|
|
|
|
set(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.content.active .main input[name="endpoint"]',
|
2018-07-26 14:24:31 +00:00
|
|
|
value: api_endpoint,
|
|
|
|
)
|
|
|
|
click(css: '.content.active .main .js-submit')
|
|
|
|
|
|
|
|
watch_for(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '#notify',
|
2018-07-26 14:24:31 +00:00
|
|
|
value: 'update successful',
|
|
|
|
)
|
|
|
|
|
2018-07-27 07:37:27 +00:00
|
|
|
# new create a new ticket with an i-doit object
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_create(
|
2018-12-19 17:31:51 +00:00
|
|
|
data: {
|
2018-07-26 14:24:31 +00:00
|
|
|
customer: 'nico',
|
2018-12-19 17:31:51 +00:00
|
|
|
group: 'Users',
|
|
|
|
title: 'subject - i-doit integration #1',
|
|
|
|
body: 'body - i-doit integration',
|
2018-08-02 21:21:13 +00:00
|
|
|
},
|
|
|
|
do_not_submit: true,
|
|
|
|
)
|
|
|
|
|
|
|
|
# open the i-doit selection modal
|
|
|
|
click(css: '.content.active .tabsSidebar svg.icon-printer')
|
|
|
|
click(css: '.content.active .sidebar[data-tab="idoit"] .js-headline')
|
|
|
|
click(css: '.content.active .sidebar[data-tab="idoit"] .dropdown-menu')
|
|
|
|
|
|
|
|
# wait for the API call to populate the dropdown menu
|
|
|
|
watch_for(css: '.content.active .modal form input.js-input')
|
|
|
|
# open the dropdown menu and choose the Building option
|
|
|
|
click(css: '.content.active .modal form input.js-input')
|
|
|
|
click(css: ".content.active .modal form li.js-option[title='#{api_category}']")
|
|
|
|
# wait for the building results to populate from the API
|
|
|
|
watch_for(css: '.content.active .modal form.js-result table.table')
|
|
|
|
|
|
|
|
# click the check box from the first row and note its entry ID
|
|
|
|
checkbox = @browser.find_elements(css: '.content.active .modal form.js-result tbody :first-child input')[0]
|
|
|
|
entry_id = checkbox.attribute('value')
|
2021-07-16 13:29:38 +00:00
|
|
|
checkbox.click
|
2018-08-02 21:21:13 +00:00
|
|
|
|
|
|
|
# submit the i-doit object selections
|
|
|
|
click(css: '.content.active .modal form button.js-submit')
|
|
|
|
|
|
|
|
# confirm that the entry have been successfully recorded
|
|
|
|
watch_for(
|
|
|
|
css: ".content.active .sidebar[data-tab='idoit'] a[href='#{api_endpoint}/?objID=#{entry_id}']",
|
|
|
|
)
|
|
|
|
|
|
|
|
# reselect the customer and verify if object is still shown in sidebar
|
|
|
|
ticket_customer_select(
|
|
|
|
css: '.content.active .newTicket',
|
2021-08-17 12:10:02 +00:00
|
|
|
customer: 'admin',
|
2018-08-02 21:21:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
watch_for(
|
|
|
|
css: ".content.active .sidebar[data-tab='idoit'] a[href='#{api_endpoint}/?objID=#{entry_id}']",
|
|
|
|
)
|
|
|
|
|
|
|
|
# now submit the ticket
|
|
|
|
click(css: '.content.active .newTicket button.js-submit')
|
|
|
|
|
|
|
|
watch_for(
|
|
|
|
css: '.content.active .ticketZoom-header .ticket-number',
|
|
|
|
)
|
|
|
|
|
|
|
|
watch_for(
|
|
|
|
css: ".content.active .sidebar[data-tab='idoit'] a[href='#{api_endpoint}/?objID=#{entry_id}']",
|
|
|
|
)
|
|
|
|
|
2021-07-16 13:29:38 +00:00
|
|
|
tasks_close_all
|
2018-08-02 21:21:13 +00:00
|
|
|
|
|
|
|
# new create a new ticket with an i-doit object
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_create(
|
2018-12-19 17:31:51 +00:00
|
|
|
data: {
|
2018-08-02 21:21:13 +00:00
|
|
|
customer: 'nico',
|
2018-12-19 17:31:51 +00:00
|
|
|
group: 'Users',
|
|
|
|
title: 'subject - i-doit integration #2',
|
|
|
|
body: 'body - i-doit integration',
|
2018-07-26 14:24:31 +00:00
|
|
|
},
|
|
|
|
do_not_submit: true,
|
|
|
|
)
|
|
|
|
|
2018-07-27 07:37:27 +00:00
|
|
|
# open the i-doit selection modal
|
2018-07-26 14:24:31 +00:00
|
|
|
click(css: '.content.active .tabsSidebar svg.icon-printer')
|
|
|
|
click(css: '.content.active .sidebar[data-tab="idoit"] .js-headline')
|
|
|
|
click(css: '.content.active .sidebar[data-tab="idoit"] .dropdown-menu')
|
|
|
|
|
|
|
|
# wait for the API call to populate the dropdown menu
|
|
|
|
watch_for(css: '.content.active .modal form input.js-input')
|
|
|
|
# open the dropdown menu and choose the Building option
|
|
|
|
click(css: '.content.active .modal form input.js-input')
|
|
|
|
click(css: ".content.active .modal form li.js-option[title='#{api_category}']")
|
|
|
|
# wait for the building results to populate from the API
|
|
|
|
watch_for(css: '.content.active .modal form.js-result table.table')
|
|
|
|
|
|
|
|
# click the check box from the first row and note its entry ID
|
2018-07-27 07:37:27 +00:00
|
|
|
checkbox = @browser.find_elements(css: '.content.active .modal form.js-result tbody :first-child input')[0]
|
2018-07-26 14:24:31 +00:00
|
|
|
entry_id = checkbox.attribute('value')
|
2021-07-16 13:29:38 +00:00
|
|
|
checkbox.click
|
2018-07-26 14:24:31 +00:00
|
|
|
|
2018-07-27 07:37:27 +00:00
|
|
|
# submit the i-doit object selections
|
2018-07-26 14:24:31 +00:00
|
|
|
click(css: '.content.active .modal form button.js-submit')
|
|
|
|
|
|
|
|
# confirm that the entry have been successfully recorded
|
|
|
|
watch_for(
|
|
|
|
css: ".content.active .sidebar[data-tab='idoit'] a[href='#{api_endpoint}/?objID=#{entry_id}']",
|
|
|
|
)
|
|
|
|
|
|
|
|
# now submit the ticket
|
|
|
|
click(css: '.content.active .newTicket button.js-submit')
|
|
|
|
|
2018-07-27 07:37:27 +00:00
|
|
|
watch_for(
|
|
|
|
css: '.content.active .ticketZoom-header .ticket-number',
|
|
|
|
)
|
|
|
|
|
|
|
|
# open the i-doit sidebar again and verify that the entry is still there
|
|
|
|
click(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="idoit"]')
|
|
|
|
watch_for(
|
|
|
|
css: ".content.active .sidebar[data-tab='idoit'] a[href='#{api_endpoint}/?objID=#{entry_id}']",
|
|
|
|
)
|
|
|
|
|
|
|
|
# remove i-doit object
|
|
|
|
click(css: ".content.active .sidebar[data-tab='idoit'] .js-delete[data-object-id=\"#{entry_id}\"]")
|
|
|
|
watch_for_disappear(
|
|
|
|
css: ".content.active .sidebar[data-tab='idoit'] a[href='#{api_endpoint}/?objID=#{entry_id}']",
|
|
|
|
)
|
|
|
|
|
|
|
|
# reload browser and check if it's still removed
|
|
|
|
sleep 3
|
2021-07-16 13:29:38 +00:00
|
|
|
reload
|
2018-07-27 07:37:27 +00:00
|
|
|
watch_for(
|
|
|
|
css: '.content.active .ticketZoom-header .ticket-number',
|
|
|
|
)
|
|
|
|
click(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="idoit"]')
|
|
|
|
watch_for(
|
|
|
|
css: ".content.active .sidebar[data-tab='idoit'] .sidebar-content",
|
|
|
|
)
|
|
|
|
match(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: ".content.active .sidebar[data-tab='idoit'] .sidebar-content",
|
2018-07-27 07:37:27 +00:00
|
|
|
value: 'none',
|
|
|
|
)
|
|
|
|
exists_not(
|
|
|
|
css: ".content.active .sidebar[data-tab='idoit'] a[href='#{api_endpoint}/?objID=#{entry_id}']",
|
|
|
|
)
|
|
|
|
|
|
|
|
# add item again
|
|
|
|
click(css: '.content.active .sidebar[data-tab="idoit"] .js-actions .dropdown-toggle')
|
|
|
|
click(css: '.content.active .sidebar[data-tab="idoit"] .js-actions [data-type="objects-change"]')
|
2021-07-16 13:29:38 +00:00
|
|
|
modal_ready
|
2018-07-27 07:37:27 +00:00
|
|
|
|
|
|
|
# wait for the API call to populate the dropdown menu
|
|
|
|
watch_for(css: '.content.active .modal form input.js-input')
|
|
|
|
# open the dropdown menu and choose the Building option
|
|
|
|
click(css: '.content.active .modal form input.js-input')
|
|
|
|
click(css: ".content.active .modal form li.js-option[title='#{api_category}']")
|
|
|
|
# wait for the building results to populate from the API
|
|
|
|
watch_for(css: '.content.active .modal form.js-result table.table')
|
|
|
|
|
|
|
|
# click the check box from the first row and note its entry ID
|
|
|
|
checkbox = @browser.find_elements(css: '.content.active .modal form.js-result tbody :first-child input')[0]
|
|
|
|
entry_id = checkbox.attribute('value')
|
2021-07-16 13:29:38 +00:00
|
|
|
checkbox.click
|
2018-07-27 07:37:27 +00:00
|
|
|
|
|
|
|
# submit the i-doit object selections
|
|
|
|
click(css: '.content.active .modal form button.js-submit')
|
|
|
|
|
|
|
|
# confirm that the entry have been successfully recorded
|
|
|
|
watch_for(
|
|
|
|
css: ".content.active .sidebar[data-tab='idoit'] a[href='#{api_endpoint}/?objID=#{entry_id}']",
|
|
|
|
)
|
|
|
|
|
|
|
|
# reload browser and check if it's still removed
|
|
|
|
sleep 3
|
2021-07-16 13:29:38 +00:00
|
|
|
reload
|
2018-07-27 07:37:27 +00:00
|
|
|
watch_for(
|
|
|
|
css: '.content.active .ticketZoom-header .ticket-number',
|
|
|
|
)
|
|
|
|
|
|
|
|
# open the i-doit sidebar again and verify that the entry is still there
|
|
|
|
click(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="idoit"]')
|
2018-07-26 14:24:31 +00:00
|
|
|
watch_for(
|
|
|
|
css: ".content.active .sidebar[data-tab='idoit'] a[href='#{api_endpoint}/?objID=#{entry_id}']",
|
|
|
|
)
|
|
|
|
|
2018-07-27 07:37:27 +00:00
|
|
|
# finally turn off i-doit integration
|
2018-07-26 14:24:31 +00:00
|
|
|
click(css: 'a[href="#manage"]')
|
|
|
|
click(css: 'a[href="#system/integration"]')
|
|
|
|
click(css: 'a[href="#system/integration/idoit"]')
|
|
|
|
|
|
|
|
switch(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.content.active .js-switch',
|
2018-07-26 14:24:31 +00:00
|
|
|
type: 'off'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|