|
|
|
|
@@ -4,9 +4,6 @@ vi.mock("@repo/core-cms", () => ({ default: Promise.resolve({}) }));
|
|
|
|
|
vi.mock("payload", () => ({
|
|
|
|
|
getPayload: vi.fn(async () => ({ jobs: { queue: vi.fn() } })),
|
|
|
|
|
}));
|
|
|
|
|
vi.mock("@repo/blog/di/bind-production", () => ({
|
|
|
|
|
bindProductionBlog: vi.fn(),
|
|
|
|
|
}));
|
|
|
|
|
vi.mock("@repo/auth/di/bind-production", () => ({
|
|
|
|
|
bindProductionAuth: vi.fn(),
|
|
|
|
|
}));
|
|
|
|
|
@@ -19,7 +16,6 @@ vi.mock("@repo/navigation/di/bind-production", () => ({
|
|
|
|
|
vi.mock("@repo/media/di/bind-production", () => ({
|
|
|
|
|
bindProductionMedia: vi.fn(),
|
|
|
|
|
}));
|
|
|
|
|
vi.mock("@repo/blog/di/bind-dev-seed", () => ({ bindDevSeedBlog: vi.fn() }));
|
|
|
|
|
vi.mock("@repo/auth/di/bind-dev-seed", () => ({ bindDevSeedAuth: vi.fn() }));
|
|
|
|
|
vi.mock("@repo/marketing-pages/di/bind-dev-seed", () => ({
|
|
|
|
|
bindDevSeedMarketingPages: vi.fn(),
|
|
|
|
|
@@ -47,10 +43,8 @@ describe("bindAllProduction", () => {
|
|
|
|
|
vi.clearAllMocks();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("binds all five feature production repos", async () => {
|
|
|
|
|
it("binds all four feature production repos", async () => {
|
|
|
|
|
const { bindAllProduction } = await import("./bind-production");
|
|
|
|
|
const { bindProductionBlog } =
|
|
|
|
|
await import("@repo/blog/di/bind-production");
|
|
|
|
|
const { bindProductionAuth } =
|
|
|
|
|
await import("@repo/auth/di/bind-production");
|
|
|
|
|
const { bindProductionMarketingPages } =
|
|
|
|
|
@@ -62,7 +56,6 @@ describe("bindAllProduction", () => {
|
|
|
|
|
|
|
|
|
|
await bindAllProduction();
|
|
|
|
|
|
|
|
|
|
expect(bindProductionBlog).toHaveBeenCalledOnce();
|
|
|
|
|
expect(bindProductionAuth).toHaveBeenCalledOnce();
|
|
|
|
|
expect(bindProductionMarketingPages).toHaveBeenCalledOnce();
|
|
|
|
|
expect(bindProductionNavigation).toHaveBeenCalledOnce();
|
|
|
|
|
@@ -72,11 +65,11 @@ describe("bindAllProduction", () => {
|
|
|
|
|
it("is idempotent via bindAll — second call does not re-bind", async () => {
|
|
|
|
|
vi.stubEnv("NODE_ENV", "production");
|
|
|
|
|
const { bindAll } = await import("./bind-production");
|
|
|
|
|
const { bindProductionBlog } =
|
|
|
|
|
await import("@repo/blog/di/bind-production");
|
|
|
|
|
const { bindProductionAuth } =
|
|
|
|
|
await import("@repo/auth/di/bind-production");
|
|
|
|
|
await bindAll();
|
|
|
|
|
await bindAll();
|
|
|
|
|
expect(bindProductionBlog).toHaveBeenCalledOnce();
|
|
|
|
|
expect(bindProductionAuth).toHaveBeenCalledOnce();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("passes a Payload-backed queue to each per-feature binder", async () => {
|
|
|
|
|
@@ -127,54 +120,54 @@ describe("bindAll dispatcher", () => {
|
|
|
|
|
vi.stubEnv("USE_DEV_SEED", "true");
|
|
|
|
|
vi.stubEnv("NODE_ENV", "production"); // even in production, dev seed wins
|
|
|
|
|
const { bindAll } = await import("./bind-production");
|
|
|
|
|
const { bindDevSeedBlog } = await import("@repo/blog/di/bind-dev-seed");
|
|
|
|
|
const { bindProductionBlog } =
|
|
|
|
|
await import("@repo/blog/di/bind-production");
|
|
|
|
|
const { bindDevSeedAuth } = await import("@repo/auth/di/bind-dev-seed");
|
|
|
|
|
const { bindProductionAuth } =
|
|
|
|
|
await import("@repo/auth/di/bind-production");
|
|
|
|
|
|
|
|
|
|
await bindAll();
|
|
|
|
|
|
|
|
|
|
expect(bindDevSeedBlog).toHaveBeenCalledOnce();
|
|
|
|
|
expect(bindProductionBlog).not.toHaveBeenCalled();
|
|
|
|
|
expect(bindDevSeedAuth).toHaveBeenCalledOnce();
|
|
|
|
|
expect(bindProductionAuth).not.toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("NODE_ENV='production' (no override) → dispatches to bindAllProduction", async () => {
|
|
|
|
|
vi.stubEnv("NODE_ENV", "production");
|
|
|
|
|
const { bindAll } = await import("./bind-production");
|
|
|
|
|
const { bindProductionBlog } =
|
|
|
|
|
await import("@repo/blog/di/bind-production");
|
|
|
|
|
const { bindDevSeedBlog } = await import("@repo/blog/di/bind-dev-seed");
|
|
|
|
|
const { bindProductionAuth } =
|
|
|
|
|
await import("@repo/auth/di/bind-production");
|
|
|
|
|
const { bindDevSeedAuth } = await import("@repo/auth/di/bind-dev-seed");
|
|
|
|
|
|
|
|
|
|
await bindAll();
|
|
|
|
|
|
|
|
|
|
expect(bindProductionBlog).toHaveBeenCalledOnce();
|
|
|
|
|
expect(bindDevSeedBlog).not.toHaveBeenCalled();
|
|
|
|
|
expect(bindProductionAuth).toHaveBeenCalledOnce();
|
|
|
|
|
expect(bindDevSeedAuth).not.toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("NODE_ENV='development' → dispatches to bindAllDevSeed (developer default)", async () => {
|
|
|
|
|
vi.stubEnv("NODE_ENV", "development");
|
|
|
|
|
const { bindAll } = await import("./bind-production");
|
|
|
|
|
const { bindDevSeedBlog } = await import("@repo/blog/di/bind-dev-seed");
|
|
|
|
|
const { bindProductionBlog } =
|
|
|
|
|
await import("@repo/blog/di/bind-production");
|
|
|
|
|
const { bindDevSeedAuth } = await import("@repo/auth/di/bind-dev-seed");
|
|
|
|
|
const { bindProductionAuth } =
|
|
|
|
|
await import("@repo/auth/di/bind-production");
|
|
|
|
|
|
|
|
|
|
await bindAll();
|
|
|
|
|
|
|
|
|
|
expect(bindDevSeedBlog).toHaveBeenCalledOnce();
|
|
|
|
|
expect(bindProductionBlog).not.toHaveBeenCalled();
|
|
|
|
|
expect(bindDevSeedAuth).toHaveBeenCalledOnce();
|
|
|
|
|
expect(bindProductionAuth).not.toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("USE_DEV_SEED='false' is treated as not-set (only 'true' triggers dev seed)", async () => {
|
|
|
|
|
vi.stubEnv("USE_DEV_SEED", "false");
|
|
|
|
|
vi.stubEnv("NODE_ENV", "production");
|
|
|
|
|
const { bindAll } = await import("./bind-production");
|
|
|
|
|
const { bindProductionBlog } =
|
|
|
|
|
await import("@repo/blog/di/bind-production");
|
|
|
|
|
const { bindDevSeedBlog } = await import("@repo/blog/di/bind-dev-seed");
|
|
|
|
|
const { bindProductionAuth } =
|
|
|
|
|
await import("@repo/auth/di/bind-production");
|
|
|
|
|
const { bindDevSeedAuth } = await import("@repo/auth/di/bind-dev-seed");
|
|
|
|
|
|
|
|
|
|
await bindAll();
|
|
|
|
|
|
|
|
|
|
expect(bindProductionBlog).toHaveBeenCalledOnce();
|
|
|
|
|
expect(bindDevSeedBlog).not.toHaveBeenCalled();
|
|
|
|
|
expect(bindProductionAuth).toHaveBeenCalledOnce();
|
|
|
|
|
expect(bindDevSeedAuth).not.toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -225,12 +218,12 @@ describe("bindAll instrumentation orthogonality", () => {
|
|
|
|
|
const { bindAll } = await import("./bind-production");
|
|
|
|
|
const { bindOtelInstrumentation } =
|
|
|
|
|
await import("@repo/core-shared/instrumentation");
|
|
|
|
|
const { bindDevSeedBlog } = await import("@repo/blog/di/bind-dev-seed");
|
|
|
|
|
const { bindDevSeedAuth } = await import("@repo/auth/di/bind-dev-seed");
|
|
|
|
|
|
|
|
|
|
await bindAll();
|
|
|
|
|
|
|
|
|
|
expect(bindOtelInstrumentation).toHaveBeenCalledOnce();
|
|
|
|
|
expect(bindDevSeedBlog).toHaveBeenCalledOnce();
|
|
|
|
|
expect(bindDevSeedAuth).toHaveBeenCalledOnce();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("Noop instrumentation works alongside production binding (DSN unset, NODE_ENV=production)", async () => {
|
|
|
|
|
@@ -239,12 +232,12 @@ describe("bindAll instrumentation orthogonality", () => {
|
|
|
|
|
const { bindAll } = await import("./bind-production");
|
|
|
|
|
const { bindNoopInstrumentation } =
|
|
|
|
|
await import("@repo/core-shared/instrumentation");
|
|
|
|
|
const { bindProductionBlog } =
|
|
|
|
|
await import("@repo/blog/di/bind-production");
|
|
|
|
|
const { bindProductionAuth } =
|
|
|
|
|
await import("@repo/auth/di/bind-production");
|
|
|
|
|
|
|
|
|
|
await bindAll();
|
|
|
|
|
|
|
|
|
|
expect(bindNoopInstrumentation).toHaveBeenCalledOnce();
|
|
|
|
|
expect(bindProductionBlog).toHaveBeenCalledOnce();
|
|
|
|
|
expect(bindProductionAuth).toHaveBeenCalledOnce();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|