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

Change subject: Fix browser tests in Chrome
......................................................................


Fix browser tests in Chrome

I tried to avoid sleeps as best I could, but some seem unavoidable.
Also removed some duplicated code that was already in a more
appropriate spot.

Bug: T86770
Change-Id: I74cd149bbd72a1c9eba1bcb4a8b06005c8996ae7
---
M resources/ui/uw.ui.Step.js
M resources/ui/uw.ui.Wizard.js
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/learn_page.rb
M tests/browser/features/support/pages/upload_page.rb
M tests/browser/features/support/pages/use_page.rb
M tests/browser/features/upload_wizard.feature
M tests/browser/features/upload_wizard_copy_metadata.feature
M tests/browser/features/upload_wizard_more_files.feature
10 files changed, 72 insertions(+), 104 deletions(-)

Approvals:
  Gilles: Looks good to me, approved
  MarkTraceur: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/resources/ui/uw.ui.Step.js b/resources/ui/uw.ui.Step.js
index 21b4c98..93eda3a 100644
--- a/resources/ui/uw.ui.Step.js
+++ b/resources/ui/uw.ui.Step.js
@@ -41,6 +41,8 @@
         * Move to the step.
         */
        SP.moveTo = function () {
+               // Remove the initial spinner if it's still present
+               $( '#mwe-first-spinner' ).remove();
                this.$div.show();
                $( '#mwe-upwiz-steps' ).arrowStepsHighlight( this.$arrow );
        };
diff --git a/resources/ui/uw.ui.Wizard.js b/resources/ui/uw.ui.Wizard.js
index ea479ce..e270305 100644
--- a/resources/ui/uw.ui.Wizard.js
+++ b/resources/ui/uw.ui.Wizard.js
@@ -30,14 +30,9 @@
 
                this.wizard = wizard;
 
-               // remove first spinner
-               $( '#mwe-first-spinner' ).remove();
-
                this.initHeader( mw.UploadWizard.config );
 
                this.initButtons();
-
-               this.initTutorial();
        }
 
        oo.mixinClass( UploadWizardInterface, oo.EventEmitter );
@@ -161,53 +156,6 @@
                $( '.mwe-upwiz-button-home' )
                        .click( function () { window.location.href = 
mw.config.get( 'wgArticlePath' ).replace( '$1', '' ); } );
 
-       };
-
-       /**
-        * Initialize the tutorial page interface.
-        */
-       UWIP.initTutorial = function () {
-               var ui = this;
-
-               // Event handlers for EventLogging-type things
-               // Skip tutorial checkbox click
-               $( '#mwe-upwiz-skip' )
-                       // Add a friendly "Here's how to get it back" tooltip 
for users who check the "Skip next time" checkbox
-                       .tipsy( {
-                               title: function () {
-                                       return mw.message(
-                                               
'mwe-upwiz-tooltip-skiptutorial',
-                                               mw.config.get( 'wgServer' ) + 
mw.util.getUrl( 'Special:Preferences' ) + '#mw-prefsection-uploads',
-                                               mw.message( 'prefs-uploads' 
).escaped(),
-                                               mw.message( 
'prefs-upwiz-interface' ).escaped()
-                                       ).parse();
-                               },
-                               delayIn: 0,
-                               html: true,
-                               trigger: 'manual'
-                       } )
-
-                       .click( function () {
-                               var $this = $( this );
-
-                               ui.emit( 'skip-tutorial-click', $this.prop( 
'checked' ) );
-
-                               if ( $this.prop( 'checked' ) ) {
-                                       $this.tipsy( 'show' );
-                               } else {
-                                       $this.tipsy( 'hide' );
-                               }
-                       } );
-
-               // Helpdesk link click
-               $( '#mwe-upwiz-tutorial-helpdesk' ).click( function () {
-                       ui.emit( 'helpdesk-click' );
-               } );
-
-               // handler for next button
-               $( '#mwe-upwiz-stepdiv-tutorial .mwe-upwiz-button-next').click( 
function () {
-                       ui.emit( 'next-from-tutorial' );
-               } );
        };
 
        ui.Wizard = UploadWizardInterface;
