public_menu_spec.rb 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. require 'rails_helper'
  2. # https://github.com/zammad/zammad/issues/266
  3. RSpec.describe 'Admin Panel > Knowledge Base > Public Menu', type: :system, authenticated: true do
  4. include_context 'basic Knowledge Base'
  5. include_context 'Knowledge Base menu items'
  6. before do
  7. visit '/#manage/knowledge_base'
  8. find('a', text: 'Public Menu').click
  9. end
  10. context 'lists menu items' do
  11. it { expect(find_locale('Footer menu', alternative_locale).text).to include menu_item_4.title }
  12. it { expect(find_locale('Header menu', primary_locale).text).to include menu_item_1.title }
  13. it { expect(find_locale('Header menu', alternative_locale).text).not_to include menu_item_2.title }
  14. it { expect(find_locale('Header menu', primary_locale).text).to include menu_item_2.title }
  15. end
  16. context 'edit menu items' do
  17. before do
  18. find_location('Header menu').find('a', text: 'Edit').click
  19. modal_ready
  20. end
  21. it 'edit menu item' do
  22. find('input') { |elem| elem.value == menu_item_1.title }.fill_in with: 'test menu'
  23. find('button', text: 'Submit').click
  24. modal_disappear
  25. expect(find_locale('Header menu', primary_locale).text).to include 'test menu'
  26. end
  27. it 'adds menu item' do
  28. container = find(:css, '.modal-body h2', text: alternative_locale.system_locale.name).find(:xpath, '..')
  29. container.find('a', text: 'Add').click
  30. container.find('input') { |elem| elem['data-name'] == 'title' }.fill_in with: 'new item'
  31. container.find('input') { |elem| elem['data-name'] == 'url' }.fill_in with: '/new_item'
  32. find('button', text: 'Submit').click
  33. modal_disappear
  34. expect(find_locale('Header menu', alternative_locale).text).to include 'new item'
  35. end
  36. it 'deletes menu item' do
  37. find(:css, '.modal-body')
  38. .find('input') { |elem| elem.value == menu_item_1.title }
  39. .ancestor('tr')
  40. .find('.js-remove')
  41. .click
  42. find('button', text: 'Submit').click
  43. modal_disappear
  44. expect(find_locale('Header menu', alternative_locale).text).not_to include menu_item_1.title
  45. end
  46. end
  47. def find_locale(location, locale)
  48. find_location(location)
  49. .find('.label', text: /#{Regexp.escape locale.system_locale.name}/i)
  50. .ancestor('.kb-menu-preview')
  51. end
  52. def find_location(location)
  53. find('h3', text: location).ancestor('.settings-entry')
  54. end
  55. end