password_reset_verify_spec.rb 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Password Reset verify', type: :system, authenticated_as: false do
  4. context 'with a valid token' do
  5. let(:user) { create(:agent) }
  6. let(:token) { User.password_reset_new_token(user.email)[:token].name }
  7. before do
  8. visit "password_reset_verify/#{token}"
  9. end
  10. it 'resetting password with non matching passwords fail' do
  11. fill_in 'password', with: 'some'
  12. fill_in 'password_confirm', with: 'some2'
  13. click '.js-passwordForm .js-submit'
  14. expect(page).to have_text 'passwords do not match'
  15. end
  16. it 'resetting password with weak password fail' do
  17. fill_in 'password', with: 'some'
  18. fill_in 'password_confirm', with: 'some'
  19. click '.js-passwordForm .js-submit'
  20. expect(page).to have_text 'Invalid password'
  21. end
  22. it 'successfully resets password and logs in' do
  23. new_password = generate :password_valid
  24. fill_in 'password', with: new_password
  25. fill_in 'password_confirm', with: new_password
  26. click '.js-passwordForm .js-submit'
  27. expect(page).to have_text('Your password has been changed')
  28. .and have_selector(".user-menu .user a[title=#{user.login}")
  29. end
  30. end
  31. context 'without a valid token' do
  32. it 'error shown if opened with a not existing token' do
  33. visit 'password_reset_verify/not_existing_token'
  34. expect(page).to have_text 'Token is invalid'
  35. end
  36. end
  37. end