agent_ticket_time_accounting_test.rb 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. require 'browser_test_helper'
  3. class AgentTicketTimeAccountingTest < TestCase
  4. def test_macro
  5. @browser = browser_instance
  6. login(
  7. username: 'admin@example.com',
  8. password: 'test',
  9. url: browser_url,
  10. )
  11. tasks_close_all
  12. # enable time accounting
  13. click(
  14. css: 'a[href="#manage"]',
  15. )
  16. click(
  17. css: '.content.active a[href="#manage/time_accounting"]',
  18. )
  19. switch(
  20. css: '.content.active .js-timeAccountingSetting',
  21. type: 'on',
  22. )
  23. ticket_create(
  24. data: {
  25. customer: 'nico',
  26. group: 'Users',
  27. title: 'some subject - time accounting#1',
  28. body: 'some body - time accounting#1',
  29. },
  30. )
  31. ticket_update(
  32. data: {
  33. body: 'some note',
  34. },
  35. do_not_submit: true,
  36. )
  37. click(
  38. css: '.active .js-submit',
  39. )
  40. modal_ready
  41. set(
  42. css: '.content.active .modal [name=time_unit]',
  43. value: '4',
  44. )
  45. click(
  46. css: '.content.active .modal .js-submit',
  47. )
  48. modal_disappear
  49. watch_for(
  50. css: '.content.active .js-timeUnit',
  51. value: '4',
  52. )
  53. ticket_create(
  54. data: {
  55. customer: 'nico',
  56. group: 'Users',
  57. title: 'some subject - time accounting#2',
  58. body: 'some body - time accounting#2',
  59. },
  60. )
  61. ticket_update(
  62. data: {
  63. body: 'some note',
  64. },
  65. do_not_submit: true,
  66. )
  67. click(
  68. css: '.active .js-submit',
  69. )
  70. modal_ready
  71. set(
  72. css: '.content.active .modal [name=time_unit]',
  73. value: '4,6',
  74. )
  75. click(
  76. css: '.content.active .modal .js-submit',
  77. )
  78. modal_disappear
  79. watch_for(
  80. css: '.content.active .js-timeUnit',
  81. value: '4.6',
  82. )
  83. ticket_update(
  84. data: {
  85. body: 'some note2',
  86. },
  87. do_not_submit: true,
  88. )
  89. click(
  90. css: '.active .js-submit',
  91. )
  92. modal_ready
  93. set(
  94. css: '.content.active .modal [name=time_unit]',
  95. value: '4abc',
  96. )
  97. click(
  98. css: '.content.active .modal .js-submit',
  99. )
  100. watch_for(
  101. css: '.content.active .modal [name=time_unit].has-error',
  102. )
  103. set(
  104. css: '.content.active .modal [name=time_unit]',
  105. value: '4 ',
  106. )
  107. click(
  108. css: '.content.active .modal .js-submit',
  109. )
  110. modal_disappear
  111. watch_for(
  112. css: '.content.active .js-timeUnit',
  113. value: '8.6',
  114. )
  115. # disable time accounting
  116. click(
  117. css: 'a[href="#manage"]',
  118. )
  119. click(
  120. css: '.content.active a[href="#manage/time_accounting"]',
  121. )
  122. switch(
  123. css: '.content.active .js-timeAccountingSetting',
  124. type: 'off',
  125. )
  126. # make sure "off" AJAX request gets completed
  127. # otherwise following tests might fail because
  128. # off still active timeaccounting
  129. logout
  130. end
  131. def test_closing_time_accounting_modal_by_clicking_background
  132. @browser = browser_instance
  133. login(
  134. username: 'admin@example.com',
  135. password: 'test',
  136. url: browser_url,
  137. )
  138. tasks_close_all
  139. # enable time accounting
  140. click(
  141. css: 'a[href="#manage"]',
  142. )
  143. click(
  144. css: '.content.active a[href="#manage/time_accounting"]',
  145. )
  146. switch(
  147. css: '.content.active .js-timeAccountingSetting',
  148. type: 'on',
  149. )
  150. ticket_create(
  151. data: {
  152. customer: 'nico',
  153. group: 'Users',
  154. title: 'some subject - time accounting#3',
  155. body: 'some body - time accounting#3',
  156. },
  157. )
  158. ticket_update(
  159. data: {
  160. body: 'some note',
  161. },
  162. do_not_submit: true,
  163. )
  164. click(
  165. css: '.active .js-submit',
  166. )
  167. modal_ready
  168. # Click outside the modal to make it disappear
  169. execute(
  170. js: 'document.elementFromPoint(300, 100).click();',
  171. )
  172. modal_disappear
  173. click(
  174. css: '.active .js-submit',
  175. )
  176. modal_ready
  177. set(
  178. css: '.content.active .modal [name=time_unit]',
  179. value: '4',
  180. )
  181. click(
  182. css: '.content.active .modal .js-submit',
  183. )
  184. modal_disappear
  185. # disable time accounting
  186. click(
  187. css: 'a[href="#manage"]',
  188. )
  189. click(
  190. css: '.content.active a[href="#manage/time_accounting"]',
  191. )
  192. switch(
  193. css: '.content.active .js-timeAccountingSetting',
  194. type: 'off',
  195. )
  196. # make sure "off" AJAX request gets completed
  197. # otherwise following tests might fail because
  198. # off still active timeaccounting
  199. logout
  200. end
  201. end