keyboard_shortcuts_test.rb 4.1 KB

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