shared_authentication_state_spec.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Mobile > Basic > Share authentication state between browser tabs', app: :mobile, type: :system do
  4. context 'when use logout action' do
  5. let(:agent) { create(:agent) }
  6. it 'check that all tabs have been logged out', authenticated_as: :agent do
  7. visit '/'
  8. # open new tab
  9. open_window_and_switch
  10. visit '/'
  11. logout
  12. expect_current_route 'login'
  13. # Check that cookies has no longer a expire date after logout.
  14. cookie = cookie('^_zammad.+?')
  15. expect(cookie[:expires]).to be_nil
  16. switch_to_window_index(1)
  17. expect_current_route 'login'
  18. end
  19. end
  20. context 'when use login action' do
  21. let(:agent) { create(:agent) }
  22. it 'check that all tabs have been logged in', authenticated_as: false do
  23. visit '/'
  24. # open new tab
  25. open_window_and_switch
  26. visit '/'
  27. login(
  28. username: agent.login,
  29. password: 'test',
  30. )
  31. expect_current_route '/'
  32. switch_to_window_index(1)
  33. expect_current_route '/'
  34. end
  35. end
  36. end