Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

update UploadWizard spec and config from Mark Holmquist

  • Loading branch information...
commit ceac06adbe800d2ff76ed8b0a46e448a436a878a 1 parent 2afe0cb
@chrismcmahon authored
Showing with 118 additions and 38 deletions.
  1. +7 −0 config.yml
  2. +111 −38 spec/upload_wizard/upload_wizard_spec.rb
View
7 config.yml
@@ -0,0 +1,7 @@
+tests:
+ username: User
+ password: Pass
+ site_address: https://commons.wikimedia.org/wiki/
+ files:
+ never_uploaded: /path/to/first/unique/file
+ another_never_uploaded: /path/to/second/unique/file
View
149 spec/upload_wizard/upload_wizard_spec.rb
@@ -1,27 +1,29 @@
-
require 'spec_helper'
+require 'yaml'
describe "Manipulating Special:UploadWizard" do
-
-
context "Log in is required" do
- it "should have a link to log in" do
+ it "should have a link to log in and have correct login credentials" do
visit_page(UploadWizardPage)
- @current_page.logged_in
- @current_page.text.should include "Log in / create account"
- on_page(LoginPage).login_with('user', 'pass')
- end
+ @current_page.logged_in
+ @current_page.text.should include "Log in / create account"
+ config = YAML.load_file('config.yml')
+ username = config['tests']['username']
+ password = config['tests']['password']
+ on_page(LoginPage).login_with(username, password)
end
-
+ end
+
context "Navigate to UW should work after login" do
it "should be on UW" do
visit_page(UploadWizardPage)
+ @current_page.text.include? "Thanks for using our new upload tool!Help with translations"
@current_page.tutorial_map.should be_true
end
end
-
+
context "Check Learn screen elements and navigate to Upload" do
- it"should have a skip box and a Next" do
+ it "should have a skip box and a Next" do
on_page(UploadWizardPage) do |page|
page.skip_radio_element.when_visible
page.check_skip_radio
@@ -32,19 +34,24 @@
end
end
end
-
+
context "Upload a file and check license info" do
it "should make all license choices available upon upload" do
- on_page(UploadWizardPage) do |@page|
- @page.select_file="/Users/christophermcmahon/Desktop/uke.jpg"
+ on_page(UploadWizardPage) do |arg|
+ @page = arg
+
+ config = YAML.load_file('config.yml')
+ files = config['tests']['files']
+ @page.select_file = files['never_uploaded']
+
#sleep 5
#refactor these waits
- @page.wait_until do
+ @page.wait_until(20) do
@page.text.include? "All uploads were successful!"
end
@page.continue_button
#own work
- @page.wait_until do
+ @page.wait_until(5) do
@page.text.include? "This site requires you to provide copyright information for this work, to make sure everyone can legally reuse it"
end
@page.select_own_work_button
@@ -53,12 +60,12 @@
@page.next_element.should be_true
@page.author_element.should be_true
@page.different_license
-
+
#refactor this, see below
@page.legal_code_cc_sa3_element.should be_true
@page.legal_code_cca3_element.should be_true
@page.legal_code_cc_waiver_element.should be_true
-
+
@page.select_cca_sa
@page.select_cca3
@page.select_cc_cc
@@ -71,14 +78,14 @@
@page.us_govt
@page.not_mentioned
@page.found_it
-
- #refactor this
+
+ #refactor this
@page.legal_code_cc_sa3_element.should be_true
@page.legal_code_cca3_element.should be_true
@page.legal_code_cc_waiver_element.should be_true
@page.legal_code_cc_sa25_element.should be_true
@page.legal_code_cca25_element.should be_true
-
+
@page.believe_free_selected?
@page.select_cca_sa3
@page.select_cca_sa2
@@ -95,49 +102,115 @@
@page.select_free_form
@page.free_lic_element.should be_true
end
- end
+ end
end
-
+
context "Source and Author are required" do
it "should display error messages for empty Source and Author fields" do
- on_page(UploadWizardPage) do |@page|
+ on_page(UploadWizardPage) do |arg|
+ @page = arg
@page.next_button_element.click
# improve this, like a regex for "glob:This field is required*Source*This field is required*Author"
- @page.wait_until do
+ @page.wait_until(5) do
@page.text.include? "This field is required"
end
#@page.text.should include "This field is required"
end
end
end
-
+
context "Title, Description, etc. are in place" do
it "should be able to type into Title, Description, check language and category link" do
- on_page(UploadWizardPage) do |@page|
+ on_page(UploadWizardPage) do |arg|
+ @page = arg
@page.own_work_button_element.click
@page.next_button_element.click
- @page.wait_until do
+ @page.wait_until(5) do
@page.text.include? "Description"
end
+
+ @page.title_field_element.click
+ @page.title_field_element.clear
+ @page.title_field_element.send_keys "DSC_002"
+ @page.title_label_element.click
+# This test is broken.
+# @page.wait_until(5) do
+# # There are two possible values, depending on the blacklist entries for the site.
+# @page.text.include? "Please choose a different, descriptive title." or @page.text.include? "Please make this title more meaningful."
+# end
+
@page.title_field_element.send_keys("Automated test title")
@page.description_field_element.send_keys("Automated testing created this description")
@page.language.should include "English"
- @page.date_created_element.send_keys("Autamated test")
+ @page.date_created_element.send_keys("Automated test")
@page.categories.should be_true
@page.add_categories_element.send_keys("Automated test")
+ @page.latitude_element.click
@page.latitude_element.send_keys("Automated test")
+ @page.longitude_element.click
+ @page.text.should include "The latitude needs to be between -90 and 90"
@page.longitude_element.send_keys("Automated test")
- @page.altitude_element.send_keys("Automated test")
- @page.other_information_element.send_keys("Automated test")
- @page.wait_until do
- @page.text.include? "The latitude needs to be between -90 and 90"
- end
+ @page.other_information_element.click
@page.text.should include "The longitude needs to be between -180 and 180"
- @page.text.should include "The altitude needs to be a number"
+ @page.other_information_element.send_keys("Automated test")
+ end
+ end
+ end
+
+ context "Navigate to UW should still work after previous tests" do
+ it "should be on UW" do
+ on_page(UploadWizardPage) do |newpage|
+ # Prevent alert from firing
+ newpage.browser.execute_script 'window.onbeforeunload = function () {};'
+ end
+ visit_page(UploadWizardPage)
+ on_page(UploadWizardPage) do |newpage|
+ newpage.tutorial_map.should be_true
+ newpage.next_element.click
end
end
end
-
-
+
+ context "Upload two files and check messages" do
+ it "should pluralize messages properly with multiple files" do
+ on_page(UploadWizardPage) do |arg|
+ @page = arg
+
+ config = YAML.load_file('config.yml')
+ files = config['tests']['files']
+ @page.select_file = files['never_uploaded']
+
+ @page.wait_until(5) do
+ @page.text.include? "All uploads were successful!"
+ end
+
+ @page.select_file = files['another_never_uploaded']
+
+ @page.wait_until(5) do
+ @page.text.include? "All uploads were successful!"
+ end
+
+ @page.continue_button
+ #own work
+ @page.wait_until(5) do
+ @page.text.include? "This site requires you to provide copyright information for these works, to make sure everyone can legally reuse them"
+ end
+ @page.select_own_work_button
+ @page.text.should include "the copyright holder of these works, irrevocably grant anyone the right to use these works under the Creative Commons Attribution ShareAlike 3.0 license"
+
+ # I don't really care about the copyright stuff in this test, I already made sure it worked before.
+ @page.select_cca_sa
+ @page.next_button_element.click
+
+ @page.wait_until(5) do
+ @page.text.include? "Description"
+ end
+
+ @page.categories.should be_true
+
+ @page.copymeta.should be_true
+ @page.text.should include 'Copy title'
+ end
+ end
end
-
+end
Please sign in to comment.
Something went wrong with that request. Please try again.