Gilles has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/192607

Change subject: Set the preferences via the API when not testing the 
preferences page
......................................................................

Set the preferences via the API when not testing the preferences page

Bug: T87462
Change-Id: If594e90ea91fdc3b65b528c273da7592ddd783c4
---
M tests/browser/features/step_definitions/upload_wizard_steps.rb
A tests/browser/features/support/pages/main_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
M tests/browser/features/upload_wizard_preferences.feature
6 files changed, 44 insertions(+), 39 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/07/192607/1

diff --git a/tests/browser/features/step_definitions/upload_wizard_steps.rb 
b/tests/browser/features/step_definitions/upload_wizard_steps.rb
index 365af53..d8369d7 100644
--- a/tests/browser/features/step_definitions/upload_wizard_steps.rb
+++ b/tests/browser/features/step_definitions/upload_wizard_steps.rb
@@ -23,7 +23,14 @@
   visit LogoutPage
 end
 
-Given(/^my Preferences Skip tutorial box is unchecked$/) do
+Given(/^I set my preference to skip the tutorial$/) do
+  on(MainPage) do |page|
+    @browser.execute_script("var api = new mw.Api(); api.postWithToken( 
'options', { action: 'options', change: 'upwiz_skiptutorial=1' } ).done( 
function() { $( '<div id=\"cucumber-tutorial-preference-set\">&nbsp;</div>' 
).appendTo( 'body' ); } );")
+    page.tutorial_preference_set_element.when_present
+  end
+end
+
+When(/^I unset Skip introductory licensing tutorial in my Preferences$/) do
   visit(PreferencesPage) do |page|
     page.upload_wizard_pref_tab_element.when_present.click
     page.uncheck_reset_skip_checkbox
@@ -37,6 +44,7 @@
     page.upload_wizard_pref_tab_element.when_present.click
     page.select_own_cc_zero_radio
     page.preferences_save_button_element.click
+    page.wait_for_ajax
   end
 end
 
@@ -45,6 +53,7 @@
     page.upload_wizard_pref_tab_element.when_present.click
     page.select_thirdparty_nasa_radio
     page.preferences_save_button_element.click
+    page.wait_for_ajax
   end
 end
 
@@ -53,6 +62,7 @@
     page.upload_wizard_pref_tab_element.when_present.click
     page.select_default_radio
     page.preferences_save_button_element.click
+    page.wait_for_ajax
   end
 end
 
diff --git a/tests/browser/features/support/pages/main_page.rb 
b/tests/browser/features/support/pages/main_page.rb
new file mode 100644
index 0000000..5594c6d
--- /dev/null
+++ b/tests/browser/features/support/pages/main_page.rb
@@ -0,0 +1,7 @@
+class MainPage
+  include PageObject
+  include URL
+
+  page_url URL.url('Main_Page')
+  div(:tutorial_preference_set, id: "cucumber-tutorial-preference-set")
+end
diff --git a/tests/browser/features/upload_wizard.feature 
b/tests/browser/features/upload_wizard.feature
index b6e53f7..c0e7971 100644
--- a/tests/browser/features/upload_wizard.feature
+++ b/tests/browser/features/upload_wizard.feature
@@ -18,45 +18,27 @@
 
   Background:
     Given I am logged in
-      And my Preferences Skip tutorial box is unchecked
+      And I set my preference to skip the tutorial
     When I navigate to Upload Wizard
 
-  Scenario: Navigate to Learn page
-    Then Learn page should appear
-      And Skip this step in the future checkbox should be there
-
-  Scenario: Skip tutorial
-    When I click the Skip checkbox
-      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 the Next button at the Learn page
-    Then Upload page should appear
-
   Scenario: Navigate to Release rights page
-    When I click the Next button at the Learn page
-      And I add file image.png
+    When 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 the Next button at the Learn page
-      And I add file image.png
+    When 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 the Next button at the Learn page
-      And I add file image.png
+    When 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 the Next button at the Learn page
-      And I add file image.png
+    When I add file image.png
       And I add file image2.png
       And I add file image3.png
       And I remove file image2.png
