jenkins-bot has submitted this change and it was merged.

Change subject: QA: Refactor for mediawiki_selenium 1.0.2
......................................................................


QA: Refactor for mediawiki_selenium 1.0.2

Refactored test code by following the documentation on upgrading to
mediawiki_selenium 1.0.x.

http://git.wikimedia.org/markdown/mediawiki%2Fselenium.git/HEAD/UPGRADE.md

Bug: T93174
Change-Id: I9c1e74f1f6ab561dc087c491f9e653699cb5c7bc
---
M .rubocop.yml
M Gemfile
M Gemfile.lock
A tests/browser/environments.yml
M tests/browser/features/step_definitions/chunked_upload_steps.rb
M tests/browser/features/step_definitions/upload_wizard_steps.rb
M tests/browser/features/support/env.rb
M tests/browser/features/support/pages/describe_page.rb
M tests/browser/features/support/pages/learn_page.rb
M tests/browser/features/support/pages/logout_page.rb
M tests/browser/features/support/pages/main_page.rb
M tests/browser/features/support/pages/preferences_page.rb
M tests/browser/features/support/pages/release_rights_page.rb
M tests/browser/features/support/pages/upload_page.rb
M tests/browser/features/support/pages/upload_wizard_page.rb
M tests/browser/features/support/pages/use_page.rb
16 files changed, 75 insertions(+), 135 deletions(-)

Approvals:
  Dduvall: Looks good to me, but someone else must approve
  Zfilipin: Looks good to me, approved
  jenkins-bot: Verified

Objections:
  Hashar: There's a problem with this change, please improve



diff --git a/.rubocop.yml b/.rubocop.yml
index cc32da4..f7d8dd1 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -1 +1,5 @@
 inherit_from: .rubocop_todo.yml
+
+AllCops:
+  # Only enforce rules that have an entry in the style guide
+  StyleGuideCopsOnly: true
diff --git a/Gemfile b/Gemfile
index 77113f7..53dda99 100755
--- a/Gemfile
+++ b/Gemfile
@@ -3,6 +3,6 @@
 
 source "https://rubygems.org";
 
-gem "chunky_png"
-gem "mediawiki_selenium"
-gem "rubocop", require: false
+gem "chunky_png", "~> 1.3.4"
+gem "mediawiki_selenium", "~> 1.0.2"
+gem "rubocop", "~> 0.29.1", require: false
diff --git a/Gemfile.lock b/Gemfile.lock
index bdbd823..41e3396 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -27,7 +27,7 @@
     faraday-cookie_jar (0.0.6)
       faraday (>= 0.7.4)
       http-cookie (~> 1.0.0)
-    ffi (1.9.6)
+    ffi (1.9.8)
     gherkin (2.12.2)
       multi_json (~> 1.3)
     headless (1.0.2)
@@ -38,7 +38,7 @@
     mediawiki_api (0.3.1)
       faraday (~> 0.9, >= 0.9.0)
       faraday-cookie_jar (~> 0.0, >= 0.0.6)
-    mediawiki_selenium (0.4.2)
+    mediawiki_selenium (1.0.2)
       cucumber (~> 1.3, >= 1.3.10)
       headless (~> 1.0, >= 1.0.1)
       json (~> 1.8, >= 1.8.1)
@@ -63,7 +63,8 @@
       ast (>= 1.1, < 3.0)
     powerpack (0.1.0)
     rainbow (2.0.0)
-    rest-client (1.7.3)
+    rest-client (1.8.0)
+      http-cookie (>= 1.0.2, < 2.0)
       mime-types (>= 1.16, < 3.0)
       netrc (~> 0.7)
     rspec-expectations (2.99.2)
@@ -95,6 +96,6 @@
   ruby
 
 DEPENDENCIES
