agent_ticket_time_accounting_test.rb 4.4 KB

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