2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
require 'browser_test_helper'
|
|
|
|
|
|
|
|
class KeyboardShortcutsTest < TestCase
|
|
|
|
def test_navigation
|
|
|
|
@browser = browser_instance
|
|
|
|
login(
|
2021-08-17 12:10:02 +00:00
|
|
|
username: 'admin@example.com',
|
2016-02-25 12:45:46 +00:00
|
|
|
password: 'test',
|
2018-12-19 17:31:51 +00:00
|
|
|
url: browser_url,
|
2016-02-25 12:45:46 +00:00
|
|
|
)
|
2021-07-16 13:29:38 +00:00
|
|
|
tasks_close_all
|
2016-06-17 10:57:54 +00:00
|
|
|
sleep 2
|
2016-02-25 12:45:46 +00:00
|
|
|
|
|
|
|
# show shortkeys
|
|
|
|
shortcut(key: 'h')
|
2016-06-17 10:57:54 +00:00
|
|
|
|
|
|
|
# ff issue, sometimes shortcut is not fired in browser test env
|
2021-05-12 11:37:44 +00:00
|
|
|
if ENV['BROWSER'] && ENV['BROWSER'] =~ %r{firefox}i
|
2016-06-17 10:57:54 +00:00
|
|
|
exists = false
|
2017-10-01 12:25:52 +00:00
|
|
|
(1..4).each do |_count|
|
2016-06-17 10:57:54 +00:00
|
|
|
sleep 1
|
|
|
|
next if !@browser.find_elements(css: '.modal')[0]
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2016-06-17 10:57:54 +00:00
|
|
|
exists = true
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2016-06-17 10:57:54 +00:00
|
|
|
if !exists
|
|
|
|
reload
|
|
|
|
sleep 4
|
|
|
|
shortcut(key: 'h')
|
2017-10-01 12:25:52 +00:00
|
|
|
(1..4).each do |_count|
|
2016-06-17 10:57:54 +00:00
|
|
|
sleep 1
|
|
|
|
next if !@browser.find_elements(css: '.modal')[0]
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2016-06-17 10:57:54 +00:00
|
|
|
exists = true
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2016-06-17 10:57:54 +00:00
|
|
|
end
|
|
|
|
if !exists
|
|
|
|
shortcut(key: 'h')
|
|
|
|
end
|
|
|
|
end
|
2016-02-25 12:45:46 +00:00
|
|
|
|
2021-07-16 13:29:38 +00:00
|
|
|
modal_ready
|
2016-02-25 12:45:46 +00:00
|
|
|
# hide shortkeys
|
|
|
|
shortcut(key: 'h')
|
2021-07-16 13:29:38 +00:00
|
|
|
modal_disappear
|
2016-02-25 12:45:46 +00:00
|
|
|
|
|
|
|
# show shortkeys
|
|
|
|
shortcut(key: 'h')
|
2021-07-16 13:29:38 +00:00
|
|
|
modal_ready
|
2016-02-25 12:45:46 +00:00
|
|
|
|
2016-03-22 10:50:12 +00:00
|
|
|
# show notifications
|
|
|
|
shortcut(key: 'a')
|
|
|
|
watch_for(
|
|
|
|
css: '.js-notificationsContainer .js-header',
|
|
|
|
value: 'Notification',
|
|
|
|
timeout: 10,
|
|
|
|
)
|
|
|
|
|
|
|
|
shortcut(key: 'a')
|
|
|
|
watch_for_disappear(
|
|
|
|
css: '.js-notificationsContainer .js-header',
|
|
|
|
value: 'Notification',
|
|
|
|
timeout: 2,
|
|
|
|
)
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
# go to overviews
|
|
|
|
shortcut(key: 'o')
|
|
|
|
watch_for(
|
|
|
|
css: '.active.content',
|
|
|
|
value: 'My assigned Tickets',
|
|
|
|
timeout: 2,
|
|
|
|
)
|
|
|
|
|
|
|
|
# go to dashboard
|
|
|
|
shortcut(key: 'd')
|
|
|
|
watch_for(
|
|
|
|
css: '.active.content',
|
|
|
|
value: 'My Stats',
|
|
|
|
timeout: 2,
|
|
|
|
)
|
|
|
|
|
|
|
|
# go to new ticket
|
|
|
|
shortcut(key: 'n')
|
|
|
|
watch_for(
|
|
|
|
css: '.active.content',
|
|
|
|
value: 'New Ticket',
|
|
|
|
timeout: 2,
|
|
|
|
)
|
|
|
|
|
|
|
|
# close again
|
2016-04-06 14:06:26 +00:00
|
|
|
shortcut(key: 'w')
|
2016-02-25 12:45:46 +00:00
|
|
|
|
|
|
|
watch_for_disappear(
|
|
|
|
css: '.active.content',
|
|
|
|
value: 'New Ticket',
|
|
|
|
timeout: 2,
|
|
|
|
)
|
|
|
|
|
|
|
|
ticket1 = ticket_create(
|
|
|
|
data: {
|
|
|
|
customer: 'nico',
|
2018-12-19 17:31:51 +00:00
|
|
|
group: 'Users',
|
|
|
|
title: 'Test Ticket for Shortcuts - ABC123',
|
|
|
|
body: 'Test Ticket Body for Shortcuts - ABC123',
|
2016-02-25 12:45:46 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
# close again
|
2016-04-06 14:06:26 +00:00
|
|
|
shortcut(key: 'w')
|
2016-02-25 12:45:46 +00:00
|
|
|
watch_for_disappear(
|
|
|
|
css: '.active.content',
|
|
|
|
value: ticket1[:number],
|
|
|
|
timeout: 2,
|
|
|
|
)
|
|
|
|
|
|
|
|
# search it
|
|
|
|
shortcut(key: 's')
|
|
|
|
window_keys(value: ticket1[:number])
|
|
|
|
exists(css: '#navigation .search.open')
|
|
|
|
sleep 2
|
|
|
|
window_keys(value: :arrow_down)
|
2016-07-05 20:38:39 +00:00
|
|
|
window_keys(value: :arrow_down)
|
2016-02-25 12:45:46 +00:00
|
|
|
window_keys(value: :enter)
|
|
|
|
watch_for(
|
|
|
|
css: '.active.content',
|
|
|
|
value: ticket1[:number],
|
|
|
|
timeout: 2,
|
|
|
|
)
|
|
|
|
exists_not(css: '#navigation .search.open')
|
|
|
|
|
|
|
|
# open ticket
|
|
|
|
shortcut(key: 's')
|
|
|
|
window_keys(value: ticket1[:number])
|
|
|
|
sleep 2
|
|
|
|
window_keys(value: :arrow_down)
|
2016-07-05 20:38:39 +00:00
|
|
|
window_keys(value: :arrow_down)
|
2016-02-25 12:45:46 +00:00
|
|
|
window_keys(value: :enter)
|
|
|
|
|
|
|
|
# open new ticket
|
|
|
|
shortcut(key: 'n')
|
|
|
|
watch_for(
|
|
|
|
css: '.active.content',
|
|
|
|
value: 'New Ticket',
|
|
|
|
timeout: 2,
|
|
|
|
)
|
|
|
|
|
|
|
|
tab_count = @browser.find_elements(css: '#navigation .tasks .task').count
|
|
|
|
assert_equal(2, tab_count)
|
|
|
|
|
|
|
|
# tab is tab
|
|
|
|
shortcut(key: :tab)
|
|
|
|
watch_for(
|
|
|
|
css: '.active.content',
|
|
|
|
value: ticket1[:number],
|
|
|
|
timeout: 2,
|
|
|
|
)
|
|
|
|
shortcut(key: 'm')
|
|
|
|
shortcut(key: 'j')
|
|
|
|
window_keys(value: 'some note')
|
2016-02-25 14:20:22 +00:00
|
|
|
sleep 1
|
2016-02-25 12:45:46 +00:00
|
|
|
shortcut(key: :enter)
|
|
|
|
watch_for(
|
|
|
|
css: '.active.content .ticket-article',
|
|
|
|
value: 'some note',
|
|
|
|
timeout: 6,
|
|
|
|
)
|
|
|
|
exists(css: '.active.content .ticket-article .internal-border')
|
|
|
|
|
|
|
|
shortcut(key: 'g')
|
|
|
|
window_keys(value: 'some reply')
|
2016-02-25 14:20:22 +00:00
|
|
|
sleep 1
|
2016-02-25 12:45:46 +00:00
|
|
|
shortcut(key: :enter)
|
|
|
|
watch_for(
|
|
|
|
css: '.active.content .ticket-article',
|
|
|
|
value: 'some reply',
|
|
|
|
timeout: 6,
|
|
|
|
)
|
|
|
|
|
|
|
|
shortcut(key: 'c')
|
|
|
|
watch_for(
|
|
|
|
css: '.active.content .sidebar-content .edit',
|
|
|
|
value: 'closed',
|
|
|
|
timeout: 6,
|
|
|
|
)
|
|
|
|
|
2016-02-25 20:42:33 +00:00
|
|
|
# open online notification
|
|
|
|
@browser_agent = browser_instance
|
|
|
|
login(
|
|
|
|
browser: @browser_agent,
|
|
|
|
username: 'agent1@example.com',
|
|
|
|
password: 'test',
|
2018-12-19 17:31:51 +00:00
|
|
|
url: browser_url,
|
2016-02-25 20:42:33 +00:00
|
|
|
)
|
|
|
|
ticket2 = ticket_create(
|
2018-12-19 17:31:51 +00:00
|
|
|
browser: @browser_agent,
|
|
|
|
data: {
|
2016-02-25 20:42:33 +00:00
|
|
|
customer: 'nico',
|
2018-12-19 17:31:51 +00:00
|
|
|
group: 'Users',
|
|
|
|
title: 'Test Ticket for Shortcuts II - ABC123',
|
|
|
|
body: 'Test Ticket Body for Shortcuts II - ABC123',
|
2016-02-25 20:42:33 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
sleep 5
|
2016-03-22 10:50:12 +00:00
|
|
|
shortcut(key: 'a')
|
2019-01-12 11:19:00 +00:00
|
|
|
# flanky
|
2016-02-25 20:42:33 +00:00
|
|
|
watch_for(
|
|
|
|
css: '.js-notificationsContainer',
|
|
|
|
value: 'Test Ticket for Shortcuts II',
|
|
|
|
timeout: 10,
|
|
|
|
)
|
|
|
|
window_keys(value: :arrow_down)
|
|
|
|
window_keys(value: :enter)
|
|
|
|
watch_for(
|
|
|
|
css: '.active.content',
|
|
|
|
value: ticket2[:number],
|
2016-03-22 10:50:12 +00:00
|
|
|
timeout: 3,
|
2016-02-25 20:42:33 +00:00
|
|
|
)
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
shortcut(key: 'e')
|
|
|
|
watch_for(
|
2021-10-06 13:06:49 +00:00
|
|
|
css: '#login',
|
|
|
|
value: 'username',
|
2016-02-25 12:45:46 +00:00
|
|
|
timeout: 4,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|