jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/393076 )

Change subject: Port go_browser.feature to nodejs
......................................................................


Port go_browser.feature to nodejs

- introduced TitlePage and moved the title param to it.
  I found it misleading to have a title param for pages like /w/index.php
- added wiki support on World.visit
- added search_steps to reflect what we had with ruby but "browser_steps"
  would probably be more approriate

Change-Id: I6bba0baac4a8f565508eb2b153c0c27a2af8f23c
---
M tests/integration/config/wdio.conf.js
A tests/integration/features/go_browser.feature
M tests/integration/features/step_definitions/page_steps.js
A tests/integration/features/step_definitions/search_steps.js
M tests/integration/features/support/pages/article_page.js
M tests/integration/features/support/pages/page.js
A tests/integration/features/support/pages/search_results_page.js
M tests/integration/features/support/pages/special_version.js
A tests/integration/features/support/pages/title_page.js
M tests/integration/features/support/world.js
10 files changed, 119 insertions(+), 40 deletions(-)

Approvals:
  Cindy-the-browser-test-bot: Looks good to me, but someone else must approve
  EBernhardson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/integration/config/wdio.conf.js 
b/tests/integration/config/wdio.conf.js
index c30dcb2..1af44b6 100644
--- a/tests/integration/config/wdio.conf.js
+++ b/tests/integration/config/wdio.conf.js
@@ -39,17 +39,20 @@
                cirrustest: {
                        username: 'Admin',
                        password: 'vagrant',
-                       apiUrl: 
'http://cirrustest.wiki.local.wmftest.net:8080/w/api.php'
+                       apiUrl: 
'http://cirrustest.wiki.local.wmftest.net:8080/w/api.php',
+                       baseUrl: 'http://cirrustest.wiki.local.wmftest.net:8080'
                },
                commons: {
                        username: 'Admin',
                        password: 'vagrant',
-                       apiUrl: 
'http://commons.wiki.local.wmftest.net:8080/w/api.php'
+                       apiUrl: 
'http://commons.wiki.local.wmftest.net:8080/w/api.php',
+                       baseUrl: 'http://cirrustest.wiki.local.wmftest.net:8080'
                },
                ru: {
                        username: 'Admin',
                        password: 'vagrant',
-                       apiUrl: 
'http://ru.wiki.local.wmftest.net:8080/w/api.php'
+                       apiUrl: 
'http://ru.wiki.local.wmftest.net:8080/w/api.php',
+                       baseUrl: 'http://ru.wiki.local.wmftest.net:8080'
                },
                beta: {},
                test2: {},
@@ -84,7 +87,8 @@
                        relPath('./integration/features/support/world.js'),
                        relPath('./integration/features/support/hooks.js'),
                        
relPath('./integration/features/step_definitions/page_step_helpers.js'),
-                       
relPath('./integration/features/step_definitions/page_steps.js')
+                       
relPath('./integration/features/step_definitions/page_steps.js'),
+                       
relPath('./integration/features/step_definitions/search_steps.js')
                ]
        },
        // Patterns to exclude.
@@ -145,18 +149,6 @@
        //
        // Saves a screenshot to a given path if a command fails.
        screenshotPath: './log/',
-       //
-       // Set a base URL in order to shorten url command calls. If your url 
parameter starts
-       // with "/", then the base url gets prepended.
-       baseUrl: (
-               process.env.MW_SERVER === undefined ?
-                       'http://dev.wiki.local.wmftest.net:8080' :
-                       process.env.MW_SERVER
-       ) + (
-               process.env.MW_SCRIPT_PATH === undefined ?
-                       '/w' :
-                       process.env.MW_SCRIPT_PATH
-       ),
        //
        // Default timeout for all waitFor* commands.
        waitforTimeout: 20000,
