0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Added webhook fixute utils

refs https://github.com/TryGhost/Toolbox/issues/320

- There will be more webhook e2e tests coming which require easy webhook fixture creation
This commit is contained in:
Naz 2022-05-30 15:05:17 +08:00 committed by naz
parent c7e833545b
commit 041a32934a
2 changed files with 18 additions and 0 deletions

View file

@ -281,6 +281,13 @@ const getAgentsForMembers = async () => {
};
};
const insertWebhook = ({event, url}) => {
return fixtureUtils.fixtures.insertWebhook({
event: event,
target_url: url
});
};
module.exports = {
// request agent
agentProvider: {
@ -297,6 +304,7 @@ module.exports = {
// DB State Manipulation
fixtureManager: {
get: getFixture,
insertWebhook: insertWebhook,
getCurrentOwnerUser: fixtureUtils.getCurrentOwnerUser,
init: initFixtures,
restore: resetData,

View file

@ -436,6 +436,16 @@ const fixtures = {
});
},
insertWebhook: function (attributes) {
const webhook = DataGenerator.forKnex.createWebhook(
Object.assign(attributes, {
integration_id: DataGenerator.forKnex.integrations[0].id
})
);
return models.Webhook.add(webhook, context.internal);
},
insertWebhooks: function insertWebhooks() {
return Promise.map(DataGenerator.forKnex.webhooks, function (webhook) {
return models.Webhook.add(webhook, context.internal);