Files
outline/server/queues/processors/UserDeletedProcessor.test.ts
T
Tom Moor e044014cea fix: Disable webhooks when deleting associated user (#12524)
* fix: Disable webhooks created by deleted users

* Delete -> disable
2026-05-29 17:44:29 -04:00

56 lines
1.3 KiB
TypeScript

import UserAuthentication from "@server/models/UserAuthentication";
import { buildUser, buildWebhookSubscription } from "@server/test/factories";
import UserDeletedProcessor from "./UserDeletedProcessor";
const ip = "127.0.0.1";
describe("UserDeletedProcessor", () => {
it("should remove relationships", async () => {
const user = await buildUser();
expect(
await UserAuthentication.count({
where: {
userId: user.id,
},
})
).toBe(1);
const processor = new UserDeletedProcessor();
await processor.perform({
name: "users.delete",
userId: user.id,
actorId: user.id,
teamId: user.teamId,
ip,
});
expect(
await UserAuthentication.count({
where: {
userId: user.id,
},
})
).toBe(0);
});
it("should disable webhook subscriptions created by the user", async () => {
const user = await buildUser();
const webhook = await buildWebhookSubscription({
teamId: user.teamId,
createdById: user.id,
});
const processor = new UserDeletedProcessor();
await processor.perform({
name: "users.delete",
userId: user.id,
actorId: user.id,
teamId: user.teamId,
ip,
});
await webhook.reload();
expect(webhook.enabled).toEqual(false);
});
});