diff --git a/tests/integration/features/go_browser.feature 
b/tests/integration/features/go_browser.feature
new file mode 100644
index 0000000..b92d70f
--- /dev/null
+++ b/tests/integration/features/go_browser.feature
@@ -0,0 +1,20 @@
+@clean @go @phantomjs
+Feature: Go Search
+  @from_core
+  Scenario: I can "go" to a user's page whether it is there or not
+    When I go search for User:DoesntExist
+    Then I am on a page titled User:DoesntExist
+
+  @options
+  Scenario Outline: When I near match more than one page but one is exact 
(case, modulo case, or converted to title case) I go to that page
+    When I go search for <term> Nearmatchflattentest
+    Then I am on a page titled <title> Nearmatchflattentest
+  Examples:
+    |      term      |      title      |
+    | bach           | Johann Sebastian Bach |
+    | Søn Redirectnoncompete | Blah Redirectnoncompete |
+    | Soñ Redirectnoncompete | Blah Redirectnoncompete |
+
+  Scenario: Searching for a string that is a valid mediawiki title but longer 
than the max prefix search does not fail
+    When I go search for vdyējūyeyafqhrqtwtfmvvbv不顾要死不活的姑娘风景如小D3:n t q h ra r 
n q r n q n r q r n w t n ran s g是否能Z或者 Ru 
人也不发达噶分湖人奴嗯也能一年时光啊郭德纲)n蜂蜜犹如的还是创始人发布A大股东
+    Then there are no search results
diff --git a/tests/integration/features/step_definitions/page_steps.js 
b/tests/integration/features/step_definitions/page_steps.js
index 7ee0774..9d0430d 100644
--- a/tests/integration/features/step_definitions/page_steps.js
+++ b/tests/integration/features/step_definitions/page_steps.js
@@ -361,4 +361,8 @@
                        return expect( found, msg ).to.be.true;
                } ).call( this );
        } );
+
+       Then(/^I am on a page titled (.*)$/, function( title ) {
+               expect(ArticlePage.articleTitle, `I am on 
${title}`).to.equal(title);
+       } );
 });
