Mholloway has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/397566 )
Change subject: Summary: Send empty summary (not 204) for empty page ...................................................................... Summary: Send empty summary (not 204) for empty page Bug: T182596 Change-Id: I2331096519ceb95eef6c9d7013b80ab026082ff4 --- M lib/mobile-util.js M test/features/summary/pagecontent.js 2 files changed, 12 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps refs/changes/66/397566/1 diff --git a/lib/mobile-util.js b/lib/mobile-util.js index d0bea4e..acbccc8 100644 --- a/lib/mobile-util.js +++ b/lib/mobile-util.js @@ -196,7 +196,6 @@ * @return {!Object} a summary 2.0 spec-compliant page summary object */ mUtil.buildSummary = function(domain, title, pageData, disambiguation = false) { - let summary = {}; const page = pageData.page; const meta = pageData.meta; const isContentModelWikitext = meta.contentmodel === 'wikitext'; @@ -222,15 +221,8 @@ const leadText = domino.createDocument(page.sections[0].text); const intro = transforms.extractLeadIntroduction(leadText); + const summary = intro.length ? transforms.summarize(intro) : intro; - if (intro) { - summary = transforms.summarize(intro); - } else { - // If the lead introduction is empty we should consider it - // a placeholder e.g. redirect page. To avoid sending an empty - // summary 204. (T176517) - return { code: 204 }; - } return Object.assign({ code: 200, type : disambiguation ? 'disambiguation' : 'standard', diff --git a/test/features/summary/pagecontent.js b/test/features/summary/pagecontent.js index 5680597..7b768f7 100644 --- a/test/features/summary/pagecontent.js +++ b/test/features/summary/pagecontent.js @@ -34,4 +34,15 @@ assert.ok(res.body.extract_html.indexOf('<b>foobar</b>') > -1); }); }); + + it('empty summary (not 204) should be sent for empty page', () => { + const uri = localUri('PreviewsEmpty%2Fsandbox', 'en.wikipedia.beta.wmflabs.org'); + return preq.get({ uri }) + .then((res) => { + assert.deepEqual(res.status, 200); + assert.deepEqual(res.body.type, 'standard'); + assert.deepEqual(res.body.extract, '', 'should send empty plaintext extract'); + assert.deepEqual(res.body.extract_html, '', 'should send empty html extract'); + }); + }); }); -- To view, visit https://gerrit.wikimedia.org/r/397566 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2331096519ceb95eef6c9d7013b80ab026082ff4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/mobileapps Gerrit-Branch: master Gerrit-Owner: Mholloway <mhollo...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits