-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added e2e tests for tag.added webhook #15540
Merged
+106
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
ghost/core/test/e2e-webhooks/__snapshots__/tags.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`tag.* events tag.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": StringMatching /Ghost\\\\/\\\\d\\+\\\\\\.\\\\d\\+\\\\\\.\\\\d\\+\\\\s\\\\\\(https:\\\\/\\\\/github\\.com\\\\/TryGhost\\\\/Ghost\\\\\\)/, | ||
} | ||
`; | ||
|
||
exports[`tag.* events tag.added event is triggered 2: [body] 1`] = ` | ||
Object { | ||
"tag": Object { | ||
"current": 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", | ||
"og_description": null, | ||
"og_image": null, | ||
"og_title": null, | ||
"slug": "test-tag", | ||
"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/, | ||
"url": StringMatching /http:\\\\/\\\\/127\\.0\\.0\\.1:2369\\\\/\\\\w\\+\\\\//, | ||
"visibility": "public", | ||
}, | ||
"previous": Object {}, | ||
}, | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const {agentProvider, mockManager, fixtureManager, matchers} = require('../utils/e2e-framework'); | ||
const {anyGhostAgent, anyObjectId, anyISODateTime, anyUuid, anyString, anyContentVersion, anyNumber, anyLocalURL} = matchers; | ||
|
||
const tagSnapshot = { | ||
created_at: anyISODateTime, | ||
description: anyString, | ||
id: anyObjectId, | ||
updated_at: anyISODateTime, | ||
url: anyLocalURL, | ||
visibility: 'public' | ||
}; | ||
|
||
describe('tag.* 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('tag.added event is triggered', async function () { | ||
const webhookURL = 'https://test-webhook-receiver.com/tag-added/'; | ||
await webhookMockReceiver.mock(webhookURL); | ||
await fixtureManager.insertWebhook({ | ||
event: 'tag.added', | ||
url: webhookURL | ||
}); | ||
|
||
await adminAPIAgent | ||
.post('tags/') | ||
.body({ | ||
tags: [{ | ||
name: 'Test Tag', | ||
slug: 'test-tag', | ||
description: 'Test Description' | ||
}] | ||
}) | ||
.expectStatus(201); | ||
|
||
await webhookMockReceiver.receivedRequest(); | ||
|
||
webhookMockReceiver | ||
.matchHeaderSnapshot({ | ||
'content-version': anyContentVersion, | ||
'content-length': anyNumber, | ||
'user-agent': anyGhostAgent | ||
}) | ||
.matchBodySnapshot({ | ||
tag: { | ||
current: tagSnapshot | ||
} | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The anyUuid matcher is not used anywhere in the test. Would be great to clean these up as you go 🙌