diff --git a/tests/integration/features/step_definitions/search_steps.js 
b/tests/integration/features/step_definitions/search_steps.js
new file mode 100644
index 0000000..e72f4cd
--- /dev/null
+++ b/tests/integration/features/step_definitions/search_steps.js
@@ -0,0 +1,15 @@
+/*jshint esversion: 6,  node:true */
+
+const defineSupportCode = require('cucumber').defineSupportCode,
+       SearchResultsPage = require('../support/pages/search_results_page'),
+       expect = require( 'chai' ).expect;
+
+defineSupportCode( function( {Then,When} ) {
+       When( /^I go search for (.*)$/, function ( title ) {
+               return this.visit( SearchResultsPage.search( title ) );
+       } );
+
+       Then( /^there are no search results/, function() {
+               return expect(SearchResultsPage.has_search_results(), 'there 
are no search results').is.false;
+       } );
+});
diff --git a/tests/integration/features/support/pages/article_page.js 
b/tests/integration/features/support/pages/article_page.js
index 8432bde..e1e2d65 100644
--- a/tests/integration/features/support/pages/article_page.js
+++ b/tests/integration/features/support/pages/article_page.js
@@ -1,15 +1,20 @@
 /*jshint esversion: 6,  node:true */
+/*global browser */
 
 // TODO: Incomplete
 // Page showing the article with some actions.  This is the page that everyone
 // is used to reading on wikpedia.  My mom would recognize this page.
 
-var Page = require('./page');
+const TitlePage = require('./title_page');
 
-class ArticlePage extends Page {
+class ArticlePage extends TitlePage {
        constructor(){
                super();
        }
+
+       get articleTitle() {
+               return browser.getText("h1#firstHeading");
+       }
 }
 
 module.exports = new ArticlePage();
\ No newline at end of file
diff --git a/tests/integration/features/support/pages/page.js 
b/tests/integration/features/support/pages/page.js
index 95623b7..9321fde 100644
--- a/tests/integration/features/support/pages/page.js
+++ b/tests/integration/features/support/pages/page.js
@@ -2,13 +2,12 @@
 /*global browser */
 
 /**
- * The Page object contains shortcuts and properties you would expect
- * to find on a wiki page such as title, url.
+ * The Page object contains shortcuts and properties
  */
 
 class Page {
 
-       constructor( title ){
+       constructor( url ){
                // tag selector shortcut.
                // analogous to Ruby's link(:create_link, text: "Create") etc.
                // assuming first param is a selector, second is text.
@@ -46,25 +45,14 @@
                                return elems;
                        };
                } );
-               this._title = title || '';
-               this._url = `/wiki/${this._title}`;
+               this._url = url;
        }
 
        get url() {
                return this._url;
        }
-       set url( title ) {
-               this._url = `/wiki/${title}`;
-       }
-
-       title( title ) {
-               if ( !title ) {
-                       return this._title;
-               } else {
-                       this.url = title;
-                       this._title = title;
-                       return this;
-               }
+       set url( url ) {
+               this._url = url;
        }
 }
 module.exports = Page;
diff --git a/tests/integration/features/support/pages/search_results_page.js 
b/tests/integration/features/support/pages/search_results_page.js
new file mode 100644
index 0000000..aeea196
--- /dev/null
+++ b/tests/integration/features/support/pages/search_results_page.js
@@ -0,0 +1,21 @@
+/*jshint esversion: 6,  node:true */
+/*global browser */
+
+const Page = require('./page');
+
+class SearchResultsPage extends Page {
+       /**
+        * Open the Search results searching for search
+        * @param {string} search
+        */
+       search( search ) {
+               this.url = `/w/index.php?search=${encodeURIComponent(search)}`;
+               return this;
+       }
+
+       has_search_results() {
+               return browser.elements(".searchresults 
p.mw-search-nonefound").value.length === 0;
+       }
+}
+
+module.exports = new SearchResultsPage();
\ No newline at end of file
diff --git a/tests/integration/features/support/pages/special_version.js 
b/tests/integration/features/support/pages/special_version.js
index 207bcc8..53572e4 100644
--- a/tests/integration/features/support/pages/special_version.js
+++ b/tests/integration/features/support/pages/special_version.js
@@ -1,10 +1,10 @@
 /*jshint esversion: 6, node:true */
 
-var Page = require('./page');
+const TitlePage = require('./title_page');
 
-class SpecialVersion extends Page {
-       constructor() {
-               super();
+class SpecialVersion extends TitlePage {
+       constructor( title ) {
+               super( title );
        }
 
        software_table_row( name ) {
diff --git a/tests/integration/features/support/pages/title_page.js 
b/tests/integration/features/support/pages/title_page.js
new file mode 100644
index 0000000..4bed813
--- /dev/null
+++ b/tests/integration/features/support/pages/title_page.js
@@ -0,0 +1,33 @@
+/*jshint esversion: 6,  node:true */
+
+/**
+ * Base page denoting a Title (can be article or special pages).
+ */
+
+const Page = require('./page');
+
+class TitlePage extends Page {
+
+       constructor( title ){
+               super( `/wiki/${title}` );
+               this._title = title || '';
+       }
+
+       get url() {
+               return this._url;
+       }
+       set url( title ) {
+               super.url =  `/wiki/${title}`;
+       }
+
+       title( title ) {
+               if ( !title ) {
+                       return this._title;
+               } else {
+                       this.url = title;
+                       this._title = title;
+                       return this;
+               }
+       }
+}
+module.exports = TitlePage;
diff --git a/tests/integration/features/support/world.js 
b/tests/integration/features/support/world.js
index b99cbba..58e3139 100644
--- a/tests/integration/features/support/world.js
+++ b/tests/integration/features/support/world.js
@@ -157,7 +157,7 @@
        // Shortcut for browser.url(), accepts a Page object
        // as well as a string, assumes the Page object
        // has a url property
-       this.visit = function( page ) {
+       this.visit = function( page, wiki = this.config.wikis.default ) {
                var tmpUrl;
                if ( page instanceof Page && page.url ) {
                        tmpUrl = page.url;
@@ -168,6 +168,7 @@
                if ( !tmpUrl ) {
                        throw Error( `In "World.visit(page)" page is falsy: 
page=${ page }` );
                }
+               tmpUrl = this.config.wikis[wiki].baseUrl + tmpUrl;
                log( `Visiting page: ${tmpUrl}` );
                browser.url( tmpUrl );
                // logs full URL in case of typos, misplaced backslashes.

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6bba0baac4a8f565508eb2b153c0c27a2af8f23c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: DCausse <dcau...@wikimedia.org>
Gerrit-Reviewer: Cindy-the-browser-test-bot <bernhardsone...@gmail.com>
Gerrit-Reviewer: EBernhardson <ebernhard...@wikimedia.org>
Gerrit-Reviewer: Gehel <guillaume.leder...@wikimedia.org>
Gerrit-Reviewer: Smalyshev <smalys...@wikimedia.org>
Gerrit-Reviewer: Tjones <tjo...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to