mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 22:02:16 +00:00
Teach the arrival-wiring mock about isScopedCredential
That file stubs @/lib/api-handler wholesale, so it lists the exports it knew about when it was written. /api/measurements now reaches for isScopedCredential to decide source attribution and whether the sync checkpoint may move, the mock does not provide it, and every test in the file dies on import rather than on an assertion. `false` is the honest stub: those cases resolve as a cookie session, which is exactly what unscoped means, so the route takes its ordinary path through both rules. Checked the rest of the tree rather than fixing only the file that went red — this is the only suite mocking that module for a route which reaches the new export. The batch route's tests mock at a different seam and are unaffected. Not verified here: this environment cannot generate the Prisma client, so that file is one of the suites which fail to import for an unrelated reason and the fix could not be run.
This commit is contained in:
1 file changed
+6
@@ -15,6 +15,12 @@ const SELF = {
|
||||
vi.mock("@/lib/api-handler", () => ({
|
||||
apiHandler: (fn: unknown) => fn,
|
||||
requireRecordAuth: vi.fn(async () => ({ user: SELF, actor: SELF })),
|
||||
// These cases resolve as a cookie session, which is what "unscoped" means:
|
||||
// no narrow Bearer admitted the request, so the route's source and
|
||||
// sync-checkpoint rules take their ordinary path. Stubbed rather than
|
||||
// omitted because this file mocks the module wholesale, so an export the
|
||||
// route reaches for and the mock does not list fails the import outright.
|
||||
isScopedCredential: vi.fn(() => false),
|
||||
}));
|
||||
|
||||
vi.mock("@/lib/idempotency", () => ({
|
||||
|
||||
Reference in new issue
Block a user