navigation_spec.rb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Navigation', type: :system do
  4. before { visit '/' }
  5. context 'when mobile', screen_size: :mobile do
  6. it 'widens navigation bar on clicking button' do
  7. expect { click '.js-navigation-toggle-button' }
  8. .to change { navigation_collapsed? }
  9. .to(false)
  10. end
  11. it 'widens navigation bar on opening search' do
  12. expect { click '#global-search' }
  13. .to change { navigation_collapsed? }
  14. .to(false)
  15. end
  16. end
  17. context 'when tablet', screen_size: :tablet do
  18. it 'collapses navigation bar on clicking button' do
  19. expect { click '.js-navigation-toggle-button' }
  20. .to change { navigation_collapsed? }
  21. .to(true)
  22. end
  23. end
  24. context 'when desktop', screen_size: :desktop do
  25. it 'does not show collapse button' do
  26. expect(page).to have_no_css '.js-navigation-toggle-button'
  27. end
  28. it 'shows full navigation bar' do
  29. expect(navigation_collapsed?).to be_falsey
  30. end
  31. end
  32. def navigation_current_width
  33. evaluate_script("$('#navigation').width()")
  34. end
  35. def navigation_collapsed?
  36. navigation_current_width == 50
  37. end
  38. end