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

Change subject: Add browser test for "copy file metadata" feature
......................................................................


Add browser test for "copy file metadata" feature

Bug: T89356
Change-Id: I98f984d8b04c451a66c68462b5251ec9d9c6dd00
---
M tests/browser/features/step_definitions/upload_wizard_steps.rb
M tests/browser/features/support/pages/describe_page.rb
M tests/browser/features/support/pages/release_rights_page.rb
A tests/browser/features/upload_wizard_copy_metadata.feature
4 files changed, 150 insertions(+), 1 deletion(-)

Approvals:
  Gilles: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/browser/features/step_definitions/upload_wizard_steps.rb 
b/tests/browser/features/step_definitions/upload_wizard_steps.rb
index c94cdd6..66f1772 100644
--- a/tests/browser/features/step_definitions/upload_wizard_steps.rb
+++ b/tests/browser/features/step_definitions/upload_wizard_steps.rb
@@ -55,7 +55,11 @@
 end
 
 When(/^I click This file is my own work$/) do
-  on(ReleaseRightsPage).select_my_own_work
+  on(ReleaseRightsPage) do |page|
+    page.highlighted_step_heading_element.when_present
+    sleep 0.5 # Sleep because of annoying JS animation
+    page.my_own_work_element.when_present.click
+  end
 end
 
 When(/^I enter category$/) do
@@ -72,6 +76,10 @@
 
 When(/^I enter title$/) do
   on(DescribePage).title = "Title #{Random.new.rand}"
+end
+
+When(/^I enter (\S+) (.+)$/) do |fieldname, value|
+  on(DescribePage).set_field(fieldname, value)
 end
 
 When(/^I navigate to Upload Wizard$/) do
@@ -173,3 +181,46 @@
 When(/^I click Upload more files button at Use page$/) do
   on(UsePage).upload_more_files_element.when_present(15).click
 end
+
+When(/^I click Copy information to all uploads below$/) do
+  on(DescribePage).copy_expand_element.when_present(15).click
+end
+
+When(/^I check Title$/) do
+  on(DescribePage).check_title_check
+end
+
+When(/^I check Descriptions$/) do
+  on(DescribePage).check_description_check
+end
+
+When(/^I check Date$/) do
+  on(DescribePage).check_date_check
+end
+
+When(/^I check Categories$/) do
+  on(DescribePage).check_categories_check
+end
+
+When(/^I click the Copy button$/) do
+  on(DescribePage) do |page|
+    page.copy_element.when_present(15).click
+    page.wait_for_ajax
+  end
+end
+
+Then(/^upload number (\d+) should have a (\S+)$/) do |index, fieldname|
+  on(DescribePage).field_filled?(index, fieldname).should == true
+end
+
+Then(/^upload number (\d+) should have the (\S+) (.+)$/) do |index, fieldname, 
value|
+  on(DescribePage).field_value(index, fieldname).should == value
+end
+
+When(/^I uncheck all of the copy checkboxes$/) do
+  on(DescribePage).title_check_element.when_present(10).uncheck
+  on(DescribePage).description_check_element.when_present(10).uncheck
+  on(DescribePage).date_check_element.when_present(10).uncheck
+  on(DescribePage).categories_check_element.when_present(10).uncheck
+  on(DescribePage).other_check_element.when_present(10).uncheck
+end
diff --git a/tests/browser/features/support/pages/describe_page.rb 
b/tests/browser/features/support/pages/describe_page.rb
index 9297ae1..77ba60d 100644
--- a/tests/browser/features/support/pages/describe_page.rb
+++ b/tests/browser/features/support/pages/describe_page.rb
@@ -26,4 +26,46 @@
     page.next_parent_element.span_element(text: "Next")
   end
   text_field(:title, id: "title0")
