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
|
|
|
|
2019-09-18 17:25:04 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2020-06-18 11:51:25 +00:00
|
|
|
RSpec.describe 'Public Knowledge Base for guest', type: :system, authenticated_as: false do
|
2019-09-18 17:25:04 +00:00
|
|
|
include_context 'basic Knowledge Base'
|
|
|
|
|
|
|
|
before do
|
2019-09-24 15:44:32 +00:00
|
|
|
published_answer && draft_answer && internal_answer
|
2019-09-18 17:25:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'homepage' do
|
|
|
|
before { visit help_no_locale_path }
|
|
|
|
|
|
|
|
it('is redirected to primary locale') { expect(page).to have_current_path help_root_path(primary_locale.system_locale.locale) }
|
|
|
|
|
2019-10-22 09:40:35 +00:00
|
|
|
it { expect(page).not_to have_breadcrumb }
|
|
|
|
it { expect(page).not_to have_editor_bar }
|
2019-09-18 17:25:04 +00:00
|
|
|
|
|
|
|
it 'shows category' do
|
|
|
|
within '.main' do
|
|
|
|
expect(page).to have_selector(:link_containing, published_answer.category.translation.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show answer' do
|
|
|
|
within '.main' do
|
2020-08-26 12:31:33 +00:00
|
|
|
expect(page).to have_no_selector(:link_containing, published_answer.translation.title)
|
2019-09-18 17:25:04 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'category' do
|
|
|
|
before { visit help_category_path(primary_locale.system_locale.locale, category) }
|
|
|
|
|
2019-10-22 09:40:35 +00:00
|
|
|
it { expect(page).to have_breadcrumb }
|
2019-09-18 17:25:04 +00:00
|
|
|
|
|
|
|
it 'shows published answer' do
|
|
|
|
within '.main' do
|
|
|
|
expect(page).to have_selector(:link_containing, published_answer.translation.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show draft answer' do
|
|
|
|
within '.main' do
|
2020-08-26 12:31:33 +00:00
|
|
|
expect(page).to have_no_selector(:link_containing, draft_answer.translation.title)
|
2019-09-18 17:25:04 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show internal answer' do
|
|
|
|
within '.main' do
|
2020-08-26 12:31:33 +00:00
|
|
|
expect(page).to have_no_selector(:link_containing, internal_answer.translation.title)
|
2019-09-18 17:25:04 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'breadcrumb' do
|
2019-10-22 09:40:35 +00:00
|
|
|
it { expect(page).to have_breadcrumb.with(2).items }
|
|
|
|
it { expect(page).to have_breadcrumb_item(knowledge_base.translation.title).at_index(0) }
|
|
|
|
it { expect(page).to have_breadcrumb_item(category.translation.title).at_index(1) }
|
2019-09-18 17:25:04 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'answer' do
|
|
|
|
before { visit help_answer_path(primary_locale.system_locale.locale, category, published_answer) }
|
|
|
|
|
|
|
|
context 'breadcrumb' do
|
2019-10-22 09:40:35 +00:00
|
|
|
it { expect(page).to have_breadcrumb.with(3).items }
|
|
|
|
it { expect(page).to have_breadcrumb_item(knowledge_base.translation.title).at_index(0) }
|
|
|
|
it { expect(page).to have_breadcrumb_item(category.translation.title).at_index(1) }
|
|
|
|
it { expect(page).to have_breadcrumb_item(published_answer.translation.title).at_index(2) }
|
2019-09-18 17:25:04 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'wrong locale' do
|
|
|
|
before { visit help_root_path(alternative_locale.system_locale.locale) }
|
|
|
|
|
2019-10-22 09:40:35 +00:00
|
|
|
it { expect(page).to have_language_banner }
|
2019-09-18 17:25:04 +00:00
|
|
|
|
|
|
|
context 'switch to correct locale after clicking on language banner' do
|
|
|
|
before do
|
|
|
|
within '.language-banner' do
|
|
|
|
click_on 'activate'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-10-22 09:40:35 +00:00
|
|
|
it { expect(page).not_to have_language_banner }
|
2019-09-18 17:25:04 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'offer in another locale' do
|
|
|
|
before do
|
|
|
|
create(:knowledge_base_translation, kb_locale: alternative_locale)
|
|
|
|
visit help_answer_path(alternative_locale.system_locale.locale, category, published_answer)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(page).to have_text(published_answer.translation_primary.title) }
|
|
|
|
it { expect(page).to have_text('only available in these languages') }
|
2020-08-26 12:31:33 +00:00
|
|
|
it { expect(page).to have_no_selector('h1', text: published_answer.translation_primary.title) }
|
2019-09-18 17:25:04 +00:00
|
|
|
|
|
|
|
context 'follow primary locale' do
|
|
|
|
before { click_on published_answer.translation_primary.title }
|
|
|
|
|
|
|
|
it { expect(page).to have_selector('h1', text: published_answer.translation_primary.title) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context '404' do
|
|
|
|
before { visit help_answer_path(primary_locale.system_locale.locale, category, 12_345) }
|
|
|
|
|
|
|
|
it { expect(page).to have_text('Page not found') }
|
|
|
|
end
|
|
|
|
end
|