Tobias Gritschacher has uploaded a new change for review.

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

Change subject: Add browsertests for two column edit conflict page
......................................................................

Add browsertests for two column edit conflict page

Bug: T149719
Change-Id: Ia215a2d5753a55a196f05cda013764be4ed707b4
---
M .gitignore
A Gemfile
A tests/browser/README.mediawiki
A tests/browser/environments.yml
A tests/browser/features/edit_conflict.feature
A tests/browser/features/support/env.rb
A tests/browser/features/support/hooks.rb
A tests/browser/features/support/pages/edit_conflict_page.rb
A tests/browser/features/support/step_definitions/edit_conflict_steps.rb
A tests/browser/features/support/step_definitions/edit_steps.rb
10 files changed, 180 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TwoColConflict 
refs/changes/13/320613/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..19a0e9d
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,8 @@
+source 'http://rubygems.org'
+
+gem 'chunky_png', '~> 1.3.4'
+gem 'jsduck', '~> 5.3.4'
+gem 'mediawiki_selenium', '~> 1.6.5'
+gem 'require_all', '~> 1.3', '>= 1.3.3'
+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..f30c427
--- /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 TwoColConflict/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 edit conflict tests:
+
+  bundle exec cucumber features/edit_conflict.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/environments.yml b/tests/browser/environments.yml
new file mode 100644
index 0000000..2e54bb8
--- /dev/null
+++ b/tests/browser/environments.yml
@@ -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: http://en.wikipedia.beta.wmflabs.org/wiki/
+  mediawiki_user: Selenium_user
+  # mediawiki_password: SET THIS IN THE ENVIRONMENT!
+
+test2:
+  mediawiki_url: http://test2.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
\ No newline at end of file
diff --git a/tests/browser/features/edit_conflict.feature 
b/tests/browser/features/edit_conflict.feature
new file mode 100644
index 0000000..0aa3d46
--- /dev/null
+++ b/tests/browser/features/edit_conflict.feature
@@ -0,0 +1,11 @@
+@chrome @en.wikipedia.beta.wmflabs.org @firefox @integration
+Feature: Two column edit conflict screen
+  Scenario: Basic two-column edit conflict page is shown correctly
+    When I go to the "TwoColConflict Test Page" page with content "I am a 
sentence."
+    And I click Edit
+    And Another user changes content of the "TwoColConflict Test Page" page to 
"I am a longer sentence than before."
+    And I edit the page with "Adding some random content."
+    And I save the edit
+    Then The two column edit conflict screen should be shown
+    And The editor should contain "I am a longer sentence than before."
+    And The changes textbox should contain "Adding some random content."
diff --git a/tests/browser/features/support/env.rb 
b/tests/browser/features/support/env.rb
new file mode 100644
index 0000000..d754621
--- /dev/null
+++ b/tests/browser/features/support/env.rb
@@ -0,0 +1,6 @@
+require 'require_all'
+require 'mediawiki_selenium/cucumber'
+require 'mediawiki_selenium/pages'
+require 'mediawiki_selenium/step_definitions'
+require_all File.dirname(__FILE__) + 
'/../../../../../../tests/browser/features/support/pages'
+require_all File.dirname(__FILE__) + 
'/../../../../../../tests/browser/features/step_definitions'
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/edit_conflict_page.rb 
b/tests/browser/features/support/pages/edit_conflict_page.rb
new file mode 100644
index 0000000..9188b49
--- /dev/null
+++ b/tests/browser/features/support/pages/edit_conflict_page.rb
@@ -0,0 +1,9 @@
+class EditConflictPage
+  include PageObject
+
+  div(:twocolconflict_explanation_header, class: 
'mw-twocolconflict-explainconflict')
+  div(:twocolconflict_changes_desc, css: '.mw-twocolconflict-changes-col 
.mw-twocolconflict-col-desc')
+  text_area(:twocolconflict_changes_text, css: '.mw-twocolconflict-changes-col 
textarea')
+  div(:twocolconflict_editor_desc, css: '.mw-twocolconflict-editor-col 
.mw-twocolconflict-col-desc')
+  text_area(:twocolconflict_editor_text, css: '.mw-twocolconflict-editor-col 
textarea')
+end
diff --git 
a/tests/browser/features/support/step_definitions/edit_conflict_steps.rb 
b/tests/browser/features/support/step_definitions/edit_conflict_steps.rb
new file mode 100644
index 0000000..3fbc7cf
--- /dev/null
+++ b/tests/browser/features/support/step_definitions/edit_conflict_steps.rb
@@ -0,0 +1,35 @@
+Then(/^The two column edit conflict screen should be shown$/) do
+  step 'An explanation header should be shown'
+  step 'A description for the changes column should be shown'
+  step 'A description for the editor column should be shown'
+  step 'A textbox with changes from the user should be shown'
+  step 'A textbox for the editor should be shown'
+end
+
+Then(/^An explanation header should be shown$/) do
+  expect(on(EditConflictPage).twocolconflict_explanation_header_element).to 
be_visible
+end
+
+Then(/^A description for the changes column should be shown$/) do
+  expect(on(EditConflictPage).twocolconflict_changes_desc_element).to 
be_visible
+end
+
+Then(/^A description for the editor column should be shown$/) do
+  expect(on(EditConflictPage).twocolconflict_editor_desc_element).to be_visible
+end
+
+Then(/^A textbox with changes from the user should be shown$/) do
+  expect(on(EditConflictPage).twocolconflict_changes_text_element).to 
be_visible
+end
+
+Then(/^A textbox for the editor should be shown$/) do
+  expect(on(EditConflictPage).twocolconflict_editor_text_element).to be_visible
+end
+
+Then(/^The editor should contain "(.+?)"$/) do |text|
+  expect(on(EditConflictPage).twocolconflict_editor_text_element.text).to 
match(text)
+end
+
+Then(/^The changes textbox should contain "(.+?)"$/) do |text|
+  expect(on(EditConflictPage).twocolconflict_changes_text_element.text).to 
match(text + @random_string)
+end
diff --git a/tests/browser/features/support/step_definitions/edit_steps.rb 
b/tests/browser/features/support/step_definitions/edit_steps.rb
new file mode 100644
index 0000000..4639116
--- /dev/null
+++ b/tests/browser/features/support/step_definitions/edit_steps.rb
@@ -0,0 +1,9 @@
+When(/^Another user changes content of the "(.+?)" page to "(.+?)"$/) do 
|page_title, page_content|
+  as_user(:conflicting_user) do
+    api.edit(
+        title: page_title,
+        text: page_content,
+        summary: "Conflicting edit"
+    )
+  end
+end

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia215a2d5753a55a196f05cda013764be4ed707b4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TwoColConflict
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