Commit 6b662718 authored by Eric Eastwood's avatar Eric Eastwood

Use count expectation so `all` finder will wait (patience)

Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/34435

Address flakey specs
parent bba020a5
......@@ -27,9 +27,8 @@ describe 'Recent searches', :js do
input_filtered_search('foo', submit: true)
input_filtered_search('bar', submit: true)
items = all('.filtered-search-history-dropdown-item', visible: false)
items = all('.filtered-search-history-dropdown-item', visible: false, count: 2)
expect(items.count).to eq(2)
expect(items[0].text).to eq('bar')
expect(items[1].text).to eq('foo')
end
......@@ -38,9 +37,8 @@ describe 'Recent searches', :js do
visit project_issues_path(project_1, label_name: 'foo', search: 'bar')
visit project_issues_path(project_1, label_name: 'qux', search: 'garply')
items = all('.filtered-search-history-dropdown-item', visible: false)
items = all('.filtered-search-history-dropdown-item', visible: false, count: 2)
expect(items.count).to eq(2)
expect(items[0].text).to eq('label:~qux garply')
expect(items[1].text).to eq('label:~foo bar')
end
......@@ -50,9 +48,8 @@ describe 'Recent searches', :js do
visit project_issues_path(project_1, search: 'foo')
items = all('.filtered-search-history-dropdown-item', visible: false)
items = all('.filtered-search-history-dropdown-item', visible: false, count: 3)
expect(items.count).to eq(3)
expect(items[0].text).to eq('foo')
expect(items[1].text).to eq('saved1')
expect(items[2].text).to eq('saved2')
......@@ -69,9 +66,8 @@ describe 'Recent searches', :js do
input_filtered_search('more', submit: true)
input_filtered_search('things', submit: true)
items = all('.filtered-search-history-dropdown-item', visible: false)
items = all('.filtered-search-history-dropdown-item', visible: false, count: 2)
expect(items.count).to eq(2)
expect(items[0].text).to eq('things')
expect(items[1].text).to eq('more')
end
......@@ -80,7 +76,7 @@ describe 'Recent searches', :js do
set_recent_searches(project_1_local_storage_key, '["foo", "bar"]')
visit project_issues_path(project_1)
all('.filtered-search-history-dropdown-item', visible: false)[0].trigger('click')
all('.filtered-search-history-dropdown-item', visible: false, count: 2)[0].trigger('click')
wait_for_filtered_search('foo')
expect(find('.filtered-search').value.strip).to eq('foo')
......@@ -90,12 +86,10 @@ describe 'Recent searches', :js do
set_recent_searches(project_1_local_storage_key, '["foo"]')
visit project_issues_path(project_1)
items_before = all('.filtered-search-history-dropdown-item', visible: false)
expect(items_before.count).to eq(1)
all('.filtered-search-history-dropdown-item', visible: false, count: 1)
find('.filtered-search-history-clear-button', visible: false).trigger('click')
items_after = all('.filtered-search-history-dropdown-item', visible: false)
items_after = all('.filtered-search-history-dropdown-item', visible: false, count: 0)
expect(items_after.count).to eq(0)
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