Skip to content

Commit

Permalink
api: webhook: fix process event (#2310)
Browse files Browse the repository at this point in the history
  • Loading branch information
gioelecerati authored Sep 13, 2024
1 parent cbcbfb4 commit 36c85c8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 20 additions & 0 deletions packages/api/src/webhooks/cannon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,26 @@ describe("webhook cannon", () => {
expect(calledFlags).toEqual([true, true]);
});

it("should fetch correct webhooks with listSubscribed", async () => {
const webhook1 = await client.post(`/webhook`, {
...mockWebhook,
name: "test-1",
});
expect(webhook1.status).toBe(201);

const webhook2 = await client.post(`/webhook`, {
...mockWebhook,
url: mockWebhook.url + "2",
name: "test-2",
});

expect(webhook2.status).toBe(201);

const subscribed = await client.get(`/webhook/subscribed/stream.started`);
const subscribedJson = await subscribed.json();
expect(subscribedJson.length).toBe(2);
});

it("should not receive events for unrelated project", async () => {
const differentProject = await db.project.create({
name: "different project",
Expand Down
1 change: 0 additions & 1 deletion packages/api/src/webhooks/cannon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ export default class WebhookCannon {
const { data: webhooks } = await db.webhook.listSubscribed(
userId,
event,
null,
projectId,
user.defaultProjectId,
);
Expand Down

0 comments on commit 36c85c8

Please sign in to comment.