MarkTraceur has uploaded a new change for review.
https://gerrit.wikimedia.org/r/190511
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
A tests/browser/features/upload_wizard_copy_metadata.feature
3 files changed, 114 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard
refs/changes/11/190511/1
diff --git a/tests/browser/features/step_definitions/upload_wizard_steps.rb
b/tests/browser/features/step_definitions/upload_wizard_steps.rb
index 7ef8814..2e19120 100644
--- a/tests/browser/features/step_definitions/upload_wizard_steps.rb
+++ b/tests/browser/features/step_definitions/upload_wizard_steps.rb
@@ -45,6 +45,7 @@
end
When(/^I click Next button at Learn page$/) do
+ sleep 1
on(LearnPage).next_element.when_present(15).click
on(LearnPage).wait_for_ajax
end
@@ -54,7 +55,8 @@
end
When(/^I click This file is my own work$/) do
- on(ReleaseRightsPage).select_my_own_work
+ sleep 1
+ on(ReleaseRightsPage).my_own_work_element.when_present.click
end
When(/^I enter category$/) do
@@ -164,3 +166,40 @@
Then(/^a duplicate name error should appear$/) do
on(UploadPage).duplicate_error_element.when_present.should be_visible
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_element
+end
+
+When(/^I check Descriptions$/) do
+ on(DescribePage).check_description_check_element
+end
+
+When(/^I check Date$/) do
+ on(DescribePage).check_date_check_element
+end
+
+When(/^I check Categories$/) do
+ on(DescribePage).check_categories_check_element
+end
+
+When(/^I uncheck Other information$/) do
+ on(DescribePage).uncheck_other_check_element
+end
+
+When(/^I click Copy button$/) do
+ on(DescribePage).copy_element.when_present(15).click
+ sleep 1 # Wait for the copy to finish
+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 title (.+)$/) do |index, title|
+ on(DescribePage).field_value(index, 'title').should == title
+end
diff --git a/tests/browser/features/support/pages/describe_page.rb
b/tests/browser/features/support/pages/describe_page.rb
index 9297ae1..5ab5e07 100644
--- a/tests/browser/features/support/pages/describe_page.rb
+++ b/tests/browser/features/support/pages/describe_page.rb
@@ -26,4 +26,34 @@
page.next_parent_element.span_element(text: "Next")
end
text_field(:title, id: "title0")
+ checkbox(:title_check_element, id: "mwe-upwiz-copy-title")
+ checkbox(:description_check_element, id: "mwe-upwiz-copy-description")
+ checkbox(:date_check_element, id: "mwe-upwiz-copy-date")
+ checkbox(:categories_check_element, id: "mwe-upwiz-copy-categories")
+ checkbox(:other_check_element, 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 field_value(index, fieldname)
+ div = @browser.divs(xpath: ["//div[@class='mwe-upwiz-info-file
ui-helper-clearfix filled'][", "]"].join(index)).first
+ case fieldname
+ when "description"
+ div.textarea(xpath: './/textarea[@class="mwe-upwiz-desc-lang-text
mwe-grow-textarea"]').value
+ when "date"
+ div.text_field(xpath: './/input[@class="mwe-date hasDatepicker"]').value
+ when "category"
+ div.li(xpath: './/li[@class="cat"]').text
+ when "title"
+ div.text_field(xpath: './/input[@class="mwe-title"]').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
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..36560e7
--- /dev/null
+++ b/tests/browser/features/upload_wizard_copy_metadata.feature
@@ -0,0 +1,44 @@
+#
+# 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
+
+ Scenario: Upload more files
+ When 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 enter description
+ And I enter category
+ And I enter date created
+ And I check Title
+ And I check Descriptions
+ And I check Date
+ And I check Categories
+ And I uncheck Other information
+ And I click Copy button
+ Then upload number 2 should have a description
+ And upload number 2 should have a category
+ And upload number 2 should have a date
+ And upload number 2 should have the title Image 02
--
To view, visit https://gerrit.wikimedia.org/r/190511
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I98f984d8b04c451a66c68462b5251ec9d9c6dd00
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits