From defe617a7125ed1ea97d374d986396c6b794218c Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 19 Jun 2026 00:47:53 +0000 Subject: [PATCH] test: address CodeRabbit nitpicks - use toMatchInlineSnapshot and document as-any cast Co-Authored-By: mantra --- apps/backend/src/lib/platform-admin.test.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/apps/backend/src/lib/platform-admin.test.ts b/apps/backend/src/lib/platform-admin.test.ts index fa3e2eafd..4e010a354 100644 --- a/apps/backend/src/lib/platform-admin.test.ts +++ b/apps/backend/src/lib/platform-admin.test.ts @@ -8,9 +8,11 @@ vi.mock("./projects", () => ({ const mockListManagedProjectIds = vi.mocked(projects.listManagedProjectIds); -// Minimal stub satisfying the UsersCrud["Admin"]["Read"] shape required by the functions. -// The actual user object is only forwarded to listManagedProjectIds, which is mocked. -const fakeUser = { id: "user-1" } as Parameters[0]; +// The actual user object is only forwarded to listManagedProjectIds, which is +// mocked, so the concrete shape doesn't matter. UsersCrud["Admin"]["Read"] is a +// large generated type; building a full fixture adds noise without value here. +// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- see above +const fakeUser: Parameters[0] = { id: "user-1" } as any; describe("isPlatformAdmin", () => { it("returns true when user manages the internal project", async () => { @@ -38,16 +40,15 @@ describe("ensurePlatformAdmin", () => { it("throws a 403 StatusError for non-platform-admins", async () => { mockListManagedProjectIds.mockResolvedValue(["customer-project"]); - await expect(ensurePlatformAdmin(fakeUser)).rejects.toMatchObject({ - statusCode: 403, - message: "You do not have access to platform analytics.", - }); + await expect(ensurePlatformAdmin(fakeUser)).rejects.toMatchInlineSnapshot( + `[StatusError: You do not have access to platform analytics.]` + ); }); it("throws a 403 StatusError when user manages no projects at all", async () => { mockListManagedProjectIds.mockResolvedValue([]); - await expect(ensurePlatformAdmin(fakeUser)).rejects.toMatchObject({ - statusCode: 403, - }); + await expect(ensurePlatformAdmin(fakeUser)).rejects.toMatchInlineSnapshot( + `[StatusError: You do not have access to platform analytics.]` + ); }); });