[MediaWiki-commits] [Gerrit] mediawiki...CirrusSearch[master]: Port linksto and more_like tests to nodejs
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/392538 ) Change subject: Port linksto and more_like tests to nodejs .. Port linksto and more_like tests to nodejs Change-Id: I9edd45add51bfad56dd87650de520bfeb08b9a20 --- A tests/integration/features/linksto_api.feature A tests/integration/features/more_like_api.feature M tests/integration/features/step_definitions/page_steps.js M tests/integration/features/support/hooks.js 4 files changed, 104 insertions(+), 19 deletions(-) Approvals: Cindy-the-browser-test-bot: Looks good to me, but someone else must approve jenkins-bot: Verified DCausse: Looks good to me, approved diff --git a/tests/integration/features/linksto_api.feature b/tests/integration/features/linksto_api.feature new file mode 100644 index 000..2503cc0 --- /dev/null +++ b/tests/integration/features/linksto_api.feature @@ -0,0 +1,23 @@ +@clean @filters @linksto @api +Feature: Searches with the linksto filter + Scenario: linksto only includes pages with the links +When I api search for linksto:"LinksToTest Target" +Then LinksToTest Plain is in the api search results + And LinksToTest OtherText is in the api search results + + Scenario: linksto can be combined with other text +When I api search for linksto:"LinksToTest Target" text +Then LinksToTest OtherText is the first api search result + + Scenario: -linksto excludes pages with the link +When I api search for -linksto:"LinksToTest Target" LinksToTest +Then LinksToTest No Link is in the api search results + But LinksToTest Plain is not in the api search results + + Scenario: linksto works on links from templates +When I api search for linksto:"LinksToTest Target" Using Template +Then LinksToTest Using Template is the first api search result + + Scenario: linksto finds links in non-main namespace +When I api search for linksto:"Template:LinksToTest Template" +Then LinksToTest LinksToTemplate is the first api search result diff --git a/tests/integration/features/more_like_api.feature b/tests/integration/features/more_like_api.feature new file mode 100644 index 000..c04a321 --- /dev/null +++ b/tests/integration/features/more_like_api.feature @@ -0,0 +1,29 @@ +@clean @more_like_this @api +Feature: More like an article + Scenario: Searching for morelike: returns no results +When I api search for morelike:IDontExist +Then there are no api search results + + Scenario: Searching for morelike: returns pages that are "like" that page +When I api search for morelike:More Like Me 1 +Then More Like Me is in the first api search result + But More Like Me 1 is not in the api search results + + Scenario: Searching for morelike: returns pages that are "like" the page that it is a redirect to +When I api search for morelike:More Like Me Rdir +Then More Like Me is in the first api search result + But More Like Me 1 is not in the api search results + + @redirect_loop + Scenario: Searching for morelike: returns no results +When I api search for morelike:Redirect Loop +Then there are no api search results + + Scenario: Searching for morelike:|| returns pages that are "like" all those pages +When I api search for morelike:More Like Me 1|More Like Me Set 2 Page 1|More Like Me Set 3 Page 1 +Then More Like Me is part of the api search result + And More Like Me Set 2 is part of the api search result + And More Like Me Set 3 is part of the api search result + But More Like Me 1 is not in the api search results + And More Like Me Set 2 Page 1 is not in the api search results + And More Like Me Set 3 Page 1 is not in the api search results diff --git a/tests/integration/features/step_definitions/page_steps.js b/tests/integration/features/step_definitions/page_steps.js index 6763049..e1b6be8 100644 --- a/tests/integration/features/step_definitions/page_steps.js +++ b/tests/integration/features/step_definitions/page_steps.js @@ -147,9 +147,12 @@ } } ); if ( in_ok ) { - // What exactly does this do? - // expect(found).to include(include(title)) - throw new Error( 'Not Implemented' ); + // Asserts that title is found within the strings that make up found. + // ex: found = ['foo bar baz'], title = 'bar' should pass. + // Chai doesnt (yet) have a native assertion for this: + // https://github.com/chaijs/chai/issues/858 + let ok = found.reduce( ( a, b ) => a || b.indexOf( title ) > -1, false ); + expect( ok, `expected ${JSON.stringify(found)} to include "${title}"`
[MediaWiki-commits] [Gerrit] mediawiki...CirrusSearch[master]: Port linksto and more_like tests to nodejs
EBernhardson has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/392538 ) Change subject: Port linksto and more_like tests to nodejs .. Port linksto and more_like tests to nodejs Change-Id: I9edd45add51bfad56dd87650de520bfeb08b9a20 --- A tests/integration/features/linksto_api.feature A tests/integration/features/more_like_api.feature M tests/integration/features/step_definitions/page_steps.js M tests/integration/features/support/hooks.js 4 files changed, 104 insertions(+), 19 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch refs/changes/38/392538/1 diff --git a/tests/integration/features/linksto_api.feature b/tests/integration/features/linksto_api.feature new file mode 100644 index 000..2503cc0 --- /dev/null +++ b/tests/integration/features/linksto_api.feature @@ -0,0 +1,23 @@ +@clean @filters @linksto @api +Feature: Searches with the linksto filter + Scenario: linksto only includes pages with the links +When I api search for linksto:"LinksToTest Target" +Then LinksToTest Plain is in the api search results + And LinksToTest OtherText is in the api search results + + Scenario: linksto can be combined with other text +When I api search for linksto:"LinksToTest Target" text +Then LinksToTest OtherText is the first api search result + + Scenario: -linksto excludes pages with the link +When I api search for -linksto:"LinksToTest Target" LinksToTest +Then LinksToTest No Link is in the api search results + But LinksToTest Plain is not in the api search results + + Scenario: linksto works on links from templates +When I api search for linksto:"LinksToTest Target" Using Template +Then LinksToTest Using Template is the first api search result + + Scenario: linksto finds links in non-main namespace +When I api search for linksto:"Template:LinksToTest Template" +Then LinksToTest LinksToTemplate is the first api search result diff --git a/tests/integration/features/more_like_api.feature b/tests/integration/features/more_like_api.feature new file mode 100644 index 000..c04a321 --- /dev/null +++ b/tests/integration/features/more_like_api.feature @@ -0,0 +1,29 @@ +@clean @more_like_this @api +Feature: More like an article + Scenario: Searching for morelike: returns no results +When I api search for morelike:IDontExist +Then there are no api search results + + Scenario: Searching for morelike: returns pages that are "like" that page +When I api search for morelike:More Like Me 1 +Then More Like Me is in the first api search result + But More Like Me 1 is not in the api search results + + Scenario: Searching for morelike: returns pages that are "like" the page that it is a redirect to +When I api search for morelike:More Like Me Rdir +Then More Like Me is in the first api search result + But More Like Me 1 is not in the api search results + + @redirect_loop + Scenario: Searching for morelike: returns no results +When I api search for morelike:Redirect Loop +Then there are no api search results + + Scenario: Searching for morelike:|| returns pages that are "like" all those pages +When I api search for morelike:More Like Me 1|More Like Me Set 2 Page 1|More Like Me Set 3 Page 1 +Then More Like Me is part of the api search result + And More Like Me Set 2 is part of the api search result + And More Like Me Set 3 is part of the api search result + But More Like Me 1 is not in the api search results + And More Like Me Set 2 Page 1 is not in the api search results + And More Like Me Set 3 Page 1 is not in the api search results diff --git a/tests/integration/features/step_definitions/page_steps.js b/tests/integration/features/step_definitions/page_steps.js index 6763049..d7881db 100644 --- a/tests/integration/features/step_definitions/page_steps.js +++ b/tests/integration/features/step_definitions/page_steps.js @@ -147,9 +147,12 @@ } } ); if ( in_ok ) { - // What exactly does this do? - // expect(found).to include(include(title)) - throw new Error( 'Not Implemented' ); + // Asserts that title is found within the strings that make up found. + // ex: found = ['foo bar baz'], title = 'bar' should pass. + // Chai doesnt (yet) have a native assertion for this: + // https://github.com/chaijs/chai/issues/858 + let ok = found.reduce( ( a, b ) => a || b.indexOf( title ) > -1, false ); + expect( ok, `expected ${JSON.stringify(found)} to include "${title}"` ).to.be.true; // jshint ignore:line