feat(auth): signUp publishes userSignedUpEvent

signUpUseCase now takes an IEventBus and publishes userSignedUpEvent
after creating the user (synthesizing email from username since auth
is username-based). Use case mocks-default in module.ts get a fresh
InMemoryEventBus per resolution; bind-production / bind-dev-seed wire
the shared bus passed by bindAll. Tests updated to inject
RecordingEventBus, including a new test that asserts publish on
success and silence on failure.
This commit is contained in:
2026-05-08 16:28:21 +02:00
parent 7f63adf740
commit c1b8a7e434
7 changed files with 67 additions and 9 deletions

View File

@@ -2,6 +2,7 @@
// Constructs the full chain via direct injection (no container rebinding).
import { describe, it, expect } from "vitest";
import { RecordingEventBus } from "@repo/core-testing/instrumentation";
import { MockUsersRepository } from "../src/infrastructure/repositories/users.repository.mock";
import { MockAuthenticationService } from "../src/infrastructure/services/authentication.service.mock";
import { signInUseCase } from "../src/application/use-cases/sign-in.use-case";
@@ -18,7 +19,7 @@ describe("auth feature: sign-up → sign-in → sign-out", () => {
const auth = new MockAuthenticationService(users);
const signIn = signInController(signInUseCase(users, auth));
const signUp = signUpController(signUpUseCase(users, auth));
const signUp = signUpController(signUpUseCase(users, auth, new RecordingEventBus()));
const signOut = signOutController(signOutUseCase(auth));
// signUp returns a cookie (presenter shape)