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

Change subject: QA: Ensure survey code loaded before testing if survey is 
visible
......................................................................


QA: Ensure survey code loaded before testing if survey is visible

So after managing to replicate browser test failures locally
when running them against beta labs I managed to get them consistently
passing with this minimal change.

It seems testing for ext.quicksurvey.init is not enough as this itself loads
the code for the survey and the code to view it. Since the former is prone to
change we test for the latter as an indication it is okay to run the test.

No sleep needed! Let's put this bug to bed!!!

Bug: T113534
Change-Id: Iffbdd4926cb9041b0c42280e5acd020ddabb952a
---
M tests/browser/features/external_survey.feature
M tests/browser/features/support/step_definitions/common_steps.rb
2 files changed, 17 insertions(+), 0 deletions(-)

Approvals:
  Phuedx: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/browser/features/external_survey.feature 
b/tests/browser/features/external_survey.feature
index ef8f529..3113905 100644
--- a/tests/browser/features/external_survey.feature
+++ b/tests/browser/features/external_survey.feature
@@ -6,6 +6,8 @@
 
   Scenario: External survey is visible with flag
     And I am on the "Quick survey test page stub" page with the external quick 
survey flag enabled
+    And the page has fully loaded
+    And the survey code has fully loaded
     Then I should see the survey
 
   Scenario: External survey is not present without flag when not bucketed
@@ -18,6 +20,7 @@
     And I am bucketed for "external-example-survey"
       And I am on the "Quick survey test page stub" page
       And the page has fully loaded
+      And the survey code has fully loaded
     Then I should see the survey
 
   Scenario: External survey is not present when dismissed
@@ -29,6 +32,7 @@
   Scenario: User can participate in external survey
     And I am on the "Quick survey test page stub" page with the external quick 
survey flag enabled
       And the page has fully loaded
+      And the survey code has fully loaded
       And I see the external survey
     When I answer the external survey in the negative
     Then I get thanks for my external survey feedback
diff --git a/tests/browser/features/support/step_definitions/common_steps.rb 
b/tests/browser/features/support/step_definitions/common_steps.rb
index ed630e3..f3c8ffc 100644
--- a/tests/browser/features/support/step_definitions/common_steps.rb
+++ b/tests/browser/features/support/step_definitions/common_steps.rb
@@ -80,6 +80,19 @@
   end
 end
 
+Then(/^the survey code has fully loaded$/) do
+  on(ArticlePage) do |page|
+    page.wait_until do
+      # Wait for async JS to load and render the survey if applicable
+      script = 'return mw && mw.loader && '\
+        'mw.loader.getState("ext.quicksurveys.views") === "ready";'
+      page.execute_script(script)
+    end
+  end
+end
+
+
+
 Then(/^I should not see the survey$/) do
   expect(on(ArticlePage).survey_element).to_not be_visible
 end

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iffbdd4926cb9041b0c42280e5acd020ddabb952a
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/QuickSurveys
Gerrit-Branch: dev
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Dduvall <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: Zfilipin <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to