Added e2e test for tag.deleted
webhook (#15553)
refs https://github.com/TryGhost/Ghost/issues/15537 - this adds an e2e test and test snapshot for the `tag.deleted` webhook so we can prevent regressions and bugs in the future
This commit is contained in:
parent
06f6fc11a7
commit
426168f73d
@ -40,3 +40,43 @@ Object {
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`tag.* events tag.deleted 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[`tag.* events tag.deleted event is triggered 2: [body] 1`] = `
|
||||
Object {
|
||||
"tag": Object {
|
||||
"current": Object {},
|
||||
"previous": Object {
|
||||
"accent_color": null,
|
||||
"canonical_url": null,
|
||||
"codeinjection_foot": null,
|
||||
"codeinjection_head": null,
|
||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"description": Any<String>,
|
||||
"feature_image": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"meta_description": null,
|
||||
"meta_title": null,
|
||||
"name": "Test Tag 2",
|
||||
"og_description": null,
|
||||
"og_image": null,
|
||||
"og_title": null,
|
||||
"slug": "test-tag-2",
|
||||
"twitter_description": null,
|
||||
"twitter_image": null,
|
||||
"twitter_title": null,
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"visibility": "public",
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
@ -5,8 +5,7 @@ const tagSnapshot = {
|
||||
created_at: anyISODateTime,
|
||||
description: anyString,
|
||||
id: anyObjectId,
|
||||
updated_at: anyISODateTime,
|
||||
url: anyLocalURL
|
||||
updated_at: anyISODateTime
|
||||
};
|
||||
|
||||
describe('tag.* events', function () {
|
||||
@ -56,7 +55,48 @@ describe('tag.* events', function () {
|
||||
})
|
||||
.matchBodySnapshot({
|
||||
tag: {
|
||||
current: tagSnapshot
|
||||
current: {...tagSnapshot, url: anyLocalURL}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('tag.deleted event is triggered', async function () {
|
||||
const webhookURL = 'https://test-webhook-receiver.com/tag-deleted/';
|
||||
await webhookMockReceiver.mock(webhookURL);
|
||||
await fixtureManager.insertWebhook({
|
||||
event: 'tag.deleted',
|
||||
url: webhookURL
|
||||
});
|
||||
|
||||
const res = await adminAPIAgent
|
||||
.post('tags/')
|
||||
.body({
|
||||
tags: [{
|
||||
name: 'Test Tag 2',
|
||||
slug: 'test-tag-2',
|
||||
description: 'Test description'
|
||||
}]
|
||||
})
|
||||
.expectStatus(201);
|
||||
|
||||
const id = res.body.tags[0].id;
|
||||
|
||||
await adminAPIAgent
|
||||
.delete('tags/' + id)
|
||||
.expectStatus(204);
|
||||
|
||||
await webhookMockReceiver.receivedRequest();
|
||||
|
||||
webhookMockReceiver
|
||||
.matchHeaderSnapshot({
|
||||
'content-version': anyContentVersion,
|
||||
'content-length': anyNumber,
|
||||
'user-agent': anyGhostAgent
|
||||
})
|
||||
.matchBodySnapshot({
|
||||
tag: {
|
||||
current: {},
|
||||
previous: tagSnapshot
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user