diff --git a/tests/browser/features/step_definitions/upload_wizard_steps.rb 
b/tests/browser/features/step_definitions/upload_wizard_steps.rb
index 66f1772..0da0029 100644
--- a/tests/browser/features/step_definitions/upload_wizard_steps.rb
+++ b/tests/browser/features/step_definitions/upload_wizard_steps.rb
@@ -28,6 +28,7 @@
     page.upload_wizard_pref_tab_element.when_present.click
     page.uncheck_reset_skip_checkbox
     page.preferences_save_button_element.click
+    page.wait_for_ajax
   end
 end
 
@@ -35,30 +36,53 @@
   on(UploadPage).continue_element.when_present(15).click
 end
 
-When(/^I click Next button$/) do
-  on(UploadWizardPage).next_element.when_present(15).click
+When(/^I click the Next button at the Describe page$/) do
+  on(DescribePage) do |page|
+    page.next_element.click
+    page.wait_for_ajax
+  end
 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.when_present(15).click
+When(/^I click the Skip checkbox$/) do
+  on(LearnPage) do |page|
+    page.highlighted_step_heading_element.when_present
+    if @browser.driver.browser == :chrome
+      # ChromeDriver can't click on the element because of a bug in the driver
+      # related to automatic scrolling to out-of-view elements taking time
+      # Reported here: https://code.google.com/p/selenium/issues/detail?id=8528
+      @browser.execute_script("$( '#mwe-upwiz-skip' ).click();")
+    else
+      page.check_tutorial_skip
+    end
+  end
 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
+When(/^I click the Next button at the Learn page$/) do
+  on(LearnPage) do |page|
+    page.highlighted_step_heading_element.when_present
+    if @browser.driver.browser == :chrome
+      # Same Chrome issue as above
+      @browser.execute_script("$( '#mwe-upwiz-stepdiv-tutorial 
.mwe-upwiz-button-next' ).click();")
+    else
+      page.next_element.click
+    end
+    page.wait_for_ajax
+  end
 end
 
-When(/^I click Next button at Release rights page$/) do
-  on(ReleaseRightsPage).next_element.when_present(15).click
+When(/^I click the Next button at the Release rights page$/) do
+  on(ReleaseRightsPage) do |page|
+    page.next_element.click
+    page.wait_for_ajax # Clicking Next fetches data about each file through 
AJAX
+  end
 end
 
 When(/^I click This file is my own work$/) do
   on(ReleaseRightsPage) do |page|
     page.highlighted_step_heading_element.when_present
-    sleep 0.5 # Sleep because of annoying JS animation
+    sleep 0.5 # Sleep because of annoying JS animation happening in this menu
     page.my_own_work_element.when_present.click
+    sleep 0.5 # Sleep because of annoying JS animation happening in this menu
   end
 end
 
@@ -66,8 +90,9 @@
   on(DescribePage).category = "Test"
 end
 
-When(/^I enter date created$/) do
+When(/^I enter date$/) do
   on(DescribePage).date_created = "11/4/2014"
+  sleep 0.5 # Sleep because of annoying JS animation happening in the date 
picker
 end
 
 When(/^I enter description$/) do
@@ -96,10 +121,6 @@
   uploads.length.should eql(count)
 end
 
-When(/^I click the Skip checkbox$/) do
-  on(LearnPage).check_tutorial_skip
-end
-
 When(/^I add file (\S+)$/) do |filename|
   shade = Random.new.rand(255)
   width = Random.new.rand(255)
@@ -117,7 +138,9 @@
 end
 
 When(/^I remove file (.+)$/) do |filename|
-  on(UploadPage).remove_file(filename)
+  on(UploadPage) do |page|
+    page.remove_file(filename)
+  end
 end
 
 When(/^I wait for the upload interface to be present$/) do
@@ -148,25 +171,18 @@
   @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).upload_more_files_element.when_present(30).should be_visible
