Tobias Gritschacher has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/318088

Change subject: Adding basic browsertests
......................................................................

Adding basic browsertests

Change-Id: I080be6304e7be3cfadbead182a23302d6de9d72f
---
M .gitignore
A Gemfile
A tests/browser/README.mediawiki
A tests/browser/features/selectionscreen.feature
A tests/browser/features/support/env.rb
A tests/browser/features/support/hooks.rb
A tests/browser/features/support/pages/mainpage_page.rb
A tests/browser/features/support/pages/selectionscreen_page.rb
A tests/browser/features/support/step_definitions/mainpage.rb
A tests/browser/features/support/step_definitions/selectionscreen.rb
10 files changed, 123 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ElectronPdfService 
refs/changes/88/318088/1

diff --git a/.gitignore b/.gitignore
index 51d4694..fb1c829 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@
 /composer.lock
 /vendor
 /node_modules
+Gemfile.lock
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..8f7df47
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,7 @@
+source 'https://rubygems.org'
+
+gem 'chunky_png', '~> 1.3.4'
+gem 'jsduck', '~> 5.3.4'
+gem 'mediawiki_selenium', '~> 1.6.5'
+gem 'rake', '~> 10.4', '>= 10.4.2'
+gem 'rubocop', '~> 0.29.1', require: false
\ No newline at end of file
diff --git a/tests/browser/README.mediawiki b/tests/browser/README.mediawiki
new file mode 100644
index 0000000..6aab0a2
--- /dev/null
+++ b/tests/browser/README.mediawiki
@@ -0,0 +1,50 @@
+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  # on Mac OS X Yosemite append ` --user-install -n~/bin`,
+                       # where ~/bin is the install folder
+  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 the "Given I create a random page using the API" step 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 RevisionSlider tests/browser directory with:
+
+  bundle exec 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/betafeature.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
diff --git a/tests/browser/features/selectionscreen.feature 
b/tests/browser/features/selectionscreen.feature
new file mode 100644
index 0000000..1998194
--- /dev/null
+++ b/tests/browser/features/selectionscreen.feature
@@ -0,0 +1,11 @@
+@chrome @en.wikipedia.beta.wmflabs.org @firefox @integration
+Feature: ElectronPdfService Selection Screen
+  Background:
+    Given I am on the Main Page
+
+  Scenario: Selection screen is shown with correct default selection
+    When I click Download as PDF
+    Then Selection screen header should be there
+    And Selection elements should be there
+    And Download button should be there
+    And Single column option should be selected
diff --git a/tests/browser/features/support/env.rb 
b/tests/browser/features/support/env.rb
new file mode 100644
index 0000000..3c896c2
--- /dev/null
+++ b/tests/browser/features/support/env.rb
@@ -0,0 +1,3 @@
+require 'mediawiki_selenium/cucumber'
+require 'mediawiki_selenium/pages'
+require 'mediawiki_selenium/step_definitions'
\ No newline at end of file
diff --git a/tests/browser/features/support/hooks.rb 
b/tests/browser/features/support/hooks.rb
new file mode 100644
index 0000000..9e8e4cd
--- /dev/null
+++ b/tests/browser/features/support/hooks.rb
@@ -0,0 +1,6 @@
+# Needed for cucumber --dry-run -f stepdefs
+require_relative 'env'
+
+Before('@skip') do |scenario|
+  scenario.skip_invoke!
+end
\ No newline at end of file
diff --git a/tests/browser/features/support/pages/mainpage_page.rb 
b/tests/browser/features/support/pages/mainpage_page.rb
new file mode 100644
index 0000000..4bdd2c3
--- /dev/null
+++ b/tests/browser/features/support/pages/mainpage_page.rb
@@ -0,0 +1,7 @@
+class MainPage
+  include PageObject
+
+  li(:download_as_pdf, css: '#coll-download-as-rl')
+
+  page_url ''
+end
diff --git a/tests/browser/features/support/pages/selectionscreen_page.rb 
b/tests/browser/features/support/pages/selectionscreen_page.rb
new file mode 100644
index 0000000..7f9f5b3
--- /dev/null
+++ b/tests/browser/features/support/pages/selectionscreen_page.rb
@@ -0,0 +1,8 @@
+class SelectionScreenPage
+  include PageObject
+
+  div(:selectionscreen_header, css: '.mw-electronPdfService-selection-header')
+  radio_button(:singlecolumn_selection, css: 
'.mw-electronPdfService-selection-form [value=download-electron-pdf]')
+  radio_button(:twocolumn_selection, css: 
'.mw-electronPdfService-selection-form [value=redirect-to-collection]')
+  button(:pdf_download_button, css: '.mw-electronPdfService-selection-form 
.oo-ui-buttonElement-button')
+end
diff --git a/tests/browser/features/support/step_definitions/mainpage.rb 
b/tests/browser/features/support/step_definitions/mainpage.rb
new file mode 100644
index 0000000..7eb84a2
--- /dev/null
+++ b/tests/browser/features/support/step_definitions/mainpage.rb
@@ -0,0 +1,7 @@
+Given(/^I am on the Main Page$/) do
+  visit(MainPage)
+end
+
+When(/^I click Download as PDF$/) do
+  on(MainPage).download_as_pdf_element.when_visible.click
+end
diff --git a/tests/browser/features/support/step_definitions/selectionscreen.rb 
b/tests/browser/features/support/step_definitions/selectionscreen.rb
new file mode 100644
index 0000000..ef05438
--- /dev/null
+++ b/tests/browser/features/support/step_definitions/selectionscreen.rb
@@ -0,0 +1,23 @@
+Then(/^Selection screen header should be there$/) do
+  expect(on(SelectionScreenPage).selectionscreen_header_element).to be_visible
+end
+
+Then(/^Selection elements should be there$/) do
+  on(SelectionScreenPage) do |page|
+    expect(page.singlecolumn_selection_element.exists?).to be true
+    expect(page.twocolumn_selection_element.exists?).to be true
+  end
+end
+
+Then(/^Download button should be there$/) do
+  on(SelectionScreenPage) do |page|
+    expect(page.pdf_download_button_element).to be_visible
+  end
+end
+
+Then(/^Single column option should be selected$/) do
+  on(SelectionScreenPage) do |page|
+    expect(page.singlecolumn_selection_element.attribute('checked')).to 
be_truthy
+    expect(page.twocolumn_selection_element.attribute('checked')).to be_falsey
+  end
+end

-- 
To view, visit https://gerrit.wikimedia.org/r/318088
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I080be6304e7be3cfadbead182a23302d6de9d72f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ElectronPdfService
Gerrit-Branch: master
Gerrit-Owner: Tobias Gritschacher <tobias.gritschac...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to