123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- require 'browser_test_helper'
- class SignupPasswordChangeAndResetTest < TestCase
- def test_signup
- signup_user_email = "signup-test-#{rand(999_999)}@example.com"
- @browser = browser_instance
- location(url: browser_url)
- click(css: 'a[href="#signup"]')
- exists(css: '.signup')
- # signup
- set(
- css: 'input[name="firstname"]',
- value: 'Signup Firstname',
- )
- set(
- css: 'input[name="lastname"]',
- value: 'Signup Lastname',
- )
- set(
- css: 'input[name="email"]',
- value: signup_user_email,
- )
- set(
- css: 'input[name="password"]',
- value: 'some-pass',
- )
- set(
- css: 'input[name="password_confirm"]',
- value: 'some-pass',
- )
- click(css: 'button.js-submit')
- watch_for_disappear(
- css: '.signup',
- timeout: 10,
- )
- match(
- css: '.user-menu .user a',
- value: signup_user_email,
- attribute: 'title',
- )
- # check email verify
- location(url: "#{browser_url}#email_verify/not_existing")
- watch_for(
- css: '#content',
- value: 'Unable to verify email',
- )
- logout()
- login(
- username: signup_user_email,
- password: 'some-pass',
- url: "#{browser_url}#email_verify/not_existing2",
- )
- watch_for(
- css: '#content',
- value: 'Unable to verify email',
- )
- execute(
- js: 'App.Event.trigger("user_signup_verify", App.Session.get())',
- )
- modal_ready()
- click(css: '.modal .js-submit')
- execute(
- js: 'App.Auth.logout()',
- )
- sleep 6
- watch_for(
- css: '#login',
- )
- login(
- username: signup_user_email,
- password: 'some-pass',
- )
- watch_for(
- css: '#content',
- value: 'Your email address has been verified',
- )
- modal_disappear()
- sleep 2
- # change password
- click(css: '.navbar-items-personal .user a')
- sleep 1
- click(css: 'a[href="#profile"]')
- click(css: 'a[href="#profile/password"]')
- set(
- css: 'input[name="password_old"]',
- value: 'nonexisiting',
- )
- set(
- css: 'input[name="password_new"]',
- value: 'some',
- )
- set(
- css: 'input[name="password_new_confirm"]',
- value: 'some',
- )
- click(css: '.content .btn--primary')
- watch_for(
- css: 'body',
- value: 'current password is wrong',
- )
- set(
- css: 'input[name="password_old"]',
- value: 'some-pass',
- )
- set(
- css: 'input[name="password_new_confirm"]',
- value: 'some2',
- )
- click(css: '.content .btn--primary')
- watch_for(
- css: 'body',
- value: 'passwords do not match',
- )
- set(
- css: 'input[name="password_new"]',
- value: 'some',
- )
- set(
- css: 'input[name="password_new_confirm"]',
- value: 'some',
- )
- click(css: '.content .btn--primary')
- watch_for(
- css: 'body',
- value: 'it must be at least',
- )
- set(
- css: 'input[name="password_new"]',
- value: 'some-pass-new',
- )
- set(
- css: 'input[name="password_new_confirm"]',
- value: 'some-pass-new',
- )
- click(css: '.content .btn--primary')
- watch_for(
- css: 'body',
- value: 'must contain at least 1 digit',
- )
- set(
- css: 'input[name="password_new"]',
- value: 'some-pass-new2',
- )
- set(
- css: 'input[name="password_new_confirm"]',
- value: 'some-pass-new2',
- )
- click(css: '.content .btn--primary')
- watch_for(
- css: 'body',
- value: 'Password changed successfully',
- )
- logout()
- # check login with new pw
- login(
- username: signup_user_email,
- password: 'some-pass-new2',
- )
- logout()
- # reset password (not possible)
- location(url: browser_url + '/#password_reset_verify/not_existing_token')
- watch_for(
- css: 'body',
- value: 'Token is invalid',
- )
- # reset password (with valid session - should not be possible)
- login(
- username: signup_user_email,
- password: 'some-pass-new2',
- url: browser_url,
- )
- location(url: browser_url + '/#password_reset')
- sleep 1
- match_not(
- css: 'body',
- value: 'password',
- )
- logout()
- # reset password (correct way)
- click(css: 'a[href="#password_reset"]')
- set(
- css: 'input[name="username"]',
- value: 'nonexisiting',
- )
- click(css: '.content .btn--primary')
- watch_for(
- css: 'body',
- value: 'address invalid',
- )
- set(
- css: 'input[name="username"]',
- value: signup_user_email,
- )
- click(css: '.content .btn--primary')
- watch_for(
- css: 'body',
- value: 'sent password reset instructions',
- )
- # redirect to "#password_reset_verify/#{token}" url by app, because of "developer_mode"
- watch_for(
- css: 'body',
- value: 'Choose your new password',
- )
- # set new password
- set(
- css: 'input[name="password"]',
- value: 'some',
- )
- set(
- css: 'input[name="password_confirm"]',
- value: 'some2',
- )
- click(css: '.content .btn--primary')
- watch_for(
- css: 'body',
- value: 'passwords do not match',
- )
- set(
- css: 'input[name="password"]',
- value: 'some',
- )
- set(
- css: 'input[name="password_confirm"]',
- value: 'some',
- )
- click(css: '.content .btn--primary')
- watch_for(
- css: 'body',
- value: 'it must be at least',
- )
- set(
- css: 'input[name="password"]',
- value: 'some-pass-new',
- )
- set(
- css: 'input[name="password_confirm"]',
- value: 'some-pass-new',
- )
- click(css: '.content .btn--primary')
- watch_for(
- css: 'body',
- value: 'must contain at least 1 digit',
- )
- set(
- css: 'input[name="password"]',
- value: 'some-pass-new2',
- )
- set(
- css: 'input[name="password_confirm"]',
- value: 'some-pass-new2',
- )
- click(css: '.content .btn--primary')
- watch_for(
- css: 'body',
- value: 'Your password has been changed',
- )
- # check if user is logged in
- sleep 5
- match(
- css: '.user-menu .user a',
- value: signup_user_email,
- attribute: 'title',
- )
- end
- end
|