search_spec.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Knowledge Base Locale Search', type: :system do
  4. include_context 'basic Knowledge Base'
  5. let!(:answer_for_search) { create(:knowledge_base_answer, category: category, translation_attributes: { title: 'A example title' }) }
  6. context 'when search query is directly used inside the url' do
  7. let(:search_query) { nil }
  8. before do
  9. visit "#knowledge_base/#{knowledge_base.id}/locale/#{primary_locale.system_locale.locale}/search/#{search_query}"
  10. end
  11. shared_examples 'check search result' do
  12. it 'answer exists in search result' do
  13. within :active_content do
  14. expect(page).to have_css('.knowledge-base-main .section', text: answer_for_search.translations.first.title)
  15. end
  16. end
  17. end
  18. context 'when search query is a single word' do
  19. let(:search_query) { 'Example' }
  20. include_examples 'check search result'
  21. end
  22. context 'when search query has encoded characters' do
  23. let(:search_query) { 'A%20Example' }
  24. include_examples 'check search result'
  25. end
  26. end
  27. end