keyboard_shortcuts_test.rb 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. # encoding: utf-8
  2. require 'browser_test_helper'
  3. class KeyboardShortcutsTest < TestCase
  4. def test_navigation
  5. @browser = browser_instance
  6. login(
  7. username: 'master@example.com',
  8. password: 'test',
  9. url: browser_url,
  10. )
  11. tasks_close_all()
  12. sleep 2
  13. # show shortkeys
  14. shortcut(key: 'h')
  15. # ff issue, sometimes shortcut is not fired in browser test env
  16. if ENV['BROWSER'] && ENV['BROWSER'] =~ /firefox/i
  17. exists = false
  18. (1..4).each { |_count|
  19. sleep 1
  20. next if !@browser.find_elements(css: '.modal')[0]
  21. exists = true
  22. }
  23. if !exists
  24. reload
  25. sleep 4
  26. shortcut(key: 'h')
  27. (1..4).each { |_count|
  28. sleep 1
  29. next if !@browser.find_elements(css: '.modal')[0]
  30. exists = true
  31. }
  32. end
  33. if !exists
  34. shortcut(key: 'h')
  35. end
  36. end
  37. watch_for(
  38. css: '.modal',
  39. value: 'Keyboard Shortcuts',
  40. timeout: 6,
  41. )
  42. # hide shortkeys
  43. shortcut(key: 'h')
  44. watch_for_disappear(
  45. css: '.modal',
  46. value: 'Keyboard Shortcuts',
  47. timeout: 2,
  48. )
  49. # show shortkeys
  50. shortcut(key: 'h')
  51. watch_for(
  52. css: '.modal',
  53. value: 'Keyboard Shortcuts',
  54. timeout: 2,
  55. )
  56. # show notifications
  57. shortcut(key: 'a')
  58. watch_for(
  59. css: '.js-notificationsContainer .js-header',
  60. value: 'Notification',
  61. timeout: 10,
  62. )
  63. shortcut(key: 'a')
  64. watch_for_disappear(
  65. css: '.js-notificationsContainer .js-header',
  66. value: 'Notification',
  67. timeout: 2,
  68. )
  69. # go to overviews
  70. shortcut(key: 'o')
  71. watch_for(
  72. css: '.active.content',
  73. value: 'My assigned Tickets',
  74. timeout: 2,
  75. )
  76. # go to dashboard
  77. shortcut(key: 'd')
  78. watch_for(
  79. css: '.active.content',
  80. value: 'My Stats',
  81. timeout: 2,
  82. )
  83. # go to new ticket
  84. shortcut(key: 'n')
  85. watch_for(
  86. css: '.active.content',
  87. value: 'New Ticket',
  88. timeout: 2,
  89. )
  90. # close again
  91. shortcut(key: 'w')
  92. watch_for_disappear(
  93. css: '.active.content',
  94. value: 'New Ticket',
  95. timeout: 2,
  96. )
  97. ticket1 = ticket_create(
  98. data: {
  99. customer: 'nico',
  100. group: 'Users',
  101. title: 'Test Ticket for Shortcuts - ABC123',
  102. body: 'Test Ticket Body for Shortcuts - ABC123',
  103. },
  104. )
  105. sleep 5
  106. # close again
  107. shortcut(key: 'w')
  108. watch_for_disappear(
  109. css: '.active.content',
  110. value: ticket1[:number],
  111. timeout: 2,
  112. )
  113. # search it
  114. shortcut(key: 's')
  115. window_keys(value: ticket1[:number])
  116. exists(css: '#navigation .search.open')
  117. sleep 2
  118. window_keys(value: :arrow_down)
  119. window_keys(value: :arrow_down)
  120. window_keys(value: :enter)
  121. watch_for(
  122. css: '.active.content',
  123. value: ticket1[:number],
  124. timeout: 2,
  125. )
  126. exists_not(css: '#navigation .search.open')
  127. # open ticket
  128. shortcut(key: 's')
  129. window_keys(value: ticket1[:number])
  130. sleep 2
  131. window_keys(value: :arrow_down)
  132. window_keys(value: :arrow_down)
  133. window_keys(value: :enter)
  134. # open new ticket
  135. shortcut(key: 'n')
  136. watch_for(
  137. css: '.active.content',
  138. value: 'New Ticket',
  139. timeout: 2,
  140. )
  141. tab_count = @browser.find_elements(css: '#navigation .tasks .task').count
  142. assert_equal(2, tab_count)
  143. # tab is tab
  144. shortcut(key: :tab)
  145. watch_for(
  146. css: '.active.content',
  147. value: ticket1[:number],
  148. timeout: 2,
  149. )
  150. shortcut(key: 'm')
  151. shortcut(key: 'j')
  152. window_keys(value: 'some note')
  153. sleep 1
  154. shortcut(key: :enter)
  155. watch_for(
  156. css: '.active.content .ticket-article',
  157. value: 'some note',
  158. timeout: 6,
  159. )
  160. exists(css: '.active.content .ticket-article .internal-border')
  161. shortcut(key: 'g')
  162. window_keys(value: 'some reply')
  163. sleep 1
  164. shortcut(key: :enter)
  165. watch_for(
  166. css: '.active.content .ticket-article',
  167. value: 'some reply',
  168. timeout: 6,
  169. )
  170. shortcut(key: 'c')
  171. watch_for(
  172. css: '.active.content .sidebar-content .edit',
  173. value: 'closed',
  174. timeout: 6,
  175. )
  176. # open online notification
  177. @browser_agent = browser_instance
  178. login(
  179. browser: @browser_agent,
  180. username: 'agent1@example.com',
  181. password: 'test',
  182. url: browser_url,
  183. )
  184. ticket2 = ticket_create(
  185. browser: @browser_agent,
  186. data: {
  187. customer: 'nico',
  188. group: 'Users',
  189. title: 'Test Ticket for Shortcuts II - ABC123',
  190. body: 'Test Ticket Body for Shortcuts II - ABC123',
  191. },
  192. )
  193. sleep 5
  194. shortcut(key: 'a')
  195. watch_for(
  196. css: '.js-notificationsContainer',
  197. value: 'Test Ticket for Shortcuts II',
  198. timeout: 10,
  199. )
  200. window_keys(value: :arrow_down)
  201. window_keys(value: :enter)
  202. watch_for(
  203. css: '.active.content',
  204. value: ticket2[:number],
  205. timeout: 3,
  206. )
  207. shortcut(key: 'e')
  208. watch_for(
  209. css: 'body',
  210. value: 'login',
  211. timeout: 4,
  212. )
  213. end
  214. end