Zfilipin has uploaded a new change for review.

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


Change subject: WIP Moved Selenium tests from browsertests repository
......................................................................

WIP Moved Selenium tests from browsertests repository

Should not be merged into master until blockers of the bug mentioned
below are resolved.

Bug: 56419
Change-Id: I1d2f73790f1d94f426569ec296389c2dfa9127a1
---
A test/browser/Gemfile
A test/browser/Gemfile.lock
A test/browser/README.md
A test/browser/features/step_definitions/upload_wizard_steps.rb
A test/browser/features/support/env.rb
A test/browser/features/support/pages/describe_page.rb
A test/browser/features/support/pages/learn_page.rb
A test/browser/features/support/pages/release_rights_page.rb
A test/browser/features/support/pages/upload_page.rb
A test/browser/features/support/pages/upload_wizard_page.rb
A test/browser/features/support/pages/use_page.rb
A test/browser/features/upload_wizard.feature
12 files changed, 354 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/79/92879/1

diff --git a/test/browser/Gemfile b/test/browser/Gemfile
new file mode 100755
index 0000000..392584f
--- /dev/null
+++ b/test/browser/Gemfile
@@ -0,0 +1,9 @@
+# License header goes here?
+
+#ruby=ruby-2.0.0-p247
+#ruby-gemset=UploadWizard
+
+source 'https://rubygems.org'
+
+gem 'chunky_png'
+gem 'mediawiki-selenium'
diff --git a/test/browser/Gemfile.lock b/test/browser/Gemfile.lock
new file mode 100644
index 0000000..e16e27d
--- /dev/null
+++ b/test/browser/Gemfile.lock
@@ -0,0 +1,64 @@
+GEM
+  remote: https://rubygems.org/
+  specs:
+    builder (3.2.2)
+    childprocess (0.3.9)
+      ffi (~> 1.0, >= 1.0.11)
+    chunky_png (1.2.9)
+    cucumber (1.3.8)
+      builder (>= 2.1.2)
+      diff-lcs (>= 1.1.3)
+      gherkin (~> 2.12.1)
+      multi_json (>= 1.7.5, < 2.0)
+      multi_test (>= 0.0.2)
+    data_magic (0.16.1)
+      faker (>= 1.1.2)
+      yml_reader (>= 0.2)
+    diff-lcs (1.2.4)
+    faker (1.2.0)
+      i18n (~> 0.5)
+    ffi (1.9.3)
+    gherkin (2.12.2)
+      multi_json (~> 1.3)
+    i18n (0.6.5)
+    json (1.8.1)
+    mediawiki-selenium (0.1.10)
+      cucumber
+      json
+      net-http-persistent
+      page-object
+      rest-client
+      rspec-expectations
+      syntax
+    mime-types (2.0)
+    multi_json (1.8.2)
+    multi_test (0.0.2)
+    net-http-persistent (2.9)
+    page-object (0.9.3)
+      page_navigation (>= 0.8)
+      selenium-webdriver (>= 2.37.0)
+      watir-webdriver (>= 0.6.4)
+    page_navigation (0.9)
+      data_magic (>= 0.14)
+    rest-client (1.6.7)
+      mime-types (>= 1.16)
+    rspec-expectations (2.14.3)
+      diff-lcs (>= 1.1.3, < 2.0)
+    rubyzip (1.0.0)
+    selenium-webdriver (2.37.0)
+      childprocess (>= 0.2.5)
+      multi_json (~> 1.0)
+      rubyzip (~> 1.0.0)
+      websocket (~> 1.0.4)
+    syntax (1.0.0)
+    watir-webdriver (0.6.4)
+      selenium-webdriver (>= 2.18.0)
+    websocket (1.0.7)
+    yml_reader (0.2)
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  chunky_png
+  mediawiki-selenium
diff --git a/test/browser/README.md b/test/browser/README.md
new file mode 100644
index 0000000..378a5e1
--- /dev/null
+++ b/test/browser/README.md
@@ -0,0 +1,3 @@
+Please see https://github.com/wikimedia/mediawiki-selenium for instructions on 
how to run tests.
+
+Should we link to 
https://git.wikimedia.org/blob/mediawiki%2Fselenium/56f4c92d77b68011f6adfd9ce0f79165d6803db5/README.md
 instead of Github?
