feat: Automatic invite reminder email (#3354)
* feat: Add user flags concept, for tracking bits on a user * feat: Example flag usage for user invite resend abuse * wip * test * fix: Set correct flag
This commit is contained in:
37
server/queues/tasks/InviteReminderTask.test.ts
Normal file
37
server/queues/tasks/InviteReminderTask.test.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { subDays } from "date-fns";
|
||||
import InviteReminderEmail from "@server/emails/templates/InviteReminderEmail";
|
||||
import { buildInvite } from "@server/test/factories";
|
||||
import { flushdb } from "@server/test/support";
|
||||
import InviteReminderTask from "./InviteReminderTask";
|
||||
|
||||
beforeEach(() => flushdb());
|
||||
|
||||
describe("InviteReminderTask", () => {
|
||||
it("should not destroy documents not deleted", async () => {
|
||||
const spy = jest.spyOn(InviteReminderEmail, "schedule");
|
||||
|
||||
// too old
|
||||
await buildInvite({
|
||||
createdAt: subDays(new Date(), 3.5),
|
||||
});
|
||||
|
||||
// too new
|
||||
await buildInvite({
|
||||
createdAt: new Date(),
|
||||
});
|
||||
|
||||
// should send reminder
|
||||
await buildInvite({
|
||||
createdAt: subDays(new Date(), 2.5),
|
||||
});
|
||||
|
||||
const task = new InviteReminderTask();
|
||||
await task.perform();
|
||||
|
||||
// running twice to make sure the email is only sent once
|
||||
await task.perform();
|
||||
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
spy.mockRestore();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user