signup_password_change_and_reset_test.rb 6.1 KB

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