Fixed #2367 - cannot sort by pending til

This commit is contained in:
Billy Zhou 2018-12-19 06:40:32 +01:00
parent 77794e0b26
commit 1be60c91db
4 changed files with 138 additions and 1 deletions

View file

@ -677,11 +677,22 @@ class App.ControllerTable extends App.Controller
@lastOrderDirection = orderDirection @lastOrderDirection = orderDirection
@lastOrderBy = orderBy @lastOrderBy = orderBy
# Underscore's sortBy cannot deal with null values, so we replace null values with a place holder string
sortBy = (list, iteratee) ->
_.sortBy(
list
(item) ->
res = iteratee(item)
return res if res
# null values are considered lexicographically "last"
'\uFFFF'
)
localObjects is undefined localObjects is undefined
if orderBy if orderBy
for header in @headers for header in @headers
if header.name is orderBy || "#{header.name}_id" is orderBy || header.name is "#{orderBy}_id" if header.name is orderBy || "#{header.name}_id" is orderBy || header.name is "#{orderBy}_id"
localObjects = _.sortBy( localObjects = sortBy(
@objects @objects
(item) -> (item) ->

View file

@ -41,6 +41,7 @@ if [ "$LEVEL" == '1' ]; then
rm test/browser/agent_ticket_overview_group_by_organization_test.rb rm test/browser/agent_ticket_overview_group_by_organization_test.rb
rm test/browser/agent_ticket_overview_level0_test.rb rm test/browser/agent_ticket_overview_level0_test.rb
rm test/browser/agent_ticket_overview_level1_test.rb rm test/browser/agent_ticket_overview_level1_test.rb
rm test/browser/agent_ticket_overview_pending_til_test.rb
rm test/browser/agent_ticket_overview_tab_test.rb rm test/browser/agent_ticket_overview_tab_test.rb
rm test/browser/agent_ticket_tag_test.rb rm test/browser/agent_ticket_tag_test.rb
rm test/browser/agent_ticket_task_changed_test.rb rm test/browser/agent_ticket_task_changed_test.rb
@ -121,6 +122,7 @@ elif [ "$LEVEL" == '2' ]; then
rm test/browser/agent_ticket_overview_group_by_organization_test.rb rm test/browser/agent_ticket_overview_group_by_organization_test.rb
rm test/browser/agent_ticket_overview_level0_test.rb rm test/browser/agent_ticket_overview_level0_test.rb
rm test/browser/agent_ticket_overview_level1_test.rb rm test/browser/agent_ticket_overview_level1_test.rb
rm test/browser/agent_ticket_overview_pending_til_test.rb
rm test/browser/agent_ticket_overview_tab_test.rb rm test/browser/agent_ticket_overview_tab_test.rb
rm test/browser/agent_ticket_tag_test.rb rm test/browser/agent_ticket_tag_test.rb
rm test/browser/agent_ticket_task_changed_test.rb rm test/browser/agent_ticket_task_changed_test.rb
@ -201,6 +203,7 @@ elif [ "$LEVEL" == '3' ]; then
rm test/browser/agent_ticket_overview_group_by_organization_test.rb rm test/browser/agent_ticket_overview_group_by_organization_test.rb
rm test/browser/agent_ticket_overview_level0_test.rb rm test/browser/agent_ticket_overview_level0_test.rb
rm test/browser/agent_ticket_overview_level1_test.rb rm test/browser/agent_ticket_overview_level1_test.rb
rm test/browser/agent_ticket_overview_pending_til_test.rb
rm test/browser/agent_ticket_overview_tab_test.rb rm test/browser/agent_ticket_overview_tab_test.rb
# test/browser/agent_ticket_tag_test.rb # test/browser/agent_ticket_tag_test.rb
# test/browser/agent_ticket_task_changed_test.rb # test/browser/agent_ticket_task_changed_test.rb
@ -281,6 +284,7 @@ elif [ "$LEVEL" == '4' ]; then
# test/browser/agent_ticket_overview_group_by_organization_test.rb # test/browser/agent_ticket_overview_group_by_organization_test.rb
# test/browser/agent_ticket_overview_level0_test.rb # test/browser/agent_ticket_overview_level0_test.rb
# test/browser/agent_ticket_overview_level1_test.rb # test/browser/agent_ticket_overview_level1_test.rb
# test/browser/agent_ticket_overview_pending_til_test.rb
# test/browser/agent_ticket_overview_tab_test.rb # test/browser/agent_ticket_overview_tab_test.rb
rm test/browser/agent_ticket_tag_test.rb rm test/browser/agent_ticket_tag_test.rb
rm test/browser/agent_ticket_task_changed_test.rb rm test/browser/agent_ticket_task_changed_test.rb
@ -360,6 +364,7 @@ elif [ "$LEVEL" == '5' ]; then
rm test/browser/agent_ticket_overview_group_by_organization_test.rb rm test/browser/agent_ticket_overview_group_by_organization_test.rb
rm test/browser/agent_ticket_overview_level0_test.rb rm test/browser/agent_ticket_overview_level0_test.rb
rm test/browser/agent_ticket_overview_level1_test.rb rm test/browser/agent_ticket_overview_level1_test.rb
rm test/browser/agent_ticket_overview_pending_til_test.rb
rm test/browser/agent_ticket_overview_tab_test.rb rm test/browser/agent_ticket_overview_tab_test.rb
rm test/browser/agent_ticket_tag_test.rb rm test/browser/agent_ticket_tag_test.rb
rm test/browser/agent_ticket_task_changed_test.rb rm test/browser/agent_ticket_task_changed_test.rb
@ -442,6 +447,7 @@ elif [ "$LEVEL" == '6' ]; then
rm test/browser/agent_ticket_overview_group_by_organization_test.rb rm test/browser/agent_ticket_overview_group_by_organization_test.rb
rm test/browser/agent_ticket_overview_level0_test.rb rm test/browser/agent_ticket_overview_level0_test.rb
rm test/browser/agent_ticket_overview_level1_test.rb rm test/browser/agent_ticket_overview_level1_test.rb
rm test/browser/agent_ticket_overview_pending_til_test.rb
rm test/browser/agent_ticket_overview_tab_test.rb rm test/browser/agent_ticket_overview_tab_test.rb
rm test/browser/agent_ticket_tag_test.rb rm test/browser/agent_ticket_tag_test.rb
rm test/browser/agent_ticket_task_changed_test.rb rm test/browser/agent_ticket_task_changed_test.rb

View file

@ -0,0 +1,66 @@
require 'browser_test_helper'
class AgentTicketOverviewPendingTil < TestCase
# regression for issue #2367 - cannot sort by Pending Til
def test_sorting_by_pending_til
name = "overview_pending_til_#{rand(999_999)}"
@browser = browser_instance
login(
username: 'master@example.com',
password: 'test',
url: browser_url,
)
tasks_close_all()
# create 4 tickets, 2 with pending til data and 2 without
tickets = []
4.times do |i|
ticket = ticket_create(
data: {
customer: 'nico',
group: 'Users',
title: "pending til ticket #{i}",
body: 'test ticket',
state: i.odd? ? 'pending close' : 'open',
pending_date: '11/24/2018',
pending_time: '08:00',
}
)
tickets.push ticket
end
# create and open new overview that has the Pending Til column
overview_create(
data: {
name: name,
roles: %w[Admin Agent],
selector: {
'State' => ['new', 'open', 'closed', 'merged', 'pending close', 'pending reminder'],
},
attributes: {
'pending_time' => true,
},
}
)
overview_open(
name: name,
)
# sort by Pending Til
click(
css: '.content.active table.table th.js-tableHead[data-column-key="pending_time"]',
)
# check if the first and second rows both correctly contain 'pending close'
match(
css: '.content.active table .js-tableBody tr:nth-child(1)',
value: 'pending close',
)
match(
css: '.content.active table .js-tableBody tr:nth-child(2)',
value: 'pending close',
)
end
end

View file

@ -1778,6 +1778,20 @@ wait untill text in selector disabppears
end end
end end
data[:attributes]&.each do |key, value|
if value
check(
browser: instance,
css: ".modal .checkbox input[value=\"#{key}\"]",
)
else
uncheck(
browser: instance,
css: ".modal .checkbox input[value=\"#{key}\"]",
)
end
end
data[:selector]&.each do |key, value| data[:selector]&.each do |key, value|
select( select(
browser: instance, browser: instance,
@ -1793,6 +1807,15 @@ wait untill text in selector disabppears
value: value, value: value,
mute_log: true, mute_log: true,
) )
elsif value.instance_of? Array
value.each do |item|
select(
browser: instance,
css: '.modal .ticket_selector .js-value select',
value: item,
mute_log: true,
)
end
else else
select( select(
browser: instance, browser: instance,
@ -2008,6 +2031,19 @@ wait untill text in selector disabppears
disable_group_check: true, disable_group_check: true,
) )
ticket = ticket_create(
browser: browser1,
data: {
customer: 'nico',
priority: '2 normal',
state: 'pending close',
pending_date: '11/24/2018',
pending_time: '08:00',
title: 'overview #1',
body: 'overview #1',
},
do_not_submit: true,
)
=end =end
def ticket_create(params) def ticket_create(params)
@ -2098,6 +2134,24 @@ wait untill text in selector disabppears
value: data[:state], value: data[:state],
mute_log: true, mute_log: true,
) )
if ['pending close', 'pending reminder'].include?(data[:state]) &&
data[:pending_date] &&
data[:pending_time]
set(
browser: instance,
css: '.content.active .newTicket input.js-datepicker',
value: data[:pending_date],
clear: true,
mute_log: true,
)
set(
browser: instance,
css: '.content.active .newTicket input.js-timepicker',
value: data[:pending_time],
clear: true,
mute_log: true,
)
end
end end
if data[:title] if data[:title]
set( set(