fix(GRO-1272): fix TS2769 and test mock iterable issues

- Add null guard for newStaff after .returning() in auto-provision block
- Make buildQuery() iterable without .limit() call (for WHERE-only queries)
- Use fallback in .limit() for manager-fallback dev-mode tests

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-20 13:19:23 +00:00
committed by Flea Flicker
parent 4a80440513
commit f9b68eb932
2 changed files with 14 additions and 7 deletions
+11 -7
View File
@@ -65,13 +65,17 @@ vi.mock("../db", () => {
const user = makeTableProxy("user"); const user = makeTableProxy("user");
const buildQuery = (result: unknown, fallback: unknown) => ({ const buildQuery = (result: unknown, fallback: unknown) => ({
limit: () => ({ [Symbol.iterator]: function* () {
[Symbol.iterator]: function* () { if (result) yield result;
if (result) yield result; },
}, limit: (_n: number) => {
0: result, const item = result ?? fallback;
length: result ? 1 : 0, return {
}), [Symbol.iterator]: function* () { if (item) yield item; },
0: item,
length: item ? 1 : 0,
};
},
}); });
return { return {
+3
View File
@@ -130,6 +130,9 @@ export const resolveStaffMiddleware: MiddlewareHandler<AppEnv> = async (
active: true, active: true,
}) })
.returning(); .returning();
if (!newStaff) {
return c.json({ error: "Internal error: staff record creation failed" }, 500);
}
c.set("staff", newStaff); c.set("staff", newStaff);
await next(); await next();
return; return;