mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 14:43:08 +03:00
Added e2e test for site.changed
webhook event (#15595)
refs: https://github.com/TryGhost/Ghost/issues/15537 - snapshot test created to add confidence to webhook stability and increase overall test coverage.
This commit is contained in:
parent
e05889cd53
commit
74f7b7b3ee
13
ghost/core/test/e2e-webhooks/__snapshots__/site.test.js.snap
Normal file
13
ghost/core/test/e2e-webhooks/__snapshots__/site.test.js.snap
Normal file
@ -0,0 +1,13 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`site.* events site.changed event is triggered 1: [headers] 1`] = `
|
||||
Object {
|
||||
"accept-encoding": "gzip, deflate",
|
||||
"content-length": Any<Number>,
|
||||
"content-type": "application/json",
|
||||
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
|
||||
"user-agent": StringMatching /Ghost\\\\/\\\\d\\+\\\\\\.\\\\d\\+\\\\\\.\\\\d\\+\\\\s\\\\\\(https:\\\\/\\\\/github\\.com\\\\/TryGhost\\\\/Ghost\\\\\\)/,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`site.* events site.changed event is triggered 2: [body] 1`] = `Object {}`;
|
51
ghost/core/test/e2e-webhooks/site.test.js
Normal file
51
ghost/core/test/e2e-webhooks/site.test.js
Normal file
@ -0,0 +1,51 @@
|
||||
const {agentProvider, mockManager, fixtureManager, matchers} = require('../utils/e2e-framework');
|
||||
const {anyGhostAgent, anyContentVersion, anyNumber} = matchers;
|
||||
|
||||
describe('site.* events', function () {
|
||||
let adminAPIAgent;
|
||||
let webhookMockReceiver;
|
||||
|
||||
before(async function () {
|
||||
adminAPIAgent = await agentProvider.getAdminAPIAgent();
|
||||
await fixtureManager.init('integrations');
|
||||
await adminAPIAgent.loginAsOwner();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
webhookMockReceiver = mockManager.mockWebhookRequests();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
mockManager.restore();
|
||||
});
|
||||
|
||||
it('site.changed event is triggered', async function () {
|
||||
const webhookURL = 'https://test-webhook-receiver.com/site-changed';
|
||||
await webhookMockReceiver.mock(webhookURL);
|
||||
await fixtureManager.insertWebhook({
|
||||
event: 'site.changed',
|
||||
url: webhookURL
|
||||
});
|
||||
|
||||
const res = await adminAPIAgent
|
||||
.post('posts/')
|
||||
.body({
|
||||
posts: [{
|
||||
title: 'webhookz',
|
||||
status: 'published',
|
||||
mobiledoc: fixtureManager.get('posts', 1).mobiledoc
|
||||
}]
|
||||
})
|
||||
.expectStatus(201);
|
||||
|
||||
await webhookMockReceiver.receivedRequest();
|
||||
|
||||
webhookMockReceiver
|
||||
.matchHeaderSnapshot({
|
||||
'content-version': anyContentVersion,
|
||||
'content-length': anyNumber,
|
||||
'user-agent': anyGhostAgent
|
||||
})
|
||||
.matchBodySnapshot();
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user