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
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ install:
script:
- docker-compose exec web bash -c "wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
- docker-compose exec web bash -c "dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install"
- docker-compose exec web bash -c "wget https://chromedriver.storage.googleapis.com/73.0.3683.68/chromedriver_linux64.zip" # https://sites.google.com/a/chromium.org/chromedriver/
- docker-compose exec web bash -c "wget https://chromedriver.storage.googleapis.com/74.0.3729.6/chromedriver_linux64.zip" # https://sites.google.com/a/chromium.org/chromedriver/
- docker-compose exec web bash -c "unzip chromedriver_linux64.zip"
- docker-compose exec web bash -c "mv chromedriver /usr/local/bin/chromedriver"
- docker-compose exec web bash -c "chmod +x /usr/local/bin/chromedriver"
Expand Down
11 changes: 11 additions & 0 deletions test/system/search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,15 @@ 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_selector ".typeahead li", text: "Canon A1200 IR conversion at PLOTS Barnraising at LUMCON", wait: 10

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 4, page.evaluate_script("$('.typeahead.dropdown-menu').find('li').length")
end
end