signup_password_change_and_reset_test.rb 6.0 KB

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