fix(GRO-1272): address QA review items for rbac.test.ts
CI / Lint & Typecheck (pull_request) Failing after 15s
CI / Test (pull_request) Failing after 20s
CI / Build (pull_request) Has been skipped
CI / Build & Push Docker Images (pull_request) Has been skipped
CI / Update Infra Image Tags (pull_request) Has been skipped

- Rename insertedStaff to _insertedStaff (ESLint unused var, line 49)
- Rename table param to _table in insert mock (ESLint unused param, line 91)
- Fix buildApp jwtPayload to prefer userLookupResult.id over staffLookupResult.userId
  (corrects auto-provision test failures where sub was 'unknown-sub' instead of 'ba-user-new')

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-20 13:37:49 +00:00
committed by Flea Flicker [agent]
parent 5bbbcceabf
commit 746b0fb9c6
+5 -5
View File
@@ -46,7 +46,7 @@ const GROOMER: StaffRow = {
let staffLookupResult: StaffRow | null = null; let staffLookupResult: StaffRow | null = null;
let managerFallbackResult: StaffRow | null = MANAGER; let managerFallbackResult: StaffRow | null = MANAGER;
let userLookupResult: { id: string; name: string | null; email: string | null } | null = null; let userLookupResult: { id: string; name: string | null; email: string | null } | null = null;
let insertedStaff: StaffRow | null = null; let _insertedStaff: StaffRow | null = null;
vi.mock("../db", () => { vi.mock("../db", () => {
const makeTableProxy = (name: string) => const makeTableProxy = (name: string) =>
@@ -88,7 +88,7 @@ vi.mock("../db", () => {
), ),
}), }),
}), }),
insert: (table: unknown) => ({ insert: (_table: unknown) => ({
values: (vals: Record<string, unknown>) => ({ values: (vals: Record<string, unknown>) => ({
returning: () => { returning: () => {
const newStaff: StaffRow = { const newStaff: StaffRow = {
@@ -104,7 +104,7 @@ vi.mock("../db", () => {
createdAt: new Date(), createdAt: new Date(),
updatedAt: new Date(), updatedAt: new Date(),
}; };
insertedStaff = newStaff; _insertedStaff = newStaff;
return [newStaff]; return [newStaff];
}, },
}), }),
@@ -124,7 +124,7 @@ function resetMocks() {
staffLookupResult = null; staffLookupResult = null;
managerFallbackResult = MANAGER; managerFallbackResult = MANAGER;
userLookupResult = null; userLookupResult = null;
insertedStaff = null; _insertedStaff = null;
} }
/** Build a minimal Hono app with jwtPayload pre-set, then apply a middleware. */ /** Build a minimal Hono app with jwtPayload pre-set, then apply a middleware. */
@@ -134,7 +134,7 @@ function buildApp(
) { ) {
const app = new Hono<AppEnv>(); const app = new Hono<AppEnv>();
app.use("*", async (c, next) => { app.use("*", async (c, next) => {
c.set("jwtPayload", { sub: staffLookupResult?.userId ?? "unknown-sub" }); c.set("jwtPayload", { sub: userLookupResult?.id ?? staffLookupResult?.userId ?? "unknown-sub" });
await next(); await next();
}); });
app.use("*", middleware); app.use("*", middleware);