2017-11-23 08:09:44 +00:00
|
|
|
|
2016-09-05 13:18:22 +00:00
|
|
|
require 'browser_test_helper'
|
|
|
|
|
|
|
|
class AgentTicketMacroTest < TestCase
|
2018-06-20 09:39:33 +00:00
|
|
|
def test_macro
|
|
|
|
@browser = browser_instance
|
|
|
|
login(
|
|
|
|
username: 'agent1@example.com',
|
|
|
|
password: 'test',
|
|
|
|
url: browser_url,
|
|
|
|
)
|
|
|
|
tasks_close_all()
|
2018-06-11 07:28:03 +00:00
|
|
|
|
2018-06-20 09:39:33 +00:00
|
|
|
ticket1 = ticket_create(
|
|
|
|
data: {
|
|
|
|
customer: 'nico',
|
|
|
|
group: 'Users',
|
|
|
|
title: 'some subject - macro#1',
|
|
|
|
body: 'some body - macro#1',
|
|
|
|
},
|
|
|
|
)
|
2018-06-11 07:28:03 +00:00
|
|
|
|
2018-06-20 09:39:33 +00:00
|
|
|
click(css: '.active.content .js-submitDropdown .js-openDropdownMacro')
|
|
|
|
click(css: '.active.content .js-submitDropdown .js-dropdownActionMacro')
|
2018-06-11 07:28:03 +00:00
|
|
|
|
2018-06-20 09:39:33 +00:00
|
|
|
# verify tags
|
|
|
|
tags_verify(
|
|
|
|
tags: {
|
|
|
|
'spam' => true,
|
|
|
|
'tag1' => false,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
2018-06-11 07:28:03 +00:00
|
|
|
|
|
|
|
def test_macro_ux_flow_next_up
|
2016-09-05 13:18:22 +00:00
|
|
|
@browser = browser_instance
|
|
|
|
login(
|
2018-06-11 07:28:03 +00:00
|
|
|
username: 'master@example.com',
|
2016-09-05 13:18:22 +00:00
|
|
|
password: 'test',
|
|
|
|
url: browser_url,
|
|
|
|
)
|
|
|
|
tasks_close_all()
|
|
|
|
|
2018-06-11 07:28:03 +00:00
|
|
|
# Setup: Create two tickets
|
|
|
|
ticket_create(
|
2016-09-05 13:18:22 +00:00
|
|
|
data: {
|
2018-06-11 07:28:03 +00:00
|
|
|
customer: 'nicole.braun',
|
2016-09-05 13:18:22 +00:00
|
|
|
group: 'Users',
|
2018-06-11 07:28:03 +00:00
|
|
|
title: 'Sample Ticket 1',
|
|
|
|
body: 'Lorem ipsum dolor sit amet consectetur adipisicing elit.',
|
2016-09-05 13:18:22 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2018-06-11 07:28:03 +00:00
|
|
|
ticket_create(
|
|
|
|
data: {
|
|
|
|
customer: 'nicole.braun',
|
|
|
|
group: 'Users',
|
|
|
|
title: 'Sample Ticket 2',
|
|
|
|
body: 'Suspendisse volutpat lectus sem, in fermentum orci semper sit amet.',
|
|
|
|
},
|
2016-09-05 13:18:22 +00:00
|
|
|
)
|
2018-06-11 07:28:03 +00:00
|
|
|
|
|
|
|
# Setup: Create three macros (one for each ux_flow_next_up option)
|
|
|
|
click(css: 'a[href="#manage"]')
|
|
|
|
click(css: '.sidebar a[href="#manage/macros"]')
|
|
|
|
macro_options = ['Stay on tab', 'Close tab', 'Advance to next ticket from overview']
|
|
|
|
macro_options.each.with_index do |o, i|
|
|
|
|
click(css: '.page-header-meta > a[data-type="new"]')
|
|
|
|
sendkey(css: '.modal-body input[name="name"]', value: "Test Macro #{i + 1}")
|
|
|
|
select(css: '.modal-body select[name="ux_flow_next_up"]', value: o)
|
|
|
|
click(css: '.modal-footer button[type="submit"]')
|
|
|
|
end
|
|
|
|
|
|
|
|
click(css: 'a[title$="Sample Ticket 1"]')
|
|
|
|
|
|
|
|
# Assert: Run the first macro and verify the tab is still open
|
|
|
|
click(css: '.active.content .js-submitDropdown .js-openDropdownMacro')
|
|
|
|
click(css: '.active.content .js-submitDropdown .js-dropdownActionMacro[data-id="2"]')
|
|
|
|
match(css: '.tasks > a.is-active > .nav-tab-name', value: 'Sample Ticket 1',)
|
|
|
|
|
|
|
|
# Setup: Close all tabs and reopen only the first ticket
|
|
|
|
tasks_close_all()
|
|
|
|
click(css: 'a[href="#ticket/view"]')
|
|
|
|
begin
|
|
|
|
remaining_retries = 1
|
|
|
|
click(css: 'a[href="#ticket/view/all_unassigned"]')
|
|
|
|
# responsive design means some elements are un-clickable at certain viewport sizes
|
|
|
|
rescue Selenium::WebDriver::Error::WebDriverError => e
|
|
|
|
raise e if remaining_retries.zero?
|
|
|
|
(remaining_retries -= 1) && click(css: 'a.tab.js-tab[href="#ticket/view/all_unassigned"]')
|
|
|
|
end
|
|
|
|
click(css: 'td[title="Sample Ticket 1"]')
|
|
|
|
|
|
|
|
# Assert: Run the second macro and verify the tab is closed
|
|
|
|
click(css: '.active.content .js-submitDropdown .js-openDropdownMacro')
|
|
|
|
click(css: '.active.content .js-submitDropdown .js-dropdownActionMacro[data-id="3"]')
|
|
|
|
exists_not(css: '.tasks > a')
|
|
|
|
|
|
|
|
# Setup: Reopen the first ticket via a Ticket Overview
|
|
|
|
click(css: 'a[href="#ticket/view"]')
|
|
|
|
begin
|
|
|
|
remaining_retries = 1
|
|
|
|
click(css: 'a[href="#ticket/view/all_unassigned"]')
|
|
|
|
# responsive design means some elements are un-clickable at certain viewport sizes
|
|
|
|
rescue Selenium::WebDriver::Error::WebDriverError => e
|
|
|
|
raise e if remaining_retries.zero?
|
|
|
|
(remaining_retries -= 1) && click(css: 'a.tab.js-tab[href="#ticket/view/all_unassigned"]')
|
|
|
|
end
|
|
|
|
click(css: 'td[title="Sample Ticket 1"]')
|
|
|
|
|
|
|
|
# Assert: Run the third macro and verify the second ticket opens
|
|
|
|
click(css: '.active.content .js-submitDropdown .js-openDropdownMacro')
|
|
|
|
click(css: '.active.content .js-submitDropdown .js-dropdownActionMacro[data-id="4"]')
|
|
|
|
match_not(css: '.tasks > a.task > .nav-tab-name', value: 'Sample Ticket 1',)
|
|
|
|
match(css: '.tasks > a.is-active > .nav-tab-name', value: 'Sample Ticket 2',)
|
2016-09-05 13:18:22 +00:00
|
|
|
end
|
|
|
|
end
|