mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Updated webhook snapshots
refs TryGhost/Toolbox#340 refs TryGhost#13451 - Fixed the snapshot files which had to include new fields like "comment_notifications" as well as other properties that came along with the hacky solution to the webhook's auhor inclusion bug - Also documented the "roles" being included inconsistently across different events - it's a BUG and should be looked into one day when we care enough.
This commit is contained in:
parent
ba061d86e8
commit
02541031ec
2 changed files with 90 additions and 16 deletions
|
@ -1,6 +1,6 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`post.* events post.added even is triggered 1: [body] 1`] = `
|
exports[`post.* events post.added event is triggered 1: [body] 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"post": Object {
|
"post": Object {
|
||||||
"current": Object {
|
"current": Object {
|
||||||
|
@ -8,6 +8,7 @@ Object {
|
||||||
Object {
|
Object {
|
||||||
"accessibility": null,
|
"accessibility": null,
|
||||||
"bio": "bio",
|
"bio": "bio",
|
||||||
|
"comment_notifications": true,
|
||||||
"cover_image": null,
|
"cover_image": null,
|
||||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
"email": "jbloggs@example.com",
|
"email": "jbloggs@example.com",
|
||||||
|
@ -53,6 +54,29 @@ Object {
|
||||||
"og_description": null,
|
"og_description": null,
|
||||||
"og_image": null,
|
"og_image": null,
|
||||||
"og_title": null,
|
"og_title": null,
|
||||||
|
"primary_author": Object {
|
||||||
|
"accessibility": null,
|
||||||
|
"bio": "bio",
|
||||||
|
"comment_notifications": true,
|
||||||
|
"cover_image": null,
|
||||||
|
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
|
"email": "jbloggs@example.com",
|
||||||
|
"facebook": null,
|
||||||
|
"id": "1",
|
||||||
|
"last_seen": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
|
"location": "location",
|
||||||
|
"meta_description": null,
|
||||||
|
"meta_title": null,
|
||||||
|
"name": "Joe Bloggs",
|
||||||
|
"profile_image": "https://example.com/super_photo.jpg",
|
||||||
|
"slug": "joe-bloggs",
|
||||||
|
"status": "active",
|
||||||
|
"tour": null,
|
||||||
|
"twitter": null,
|
||||||
|
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
|
"url": "http://127.0.0.1:2369/author/joe-bloggs/",
|
||||||
|
"website": null,
|
||||||
|
},
|
||||||
"primary_tag": null,
|
"primary_tag": null,
|
||||||
"published_at": null,
|
"published_at": null,
|
||||||
"slug": "testing-post-added-webhook",
|
"slug": "testing-post-added-webhook",
|
||||||
|
@ -102,7 +126,7 @@ Object {
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`post.* events post.published even is triggered 1: [body] 1`] = `
|
exports[`post.* events post.published event is triggered 1: [body] 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"post": Object {
|
"post": Object {
|
||||||
"current": Object {
|
"current": Object {
|
||||||
|
@ -110,6 +134,7 @@ Object {
|
||||||
Object {
|
Object {
|
||||||
"accessibility": null,
|
"accessibility": null,
|
||||||
"bio": "bio",
|
"bio": "bio",
|
||||||
|
"comment_notifications": true,
|
||||||
"cover_image": null,
|
"cover_image": null,
|
||||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
"email": "jbloggs@example.com",
|
"email": "jbloggs@example.com",
|
||||||
|
@ -123,11 +148,11 @@ Object {
|
||||||
"profile_image": "https://example.com/super_photo.jpg",
|
"profile_image": "https://example.com/super_photo.jpg",
|
||||||
"roles": Array [
|
"roles": Array [
|
||||||
Object {
|
Object {
|
||||||
"created_at": "2022-06-03T09:31:02.000Z",
|
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
"description": "Blog Owner",
|
"description": "Blog Owner",
|
||||||
"id": "6299d4d6cf0c0f6aabf10096",
|
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||||
"name": "Owner",
|
"name": "Owner",
|
||||||
"updated_at": "2022-06-03T09:31:02.000Z",
|
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"slug": "joe-bloggs",
|
"slug": "joe-bloggs",
|
||||||
|
@ -163,6 +188,38 @@ Object {
|
||||||
"og_description": null,
|
"og_description": null,
|
||||||
"og_image": null,
|
"og_image": null,
|
||||||
"og_title": null,
|
"og_title": null,
|
||||||
|
"primary_author": Object {
|
||||||
|
"accessibility": null,
|
||||||
|
"bio": "bio",
|
||||||
|
"comment_notifications": true,
|
||||||
|
"cover_image": null,
|
||||||
|
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
|
"email": "jbloggs@example.com",
|
||||||
|
"facebook": null,
|
||||||
|
"id": "1",
|
||||||
|
"last_seen": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
|
"location": "location",
|
||||||
|
"meta_description": null,
|
||||||
|
"meta_title": null,
|
||||||
|
"name": "Joe Bloggs",
|
||||||
|
"profile_image": "https://example.com/super_photo.jpg",
|
||||||
|
"roles": Array [
|
||||||
|
Object {
|
||||||
|
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
|
"description": "Blog Owner",
|
||||||
|
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||||
|
"name": "Owner",
|
||||||
|
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"slug": "joe-bloggs",
|
||||||
|
"status": "active",
|
||||||
|
"tour": null,
|
||||||
|
"twitter": null,
|
||||||
|
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
|
"url": "http://127.0.0.1:2369/author/joe-bloggs/",
|
||||||
|
"website": null,
|
||||||
|
},
|
||||||
"primary_tag": null,
|
"primary_tag": null,
|
||||||
"published_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
"published_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
"slug": "webhookz",
|
"slug": "webhookz",
|
||||||
|
|
|
@ -7,13 +7,27 @@ const tierSnapshot = {
|
||||||
updated_at: anyISODateTime
|
updated_at: anyISODateTime
|
||||||
};
|
};
|
||||||
|
|
||||||
const authorSnapshot = {
|
const buildAuthorSnapshot = (roles = false) => {
|
||||||
last_seen: anyISODateTime,
|
const authorSnapshot = {
|
||||||
created_at: anyISODateTime,
|
last_seen: anyISODateTime,
|
||||||
updated_at: anyISODateTime
|
created_at: anyISODateTime,
|
||||||
|
updated_at: anyISODateTime
|
||||||
|
};
|
||||||
|
|
||||||
|
// NOTE: this is such a bad hack! for the reasons I did not investigate the "add" event does not include
|
||||||
|
// the roles but the "published" does! massive inconsistency and needs to be fixed one day
|
||||||
|
if (roles) {
|
||||||
|
authorSnapshot.roles = new Array(1).fill({
|
||||||
|
id: anyObjectId,
|
||||||
|
created_at: anyISODateTime,
|
||||||
|
updated_at: anyISODateTime
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return authorSnapshot;
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildPostSnapshotWithTiers = ({published, tiersCount}) => {
|
const buildPostSnapshotWithTiers = ({published, tiersCount, roles = false}) => {
|
||||||
return {
|
return {
|
||||||
id: anyObjectId,
|
id: anyObjectId,
|
||||||
uuid: anyUuid,
|
uuid: anyUuid,
|
||||||
|
@ -25,8 +39,8 @@ const buildPostSnapshotWithTiers = ({published, tiersCount}) => {
|
||||||
// this matcher should be removed once the issue is solved
|
// this matcher should be removed once the issue is solved
|
||||||
url: stringMatching(/http:\/\/127.0.0.1:2369\/\w+\//),
|
url: stringMatching(/http:\/\/127.0.0.1:2369\/\w+\//),
|
||||||
tiers: new Array(tiersCount).fill(tierSnapshot),
|
tiers: new Array(tiersCount).fill(tierSnapshot),
|
||||||
primary_author: authorSnapshot,
|
primary_author: buildAuthorSnapshot(roles),
|
||||||
authors: new Array(1).fill(authorSnapshot)
|
authors: new Array(1).fill(buildAuthorSnapshot(roles))
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -55,7 +69,7 @@ describe('post.* events', function () {
|
||||||
mockManager.restore();
|
mockManager.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('post.published even is triggered', async function () {
|
it('post.published event is triggered', async function () {
|
||||||
const webhookURL = 'https://test-webhook-receiver.com/post-published/';
|
const webhookURL = 'https://test-webhook-receiver.com/post-published/';
|
||||||
await webhookMockReceiver.mock(webhookURL);
|
await webhookMockReceiver.mock(webhookURL);
|
||||||
await fixtureManager.insertWebhook({
|
await fixtureManager.insertWebhook({
|
||||||
|
@ -91,14 +105,17 @@ describe('post.* events', function () {
|
||||||
post: {
|
post: {
|
||||||
current: buildPostSnapshotWithTiers({
|
current: buildPostSnapshotWithTiers({
|
||||||
published: true,
|
published: true,
|
||||||
tiersCount: 2
|
tiersCount: 2,
|
||||||
|
roles: true
|
||||||
}),
|
}),
|
||||||
previous: buildPreviousPostSnapshotWithTiers({tiersCount: 2})
|
previous: buildPreviousPostSnapshotWithTiers({
|
||||||
|
tiersCount: 2
|
||||||
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('post.added even is triggered', async function () {
|
it('post.added event is triggered', async function () {
|
||||||
const webhookURL = 'https://test-webhook-receiver.com/post-added/';
|
const webhookURL = 'https://test-webhook-receiver.com/post-added/';
|
||||||
await webhookMockReceiver.mock(webhookURL);
|
await webhookMockReceiver.mock(webhookURL);
|
||||||
await fixtureManager.insertWebhook({
|
await fixtureManager.insertWebhook({
|
||||||
|
|
Loading…
Add table
Reference in a new issue