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

Change subject: QA: Add browser tests for ajax pages
......................................................................


QA: Add browser tests for ajax pages

Also enable ajax loading on Firefox so that this can be tested
in browser tests.

Note once test is marked as wip and thus fails

Change-Id: I64c70678309d74a9bb542df80d04e310a93e8b8c
---
M javascripts/externals/epoch.js
M tests/browser/README.mediawiki
A tests/browser/features/page_loading.feature
M tests/browser/features/step_definitions/common_article_steps.rb
M tests/browser/features/step_definitions/common_steps.rb
M tests/browser/features/step_definitions/editor_steps.rb
M tests/browser/features/step_definitions/search_steps.rb
M tests/browser/features/support/pages/article_page.rb
8 files changed, 63 insertions(+), 6 deletions(-)

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



diff --git a/javascripts/externals/epoch.js b/javascripts/externals/epoch.js
index 6eb106c..dd7322e 100644
--- a/javascripts/externals/epoch.js
+++ b/javascripts/externals/epoch.js
@@ -12,6 +12,8 @@
        function isBrowserSupported( ua ) {
                // http://caniuse.com/history
                return (
+                       // Firefox 4.0+
+                       ua.match( /Firefox\/[4-9]\.|Firefox\/[1-9][1-9]*\./ ) ||
                        // Chrome browser 5-9
                        ua.match( /Chrome\/[5-9]\./ ) ||
                        // Chrome 10+
diff --git a/tests/browser/README.mediawiki b/tests/browser/README.mediawiki
index de2f980..5fd7b56 100644
--- a/tests/browser/README.mediawiki
+++ b/tests/browser/README.mediawiki
@@ -8,9 +8,13 @@
 * Create an account and store the username in MEDIAWIKI_USER which has
 an edit count of greater than 0
 * Ensure the Main Page has languages enabled
-* Ensure there is a Barack Obama article with the content
+* Ensure an article called "Foo bar" (without quotes) exists and is not 
protected
+* Ensure there is a Barack Obama article
+** and it is a protected page
+** and it has the content:
 * Ensure you have [//www.mediawiki.org/wiki/Extension:ConfirmEdit 
Extension:ConfirmEdit] installed
 ** and setup with FancyCaptcha
+
 <pre>
   == Presidential_campaigns ==
   Test
diff --git a/tests/browser/features/page_loading.feature 
b/tests/browser/features/page_loading.feature
new file mode 100644
index 0000000..77da887
--- /dev/null
+++ b/tests/browser/features/page_loading.feature
@@ -0,0 +1,24 @@
[email protected] @test2.m.wikipedia.org
+Feature: Loading pages
+
+# In stable pages are loaded the standard way via links.
+Scenario: Page loads without ajax in stable
+  Given I am logged in as a new user
+    And I visit a protected page
+    And I click the placeholder search box
+    And I type into search box Foo bar
+  When I click a search result
+  Then The edit button is enabled
+    And The text of the first heading is "Foo bar"
+
+# In alpha mode pages are loaded via JavaScript and ajax.
+@wip
+Scenario: Edit button updates when lazy load a page from search
+  Given I am in alpha mode
+    And I am logged in as a new user
+    And I visit a protected page
+    And I click the placeholder search box
+    And I type into search box Foo bar
+  When I click a search result
+  Then The edit button is enabled
+    And The text of the first heading is "Foo bar"
diff --git a/tests/browser/features/step_definitions/common_article_steps.rb 
b/tests/browser/features/step_definitions/common_article_steps.rb
index 69452b8..07df711 100644
--- a/tests/browser/features/step_definitions/common_article_steps.rb
+++ b/tests/browser/features/step_definitions/common_article_steps.rb
@@ -41,3 +41,7 @@
 Then(/^I see a toast confirmation$/) do
   on(ArticlePage).toast_element.when_present.should be_visible
 end
+
+Then(/^The text of the first heading is "(.*)"$/) do |title|
+  on(ArticlePage).first_heading_element.when_present.text.should match title
+end
diff --git a/tests/browser/features/step_definitions/common_steps.rb 
b/tests/browser/features/step_definitions/common_steps.rb
index 139f138..722d405 100644
--- a/tests/browser/features/step_definitions/common_steps.rb
+++ b/tests/browser/features/step_definitions/common_steps.rb
@@ -104,6 +104,11 @@
   visit(HomePage)
 end
 
+Given(/^I visit a protected page$/) do
+  # FIXME: Assumes Barack Obama article is protected
+  step 'I am on the Barack_Obama article'
+end
+
 When(/^I click the browser back button$/) do
   on(ArticlePage).back
 end
diff --git a/tests/browser/features/step_definitions/editor_steps.rb 
b/tests/browser/features/step_definitions/editor_steps.rb
index e50e832..d8096fd 100644
--- a/tests/browser/features/step_definitions/editor_steps.rb
+++ b/tests/browser/features/step_definitions/editor_steps.rb
@@ -1,5 +1,9 @@
+Then(/^The edit button is enabled$/) do
+  on(ArticlePage).edit_button_element.when_present.class_name.should match 
"enabled"
+end
+
 When(/^I click the edit button$/) do
-  on(ArticlePage).edit_button_element.when_present.click
+  on(ArticlePage).edit_link_element.when_present.click
 end
 
 Then(/^I see the editor$/) do
diff --git a/tests/browser/features/step_definitions/search_steps.rb 
b/tests/browser/features/step_definitions/search_steps.rb
index 11afff8..a4032d1 100644
--- a/tests/browser/features/step_definitions/search_steps.rb
+++ b/tests/browser/features/step_definitions/search_steps.rb
@@ -26,3 +26,7 @@
 Then(/^I don't see the search overlay$/) do
   on(ArticlePage).search_overlay_element.should_not be_visible
 end
+
+When(/^I click a search result$/) do
+  on(ArticlePage).search_result_element.when_present.click
+end
diff --git a/tests/browser/features/support/pages/article_page.rb 
b/tests/browser/features/support/pages/article_page.rb
index 3fc0ebb..17fbbf0 100644
--- a/tests/browser/features/support/pages/article_page.rb
+++ b/tests/browser/features/support/pages/article_page.rb
@@ -3,8 +3,10 @@
 
   include URL
   page_url URL.url("<%=params[:article_name]%>")
+  h1(:first_heading, id: "section_0")
 
-  a(:edit_button, text: "Edit")
+  li(:edit_button, id: "ca-edit")
+  a(:edit_link, text: "Edit")
   div(:editor_overlay, class: "editor-overlay")
   button(:editor_overlay_close_button) do |page|
     page.editor_overlay_element.button_element(class: "cancel")
@@ -23,15 +25,19 @@
     page.upload_button_element.link_element(href: '#/upload-tutorial/article')
   end
 
+  # search
   text_field(:search_box_placeholder, name: "search", index: 0)
   text_field(:search_box2, name: "search", index: 1)
   li(:search_results, title: "Barack Obama")
-  a(:search_result) do |page|
-    page.search_results_element.element.a
-  end
   div(:search_overlay, class: "search-overlay")
   button(:search_overlay_close_button) do |page|
     page.search_overlay_element.button_element(class: "cancel")
+  end
+  ul(:search_overlay_page_list) do |page|
+    page.search_overlay_element.element.ul(class: "page-list thumbs 
actionable")
+  end
+  a(:search_result) do |page|
+    page.search_overlay_page_list_element.element.a
   end
 
   a(:notifications_button, id: "secondary-button", class: "user-button")
@@ -44,6 +50,7 @@
   span(:pres_campaign_section, id:"Presidential_campaigns")
   a(:ext_whitehouse_link, href: 
"http://www.whitehouse.gov/administration/president_obama/";)
   a(:image_link, class:"image")
+
 
   # page-actions
   ul(:page_actions, id:"page-actions")
@@ -62,4 +69,7 @@
 
   # toast
   div(:toast, class:'toast position-fixed visible')
+
+  #loader
+  div(:content_wrapper, id:'content_wrapper')
 end

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I64c70678309d74a9bb542df80d04e310a93e8b8c
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to