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:
@@ -1,4 +1,5 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { RecordingEventBus } from "@repo/core-testing/instrumentation";
|
||||
import { signUpController } from "@/interface-adapters/controllers/sign-up.controller";
|
||||
import { MockUsersRepository } from "@/infrastructure/repositories/users.repository.mock";
|
||||
import { MockAuthenticationService } from "@/infrastructure/services/authentication.service.mock";
|
||||
@@ -10,7 +11,7 @@ describe("signUpController", () => {
|
||||
it("returns a cookie on successful sign-up", async () => {
|
||||
const users = new MockUsersRepository([]);
|
||||
const auth = new MockAuthenticationService(users);
|
||||
const useCase = signUpUseCase(users, auth);
|
||||
const useCase = signUpUseCase(users, auth, new RecordingEventBus());
|
||||
const controller = signUpController(useCase);
|
||||
|
||||
const result = await controller({
|
||||
@@ -25,7 +26,7 @@ describe("signUpController", () => {
|
||||
it("throws InputParseError when passwords do not match", async () => {
|
||||
const users = new MockUsersRepository([]);
|
||||
const auth = new MockAuthenticationService(users);
|
||||
const useCase = signUpUseCase(users, auth);
|
||||
const useCase = signUpUseCase(users, auth, new RecordingEventBus());
|
||||
const controller = signUpController(useCase);
|
||||
|
||||
await expect(
|
||||
@@ -41,7 +42,7 @@ describe("signUpController", () => {
|
||||
const users = new MockUsersRepository([]);
|
||||
const auth = new MockAuthenticationService(users);
|
||||
await users.createUser(userFactory.build({ username: "alice" }));
|
||||
const useCase = signUpUseCase(users, auth);
|
||||
const useCase = signUpUseCase(users, auth, new RecordingEventBus());
|
||||
const controller = signUpController(useCase);
|
||||
|
||||
await expect(
|
||||
|
||||
Reference in New Issue
Block a user