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

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

Port boost_template_api.feature to nodejs

Change-Id: Ib6c5c2bef4b89558b94144121afa946824e270e2
---
A tests/integration/features/boost_template_api.feature
M tests/integration/features/step_definitions/page_steps.js
M tests/integration/features/support/hooks.js
3 files changed, 59 insertions(+), 15 deletions(-)


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

diff --git a/tests/integration/features/boost_template_api.feature 
b/tests/integration/features/boost_template_api.feature
new file mode 100644
index 0000000..3e91dd1
--- /dev/null
+++ b/tests/integration/features/boost_template_api.feature
@@ -0,0 +1,25 @@
+@boost_template @clean @api
+Feature: Searches with the boost-template operator
+  Scenario: Searching for a page without template boosts doesn't use them
+    When I api search for BoostTemplateTest
+    Then NoTemplates BoostTemplateTest is the first api search result
+
+  Scenario: Adding a single template boost is recognized
+    When I api search for boost-templates:"Template:BoostTemplateLow|10000%" 
BoostTemplateTest
+    Then LowTemplate is the first api search result
+
+  Scenario: Adding two template boosts is also recognized
+    When I api search for boost-templates:"Template:BoostTemplateLow|10000% 
Template:BoostTemplateHigh|100000%" BoostTemplateTest
+    Then HighTemplate is the first api search result
+
+  Scenario: Four templates is just fine (though I'm only actually using two of 
them)
+    When I api search for boost-templates:"Template:BoostTemplateFake|10% 
Template:BoostTemplateLow|10000% Template:BoostTemplateFake2|1000000% 
Template:BoostTemplateHigh|100000%" BoostTemplateTest
+    Then HighTemplate is the first api search result
+
+  Scenario: Template boosts can also lower the score of a template
+    When I api search for boost-templates:"Template:BoostTemplateLow|1%" 
BoostTemplateTest -intitle:"BoostTemplateTest"
+    Then HighTemplate is the first api search result
+
+  Scenario: Template boosts can also lower the score of another template (we 
didn't get lucky with the first one)
+    When I api search for boost-templates:"Template:BoostTemplateHigh|1%" 
BoostTemplateTest -intitle:"BoostTemplateTest"
+    Then LowTemplate is the first api search result
diff --git a/tests/integration/features/step_definitions/page_steps.js 
b/tests/integration/features/step_definitions/page_steps.js
index 268a91d..3695e06 100644
--- a/tests/integration/features/step_definitions/page_steps.js
+++ b/tests/integration/features/step_definitions/page_steps.js
@@ -134,30 +134,32 @@
                if ( title === "none" ) {
                        expect( this.apiResponse.query.search 
).to.have.lengthOf.below( 1 + Math.min.apply( null, indexes ) );
                } else {
-                       withApi( this, () => {
-                               let found = indexes.map( pos => {
-                                       if ( this.apiResponse.query.search[pos] 
) {
-                                               return 
this.apiResponse.query.search[pos].title;
-                                       } else {
-                                               return null;
-                                       }
-                               } );
-                               if ( in_ok ) {
-                                       // What exactly does this do?
-                                       // expect(found).to 
include(include(title))
-                                       throw new Error( 'Not Implemented' );
+                       let found = indexes.map( pos => {
+                               if ( this.apiResponse.query.search[pos] ) {
+                                       return 
this.apiResponse.query.search[pos].title;
                                } else {
-                                       expect( found ).to.include(title);
+                                       return null;
                                }
                        } );
+                       if ( in_ok ) {
+                               // What exactly does this do?
+                               // expect(found).to include(include(title))
+                               throw new Error( 'Not Implemented' );
+                       } else {
+                               expect( found ).to.include(title);
+                       }
                }
        }
-       Then( /^(.+) is( in)? the ((?:[^ ])+(?: or (?:[^ ])+)*) api search 
result$/, checkApiSearchResultStep );
+       Then( /^(.+) is( in)? the ((?:[^ ])+(?: or (?:[^ ])+)*) api search 
result$/, function ( title, in_ok, indexes ) {
+               withApi( this, () => {
+                       checkApiSearchResultStep.call( this, title, in_ok, 
indexes );
+               } );
+       } );
 
        function apiSearchStep( enableRewrites, qiprofile, offset, lang, 
namespaces, search ) {
                let options = {
                        srnamespace: (namespaces || "0").split(' '),
-                       enablerewrites: enableRewrites ? 1 : 0,
+                       srenablerewrites: enableRewrites ? 1 : 0,
                };
                if ( offset ) {
                        options.sroffset = offset;
diff --git a/tests/integration/features/support/hooks.js 
b/tests/integration/features/support/hooks.js
index 7be4bd3..e1e5082 100644
--- a/tests/integration/features/support/hooks.js
+++ b/tests/integration/features/support/hooks.js
@@ -182,4 +182,21 @@
                        } );
                } );
        } );
+
+       BeforeOnce( { tags: "@boost_template" }, function () {
+               let batchJobs = {
+                       edit: {
+                               "Template:BoostTemplateHigh": 
"BoostTemplateTest",
+                               "Template:BoostTemplateLow": 
"BoostTemplateTest",
+                               "NoTemplates BoostTemplateTest": "nothing 
important",
+                               "HighTemplate": "{{BoostTemplateHigh}}",
+                               "LowTemplate": "{{BoostTemplateLow}}",
+                       }
+               };
+               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/381513
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

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