signup_password_change_and_reset_test.rb 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. # encoding: utf-8
  2. require 'browser_test_helper'
  3. class SignupPasswordChangeAndResetTest < TestCase
  4. def test_signup
  5. signup_user_email = 'signup-test-' + rand(999_999).to_s + '@example.com'
  6. @browser = browser_instance
  7. location( url: browser_url )
  8. click( css: 'a[href="#signup"]' )
  9. exists( css: '.signup' )
  10. # signup
  11. set(
  12. css: 'input[name="firstname"]',
  13. value: 'Signup Firstname',
  14. )
  15. set(
  16. css: 'input[name="lastname"]',
  17. value: 'Signup Lastname',
  18. )
  19. set(
  20. css: 'input[name="email"]',
  21. value: signup_user_email,
  22. )
  23. set(
  24. css: 'input[name="password"]',
  25. value: 'some-pass',
  26. )
  27. set(
  28. css: 'input[name="password_confirm"]',
  29. value: 'some-pass',
  30. )
  31. click( css: 'button.js-submit' )
  32. sleep 5
  33. exists_not( css: '.signup' )
  34. match(
  35. css: '.user-menu .user a',
  36. value: signup_user_email,
  37. attribute: 'title',
  38. )
  39. # change password
  40. click( css: '.navbar-items-personal .user a' )
  41. sleep 1
  42. click( css: 'a[href="#profile"]' )
  43. click( css: 'a[href="#profile/password"]' )
  44. set(
  45. css: 'input[name="password_old"]',
  46. value: 'nonexisiting',
  47. )
  48. set(
  49. css: 'input[name="password_new"]',
  50. value: 'some',
  51. )
  52. set(
  53. css: 'input[name="password_new_confirm"]',
  54. value: 'some',
  55. )
  56. click( css: '.content .btn--primary' )
  57. watch_for(
  58. css: 'body',
  59. value: 'current password is wrong',
  60. )
  61. set(
  62. css: 'input[name="password_old"]',
  63. value: 'some-pass',
  64. )
  65. set(
  66. css: 'input[name="password_new_confirm"]',
  67. value: 'some2',
  68. )
  69. click( css: '.content .btn--primary' )
  70. watch_for(
  71. css: 'body',
  72. value: 'passwords do not match',
  73. )
  74. set(
  75. css: 'input[name="password_new"]',
  76. value: 'some',
  77. )
  78. set(
  79. css: 'input[name="password_new_confirm"]',
  80. value: 'some',
  81. )
  82. click( css: '.content .btn--primary' )
  83. watch_for(
  84. css: 'body',
  85. value: 'it must be at least',
  86. )
  87. set(
  88. css: 'input[name="password_new"]',
  89. value: 'some-pass-new',
  90. )
  91. set(
  92. css: 'input[name="password_new_confirm"]',
  93. value: 'some-pass-new',
  94. )
  95. click( css: '.content .btn--primary' )
  96. watch_for(
  97. css: 'body',
  98. value: 'must contain at least 1 digit',
  99. )
  100. set(
  101. css: 'input[name="password_new"]',
  102. value: 'some-pass-new2',
  103. )
  104. set(
  105. css: 'input[name="password_new_confirm"]',
  106. value: 'some-pass-new2',
  107. )
  108. click( css: '.content .btn--primary' )
  109. watch_for(
  110. css: 'body',
  111. value: 'Password changed successfully',
  112. )
  113. logout()
  114. # check login with new pw
  115. login(
  116. username: signup_user_email,
  117. password: 'some-pass-new2',
  118. )
  119. logout()
  120. # reset password (not possible)
  121. location( url: browser_url + '/#password_reset_verify/not_existing_token' )
  122. watch_for(
  123. css: 'body',
  124. value: 'Token is invalid',
  125. )
  126. # reset password (with valid session - should not be possible)
  127. login(
  128. username: signup_user_email,
  129. password: 'some-pass-new2',
  130. url: browser_url,
  131. )
  132. location( url: browser_url + '/#password_reset' )
  133. sleep 1
  134. match_not(
  135. css: 'body',
  136. value: 'password',
  137. )
  138. logout()
  139. # reset password (correct way)
  140. click( css: 'a[href="#password_reset"]' )
  141. set(
  142. css: 'input[name="username"]',
  143. value: 'nonexisiting',
  144. )
  145. click( css: '.content .btn--primary' )
  146. watch_for(
  147. css: 'body',
  148. value: 'address invalid',
  149. )
  150. set(
  151. css: 'input[name="username"]',
  152. value: signup_user_email,
  153. )
  154. click( css: '.content .btn--primary' )
  155. watch_for(
  156. css: 'body',
  157. value: 'sent password reset instructions',
  158. )
  159. # redirect to "#password_reset_verify/#{token}" url by app, because of "developer_mode"
  160. watch_for(
  161. css: 'body',
  162. value: 'Choose your new password',
  163. )
  164. # set new password
  165. set(
  166. css: 'input[name="password"]',
  167. value: 'some',
  168. )
  169. set(
  170. css: 'input[name="password_confirm"]',
  171. value: 'some2',
  172. )
  173. click( css: '.content .btn--primary' )
  174. watch_for(
  175. css: 'body',
  176. value: 'passwords do not match',
  177. )
  178. set(
  179. css: 'input[name="password"]',
  180. value: 'some',
  181. )
  182. set(
  183. css: 'input[name="password_confirm"]',
  184. value: 'some',
  185. )
  186. click( css: '.content .btn--primary' )
  187. watch_for(
  188. css: 'body',
  189. value: 'it must be at least',
  190. )
  191. set(
  192. css: 'input[name="password"]',
  193. value: 'some-pass-new',
  194. )
  195. set(
  196. css: 'input[name="password_confirm"]',
  197. value: 'some-pass-new',
  198. )
  199. click( css: '.content .btn--primary' )
  200. watch_for(
  201. css: 'body',
  202. value: 'must contain at least 1 digit',
  203. )
  204. set(
  205. css: 'input[name="password"]',
  206. value: 'some-pass-new2',
  207. )
  208. set(
  209. css: 'input[name="password_confirm"]',
  210. value: 'some-pass-new2',
  211. )
  212. click( css: '.content .btn--primary' )
  213. watch_for(
  214. css: 'body',
  215. value: 'Your password has been changed',
  216. )
  217. # check if user is logged in
  218. sleep 5
  219. match(
  220. css: '.user-menu .user a',
  221. value: signup_user_email,
  222. attribute: 'title',
  223. )
  224. end
  225. end