Merge "QA: Browser tests for Echo notifications"

This commit is contained in:
Spage 2014-08-13 21:10:34 +00:00 committed by Gerrit Code Review
commit 8755b2e8cc
5 changed files with 120 additions and 6 deletions

View file

@ -1,4 +1,4 @@
@chrome @firefox @en.m.wikipedia.beta.wmflabs.org
@chrome @en.wikipedia.beta.wmflabs.org @firefox
Feature: Flyout
Background:

View file

@ -1,4 +1,4 @@
@en.m.wikipedia.beta.wmflabs.org @firefox
@chrome @en.wikipedia.beta.wmflabs.org @firefox @login
Feature: Flyout (nojs)
Background:

View file

@ -1,8 +1,43 @@
@chrome @firefox @en.m.wikipedia.beta.wmflabs.org
@chrome @en.wikipedia.beta.wmflabs.org @firefox @login
Feature: Notification types
# Scenarios which trigger notifications
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
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
When I am on the "Selenium Echo flyout test page" page
Then I have new notifications
Scenario: Talk page message triggers talk notification
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
When I am on the "Selenium Echo flyout test page" page
Then I have new notifications
Scenario: New user gets a sign up notification
Given I am logged in as a new user
And I am on the "Selenium Echo flyout test page" page
And I am on the "Selenium Echo flyout test page" page
Then I have new notifications
Scenario: Change in user rights
# Too hard. Will do later.
Scenario: Page revert
# Too hard. Will do later.
# Scenarios which do not trigger notifications (but might be expected to)
Scenario: The @ message is not a keyword
Given I am logged in with no notifications
And another user @s me on "Talk:Echo at test"
When I am on the "Selenium Echo flyout test page" page
Then I have no new notifications

View file

@ -1,3 +1,7 @@
def get_session_username
return "#{ENV["MEDIAWIKI_USER"]}_#{@browser.name}"
end
# For use in Firefox browser tests only
Given /^I am using user agent "(.+)"$/ do |user_agent|
@user_agent = user_agent
@ -18,9 +22,24 @@ Given(/^I am on the "(.+)" page$/) do |title|
visit(ArticlePage, :using_params => {:article_name => title})
end
Given(/^the user "(.*?)" exists$/) do |username|
on(APIPage).client.log_in(ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"])
begin
on(APIPage).client.create_account(username, ENV["MEDIAWIKI_PASSWORD"])
rescue MediawikiApi::ApiError
puts 'Assuming user ' + username + ' already exists since was unable to create.'
end
end
Given(/^I am logged in as the user "(.*?)"$/) do |username|
on(APIPage).client.create_account(@username, ENV["MEDIAWIKI_PASSWORD"])
visit(LoginPage).login_with(@username, ENV["MEDIAWIKI_PASSWORD"])
step 'the user "' + username +'" exists'
visit(LoginPage).login_with(username, ENV["MEDIAWIKI_PASSWORD"])
end
# Note Echo redefines this so that the user is unique to the current browser
Given(/^I am logged in my non-shared account$/) do
username = get_session_username()
step 'I am logged in as the user "' + username + '"'
end
Given(/^I am logged in as a new user$/) do

View file

@ -1,3 +1,63 @@
def make_page_with_user( title, text, username )
client = on(APIPage).client
client.log_in(username, ENV["MEDIAWIKI_PASSWORD"])
client.create_page(title, text)
end
def make_page_with_user_b( title, text )
username = "EchoUser"
step 'the user "' + username + '" exists'
make_page_with_user( title, text, username )
end
def make_page_with_user_a( title, text )
make_page_with_user( title, text, get_session_username() )
end
Given(/^another user writes on my talk page$/) do
make_page_with_user_b("User talk:" + get_session_username(),
"== Barnstar ==\nHello Selenium, here is a barnstar for all your testing! " + @random_string + "~~~~\n")
end
Given(/^another user @s me on "(.*?)"$/) do |title|
username = get_session_username().sub( '_', ' ' )
text = "@" + username + " Cho cho cho. ~~~~"
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
end
Given(/^another user mentions me on the wiki$/) do
title = 'Selenium Echo mention test ' + @random_string
username = get_session_username().sub( '_', ' ' )
text = "== The walrus ==\n[[User:" + username + "]]: Cho cho cho. ~~~~\n"
make_page_with_user_b(title, text)
end
Given(/^I am logged in with no notifications$/) do
step 'I am logged in my non-shared account'
# wait for JavaScript to have fully loaded
sleep 5
on(ArticlePage).flyout_link_element.click
# wait for the API call that marks these as read and for UI to refresh
sleep 5
on(ArticlePage).flyout_link_element.class_name.should_not match 'mw-echo-unread-notifications'
end
Then(/^I have new notifications$/) do
on(ArticlePage).flyout_link_element.when_present.class_name.should match 'mw-echo-unread-notifications'
end
Then(/^I have no new notifications$/) do
on(ArticlePage).flyout_link_element.when_present.class_name.should_not match 'mw-echo-unread-notifications'
end
Then(/^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.")
title2 = title + ' ' + @random_string
make_page_with_user_b(title2, "I am linking to [[" + title + "]].")
end