@@ -65,14 +47,12 @@
      And there should be an upload for image3.png
 
   Scenario: Same name, different content
-    When I click the Next button at the Learn page
-      And I add file image.png with 50% black, 50px x 50px
+    When 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 the Next button at the Learn page
-      And I add file image.png
+    When I add file image.png
       And click button Continue
       And I click This file is my own work
       And I click the Next button at the Release rights page
@@ -80,8 +60,7 @@
       And title text field should be there
 
   Scenario: Navigate to Use page
-    When I click the Next button at the Learn page
-      And I add file image.png
+    When I add file image.png
       And click button Continue
       And I click This file is my own work
       And I click the Next button at the Release rights page
diff --git a/tests/browser/features/upload_wizard_copy_metadata.feature 
b/tests/browser/features/upload_wizard_copy_metadata.feature
index 149f3ee..691fa97 100644
--- a/tests/browser/features/upload_wizard_copy_metadata.feature
+++ b/tests/browser/features/upload_wizard_copy_metadata.feature
@@ -18,9 +18,8 @@
 
   Background:
     Given I am logged in
-      And my Preferences Skip tutorial box is unchecked
+      And I set my preference to skip the tutorial
     When I navigate to Upload Wizard
-      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
diff --git a/tests/browser/features/upload_wizard_more_files.feature 
b/tests/browser/features/upload_wizard_more_files.feature
index 51fec3d..68708ae 100644
--- a/tests/browser/features/upload_wizard_more_files.feature
+++ b/tests/browser/features/upload_wizard_more_files.feature
@@ -18,12 +18,11 @@
 
   Background:
     Given I am logged in
-      And my Preferences Skip tutorial box is unchecked
+      And I set my preference to skip the tutorial
     When I navigate to Upload Wizard
 
   Scenario: Upload more files
-    When I click the Next button at the Learn page
-      And I add file image.png
+    When I add file image.png
       And click button Continue
       And I click This file is my own work
       And I click the Next button at the Release rights page
diff --git a/tests/browser/features/upload_wizard_preferences.feature 
b/tests/browser/features/upload_wizard_preferences.feature
index 66c0ade..9b3c5ae 100644
--- a/tests/browser/features/upload_wizard_preferences.feature
+++ b/tests/browser/features/upload_wizard_preferences.feature
@@ -14,12 +14,25 @@
 
   Background:
     Given I am logged in
-      And my Preferences Skip tutorial box is unchecked
+      And I set my preference to skip the tutorial
+
+  Scenario: Set license preference to show the tutorial
+    When I unset Skip introductory licensing tutorial in my Preferences
+      And I navigate to Upload Wizard
+    Then Learn page should appear
+      And Skip this step in the future checkbox should be there
+
+  Scenario: Skip tutorial
+    When I unset Skip introductory licensing tutorial in my Preferences
+      And I navigate to Upload Wizard
+      And I click the Skip checkbox
+      And I click the Next button at the Learn page
+      And I navigate to Upload Wizard
+    Then the tutorial should not be visible
 
   Scenario: Set license preference to Own work - Creative Commons CC0 Waiver
     When I set the default license to Own work - Creative Commons CC0 Waiver 
in my Preferences
       And I navigate to Upload Wizard
-      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
@@ -31,7 +44,6 @@
   Scenario: Set license preference to Someone else's work - Original work of 
NASA
     When I set the default license to Someone else's work - Original work of 
NASA in my Preferences
       And I navigate to Upload Wizard
-      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
@@ -42,7 +54,6 @@
   Scenario: Set license preference to Use whatever the default is
     When I set the default license to Use whatever the default is in my 
Preferences
       And I navigate to Upload Wizard
-      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

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If594e90ea91fdc3b65b528c273da7592ddd783c4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Gilles <gdu...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to