agent_ticket_time_accounting_test.rb 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. watch_for(
  40. css: '.content.active .modal',
  41. value: 'Time Accounting',
  42. )
  43. set(
  44. css: '.content.active .modal [name=time_unit]',
  45. value: '4',
  46. )
  47. click(
  48. css: '.content.active .modal .js-submit',
  49. )
  50. watch_for_disappear(
  51. css: '.content.active .modal',
  52. value: 'Time Accounting',
  53. )
  54. watch_for(
  55. css: '.content.active .js-timeUnit',
  56. value: '4',
  57. )
  58. ticket2 = ticket_create(
  59. data: {
  60. customer: 'nico',
  61. group: 'Users',
  62. title: 'some subject - time accounting#2',
  63. body: 'some body - time accounting#2',
  64. },
  65. )
  66. ticket_update(
  67. data: {
  68. body: 'some note',
  69. },
  70. do_not_submit: true,
  71. )
  72. click(
  73. css: '.active .js-submit',
  74. )
  75. watch_for(
  76. css: '.content.active .modal',
  77. value: 'Time Accounting',
  78. )
  79. set(
  80. css: '.content.active .modal [name=time_unit]',
  81. value: '4,6',
  82. )
  83. click(
  84. css: '.content.active .modal .js-submit',
  85. )
  86. watch_for_disappear(
  87. css: '.content.active .modal',
  88. value: 'Time Accounting',
  89. )
  90. watch_for(
  91. css: '.content.active .js-timeUnit',
  92. value: '4.6',
  93. )
  94. ticket_update(
  95. data: {
  96. body: 'some note2',
  97. },
  98. do_not_submit: true,
  99. )
  100. click(
  101. css: '.active .js-submit',
  102. )
  103. watch_for(
  104. css: '.content.active .modal',
  105. value: 'Time Accounting',
  106. )
  107. set(
  108. css: '.content.active .modal [name=time_unit]',
  109. value: '4abc',
  110. )
  111. click(
  112. css: '.content.active .modal .js-submit',
  113. )
  114. watch_for(
  115. css: '.content.active .modal [name=time_unit].has-error',
  116. )
  117. set(
  118. css: '.content.active .modal [name=time_unit]',
  119. value: '4 ',
  120. )
  121. click(
  122. css: '.content.active .modal .js-submit',
  123. )
  124. watch_for_disappear(
  125. css: '.content.active .modal',
  126. value: 'Time Accounting',
  127. )
  128. watch_for(
  129. css: '.content.active .js-timeUnit',
  130. value: '8.6',
  131. )
  132. # disable time accounting
  133. click(
  134. css: 'a[href="#manage"]',
  135. )
  136. click(
  137. css: '.content.active a[href="#manage/time_accounting"]',
  138. )
  139. switch(
  140. css: '.content.active .js-timeAccountingSetting',
  141. type: 'off',
  142. )
  143. # make sure "off" AJAX request gets completed
  144. # otherwise following tests might fail because
  145. # off still active timeaccounting
  146. logout()
  147. end
  148. end