-  chunky_png
-  mediawiki_selenium
-  rubocop
+  chunky_png (~> 1.3.4)
+  mediawiki_selenium (~> 1.0.2)
+  rubocop (~> 0.29.1)
diff --git a/tests/browser/environments.yml b/tests/browser/environments.yml
new file mode 100644
index 0000000..7cb0200
--- /dev/null
+++ b/tests/browser/environments.yml
@@ -0,0 +1,35 @@
+# 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:
+  mediawiki_url: http://127.0.0.1:8080/wiki/
+  mediawiki_user: Selenium_user
+  mediawiki_password: vagrant
+
+mw-vagrant-guest:
+  mediawiki_url: http://127.0.0.1/wiki/
+  mediawiki_user: Selenium_user
+  mediawiki_password: vagrant
+
+beta:
+  mediawiki_url: http://commons.wikimedia.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!
diff --git a/tests/browser/features/step_definitions/chunked_upload_steps.rb 
b/tests/browser/features/step_definitions/chunked_upload_steps.rb
index 0f02a02..d5b99c3 100644
--- a/tests/browser/features/step_definitions/chunked_upload_steps.rb
+++ b/tests/browser/features/step_definitions/chunked_upload_steps.rb
@@ -9,7 +9,7 @@
 
 And(/^chunked upload is enabled in my preferences$/) do
   # quite a nasty hack. Faster than actually enabling and reloading, though, 
and does not have race conditions
-  @browser.execute_script('mw.UploadWizard.config.enableChunked = true;')
+  browser.execute_script('mw.UploadWizard.config.enableChunked = true;')
 end
 
 When(/^I upload a large file$/) do
diff --git a/tests/browser/features/step_definitions/upload_wizard_steps.rb 
b/tests/browser/features/step_definitions/upload_wizard_steps.rb
index 7982a1a..3918c22 100644
--- a/tests/browser/features/step_definitions/upload_wizard_steps.rb
+++ b/tests/browser/features/step_definitions/upload_wizard_steps.rb
@@ -1,14 +1,3 @@
-#
-# This file is subject to the license terms in the COPYING file found in the
-# UploadWizard top-level directory and at
-# 
https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FUploadWizard/HEAD/COPYING.
 No part of
-# UploadWizard, including this file, may be copied, modified, propagated, or
-# distributed except according to the terms contained in the COPYING file.
-#
-# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
-# UploadWizard top-level directory and at
-# 
https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FUploadWizard/HEAD/CREDITS
-#
 require "tempfile"
 
 Given(/^I am logged out$/) do
@@ -16,12 +5,7 @@
 end
 
 Given(/^I set my preference to skip the tutorial$/) do
