EBernhardson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/381512 )

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

Port boolean_operators_api.feature to nodejs

Change-Id: Ic48c984de77743d0cb32e9817f91951825f59d24
---
A tests/integration/features/boolean_operators_api.feature
M tests/integration/features/step_definitions/page_steps.js
2 files changed, 58 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/12/381512/1

diff --git a/tests/integration/features/boolean_operators_api.feature 
b/tests/integration/features/boolean_operators_api.feature
new file mode 100644
index 0000000..230268e
--- /dev/null
+++ b/tests/integration/features/boolean_operators_api.feature
@@ -0,0 +1,38 @@
+@boolean_operators @clean @api @setup_main
+Feature: Searches with boolean operators
+  Scenario Outline: -, !, and NOT prohibit words in search results
+    When I api search for <query>
+    Then Catapult is the first api search result
+      But Amazing Catapult is not in the api search results
+  Examples:
+  |        query         |
+  | catapult -amazing    |
+  | -amazing catapult    |
+  | catapult !amazing    |
+  | !amazing catapult    |
+  | catapult NOT amazing |
+  | NOT amazing catapult |
+
+  Scenario Outline: +, &&, and AND require matches but since that is the 
default they don't look like they do anything
+    When I api search for <query>
+    Then Amazing Catapult is the first api search result
+      But Catapult is not in the api search results
+  Examples:
+  |         query         |
+  | +catapult amazing     |
+  | amazing +catapult     |
+  | +amazing +catapult    |
+  | catapult AND amazing  |
+
+  Scenario Outline: OR and || matches docs with either set
+    When I api search for <query>
+    Then Catapult is in the api search results
+      And Two Words is in the api search results
+  Examples:
+  |          query         |
+  | catapult OR África     |
+  | África \|\| catapult   |
+  | catapult OR "África"   |
+  | catapult \|\| "África" |
+  | "África" OR catapult   |
+  | "África" \|\| catapult |
diff --git a/tests/integration/features/step_definitions/page_steps.js 
b/tests/integration/features/step_definitions/page_steps.js
index d889ab9..268a91d 100644
--- a/tests/integration/features/step_definitions/page_steps.js
+++ b/tests/integration/features/step_definitions/page_steps.js
@@ -155,14 +155,19 @@
        Then( /^(.+) is( in)? the ((?:[^ ])+(?: or (?:[^ ])+)*) api search 
result$/, checkApiSearchResultStep );
 
        function apiSearchStep( enableRewrites, qiprofile, offset, lang, 
namespaces, search ) {
-               // JSON.stringify will remove keys that have `undefined` as 
their value
                let options = {
-                       sroffset: offset,
                        srnamespace: (namespaces || "0").split(' '),
-                       uselang: lang,
                        enablerewrites: enableRewrites ? 1 : 0,
-                       srqiprofile: qiprofile ? qiprofile : undefined
                };
+               if ( offset ) {
+                       options.sroffset = offset;
+               }
+               if ( lang ) {
+                       options.uselang = lang;
+               }
+               if ( qiprofile ) {
+                       options.srqiprofile = qiprofile;
+               }
                // This is reset between scenarios
                if ( this.didyoumeanOptions ) {
                        Object.assign(options, this.didyoumeanOptions );
@@ -208,4 +213,15 @@
                        expect( this.apiResponse.query.search 
).to.not.have.lengthOf( 0 );
                } );
        } );
+
+       Then( /^(.+) is( not)? in the api search results$/, function( title, 
not ) {
+               withApi( this, () => {
+                       let titles = this.apiResponse.query.search.map( res => 
res.title );
+                       if ( not ) {
+                               expect( titles ).to.not.include( title );
+                       } else {
+                               expect( titles ).to.include( title );
+                       }
+               } );
+       } );
 });

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic48c984de77743d0cb32e9817f91951825f59d24
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>

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

Reply via email to