Fixes #3378 - Spaces stay URL-encoded when going back to search results on KB for agents.

This commit is contained in:
Dominik Klein 2021-09-14 15:10:49 +02:00
parent 7597d147c1
commit 37e01cab84
2 changed files with 39 additions and 1 deletions

View file

@ -14,7 +14,8 @@ class App.KnowledgeBaseSearchController extends App.Controller
return_path: @parentController.getKnowledgeBase().uiUrl(@parentController.kb_locale(), 'search') return_path: @parentController.getKnowledgeBase().uiUrl(@parentController.kb_locale(), 'search')
) )
if query = @parentController.lastParams.arguments if @parentController.lastParams.arguments
query = decodeURIComponent(@parentController.lastParams.arguments)
@searchFieldPanel.widget.startSearch(query) @searchFieldPanel.widget.startSearch(query)
@searchFieldPanel.widget.focus() @searchFieldPanel.widget.focus()

View file

@ -0,0 +1,37 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require 'rails_helper'
RSpec.describe 'Knowledge Base Locale Search', type: :system do
include_context 'basic Knowledge Base'
let!(:answer_for_search) { create(:knowledge_base_answer, category: category, translation_attributes: { title: 'A example title' }) }
context 'when search query is directly used inside the url' do
let(:search_query) { nil }
before do
visit "#knowledge_base/#{knowledge_base.id}/locale/#{locale_name}/search/#{search_query}"
end
shared_examples 'check search result' do
it 'answer exists in search result' do
within :active_content do
expect(page).to have_css('.knowledge-base-main .section', text: answer_for_search.translations.first.title)
end
end
end
context 'when search query is a single word' do
let(:search_query) { 'Example' }
include_examples 'check search result'
end
context 'when search query has encoded characters' do
let(:search_query) { 'A%20Example' }
include_examples 'check search result'
end
end
end