2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2016-03-13 23:25:05 +00:00
|
|
|
require 'browser_test_helper'
|
|
|
|
|
|
|
|
class AdminOverviewTest < TestCase
|
|
|
|
def test_account_add
|
2021-09-20 10:47:05 +00:00
|
|
|
name = "some overview #{SecureRandom.uuid}"
|
2016-03-13 23:25:05 +00:00
|
|
|
|
|
|
|
@browser = browser_instance
|
|
|
|
login(
|
2021-08-17 12:10:02 +00:00
|
|
|
username: 'admin@example.com',
|
2016-03-13 23:25:05 +00:00
|
|
|
password: 'test',
|
2018-12-19 17:31:51 +00:00
|
|
|
url: browser_url,
|
2016-03-13 23:25:05 +00:00
|
|
|
)
|
2021-07-16 13:29:38 +00:00
|
|
|
tasks_close_all
|
2016-03-13 23:25:05 +00:00
|
|
|
|
|
|
|
# add new overview
|
|
|
|
overview_create(
|
|
|
|
data: {
|
2017-04-19 19:54:04 +00:00
|
|
|
name: name,
|
|
|
|
roles: ['Agent'],
|
2016-03-13 23:25:05 +00:00
|
|
|
selector: {
|
|
|
|
'Priority' => '1 low',
|
|
|
|
},
|
|
|
|
'order::direction' => 'down',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
# edit overview
|
|
|
|
overview_update(
|
|
|
|
data: {
|
2017-04-19 19:54:04 +00:00
|
|
|
name: name,
|
|
|
|
roles: ['Agent'],
|
2016-03-13 23:25:05 +00:00
|
|
|
selector: {
|
|
|
|
'State' => 'new',
|
|
|
|
},
|
|
|
|
'order::direction' => 'up',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2018-07-12 07:18:39 +00:00
|
|
|
def test_overview_group_by_direction
|
2021-09-20 10:47:05 +00:00
|
|
|
name = "overview_#{SecureRandom.uuid}"
|
2018-07-12 07:18:39 +00:00
|
|
|
ticket_titles = (1..3).map { |i| "Priority #{i} ticket" }
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
@browser = browser_instance
|
2018-07-12 07:18:39 +00:00
|
|
|
login(
|
2021-08-17 12:10:02 +00:00
|
|
|
username: 'admin@example.com',
|
2018-07-12 07:18:39 +00:00
|
|
|
password: 'test',
|
2018-12-19 17:31:51 +00:00
|
|
|
url: browser_url,
|
2018-07-12 07:18:39 +00:00
|
|
|
)
|
2021-07-16 13:29:38 +00:00
|
|
|
tasks_close_all
|
2018-07-12 07:18:39 +00:00
|
|
|
|
|
|
|
ticket_create(
|
|
|
|
data: {
|
|
|
|
customer: 'nico',
|
2018-12-19 17:31:51 +00:00
|
|
|
group: 'Users',
|
|
|
|
title: 'Priority 1 ticket',
|
|
|
|
body: 'some body 123äöü',
|
2018-07-12 07:18:39 +00:00
|
|
|
priority: '1 low',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
ticket_create(
|
|
|
|
data: {
|
|
|
|
customer: 'nico',
|
2018-12-19 17:31:51 +00:00
|
|
|
group: 'Users',
|
|
|
|
title: 'Priority 2 ticket',
|
|
|
|
body: 'some body 123äöü',
|
2018-07-12 07:18:39 +00:00
|
|
|
priority: '2 normal',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
ticket_create(
|
|
|
|
data: {
|
|
|
|
customer: 'nico',
|
2018-12-19 17:31:51 +00:00
|
|
|
group: 'Users',
|
|
|
|
title: 'Priority 3 ticket',
|
|
|
|
body: 'some body 123äöü',
|
2018-07-12 07:18:39 +00:00
|
|
|
priority: '3 high',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
# Add new overview to sort groups from high to low
|
|
|
|
overview_create(
|
|
|
|
data: {
|
|
|
|
name: name,
|
|
|
|
roles: ['Agent'],
|
|
|
|
selector: {
|
|
|
|
'State' => 'open',
|
|
|
|
},
|
|
|
|
'order::direction' => 'down',
|
|
|
|
group_by: 'Priority',
|
|
|
|
group_direction: 'down',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2018-07-24 15:32:32 +00:00
|
|
|
overview_open(
|
|
|
|
name: name
|
2018-07-12 07:18:39 +00:00
|
|
|
)
|
|
|
|
|
2018-07-24 15:32:32 +00:00
|
|
|
assert_equal(ticket_titles.reverse, ordered_ticket_titles(ticket_titles))
|
2018-07-12 07:18:39 +00:00
|
|
|
|
|
|
|
# Update overview to sort groups from low to high
|
|
|
|
overview_update(
|
|
|
|
data: {
|
2018-12-19 17:31:51 +00:00
|
|
|
name: name,
|
2018-07-12 07:18:39 +00:00
|
|
|
group_direction: 'up',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2018-07-24 15:32:32 +00:00
|
|
|
overview_open(
|
|
|
|
name: name
|
2018-07-12 07:18:39 +00:00
|
|
|
)
|
|
|
|
|
2018-07-24 15:32:32 +00:00
|
|
|
# wait till the scheduler pushed
|
|
|
|
# the changes to the FE
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
assert_equal(ticket_titles, ordered_ticket_titles(ticket_titles))
|
|
|
|
end
|
|
|
|
|
|
|
|
def ordered_ticket_titles(ticket_titles)
|
|
|
|
ticket_titles.map do |title|
|
2018-07-12 07:18:39 +00:00
|
|
|
[title,
|
2021-07-16 13:38:01 +00:00
|
|
|
get_location(css: "td[title='#{title}']").y]
|
2018-07-24 15:32:32 +00:00
|
|
|
end.sort_by { |x| x[1] }.map { |x| x[0] }
|
2018-07-12 07:18:39 +00:00
|
|
|
end
|
2018-09-15 17:45:06 +00:00
|
|
|
|
|
|
|
# verify fix for issue #2235 - Overview setting isn't applied on submit
|
|
|
|
def test_overview_toggle_out_of_office_setting
|
|
|
|
@browser = browser_instance
|
|
|
|
login(
|
2021-08-17 12:10:02 +00:00
|
|
|
username: 'admin@example.com',
|
2018-09-15 17:45:06 +00:00
|
|
|
password: 'test',
|
2018-12-19 17:31:51 +00:00
|
|
|
url: browser_url,
|
2018-09-15 17:45:06 +00:00
|
|
|
)
|
2021-07-16 13:29:38 +00:00
|
|
|
tasks_close_all
|
2018-09-15 17:45:06 +00:00
|
|
|
|
|
|
|
out_of_office_css = '.content.active .modal select[name="out_of_office"]'
|
|
|
|
first_overview_css = '.content.active tr[data-id="1"] td'
|
|
|
|
|
2021-07-16 13:38:01 +00:00
|
|
|
click(css: 'a[href="#manage"]')
|
|
|
|
click(css: '.content.active a[href="#manage/overviews"]')
|
2018-09-15 17:45:06 +00:00
|
|
|
|
|
|
|
# round 1, open the overview and set out_of_office to true
|
2021-07-16 13:38:01 +00:00
|
|
|
click(css: first_overview_css)
|
2018-09-15 17:45:06 +00:00
|
|
|
modal_ready
|
|
|
|
watch_for(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: out_of_office_css,
|
2018-09-15 17:45:06 +00:00
|
|
|
value: 'no',
|
|
|
|
)
|
|
|
|
select(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: out_of_office_css,
|
2018-09-15 17:45:06 +00:00
|
|
|
value: 'yes',
|
|
|
|
)
|
2021-07-16 13:38:01 +00:00
|
|
|
click(css: '.content.active .modal .js-submit')
|
2018-09-15 17:45:06 +00:00
|
|
|
modal_disappear
|
|
|
|
|
|
|
|
# round 2, open the overview and set out_of_office back to false
|
2021-07-16 13:38:01 +00:00
|
|
|
click(css: first_overview_css)
|
2018-09-15 17:45:06 +00:00
|
|
|
modal_ready
|
|
|
|
watch_for(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: out_of_office_css,
|
2018-09-15 17:45:06 +00:00
|
|
|
value: 'yes',
|
|
|
|
)
|
|
|
|
select(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: out_of_office_css,
|
2018-09-15 17:45:06 +00:00
|
|
|
value: 'no',
|
|
|
|
)
|
2021-07-16 13:38:01 +00:00
|
|
|
click(css: '.content.active .modal .js-submit')
|
2018-09-15 17:45:06 +00:00
|
|
|
modal_disappear
|
|
|
|
|
|
|
|
# round 3, open the overview and confirm that it's still false
|
2021-07-16 13:38:01 +00:00
|
|
|
click(css: first_overview_css)
|
2018-09-15 17:45:06 +00:00
|
|
|
modal_ready
|
|
|
|
watch_for(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: out_of_office_css,
|
2018-09-15 17:45:06 +00:00
|
|
|
value: 'no',
|
|
|
|
)
|
2021-07-16 13:38:01 +00:00
|
|
|
click(css: '.content.active .modal .js-submit')
|
2018-09-15 17:45:06 +00:00
|
|
|
modal_disappear
|
|
|
|
end
|
2016-03-13 23:25:05 +00:00
|
|
|
end
|