keyboard_shortcuts_test.rb 4.5 KB

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