Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
+56
@@ -0,0 +1,56 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { bootstrapFormSubmissionWebhookDelivery } from "./form-submission-webhook-delivery-bootstrap.js";
|
||||
import { FORM_SUBMISSION_WEBHOOK_OUTBOX_QUEUE } from "./form-submission-webhook-delivery.js";
|
||||
|
||||
function buildHandlerDeps() {
|
||||
return {
|
||||
enqueueWebhook: vi.fn(async () => undefined),
|
||||
};
|
||||
}
|
||||
|
||||
describe("bootstrapFormSubmissionWebhookDelivery", () => {
|
||||
it("disables itself outside the mail worker group", () => {
|
||||
const res = bootstrapFormSubmissionWebhookDelivery({ WORKER_QUEUE_GROUP: "general" } as Record<string, string>);
|
||||
expect(res.status).toBe("disabled");
|
||||
if (res.status === "disabled") expect(res.reason).toMatch(/non-mail/);
|
||||
});
|
||||
|
||||
it("disables itself when the env flag is false", () => {
|
||||
const res = bootstrapFormSubmissionWebhookDelivery({
|
||||
WORKER_QUEUE_GROUP: "mail",
|
||||
FORM_SUBMISSION_WEBHOOK_DELIVERY_ENABLED: "false",
|
||||
} as Record<string, string>);
|
||||
expect(res.status).toBe("disabled");
|
||||
if (res.status === "disabled") expect(res.reason).toMatch(/FORM_SUBMISSION_WEBHOOK_DELIVERY_ENABLED/);
|
||||
});
|
||||
|
||||
it("subscribes to outbox.webhook on the mail worker group", () => {
|
||||
const create = vi.fn(() => ({ name: FORM_SUBMISSION_WEBHOOK_OUTBOX_QUEUE, close: async () => undefined }));
|
||||
const res = bootstrapFormSubmissionWebhookDelivery(
|
||||
{ WORKER_QUEUE_GROUP: "mail" } as Record<string, string>,
|
||||
{ handlerDeps: buildHandlerDeps(), createWorkerImpl: create },
|
||||
);
|
||||
expect(res.status).toBe("started");
|
||||
expect(create).toHaveBeenCalledWith(
|
||||
FORM_SUBMISSION_WEBHOOK_OUTBOX_QUEUE,
|
||||
expect.any(Function),
|
||||
expect.objectContaining({ concurrency: 5 }),
|
||||
);
|
||||
});
|
||||
|
||||
it("honours FORM_SUBMISSION_WEBHOOK_DELIVERY_CONCURRENCY", () => {
|
||||
const create = vi.fn(() => ({ name: FORM_SUBMISSION_WEBHOOK_OUTBOX_QUEUE, close: async () => undefined }));
|
||||
bootstrapFormSubmissionWebhookDelivery(
|
||||
{
|
||||
WORKER_QUEUE_GROUP: "mail",
|
||||
FORM_SUBMISSION_WEBHOOK_DELIVERY_CONCURRENCY: "9",
|
||||
} as Record<string, string>,
|
||||
{ handlerDeps: buildHandlerDeps(), createWorkerImpl: create },
|
||||
);
|
||||
expect(create).toHaveBeenCalledWith(
|
||||
FORM_SUBMISSION_WEBHOOK_OUTBOX_QUEUE,
|
||||
expect.any(Function),
|
||||
expect.objectContaining({ concurrency: 9 }),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user