fix(tests): use AppEnv type for clients test Hono app
Properly type the test app with AppEnv so c.set("staff", ...) satisfies
TypeScript's strict overload check. Fixes TS2769 typecheck failure on CI.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
|
import type { AppEnv } from "../middleware/rbac.js";
|
||||||
|
|
||||||
// ─── Mock data ────────────────────────────────────────────────────────────────
|
// ─── Mock data ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -104,9 +105,9 @@ vi.mock("@groombook/db", () => {
|
|||||||
|
|
||||||
const { clientsRouter } = await import("../routes/clients.js");
|
const { clientsRouter } = await import("../routes/clients.js");
|
||||||
|
|
||||||
const app = new Hono();
|
const app = new Hono<AppEnv>();
|
||||||
app.use("*", async (c, next) => {
|
app.use("*", async (c, next) => {
|
||||||
c.set("staff", { id: "staff-uuid-1", role: "manager" } as never);
|
c.set("staff", { id: "staff-uuid-1", role: "manager" } as AppEnv["Variables"]["staff"]);
|
||||||
await next();
|
await next();
|
||||||
});
|
});
|
||||||
app.route("/clients", clientsRouter);
|
app.route("/clients", clientsRouter);
|
||||||
|
|||||||
Reference in New Issue
Block a user