diff --git a/ghost/core/test/e2e-api/webmentions/webmentions.test.js b/ghost/core/test/e2e-api/webmentions/webmentions.test.js index 02e75e7578..d20617e956 100644 --- a/ghost/core/test/e2e-api/webmentions/webmentions.test.js +++ b/ghost/core/test/e2e-api/webmentions/webmentions.test.js @@ -75,6 +75,75 @@ describe('Webmentions (receiving)', function () { })); }); + it('will update a mentions source metadata', async function () { + const targetUrl = new URL(urlUtils.getSiteUrl()); + const sourceUrl = new URL('http://testpage.com/update-mention-test-1/'); + + testCreatingTheMention: { + const processWebmentionJob = jobsService.awaitCompletion('processWebmention'); + const html = ` + Test Page + `; + + nock(targetUrl.origin) + .head(targetUrl.pathname) + .reply(200); + + nock(sourceUrl.origin) + .get(sourceUrl.pathname) + .reply(200, html, {'Content-Type': 'text/html'}); + + await agent.post('/receive') + .body({ + source: sourceUrl.href, + target: targetUrl.href + }) + .expectStatus(202); + + await processWebmentionJob; + + const mention = await models.Mention.findOne({source: 'http://testpage.com/update-mention-test-1/'}); + assert(mention); + assert.equal(mention.get('source_title'), 'Test Page'); + assert.equal(mention.get('source_excerpt'), 'Test description'); + assert.equal(mention.get('source_author'), 'John Doe'); + + break testCreatingTheMention; + } + + testUpdatingTheMention: { + const processWebmentionJob = jobsService.awaitCompletion('processWebmention'); + const html = ` + New Title + `; + + nock(targetUrl.origin) + .head(targetUrl.pathname) + .reply(200); + + nock(sourceUrl.origin) + .get(sourceUrl.pathname) + .reply(200, html, {'Content-Type': 'text/html'}); + + await agent.post('/receive') + .body({ + source: sourceUrl.href, + target: targetUrl.href + }) + .expectStatus(202); + + await processWebmentionJob; + + const mention = await models.Mention.findOne({source: 'http://testpage.com/update-mention-test-1/'}); + assert(mention); + assert.equal(mention.get('source_title'), 'New Title'); + assert.equal(mention.get('source_excerpt'), 'New Description'); + assert.equal(mention.get('source_author'), 'big man with a beard'); + + break testUpdatingTheMention; + } + }); + it('can receive a webmention to homepage', async function () { const processWebmentionJob = jobsService.awaitCompletion('processWebmention'); const targetUrl = new URL(urlUtils.getSiteUrl());