Port browser tests from MobileFrontend to Minerva

This moves all browser tests from MobileFrontend to the Minerva repo
in preparation for separating the two.

Note, this means browser tests will exist in both repositories for a
period of time. This is important and necessary to ensure we do not
break anything.

See:
https://lists.wikimedia.org/pipermail/mobile-l/2017-July/010536.html

Bug: T168758
Change-Id: I84ae3ea14191f672cabcd52020e80b0a40a72ce1
This commit is contained in:
jdlrobson 2017-06-09 12:12:53 -07:00
parent b1c80e7e3e
commit c0c90234d0
72 changed files with 1892 additions and 1 deletions

1
.rubocop.yml Normal file
View File

@ -0,0 +1 @@
inherit_from: .rubocop_todo.yml

17
Rakefile Normal file
View File

@ -0,0 +1,17 @@
require 'bundler/setup'
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop) do |task|
# if you use mediawiki-vagrant, rubocop will by default use it's .rubocop.yml
# the next line makes it explicit that you want .rubocop.yml from the directory
# where `bundle exec rake` is executed
task.options = ['-c', '.rubocop.yml']
end
require 'mediawiki_selenium/rake_task'
MediawikiSelenium::RakeTask.new
task default: [:test]
desc 'Run all build/tests commands (CI entry point)'
task test: [:rubocop]

View File

@ -0,0 +1,35 @@
<?php
$wgRightsText = 'Creative Commons Attribution 3.0';
$wgRightsUrl = "http://creativecommons.org/licenses/by-sa/3.0/";
// Allow users to edit privacy link.
$wgGroupPermissions['user']['editinterface'] = true;
$wgHooks['InterwikiLoadPrefix'][] = function ( $prefix, &$iwdata ) {
if ( $prefix === 'es' ) {
// return our hardcoded interwiki info
$iwdata = [
'iw_url' => 'http://wikifoo.org/es/index.php/$1',
'iw_local' => 0,
'iw_trans' => 0,
];
return false;
}
// nothing to do, continue lookup
return true;
};
$wgInterwikiCache = false;
$wgMFEnableBeta = true;
// needed for testing whether the language button is displayed and disabled
$wgMinervaAlwaysShowLanguageButton = true;
// For those who have wikibase installed.
$wgMFUseWikibase = true;
$wgMFDisplayWikibaseDescriptions = [
'search' => true,
'nearby' => true,
'watchlist' => true,
'tagline' => true,
];

View File

