agent_user_manage_test.rb 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. # encoding: utf-8
  2. require 'browser_test_helper'
  3. class AgentUserManageTest < TestCase
  4. def test_agent_user
  5. customer_user_email = 'customer-test-' + rand(999999).to_s + '@example.com'
  6. firstname = 'Customer Firstname'
  7. lastname = 'Customer Lastname'
  8. fullname = "#{ firstname } #{ lastname } <#{ customer_user_email }>"
  9. tests = [
  10. {
  11. :name => 'create customer',
  12. :action => [
  13. {
  14. :execute => 'close_all_tasks',
  15. },
  16. {
  17. :execute => 'wait',
  18. :value => 1,
  19. },
  20. {
  21. :execute => 'click',
  22. :css => 'a[href="#new"]',
  23. },
  24. {
  25. :execute => 'click',
  26. :css => 'a[href="#ticket/create"]',
  27. },
  28. {
  29. :execute => 'click',
  30. :css => '.active [name="customer_id_completion"]',
  31. },
  32. {
  33. :execute => 'sendkey',
  34. :value => [:arrow_down,:enter]
  35. },
  36. {
  37. :execute => 'wait',
  38. :value => 2,
  39. },
  40. {
  41. :execute => 'set',
  42. :css => '.modal input[name="firstname"]',
  43. :value => firstname,
  44. },
  45. {
  46. :execute => 'set',
  47. :css => '.modal input[name="lastname"]',
  48. :value => lastname,
  49. },
  50. {
  51. :execute => 'set',
  52. :css => '.modal input[name="email"]',
  53. :value => customer_user_email,
  54. },
  55. {
  56. :execute => 'click',
  57. :css => '.modal button.js-submit',
  58. },
  59. {
  60. :execute => 'wait',
  61. :value => 4,
  62. },
  63. # check is used is selected
  64. {
  65. :execute => 'match',
  66. :css => '.active input[name="customer_id"]',
  67. :value => '^\d+$',
  68. :no_quote => true,
  69. :match_result => true,
  70. },
  71. {
  72. :execute => 'match',
  73. :css => '.active input[name="customer_id_completion"]',
  74. :value => firstname,
  75. :no_quote => true,
  76. :match_result => true,
  77. },
  78. {
  79. :execute => 'match',
  80. :css => '.active input[name="customer_id_completion"]',
  81. :value => lastname,
  82. :no_quote => true,
  83. :match_result => true,
  84. },
  85. {
  86. :execute => 'match',
  87. :css => '.active input[name="customer_id_completion"]',
  88. :value => customer_user_email,
  89. :no_quote => true,
  90. :match_result => true,
  91. },
  92. {
  93. :execute => 'match',
  94. :css => '.active input[name="customer_id_completion"]',
  95. :value => fullname,
  96. :no_quote => true,
  97. :match_result => true,
  98. },
  99. # call new ticket screen again
  100. {
  101. :execute => 'close_all_tasks',
  102. },
  103. {
  104. :execute => 'wait',
  105. :value => 2,
  106. },
  107. # accept task close warning
  108. {
  109. :execute => 'click',
  110. :css => '.modal button.js-submit',
  111. },
  112. {
  113. :execute => 'wait',
  114. :value => 1,
  115. },
  116. {
  117. :execute => 'click',
  118. :css => 'a[href="#new"]',
  119. },
  120. {
  121. :execute => 'click',
  122. :css => 'a[href="#ticket/create"]',
  123. },
  124. {
  125. :execute => 'wait',
  126. :value => 2,
  127. },
  128. {
  129. :execute => 'match',
  130. :css => '.active input[name="customer_id"]',
  131. :value => '^\d+$',
  132. :no_quote => true,
  133. :match_result => false,
  134. },
  135. {
  136. :execute => 'match',
  137. :css => '.active input[name="customer_id_completion"]',
  138. :value => firstname,
  139. :no_quote => true,
  140. :match_result => false,
  141. },
  142. {
  143. :execute => 'set',
  144. :css => '.active .newTicket input[name="customer_id_completion"]',
  145. :value => customer_user_email,
  146. },
  147. {
  148. :execute => 'wait',
  149. :value => 3,
  150. },
  151. {
  152. :execute => 'sendkey',
  153. :value => [:arrow_down,:enter]
  154. },
  155. {
  156. :execute => 'wait',
  157. :value => 1,
  158. },
  159. {
  160. :execute => 'match',
  161. :css => '.active input[name="customer_id"]',
  162. :value => '^\d+$',
  163. :no_quote => true,
  164. :match_result => true,
  165. },
  166. {
  167. :execute => 'match',
  168. :css => '.active input[name="customer_id_completion"]',
  169. :value => firstname,
  170. :no_quote => true,
  171. :match_result => true,
  172. },
  173. {
  174. :execute => 'match',
  175. :css => '.active input[name="customer_id_completion"]',
  176. :value => lastname,
  177. :no_quote => true,
  178. :match_result => true,
  179. },
  180. {
  181. :execute => 'match',
  182. :css => '.active input[name="customer_id_completion"]',
  183. :value => fullname,
  184. :no_quote => true,
  185. :match_result => true,
  186. },
  187. ],
  188. },
  189. ]
  190. browser_signle_test_with_login(tests, { :username => 'agent1@example.com' })
  191. end
  192. end