Jdlrobson has uploaded a new change for review.

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

Change subject: Talk browser test should check JS has loaded before continuing
......................................................................

Talk browser test should check JS has loaded before continuing

When testing Sam's MobileFormatter changes there were a few browser
test failures around this scenario due to the page not completely
loading. This change asserts that the JS that enhances the talk button
has fully loaded.

Other changes:
* Given we now use this method in 3 places I've generalised this
into a separate rule so other browser tests can make use of it

Change-Id: I575f4d44ed9f18872710605482c1438a4a8385f8
---
M tests/browser/features/step_definitions/common_steps.rb
M tests/browser/features/step_definitions/notification_steps.rb
M tests/browser/features/step_definitions/ui_links_steps.rb
M tests/browser/features/talk.feature
4 files changed, 15 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/58/310458/1

diff --git a/tests/browser/features/step_definitions/common_steps.rb 
b/tests/browser/features/step_definitions/common_steps.rb
index 6710eac..f2ce36e 100644
--- a/tests/browser/features/step_definitions/common_steps.rb
+++ b/tests/browser/features/step_definitions/common_steps.rb
@@ -12,6 +12,18 @@
   end
 end
 
+Given(/^the module "(.*?)" has loaded$/) do |module_name|
+  on(ArticlePage) do |page|
+    page.wait_until do
+      # Wait for JS to hijack standard link
+      # TODO: If this approach works well, we should implement general
+      # `wait_for_resource` and `resource_ready?` helper methods in
+      # mw-selenium, and document this pattern on mw.org
+      browser.execute_script("return mw.loader.getState('#{module_name}') === 
'ready'")
+    end
+  end
+end
+
 Given /^I am logged in as a new user$/ do
   step 'I am on the "Main Page" page'
   step 'I click on "Log in" in the main navigation menu'
diff --git a/tests/browser/features/step_definitions/notification_steps.rb 
b/tests/browser/features/step_definitions/notification_steps.rb
index d73cec0..0a70e18 100644
--- a/tests/browser/features/step_definitions/notification_steps.rb
+++ b/tests/browser/features/step_definitions/notification_steps.rb
@@ -1,13 +1,6 @@
 When /^I click on the notification icon$/ do
+  step 'the module "skins.minerva.notifications" has loaded'
   on(ArticlePage) do |page|
-    page.wait_until do
-      # Wait for JS to hijack standard link
-      # TODO: If this approach works well, we should implement general
-      # `wait_for_resource` and `resource_ready?` helper methods in
-      # mw-selenium, and document this pattern on mw.org
-      browser.execute_script("return 
mw.loader.getState('skins.minerva.notifications') === 'ready'")
-    end
-
     page.notifications_button_element.when_present.click
   end
 end
diff --git a/tests/browser/features/step_definitions/ui_links_steps.rb 
b/tests/browser/features/step_definitions/ui_links_steps.rb
index 8d0d77d..27c4e52 100644
--- a/tests/browser/features/step_definitions/ui_links_steps.rb
+++ b/tests/browser/features/step_definitions/ui_links_steps.rb
@@ -8,11 +8,7 @@
 
 Then(/^I should see the link to the user page of the last editor$/) do
   # T132753
-  on(ArticlePage) do |page|
-    page.wait_until do
-      browser.execute_script("return 
mw.loader.getState('skins.minerva.scripts') === 'ready'")
-    end
-  end
+  step 'the module "skins.minerva.scripts" has loaded'
   expect(on(ArticlePage).last_modified_bar_history_userpage_link_element).to 
be_visible
 end
 
diff --git a/tests/browser/features/talk.feature 
b/tests/browser/features/talk.feature
index 48c2aa0..c601d46 100644
--- a/tests/browser/features/talk.feature
+++ b/tests/browser/features/talk.feature
@@ -29,6 +29,7 @@
     Given the page "Talk:Selenium talk test" exists
       And I am logged in as a user with a > 5 edit count
       And the page "Selenium talk test" exists
+      And the module "skins.minerva.talk" has loaded
     When I click the talk button
     Then there should be an add discussion button
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I575f4d44ed9f18872710605482c1438a4a8385f8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>

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

Reply via email to