mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 23:52:24 +00:00
test: type the new fixtures instead of casting them to never
The fixtures added with these fixes switched the type checker off with `as never`, which the realism ratchet refuses to see grow. They now carry their types, three webhook mocks needed no cast at all, and the lowered counts, with the targets route's one fewer version stamp, are written back.
This commit is contained in:
1 parent
315c89d229
commit
2af0751b69
10 files changed
+31
-23
No files matched your search
@@ -362,7 +362,7 @@ describe("resolveProviderForTest — empty override resolves via the chain", ()
|
||||
aiLocalKeyEncrypted: null,
|
||||
aiOpenaiKeyEncrypted: null,
|
||||
aiProviderChain: [{ providerType: "openai", priority: 1, enabled: true }],
|
||||
} as never);
|
||||
} as unknown as Awaited<ReturnType<typeof prisma.user.findUnique>>);
|
||||
|
||||
const provider = await resolveProviderForTest("user-123", {});
|
||||
expect(provider.type).toBe("none");
|
||||
|
||||
@@ -230,9 +230,7 @@ describe("resolveProviderChain and the picked gateway", () => {
|
||||
|
||||
/** Serve `chain` as the record's saved chain; Codex is not connected. */
|
||||
async function resolveWith(chain: unknown) {
|
||||
vi.mocked(prisma.user.findUnique).mockImplementation((async (args: {
|
||||
select?: Record<string, unknown>;
|
||||
}) =>
|
||||
const read = async (args: { select?: Record<string, unknown> }) =>
|
||||
args.select?.codexAccessTokenEncrypted
|
||||
? {
|
||||
codexAccessTokenEncrypted: null,
|
||||
@@ -240,7 +238,10 @@ describe("resolveProviderChain and the picked gateway", () => {
|
||||
codexTokenExpiresAt: null,
|
||||
codexConnectionStatus: "disconnected",
|
||||
}
|
||||
: { ...gatewayRow, aiProviderChain: chain }) as never);
|
||||
: { ...gatewayRow, aiProviderChain: chain };
|
||||
vi.mocked(prisma.user.findUnique).mockImplementation(
|
||||
read as unknown as typeof prisma.user.findUnique,
|
||||
);
|
||||
operator({ adminAiKeyEncrypted: null });
|
||||
return (await resolveProviderChain("user-1")).map((c) => c.providerType);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
* account only possession of a factor counts now; the account without one is
|
||||
* unchanged.
|
||||
*/
|
||||
import type { NextRequest } from "next/server";
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
|
||||
vi.mock("@/lib/db", () => ({
|
||||
@@ -252,10 +253,10 @@ describe("POST /api/auth/passkey/register-options", () => {
|
||||
vi.mocked(requireCookieAuth).mockResolvedValue({
|
||||
user: stored(PLAIN),
|
||||
session: { id: "sess-1" },
|
||||
} as never);
|
||||
} as unknown as Awaited<ReturnType<typeof requireCookieAuth>>);
|
||||
vi.mocked(verifyPassword).mockResolvedValue(false);
|
||||
const res = await PASSKEY_REGISTER_OPTIONS(
|
||||
passkeyReq({ method: "password", password: "typo" }) as never,
|
||||
passkeyReq({ method: "password", password: "typo" }) as NextRequest,
|
||||
);
|
||||
expect(res.status).toBe(401);
|
||||
expect((await res.json()).meta.errorCode).toBe("auth.reproof.failed");
|
||||
|
||||
@@ -102,7 +102,7 @@ describe("applyProfileUpdate date of birth", () => {
|
||||
// the zone resolver caches per account.
|
||||
vi.mocked(prisma.user.findUnique).mockResolvedValue({
|
||||
timezone: "Pacific/Tongatapu",
|
||||
} as never);
|
||||
} as unknown as Awaited<ReturnType<typeof prisma.user.findUnique>>);
|
||||
await applyProfileUpdate("user-tonga", {
|
||||
dateOfBirth: "2012-05-13T20:30:00Z",
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user