test(web-next): e2e cross-feature sign-up→welcome-email flow

End-to-end proof-of-life. bindAllDevSeed wires InMemoryEventBus +
InMemoryJobQueue across all features. signUpController publishes
auth.user.signed-up; marketing-pages' handler enqueues
marketing-pages.send-welcome-email; the in-memory queue dispatches
the wrapped job which records on RecordingMailerService.

Adds ./di/container, ./di/symbols, ./services/mailer, and
./services/recording-mailer to auth + marketing-pages exports so
the e2e test can resolve from the per-feature containers without
deep-importing.
This commit is contained in:
2026-05-08 16:37:37 +02:00
parent 7e844c646d
commit 04899de98c
3 changed files with 52 additions and 2 deletions

View File

@@ -0,0 +1,44 @@
// Cross-feature proof-of-life: signing up in @repo/auth publishes
// userSignedUpEvent on the shared bus, marketing-pages' subscriber enqueues
// a send-welcome-email job on the shared queue, and dev-seed's
// InMemoryJobQueue.register() dispatches it to the wrapped job — which
// records the call on the bound RecordingMailerService.
import "reflect-metadata";
import { describe, it, expect, beforeEach } from "vitest";
import { bindAllDevSeed, __resetBindStateForTests } from "@/server/bind-production";
import { authContainer } from "@repo/auth/di/container";
import { AUTH_SYMBOLS } from "@repo/auth/di/symbols";
import type { ISignUpController } from "@repo/auth";
import { marketingPagesContainer } from "@repo/marketing-pages/di/container";
import { MARKETING_PAGES_SYMBOLS } from "@repo/marketing-pages/di/symbols";
import { RecordingMailerService } from "@repo/marketing-pages/services/recording-mailer";
describe("e2e: sign-up triggers welcome email via cross-feature event", () => {
beforeEach(() => {
__resetBindStateForTests();
});
it("delivers a welcome email after a successful sign-up", async () => {
await bindAllDevSeed();
const mailer = marketingPagesContainer.get<RecordingMailerService>(
MARKETING_PAGES_SYMBOLS.IMailerService,
);
const signUp = authContainer.get<ISignUpController>(AUTH_SYMBOLS.ISignUpController);
await signUp({
username: "testuser",
password: "secret_password",
confirmPassword: "secret_password",
});
// The InMemoryJobQueue dispatches the registered handler on setImmediate;
// wait for microtasks + one setImmediate tick to settle.
await new Promise((r) => setImmediate(r));
expect(mailer.sent).toEqual([
{ userId: expect.any(String), email: "testuser@example.local" },
]);
});
});

View File

@@ -9,7 +9,9 @@
"./cms": "./src/integrations/cms/index.ts",
"./api": "./src/integrations/api/router.ts",
"./di/bind-production": "./src/di/bind-production.ts",
"./di/bind-dev-seed": "./src/di/bind-dev-seed.ts"
"./di/bind-dev-seed": "./src/di/bind-dev-seed.ts",
"./di/container": "./src/di/container.ts",
"./di/symbols": "./src/di/symbols.ts"
},
"scripts": {
"build": "tsc --noEmit",

View File

@@ -9,7 +9,11 @@
"./cms": "./src/integrations/cms/index.ts",
"./api": "./src/integrations/api/router.ts",
"./di/bind-production": "./src/di/bind-production.ts",
"./di/bind-dev-seed": "./src/di/bind-dev-seed.ts"
"./di/bind-dev-seed": "./src/di/bind-dev-seed.ts",
"./di/container": "./src/di/container.ts",
"./di/symbols": "./src/di/symbols.ts",
"./services/mailer": "./src/application/services/mailer.service.interface.ts",
"./services/recording-mailer": "./src/infrastructure/services/recording-mailer.service.ts"
},
"scripts": {
"build": "tsc --noEmit",