browser acceptance tests
authorcmcmahon <cmcmahon@wikimedia.org>
Thu, 15 May 2014 17:40:01 +0000 (10:40 -0700)
committerCmcmahon <cmcmahon@wikimedia.org>
Mon, 23 Jun 2014 15:03:06 +0000 (08:03 -0700)
Apropos of https://www.mediawiki.org/wiki/Wikimedia_Release_and_QA_Team/Quarterly_review,_April_2014#Action_items

Tests pass on a bare wiki install, beta enwiki, beta dewiki, beta hewiki

Bug: 66272

Ported create_account.feature and supporting files from /qa/browsertest without needing updates
Change-Id: I2b4bfa512a33ff31cc0369dfd9ec19cb875d5e36

23 files changed:
tests/.gitignore [new file with mode: 0644]
tests/browser/Gemfile [new file with mode: 0755]
tests/browser/Gemfile.lock [new file with mode: 0644]
tests/browser/README.mediawiki [new file with mode: 0644]
tests/browser/environment_variables [new file with mode: 0644]
tests/browser/features/create_account.feature [new file with mode: 0644]
tests/browser/features/create_and_follow_wiki_link.feature [new file with mode: 0644]
tests/browser/features/edit_page.feature [new file with mode: 0644]
tests/browser/features/main_page_links.feature [new file with mode: 0644]
tests/browser/features/step_definitions/create_account_steps.rb [new file with mode: 0644]
tests/browser/features/step_definitions/create_and_follow_wiki_link_steps.rb [new file with mode: 0644]
tests/browser/features/step_definitions/edit_page_steps.rb [new file with mode: 0644]
tests/browser/features/step_definitions/main_page_links_steps.rb [new file with mode: 0644]
tests/browser/features/step_definitions/view_history_steps.rb [new file with mode: 0644]
tests/browser/features/support/env.rb [new file with mode: 0644]
tests/browser/features/support/hooks.rb [new file with mode: 0644]
tests/browser/features/support/modules/url_module.rb [new file with mode: 0644]
tests/browser/features/support/pages/create_account_page.rb [new file with mode: 0644]
tests/browser/features/support/pages/edit_page.rb [new file with mode: 0644]
tests/browser/features/support/pages/main_page.rb [new file with mode: 0644]
tests/browser/features/support/pages/view_history_page.rb [new file with mode: 0644]
tests/browser/features/support/pages/ztargetpage.rb [new file with mode: 0644]
tests/browser/features/view_history.feature [new file with mode: 0644]

diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644 (file)
index 0000000..eb56bcc
--- /dev/null
@@ -0,0 +1,4 @@
+# Puppet-managed dependencies for browser tests
+.bundle
+.gem
+.ruby-version
diff --git a/tests/browser/Gemfile b/tests/browser/Gemfile
new file mode 100755 (executable)
index 0000000..fd6803e
--- /dev/null
@@ -0,0 +1,7 @@
+#ruby=ruby-2.1.1
+
+source "https://rubygems.org"
+
+gem "chunky_png"
+gem "mediawiki_api"
+gem "mediawiki_selenium"
diff --git a/tests/browser/Gemfile.lock b/tests/browser/Gemfile.lock
new file mode 100644 (file)
index 0000000..d78c9a1
--- /dev/null
@@ -0,0 +1,83 @@
+GEM
+  remote: https://rubygems.org/
+  specs:
+    builder (3.2.2)
+    childprocess (0.5.2)
+      ffi (~> 1.0, >= 1.0.11)
+    chunky_png (1.3.0)
+    cucumber (1.3.14)
+      builder (>= 2.1.2)
+      diff-lcs (>= 1.1.3)
+      gherkin (~> 2.12)
+      multi_json (>= 1.7.5, < 2.0)
+      multi_test (>= 0.1.1)
+    data_magic (0.18)
+      faker (>= 1.1.2)
+      yml_reader (>= 0.2)
+    diff-lcs (1.2.5)
+    domain_name (0.5.18)
+      unf (>= 0.0.5, < 1.0.0)
+    faker (1.3.0)
+      i18n (~> 0.5)
+    faraday (0.9.0)
+      multipart-post (>= 1.2, < 3)
+    faraday-cookie_jar (0.0.6)
+      faraday (>= 0.7.4)
+      http-cookie (~> 1.0.0)
+    ffi (1.9.3)
+    gherkin (2.12.2)
+      multi_json (~> 1.3)
+    headless (1.0.1)
+    http-cookie (1.0.2)
+      domain_name (~> 0.5)
+    i18n (0.6.9)
+    json (1.8.1)
+    mediawiki_api (0.1.2)
+      faraday (~> 0.9, >= 0.9.0)
+      faraday-cookie_jar (~> 0.0, >= 0.0.6)
+    mediawiki_selenium (0.2.20)
+      cucumber (~> 1.3, >= 1.3.10)
+      headless (~> 1.0, >= 1.0.1)
+      json (~> 1.8, >= 1.8.1)
+      net-http-persistent (~> 2.9, >= 2.9.1)
+      page-object (~> 0.9, >= 0.9.5)
+      rest-client (~> 1.6, >= 1.6.7)
+      rspec-expectations (~> 2.14, >= 2.14.4)
+      syntax (~> 1.2, >= 1.2.0)
+    mime-types (2.2)
+    multi_json (1.9.2)
+    multi_test (0.1.1)
+    multipart-post (2.0.0)
+    net-http-persistent (2.9.4)
+    page-object (0.9.8)
+      page_navigation (>= 0.9)
+      selenium-webdriver (>= 2.40.0)
+      watir-webdriver (>= 0.6.8)
+    page_navigation (0.9)
+      data_magic (>= 0.14)
+    rest-client (1.6.7)
+      mime-types (>= 1.16)
+    rspec-expectations (2.14.5)
+      diff-lcs (>= 1.1.3, < 2.0)
+    rubyzip (1.1.3)
+    selenium-webdriver (2.41.0)
+      childprocess (>= 0.5.0)
+      multi_json (~> 1.0)
+      rubyzip (~> 1.0)
+      websocket (~> 1.0.4)
+    syntax (1.2.0)
+    unf (0.1.4)
+      unf_ext
+    unf_ext (0.0.6)
+    watir-webdriver (0.6.9)
+      selenium-webdriver (>= 2.18.0)
+    websocket (1.0.7)
+    yml_reader (0.2)
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  chunky_png
+  mediawiki_api
+  mediawiki_selenium
diff --git a/tests/browser/README.mediawiki b/tests/browser/README.mediawiki
new file mode 100644 (file)
index 0000000..8921fb6
--- /dev/null
@@ -0,0 +1,64 @@
+Purpose:
+
+The purpose of these tests is to validate that a newly installed (or updated, or hacked, or whatever) mediawiki instance presents to the user a set of expected features, regardless of what language the wiki is in, or where it is installed, or what extensions it might have.
+
+The tests are based on the basic definition of a wiki, a website where anyone
+
+* can read a page
+* can create a page
+* can edit a page
+* can link one page to another page
+
+Install:
+
+Ruby 1.9.3 or higher is required
+Firefox browser is required
+
+cd /tests/browser
+gem update --system
+gem install bundler
+bundle install
+
+Run the tests:
+
+Edit the environment_variables file with appropriate values for your wiki
+$source environment_variables (example shown in bash shell)
+
+bundle exec cucumber features/
+
+Note that the acceptance tests will create three pages in your wiki entitled "Editing Test Page", "Link Source Test Page", and "Link Target Test Page".  These pages may be deleted at any time.  If you wish to re-run the tests at any time, these test pages will be re-created or reset to their original contents at the time that the tests run.
+
+For more information about running Selenium tests please see
+https://github.com/wikimedia/mediawiki-selenium
+
+Details:
+
+create_account.feature
+* Checks three different ways to arrive on page allowing the user to create an account
+
+create_and_follow_wiki_link.feature:
+* uses the mediawiki API to create a link target page
+* uses the mediawiki API to create a link source page
+* navigates a browser to the link source page
+* clicks the link in that page to the link target page
+* validates that the browser has in fact followed the link to the target page correctly
+
+edit_page.feature:
+* uses the mediawiki API to create an editable page on the wiki
+* navigates a browser to the page
+* clicks the Edit button to invoke the basic editor
+* edits the page with a particular string containing a static part and also a quasi-unique random part
+* saves the edited page
+* checks that the saved page contains the particular string with which the page was edited
+
+main_page.feature:
+* navigates a browser to the default landing page of the wiki
+* checks for the View History link on the landing page
+* checks for the full set of of sidebar links that should exist on every mediawiki wiki
+
+view_history.feature
+* similar to edit_page.feature but checks for an older version of the edited page
+
+Notes:
+
+Tested on beta labs hewiki, dewiki, enwiki, and on a local installation of mediawiki
\ No newline at end of file
diff --git a/tests/browser/environment_variables b/tests/browser/environment_variables
new file mode 100644 (file)
index 0000000..25c4577
--- /dev/null
@@ -0,0 +1,5 @@
+export MEDIAWIKI_URL=http://localhost/wiki/
+export MEDIAWIKI_API_URL=http://localhost/w/api.php
+export MEDIAWIKI_USER=Selenium_user
+export MEDIAWIKI_PASSWORD=Selenium_password
+export BROWSER=firefox
diff --git a/tests/browser/features/create_account.feature b/tests/browser/features/create_account.feature
new file mode 100644 (file)
index 0000000..a8a96d6
--- /dev/null
@@ -0,0 +1,11 @@
+Feature: Create account
+
+  Scenario Outline: Go to Create account page
+    Given I go to Create account page at <path>
+    Then form has Create account button
+
+  Examples:
+    | path                          |
+    | Special:CreateAccount         |
+    | Special:UserLogin/signup      |
+    | Special:UserLogin?type=signup |
diff --git a/tests/browser/features/create_and_follow_wiki_link.feature b/tests/browser/features/create_and_follow_wiki_link.feature
new file mode 100644 (file)
index 0000000..f5f0ce0
--- /dev/null
@@ -0,0 +1,9 @@
+
+Feature: Create Page With Wiki Link
+
+  Scenario: Create Page With Wiki Link
+    Given I create page "Link Target Test Page" with content "Link Target Test Page"
+      And I go to the "Link Source Test Page" page with content "This is a [[Link Target Test Page|link to the test target page]] right here."
+    When I click the Link Target link
+    Then I should be on the Link Target Test Page
+      And the page content should contain "Link Target Test Page"
\ No newline at end of file
diff --git a/tests/browser/features/edit_page.feature b/tests/browser/features/edit_page.feature
new file mode 100644 (file)
index 0000000..53efd6b
--- /dev/null
@@ -0,0 +1,8 @@
+Feature: Edit Page
+
+  Scenario: Create and edit page
+    Given I go to the "Editing Test Page" page with content "This is a page to test editing"
+    When I click Edit
+      And I edit the page with "Edited and a random string"
+      And I save the edit
+    Then the edited page content should contain "Edited and a random string"
diff --git a/tests/browser/features/main_page_links.feature b/tests/browser/features/main_page_links.feature
new file mode 100644 (file)
index 0000000..053ee62
--- /dev/null
@@ -0,0 +1,18 @@
+Feature: Main Page View History Links
+
+  Background:
+  Given I open the main wiki URL
+
+  Scenario: Main Page View History links exist
+    Then I should see a link for View History
+
+  Scenario: Main Page Sidebar Links
+    Then I should see a link for Recent changes
+      And I should see a link for Random page
+      And I should see a link for Help
+      And I should see a link for What links here
+      And I should see a link for Related changes
+      And I should see a link for Special pages
+      And I should see a link for Printable version
+      And I should see a link for Permanent link
+      And I should see a link for Page information
\ No newline at end of file
diff --git a/tests/browser/features/step_definitions/create_account_steps.rb b/tests/browser/features/step_definitions/create_account_steps.rb
new file mode 100644 (file)
index 0000000..7fa2984
--- /dev/null
@@ -0,0 +1,18 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+Given(/^I go to Create account page at (.+)$/) do |path|
+  visit(CreateAccountPage, :using_params => {:page_title => path})
+end
+
+Then(/^form has Create account button$/) do
+  on(CreateAccountPage).create_account_element.should exist
+end
diff --git a/tests/browser/features/step_definitions/create_and_follow_wiki_link_steps.rb b/tests/browser/features/step_definitions/create_and_follow_wiki_link_steps.rb
new file mode 100644 (file)
index 0000000..ba41f7f
--- /dev/null
@@ -0,0 +1,28 @@
+Given(/^I go to the "(.+)" page with content "(.+)"$/) do |page_title, page_content|
+  @wikitext = page_content
+  on(APIPage).create page_title, page_content
+  step "I am on the #{page_title} page"
+end
+
+Given(/^I am on the (.+) page$/) do |article|
+  article = article.gsub(/ /, '_')
+  visit(ZtargetPage, :using_params => {:article_name => article})
+end
+
+Given(/^I create page "(.*?)" with content "(.*?)"$/) do |page_title, page_content|
+  on(APIPage).create page_title, page_content
+end
+
+
+When(/^I click the Link Target link$/) do
+  on(ZtargetPage).link_target_page_link
+end
+
+Then(/^I should be on the Link Target Test Page$/) do
+  @browser.url.should match /Link_Target_Test_Page/
+end
+
+Then(/^the page content should contain "(.*?)"$/) do |content|
+  on(ZtargetPage).page_content.should match content
+end
+
diff --git a/tests/browser/features/step_definitions/edit_page_steps.rb b/tests/browser/features/step_definitions/edit_page_steps.rb
new file mode 100644 (file)
index 0000000..5af097b
--- /dev/null
@@ -0,0 +1,16 @@
+When(/^I click Edit$/) do
+  on(MainPage).edit_link
+end
+
+When(/^I edit the page with "(.*?)"$/) do |edit_content|
+  on(EditPage).edit_page_content_element.send_keys(edit_content + @random_string)
+end
+
+When(/^I save the edit$/) do
+  on(EditPage).save_button
+end
+
+Then(/^the edited page content should contain "(.*?)"$/) do |content|
+  on(MainPage).page_content.should match(content + @random_string)
+end
+
diff --git a/tests/browser/features/step_definitions/main_page_links_steps.rb b/tests/browser/features/step_definitions/main_page_links_steps.rb
new file mode 100644 (file)
index 0000000..c76fd2b
--- /dev/null
@@ -0,0 +1,47 @@
+Given(/^I open the main wiki URL$/) do
+  visit(MainPage)
+end
+
+Then(/^I should see a link for View History$/) do
+  on(MainPage).view_history_link_element.should be_visible
+end
+
+Then(/^I should see a link for Edit$/) do
+  on(MainPage).edit_link_element.should be_visible
+end
+
+Then(/^I should see a link for Recent changes$/) do
+  on(MainPage).recent_changes_link_element.should be_visible
+end
+
+Then(/^I should see a link for Random page$/) do
+  on(MainPage).random_page_link_element.should be_visible
+end
+
+Then(/^I should see a link for Help$/) do
+  on(MainPage).help_link_element.should be_visible
+end
+
+Then(/^I should see a link for What links here$/) do
+  on(MainPage).what_links_here_link_element.should be_visible
+end
+
+Then(/^I should see a link for Related changes$/) do
+  on(MainPage).related_changes_link_element.should be_visible
+end
+
+Then(/^I should see a link for Special pages$/) do
+  on(MainPage).special_pages_link_element.should be_visible
+end
+
+Then(/^I should see a link for Printable version$/) do
+  on(MainPage).printable_version_link_element.should be_visible
+end
+
+Then(/^I should see a link for Permanent link$/) do
+  on(MainPage).permanent_link_link_element.should be_visible
+end
+
+Then(/^I should see a link for Page information$/) do
+  on(MainPage).page_information_link_element.should be_visible
+end
diff --git a/tests/browser/features/step_definitions/view_history_steps.rb b/tests/browser/features/step_definitions/view_history_steps.rb
new file mode 100644 (file)
index 0000000..1ecc008
--- /dev/null
@@ -0,0 +1,8 @@
+When(/^I click View History$/) do
+  on(ViewHistoryPage).view_history_link
+end
+
+Then(/^I should see a link to a previous version of the page$/) do
+  on(ViewHistoryPage).old_version_link_element.should be_visible
+end
+
diff --git a/tests/browser/features/support/env.rb b/tests/browser/features/support/env.rb
new file mode 100644 (file)
index 0000000..4ffef5e
--- /dev/null
@@ -0,0 +1,2 @@
+require "mediawiki_selenium"
+require "mediawiki_api"
diff --git a/tests/browser/features/support/hooks.rb b/tests/browser/features/support/hooks.rb
new file mode 100644 (file)
index 0000000..85309f3
--- /dev/null
@@ -0,0 +1,2 @@
+# Needed for cucumber --dry-run -f stepdefs
+require 'page-object'
diff --git a/tests/browser/features/support/modules/url_module.rb b/tests/browser/features/support/modules/url_module.rb
new file mode 100644 (file)
index 0000000..6c329e8
--- /dev/null
@@ -0,0 +1,10 @@
+module URL
+  def self.url(name)
+    if ENV["MEDIAWIKI_URL"]
+      mediawiki_url = ENV["MEDIAWIKI_URL"]
+    else
+      mediawiki_url = "http://127.0.0.1:80/w/index.php"
+    end
+    "#{mediawiki_url}#{name}"
+  end
+end
diff --git a/tests/browser/features/support/pages/create_account_page.rb b/tests/browser/features/support/pages/create_account_page.rb
new file mode 100644 (file)
index 0000000..380bccb
--- /dev/null
@@ -0,0 +1,19 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+class CreateAccountPage
+  include PageObject
+
+  include URL
+  page_url URL.url("<%=params[:page_title]%>")
+
+  button(:create_account, id: "wpCreateaccount")
+end
diff --git a/tests/browser/features/support/pages/edit_page.rb b/tests/browser/features/support/pages/edit_page.rb
new file mode 100644 (file)
index 0000000..594ac73
--- /dev/null
@@ -0,0 +1,7 @@
+class EditPage
+  include PageObject
+
+  text_area(:edit_page_content, id: "wpTextbox1")
+  button(:save_button, id: "wpSave")
+
+end
\ No newline at end of file
diff --git a/tests/browser/features/support/pages/main_page.rb b/tests/browser/features/support/pages/main_page.rb
new file mode 100644 (file)
index 0000000..7d96c2b
--- /dev/null
@@ -0,0 +1,19 @@
+class MainPage
+  include PageObject
+
+  include URL
+  page_url URL.url("")
+
+  a(:edit_link, href: /action=edit/)
+  li(:help_link, id: "n-help")
+  div(:page_content, id: "content")
+  li(:page_information_link, id: "t-info")
+  li(:permanent_link_link, id: "t-permalink")
+  a(:printable_version_link, href: /printable=yes/)
+  li(:random_page_link, id: "n-randompage")
+  li(:recent_changes_link, id: "n-recentchanges")
+  li(:related_changes_link, id: "t-recentchangeslinked")
+  li(:special_pages_link, id: "t-specialpages")
+  a(:view_history_link, href: /action=history/)
+  li(:what_links_here_link, id: "t-whatlinkshere")
+end
\ No newline at end of file
diff --git a/tests/browser/features/support/pages/view_history_page.rb b/tests/browser/features/support/pages/view_history_page.rb
new file mode 100644 (file)
index 0000000..6689598
--- /dev/null
@@ -0,0 +1,7 @@
+class ViewHistoryPage
+  include PageObject
+
+  a(:view_history_link, href: /action=history/)
+  a(:old_version_link, href: /oldid=/)
+
+end
\ No newline at end of file
diff --git a/tests/browser/features/support/pages/ztargetpage.rb b/tests/browser/features/support/pages/ztargetpage.rb
new file mode 100644 (file)
index 0000000..c1f46ec
--- /dev/null
@@ -0,0 +1,7 @@
+class ZtargetPage < MainPage
+  include URL
+  page_url URL.url("<%=params[:article_name]%>")
+  include PageObject
+
+  a(:link_target_page_link, text: "link to the test target page")
+end
\ No newline at end of file
diff --git a/tests/browser/features/view_history.feature b/tests/browser/features/view_history.feature
new file mode 100644 (file)
index 0000000..82bc813
--- /dev/null
@@ -0,0 +1,10 @@
+Feature: View History
+
+  Scenario: Edit page and view history
+    Given I go to the "History Test Page" page with content "This is a page that will have history"
+    When I click Edit
+      And I edit the page with "Edited and a random string"
+      And I save the edit
+      And the edited page content should contain "Edited and a random string"
+      And I click View History
+    Then I should see a link to a previous version of the page
\ No newline at end of file