@ -0,0 +1,73 @@
= Setup =
Include the LocalSettings.php in this folder into your MediaWiki LocalSettings.php.
Note including this in a production instance is not advised given it fiddles with permissions.
<pre>
include_once "$IP/extensions/MobileFrontend/tests/browser/LocalSettings.php";
</pre>
Further tweaks may be necessary to run tests that are not tagged @integration:
* Ensure you have [//www.mediawiki.org/wiki/Extension:ConfirmEdit Extension:ConfirmEdit] installed
** and setup with FancyCaptcha
* The VisualEditor, Cite, and Echo extensions should be installed to run the full suite of tests
* Create an account Selenium_newuser which has an edit count of 0
* Create an account and store the username in MEDIAWIKI_USER which has
** an edit count of greater than 0
** Ensure user has bureaucrat and admin rights (set via Special:UserRights)
= MobileFrontend Extension =
For general information about MobileFrontend Extension please see
README.mediawiki file in the root of the repository.
==== Selenium tests ====
To run the Selenium tests you will have to install Ruby (for the exact
version see Gemfile), the latest versions of RubyGems and Firefox.
The easiest way to install Ruby on *nix is RVM (https://rvm.io/) and on
Windows RubyInstaller (http://rubyinstaller.org/).
Open terminal in tests/browser. Update RubyGems and install required
gems with:
gem update --system
gem install bundler
bundle install
Environment variables MEDIAWIKI_USER and MEDIAWIKI_PASSWORD are required for
tests that require a logged in user. For local testing, create a test user on your local wiki
and export the user and password as the values for those variables.
For example:
export MEDIAWIKI_USER=<username here> # Linux/Unix/Mac
set MEDIAWIKI_USER=<username here> # Windows
export MEDIAWIKI_PASSWORD=<password here> # Linux/Unix/Mac
set MEDIAWIKI_PASSWORD=<password here> # Windows
In addition to this create another user which will be reserved for new uploads
"Selenium_newuser". The password for this user should be the same as
MEDIAWIKI_PASSWORD
Tests that use steps that create pages (create_page_api_steps.rb) need to set
the MEDIAWIKI_API_URL environment variable, e.g.
export MEDIAWIKI_API_URL=http://en.wikipedia.beta.wmflabs.org/w/api.php
Run the tests from the MobileFrontend directory with:
make cucumber
If you want to run a single set of tests, go to the tests/browser directory and
call 'bundle exec cucumber' with the path to the test file. For example, to run
only the watchlist tests:
bundle exec cucumber features/watchstar.feature
XML report (for Jenkins) is created at tests/browser/reports/junit.
Jenkins is hosted at https://wmf.ci.cloudbees.com/ and it drives
browsers at http://saucelabs.com/
For more information about running Selenium tests please see
https://github.com/wikimedia/mediawiki-selenium

9
tests/browser/ci.yml Normal file
View File

@ -0,0 +1,9 @@
BROWSER:
- chrome
- firefox
MEDIAWIKI_ENVIRONMENT:
- beta
PLATFORM:
- Linux

View File

@ -0,0 +1,45 @@
# Customize this configuration as necessary to provide defaults for various
# test environments.
#
# The set of defaults to use is determined by the MEDIAWIKI_ENVIRONMENT
# environment variable.
#
# export MEDIAWIKI_ENVIRONMENT=mw-vagrant-host
# bundle exec cucumber
#
# Additional variables set by the environment will override the corresponding
# defaults defined here.
#
# export MEDIAWIKI_ENVIRONMENT=mw-vagrant-host
# export MEDIAWIKI_USER=Selenium_user2
# bundle exec cucumber
#
mw-vagrant-host: &default
mediawiki_url: http://127.0.0.1:8080/wiki/
user_factory: true
barry:
browser: phantomjs
user_factory: false
# mediawiki_url: Will be set manually
mw-vagrant-guest:
mediawiki_url: http://127.0.0.1/wiki/
user_factory: true
beta:
mediawiki_url: https://en.m.wikipedia.beta.wmflabs.org/wiki/
mediawiki_user: Selenium_user
# mediawiki_password: SET THIS IN THE ENVIRONMENT!
test2:
mediawiki_url: https://test2.m.wikipedia.org/wiki/
mediawiki_user: Selenium_user
# mediawiki_password: SET THIS IN THE ENVIRONMENT!
integration:
browser: chrome
user_factory: true
# mediawiki_url: THIS WILL BE SET BY JENKINS
default: *default

View File

@ -1 +0,0 @@
This will be filled as part of the migration of Minerva to MobileFrontend.

View File

@ -0,0 +1,11 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org @vagrant @login
Feature: Categories
Scenario: I can view categories
Given I am in a wiki that has categories
And I am using the mobile site
And I am in beta mode
And I am on the "Selenium categories test page" page
When I click on the category button
Then I should see the categories overlay
And I should see a list of categories

View File

@ -0,0 +1,14 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org @vagrant @login
Feature: Page diff
@smoke @editing @integration
Scenario: Added and removed content
Given I am logged into the mobile website
And I am on a page that has the following edits:
| text |
| ABC DEF |
| ABC GHI |
And I click on the history link in the last modified bar
And I open the latest diff
Then I should see "GHI" as added content
And I should see "DEF" as removed content

View File

@ -0,0 +1,17 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org @vagrant @login
Feature: Wikitext Editor
Background:
Given I am logged into the mobile website
And I am on a page that does not exist
And I click the edit button
And I see the wikitext editor overlay
@smoke @integration
Scenario: Closing editor (overlay button)
When I click the wikitext editor overlay close button
Then I should not see the wikitext editor overlay
Scenario: Closing editor (browser button)
When I click the browser back button
Then I should not see the wikitext editor overlay

View File

@ -0,0 +1,52 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org @login
Feature: Wikitext Editor (Makes actual saves)
Background:
Given I am logged into the mobile website
@smoke @editing @integration
Scenario: Successful edit on page without languages shows no language button [bug 63675]
Given the page "Selenium no languages test page" exists
When I click the edit button
And I see the wikitext editor overlay
And I type "ABC GHI" into the editor
And I click continue
And I click submit
Then I should see a toast notification
And the text of the first heading should be "Selenium no languages test page"
@editing
Scenario: Successful edit reloads language button
Given I go to a page that has languages
When I click the edit button
And I see the wikitext editor overlay
And I type "ABC GHI" into the editor
And I click continue
And I click submit
And I do not see the wikitext editor overlay
Then I should see a toast notification
@editing
Scenario: Redirects
Given the page "Selenium wikitext editor test" exists
And I am on a page that does not exist
When I click the edit button
And I clear the editor
And I type "#REDIRECT [[Selenium wikitext editor test]]" into the editor
And I click continue
And I click submit
And I say OK in the confirm dialog
And I do not see the wikitext editor overlay
Then the text of the first heading should be "Selenium wikitext editor test"
@editing
Scenario: Broken redirects
Given I am on a page that does not exist
When I click the edit button
And I clear the editor
And I type "#REDIRECT [[AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA]]" into the editor
And I click continue
And I click submit
And I say OK in the confirm dialog
And I do not see the wikitext editor overlay
Then there should be a red link with text "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"

View File

@ -0,0 +1,23 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org @vagrant
Feature: Issues
Background:
Given I am using the mobile site
And I am on a page which has cleanup templates
And this page has issues
Scenario: Clicking page issues opens overlay
When I click the page issues stamp
Then I should see the issues overlay
Scenario: Closing page issues
When I click the page issues stamp
And I see the issues overlay
And I click the overlay issue close button
Then I should not see the issues overlay
Scenario: Closing page issues (browser back)
When I click the page issues stamp
And I see the issues overlay
And I click the browser back button
Then I should not see the issues overlay

View File

@ -0,0 +1,60 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org
Feature: Language selection
Background:
Given I am using the mobile site
@smoke @integration
Scenario: Language button
Given I go to a page that has languages
Then I should see the switch-language page action
@smoke @integration
Scenario: Language button (on a page that doesn't have languages)
Given I go to a page that does not have languages
Then I should see the disabled switch-language page action
Scenario: Tapping icon opens language overlay
Given I go to a page that has languages
When I click the switch-language page action
Then I should see the language overlay
Scenario: Tapping icon does not open language overlay (on a page that doesn't have languages)
Given I go to a page that does not have languages
When I click the switch-language page action
Then I should not see the languages overlay
Scenario: Tapping the disabled icon shows a toast
Given I go to a page that does not have languages
When I click the switch-language page action
Then I should see a toast with message about page not being available in other languages
Scenario: Closing language overlay (overlay button)
Given I go to a page that has languages
When I click the switch-language page action
And I see the language overlay
And I click the language overlay close button
Then I should not see the languages overlay
Scenario: Closing language overlay (browser button)
Given I go to a page that has languages
When I click the switch-language page action
And I see the language overlay
And I click the browser back button
Then I should not see the languages overlay
Scenario: Checking that there are no suggested language links
Given I go to a page that has languages
When I click the switch-language page action
And I see the language overlay
Then I should not see a suggested language link
Then I should see a non-suggested language link
@smoke
Scenario: Checking that the suggested language link has been created
Given I go to a page that has languages
And I click the switch-language page action
And I click on a language from the list of all languages
And I click the browser back button
And I see the language overlay
Then I should see a suggested language link

View File

@ -0,0 +1,22 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org @vagrant
Feature: Menus open correct page for anonymous users
Background:
Given I am using the mobile site
And I am on the "Main Page" page
@smoke @integration
Scenario: Check links in menu
When I click on the main navigation button
Then I should see a link to the disclaimer
And I should see a link to the about page
And I should see a link to "Home" in the main navigation menu
And I should see a link to "Random" in the main navigation menu
And I should see a link to "Settings" in the main navigation menu
And I should see a link to "Log in" in the main navigation menu
@extension-geodata
Scenario: Nearby link in menu
Given at least one article with geodata exists
When I click on the main navigation button
Then I should see a link to "Nearby" in the main navigation menu

View File

@ -0,0 +1,25 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org @vagrant @login
Feature: Menus open correct page for anonymous users
Background:
Given I am logged into the mobile website
And I am on the "Main Page" page
@integration
Scenario: Check links in menu
When I click on the main navigation button
Then I should see a link to the disclaimer
And I should see a link to "Log out" in the main navigation menu
And I should see a link to my user page in the main navigation menu
And I should see a link to the about page
And I should see a link to "Home" in the main navigation menu
And I should see a link to "Random" in the main navigation menu
And I should see a link to "Settings" in the main navigation menu
And I should see a link to "Contributions" in the main navigation menu
And I should see a link to "Watchlist" in the main navigation menu
@extension-geodata
Scenario: Nearby link in menu
Given at least one article with geodata exists
When I click on the main navigation button
Then I should see a link to "Nearby" in the main navigation menu

View File

@ -0,0 +1,36 @@
@custom-browser @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org
Feature: Basic site for legacy devices
Background:
Given my browser doesn't support JavaScript
And I am using the mobile site
And I am on the "Main Page" page
# FIXME: Add scenario to check search actually works
Scenario: Able to search in basic non-JavaScript site
When I click on "Random" in the main navigation menu
Then I should see the search button
# FIXME: Check that the edit button is invisible
@smoke
Scenario: Able to access left navigation in basic non-JavaScript site
When I click on "Random" in the main navigation menu
And I click on the main navigation button
Then I should see a link to "Home" in the main navigation menu
And I should see a link to "Random" in the main navigation menu
And I should see a link to "Settings" in the main navigation menu
And I should not see a link to "Watchlist" in the main navigation menu
And I should see a link to "Log in" in the main navigation menu
@extension-geodata
Scenario: Nearby link not present in main navigation menu
When I click on "Random" in the main navigation menu
And I click on the main navigation button
Then I should not see a link to "Nearby" in the main navigation menu
@smoke @integration @skip
Scenario: Search with JavaScript disabled
Given the page "Selenium search test" exists
When I type into search box "Test is used by Selenium web driver"
And I click the search button
Then I should see a list of search results

View File

@ -0,0 +1,20 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @extension-echo @firefox @test2.m.wikipedia.org @vagrant @login
Feature: Notification
Background:
Given I am logged into the mobile website
And I have no notifications
When I click on the notification icon
And the notifications overlay appears
@smoke @integration
Scenario: Opening notifications
Then I should see the notifications overlay
Scenario: Closing notifications (overlay button)
When I click the notifications overlay close button
Then after 1 seconds I should not see the notifications overlay
Scenario: Closing notifications (browser button)
When I click the browser back button
Then after 1 seconds I should not see the notifications overlay

View File

@ -0,0 +1,15 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org @vagrant
Feature: Page actions menu when anonymous
Background:
Given I am using the mobile site
And I am on the "Albert Einstein" page
@feature-anon-editing-support
Scenario: Receive notification message - Edit Icon
When I click the edit button
Then I see the anonymous editor warning
Scenario: Receive notification message - Watchlist Icon
When I click the watch star
Then I should see a drawer with message "Keep track of this page and all changes to it."

View File

@ -0,0 +1,10 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @adminuser
Feature: Page actions menu when anonymous
Background:
Given I am using the mobile site
And I visit a protected page
Scenario: I cannot edit a protected page when anonymous
When I click the edit icon holder
Then I should see a toast notification

View File

@ -0,0 +1,22 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org @vagrant @extension-cite
Feature: Reference popup drawer
Background:
Given I am using the mobile site
Scenario: Opening the reference drawer
Given I go to a page that has references
When I click on a reference
Then I should see the reference drawer
Scenario: Closing the reference drawer
Given I go to a page that has references
When I click on a reference
And I click on the page
Then I should not see the reference drawer
Scenario: Opening a nested reference
Given I go to a page that has references
When I click on a reference
And I click on a nested reference
Then I should see a drawer with message "This is a nested ref."

View File

@ -0,0 +1,50 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @integration @test2.m.wikipedia.org @vagrant
Feature: Search
Background:
Given I am using the mobile site
And I am in beta mode
And the page "Selenium search test" exists
And I am on the "Main Page" page
And I am viewing the site in mobile mode
And I click the search icon
And I see the search overlay
Scenario: Closing search (overlay button)
When I click the search overlay close button
Then I should not see the search overlay
Scenario: Closing search (browser button)
When I click the browser back button
Then I should not see the search overlay
@smoke @integration
Scenario: Search for partial text
When I type into search box "Selenium search tes"
Then search results should contain "Selenium search test"
Scenario: Search with search in pages button
When I type into search box "Test is used by Selenium web driver"
And I see the search in pages button
And I click the search in pages button
Then I should see a list of search results
Scenario: Search with enter key
When I type into search box "Test is used by Selenium web driver"
And I press the enter key
Then I should see a list of search results
Scenario: Going back to the previous page
When I type into search box "Selenium search tes"
When I click a search result
When I click the browser back button
Then I should not see '#/search' in URL
@integration
Scenario: Search doesn't break after one search result
When I type into search box "Selenium search tes"
And I click a search result
And the text of the first heading should be "Selenium search test"
And I click the search icon
And I type into search box "Main Page"
Then search results should contain "Main Page"

View File

@ -0,0 +1,15 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @integration @test2.m.wikipedia.org @vagrant @login
Feature: Search
Scenario: Clicking on a watchstar toggles the watchstar
Given I am using the mobile site
And I am in beta mode
And the page "Selenium search test" exists
And I am logged into the mobile website
And I am on the "Main Page" page
And I am viewing the site in mobile mode
And I click the search icon
And I see the search overlay
And I type into search box "Selenium search tes"
When I click a search watch star
Then I should see a toast

View File

@ -0,0 +1,10 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @integration @test2.m.wikipedia.org @vagrant
Feature: Search
Scenario: Clicking search input in tablet mode
Given I am using the mobile site
And the page "Selenium search test" exists
And I am on the "Main Page" page
And I am viewing the site in tablet mode
When I click the search input field
Then I see the search overlay

View File

@ -0,0 +1,10 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @vagrant @login
Feature: Signup edit tutorial
Background:
Given I have just signed up after trying to edit as anonymous
Scenario: Signup edit tutorial shows up correctly and hides when main menu is opened
Then I should see the signup edit tutorial
When I click on the main navigation button
Then I should not see the signup edit tutorial

View File

@ -0,0 +1,27 @@
@chrome @firefox @test2.m.wikipedia.org @vagrant @integration
Feature: Generic special page features
Background:
Given I am using the mobile site
And I am in beta mode
And I am viewing the site in mobile mode
And I am on the "Main Page" page
@login
Scenario: Search from Watchlist
Given I am logged into the mobile website
When I click on "Watchlist" in the main navigation menu
And I click the search icon
Then I should see the search overlay
@en.m.wikipedia.beta.wmflabs.org @extension-geodata
Scenario: Search from Nearby
When I click on "Nearby" in the main navigation menu
And I click the search icon
Then I should see the search overlay
@en.m.wikipedia.beta.wmflabs.org
Scenario: Search from Login
When I click on "Log in" in the main navigation menu
And I click the search icon
Then I should see the search overlay

View File

@ -0,0 +1,18 @@
When(/^I click on the category button$/) do
on(ArticlePage) do |page|
page.wait_until_rl_module_ready('skins.minerva.categories')
page.category_element.when_present.click
end
end
Then(/^I should see the categories overlay$/) do
on(ArticlePage) do |page|
expect(page.overlay_heading_element.when_present.text).to match 'Categories'
end
end
Then(/^I should see a list of categories$/) do
on(ArticlePage) do |page|
expect(page.overlay_category_topic_item_element.when_present).to be_visible
end
end

View File

@ -0,0 +1,52 @@
Given(/^I click continue$/) do
on(ArticlePage).continue_button_element.when_present.click
end
Given(/^I click submit$/) do
on(ArticlePage) do |page|
page.spinner_loading_element.when_not_present
page.submit_button_element.when_present.click
end
end
When(/^I click on the history link in the last modified bar$/) do
on(ArticlePage).last_modified_bar_history_link_element.when_present.click
expect(on(SpecialHistoryPage).side_list_element.when_present(10)).to be_visible
end
When(/^I click on the page$/) do
on(ArticlePage).content_wrapper_element.click
end
When(/^I click the unwatch star$/) do
on(ArticlePage).unwatch_star_element.when_present.click
end
When(/^I click the watch star$/) do
on(ArticlePage).watch_star_element.when_present.click
end
Then(/^I should see a toast notification$/) do
expect(on(ArticlePage).toast_element.when_present(10)).to be_visible
end
Then /^I should see a drawer with message "(.+)"$/ do |text|
expect(on(ArticlePage).drawer_element.when_present.text).to match text
end
Then(/^the text of the first heading should be "(.*)"$/) do |title|
on(ArticlePage) do |page|
page.wait_until do
page.first_heading_element.when_present.text.include? title
end
expect(page.first_heading_element.when_present.text).to match title
end
end
Then /^the watch star should be selected$/ do
expect(on(ArticlePage).unwatch_star_element).to be_visible
end
Then /^the watch star should not be selected$/ do
expect(on(ArticlePage).watch_star_element).to be_visible
end

View File

@ -0,0 +1,86 @@
Given /^I am in beta mode$/ do
visit(MainPage) do |page|
page_uri = URI.parse(page.page_url_value)
# A domain is explicitly given to avoid a bug in earlier versions of Chrome
domain = page_uri.host == 'localhost' ? nil : page_uri.host
# FIXME: remove 'mf_useformat' cookie from here
browser.cookies.add 'mf_useformat', 'true', domain: domain
browser.cookies.add 'optin', 'beta', domain: domain
page.refresh
end
end
Given(/^I am logged in as a user with a > (\d+) edit count$/) do |count|
api.meta(:userinfo, uiprop: 'editcount').data['editcount'].upto(count.to_i) do |n|
api.create_page("Ensure #{user} edit count - #{n + 1}", 'foo')
end
log_in
end
Given(/^I am logged into the mobile website$/) do
step 'I am using the mobile site'
log_in
# avoids login failing (see https://phabricator.wikimedia.org/T109593)
expect(on(ArticlePage).is_authenticated_element.when_present(20)).to exist
end
Given(/^I am on a page that does not exist$/) do
name = 'NewPage' + Time.now.to_i.to_s
visit(ArticlePage, using_params: { article_name: name })
end
Given(/^I am on the "(.+)" page$/) do |article|
# Ensure we do not cause a redirect
article = article.gsub(/ /, '_')
visit(ArticlePage, using_params: { article_name: article })
end
Given(/^I am using the mobile site$/) do
visit(MainPage) do |page|
page_uri = URI.parse(page.page_url_value)
domain = page_uri.host == 'localhost' ? nil : page_uri.host
browser.cookies.add 'mf_useformat', 'true', domain: domain
page.refresh
end
end
Given(/^I am viewing the site in mobile mode$/) do
browser.window.resize_to(320, 480)
end
Given(/^I am viewing the site in tablet mode$/) do
# Use numbers significantly larger than tablet threshold to account for browser chrome
browser.window.resize_to(1280, 1024)
end
Given(/^my browser doesn't support JavaScript$/) do
browser_factory.override(browser_user_agent: 'Opera/9.80 (J2ME/MIDP; Opera Mini/9.80 (S60; SymbOS; Opera Mobi/23.348; U; en) Presto/2.5.25 Version/10.54')
end
Given(/^the "(.*?)" page is protected\.$/) do |page|
api.protect_page(page, 'MobileFrontend Selenium test protected this page')
end
When(/^I click the browser back button$/) do
on(ArticlePage).back
end
When(/^I say OK in the confirm dialog$/) do
on(ArticlePage).confirm(true) do
end
end
When(/^I visit the page "(.*?)" with hash "(.*?)"$/) do |article, hash|
# Ensure we do not cause a redirect
article = article.gsub(/ /, '_')
visit(ArticlePage, using_params: { article_name: article, hash: hash })
end
Then(/^there should be a red link with text "(.+)"$/) do |text|
# FIXME: Switch to link_element when red links move to stable
expect(on(ArticlePage).content_wrapper_element.link_element(text: text).when_present(10)).to be_visible
end

View File

@ -0,0 +1,102 @@
# export MEDIAWIKI_API_URL = http://en.wikipedia.beta.wmflabs.org/w/api.php
Given(/^I go to a page that has references$/) do
wikitext = "MobileFrontend is a MediaWiki extension.
{{#tag:ref|This is a note.<ref>This is a nested ref.</ref>|group=note}}
==Notes==
<references group=note />
==References==
<references/>
"
api.create_page 'Selenium References test page', wikitext
step 'I am on the "Selenium References test page" page'
end
Given(/^I go to a page that has sections$/) do
wikitext = "==Section 1==
Hello world
== Section 2 ==
Section 2.
=== Section 2A ===
Section 2A.
== Section 3 ==
Section 3.
"
api.create_page 'Selenium section test page2', wikitext
step 'I am on the "Selenium section test page2" page'
end
Given(/^I am on a page which has cleanup templates$/) do
wikitext = <<-END.gsub(/^ */, '')
This page is used by Selenium to test MediaWiki functionality.
<table class="metadata plainlinks ambox ambox-content ambox-Refimprove" role="presentation">
<tr>
<td class="mbox-image">[[File:Question_book-new.svg|thumb]]</td>
<td class="mbox-text">
<span class="mbox-text-span">This article \'\'\'needs additional citations for [[Wikipedia:Verifiability|verification]]\'\'\'. <span class="hide-when-compact">Please help [[Selenium page issues test page#editor/0|improve this article]] by [[Help:Introduction_to_referencing/1|adding citations to reliable sources]]. Unsourced material may be challenged and removed.</span> <small><i>(October 2012)</i></small></span>
</td>
</tr>
</table>
END
api.create_page 'Selenium page issues test page', wikitext
step 'I am on the "Selenium page issues test page" page'
end
Given(/^the page "(.*?)" exists$/) do |title|
api.create_page title, 'Test is used by Selenium web driver'
step 'I am on the "' + title + '" page'
end
Given(/^at least one article with geodata exists$/) do
api.create_page 'Selenium geo test page', <<-end
This page is used by Selenium to test geo related features.
{{#coordinates:43|-75|primary}}
end
end
Given(/^I am in a wiki that has categories$/) do
msg = 'This page is used by Selenium to test category related features.'
wikitext = msg + '
[[Category:Test category]]
[[Category:Selenium artifacts]]
[[Category:Selenium hidden category]]'
api.create_page 'Category:Selenium artifacts', msg
api.create_page 'Category:Test category', msg
api.create_page 'Category:Selenium hidden category', '__HIDDENCAT__' + msg
api.create_page 'Selenium categories test page', wikitext
end
Given(/^I go to a page that has languages$/) do
wikitext = 'This page is used by Selenium to test language related features.
[[es:Selenium language test page]]'
api.create_page 'Selenium language test page', wikitext
step 'I am on the "Selenium language test page" page'
end
Given(/^I go to a page that does not have languages$/) do
wikitext = 'This page is used by Selenium to test language related features.'
api.create_page 'Selenium language test page without languages', wikitext
step 'I am on the "Selenium language test page without languages" page'
end
Given(/^the wiki has a terms of use$/) do
api.create_page 'MediaWiki:mobile-frontend-terms-url', 'http://m.wikimediafoundation.org/wiki/Terms_of_Use'
api.create_page 'MediaWiki:mobile-frontend-terms-text', 'Terms of use'
# force a visit to check its existence
visit(ArticlePage, using_params: { article_name: 'MediaWiki:Mobile-frontend-terms-url?action=info' })
end
Given(/^I visit a protected page$/) do
api.create_page 'Selenium protected test 2', 'Test is used by Selenium web driver'
step 'the "Selenium protected test 2" page is protected.'
step 'I am on the "Selenium protected test 2" page'
end

View File

@ -0,0 +1,7 @@
Then(/^I should see "(.*?)" as added content$/) do |text|
expect(on(DiffPage).inserted_content_element.text).to eq text
end
Then(/^I should see "(.*?)" as removed content$/) do |text|
expect(on(DiffPage).deleted_content_element.text).to eq text
end

View File

@ -0,0 +1,37 @@
Given(/^I am on a page that has the following edits:$/) do |table|
page = 'Selenium_diff_test_'.concat(@random_string)
table.rows.each { |(text)| api.edit(title: page, text: text) }
visit(ArticlePage, using_params: { article_name: page })
end
When(/^I clear the editor$/) do
on(ArticlePage).editor_textarea_element.when_present.clear
end
When(/^I click the edit button$/) do
on(ArticlePage).edit_link_element.when_present.click
end
When(/^I click the wikitext editor overlay close button$/) do
on(ArticlePage).editor_overlay_close_button_element.when_present.click
end
When(/^I do not see the wikitext editor overlay$/) do
on(ArticlePage).editor_overlay_element.when_not_visible
end
When(/^I see the wikitext editor overlay$/) do
on(ArticlePage).editor_textarea_element.when_present
end
When(/^I type "(.+)" into the editor$/) do |text|
on(ArticlePage).editor_textarea_element.when_present.send_keys(text)
end
Then(/^I should not see the wikitext editor overlay$/) do
expect(on(ArticlePage).editor_overlay_element).not_to be_visible
end
Then(/^I see the anonymous editor warning$/) do
expect(on(ArticlePage).anon_editor_warning_element.when_present).to be_visible
end

View File

@ -0,0 +1,23 @@
When(/^I click the overlay issue close button$/) do
on(ArticlePage).overlay_close_button_element.when_present.click
end
When(/^I click the page issues stamp$/) do
on(ArticlePage).issues_stamp_element.when_present.click
end
When(/^I see the issues overlay$/) do
on(ArticlePage).overlay_element.when_present
end
When(/^this page has issues$/) do
on(ArticlePage).issues_stamp_element.when_present
end
Then(/^I should not see the issues overlay$/) do
expect(on(ArticlePage).overlay_element).not_to be_visible
end
Then(/^I should see the issues overlay$/) do
expect(on(ArticlePage).overlay_element.when_present).to be_visible
end

View File

@ -0,0 +1,12 @@
When /^I click the switch-language page action$/ do
on(ArticlePage).wait_until_rl_module_ready('skins.minerva.scripts')
on(ArticlePage).switch_language_page_action_element.when_present.click
end
Then(/^I should see the disabled switch-language page action$/) do
expect(on(ArticlePage).disabled_switch_langage_page_action_element).to be_visible
end
Then(/^I should see the switch-language page action$/) do
expect(on(ArticlePage).switch_language_page_action_element).to be_visible
end

View File

@ -0,0 +1,35 @@
When(/^I click the language overlay close button$/) do
on(ArticlePage).overlay_languages_element.when_present.button_element(class: 'cancel').click
end
When(/^I see the language overlay$/) do
on(ArticlePage).overlay_languages_element.when_present
end
When /^I click on a language from the list of all languages$/ do
on(ArticlePage).non_suggested_language_link_element.when_present.click
end
Then(/^I should see a toast with message about page not being available in other languages$/) do
expect(on(ArticlePage).toast_element.when_present.text).to match 'This page is not available in other languages.'
end
Then(/^I should not see the languages overlay$/) do
expect(on(ArticlePage).overlay_languages_element).not_to be_visible
end
Then(/^I should see the language overlay$/) do
expect(on(ArticlePage).overlay_languages_element.when_present).to be_visible
end
Then(/^I should see a non-suggested language link$/) do
expect(on(ArticlePage).non_suggested_language_link_element).to be_visible
end
Then(/^I should not see a suggested language link$/) do
expect(on(ArticlePage).suggested_language_link_element).not_to be_visible
end
Then(/^I should see a suggested language link$/) do
expect(on(ArticlePage).suggested_language_link_element).to be_visible
end

View File

@ -0,0 +1,28 @@
When(/^I click on the main navigation button$/) do
on(ArticlePage).mainmenu_button_element.click
end
When(/^I click on "(.*?)" in the main navigation menu$/) do |text|
step 'I click on the main navigation button'
on(ArticlePage).navigation_element.link_element(text: text).when_visible.click
end
Then(/^I should see a link to "(.*?)" in the main navigation menu$/) do |text|
expect(on(ArticlePage).navigation_element.link_element(text: text)).to be_visible
end
Then(/^I should not see a link to "(.*?)" in the main navigation menu$/) do |text|
expect(on(ArticlePage).navigation_element.link_element(text: text)).not_to be_visible
end
Then(/^I should see a link to the about page$/) do
expect(on(ArticlePage).about_link_element).to be_visible
end
Then(/^I should see a link to the disclaimer$/) do
expect(on(ArticlePage).disclaimer_link_element).to be_visible
end
Then(/^I should see a link to my user page in the main navigation menu$/) do
expect(on(ArticlePage).navigation_element.link_element(href: /User:#{user}/, text: user_label)).to be_visible
end

View File

@ -0,0 +1,33 @@
When /^I click on the notification icon$/ do
on(ArticlePage) do |page|
page.wait_until_rl_module_ready('skins.minerva.notifications')
page.notifications_button_element.when_present.click
end
end
Given(/^I have no notifications$/) do
expect(on(ArticlePage).notifications_button_element.when_present).to be_visible
# This is somewhat hacky, but I don't want this test making use of Echo's APIs which may change
browser.execute_script("$( function () { $( '.notification-count span' ).hide(); } );")
end
When(/^I click the notifications overlay close button$/) do
sleep 1
on(ArticlePage).notifications_overlay_close_button_element.when_present.click
end
When(/^the notifications overlay appears$/) do
on(ArticlePage) do |page|
page.wait_until_rl_module_ready('oojs-ui-core')
page.notifications_overlay_element.when_present
end
end
Then(/^after (.+) seconds I should not see the notifications overlay$/) do |seconds|
sleep seconds.to_i
expect(on(ArticlePage).notifications_overlay_element).not_to be_visible
end
Then(/^I should see the notifications overlay$/) do
expect(on(ArticlePage).notifications_overlay_element.when_present).to be_visible
end

View File

@ -0,0 +1,3 @@
Given(/^I click the edit icon holder$/) do
on(ArticlePage).edit_button_holder_element.when_present.click
end

View File

@ -0,0 +1,21 @@
When(/^I click on a reference$/) do
on(ArticlePage) do |page|
page.wait_until_rl_module_ready('skins.minerva.scripts')
page.reference_element.click
page.reference_drawer_element.when_present
end
end
When(/^I click on a nested reference$/) do
on(ArticlePage) do |page|
page.nested_reference_element.when_present.click
end
end
Then(/^I should see the reference drawer$/) do
expect(on(ArticlePage).reference_drawer_element).to be_visible
end
Then(/^I should not see the reference drawer$/) do
expect(on(ArticlePage).reference_drawer_element.when_not_present).to be_nil
end

View File

@ -0,0 +1,84 @@
When(/^I click a search result$/) do
on(ArticlePage).search_result_element.when_present.click
end
When(/^I click the search icon$/) do
on(ArticlePage).wait_until_rl_module_ready('skins.minerva.scripts')
on(ArticlePage).search_icon_element.when_present.click
# this check is needed to accommodate for the hack for opening the virtual
# keyboard (see comments in search.js)
on(ArticlePage).wait_until do
on(ArticlePage).current_url.end_with? '#/search'
end
end
When(/^I click the search input field$/) do
on(ArticlePage).search_box_placeholder_element.when_present.click
end
When(/^I click the search button$/) do
on(ArticlePage).search_icon_element.when_present.click
end
When(/^I see the search in pages button$/) do
expect(on(ArticlePage).search_within_pages_element.when_visible).to be_visible
end
When(/^I click the search in pages button$/) do
on(ArticlePage).search_content_header_element.when_present.click
end
When(/^I click a search watch star$/) do
on(ArticlePage).search_watchstars_element.when_present.click
end
When(/^I press the enter key$/) do
on(ArticlePage).search_box2_element.when_present.send_keys :enter
end
When(/^I click the search overlay close button$/) do
on(ArticlePage).search_overlay_close_button_element.click
end
When(/^I see the search overlay$/) do
on(ArticlePage).search_overlay_element.when_present
end
When(/^I type into search box "(.+)"$/) do |search_term|
on(ArticlePage) do |page|
if page.search_box2_element.exists?
# Type in JavaScript mode
page.search_box2 = search_term
else
page.search_box_placeholder = search_term
end
end
end
Then(/^I should not see the search overlay$/) do
expect(on(ArticlePage).search_overlay_element).not_to be_visible
end
Then(/^I should see a list of search results$/) do
expect(on(SearchPage).list_of_results_element.when_present(10)).to be_visible
end
Then(/^I should see the search button$/) do
expect(on(ArticlePage).search_icon_element.when_present).to be_visible
end
When(/^I should see the search overlay$/) do
expect(on(ArticlePage).search_overlay_element.when_present).to be_visible
end
Then(/^search results should contain "(.+)"$/) do |text|
expect(on(ArticlePage).search_result_heading_element.when_present.text).to eq text
end
Then(/^I should not see '#\/search' in URL$/) do
expect(on(ArticlePage).current_url.end_with? '#/search').to be false
end
Then(/^I should see a toast$/) do
expect(on(ArticlePage).toast_element.when_present).to be_visible
end

View File

@ -0,0 +1,14 @@
Given(/^I have just signed up after trying to edit as anonymous$/) do
step 'I am logged into the mobile website'
api.create_page 'Selenium mobile signup edit tutorial test', 'signup edit tutorial test'
visit(ArticlePage, using_params: { article_name: 'Selenium_mobile_signup_edit_tutorial_test?article_action=signup-edit' })
on(ArticlePage).wait_until_rl_module_ready('skins.minerva.newusers')
end
Then(/^I should see the signup edit tutorial$/) do
expect(on(ArticlePage).signup_edit_tutorial_element).to be_visible
end
Then(/^I should not see the signup edit tutorial$/) do
expect(on(ArticlePage).signup_edit_tutorial_element).not_to be_visible
end

View File

@ -0,0 +1,4 @@
When(/^I open the latest diff$/) do
on(SpecialHistoryPage).last_contribution_link_element.click
expect(on(SpecialMobileDiffPage).user_info_element.when_present(20)).to be_visible
end

View File

@ -0,0 +1,44 @@
When(/^I click the talk button$/) do
on(ArticlePage) do |page|
page.wait_until_rl_module_ready('skins.minerva.talk')
page.talk_element.when_present.click
end
end
When(/^no topic is present$/) do
expect(on(ArticlePage).talk_overlay_content_header_element.when_present.text).to match 'There are no conversations about this page.'
end
When(/^I add a topic called "(.+)"$/) do |topic|
step 'I click the add discussion button'
on(ArticlePage) do |page|
page.talk_overlay_summary = topic
page.talk_overlay_wikitext_editor = 'Topic body is a really long text.'
page.wait_until { page.talk_overlay_save_button_element.enabled? }
page.talk_overlay_save_button
end
end
When(/^I click the add discussion button$/) do
on(ArticlePage).talkadd_element.when_present.click
end
Then(/^I should see the topic called "(.+)" in the list of topics$/) do |topic|
expect(on(ArticlePage).talk_overlay_first_topic_title_element.when_present.text).to match topic
end
Then(/^I should see the talk overlay$/) do
on(ArticlePage) do |page|
page.wait_until_rl_module_ready('mobile.talk.overlays')
expect(on(ArticlePage).overlay_heading_element.when_present.text).to match 'Talk'
end
end
Then(/^there should be no talk button$/) do
expect(on(ArticlePage).talk_element).not_to be_visible
end
Then(/^there should be an add discussion button$/) do
# give overlay time to fully load
expect(on(ArticlePage).talkadd_element.when_present(10)).to be_visible
end

View File

@ -0,0 +1,10 @@
Then(/^I should not see the table of contents$/) do
on(ArticlePage) do |page|
page.toc_element.when_not_visible
expect(page.toc_element).not_to be_visible
end
end
Then(/^I should see the table of contents$/) do
expect(on(ArticlePage).toc_element.when_present(10)).to be_visible
end

View File

@ -0,0 +1,18 @@
When(/^I click on the first collapsible section heading$/) do
on(ArticlePage) do |page|
page.wait_until_rl_module_ready('skins.minerva.toggling')
page.first_section_element.when_present.click
end
end
Then(/^I should not see the content of the first section$/) do
expect(on(ArticlePage).first_section_content_element).not_to be_visible
end
Then(/^I should see the content of the first section$/) do
expect(on(ArticlePage).first_section_content_element.when_present(10)).to be_visible
end
Then(/^the heading element with id "(.*?)" should be visible$/) do |id|
expect(on(ArticlePage).span_element(id: id).when_present(10)).to be_visible
end

View File

@ -0,0 +1,39 @@
Then(/^I should see a link to the privacy page$/) do
expect(on(ArticlePage).privacy_link_element).to be_visible
end
Then(/^I should see a link to the terms of use$/) do
expect(on(ArticlePage).terms_link_element).to be_visible
end
Then(/^I should see the link to the user page of the last editor$/) do
# T132753
on(ArticlePage) do |page|
page.wait_until_rl_module_ready('skins.minerva.scripts')
expect(page.last_modified_bar_history_userpage_link_element).to be_visible
end
end
Then(/^I should see the history link$/) do
expect(on(ArticlePage).standalone_edit_history_link_element).to be_visible
end
Then(/^I should see the beta mode indicator$/) do
expect(on(ArticlePage).beta_mode_indicator_element).to be_visible
end
Then(/^I should not see the beta mode indicator$/) do
expect(on(ArticlePage).beta_mode_indicator_element).not_to be_visible
end
Then(/^I should see the last modified bar history link$/) do
expect(on(ArticlePage).last_modified_bar_history_link_element).to be_visible
end
Then(/^I should see the license link$/) do
expect(on(ArticlePage).license_link_element).to be_visible
end
Then(/^I should see the switch to desktop link$/) do
expect(on(ArticlePage).desktop_link_element).to be_visible
end

View File

@ -0,0 +1,35 @@
Given(/^I visit my user page$/) do
visit(UserPage, using_params: { user: user })
end
Then(/^I should be on my user page$/) do
on(UserPage) do |page|
page.wait_until do
page.heading_element.when_present
end
expect(page.heading_element).to be_visible
end
end
Then(/^there should be a link to my contributions$/) do
expect(on(UserPage).contributions_link_element).to be_visible
end
Then(/^there should be a link to my talk page$/) do
expect(on(UserPage).talk_link_element).to be_visible
end
Then(/^there should be a link to my uploads$/) do
expect(on(UserPage).uploads_link_element).to be_visible
end
Then(/^there should be a link to create my user page$/) do
expect(on(UserPage).edit_link_element).to be_visible
end
When(/^I click the create my user page link$/) do
on(UserPage) do |page|
page.wait_until_rl_module_ready('skins.minerva.editor')
page.edit_link_element.click
end
end

View File

@ -0,0 +1,24 @@
Given(/^I am viewing a watched page$/) do
api.create_page 'Selenium mobile watch test', 'watch test'
api.watch_page 'Selenium mobile watch test'
step 'I am on the "Selenium mobile watch test" page'
end
Given(/^I am viewing an unwatched page$/) do
api.create_page 'Selenium mobile watch test', 'watch test'
api.unwatch_page 'Selenium mobile watch test'
step 'I am on the "Selenium mobile watch test" page'
end
Then(/^I should see a toast with message about watching the page$/) do
expect(on(ArticlePage).toast_element.when_present.text).to match 'Added Selenium mobile watch test to your watchlist'
end
Then(/^I should see a toast with message about unwatching the page$/) do
on(ArticlePage) do |page|
page.wait_until do
page.text.include? 'Removed' # Chrome needs this, FF does not
end
expect(page.toast_element.when_present.text).to match 'Removed Selenium mobile watch test from your watchlist'
end
end

View File

@ -0,0 +1,7 @@
Then(/^I should see a wikidata description$/) do
expect(on(ArticlePage).wikidata_description_element).to be_visible
end
Then(/^I should not see a wikidata description$/) do
expect(on(ArticlePage).wikidata_description_element).not_to be_visible
end

View File

@ -0,0 +1,3 @@
require 'mediawiki_selenium/cucumber'
require 'mediawiki_selenium/pages'
require 'mediawiki_selenium/step_definitions'

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -0,0 +1,6 @@
# Needed for cucumber --dry-run -f stepdefs
require_relative 'env'
Before('@skip') do |scenario|
scenario.skip_invoke!
end

View File

@ -0,0 +1,198 @@
class ArticlePage
include PageObject
page_url '<%=params[:article_name]%><%=params[:hash]%>'
# UI elements
a(:mainmenu_button, id: 'mw-mf-main-menu-button')
body(:is_authenticated, css: '.is-authenticated')
# pre-content
h1(:first_heading, id: 'section_0')
# standalone history link
a(:standalone_edit_history_link, css: '.last-modified-bar a')
# beta mode indicator
a(:beta_mode_indicator, css: '.branding-box sup')
# left nav
nav(:navigation, css: 'nav')
a(:about_link) { |page| page.navigation_element.link_element(text: /^About/) }
a(:disclaimer_link) { |page| page.navigation_element.link_element(text: 'Disclaimers') }
# last modified bar
a(:last_modified_bar_history_link, href: /Special:History/)
a(:last_modified_bar_history_userpage_link, href: /User:/)
# page actions
## edit
li(:edit_button_holder, id: 'ca-edit')
a(:edit_button) do |page|
page.edit_button_holder_element.link_element(class: 'edit-page')
end
li(:upload_page_action, id: 'ca-upload')
div(:signup_edit_tutorial, class: 'pointer-overlay-tutorial')
a(:edit_link, text: 'Edit')
div(:anon_editor_warning, css: '.anon-msg')
div(:editor_overlay, class: 'editor-overlay')
button(:editor_overlay_close_button) do |page|
page.editor_overlay_element.button_element(css: '.cancel')
end
## upload
li(:upload_button, id: 'ca-upload')
file_field(:select_file, name: 'file', type: 'file')
div(:photo_overlay, class: 'photo-overlay')
button(:photo_overlay_close_button) do |page|
page.photo_overlay_element.button_element(class: 'cancel')
end
text_area(:photo_description) do |page|
page.photo_overlay_element.text_area_element(name: 'description')
end
a(:tutorial_link) do |page|
page.upload_button_element.link_element(href: '#/upload-tutorial/article')
end
## watch star
button(:watch_star, text: 'Watch this page')
button(:unwatch_star, text: 'Stop watching')
button(:watch_confirm, class: 'mw-htmlform-submit')
# search
button(:search_icon, css: '#searchIcon')
p(:search_within_pages, css: '.without-results')
div(:search_content_header, css: '.search-content')
text_field(:search_box_placeholder, name: 'search', index: 0)
text_field(:search_box2, name: 'search', index: 1)
li(:search_results, css: '.search-overlay .page-list li')
div(:search_watchstars, css: '.search-overlay .page-list li .watch-this-article')
div(:search_overlay, class: 'search-overlay')
button(:search_overlay_close_button) do |page|
page.search_overlay_element.button_element(class: 'cancel')
end
ul(:search_overlay_page_list) do |page|
page.search_overlay_element.element.ul(class: 'page-list thumbs actionable')
end
a(:search_result) do |page|
page.search_overlay_page_list_element.element.a
end
h3(:search_result_heading) do |page|
page.search_overlay_page_list_element.element.h3
end
a(:notifications_button, css: '.user-button')
div(:notifications_overlay, class: 'notifications-overlay')
button(:notifications_overlay_close_button) do |page|
page.notifications_overlay_element.button_element(class: 'cancel')
end
h2(:progress_header, class: 'uploading')
a(:image_link, class: 'image')
# page-actions
ul(:page_actions, id: 'page-actions')
a(:talk, css: '.talk')
a(:category, css: '.category-button')
a(:nearby_button, css: '#page-secondary-actions .nearby')
# wikidata descriptions
div(:wikidata_description, css: '.tagline')
# toc
div(:toc, css: '.toc-mobile')
# editor (common)
span(:overlay_editor_mode_switcher, css: '.editor-switcher .oo-ui-indicatorElement-indicator')
span(:source_editor_button, css: '.source-editor .oo-ui-icon-edit-source')
span(:visual_editor_button, css: '.visual-editor .oo-ui-icon-edit-ve')
# editor
textarea(:editor_textarea, class: 'wikitext-editor')
button(:escape_button, class: 'mw-ui-icon-back')
button(:continue_button, class: 'continue')
button(:submit_button, class: 'submit')
# drawer
div(:drawer, css: '.drawer.visible')
# overlay
div(:overlay, css: '.overlay')
button(:overlay_close_button) do |page|
page.overlay_element.button_element(class: 'cancel')
end
h2(:overlay_heading, css: '.overlay-title h2')
# category
li(:overlay_category_topic_item, css: '.topic-title-list li')
# visual editor
div(:overlay_ve, css: '.editor-overlay-ve')
div(:overlay_ve_header) do |page|
page.overlay_ve_element.div_element(css: '.overlay-header-container')
end
div(:overlay_ve_header_toolbar) do |page|
page.overlay_ve_header_element.div_element(css: '.oo-ui-toolbar-bar')
end
span(:overlay_ve_header_toolbar_bold_button) do |page|
page.overlay_ve_header_element.span_element(class: 'oo-ui-iconElement-icon oo-ui-icon-bold-b')
end
span(:overlay_ve_header_toolbar_italic_button) do |page|
page.overlay_ve_header_element.span_element(class: 'oo-ui-iconElement-icon oo-ui-icon-italic-i')
end
div(:editor_ve, css: '.ve-ce-documentNode')
div(:spinner_loading, class: 'spinner loading')
# toast
div(:toast, class: 'mw-notification')
# loader
div(:content_wrapper, id: 'content')
div(:content, id: 'bodyContent')
# secondary menu
## languages
a(:switch_language_page_action, css: '#page-actions .language-selector')
a(:disabled_switch_langage_page_action, css: '#page-actions .language-selector.disabled')
# Can't use generic overlay class as this will match with the LoadingOverlay that shows before loading the language overlay
div(:overlay_languages, css: '.language-overlay')
a(:non_suggested_language_link, css: '.all-languages a', index: 0)
a(:suggested_language_link, css: '.suggested-languages a', index: 0)
# footer
a(:desktop_link, text: 'Desktop')
a(:terms_link, css: '#footer-places-terms-use')
a(:license_link, css: 'footer .license a')
a(:privacy_link, text: 'Privacy')
# pagelist
ul(:page_list, css: '.page-list')
# references
a(:reference, css: 'sup.reference a')
a(:nested_reference, css: '.drawer.references sup.reference a')
a(:reference_drawer, css: '.drawer.references')
# sections
h2(:first_section, css: '.section-heading', index: 0)
div(:first_section_content, id: 'content-collapsible-block-0')
h2(:third_section, css: '.collapsible-block', index: 2)
# issues
a(:issues_stamp, css: '.mw-mf-cleanup')
# page info (action=info)
td(:edit_count, css: '#mw-pageinfo-edits td', index: 1)
# error and warning boxes
div(:warning_box, css: '.warning')
div(:error_message, css: '.error')
# talk overlay
a(:talkadd, css: '.add.continue')
p(:talk_overlay_content_header, css: '.talk-overlay .content-header')
li(:talk_overlay_first_topic_title, css: '.talk-overlay .topic-title-list li:first-child')
text_field(:talk_overlay_summary, css: '.talk-overlay .summary')
text_area(:talk_overlay_wikitext_editor, css: '.talk-overlay .wikitext-editor')
button(:talk_overlay_save_button, css: '.talk-overlay .confirm-save')
end

View File

@ -0,0 +1,7 @@
class CreateArticlePage
include PageObject
page_url '<%=params[:article_name]%>'
a(:doesnotexist_msg, text: 'Look for pages within Wikipedia that link to this title')
end

View File

@ -0,0 +1,6 @@
class DiffPage
include PageObject
element(:inserted_content, 'ins')
element(:deleted_content, 'del')
end

View File

@ -0,0 +1,7 @@
class LanguagePage
include PageObject
text_field(:search_box_placeholder, placeholder: 'Search language')
p(:number_languages, text: /This page is available in (\d+) languages/)
a(:language_search_results, lang: 'es')
end

View File

@ -0,0 +1,5 @@
class MainPage
include PageObject
page_url 'Main_Page'
end

View File

@ -0,0 +1,9 @@
class NotificationPage
include PageObject
div(:content, id: 'content')
a(:content) do |page|
page.content_element.p.a
end
# a(:return_to_main_link, text:"Return to Main Page")
end

View File

@ -0,0 +1,14 @@
class Page
include PageObject
a(:toggle_view_mobile, css: '.stopMobileRedirectToggle')
a(:toggle_view_desktop, id: 'mw-mf-display-toggle')
def toggle_mobile_view
toggle_view_mobile_element.when_present.click
end
def toggle_desktop_view
toggle_view_desktop_element.when_present.click
end
end

View File

@ -0,0 +1,35 @@
class SpecialHistoryPage < ArticlePage
include PageObject
page_url 'Special:History'
div(:content_header_bar, css: '.content-header')
a(:content_header_bar_link) do |page|
page.content_header_bar_element.link_element(index: 0)
end
ul(:side_list, css: '.side-list', index: 0)
li(:last_contribution) do |page|
page.side_list_element.list_item_element(index: 0)
end
a(:last_contribution_link) do |page|
page.last_contribution_element.link_element(index: 0)
end
h3(:last_contribution_title) do |page|
page.last_contribution_element.h3_element(index: 0)
end
p(:last_contribution_timestamp) do |page|
page.last_contribution_element.paragraph_element(index: 0, css: '.timestamp')
end
p(:last_contribution_edit_summary) do |page|
page.last_contribution_element.paragraph_element(index: 0, css: '.edit-summary')
end
p(:last_contribution_username) do |page|
page.last_contribution_element.paragraph_element(index: 0, css: '.mw-mf-user')
end
a(:more_link, css: '.more')
end
class SpecialContributionsPage < SpecialHistoryPage
page_url 'Special:Contributions/<%= params[:user] %>'
end

View File

@ -0,0 +1,5 @@
class SpecialMobileDiffPage < ArticlePage
include PageObject
div(:user_info, id: 'mw-mf-userinfo')
end

View File

@ -0,0 +1,5 @@
class SearchPage < ArticlePage
include PageObject
ul(:list_of_results, css: '.mw-search-results')
end

View File

@ -0,0 +1,22 @@
class SpecialUserLoginPage < ArticlePage
include PageObject
page_url 'Special:UserLogin'
h1(:first_heading, id: 'section_0')
button(:login, id: 'wpLoginAttempt')
text_field(:username, name: 'wpName')
text_field(:password, name: 'wpPassword')
text_field(:confirm_password, id: 'wpRetype')
a(:login_wl, class: 'button')
button(:signup_submit, id: 'wpCreateaccount')
a(:create_account_link, id: 'mw-createaccount-join')
div(:error_box, css: '#userlogin2 > .error')
span(:confirm_password_error_box, css: '#wpRetype + .error')
a(:password_reset, title: 'Special:PasswordReset')
# signup specific
text_field(:confirmation_field, id: 'wpCaptchaWord')
div(:refresh_captcha, id: 'mf-captcha-reload-container')
end

View File

@ -0,0 +1,21 @@
class UserPage < ArticlePage
include PageObject
page_url 'User:<%= params[:user] %>'
h1(:heading, css: '#section_0')
ul(:user_links, css: '.user-links')
div(:cta_holder, css: '.cta-holder')
a(:talk_link) do |page|
page.user_links_element.element.a(href: /User_talk:/)
end
a(:contributions_link) do |page|
page.user_links_element.element.a(href: /Special:Contributions\//)
end
a(:uploads_link) do |page|
page.user_links_element.element.a(href: /Special:Uploads\//)
end
a(:edit_link) do |page|
page.cta_holder_element.element.a(href: %r{#/editor/0})
end
end

Binary file not shown.

View File

@ -0,0 +1,50 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org @vagrant
Feature: Talk
Background:
Given I am using the mobile site
@smoke @integration @login
Scenario: Talk doesn't show on talk pages
Given the page "Talk:Selenium talk test" exists
And I am logged in as a user with a > 5 edit count
And I am on the "Talk:Selenium talk test" page
Then there should be no talk button
@login
Scenario: Talk on a page that does exist
Given the page "Talk:Selenium talk test" exists
And I am logged in as a user with a > 5 edit count
And the page "Selenium talk test" exists
When I click the talk button
Then I should see the talk overlay
@login
Scenario: Talk on a page that doesn't exist (bug 64268)
Given I am logged in as a user with a > 5 edit count
And I am on a page that does not exist
When I click the talk button
Then I should see the talk overlay
@smoke @integration @login
Scenario: Add discussion on talk page possible as logged in user
Given the page "Talk:Selenium talk test" exists
And I am logged in as a user with a > 5 edit count
And the page "Selenium talk test" exists
When I click the talk button
Then there should be an add discussion button
@integration
Scenario: A newly created topic appears in the list of topics immediately
Given the page "Talk:Selenium talk test" exists
And I am logged in as a user with a > 5 edit count
And the page "Selenium talk test" exists
When I click the talk button
And no topic is present
And I add a topic called "New topic"
Then I should see the topic called "New topic" in the list of topics
Scenario: Add discussion on talk page not possible as logged out user
Given the page "Talk:Selenium talk test" exists
And the page "Selenium talk test" exists
Then there should be no talk button

View File

@ -0,0 +1,17 @@
@en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org @vagrant
Feature: Table of contents
Background:
Given I am using the mobile site
#And in Firefox see bug T88288
@smoke @integration
Scenario: Don't show table of contents on mobile
Given I am viewing the site in mobile mode
When I go to a page that has sections
Then I should not see the table of contents
Scenario: Show table of contents on tablet
Given I am viewing the site in tablet mode
When I go to a page that has sections
Then I should see the table of contents

View File

@ -0,0 +1,22 @@
@en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org @vagrant
Feature: Toggling sections
Background:
Given I am using the mobile site
And I am viewing the site in mobile mode
Scenario: Respect the hash on sections
When I visit the page "Selenium section test page" with hash "#Section_2A"
Then the heading element with id "Section_2A" should be visible
@smoke @integration
Scenario: Opening a section on mobile
Given I go to a page that has sections
When I click on the first collapsible section heading
Then I should see the content of the first section
Scenario: Closing a section on mobile
Given I go to a page that has sections
And I click on the first collapsible section heading
When I click on the first collapsible section heading
Then I should not see the content of the first section

View File

@ -0,0 +1,11 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @vagrant
Feature: Toggling sections
Background:
Given I am using the mobile site
Scenario: Section open by default on tablet
Given I am viewing the site in tablet mode
And I go to a page that has sections
When I click on the first collapsible section heading
Then I should not see the content of the first section

View File

@ -0,0 +1,38 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox
Feature: Check UI components
Background:
Given I am using the mobile site
@smoke @integration
Scenario: Check existence of important UI components on the main page
Given I am on the "Main Page" page
Then I should see the history link
@smoke @integration
Scenario: Check existence of important UI components on other pages.
Given the page "Selenium UI test" exists
And I am on the "Selenium UI test" page
Then I should see the link to the user page of the last editor
And I should see the last modified bar history link
And I should see the switch to desktop link
And I should see the license link
And I should see a link to the privacy page
@smoke @integration @adminuser
Scenario: Check existence of important UI components on other pages.
Given the wiki has a terms of use
And the page "Selenium UI test" exists
And I am on the "Selenium UI test" page
Then I should see a link to the terms of use
@smoke @integration
Scenario: Check that the beta mode indicator is hidden in stable.
Given I am on the "Main Page" page
Then I should not see the beta mode indicator
@smoke @integration
Scenario: Check that the beta mode indicator is visible in beta.
Given I am on the "Main Page" page
And I am in beta mode
Then I should see the beta mode indicator

View File

@ -0,0 +1,18 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @login @test2.m.wikipedia.org @vagrant @integration @login
Feature: User:<username>
Background:
Given I am logged into the mobile website
And I visit my user page
Scenario: Check components in user page
Then I should be on my user page
And there should be a link to my talk page
And there should be a link to my contributions
And there should be a link to my uploads
Scenario: Check user page is editable
And I should be on my user page
And there should be a link to create my user page
When I click the create my user page link
Then I see the wikitext editor overlay

View File

@ -0,0 +1,17 @@
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @integration @smoke @test2.m.wikipedia.org @login @vagrant
Feature: Manage Watchlist
Background:
Given I am logged into the mobile website
Scenario: Add an article to the watchlist
Given I am viewing an unwatched page
When I click the watch star
Then I should see a toast with message about watching the page
And the watch star should be selected
Scenario: Remove an article from the watchlist
Given I am viewing a watched page
When I click the unwatch star
Then I should see a toast with message about unwatching the page
And the watch star should not be selected

View File

@ -0,0 +1,21 @@
@chrome @firefox @en.m.wikipedia.beta.wmflabs.org @vagrant
Feature: Wikidata descriptions
Background:
Given I am using the mobile site
And I am on the "Main Page" page
Scenario: Description does not appear on Main Page
Then I should not see a wikidata description
Scenario: Description appears on main namespace
When I am on the "Albert Einstein" page
Then I should see a wikidata description
Scenario: Description does not appear on non-main namespaces
Given I am on the "Talk:Contributions" page
Then I should not see a wikidata description
Scenario: Description does not appear on special pages
Given I am on the "Special:Contributions" page
Then I should not see a wikidata description