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

Change subject: Port full_text_advanced.feature to node
......................................................................


Port full_text_advanced.feature to node

Change-Id: Ic1d27ee0be2b14c1ff3e6d4901be61e084d845ab
---
A tests/integration/features/full_text_advanced.feature
M tests/integration/features/step_definitions/search_steps.js
M tests/integration/features/support/pages/search_results_page.js
3 files changed, 105 insertions(+), 8 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/features/full_text_advanced.feature 
b/tests/integration/features/full_text_advanced.feature
new file mode 100644
index 0000000..03d0a08
--- /dev/null
+++ b/tests/integration/features/full_text_advanced.feature
@@ -0,0 +1,34 @@
+@clean @phantomjs @setup_main @setup_namespaces
+Feature: Full text search advanced features
+  Background:
+    Given I am at the search results page
+
+  Scenario Outline: Main search with non-advanced clicky features
+    When I click the <filter> link
+      And I search for <term>
+    Then I am on a page titled Search results
+      And <first_result> is the first search result
+  Examples:
+    | filter                 | term         | first_result     |
+    | Content pages          | catapult     | Catapult         |
+    | Content pages          | smoosh       | none             |
+    | Content pages          | nothingasdf  | none             |
+    | Multimedia             | catapult     | none             |
+    | Multimedia             | smoosh       | none             |
+    | Multimedia             | nothingasdf  | File:Nothingasdf |
+    | Everything             | catapult     | Catapult         |
+    | Everything             | smoosh       | Help:Smoosh      |
+    | Everything             | nothingasdf  | File:Nothingasdf |
+
+  Scenario Outline: Main search with advanced clicky features
+    When I click the Advanced link
+      And I click the (Main) or (Article) label
+      And I click the <filters> labels
+      And I search for <term>
+    Then I am on a page titled Search results
+      And <first_result> is the first search result
+  Examples:
+    | filters             | term     | first_result   |
+    | Talk, Help          | catapult | Talk:Two Words |
+    | Help, Help talk     | catapult | none           |
+    | (Main) or (Article) | catapult | Catapult       |
diff --git a/tests/integration/features/step_definitions/search_steps.js 
b/tests/integration/features/step_definitions/search_steps.js
index 2e2a7aa..3a3adc9 100644
--- a/tests/integration/features/step_definitions/search_steps.js
+++ b/tests/integration/features/step_definitions/search_steps.js
@@ -3,9 +3,10 @@
 const defineSupportCode = require('cucumber').defineSupportCode,
        SearchResultsPage = require('../support/pages/search_results_page'),
        ArticlePage = require('../support/pages/article_page'),
+       TitlePage = require('../support/pages/title_page'),
        expect = require( 'chai' ).expect;
 
-defineSupportCode( function( {Then,When} ) {
+defineSupportCode( function( {Then,When,Given} ) {
        When( /^I go search for (.*)$/, function ( title ) {
                return this.visit( SearchResultsPage.search( title ) );
        } );
@@ -37,8 +38,28 @@
 
        Then( /^(.*) is the first search result$/, function (result) {
                let msg = `${result} is the first search result`;
-               expect(SearchResultsPage.is_on_srp(), msg).to.equal(true);
-               expect(SearchResultsPage.has_search_results(), 
msg).to.equal(true);
-               expect(SearchResultsPage.get_result_at(1), msg).to.equal( 
result );
+               if ( result === "none" ) {
+                       expect(SearchResultsPage.has_search_results(), 
msg).to.equal(false);
+               } else {
+                       expect(SearchResultsPage.is_on_srp(), 
msg).to.equal(true);
+                       expect(SearchResultsPage.has_search_results(), 
msg).to.equal(true);
+                       expect(SearchResultsPage.get_result_at(1), 
msg).to.equal(result);
+               }
+       } );
+
+       Given( /^I am at the search results page$/, function() {
+               this.visit( new TitlePage( 'Special:Search' ) );
+       } );
+
+       When( /^I click the (.*) link$/, function( filter ) {
+               SearchResultsPage.click_filter( filter );
+       } );
+
+       When( /^I click the (.*) labels?$/, function( filter ) {
+               let and_labels = filter.split(/, /, 10);
+               for ( let labels of and_labels ) {
+                       let or_labels = labels.split(/ or /, 10);
+                       SearchResultsPage.select_namespaces( or_labels, true );
+               }
        } );
 });
diff --git a/tests/integration/features/support/pages/search_results_page.js 
b/tests/integration/features/support/pages/search_results_page.js
index e870642..3083c56 100644
--- a/tests/integration/features/support/pages/search_results_page.js
+++ b/tests/integration/features/support/pages/search_results_page.js
@@ -32,8 +32,8 @@
        }
 
        is_on_srp() {
-               // Q: why selecting form.search div.mw-search-top-table does 
not work?
-               return browser.elements("form#search 
div#mw-search-top-table").value.length > 0;
+               return browser.elements("form#search 
div#mw-search-top-table").value.length > 0 ||
+                       browser.elements("form#powersearch 
div#mw-search-top-table").value.length > 0;
        }
 
        set search_query(search ) {
@@ -45,11 +45,53 @@
        }
 
        get_result_at( nth ) {
-               return browser.getText( `ul.mw-search-results li 
div.mw-search-result-heading a[data-serp-pos=\"${nth-1}\"]` );
+               return browser.getAttribute( `ul.mw-search-results li 
div.mw-search-result-heading a[data-serp-pos=\"${nth-1}\"]`, 'title' );
        }
 
        click_search() {
-               browser.click( "#simpleSearch #searchButton" );
+               let forms = ['form#powersearch', 'form#search'];
+               for( let form of forms ) {
+                       let elt = browser.element( form );
+                       if ( elt.value ) {
+                               elt.click('button[type="submit"]');
+                               return;
+                       }
+               }
+               throw new Error("Cannot click the search button, are you on the 
Search page?");
+       }
+
+       /**
+        * @param {string} filter
+        */
+       click_filter( filter ) {
+               let linkSel = `a=${filter}`;
+               browser.element( 'div.search-types' ).click( linkSel );
+       }
+
+       /**
+        * @param {Array.<string>} namespaceLabels
+        * @param {boolean} first true to select first, false to select all
+        */
+       select_namespaces( namespaceLabels, first ) {
+               let elt = browser.element( 'form#powersearch 
fieldset#mw-searchoptions' );
+               if ( !elt.value ) {
+                       throw new Error( "Cannot find the namespace filters, 
did you click on 'Advanced' first?" );
+               }
+               for ( let nsLabel of namespaceLabels ) {
+                       let labelSel = `label=${nsLabel}`;
+                       let label = elt.element( labelSel );
+                       if ( label.value ) {
+                               label.click();
+                               if ( first ) {
+                                       return;
+                               }
+                       } else if ( !first ) {
+                               throw new Error( `Count not find namespace 
labeled as ${nsLabel}` );
+                       }
+               }
+               if ( first ) {
+                       throw new Error( `Count not find any namespace link 
labeled as ${namespaceLabels.join()}` );
+               }
        }
 }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic1d27ee0be2b14c1ff3e6d4901be61e084d845ab
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: DCausse <[email protected]>
Gerrit-Reviewer: Cindy-the-browser-test-bot <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Gehel <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: Tjones <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to