EBernhardson has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/396471 )
Change subject: Port update_redirect_api.feature to nodejs ...................................................................... Port update_redirect_api.feature to nodejs Mostly a straight copy from ruby. While most of the 'within ...' steps could be removed unfortunately the one that waits for a redirect converted to not a redirect couldn't be removed. This has to wait for the previously redirected-to page to be updated. Rather than indirectly waiting on search results added a new step that directly waits for the redirect to be removed from the previously redirected to document. Change-Id: I1febfdad9eac1f8e3577b545274378dd50ae5de0 --- M tests/integration/features/step_definitions/page_step_helpers.js M tests/integration/features/step_definitions/page_steps.js A tests/integration/features/update_redirect_api.feature 3 files changed, 44 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch refs/changes/71/396471/1 diff --git a/tests/integration/features/step_definitions/page_step_helpers.js b/tests/integration/features/step_definitions/page_step_helpers.js index 7281da6..b5f39cc 100644 --- a/tests/integration/features/step_definitions/page_step_helpers.js +++ b/tests/integration/features/step_definitions/page_step_helpers.js @@ -296,7 +296,8 @@ // Is the requested page and the returned document dont have the same // title that means we have a redirect. In that case the revision id // wont match, but the backend api ensures the redirect is now contained - // within the document. + // within the document. Unfortunately if the page was just edited to + // now be a redirect anymore this is wrong ... if ( isOk && revisionId && content[0].source.title === page.title ) { isOk = parseInt( content[0].source.version, 10 ) === revisionId; } diff --git a/tests/integration/features/step_definitions/page_steps.js b/tests/integration/features/step_definitions/page_steps.js index 9db07e3..522c8ac 100644 --- a/tests/integration/features/step_definitions/page_steps.js +++ b/tests/integration/features/step_definitions/page_steps.js @@ -484,4 +484,24 @@ let found = snippets.reduce( ( a, b ) => a || b.indexOf( within ) > -1, false ); expect( found ).to.equal( !should_not ); } ); + + Then( /^I wait for (.+) to not be included in the redirects of (.+)$/, function ( source, redirect ) { + return Promise.coroutine( function* () { + let timeoutMs = 20000; + let start = new Date(); + while (true) { + let doc = yield this.stepHelpers.getCirrusIndexedContent( redirect ); + if ( doc.cirrusdoc.length > 0 ) { + let exists = doc.cirrusdoc[0].source.redirect.reduce( ( a, b ) => a || b.title === source, false ); + if ( !exists ) { + break; + } + } + if (new Date() - start >= timeoutMs) { + throw new Error( `Timed out waiting for ${source} to not exist in document of ${redirect}` ); + } + yield this.stepHelpers.waitForMs( 200 ); + } + } ).call( this ); + } ); }); diff --git a/tests/integration/features/update_redirect_api.feature b/tests/integration/features/update_redirect_api.feature new file mode 100644 index 0000000..50171ea --- /dev/null +++ b/tests/integration/features/update_redirect_api.feature @@ -0,0 +1,22 @@ +@clean @api @redirect @update +Feature: Updating a page from or to a redirect + Scenario: Turning a page into a redirect removes it from the search index + Given a page named RedirectTarget exists + When a page named ToBeRedirect%{epoch} exists + And I api search for ToBeRedirect%{epoch} + Then ToBeRedirect%{epoch} is the first api search result + When a page named ToBeRedirect%{epoch} exists with contents #REDIRECT [[RedirectTarget]] + And I api search for ToBeRedirect%{epoch} + Then RedirectTarget is the first api search result + And ToBeRedirect%{epoch} is not in the api search results + + Scenario: Turning a page from a redirect to a regular page puts it in the index + Given a page named RedirectTarget exists + When a page named StartsAsRedirect%{epoch} exists with contents #REDIRECT [[RedirectTarget]] + And I api search for StartsAsRedirect%{epoch} + Then RedirectTarget is the first api search result + When a page named StartsAsRedirect%{epoch} exists + And I wait for StartsAsRedirect%{epoch} to not be included in the redirects of RedirectTarget + And I api search for StartsAsRedirect%{epoch} + Then StartsAsRedirect%{epoch} is the first api search result + And RedirectTarget is not in the api search results -- To view, visit https://gerrit.wikimedia.org/r/396471 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1febfdad9eac1f8e3577b545274378dd50ae5de0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CirrusSearch Gerrit-Branch: master Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits