mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
Added header snapshots to webhook e2e tests
refs https://github.com/TryGhost/Toolbox/issues/320 - Header snapshot matching was missing from webhook e2e tests. With a bumped version of webhook-mock-receiver it's now possible to record and match webhook request headers.
This commit is contained in:
parent
8b7a573a1d
commit
d817e5830d
@ -190,7 +190,7 @@
|
||||
"devDependencies": {
|
||||
"@playwright/test": "1.26.1",
|
||||
"@tryghost/express-test": "0.11.5",
|
||||
"@tryghost/webhook-mock-receiver": "0.1.2",
|
||||
"@tryghost/webhook-mock-receiver": "0.2.0",
|
||||
"@types/common-tags": "1.8.1",
|
||||
"c8": "7.12.0",
|
||||
"cli-progress": "3.11.2",
|
||||
|
@ -1,6 +1,16 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`post.* events post.added event is triggered 1: [body] 1`] = `
|
||||
exports[`post.* events post.added 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": "Ghost/5.17.1 (https://github.com/TryGhost/Ghost)",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`post.* events post.added event is triggered 2: [body] 1`] = `
|
||||
Object {
|
||||
"post": Object {
|
||||
"current": Object {
|
||||
@ -134,7 +144,17 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`post.* events post.published event is triggered 1: [body] 1`] = `
|
||||
exports[`post.* events post.published 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": "Ghost/5.17.1 (https://github.com/TryGhost/Ghost)",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`post.* events post.published event is triggered 2: [body] 1`] = `
|
||||
Object {
|
||||
"post": Object {
|
||||
"current": Object {
|
||||
|
@ -1,5 +1,5 @@
|
||||
const {agentProvider, mockManager, fixtureManager, matchers} = require('../utils/e2e-framework');
|
||||
const {anyObjectId, anyISODateTime, anyUuid, stringMatching} = matchers;
|
||||
const {anyObjectId, anyISODateTime, anyUuid, anyContentVersion, anyNumber, stringMatching} = matchers;
|
||||
|
||||
const tierSnapshot = {
|
||||
id: anyObjectId,
|
||||
@ -98,9 +98,13 @@ describe('post.* events', function () {
|
||||
})
|
||||
.expectStatus(200);
|
||||
|
||||
await webhookMockReceiver
|
||||
// TODO: implement header matching feature next!
|
||||
// .matchHeaderSnapshot();
|
||||
await webhookMockReceiver.receivedRequest();
|
||||
|
||||
webhookMockReceiver
|
||||
.matchHeaderSnapshot({
|
||||
'content-version': anyContentVersion,
|
||||
'content-length': anyNumber
|
||||
})
|
||||
.matchBodySnapshot({
|
||||
post: {
|
||||
current: buildPostSnapshotWithTiers({
|
||||
@ -133,9 +137,13 @@ describe('post.* events', function () {
|
||||
})
|
||||
.expectStatus(201);
|
||||
|
||||
await webhookMockReceiver
|
||||
// TODO: implement header matching feature next!
|
||||
// .matchHeaderSnapshot();
|
||||
await webhookMockReceiver.receivedRequest();
|
||||
|
||||
webhookMockReceiver
|
||||
.matchHeaderSnapshot({
|
||||
'content-version': anyContentVersion,
|
||||
'content-length': anyNumber
|
||||
})
|
||||
.matchBodySnapshot({
|
||||
post: {
|
||||
current: buildPostSnapshotWithTiers({
|
||||
|
10
yarn.lock
10
yarn.lock
@ -4690,10 +4690,12 @@
|
||||
"@tryghost/root-utils" "^0.3.16"
|
||||
semver "^7.3.5"
|
||||
|
||||
"@tryghost/webhook-mock-receiver@0.1.2":
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@tryghost/webhook-mock-receiver/-/webhook-mock-receiver-0.1.2.tgz#feeaad6298cbcda16447804e0b7829f2aa32584c"
|
||||
integrity sha512-urg+UERP6CPUaCYoZBg1ANe1DCu1+QbJL8V2hDrkJlRCAjokJpXwy9Wwc/VdHXbVSTeH6JVAK1LNH3gjJVGhVw==
|
||||
"@tryghost/webhook-mock-receiver@0.2.0":
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@tryghost/webhook-mock-receiver/-/webhook-mock-receiver-0.2.0.tgz#5f77636e40c82df8c06afbbcef1c49ec6d1d70e5"
|
||||
integrity sha512-/VqNp5/NQ7us5RgrkZQztgYFlP9qpKogonQRDYgYMYH+7CMmm8cwm7734GDdwS/kJrUl2kPhyvehV6pIbGASNw==
|
||||
dependencies:
|
||||
p-wait-for "3.1.0"
|
||||
|
||||
"@tryghost/zip@1.1.27":
|
||||
version "1.1.27"
|
||||
|
Loading…
Reference in New Issue
Block a user