Files
outline/server/queues/processors/NotificationsProcessor.test.ts
Tom Moor 8af64ee306 feat: Notify users when added to or removed from a group (#13999)
* feat: Notify users when added to or removed from a group

* Replace unread group membership notifications on change, link removals to group
2026-10-10 08:38:23 -04:00

53 lines
1.5 KiB
TypeScript

import { buildGroup, buildUser } from "@server/test/factories";
import GroupUserNotificationsTask from "../tasks/GroupUserNotificationsTask";
import NotificationsProcessor from "./NotificationsProcessor";
const ip = "127.0.0.1";
describe("NotificationsProcessor", () => {
describe("group membership", () => {
let schedule: ReturnType<typeof vi.spyOn>;
beforeEach(() => {
schedule = vi.spyOn(GroupUserNotificationsTask.prototype, "schedule");
});
afterEach(() => {
schedule.mockRestore();
});
it("should schedule a notification when another user changes membership", async () => {
const actor = await buildUser();
const user = await buildUser({ teamId: actor.teamId });
const group = await buildGroup({ teamId: actor.teamId });
await new NotificationsProcessor().perform({
name: "groups.add_user",
userId: user.id,
modelId: group.id,
teamId: actor.teamId,
actorId: actor.id,
ip,
});
expect(schedule).toHaveBeenCalledTimes(1);
});
it("should not schedule a notification when the user changes their own membership", async () => {
const user = await buildUser();
const group = await buildGroup({ teamId: user.teamId });
await new NotificationsProcessor().perform({
name: "groups.add_user",
userId: user.id,
modelId: group.id,
teamId: user.teamId,
actorId: user.id,
ip,
});
expect(schedule).not.toHaveBeenCalled();
});
});
});