Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try system test to count navbar typeahead results in dropdown #5525

Merged
merged 9 commits into from
Apr 24, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/system/search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,13 @@ class SearchTest < ApplicationSystemTestCase

assert_selector('h2', text: 'Results for Canon')
end

test 'searching using navbar autocomplete' do
visit '/'

fill_in("searchform_input", with: "Canon")

assert page.evaluate_script("$('.typeahead.dropdown-menu').is(':visible')")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like Capybara won't wait unless we ask it to look for a selector. Even then we can increase the max time:

select('Item that is being loaded', wait: 10)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also see https://www.rubydoc.info/github/jnicklas/capybara/Capybara/Node/Matchers#assert_selector-instance_method

for example: page.assert_selector('li', text: 'Horse', visible: true)

assert_equal 1, page.evaluate_script("$('.typeahead.dropdown-menu').find('li').length")
end
end