From 0fa53645b9bbd4c85dcf8fc261d0815a770f18f9 Mon Sep 17 00:00:00 2001 From: Flea Flicker Date: Fri, 27 Mar 2026 01:52:25 +0000 Subject: [PATCH] fix(tests): inject mock staff context in clients test suite RBAC Phase 2 added row-level scoping that reads c.get("staff") on every clients route. The test app had no middleware setting this context, causing a TypeError (undefined.role) and 500 responses on all GET tests. Add a manager-role mock staff middleware to the test Hono app so the existing tests continue to cover the non-groomer code path. Co-Authored-By: Paperclip --- apps/api/src/__tests__/clients.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/api/src/__tests__/clients.test.ts b/apps/api/src/__tests__/clients.test.ts index 38a2886..ff7b2d3 100644 --- a/apps/api/src/__tests__/clients.test.ts +++ b/apps/api/src/__tests__/clients.test.ts @@ -105,6 +105,10 @@ vi.mock("@groombook/db", () => { const { clientsRouter } = await import("../routes/clients.js"); const app = new Hono(); +app.use("*", async (c, next) => { + c.set("staff", { id: "staff-uuid-1", role: "manager" } as never); + await next(); +}); app.route("/clients", clientsRouter); function jsonRequest(method: string, path: string, body?: unknown) {