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

Change subject: Port bad_syntax_api.features to nodejs
......................................................................

Port bad_syntax_api.features to nodejs

Change-Id: I6fc234a31bb6cd11ef6eea3a3d1130180285b32f
---
A tests/integration/features/bad_syntax_api.feature
M tests/integration/features/step_definitions/page_steps.js
M tests/integration/features/support/hooks.js
3 files changed, 173 insertions(+), 0 deletions(-)


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

diff --git a/tests/integration/features/bad_syntax_api.feature 
b/tests/integration/features/bad_syntax_api.feature
new file mode 100644
index 0000000..d2506aa
--- /dev/null
+++ b/tests/integration/features/bad_syntax_api.feature
@@ -0,0 +1,104 @@
+@bad_syntax @clean @api
+Feature: Searches with syntax errors
+  @setup_main
+  Scenario: Searching for <text>~<text> treats the tilde like a space except 
that the whole "word" (including tilde) makes a phrase search
+    When I api search for ffnonesenseword~catapult
+    Then Two Words is the first api search result
+
+ @setup_main
+  Scenario: Searching for <text>~<text> treats the tilde like a space (not 
finding any results if a fuzzy search was needed)
+    When I api search for ffnonesensewor~catapult
+    Then none is the first api search result
+
+  @balance_quotes
+  Scenario Outline: Searching for for a phrase with a hanging quote adds the 
quote automatically
+    When I api search for <term>
+    Then Two Words is the first api search result
+   Examples:
+    |                      term                     |
+    | "two words                                    |
+    | "two words" "ffnonesenseword catapult         |
+    | "two words" "ffnonesenseword catapult pickles |
+    | "two words" pickles "ffnonesenseword catapult |
+
+  @balance_quotes
+  Scenario Outline: Searching for a phrase containing /, :, and \" find the 
page as expected
+    Given a page named <title> exists
+    When I api search for <term>
+    Then <title> is the first api search result
+  Examples:
+    |                        term                       |                   
title                   |
+    | "10.1093/acprof:oso/9780195314250.003.0001"       | 
10.1093/acprof:oso/9780195314250.003.0001 |
+    | "10.5194/os-8-1071-2012"                          | 
10.5194/os-8-1071-2012                    |
+    | "10.7227/rie.86.2"                                | 10.7227/rie.86.2     
                     |
+    | "10.7227\"yay"                                    | 10.7227"yay          
                     |
+    | intitle:"1911 Encyclopædia Britannica/Dionysius"' | 1911 Encyclopædia 
Britannica/Dionysius    |
+
+  Scenario: searching for NOT something will not crash (technically it should 
bring up the most linked document, but this isn't worth checking)
+    When I api search for NOT catapult
+    Then there is an api search result
+
+  Scenario Outline: searching for less than and greater than doesn't find tons 
and tons of tokens
+    When I api search for <query>
+    Then none is the first api search result
+  Examples:
+    | query |
+    | <}    |
+    | <=}   |
+    | >.    |
+    | >=.   |
+    | >     |
+    | <     |
+    | >>    |
+    | <>    |
+    | <>=   |
+    | >>>   |
+    | <<<   |
+    | <<<~  |
+
+  @filters
+  Scenario Outline: Empty filters work like terms but aren't in test data so 
aren't found
+    When I api search for <term>
+       Then none is the first api search result
+  Examples:
+    |         term           |
+    | intitle:"" catapult    |
+    | incategory:"" catapult |
+    | intitle:               |
+    | intitle:""             |
+    | incategory:            |
+    | incategory:""          |
+    | hastemplate:           |
+    | hastemplate:""         |
+
+  Scenario Outline: Searching with a / doesn't cause a degraded search result
+    When I api search for main <term>
+    Then Main Page is the first api search result
+  Examples:
+    |      term      |
+    | intitle:/page  |
+    | Main/Page      |
+
+  @exact_quotes @setup_main
+  Scenario: Searching for "<word> <word>"~<not a numer> treats the ~ as a space
+    When I api search for "ffnonesenseword catapult"~anotherword
+      And Two Words is the first api search result
+
+  Scenario Outline: Searching for special whitespaces returns no result
+    When I api search for <specialwhitespaces>
+    Then none is the first api search result
+  Examples:
+    |     specialwhitespaces     |
+    | %{\u3000}%                 |
+    | %{\u0009}%%{\u3000}%       |
+    | %{\u0009}% %{\u3000}%      |
+    | %ideographic_whitespace%   |
+
+  @boolean_operators
+  Scenario Outline: ORs and ANDs around phrase prefixes finds the search terms
+    When I api search for "test catapul*" <operator> "test catapul*" 
<operator> "test catapul*"
+    Then there are no errors reported by the api
+  Examples:
+    | operator |
+    | AND      |
+    | OR       |
diff --git a/tests/integration/features/step_definitions/page_steps.js 
b/tests/integration/features/step_definitions/page_steps.js
index c53b403..d889ab9 100644
--- a/tests/integration/features/step_definitions/page_steps.js
+++ b/tests/integration/features/step_definitions/page_steps.js
@@ -197,4 +197,15 @@
                } );
        } );
 
