From 17bf9fd0c173d8c76a94be8ae0a35caf13622888 Mon Sep 17 00:00:00 2001 From: Danijel Martinek Date: Tue, 12 May 2026 21:49:57 +0200 Subject: [PATCH] test(auth): assert unwrapped factory rejected at branded slot --- .../auth/src/di/bind-production.types.test.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 packages/auth/src/di/bind-production.types.test.ts diff --git a/packages/auth/src/di/bind-production.types.test.ts b/packages/auth/src/di/bind-production.types.test.ts new file mode 100644 index 0000000..7782a3a --- /dev/null +++ b/packages/auth/src/di/bind-production.types.test.ts @@ -0,0 +1,28 @@ +import { describe, it } from "vitest"; +import type { ProductionUseCase } from "@repo/core-shared/conformance"; +import type { AuthManifest } from "../feature.manifest"; +import type { + SignInInput, + SignInOutput, +} from "../application/use-cases/sign-in.use-case"; +import { signInUseCase } from "../application/use-cases/sign-in.use-case"; + +describe("auth.signIn binding slot (type-level)", () => { + it("rejects an unwrapped factory", () => { + type Slot = ProductionUseCase< + SignInInput, + SignInOutput, + AuthManifest["useCases"]["signIn"] + >; + + // Build the unwrapped factory exactly as it would be at the use-case file. + // It returns a function with no brand attached — must not be assignable. + const fakeRepo = {} as never; + const fakeAuth = {} as never; + const unwrapped = signInUseCase(fakeRepo, fakeAuth); + + // @ts-expect-error — unwrapped factory has no __instrumented / __captured brand + const _bad: Slot = unwrapped; + void _bad; + }); +});