+  on(UsePage) do |page|
+    page.highlighted_step_heading_element.when_present(15)
+    page.upload_more_files_element.when_present.should be_visible
+  end
 end
 
 Then(/^Upload page should appear$/) do
-  @browser.url.should match /Special:UploadWizard/
-end
-
-Then(/^Use page should open$/) do
-  on(UsePage)
   @browser.url.should match /Special:UploadWizard/
 end
 
diff --git a/tests/browser/features/support/pages/describe_page.rb 
b/tests/browser/features/support/pages/describe_page.rb
index 77ba60d..cfc53bd 100644
--- a/tests/browser/features/support/pages/describe_page.rb
+++ b/tests/browser/features/support/pages/describe_page.rb
@@ -18,6 +18,7 @@
   end
   page_url url
 
+  li(:highlighted_step_heading, xpath: 
"//ul[@id='mwe-upwiz-steps']/li[@id='mwe-upwiz-step-details'][@class='arrow 
head']")
   text_field(:category, id: "categories0")
   text_field(:date_created, id: "dateInput0")
   textarea(:description, name: /^description/)
diff --git a/tests/browser/features/support/pages/learn_page.rb 
b/tests/browser/features/support/pages/learn_page.rb
index 63fabe6..ad1844e 100644
--- a/tests/browser/features/support/pages/learn_page.rb
+++ b/tests/browser/features/support/pages/learn_page.rb
@@ -21,4 +21,5 @@
     page.tutorial_element.span_element(text: "Next")
   end
   checkbox(:tutorial_skip, id: "mwe-upwiz-skip")
+  li(:highlighted_step_heading, xpath: 
"//ul[@id='mwe-upwiz-steps']/li[@id='mwe-upwiz-step-tutorial'][@class='arrow 
head']")
 end
diff --git a/tests/browser/features/support/pages/upload_page.rb 
b/tests/browser/features/support/pages/upload_page.rb
index acb9fbc..07d9bb3 100644
--- a/tests/browser/features/support/pages/upload_page.rb
+++ b/tests/browser/features/support/pages/upload_page.rb
@@ -20,7 +20,7 @@
 
   span(:continue, text: "Continue")
   p(:duplicate_error, text: /You are already uploading/)
-  div(:select_file_control_to_wait_for, class: 'mwe-upwiz-file-ctrl-container')
+  div(:select_file_control_to_wait_for, class: "mwe-upwiz-file-ctrl-container")
 
   # We need to keep track of all the uploads on the page.
   # PageObjects are bad at finding elements that are repeated and change.
@@ -49,7 +49,7 @@
         fileInput: uploadDiv.file_field(xpath: './/input[@type="file"]'),
         indicator: uploadDiv.div(xpath: 
'.//div[contains(@class,"mwe-upwiz-file-indicator")]'),
         fileName: uploadDiv.div(xpath: 
'.//div[contains(@class,"mwe-upwiz-visible-file-filename-text")]').text.strip,
-        removeCtrl: uploadDiv.div(xpath: 
'.//div[contains(@class,"mwe-upwiz-remove-ctrl")]')
+        removeCtrl: uploadDiv.div(xpath: 
'.//div[contains(@class,"mwe-upwiz-remove-ctrl-msg")]')
       }
     end
   end
diff --git a/tests/browser/features/support/pages/use_page.rb 
b/tests/browser/features/support/pages/use_page.rb
index 76a76f2..1b9ab69 100644
--- a/tests/browser/features/support/pages/use_page.rb
+++ b/tests/browser/features/support/pages/use_page.rb
@@ -19,4 +19,5 @@
   page_url url
 
   span(:upload_more_files, text: "Upload more files")
+  li(:highlighted_step_heading, xpath: 
"//ul[@id='mwe-upwiz-steps']/li[@id='mwe-upwiz-step-thanks'][@class='head']")
 end
diff --git a/tests/browser/features/upload_wizard.feature 
b/tests/browser/features/upload_wizard.feature
index 3c1c408..b6e53f7 100644
--- a/tests/browser/features/upload_wizard.feature
+++ b/tests/browser/features/upload_wizard.feature
@@ -27,35 +27,35 @@
 
   Scenario: Skip tutorial
     When I click the Skip checkbox
-      And I click Next button at Learn page
+      And I click the Next button at the Learn page
       And I navigate to Upload Wizard
     Then the tutorial should not be visible
 
   Scenario: Navigate to Upload page
-    When I click Next button at Learn page
+    When I click the Next button at the Learn page
     Then Upload page should appear
 
   Scenario: Navigate to Release rights page
-    When I click Next button at Learn page
+    When I click the Next button at the Learn page
       And I add file image.png
       And click button Continue
     Then Release rights page should open
       And thumbnail should be visible
 
   Scenario: Add two files
-    When I click Next button at Learn page
+    When I click the Next button at the Learn page
       And I add file image.png
       And I add file image2.png
     Then there should be 2 uploads
 
   Scenario: Add and remove file
-    When I click Next button at Learn page
+    When I click the Next button at the Learn page
       And I add file image.png
       And I remove file image.png
     Then there should be 0 uploads
 
   Scenario: Add two and remove one
-    When I click Next button at Learn page
+    When I click the Next button at the Learn page
       And I add file image.png
       And I add file image2.png
       And I add file image3.png
@@ -65,30 +65,29 @@
      And there should be an upload for image3.png
 
   Scenario: Same name, different content
-    When I click Next button at Learn page
+    When I click the Next button at the Learn page
       And I add file image.png with 50% black, 50px x 50px
       And I add file image.png with 100% black, 100px x 70px
     Then a duplicate name error should appear
 
   Scenario: Navigate to Describe page
-    When I click Next button at Learn page
+    When I click the Next button at the Learn page
       And I add 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 click the Next button at the Release rights page
     Then Describe page should open
       And title text field should be there
 
   Scenario: Navigate to Use page
-    When I click Next button at Learn page
+    When I click the Next button at the Learn page
       And I add 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 click the Next button at the Release rights page
       And I enter title
       And I enter description
       And I enter category
-      And I enter date created
-      And I click Next button at Describe page
-    Then Use page should open
-      And Upload more files button should be there
+      And I enter date
+      And I click the Next button at the Describe page
+    Then Upload more files button should be there
diff --git a/tests/browser/features/upload_wizard_copy_metadata.feature 
b/tests/browser/features/upload_wizard_copy_metadata.feature
index 4512644..149f3ee 100644
--- a/tests/browser/features/upload_wizard_copy_metadata.feature
+++ b/tests/browser/features/upload_wizard_copy_metadata.feature
@@ -20,12 +20,12 @@
     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 click the Next button at the 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 the Next button at the Release rights page
       And I click Copy information to all uploads below
       And I uncheck all of the copy checkboxes
 
diff --git a/tests/browser/features/upload_wizard_more_files.feature 
b/tests/browser/features/upload_wizard_more_files.feature
index fe5d357..51fec3d 100644
--- a/tests/browser/features/upload_wizard_more_files.feature
+++ b/tests/browser/features/upload_wizard_more_files.feature
@@ -22,16 +22,16 @@
     When I navigate to Upload Wizard
 
   Scenario: Upload more files
-    When I click Next button at Learn page
+    When I click the Next button at the Learn page
       And I add 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 click the Next button at the Release rights page
       And I enter title
       And I enter description
       And I enter category
-      And I enter date created
-      And I click Next button at Describe page
+      And I enter date
+      And I click the Next button at the Describe page
       And I click Upload more files button at Use page
       And I wait for the upload interface to be present
       And I add file image3.png

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I74cd149bbd72a1c9eba1bcb4a8b06005c8996ae7
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Gilles <[email protected]>
Gerrit-Reviewer: GergÅ‘ Tisza <[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