From a499f866f325163254056e2feffe361151ff87d8 Mon Sep 17 00:00:00 2001 From: Simon Backx Date: Wed, 5 Oct 2022 14:25:00 +0200 Subject: [PATCH] Prevented posts webhook tests from breaking on every release --- .../test/e2e-webhooks/__snapshots__/posts.test.js.snap | 4 ++-- ghost/core/test/e2e-webhooks/posts.test.js | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ghost/core/test/e2e-webhooks/__snapshots__/posts.test.js.snap b/ghost/core/test/e2e-webhooks/__snapshots__/posts.test.js.snap index 2b3ef9aa5b..237f7ac282 100644 --- a/ghost/core/test/e2e-webhooks/__snapshots__/posts.test.js.snap +++ b/ghost/core/test/e2e-webhooks/__snapshots__/posts.test.js.snap @@ -6,7 +6,7 @@ Object { "content-length": Any, "content-type": "application/json", "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, - "user-agent": "Ghost/5.17.2 (https://github.com/TryGhost/Ghost)", + "user-agent": StringMatching /Ghost\\\\/\\\\d\\+\\\\\\.\\\\d\\+\\\\\\.\\\\d\\+\\\\s\\\\\\(https:\\\\/\\\\/github\\.com\\\\/TryGhost\\\\/Ghost\\\\\\)/, } `; @@ -150,7 +150,7 @@ Object { "content-length": Any, "content-type": "application/json", "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, - "user-agent": "Ghost/5.17.2 (https://github.com/TryGhost/Ghost)", + "user-agent": StringMatching /Ghost\\\\/\\\\d\\+\\\\\\.\\\\d\\+\\\\\\.\\\\d\\+\\\\s\\\\\\(https:\\\\/\\\\/github\\.com\\\\/TryGhost\\\\/Ghost\\\\\\)/, } `; diff --git a/ghost/core/test/e2e-webhooks/posts.test.js b/ghost/core/test/e2e-webhooks/posts.test.js index 2932c4cef2..dbd748471a 100644 --- a/ghost/core/test/e2e-webhooks/posts.test.js +++ b/ghost/core/test/e2e-webhooks/posts.test.js @@ -1,5 +1,5 @@ const {agentProvider, mockManager, fixtureManager, matchers} = require('../utils/e2e-framework'); -const {anyObjectId, anyISODateTime, anyUuid, anyContentVersion, anyNumber, anyLocalURL} = matchers; +const {stringMatching, anyObjectId, anyISODateTime, anyUuid, anyContentVersion, anyNumber, anyLocalURL} = matchers; const tierSnapshot = { id: anyObjectId, @@ -7,6 +7,8 @@ const tierSnapshot = { updated_at: anyISODateTime }; +const anyGhostAgent = stringMatching(/Ghost\/\d+\.\d+\.\d+\s\(https:\/\/github.com\/TryGhost\/Ghost\)/); + const buildAuthorSnapshot = (roles = false) => { const authorSnapshot = { last_seen: anyISODateTime, @@ -101,7 +103,8 @@ describe('post.* events', function () { webhookMockReceiver .matchHeaderSnapshot({ 'content-version': anyContentVersion, - 'content-length': anyNumber + 'content-length': anyNumber, + 'user-agent': anyGhostAgent }) .matchBodySnapshot({ post: { @@ -140,7 +143,8 @@ describe('post.* events', function () { webhookMockReceiver .matchHeaderSnapshot({ 'content-version': anyContentVersion, - 'content-length': anyNumber + 'content-length': anyNumber, + 'user-agent': anyGhostAgent }) .matchBodySnapshot({ post: {