refactor: remove core-events from main (scaffoldable via gen core-package events)
- Delete packages/core-events/ (15 files) - Strip @repo/core-events from all 5 feature package.json + apps/web-next/package.json - Strip @repo/core-events from apps/web-next/next.config.mjs transpilePackages - Strip E1 + J no-restricted-syntax blocks from core-eslint/base.js (anchor remains) - Update bind-production.ts: drop bus construction + IEventBus import; rename resolveEventsAndJobsProduction → resolveJobsProduction (queue only), resolveEventsAndJobsDevSeed → resolveJobsDevSeed (queue only); ctx no longer has bus field; BindProductionContext generic arg narrowed - Update bind-production.test.ts: assert ctx.bus is undefined, drop PayloadJobsEventBus/InMemoryEventBus instanceof checks - Update sign-up-welcome-email.test.ts: assert mailer stays empty without bus - Inline userSignedUpEvent in auth (drop defineEvent import from core-events) - Drop InMemoryEventBus fallback from auth/di/module.ts Feature binders' bus?.subscribe/publish calls remain as no-ops. Scaffold @repo/core-events back via: pnpm turbo gen core-package events Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,16 @@
|
||||
// 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.
|
||||
// Cross-feature event bus proof-of-life (DISABLED — @repo/core-events removed).
|
||||
//
|
||||
// @repo/core-events is now optional. When absent, ctx.bus is undefined, and
|
||||
// bus?.subscribe(...) / bus?.publish(...) calls are no-ops. Cross-feature event
|
||||
// fanout does not occur until core-events is scaffolded via:
|
||||
//
|
||||
// pnpm turbo gen core-package events
|
||||
//
|
||||
// After scaffolding, restore this test and re-wire the bus in bind-production.ts
|
||||
// (see the comment in bindAll()). Until then, signing up does NOT trigger a
|
||||
// welcome email — the mailer queue stays empty.
|
||||
//
|
||||
// Replaced with a reduced test that asserts the no-bus behavior.
|
||||
|
||||
import "reflect-metadata";
|
||||
import { describe, it, expect, beforeEach } from "vitest";
|
||||
@@ -14,12 +22,12 @@ 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", () => {
|
||||
describe("e2e: sign-up with no event bus (core-events not scaffolded)", () => {
|
||||
beforeEach(() => {
|
||||
__resetBindStateForTests();
|
||||
});
|
||||
|
||||
it("delivers a welcome email after a successful sign-up", async () => {
|
||||
it("sign-up succeeds and mailer stays empty (no cross-feature fanout without bus)", async () => {
|
||||
await bindAllDevSeed();
|
||||
|
||||
const mailer = marketingPagesContainer.get<RecordingMailerService>(
|
||||
@@ -33,12 +41,10 @@ describe("e2e: sign-up triggers welcome email via cross-feature event", () => {
|
||||
confirmPassword: "secret_password",
|
||||
});
|
||||
|
||||
// The InMemoryJobQueue dispatches the registered handler on setImmediate;
|
||||
// wait for microtasks + one setImmediate tick to settle.
|
||||
// Without a bus, bus?.subscribe() is a no-op so the event handler never
|
||||
// fires and the mailer receives nothing.
|
||||
await new Promise((r) => setImmediate(r));
|
||||
|
||||
expect(mailer.sent).toEqual([
|
||||
{ userId: expect.any(String), email: "testuser@example.local" },
|
||||
]);
|
||||
expect(mailer.sent).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user