Merge "QA: Updates to browser tests to avoid flakiness"

This commit is contained in:
jenkins-bot 2016-04-20 22:39:39 +00:00 committed by Gerrit Code Review
commit 57bc00c9ad
4 changed files with 18 additions and 4 deletions

View file

@ -5,6 +5,7 @@ Feature: Popups core
And I am logged in
And HoverCards is enabled as a beta feature
And I am on the "Popups test page" page
And the Hovercards JavaScript module has loaded
Scenario: Hover card is visible on mouse over
And I hover over the first valid link

View file

@ -5,11 +5,16 @@ class SpecialPreferencesPage
a(:beta_features_tab, css: '#preftab-betafeatures')
text_field(:hovercards_checkbox, css: '#mw-input-wppopups')
button(:submit_button, css: '#prefcontrol')
div(:notification, css: ".mw-notification")
def enable_hovercards
beta_features_tab_element.when_present.click
return unless hovercards_checkbox_element.attribute('checked').nil?
hovercards_checkbox_element.click
submit_button_element.when_present.click
# Note well that Element#wait_until_present is more semantic but is
# deprecated. Fortunately, #when_present simply wraps #wait_until_present.
notification_element.when_present
end
end
end

View file

@ -9,3 +9,11 @@ end
Then(/^HoverCards is enabled as a beta feature$/) do
visit(SpecialPreferencesPage).enable_hovercards
end
Given(/^the Hovercards JavaScript module has loaded$/) do
on(ArticlePage) do |page|
page.wait_until do
browser.execute_script("return mw.loader.getState('ext.popups.desktop') === 'ready'")
end
end
end

View file

@ -1,17 +1,17 @@
When(/^I hover over the page header$/) do
on(ArticlePage).page_header_element.hover
sleep 1 # and dwell on it for a sec to give time for the visible hover card hide itself
end
When(/^I hover over the first valid link$/) do
on(ArticlePage).first_valid_link_element.hover
sleep 1 # and dwell on it for a sec to give time for hover card to appear
end
Then(/^I should see a hover card$/) do
expect(on(ArticlePage).hovercard_element).to be_visible
expect(on(ArticlePage).hovercard_element.when_present(5)).to be_visible
end
Then(/^I should not see a hover card$/) do
# Requesting a hovercard hits API so wait time before asserting it did not show
sleep 5
expect(on(ArticlePage).hovercard_element).not_to be_visible
end