jenkins-bot has submitted this change and it was merged. Change subject: QA: Add tests for lead photo and uploads workflows ......................................................................
QA: Add tests for lead photo and uploads workflows Add new feature tests features/lead_photo_uploads.feature features/uploads.feature Rename feature for uploading from uploads page to distinguish from lead photo uploads Change-Id: If1e24c8e1342f8be664830b7e8dba0a72bc51f6a --- M tests/browser/README.mediawiki A tests/browser/features/lead_photo_uploads.feature M tests/browser/features/step_definitions/common_steps.rb A tests/browser/features/step_definitions/lead_photo_steps.rb M tests/browser/features/step_definitions/uploads_steps.rb A tests/browser/features/support/pages/lead_photo_page.rb M tests/browser/features/support/pages/uploads_page.rb R tests/browser/features/upload_page_upload_image.feature D tests/browser/features/uploads.feature A tests/browser/features/uploads_page_new_user_tutorials.feature 10 files changed, 150 insertions(+), 21 deletions(-) Approvals: Kaldari: Looks good to me, approved jenkins-bot: Verified diff --git a/tests/browser/README.mediawiki b/tests/browser/README.mediawiki index f051c6f..994c45b 100644 --- a/tests/browser/README.mediawiki +++ b/tests/browser/README.mediawiki @@ -1,3 +1,13 @@ += Setup = +Unfortunately there are various tweaks you will need to make to any +instance you run these tests against See +[https://bugzilla.wikimedia.org/show_bug.cgi?id=56057 bug 56057]. + +These include: +* Create an account Selenium_newuser which has an edit count of 0 +* Create an account and store the username in MEDIAWIKI_USER which has +an edit count of greater than 0 + = MobileFrontend Extension = For general information about MobileFrontend Extension please see @@ -29,6 +39,10 @@ export MEDIAWIKI_PASSWORD=<password here> # Linux/Unix/Mac set MEDIAWIKI_PASSWORD=<password here> # Windows +In addition to this create another user which will be reserved for new uploads +"Selenium_newuser". The password for this user should be the same as +MEDIAWIKI_PASSWORD + Run the tests from the MobileFrontend directory with: make cucumber diff --git a/tests/browser/features/lead_photo_uploads.feature b/tests/browser/features/lead_photo_uploads.feature new file mode 100644 index 0000000..97f821d --- /dev/null +++ b/tests/browser/features/lead_photo_uploads.feature @@ -0,0 +1,45 @@ [email protected] @en.m.wikipedia.org @login @test2.m.wikipedia.org +Feature: Uploading a lead photo + # Stable: New user scenarios + Scenario: There is an upload button + Given I am logged in as a new user + When I go to a page with no lead photo + Then There is an upload an image to this page button + And The upload an image to this page button is enabled + + # Stable: +1 edit user scenarios + Scenario: See Upload Overlay when click on upload button + Given I am logged in as a user with a > 0 edit count + When I go to a page with no lead photo + And I upload Mobile file image.png on LeadPhotoPage + Then I see the old upload overlay + + # Beta: new user scenarios + Scenario: There is an upload button + Given I am logged in as a new user + Given I am in beta mode + When I go to a page with no lead photo + Then There is an upload an image to this page button + And The upload an image to this page button is enabled + + Scenario: See tutorial as new user + Given I am logged in as a new user + Given I am in beta mode + When I go to a page with no lead photo + Then The upload button in page actions links to the tutorial + + # Beta: +1 edit user scenarios + Scenario: There is an upload button + Given I am logged in as a new user + Given I am in beta mode + When I go to a page with no lead photo + Then There is an upload an image to this page button + And The upload an image to this page button is enabled + + Scenario: See Upload Overlay when click on upload button + Given I am logged in as a user with a > 0 edit count + Given I am in beta mode + When I go to a page with no lead photo + And I upload Mobile file image.png on LeadPhotoPage + Then I see the upload overlay + And I can enter a description for my file upload diff --git a/tests/browser/features/step_definitions/common_steps.rb b/tests/browser/features/step_definitions/common_steps.rb index c192047..6b17b6e 100644 --- a/tests/browser/features/step_definitions/common_steps.rb +++ b/tests/browser/features/step_definitions/common_steps.rb @@ -20,6 +20,24 @@ end end +Given /^I am logged in as a new user$/ do + visit(HomePage) do |page| + page.mainmenu_button_element.when_present.click + page.login_button + end + # FIXME: Actually create a new user instead of using an existing one + on(LoginPage).login_with("Selenium_newuser", ENV["MEDIAWIKI_PASSWORD"]) +end + +Given(/^I am logged in as a user with a > (\d+) edit count$/) do |arg1| + visit(HomePage) do |page| + page.mainmenu_button_element.when_present.click + page.login_button + end + # FIXME: Guarantee that MEDIAWIKI_USER has an edit count of > 0 + on(LoginPage).login_with(ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"]) +end + Given /^I am in beta mode$/ do visit(BetaPage) do |page| page.beta_element.click @@ -34,3 +52,7 @@ When /^I go to random page$/ do visit(RandomPage) end + +When(/^I go to a page with no lead photo$/) do + visit(LeadPhotoPage) +end diff --git a/tests/browser/features/step_definitions/lead_photo_steps.rb b/tests/browser/features/step_definitions/lead_photo_steps.rb new file mode 100644 index 0000000..9b0ad64 --- /dev/null +++ b/tests/browser/features/step_definitions/lead_photo_steps.rb @@ -0,0 +1,23 @@ +Then(/^There is an upload an image to this page button$/) do + on(LeadPhotoPage).upload_button_element.should exist +end + +Then(/^The upload an image to this page button is enabled$/) do + on(LeadPhotoPage).upload_button_element.when_present.class_name.should match "enabled" +end + +Then(/^The upload button in page actions links to the tutorial$/) do + on(LeadPhotoPage).tutorial_link_element.when_present.should exist +end + +Then(/^I see the upload overlay$/) do + on(LeadPhotoPage).upload_overlay_element.when_present.should exist +end + +Then(/^I see the old upload overlay$/) do + on(LeadPhotoPage).old_upload_overlay_element.when_present.should exist +end + +Then(/^I can enter a description for my file upload$/) do + on(LeadPhotoPage).description_textarea_element.when_present.should exist +end diff --git a/tests/browser/features/step_definitions/uploads_steps.rb b/tests/browser/features/step_definitions/uploads_steps.rb index 809f75e..946c843 100644 --- a/tests/browser/features/step_definitions/uploads_steps.rb +++ b/tests/browser/features/step_definitions/uploads_steps.rb @@ -1,11 +1,3 @@ -Given /^I am logged in as a new user$/ do - visit(HomePage) do |page| - page.mainmenu_button_element.when_present.click - page.login_button - end - on(LoginPage).login_with("Selenium_newuser", ENV["MEDIAWIKI_PASSWORD"]) -end - When(/^I click Submit$/) do on(UploadsPage).submit_button_element.when_present.click end @@ -18,14 +10,14 @@ on(UploadsPage).description_textarea_element.when_present.send_keys("Describing with #{@random_string}") end -When(/^I upload Mobile file (.+)$/) do |file_name| +When(/^I upload Mobile file (.+) on (.+)$/) do |file_name, page| 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 - on(UploadsPage).select_file_element.send_keys(path) + on(page).select_file_element.send_keys(path) end Then(/^I see a blue tutorial screen$/) do @@ -41,10 +33,15 @@ page.wait_until(10) do page.text.include? "#{@random_string}" #Chrome needs this, FF does not end - page.uploaded_image_link_element.when_present.href.should match "#{@random_string}" + page.uploaded_image_link_element.when_present.attribute( 'href' ).should match "#{@random_string}" end end Then(/^The Contribute an image button is visible$/) do on(UploadsPage).contribute_image_element.should be_visible end + +Then(/^The upload button links to the tutorial$/) do + # use should match as href will be relative/absolute url + on(UploadsPage).tutorial_link_element.when_present.attribute( 'href' ).should match "#/upload-tutorial/uploads$" +end diff --git a/tests/browser/features/support/pages/lead_photo_page.rb b/tests/browser/features/support/pages/lead_photo_page.rb new file mode 100644 index 0000000..9ad0b91 --- /dev/null +++ b/tests/browser/features/support/pages/lead_photo_page.rb @@ -0,0 +1,20 @@ +class LeadPhotoPage + include PageObject + include URL + page_url URL.url("This page needs a lead photo") + + # upload buttons + li(:upload_button, id: "ca-upload") + a(:tutorial_link) do |page| + page.upload_button_element.link_element(href: '#/upload-tutorial/article') + end + file_field(:select_file, name: 'file', type: 'file') + + #old upload overlay + div(:old_upload_overlay, class:"mw-mf-overlay") + + # upload overlay + div(:upload_overlay, class:"overlay photo-overlay") + text_area(:description_textarea, name: "description") +end + diff --git a/tests/browser/features/support/pages/uploads_page.rb b/tests/browser/features/support/pages/uploads_page.rb index 71204bd..c4139e1 100644 --- a/tests/browser/features/support/pages/uploads_page.rb +++ b/tests/browser/features/support/pages/uploads_page.rb @@ -4,10 +4,12 @@ page_url URL.url("Special:Uploads") div(:contribute_image, class: "button photo") + # This may seem confusing but one is a DIV and one is an A tag + a(:tutorial_link, class: "button photo") text_area(:description_textarea, name: "description") button(:next_button, class: "next") file_field(:select_file, name: 'file') button(:submit_button, text: "Submit") div(:tutorial, class: "mw-mf-overlay carousel tutorial") a(:uploaded_image_link, class: "image") -end \ No newline at end of file +end diff --git a/tests/browser/features/upload_image.feature b/tests/browser/features/upload_page_upload_image.feature similarity index 85% rename from tests/browser/features/upload_image.feature rename to tests/browser/features/upload_page_upload_image.feature index 894ded4..2ef1111 100644 --- a/tests/browser/features/upload_image.feature +++ b/tests/browser/features/upload_page_upload_image.feature @@ -4,7 +4,7 @@ Scenario: Upload image file Given I am logged into the mobile website And I select Uploads - When I upload Mobile file image.png + When I upload Mobile file image.png on UploadsPage And I type a description And I click Submit Then my image is on the Uploads page diff --git a/tests/browser/features/uploads.feature b/tests/browser/features/uploads.feature deleted file mode 100644 index a0d2ff8..0000000 --- a/tests/browser/features/uploads.feature +++ /dev/null @@ -1,8 +0,0 @@ [email protected] @en.m.wikipedia.org @login @test2.m.wikipedia.org -Feature: Special:Uploads - - Scenario: See tutorial as new user - Given I am logged in as a new user - When I go to uploads page - Then I see a blue tutorial screen - And I see a next button diff --git a/tests/browser/features/uploads_page_new_user_tutorials.feature b/tests/browser/features/uploads_page_new_user_tutorials.feature new file mode 100644 index 0000000..4913e05 --- /dev/null +++ b/tests/browser/features/uploads_page_new_user_tutorials.feature @@ -0,0 +1,14 @@ [email protected] @en.m.wikipedia.org @login @test2.m.wikipedia.org +Feature: Special:Uploads + + Scenario: See tutorial as new user + Given I am logged in as a new user + When I go to uploads page + Then I see a blue tutorial screen + And I see a next button + + Scenario: Link to tutorial for new user in beta + Given I am logged in as a new user + And I am in beta mode + When I go to uploads page + Then The upload button links to the tutorial -- To view, visit https://gerrit.wikimedia.org/r/105106 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If1e24c8e1342f8be664830b7e8dba0a72bc51f6a Gerrit-PatchSet: 12 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Jdlrobson <[email protected]> Gerrit-Reviewer: Cmcmahon <[email protected]> Gerrit-Reviewer: JGonera <[email protected]> Gerrit-Reviewer: Jdlrobson <[email protected]> Gerrit-Reviewer: Kaldari <[email protected]> Gerrit-Reviewer: Zfilipin <[email protected]> Gerrit-Reviewer: jenkins-bot <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