+       Then( /there are no errors reported by the api/, function () {
+               withApi( this, () => {
+                       expect( this.apiError ).to.be.undefined;
+               } );
+       } );
+
+       Then( /there is an api search result/, function () {
+               withApi( this, () => {
+                       expect( this.apiResponse.query.search 
).to.not.have.lengthOf( 0 );
+               } );
+       } );
 });
diff --git a/tests/integration/features/support/hooks.js 
b/tests/integration/features/support/hooks.js
index fd94196..7be4bd3 100644
--- a/tests/integration/features/support/hooks.js
+++ b/tests/integration/features/support/hooks.js
@@ -124,4 +124,62 @@
                        } );
                } );
        } );
+
+       BeforeOnce( { tags: "@setup_main or @filters or @prefix or @bad_syntax 
or @wildcard or @exact_quotes or @phrase_prefix" }, function () {
+               let batchJobs = {
+                       edit: {
+                               "Template:Template Test": "pickles 
[[Category:TemplateTagged]]",
+                               "Catapult/adsf": "catapult subpage 
[[Catapult]]",
+                               "Links To Catapult": "[[Catapult]]",
+                               "Catapult": "♙ asdf [[Category:Weaponry]]",
+                               "Amazing Catapult": "test [[Catapult]] 
[[Category:Weaponry]]",
+                               "Category:Weaponry": "Weaponry refers to any 
items designed or used to attack and kill or destroy other people and 
property.",
+                               "Two Words": "ffnonesenseword catapult 
{{Template_Test}} anotherword [[Category:TwoWords]] [[Category:Categorywith 
Twowords]] [[Category:Categorywith \" Quote]]",
+                               "AlphaBeta": "[[Category:Alpha]] 
[[Category:Beta]]",
+                               "IHaveATwoWordCategory": 
"[[Category:CategoryWith ASpace]]",
+                               "Functional programming": "Functional 
programming is referential transparency.",
+                               "वाङ्मय": "वाङ्मय",
+                               "वाङ्\u200dमय": "वाङ्\u200dमय",
+                               "वाङ्\u200cमय": "वाङ्\u200cमय",
+                               "ChangeMe": "foo",
+                               "Wikitext": "{{#tag:somebug}}",
+                               "Page with non ascii letters": "ἄνθρωπος, 
широкий"
+                       }
+               };
+               return this.onWiki().then( ( api ) => {
+                       return api.loginGetEditToken().then( () => {
+                               return api.batch(batchJobs, 'CirrusSearch 
integration test edit');
+                       } );
+               } );
+       } );
+
+       BeforeOnce( { tags: "@setup_main or @prefix or @bad_syntax" }, function 
() {
+               // TODO: File upload
+               // And a file named File:Savepage-greyed.png exists with 
contents Savepage-greyed.png and description Screenshot, for test purposes, 
associated with https://bugzilla.wikimedia.org/show_bug.cgi?id=52908 .
+               let batchJobs = {
+                       edit: {
+                               "Rdir": "#REDIRECT [[Two Words]]",
+                               "IHaveAVideo": "[[File:How to Edit Article in 
Arabic Wikipedia.ogg|thumb|267x267px]]",
+                               "IHaveASound": "[[File:Serenade for Strings 
-mvt-1- Elgar.ogg]]"
+                       }
+               };
+               return this.onWiki().then( ( api ) => {
+                       return api.loginGetEditToken().then( () => {
+                               return api.batch(batchJobs, 'CirrusSearch 
integration test edit');
+                       } );
+               } );
+       } );
+
+       BeforeOnce( { tags: "@setup_main or @prefix or @go or @bad_syntax" }, 
function () {
+               let batchJobs = {
+                       edit: {
+                               "África": "for testing"
+                       }
+               };
+               return this.onWiki().then( ( api ) => {
+                       return api.loginGetEditToken().then( () => {
+                               return api.batch(batchJobs, 'CirrusSearch 
integration test edit');
+                       } );
+               } );
+       } );
 } );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6fc234a31bb6cd11ef6eea3a3d1130180285b32f
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