QA: Add some basic browser tests

yippee ki yay!
Tests basic functionality
1) presence of Echo button
2) behaviour of clicking Echo button

Change-Id: I6334264e1ee73a59da1e7b0c3f18a1d43b565f3a
This commit is contained in:
jdlrobson 2014-08-04 16:07:37 -07:00
parent 091d1c9b52
commit bb6eef198c
8 changed files with 90 additions and 0 deletions

8
tests/browser/Gemfile Executable file
View file

@ -0,0 +1,8 @@
#ruby=ruby-2.1.1
#ruby-gemset=MobileFrontend
source "https://rubygems.org"
gem "chunky_png"
gem "mediawiki_api"
gem "mediawiki_selenium"

View file

@ -0,0 +1,17 @@
@chrome @firefox @en.m.wikipedia.beta.wmflabs.org
Feature: Flyout
Background:
Given I am on the "Selenium Echo flyout test page" page
Scenario: Flyout button not present when anon
Then I do not see the notification flyout button
Scenario: Flyout button present
Given I am logged in
Then I see the notification flyout button
Scenario: Flyout button present
Given I am logged in
When I click the notification flyout button
Then I see the notification flyout

View file

@ -0,0 +1,11 @@
@en.m.wikipedia.beta.wmflabs.org @firefox
Feature: Flyout (nojs)
Background:
Given I am viewing the basic non-JavaScript site
And I am on the "Selenium Echo flyout test page" page
Scenario: Flyout button present
Given I am logged in
When I click the notification flyout button
Then I find myself on the "Special:Notifications" page

View file

@ -0,0 +1,19 @@
# For use in Firefox browser tests only
Given /^I am using user agent "(.+)"$/ do |user_agent|
@user_agent = user_agent
@browser = browser(test_name(@scenario), {user_agent: user_agent})
$session_id = @browser.driver.instance_variable_get(:@bridge).session_id
end
Then(/^I find myself on the "(.*?)" page$/) do |title|
on(ArticlePage, :using_params => {:article_name => title})
end
Given(/^I am viewing the basic non-JavaScript site$/) do
step 'I am using user agent "Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)"'
end
Given(/^I am on the "(.+)" page$/) do |title|
on(APIPage).create title, "Test is used by Selenium web driver"
visit(ArticlePage, :using_params => {:article_name => title})
end

View file

@ -0,0 +1,15 @@
Then(/^I do not see the notification flyout button$/) do
on(ArticlePage).flyout_link_container_element.when_not_present
end
Then(/^I see the notification flyout button$/) do
on(ArticlePage).flyout_link_container_element.when_present
end
When(/^I click the notification flyout button$/) do
on(ArticlePage).flyout_link_element.when_present.click
end
Then(/^I see the notification flyout$/) do
on(ArticlePage).flyout_element.when_present
end

View file

@ -0,0 +1,9 @@
require 'mediawiki_selenium'
if ( ENV['PAGE_WAIT_TIMEOUT'] ) then
PageObject.default_page_wait = ENV['PAGE_WAIT_TIMEOUT'].to_i
end
if ( ENV['ELEMENT_WAIT_TIMEOUT'] ) then
PageObject.default_element_wait = ENV['ELEMENT_WAIT_TIMEOUT'].to_i
end

View file

@ -0,0 +1,3 @@
# Allow running of bundle exec cucumber --dry-run -f stepdefs
require "mediawiki_selenium"
require 'page-object'

View file

@ -0,0 +1,8 @@
class ArticlePage
include PageObject
include URL
page_url URL.url("<%=params[:article_name]%><%=params[:hash]%>")
li("flyout_link_container", css: "#pt-notifications")
a("flyout_link", css: "#pt-notifications a")
div("flyout", css: ".mw-echo-overlay")
end