diff --git a/test/browser/features/step_definitions/upload_wizard_steps.rb 
b/test/browser/features/step_definitions/upload_wizard_steps.rb
new file mode 100644
index 0000000..bfd9de8
--- /dev/null
+++ b/test/browser/features/step_definitions/upload_wizard_steps.rb
@@ -0,0 +1,81 @@
+# License header goes here?
+
+When(/^click button Continue$/) do
+  on(UploadPage).continue_element.when_present.click
+end
+When(/^I click Next button$/) do
+  on(UploadWizardPage).next_element.when_present.click
+end
+When(/^I click Next button at Describe page$/) do
+  sleep 1 # todo # I can not figure out at the moment how to make this work 
without using sleep
+  on(DescribePage).next_element.click
+end
+When(/^I click Next button at Learn page$/) do
+  on(LearnPage).next_element.when_present(15).click
+end
+When(/^I click Next button at Release rights page$/) do
+  on(ReleaseRightsPage).next_element.when_present.click
+end
+When(/^I click This file is my own work$/) do
+  on(ReleaseRightsPage).select_my_own_work
+end
+When(/^I enter category$/) do
+  on(DescribePage).category = 'Test'
+end
+When(/^I enter description$/) do
+  on(DescribePage).description = 'description'
+end
+When(/^I enter title$/) do
+  on(DescribePage).title = "Title #{Random.new.rand}"
+end
+When(/^I navigate to Upload Wizard$/) do
+  visit UploadWizardPage
+end
+When(/^thumbnail should be visible$/) do
+  on(ReleaseRightsPage).thumbnail_element.when_present.should be_visible
+end
+When(/^upload file (.+)$/) do |file_name|
+  require 'tempfile'
+  path = "#{Dir.tmpdir}/#{file_name}"
+
+  require 'chunky_png'
+  ChunkyPNG::Image.new(Random.new.rand(255), Random.new.rand(255), 
Random.new.rand(255)).save path
+
+  if @browser.driver.browser == :chrome
+    @browser.execute_script 
'document.getElementsByName("file")[0].removeAttribute("class");'
+    @browser.execute_script 
'document.getElementsByName("file")[0].removeAttribute("style");'
+  end
+
+  on(UploadPage).select_file = path
+end
+Then(/^(.+) checkbox should be there$/) do |_|
+  on(LearnPage).skip_element.when_present.should be_visible
+end
+Then(/^Describe page should open$/) do
+  @browser.url.should match /Special:UploadWizard/
+end
+Then(/^Learn page should appear$/) do
+  @browser.url.should match /Special:UploadWizard/
+end
+Then(/^Release rights page should open$/) do
+  @browser.url.should match /Special:UploadWizard/
+end
+Then(/^Select a media file to donate button should be there$/) do
+  sleep 1
+  on(UploadPage).select_file_element.when_present.should be_visible
+end
+Then(/^title text field should be there$/) do
+  on(DescribePage).title_element.when_present.should be_visible
+end
+Then(/^Upload more files button should be there$/) do
+  on(UsePage) do |page|
+    page.upload_more_files_element.when_present
+    page.upload_more_files_element.should be_visible
+  end
+end
+Then(/^Upload page should appear$/) do
+  @browser.url.should match /Special:UploadWizard/
+end
+Then(/^Use page should open$/) do
+  @browser.url.should match /Special:UploadWizard/
+end
diff --git a/test/browser/features/support/env.rb 
b/test/browser/features/support/env.rb
new file mode 100644
index 0000000..ba1c877
--- /dev/null
+++ b/test/browser/features/support/env.rb
@@ -0,0 +1,3 @@
+# License header goes here?
+
+require 'mediawiki/selenium'
diff --git a/test/browser/features/support/pages/describe_page.rb 
b/test/browser/features/support/pages/describe_page.rb
new file mode 100644
index 0000000..63e638f
--- /dev/null
+++ b/test/browser/features/support/pages/describe_page.rb
@@ -0,0 +1,19 @@
+# License header goes here?
+
+class DescribePage
+  include PageObject
+
+  include URL
+  def self.url
+    URL.url('Special:UploadWizard')
+  end
+  page_url url
+
+  text_field(:category, id: 'categories0')
+  textarea(:description, name: /^description/)
+  div(:next_parent, id: 'mwe-upwiz-stepdiv-details')
+  span(:next) do |page|
+    page.next_parent_element.span_element(text: 'Next')
+  end
+  text_field(:title, id: 'title0')
+end
diff --git a/test/browser/features/support/pages/learn_page.rb 
b/test/browser/features/support/pages/learn_page.rb
new file mode 100644
index 0000000..991e11b
--- /dev/null
+++ b/test/browser/features/support/pages/learn_page.rb
@@ -0,0 +1,14 @@
+# License header goes here?
+
+class LearnPage
+  include PageObject
+
+  include URL
+  page_url URL.url('Special:UploadWizard')
+
+  div(:next_parent, id: 'mwe-upwiz-stepdiv-tutorial')
+  span(:next) do |page|
+    page.next_parent_element.span_element(text: 'Next')
+  end
+  checkbox(:skip, id: 'mwe-upwiz-skip')
+end
diff --git a/test/browser/features/support/pages/release_rights_page.rb 
b/test/browser/features/support/pages/release_rights_page.rb
new file mode 100644
index 0000000..22028f3
--- /dev/null
+++ b/test/browser/features/support/pages/release_rights_page.rb
@@ -0,0 +1,18 @@
+# License header goes here?
+
+class ReleaseRightsPage
+  include PageObject
+
+  include URL
+  def self.url
+    URL.url('Special:UploadWizard')
+  end
+  page_url url
+
+  radio(:my_own_work, id: 'deedChooser1-ownwork')
+  div(:next_parent, id: 'mwe-upwiz-stepdiv-deeds')
+  span(:next) do |page|
+    page.next_parent_element.span_element(text: 'Next')
+  end
+  div(:thumbnail, id: 'mwe-upwiz-deeds-thumbnails')
+end
diff --git a/test/browser/features/support/pages/upload_page.rb 
b/test/browser/features/support/pages/upload_page.rb
new file mode 100644
index 0000000..adf4cdc
--- /dev/null
+++ b/test/browser/features/support/pages/upload_page.rb
@@ -0,0 +1,14 @@
+# License header goes here?
+
+class UploadPage
+  include PageObject
+
+  include URL
+  def self.url
+    URL.url('Special:UploadWizard')
+  end
+  page_url url
+
+  span(:continue, text: 'Continue')
+  file_field(:select_file, name: 'file')
+end
diff --git a/test/browser/features/support/pages/upload_wizard_page.rb 
b/test/browser/features/support/pages/upload_wizard_page.rb
new file mode 100644
index 0000000..38a7809
--- /dev/null
+++ b/test/browser/features/support/pages/upload_wizard_page.rb
@@ -0,0 +1,68 @@
+# License header goes here?
+
+class UploadWizardPage
+  include PageObject
+
+  include URL
+  def self.url
+    URL.url('Special:UploadWizard')
+  end
+  page_url url
+
+  text_field(:add_categories, id: 'categories0')
+  text_field(:altitude, id: 'location-altitude0')
+  text_field(:author, name: 'author2')
+  textarea(:author, name: 'author') # todo # fix duplicate
+  radio(:believe_free, id: 'license2_13')
+  a(:categories, text: 'Add categories and more information ...')
+  a(:cc, text: 'The copyright holder published this work with the right 
Creative Commons license')
+  radio(:cc_cc, id: 'license1_2')
+  radio(:cc_waiver, id: 'license2_4')
+  radio(:cca2, id: 'license2_3')
+  radio(:cca3, id: 'license1_1')
+  radio(:cca3_2, id: 'license2_2')
+  radio(:cca_2_2, id: 'license2_6')
+  radio(:cca_sa, id: 'license1_0')
+  radio(:cca_sa2, id: 'license2_1')
+  radio(:cca_sa20, id: 'license2_5')
+  radio(:cca_sa3, id: 'license2_0')
+  button(:continue_button, xpath: '//div[2]/div[2]/div/button')
+  # todo # replace xpath # button(:continue_button, class: 
'mwe-upwiz-button-next ui-button ui-widget ui-state-default ui-corner-all 
ui-button-text-only')
+  text_field(:date_created, id: 'dateInput0')
+  textarea(:description_field, name: 'description1')
+  a(:different_license, text: 'Use a different license')
+  a(:expired, text: 'The copyright has definitely expired in the USA')
+  a(:flickr, text: 'The copyright holder published their photo or video on 
Flickr with the right license')
+  a(:found_it, text: "I found it on the Internet -- I'm not sure")
+  radio(:free_form, id: 'license2_12')
+  textarea(:free_lic, id: 'license2_12_custom')
+  select(:language, name: 'lang')
+  text_field(:latitude, id: 'location-latitude0')
+  # todo # check if legal_* links actually go the right place 
https://bugzilla.wikimedia.org/show_bug.cgi?id=35702
+  a(:legal_code_cc_sa25, href: 
'https://creativecommons.org/licenses/by-sa/2.5/')
+  a(:legal_code_cc_sa3, href: 
'https://creativecommons.org/licenses/by-sa/3.0/')
+  a(:legal_code_cc_waiver, href: 
'https://creativecommons.org/publicdomain/zero/1.0/')
+  a(:legal_code_cca25, href: 'https://creativecommons.org/licenses/by/2.5/')
+  a(:legal_code_cca3, href: 'https://creativecommons.org/licenses/by/3.0/')
+  a(:legal_code_recommended, href: 
'https://creativecommons.org/licenses/by-sa/3.0/')
+  a(:logged_in, text: 'logged in')
+  text_field(:longitude, id: 'location-longitude0')
+  radio(:nasa, id: 'license2_11')
+  span(:next, text: 'Next')
+  button(:next_button, xpath: '//div[4]/button')
+  a(:not_mentioned, text: 'Another reason not mentioned above')
+  textarea(:other_information, id: 'otherInformation0')
+  radio(:own_work_button, id: 'deedChooser1-ownwork')
+  radio(:pre_1923, id: 'license2_8')
+  a(:recommended_license, text: 'Use the recommended license')
+  radio(:repro, id: 'license2_9')
+  file_field(:select_file, name: 'file')
+  checkbox(:skip_radio, id: 'mwe-upwiz-skip')
+  textarea(:source, name: 'source')
+  radio(:third_party_button, id: 'deedChooser1-thirdparty')
+  text_field(:title_field, id: 'title0')
+  div(:tutorial_map, id: 'mwe-upwiz-tutorial')
+  a(:us_govt, text: 'This work was made by the United States government')
+  radio(:us_govt_2, id: 'license2_7')
+  radio(:us_govt_3, id: 'license2_10')
+end
diff --git a/test/browser/features/support/pages/use_page.rb 
b/test/browser/features/support/pages/use_page.rb
new file mode 100644
index 0000000..ec0474b
--- /dev/null
+++ b/test/browser/features/support/pages/use_page.rb
@@ -0,0 +1,13 @@
+# License header goes here?
+
+class UsePage
+  include PageObject
+
+  include URL
+  def self.url
+    URL.url('Special:UploadWizard')
+  end
+  page_url url
+
+  span(:upload_more_files, text: 'Upload more files')
+end
diff --git a/test/browser/features/upload_wizard.feature 
b/test/browser/features/upload_wizard.feature
new file mode 100644
index 0000000..ad91379
--- /dev/null
+++ b/test/browser/features/upload_wizard.feature
@@ -0,0 +1,48 @@
+# License header goes here?
+
[email protected] @ie6-bug  @ie7-bug  @ie8-bug @login 
@test2.wikipedia.org
+Feature: UploadWizard
+
+  Background:
+    Given I am logged in
+    When I navigate to Upload Wizard
+
+  Scenario: Navigate to Learn page
+    Then Learn page should appear
+      And Skip this step in the future checkbox should be there
+
+  Scenario: Navigate to Upload page
+    When I click Next button at Learn page
+    Then Upload page should appear
+
+
+  Scenario: Navigate to Release rights page
+    When I click Next button at Learn page
+      And upload file image.png
+      And click button Continue
+    Then Release rights page should open
+      And thumbnail should be visible
+
+
+  Scenario: Navigate to Describe page
+    When I click Next button at Learn page
+      And upload file image.png
+      And click button Continue
+      And I click This file is my own work
+      And I click Next button at Release rights page
+    Then Describe page should open
+      And title text field should be there
+
+  @ie6-bug @ie7-bug @ie8-bug
+  Scenario: Navigate to Use page
+    When I click Next button at Learn page
+      And upload file image.png
+      And click button Continue
+      And I click This file is my own work
+      And I click Next button at Release rights page
+      And I enter title
+      And I enter description
+      And I enter category
+      And I click Next button at Describe page
+    Then Use page should open
+      And Upload more files button should be there

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1d2f73790f1d94f426569ec296389c2dfa9127a1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Zfilipin <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to