+  checkbox(:title_check, id: "mwe-upwiz-copy-title")
+  checkbox(:description_check, id: "mwe-upwiz-copy-description")
+  checkbox(:date_check, id: "mwe-upwiz-copy-date")
+  checkbox(:categories_check, id: "mwe-upwiz-copy-categories")
+  checkbox(:other_check, id: "mwe-upwiz-copy-other")
+  span(:copy_expand) do |page|
+    page.next_parent_element.link_element(text: "Copy information to all 
uploads below ...")
+  end
+  span(:copy) do |page|
+    page.next_parent_element.button_element(id: 
"mwe-upwiz-copy-metadata-button")
+  end
+
+  def div_at_index(index)
+    @browser.divs(xpath: ["//div[@class='mwe-upwiz-info-file 
ui-helper-clearfix filled'][", "]"].join(index)).first
+  end
+
+  def field(index, fieldname)
+    case fieldname
+    when "description" then div_at_index(index).textarea(css: 
'textarea.mwe-upwiz-desc-lang-text')
+    when "date" then div_at_index(index).text_field(css: 'input.mwe-date')
+    when "category" then div_at_index(index).text_field(css: 
'input.categoryInput')
+    when "title" then div_at_index(index).text_field(css: 'input.mwe-title')
+    end
+  end
+
+  def field_value(index, fieldname)
+    if index != '1' && fieldname == 'category'
+      div_at_index(index).li(xpath: './/li[@class="cat"]').text
+    else
+      field(index, fieldname).value
+    end
+  end
+
+  # Check if a field exists and is non-empty for a given filename
+  def field_filled?(index, fieldname)
+    field_value(index, fieldname) != ''
+  end
+
+  # Add value to a field on the first upload
+  def set_field(fieldname, value)
+    field('1', fieldname).value = value
+  end
 end
diff --git a/tests/browser/features/support/pages/release_rights_page.rb 
b/tests/browser/features/support/pages/release_rights_page.rb
index 208dbb3..2eecdfd 100644
--- a/tests/browser/features/support/pages/release_rights_page.rb
+++ b/tests/browser/features/support/pages/release_rights_page.rb
@@ -24,4 +24,5 @@
     page.next_parent_element.span_element(text: "Next")
   end
   div(:thumbnail, id: "mwe-upwiz-deeds-thumbnails")
+  li(:highlighted_step_heading, xpath: 
"//ul[@id='mwe-upwiz-steps']/li[@id='mwe-upwiz-step-deeds'][@class='arrow 
head']")
 end
diff --git a/tests/browser/features/upload_wizard_copy_metadata.feature 
b/tests/browser/features/upload_wizard_copy_metadata.feature
new file mode 100644
index 0000000..4512644
--- /dev/null
+++ b/tests/browser/features/upload_wizard_copy_metadata.feature
@@ -0,0 +1,55 @@
+#
+# 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
+#
+
+# IMPORTANT: For scenarios which set a preference, tag as @preferenceSet to
+# reset to defaults after they are finished. (See support/hooks.rb)
+
+@chrome @commons.wikimedia.beta.wmflabs.org @firefox @login 
@test2.wikipedia.org
+Feature: UploadWizard
+
+  Background:
+    Given I am logged in
+      And my Preferences Skip tutorial box is unchecked
+    When I navigate to Upload Wizard
+      And I click Next button at Learn page
+      And I add file image.png
+      And I add file image2.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 click Copy information to all uploads below
+      And I uncheck all of the copy checkboxes
+
+  Scenario: Copy description
+    When I enter description Testing 1 2 3
+      And I check Descriptions
+      And I click the Copy button
+    Then upload number 2 should have the description Testing 1 2 3
+
+  Scenario: Copy category
+    When I enter category Testing 4 5 6
+      And I check Categories
+      And I click the Copy button
+    Then upload number 2 should have the category Testing 4 5 6
+
+  Scenario: Copy date
+    When I enter date 1990-04-28
+      And I check Date
+      And I click the Copy button
+    Then upload number 2 should have the date 1990-04-28
+
+  Scenario: Copy title
+    When I enter title This is a test file
+      And I check Title
+      And I click the Copy button
+    Then upload number 2 should have the title This is a test file 02
+      And upload number 1 should have the title This is a test file 01

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I98f984d8b04c451a66c68462b5251ec9d9c6dd00
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
Gerrit-Reviewer: Gilles <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to