-  on(MainPage) do |page|
-    @browser.execute_script("var api = new mw.Api();
-api.postWithToken( 'options', { action: 'options', change: 
'upwiz_skiptutorial=1' } ).done(
-function() { $( '<div id=\"cucumber-tutorial-preference-set\">&nbsp;</div>' 
).appendTo( 'body' ); } );")
-    page.tutorial_preference_set_element.when_present
-  end
+  api.action(:options, change: 'upwiz_skiptutorial=1')
 end
 
 When(/^I unset Skip introductory licensing tutorial in my Preferences$/) do
@@ -75,11 +59,11 @@
 When(/^I click the Skip checkbox$/) do
   on(LearnPage) do |page|
     page.highlighted_step_heading_element.when_present
-    if @browser.driver.browser == :chrome
+    if browser.driver.browser == :chrome
       # ChromeDriver can't click on the element because of a bug in the driver
       # related to automatic scrolling to out-of-view elements taking time
       # Reported here: https://code.google.com/p/selenium/issues/detail?id=8528
-      @browser.execute_script("$( '#mwe-upwiz-skip' ).click();")
+      browser.execute_script("$( '#mwe-upwiz-skip' ).click();")
     else
       page.check_tutorial_skip
     end
@@ -89,9 +73,9 @@
 When(/^I click the Next button at the Learn page$/) do
   on(LearnPage) do |page|
     page.highlighted_step_heading_element.when_present
-    if @browser.driver.browser == :chrome
+    if browser.driver.browser == :chrome
       # Same Chrome issue as above
-      @browser.execute_script("$( '#mwe-upwiz-stepdiv-tutorial 
.mwe-upwiz-button-next' ).click();")
+      browser.execute_script("$( '#mwe-upwiz-stepdiv-tutorial 
.mwe-upwiz-button-next' ).click();")
     else
       page.next_element.click
     end
@@ -242,15 +226,15 @@
 end
 
 Then(/^Describe page should open$/) do
-  @browser.url.should match /Special:UploadWizard/
+  browser.url.should match /Special:UploadWizard/
 end
 
 Then(/^Learn page should appear$/) do
-  @browser.url.should match /Special:UploadWizard/
+  browser.url.should match /Special:UploadWizard/
 end
 
 Then(/^Release rights page should open$/) do
-  @browser.url.should match /Special:UploadWizard/
+  browser.url.should match /Special:UploadWizard/
 end
 
 Then(/^title text field should be there$/) do
@@ -265,7 +249,7 @@
 end
 
 Then(/^Upload page should appear$/) do
-  @browser.url.should match /Special:UploadWizard/
+  browser.url.should match /Special:UploadWizard/
 end
 
 Then(/^there should be an upload for (\S+)$/) do |filename|
diff --git a/tests/browser/features/support/env.rb 
b/tests/browser/features/support/env.rb
index 7254d26..b641e47 100644
--- a/tests/browser/features/support/env.rb
+++ b/tests/browser/features/support/env.rb
@@ -1,15 +1,6 @@
-#
-# This file is subject to the license terms in the COPYING file found in the
-# UploadWizard top-level directory and at
-# 
https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FUploadWizard/HEAD/COPYING.
 No part of
-# UploadWizard, including this file, may be copied, modified, propagated, or
-# distributed except according to the terms contained in the COPYING file.
-#
-# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
-# UploadWizard top-level directory and at
-# 
https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FUploadWizard/HEAD/CREDITS
-#
 require "mediawiki_selenium"
+require 'mediawiki_selenium/support'
+require 'mediawiki_selenium/step_definitions'
 
 require_relative "file_helper"
 
diff --git a/tests/browser/features/support/pages/describe_page.rb 
b/tests/browser/features/support/pages/describe_page.rb
index 4b1b79a..c60a3e9 100644
--- a/tests/browser/features/support/pages/describe_page.rb
+++ b/tests/browser/features/support/pages/describe_page.rb
@@ -1,22 +1,7 @@
-#
-# This file is subject to the license terms in the COPYING file found in the
-# UploadWizard top-level directory and at
-# 
https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FUploadWizard/HEAD/COPYING.
 No part of
-# UploadWizard, including this file, may be copied, modified, propagated, or
-# distributed except according to the terms contained in the COPYING file.
-#
-# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
-# UploadWizard top-level directory and at
-# 
https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FUploadWizard/HEAD/CREDITS
-#
 class DescribePage
   include PageObject
 
-  include URL
-  def self.url
-    URL.url("Special:UploadWizard")
-  end
-  page_url url
+  page_url 'Special:UploadWizard'
 
   li(:highlighted_step_heading, xpath: 
"//ul[@id='mwe-upwiz-steps']/li[@id='mwe-upwiz-step-details'][@class='arrow 
head']")
   text_field(:category, id: "categories0")
@@ -50,7 +35,7 @@
   end
 
   def div_at_index(index)
-    @browser.div(xpath: "//div[@class='mwe-upwiz-info-file ui-helper-clearfix 
filled'][" + index.to_s + "]")
+    browser.div(xpath: "//div[@class='mwe-upwiz-info-file ui-helper-clearfix 
filled'][" + index.to_s + "]")
   end
 
   def field(index, fieldname)
diff --git a/tests/browser/features/support/pages/learn_page.rb 
b/tests/browser/features/support/pages/learn_page.rb
index ad1844e..94975fe 100644
--- a/tests/browser/features/support/pages/learn_page.rb
+++ b/tests/browser/features/support/pages/learn_page.rb
@@ -1,19 +1,7 @@
-#
-# This file is subject to the license terms in the COPYING file found in the
-# UploadWizard top-level directory and at
-# 
https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FUploadWizard/HEAD/COPYING.
 No part of
-# UploadWizard, including this file, may be copied, modified, propagated, or
-# distributed except according to the terms contained in the COPYING file.
-#
-# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
-# UploadWizard top-level directory and at
-# 
https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FUploadWizard/HEAD/CREDITS
-#
 class LearnPage
   include PageObject
 
-  include URL
-  page_url URL.url("Special:UploadWizard")
+  page_url 'Special:UploadWizard'
 
   div(:tutorial, id: "mwe-upwiz-stepdiv-tutorial")
 
diff --git a/tests/browser/features/support/pages/logout_page.rb 
b/tests/browser/features/support/pages/logout_page.rb
index 1c08634..9d333c2 100644
--- a/tests/browser/features/support/pages/logout_page.rb
+++ b/tests/browser/features/support/pages/logout_page.rb
@@ -1,22 +1,6 @@
-# Encoding: utf-8
-# This file is subject to the license terms in the COPYING file found in the
-# UploadWizard top-level directory and at
-# 
https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FUploadWizard/HEAD/COPYING.
-# No part of UploadWizard, including this file, may be copied, modified,
-# propagated, or distributed except according to the terms contained in the
-# COPYING file.
-#
-# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
-# UploadWizard top-level directory and at
-# 
https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FUploadWizard/HEAD/CREDITS
-
 # Simple page with no elements defined since visiting it does the trick
 class LogoutPage
   include PageObject
 
-  include URL
-  def self.url
-    URL.url('Special:UserLogout')
-  end
-  page_url url
+  page_url 'Special:UserLogout'
 end
diff --git a/tests/browser/features/support/pages/main_page.rb 
b/tests/browser/features/support/pages/main_page.rb
index 5d00785..9c047ba 100644
--- a/tests/browser/features/support/pages/main_page.rb
+++ b/tests/browser/features/support/pages/main_page.rb
@@ -1,20 +1,8 @@
-# Encoding: utf-8
-# This file is subject to the license terms in the COPYING file found in the
-# UploadWizard top-level directory and at
-# 
https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FUploadWizard/HEAD/COPYING.
-# No part of UploadWizard, including this file, may be copied, modified,
-# propagated, or distributed except according to the terms contained in the
-# COPYING file.
-#
-# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
-# UploadWizard top-level directory and at
-# 
https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FUploadWizard/HEAD/CREDITS
-
 # Main wiki page, where we land after logging in
 class MainPage
   include PageObject
-  include URL
 
-  page_url URL.url('Main_Page')
+  page_url 'Main_Page'
+
   div(:tutorial_preference_set, id: "cucumber-tutorial-preference-set")
 end
diff --git a/tests/browser/features/support/pages/preferences_page.rb 
b/tests/browser/features/support/pages/preferences_page.rb
index 16b5fba..b8e6fc1 100644
--- a/tests/browser/features/support/pages/preferences_page.rb
+++ b/tests/browser/features/support/pages/preferences_page.rb
@@ -12,11 +12,7 @@
 class PreferencesPage
   include PageObject
 
-  include URL
-  def self.url
-    URL.url('Special:Preferences')
-  end
-  page_url url
+  page_url 'Special:Preferences'
 
   a(:upload_wizard_pref_tab, id: "preftab-uploads")
   checkbox(:reset_skip_checkbox, id: "mw-input-wpupwiz_skiptutorial")
diff --git a/tests/browser/features/support/pages/release_rights_page.rb 
b/tests/browser/features/support/pages/release_rights_page.rb
index 7df94e6..7f0946c 100644
--- a/tests/browser/features/support/pages/release_rights_page.rb
+++ b/tests/browser/features/support/pages/release_rights_page.rb
@@ -12,11 +12,7 @@
 class ReleaseRightsPage
   include PageObject
 
-  include URL
-  def self.url
-    URL.url("Special:UploadWizard")
-  end
-  page_url url
+  page_url 'Special:UploadWizard'
 
   radio(:my_own_work, id: "deedChooser1-ownwork")
   radio(:provide_copyright_information, id: "deedChooser1-custom")
diff --git a/tests/browser/features/support/pages/upload_page.rb 
b/tests/browser/features/support/pages/upload_page.rb
index 15668fc..1745e5e 100644
--- a/tests/browser/features/support/pages/upload_page.rb
+++ b/tests/browser/features/support/pages/upload_page.rb
@@ -11,12 +11,8 @@
 #
 class UploadPage
   include PageObject
-  include URL
 
-  def self.url
-    URL.url("Special:UploadWizard")
-  end
-  page_url url
+  page_url 'Special:UploadWizard'
 
   span(:continue, text: "Continue")
   p(:duplicate_error, text: /You are already uploading/)
@@ -28,13 +24,13 @@
   button(:flickr_select_button, id: "mwe-upwiz-select-flickr")
 
   def flickr_upload(index)
-    @browser.li(id: "upload-" + index)
+    browser.li(id: "upload-" + index)
   end
 
   # We need to keep track of all the uploads on the page.
   # PageObjects are bad at finding elements that are repeated and change.
   # We have to break through to the underlying Watir library,
-  # accessible through @browser.
+  # accessible through browser.
 
   # Get all the 'uploads' on the page, or more precisely the Upload
   # interfaces. n.b. there is at least one "unfilled" upload on
@@ -45,7 +41,7 @@
     basic_constraint = "contains(@class,'mwe-upwiz-file')"
     filled_constraint = is_filled ? "contains(@class,'filled')" : 
"not(contains(@class,'filled'))"
     constraints = [basic_constraint, filled_constraint].join(' and ')
-    @browser.divs(
+    browser.divs(
       xpath: "//div[@id='mwe-upwiz-filelist']/div[#{constraints}]"
     )
   end
diff --git a/tests/browser/features/support/pages/upload_wizard_page.rb 
b/tests/browser/features/support/pages/upload_wizard_page.rb
index 0b49381..8d74726 100644
--- a/tests/browser/features/support/pages/upload_wizard_page.rb
+++ b/tests/browser/features/support/pages/upload_wizard_page.rb
@@ -12,11 +12,7 @@
 class UploadWizardPage
   include PageObject
 
-  include URL
-  def self.url
-    URL.url("Special:UploadWizard")
-  end
-  page_url url
+  page_url 'Special:UploadWizard'
 
   div(:stepdiv_file, id: "mwe-upwiz-stepdiv-file")
   text_field(:add_categories, id: "categories0")
diff --git a/tests/browser/features/support/pages/use_page.rb 
b/tests/browser/features/support/pages/use_page.rb
index 1b9ab69..48b0618 100644
--- a/tests/browser/features/support/pages/use_page.rb
+++ b/tests/browser/features/support/pages/use_page.rb
@@ -12,11 +12,7 @@
 class UsePage
   include PageObject
 
-  include URL
-  def self.url
-    URL.url("Special:UploadWizard")
-  end
-  page_url url
+  page_url 'Special:UploadWizard'
 
   span(:upload_more_files, text: "Upload more files")
   li(:highlighted_step_heading, xpath: 
"//ul[@id='mwe-upwiz-steps']/li[@id='mwe-upwiz-step-thanks'][@class='head']")

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9c1e74f1f6ab561dc087c491f9e653699cb5c7bc
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Dduvall <dduv...@wikimedia.org>
Gerrit-Reviewer: Dduvall <dduv...@wikimedia.org>
Gerrit-Reviewer: Gilles <gdu...@wikimedia.org>
Gerrit-Reviewer: Hashar <has...@free.fr>
Gerrit-Reviewer: Zfilipin <zfili...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to