Skip to content
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

api: webhook: fix process event #2310

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading