menu_items_spec.rb 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Public Knowledge Base menu items', type: :system, authenticated_as: false do
  4. include_context 'basic Knowledge Base'
  5. include_context 'Knowledge Base menu items'
  6. context 'menu items visibility' do
  7. before do
  8. published_answer
  9. visit help_no_locale_path
  10. end
  11. it 'shows header public link' do
  12. expect(page).to have_css('header .menu-item', text: menu_item_1.title)
  13. end
  14. it 'shows another header public link' do
  15. expect(page).to have_css('header .menu-item', text: menu_item_2.title)
  16. end
  17. it "doesn't show footer link in header" do
  18. expect(page).to have_no_css('header .menu-item', text: menu_item_3.title)
  19. end
  20. it 'shows footer public link' do
  21. expect(page).to have_css('footer .menu-item', text: menu_item_3.title)
  22. end
  23. it "doesn't show footer link of another locale" do
  24. expect(page).to have_no_css('footer .menu-item', text: menu_item_4.title)
  25. end
  26. it 'shows public links in given order' do
  27. index_1 = page.body.index menu_item_1.title
  28. index_2 = page.body.index menu_item_2.title
  29. expect(index_1).to be < index_2
  30. end
  31. end
  32. context 'menu items color' do
  33. before do
  34. knowledge_base.update! color_header_link: color
  35. visit help_no_locale_path
  36. end
  37. let(:color) { 'rgb(255, 0, 255)' }
  38. it 'applies color for header preview' do
  39. elem = all('.menu-item')[0]
  40. expect(elem).to have_computed_style :color, color
  41. end
  42. it 'does not apply color for footer preview' do
  43. elem = all('.menu-item')[2]
  44. expect(elem).not_to have_computed_style :color, color
  45. end
  46. end
  47. end