Commit a8445cc2 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'fix-flakey-user-assignee-autocomplete-dropdown-specs' into 'master'

Fix flakey time-sensitive user/assignee autocomplete dropdown

See merge request gitlab-org/gitlab-ce!19799
parents 6ce86d85 9201e42a
...@@ -31,7 +31,7 @@ describe 'Dropdown assignee', :js do ...@@ -31,7 +31,7 @@ describe 'Dropdown assignee', :js do
describe 'behavior' do describe 'behavior' do
it 'opens when the search bar has assignee:' do it 'opens when the search bar has assignee:' do
filtered_search.set('assignee:') input_filtered_search('assignee:', submit: false, extra_space: false)
expect(page).to have_css(js_dropdown_assignee, visible: true) expect(page).to have_css(js_dropdown_assignee, visible: true)
end end
...@@ -44,6 +44,7 @@ describe 'Dropdown assignee', :js do ...@@ -44,6 +44,7 @@ describe 'Dropdown assignee', :js do
it 'should show loading indicator when opened' do it 'should show loading indicator when opened' do
slow_requests do slow_requests do
# We aren't using `input_filtered_search` because we want to see the loading indicator
filtered_search.set('assignee:') filtered_search.set('assignee:')
expect(page).to have_css('#js-dropdown-assignee .filter-dropdown-loading', visible: true) expect(page).to have_css('#js-dropdown-assignee .filter-dropdown-loading', visible: true)
...@@ -51,19 +52,19 @@ describe 'Dropdown assignee', :js do ...@@ -51,19 +52,19 @@ describe 'Dropdown assignee', :js do
end end
it 'should hide loading indicator when loaded' do it 'should hide loading indicator when loaded' do
filtered_search.set('assignee:') input_filtered_search('assignee:', submit: false, extra_space: false)
expect(find(js_dropdown_assignee)).not_to have_css('.filter-dropdown-loading') expect(find(js_dropdown_assignee)).not_to have_css('.filter-dropdown-loading')
end end
it 'should load all the assignees when opened' do it 'should load all the assignees when opened' do
filtered_search.set('assignee:') input_filtered_search('assignee:', submit: false, extra_space: false)
expect(dropdown_assignee_size).to eq(4) expect(dropdown_assignee_size).to eq(4)
end end
it 'shows current user at top of dropdown' do it 'shows current user at top of dropdown' do
filtered_search.set('assignee:') input_filtered_search('assignee:', submit: false, extra_space: false)
expect(filter_dropdown.first('.filter-dropdown-item')).to have_content(user.name) expect(filter_dropdown.first('.filter-dropdown-item')).to have_content(user.name)
end end
...@@ -71,7 +72,7 @@ describe 'Dropdown assignee', :js do ...@@ -71,7 +72,7 @@ describe 'Dropdown assignee', :js do
describe 'filtering' do describe 'filtering' do
before do before do
filtered_search.set('assignee:') input_filtered_search('assignee:', submit: false, extra_space: false)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_john.name) expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_john.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name) expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name)
...@@ -79,23 +80,21 @@ describe 'Dropdown assignee', :js do ...@@ -79,23 +80,21 @@ describe 'Dropdown assignee', :js do
end end
it 'filters by name' do it 'filters by name' do
filtered_search.send_keys('j') input_filtered_search('jac', submit: false, extra_space: false)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_john.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name) expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_no_content(user.name) expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_no_content(user.name)
end end
it 'filters by case insensitive name' do it 'filters by case insensitive name' do
filtered_search.send_keys('J') input_filtered_search('JAC', submit: false, extra_space: false)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_john.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name) expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_no_content(user.name) expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_no_content(user.name)
end end
it 'filters by username with symbol' do it 'filters by username with symbol' do
filtered_search.send_keys('@ot') input_filtered_search('@ott', submit: false, extra_space: false)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name) expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user.name) expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user.name)
...@@ -103,7 +102,7 @@ describe 'Dropdown assignee', :js do ...@@ -103,7 +102,7 @@ describe 'Dropdown assignee', :js do
end end
it 'filters by case insensitive username with symbol' do it 'filters by case insensitive username with symbol' do
filtered_search.send_keys('@OT') input_filtered_search('@OTT', submit: false, extra_space: false)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name) expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user.name) expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user.name)
...@@ -111,7 +110,9 @@ describe 'Dropdown assignee', :js do ...@@ -111,7 +110,9 @@ describe 'Dropdown assignee', :js do
end end
it 'filters by username without symbol' do it 'filters by username without symbol' do
filtered_search.send_keys('ot') input_filtered_search('ott', submit: false, extra_space: false)
wait_for_requests
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name) expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user.name) expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user.name)
...@@ -119,7 +120,9 @@ describe 'Dropdown assignee', :js do ...@@ -119,7 +120,9 @@ describe 'Dropdown assignee', :js do
end end
it 'filters by case insensitive username without symbol' do it 'filters by case insensitive username without symbol' do
filtered_search.send_keys('OT') input_filtered_search('OTT', submit: false, extra_space: false)
wait_for_requests
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name) expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user.name) expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user.name)
...@@ -129,7 +132,7 @@ describe 'Dropdown assignee', :js do ...@@ -129,7 +132,7 @@ describe 'Dropdown assignee', :js do
describe 'selecting from dropdown' do describe 'selecting from dropdown' do
before do before do
filtered_search.set('assignee:') input_filtered_search('assignee:', submit: false, extra_space: false)
end end
it 'fills in the assignee username when the assignee has not been filtered' do it 'fills in the assignee username when the assignee has not been filtered' do
...@@ -143,7 +146,7 @@ describe 'Dropdown assignee', :js do ...@@ -143,7 +146,7 @@ describe 'Dropdown assignee', :js do
end end
it 'fills in the assignee username when the assignee has been filtered' do it 'fills in the assignee username when the assignee has been filtered' do
filtered_search.send_keys('roo') input_filtered_search('roo', submit: false, extra_space: false)
click_assignee(user.name) click_assignee(user.name)
wait_for_requests wait_for_requests
...@@ -165,7 +168,7 @@ describe 'Dropdown assignee', :js do ...@@ -165,7 +168,7 @@ describe 'Dropdown assignee', :js do
describe 'selecting from dropdown without Ajax call' do describe 'selecting from dropdown without Ajax call' do
before do before do
Gitlab::Testing::RequestBlockerMiddleware.block_requests! Gitlab::Testing::RequestBlockerMiddleware.block_requests!
filtered_search.set('assignee:') input_filtered_search('assignee:', submit: false, extra_space: false)
end end
after do after do
...@@ -183,31 +186,31 @@ describe 'Dropdown assignee', :js do ...@@ -183,31 +186,31 @@ describe 'Dropdown assignee', :js do
describe 'input has existing content' do describe 'input has existing content' do
it 'opens assignee dropdown with existing search term' do it 'opens assignee dropdown with existing search term' do
filtered_search.set('searchTerm assignee:') input_filtered_search('searchTerm assignee:', submit: false, extra_space: false)
expect(page).to have_css(js_dropdown_assignee, visible: true) expect(page).to have_css(js_dropdown_assignee, visible: true)
end end
it 'opens assignee dropdown with existing author' do it 'opens assignee dropdown with existing author' do
filtered_search.set('author:@user assignee:') input_filtered_search('author:@user assignee:', submit: false, extra_space: false)
expect(page).to have_css(js_dropdown_assignee, visible: true) expect(page).to have_css(js_dropdown_assignee, visible: true)
end end
it 'opens assignee dropdown with existing label' do it 'opens assignee dropdown with existing label' do
filtered_search.set('label:~bug assignee:') input_filtered_search('label:~bug assignee:', submit: false, extra_space: false)
expect(page).to have_css(js_dropdown_assignee, visible: true) expect(page).to have_css(js_dropdown_assignee, visible: true)
end end
it 'opens assignee dropdown with existing milestone' do it 'opens assignee dropdown with existing milestone' do
filtered_search.set('milestone:%v1.0 assignee:') input_filtered_search('milestone:%v1.0 assignee:', submit: false, extra_space: false)
expect(page).to have_css(js_dropdown_assignee, visible: true) expect(page).to have_css(js_dropdown_assignee, visible: true)
end end
it 'opens assignee dropdown with existing my-reaction' do it 'opens assignee dropdown with existing my-reaction' do
filtered_search.set('my-reaction:star assignee:') input_filtered_search('my-reaction:star assignee:', submit: false, extra_space: false)
expect(page).to have_css(js_dropdown_assignee, visible: true) expect(page).to have_css(js_dropdown_assignee, visible: true)
end end
...@@ -215,8 +218,7 @@ describe 'Dropdown assignee', :js do ...@@ -215,8 +218,7 @@ describe 'Dropdown assignee', :js do
describe 'caching requests' do describe 'caching requests' do
it 'caches requests after the first load' do it 'caches requests after the first load' do
filtered_search.set('assignee') input_filtered_search('assignee:', submit: false, extra_space: false)
filtered_search.send_keys(':')
initial_size = dropdown_assignee_size initial_size = dropdown_assignee_size
expect(initial_size).to be > 0 expect(initial_size).to be > 0
...@@ -224,8 +226,7 @@ describe 'Dropdown assignee', :js do ...@@ -224,8 +226,7 @@ describe 'Dropdown assignee', :js do
new_user = create(:user) new_user = create(:user)
project.add_master(new_user) project.add_master(new_user)
find('.filtered-search-box .clear-search').click find('.filtered-search-box .clear-search').click
filtered_search.set('assignee') input_filtered_search('assignee:', submit: false, extra_space: false)
filtered_search.send_keys(':')
expect(dropdown_assignee_size).to eq(initial_size) expect(dropdown_assignee_size).to eq(initial_size)
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