QA: replace hard-coded 7 seconds sleep with poll method

The step formerly know as "I come back from grabbing a cup of coffee"
is replaced by a step that reloads the page a number of times, where
that number may be set by the user.  If the notification has arrived,
the polling stops and the test continues.

In practice with a local browser pointed to beta labs, the
notification is arriving in plenty of time for the first page load
and I do not see the page reloading at all.

Change-Id: I95dd77d4f5525645e46244e40bfcd86e9124f3b1
This commit is contained in:
Cmcmahon 2014-09-24 14:34:42 -07:00
parent de40ed7381
commit 530688aa39
2 changed files with 12 additions and 6 deletions

View file

@ -5,14 +5,14 @@ Feature: Notification types
Scenario: Someone links to a page I created
Given I am logged in with no notifications
And another user has linked to a page I created from another page
And I come back from grabbing a cup of coffee
And I reload the page 5 times or until a notification shows up
When I am on the "Selenium Echo flyout test page" page
Then I have new notifications
Scenario: Mention message triggers notification
Given I am logged in with no notifications
And another user mentions me on the wiki
And I come back from grabbing a cup of coffee
And I reload the page 5 times or until a notification shows up
When I am on the "Selenium Echo flyout test page" page
Then I have new notifications
@ -20,7 +20,7 @@ Feature: Notification types
Given I am logged in with no notifications
# And I do not have Flow boards enabled on the user talk namespace
And another user writes on my talk page
And I come back from grabbing a cup of coffee
And I reload the page 5 times or until a notification shows up
When I am on the "Selenium Echo flyout test page" page
Then I have new notifications

View file

@ -21,6 +21,13 @@ def make_page_with_user_a( title, text )
make_page_with_user( title, text, get_session_username() )
end
def poll_for_new_notifications(number_of_polls)
number_of_polls.to_i.times do
step 'I am on the "Selenium Echo flyout test page" page'
break if on(ArticlePage).flyout_link_element.class_name =~ /mw-echo-unread-notifications/
end
end
Given(/^another user has linked to a page I created from another page$/) do
title = 'Selenium Echo link test ' + @random_string
make_page_with_user_a(title, "Selenium test page. Feel free to delete me.")
@ -39,9 +46,8 @@ Given(/^another user @s me on "(.*?)"$/) do |title|
make_page_with_user_b(title, text)
end
Given(/^I come back from grabbing a cup of coffee$/) do
# Notifications can be extremely slow to trickle into beta labs so go to sleep for a bit
sleep 7
Given(/^I reload the page (.*?) times or until a notification shows up$/) do |number_of_polls|
poll_for_new_notifications(number_of_polls)
end
Given(/^another user mentions me on the wiki$/) do