signup_password_change_and_reset_test.rb 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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: 'sent password reset instructions',
  188. )
  189. click(css: '.content .btn--primary')
  190. set(
  191. css: 'input[name="username"]',
  192. value: signup_user_email,
  193. )
  194. click(css: '.content .btn--primary')
  195. watch_for(
  196. css: 'body',
  197. value: 'sent password reset instructions',
  198. )
  199. # redirect to "#password_reset_verify/#{token}" url by app, because of "developer_mode"
  200. watch_for(
  201. css: 'body',
  202. value: 'Choose your new password',
  203. )
  204. # set new password
  205. set(
  206. css: 'input[name="password"]',
  207. value: 'some',
  208. )
  209. set(
  210. css: 'input[name="password_confirm"]',
  211. value: 'some2',
  212. )
  213. click(css: '.content .btn--primary')
  214. watch_for(
  215. css: 'body',
  216. value: 'passwords do not match',
  217. )
  218. set(
  219. css: 'input[name="password"]',
  220. value: 'some',
  221. )
  222. set(
  223. css: 'input[name="password_confirm"]',
  224. value: 'some',
  225. )
  226. click(css: '.content .btn--primary')
  227. watch_for(
  228. css: 'body',
  229. value: 'it must be at least',
  230. )
  231. set(
  232. css: 'input[name="password"]',
  233. value: 'some-pass-new',
  234. )
  235. set(
  236. css: 'input[name="password_confirm"]',
  237. value: 'some-pass-new',
  238. )
  239. click(css: '.content .btn--primary')
  240. watch_for(
  241. css: 'body',
  242. value: 'must contain at least 1 digit',
  243. )
  244. set(
  245. css: 'input[name="password"]',
  246. value: 'some-pass-new2',
  247. )
  248. set(
  249. css: 'input[name="password_confirm"]',
  250. value: 'some-pass-new2',
  251. )
  252. click(css: '.content .btn--primary')
  253. watch_for(
  254. css: 'body',
  255. value: 'Your password has been changed',
  256. )
  257. # check if user is logged in
  258. sleep 5
  259. match(
  260. css: '.user-menu .user a',
  261. value: signup_user_email,
  262. attribute: 'title',
  263. )
  264. end
  265. end