2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2020-05-13 17:01:42 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
# https://github.com/zammad/zammad/issues/266
|
2021-07-22 14:03:33 +00:00
|
|
|
RSpec.describe 'Admin Panel > Knowledge Base > Public Menu', type: :system do
|
2020-05-13 17:01:42 +00:00
|
|
|
include_context 'basic Knowledge Base'
|
|
|
|
include_context 'Knowledge Base menu items'
|
|
|
|
|
|
|
|
context 'lists menu items' do
|
2021-09-27 12:28:53 +00:00
|
|
|
before do
|
|
|
|
visit '/#manage/knowledge_base'
|
|
|
|
find('a', text: 'Public Menu').click
|
|
|
|
end
|
|
|
|
|
2021-12-16 13:42:09 +00:00
|
|
|
it { expect(find_locale('Footer Menu', alternative_locale).text).to include menu_item_4.title }
|
|
|
|
it { expect(find_locale('Header Menu', primary_locale).text).to include menu_item_1.title }
|
|
|
|
it { expect(find_locale('Header Menu', alternative_locale).text).not_to include menu_item_2.title }
|
|
|
|
it { expect(find_locale('Header Menu', primary_locale).text).to include menu_item_2.title }
|
2020-05-13 17:01:42 +00:00
|
|
|
end
|
|
|
|
|
2021-09-27 12:28:53 +00:00
|
|
|
context 'menu items color' do
|
|
|
|
before do
|
|
|
|
knowledge_base.update! color_header_link: color
|
|
|
|
visit '/#manage/knowledge_base'
|
|
|
|
find('a', text: 'Public Menu').click
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:color) { 'rgb(255, 0, 255)' }
|
|
|
|
|
|
|
|
it 'applies color for header preview' do
|
|
|
|
elem = all('.kb-menu-preview a')[0]
|
|
|
|
|
|
|
|
expect(elem).to have_computed_style :color, color
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not apply color for footer preview' do
|
|
|
|
elem = all('.kb-menu-preview a')[3]
|
|
|
|
|
|
|
|
expect(elem).not_to have_computed_style :color, color
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-05-13 17:01:42 +00:00
|
|
|
context 'edit menu items' do
|
|
|
|
before do
|
2021-09-27 12:28:53 +00:00
|
|
|
visit '/#manage/knowledge_base'
|
|
|
|
find('a', text: 'Public Menu').click
|
2021-12-16 13:42:09 +00:00
|
|
|
find_location('Header Menu').find('a', text: 'Edit').click
|
2020-05-13 17:01:42 +00:00
|
|
|
|
|
|
|
modal_ready
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'edit menu item' do
|
|
|
|
find('input') { |elem| elem.value == menu_item_1.title }.fill_in with: 'test menu'
|
|
|
|
find('button', text: 'Submit').click
|
|
|
|
|
|
|
|
modal_disappear
|
|
|
|
|
2021-12-16 13:42:09 +00:00
|
|
|
expect(find_locale('Header Menu', primary_locale).text).to include 'test menu'
|
2020-05-13 17:01:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'adds menu item' do
|
|
|
|
container = find(:css, '.modal-body h2', text: alternative_locale.system_locale.name).find(:xpath, '..')
|
|
|
|
container.find('a', text: 'Add').click
|
|
|
|
|
|
|
|
container.find('input') { |elem| elem['data-name'] == 'title' }.fill_in with: 'new item'
|
|
|
|
container.find('input') { |elem| elem['data-name'] == 'url' }.fill_in with: '/new_item'
|
|
|
|
|
|
|
|
find('button', text: 'Submit').click
|
|
|
|
|
|
|
|
modal_disappear
|
|
|
|
|
2021-12-16 13:42:09 +00:00
|
|
|
expect(find_locale('Header Menu', alternative_locale).text).to include 'new item'
|
2020-05-13 17:01:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'deletes menu item' do
|
|
|
|
find(:css, '.modal-body')
|
|
|
|
.find('input') { |elem| elem.value == menu_item_1.title }
|
|
|
|
.ancestor('tr')
|
|
|
|
.find('.js-remove')
|
|
|
|
.click
|
|
|
|
|
|
|
|
find('button', text: 'Submit').click
|
|
|
|
|
|
|
|
modal_disappear
|
|
|
|
|
2021-12-16 13:42:09 +00:00
|
|
|
expect(find_locale('Header Menu', alternative_locale).text).not_to include menu_item_1.title
|
2020-05-13 17:01:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_locale(location, locale)
|
|
|
|
find_location(location)
|
2021-05-12 11:37:44 +00:00
|
|
|
.find('.label', text: %r{#{Regexp.escape locale.system_locale.name}}i)
|
2020-05-13 17:01:42 +00:00
|
|
|
.ancestor('.kb-menu-preview')
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_location(location)
|
|
|
|
find('h3', text: location).ancestor('.settings-entry')
|
|
|
|
end
|
|
|
|
end
|