Fixes #3873 - Search is not triggered/updated if url of search is updated new search item or new search is triggered via global search.

This commit is contained in:
Rolf Schmidt 2021-12-08 09:44:22 +00:00
parent 3a76defc83
commit 41d72e92e9
2 changed files with 63 additions and 8 deletions

View file

@ -56,13 +56,9 @@ class App.Search extends App.Controller
@navupdate(url: '#search', type: 'menu')
return if _.isEmpty(params.query)
@$('.js-search').val(params.query).trigger('change')
return if @shown
@search(1000, true)
@$('.js-search').val(params.query).trigger('keyup')
hide: ->
@shown = false
if @table
@table.hide()
@ -108,6 +104,7 @@ class App.Search extends App.Controller
return
# on other keys, show result
@navigate "#search/#{encodeURIComponent(@searchInput.val())}"
@search(0)
empty: =>

View file

@ -9,7 +9,7 @@ RSpec.describe 'Search', type: :system, authenticated: true, searchindex: true d
let(:note) { 'Test note' }
before do
configure_elasticsearch(required: true, rebuild: true)
ticket_1 && ticket_2 && configure_elasticsearch(required: true, rebuild: true)
end
it 'shows default widgets' do
@ -24,8 +24,6 @@ RSpec.describe 'Search', type: :system, authenticated: true, searchindex: true d
context 'with ticket search result' do
before do
ticket_1 && ticket_2 && rebuild_searchindex
fill_in id: 'global-search', with: 'Testing'
click_on 'Show Search Details'
@ -176,4 +174,64 @@ RSpec.describe 'Search', type: :system, authenticated: true, searchindex: true d
expect(page).to have_css('.popover-title .is-inactive', count: 1)
end
end
describe 'Search is not triggered/updated if url of search is updated new search item or new search is triggered via global search #3873' do
context 'when search changed via input box' do
before do
visit '#search'
end
it 'does switch search results properly' do
page.find('.js-search').fill_in(with: '"Testing Ticket 1"', fill_options: { clear: :backspace })
expect(page.find('.js-tableBody')).to have_text('Testing Ticket 1')
expect(page.find('.js-tableBody')).to have_no_text('Testing Ticket 2')
expect(current_url).to include('Testing%20Ticket%201')
# switch by global search
page.find('.js-search').fill_in(with: '"Testing Ticket 2"', fill_options: { clear: :backspace })
expect(page.find('.js-tableBody')).to have_text('Testing Ticket 2')
expect(page.find('.js-tableBody')).to have_no_text('Testing Ticket 1')
expect(current_url).to include('Testing%20Ticket%202')
end
end
context 'when search changed via global search' do
before do
fill_in id: 'global-search', with: '"Testing Ticket 1"'
click_on 'Show Search Details'
end
it 'does switch search results properly' do
expect(page.find('.js-tableBody')).to have_text('Testing Ticket 1')
expect(page.find('.js-tableBody')).to have_no_text('Testing Ticket 2')
expect(current_url).to include('Testing%20Ticket%201')
# switch by global search
fill_in id: 'global-search', with: '"Testing Ticket 2"'
click_on 'Show Search Details'
expect(page.find('.js-tableBody')).to have_text('Testing Ticket 2')
expect(page.find('.js-tableBody')).to have_no_text('Testing Ticket 1')
expect(current_url).to include('Testing%20Ticket%202')
end
end
context 'when search is changed via url' do
before do
visit '#search/"Testing Ticket 1"'
end
it 'does switch search results properly' do
expect(page.find('.js-tableBody')).to have_text('Testing Ticket 1')
expect(page.find('.js-tableBody')).to have_no_text('Testing Ticket 2')
expect(current_url).to include('Testing%20Ticket%201')
# switch by url
visit '#search/"Testing Ticket 2"'
expect(page.find('.js-tableBody')).to have_text('Testing Ticket 2')
expect(page.find('.js-tableBody')).to have_no_text('Testing Ticket 1')
expect(current_url).to include('Testing%20Ticket%202')
end
end
end
end