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:
@@ -65,13 +65,17 @@ vi.mock("../db", () => {
|
||||
const user = makeTableProxy("user");
|
||||
|
||||
const buildQuery = (result: unknown, fallback: unknown) => ({
|
||||
limit: () => ({
|
||||
[Symbol.iterator]: function* () {
|
||||
if (result) yield result;
|
||||
},
|
||||
0: result,
|
||||
length: result ? 1 : 0,
|
||||
}),
|
||||
[Symbol.iterator]: function* () {
|
||||
if (result) yield result;
|
||||
},
|
||||
limit: (_n: number) => {
|
||||
const item = result ?? fallback;
|
||||
return {
|
||||
[Symbol.iterator]: function* () { if (item) yield item; },
|
||||
0: item,
|
||||
length: item ? 1 : 0,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
@@ -130,6 +130,9 @@ export const resolveStaffMiddleware: MiddlewareHandler<AppEnv> = async (
|
||||
active: true,
|
||||
})
|
||||
.returning();
|
||||
if (!newStaff) {
|
||||
return c.json({ error: "Internal error: staff record creation failed" }, 500);
|
||||
}
|
||||
c.set("staff", newStaff);
|
||||
await next();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user