Fix recent_searches_spec.rb by clicking on buttons instead of relying on hidden elements

This commit is contained in:
Stan Hu 2017-08-23 23:57:51 -07:00
parent 1899d543a6
commit 07e95212d2

View file

@ -80,7 +80,8 @@ describe 'Recent searches', js: true 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].click
find('.filtered-search-history-dropdown-toggle-button').click
all('.filtered-search-history-dropdown-item')[0].click
wait_for_filtered_search('foo')
expect(find('.filtered-search').value.strip).to eq('foo')
@ -90,12 +91,14 @@ describe 'Recent searches', js: true 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)
find('.filtered-search-history-dropdown-toggle-button').click
items_before = all('.filtered-search-history-dropdown-item')
expect(items_before.count).to eq(1)
find('.filtered-search-history-clear-button', visible: false).click
items_after = all('.filtered-search-history-dropdown-item', visible: false)
find('.filtered-search-history-clear-button').click
find('.filtered-search-history-dropdown-toggle-button').click
items_after = all('.filtered-search-history-dropdown-item')
expect(items_after.count).to eq(0)
end