Commit 07e0b783 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'add-wait-for-requests-to-search-feature-specs' into 'master'

Add wait_for_all_requests to search feature specs

See merge request gitlab-org/gitlab!42690
parents 42f26785 7e5c1737
...@@ -30,6 +30,8 @@ RSpec.describe 'User uses header search field', :js do ...@@ -30,6 +30,8 @@ RSpec.describe 'User uses header search field', :js do
before do before do
find('#search') find('#search')
find('body').native.send_keys('s') find('body').native.send_keys('s')
wait_for_all_requests
end end
it 'shows the category search dropdown' do it 'shows the category search dropdown' do
...@@ -89,9 +91,7 @@ RSpec.describe 'User uses header search field', :js do ...@@ -89,9 +91,7 @@ RSpec.describe 'User uses header search field', :js do
context 'when entering text into the search field' do context 'when entering text into the search field' do
it 'does not display the category search dropdown' do it 'does not display the category search dropdown' do
page.within('.search-input-wrap') do fill_in_search(scope_name.first(4))
fill_in('search', with: scope_name.first(4))
end
expect(page).not_to have_selector('.dropdown-header', text: /#{scope_name}/i) expect(page).not_to have_selector('.dropdown-header', text: /#{scope_name}/i)
end end
...@@ -105,9 +105,7 @@ RSpec.describe 'User uses header search field', :js do ...@@ -105,9 +105,7 @@ RSpec.describe 'User uses header search field', :js do
end end
it 'displays search options' do it 'displays search options' do
page.within('.search-input-wrap') do fill_in_search('test')
fill_in('search', with: 'test')
end
expect(page).to have_selector(scoped_search_link('test')) expect(page).to have_selector(scoped_search_link('test'))
end end
...@@ -140,9 +138,7 @@ RSpec.describe 'User uses header search field', :js do ...@@ -140,9 +138,7 @@ RSpec.describe 'User uses header search field', :js do
end end
it 'displays search options' do it 'displays search options' do
page.within('.search-input-wrap') do fill_in_search('test')
fill_in('search', with: 'test')
end
expect(page).to have_selector(scoped_search_link('test')) expect(page).to have_selector(scoped_search_link('test'))
expect(page).to have_selector(scoped_search_link('test', group_id: group.id)) expect(page).to have_selector(scoped_search_link('test', group_id: group.id))
...@@ -157,9 +153,7 @@ RSpec.describe 'User uses header search field', :js do ...@@ -157,9 +153,7 @@ RSpec.describe 'User uses header search field', :js do
end end
it 'displays search options' do it 'displays search options' do
page.within('.search-input-wrap') do fill_in_search('test')
fill_in('search', with: 'test')
end
expect(page).to have_selector(scoped_search_link('test')) expect(page).to have_selector(scoped_search_link('test'))
expect(page).not_to have_selector(scoped_search_link('test', group_id: project.namespace_id)) expect(page).not_to have_selector(scoped_search_link('test', group_id: project.namespace_id))
...@@ -182,9 +176,7 @@ RSpec.describe 'User uses header search field', :js do ...@@ -182,9 +176,7 @@ RSpec.describe 'User uses header search field', :js do
end end
it 'displays search options' do it 'displays search options' do
page.within('.search-input-wrap') do fill_in_search('test')
fill_in('search', with: 'test')
end
expect(page).to have_selector(scoped_search_link('test')) expect(page).to have_selector(scoped_search_link('test'))
expect(page).to have_selector(scoped_search_link('test', group_id: group.id)) expect(page).to have_selector(scoped_search_link('test', group_id: group.id))
...@@ -208,9 +200,7 @@ RSpec.describe 'User uses header search field', :js do ...@@ -208,9 +200,7 @@ RSpec.describe 'User uses header search field', :js do
end end
it 'displays search options' do it 'displays search options' do
page.within('.search-input-wrap') do fill_in_search('test')
fill_in('search', with: 'test')
end
expect(page).to have_selector(scoped_search_link('test')) expect(page).to have_selector(scoped_search_link('test'))
expect(page).to have_selector(scoped_search_link('test', group_id: subgroup.id)) expect(page).to have_selector(scoped_search_link('test', group_id: subgroup.id))
......
...@@ -124,6 +124,7 @@ RSpec.configure do |config| ...@@ -124,6 +124,7 @@ RSpec.configure do |config|
config.include LoginHelpers, type: :feature config.include LoginHelpers, type: :feature
config.include SearchHelpers, type: :feature config.include SearchHelpers, type: :feature
config.include WaitHelpers, type: :feature config.include WaitHelpers, type: :feature
config.include WaitForRequests, type: :feature
config.include EmailHelpers, :mailer, type: :mailer config.include EmailHelpers, :mailer, type: :mailer
config.include Warden::Test::Helpers, type: :request config.include Warden::Test::Helpers, type: :request
config.include Gitlab::Routing, type: :routing config.include Gitlab::Routing, type: :routing
...@@ -133,7 +134,6 @@ RSpec.configure do |config| ...@@ -133,7 +134,6 @@ RSpec.configure do |config|
config.include InputHelper, :js config.include InputHelper, :js
config.include SelectionHelper, :js config.include SelectionHelper, :js
config.include InspectRequests, :js config.include InspectRequests, :js
config.include WaitForRequests, :js
config.include LiveDebugger, :js config.include LiveDebugger, :js
config.include MigrationsHelpers, :migration config.include MigrationsHelpers, :migration
config.include RedisHelpers config.include RedisHelpers
......
# frozen_string_literal: true # frozen_string_literal: true
module SearchHelpers module SearchHelpers
def fill_in_search(text)
page.within('.search-input-wrap') do
fill_in('search', with: text)
end
wait_for_all_requests
end
def submit_search(query, scope: nil) def submit_search(query, scope: nil)
page.within('.search-form, .search-page-form') do page.within('.search-form, .search-page-form') do
field = find_field('search') field = find_field('search')
...@@ -11,6 +19,8 @@ module SearchHelpers ...@@ -11,6 +19,8 @@ module SearchHelpers
else else
click_button('Search') click_button('Search')
end end
wait_for_all_requests
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment