chore: Refactor worker, emails and data cleanup to task system (#3337)
* Refactor worker, all emails on task system * fix * lint * fix: Remove a bunch of expect-error comments in related tests * refactor: Move work from utils.gc into tasks * test * Add tracing to tasks and processors fix: DebounceProcessor triggering on all events Event.add -> Event.schedule
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import TestServer from "fetch-test-server";
|
||||
import mailer from "@server/mailer";
|
||||
import EmailTask from "@server/queues/tasks/EmailTask";
|
||||
import webService from "@server/services/web";
|
||||
import { buildUser, buildGuestUser, buildTeam } from "@server/test/factories";
|
||||
import { flushdb } from "@server/test/support";
|
||||
@@ -24,7 +24,7 @@ describe("email", () => {
|
||||
});
|
||||
|
||||
it("should respond with redirect location when user is SSO enabled", async () => {
|
||||
const spy = jest.spyOn(mailer, "sendTemplate");
|
||||
const spy = jest.spyOn(EmailTask, "schedule");
|
||||
const user = await buildUser();
|
||||
const res = await server.post("/auth/email", {
|
||||
body: {
|
||||
@@ -42,7 +42,7 @@ describe("email", () => {
|
||||
process.env.URL = "http://localoutline.com";
|
||||
process.env.SUBDOMAINS_ENABLED = "true";
|
||||
const user = await buildUser();
|
||||
const spy = jest.spyOn(mailer, "sendTemplate");
|
||||
const spy = jest.spyOn(EmailTask, "schedule");
|
||||
await buildTeam({
|
||||
subdomain: "example",
|
||||
});
|
||||
@@ -62,7 +62,7 @@ describe("email", () => {
|
||||
});
|
||||
|
||||
it("should respond with success when user is not SSO enabled", async () => {
|
||||
const spy = jest.spyOn(mailer, "sendTemplate");
|
||||
const spy = jest.spyOn(EmailTask, "schedule");
|
||||
const user = await buildGuestUser();
|
||||
const res = await server.post("/auth/email", {
|
||||
body: {
|
||||
@@ -77,7 +77,7 @@ describe("email", () => {
|
||||
});
|
||||
|
||||
it("should respond with success regardless of whether successful to prevent crawling email logins", async () => {
|
||||
const spy = jest.spyOn(mailer, "sendTemplate");
|
||||
const spy = jest.spyOn(EmailTask, "schedule");
|
||||
const res = await server.post("/auth/email", {
|
||||
body: {
|
||||
email: "user@example.com",
|
||||
@@ -91,7 +91,7 @@ describe("email", () => {
|
||||
});
|
||||
describe("with multiple users matching email", () => {
|
||||
it("should default to current subdomain with SSO", async () => {
|
||||
const spy = jest.spyOn(mailer, "sendTemplate");
|
||||
const spy = jest.spyOn(EmailTask, "schedule");
|
||||
process.env.URL = "http://localoutline.com";
|
||||
process.env.SUBDOMAINS_ENABLED = "true";
|
||||
const email = "sso-user@example.org";
|
||||
@@ -121,7 +121,7 @@ describe("email", () => {
|
||||
});
|
||||
|
||||
it("should default to current subdomain with guest email", async () => {
|
||||
const spy = jest.spyOn(mailer, "sendTemplate");
|
||||
const spy = jest.spyOn(EmailTask, "schedule");
|
||||
process.env.URL = "http://localoutline.com";
|
||||
process.env.SUBDOMAINS_ENABLED = "true";
|
||||
const email = "guest-user@example.org";
|
||||
@@ -151,7 +151,7 @@ describe("email", () => {
|
||||
});
|
||||
|
||||
it("should default to custom domain with SSO", async () => {
|
||||
const spy = jest.spyOn(mailer, "sendTemplate");
|
||||
const spy = jest.spyOn(EmailTask, "schedule");
|
||||
const email = "sso-user-2@example.org";
|
||||
const team = await buildTeam({
|
||||
domain: "docs.mycompany.com",
|
||||
@@ -179,7 +179,7 @@ describe("email", () => {
|
||||
});
|
||||
|
||||
it("should default to custom domain with guest email", async () => {
|
||||
const spy = jest.spyOn(mailer, "sendTemplate");
|
||||
const spy = jest.spyOn(EmailTask, "schedule");
|
||||
const email = "guest-user-2@example.org";
|
||||
const team = await buildTeam({
|
||||
domain: "docs.mycompany.com",
|
||||
|
||||
Reference in New Issue
Block a user