Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+44
@@ -0,0 +1,44 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import {
|
||||
findLegacyUserWithoutPasswordById,
|
||||
updateLegacyUserDefaultTenantId,
|
||||
type LegacyUserDefaultTenantWriterClient,
|
||||
type LegacyUserWithoutPasswordReaderClient,
|
||||
} from "./users.server.js";
|
||||
|
||||
describe("findLegacyUserWithoutPasswordById error handling", () => {
|
||||
it("returns null instead of propagating a read failure", async () => {
|
||||
const client = {
|
||||
user: {
|
||||
findUnique: vi.fn().mockRejectedValue(new Error("connection lost")),
|
||||
},
|
||||
} as unknown as LegacyUserWithoutPasswordReaderClient;
|
||||
|
||||
await expect(findLegacyUserWithoutPasswordById("user_1", client)).resolves.toBeNull();
|
||||
expect(client.user.findUnique).toHaveBeenCalledOnce();
|
||||
});
|
||||
});
|
||||
|
||||
describe("updateLegacyUserDefaultTenantId", () => {
|
||||
it("updates the default tenant for a valid user id", async () => {
|
||||
const update = vi.fn().mockResolvedValue({ id: "user_1", defaultTenantId: "tenant_2" });
|
||||
const client = { user: { update } } as unknown as LegacyUserDefaultTenantWriterClient;
|
||||
|
||||
const result = await updateLegacyUserDefaultTenantId({ defaultTenantId: "tenant_2" }, "user_1", client);
|
||||
|
||||
expect(result).toEqual({ id: "user_1", defaultTenantId: "tenant_2" });
|
||||
expect(update).toHaveBeenCalledWith({
|
||||
where: { id: "user_1" },
|
||||
data: { defaultTenantId: "tenant_2" },
|
||||
});
|
||||
});
|
||||
|
||||
it("short-circuits to null when the user id is empty", async () => {
|
||||
const update = vi.fn();
|
||||
const client = { user: { update } } as unknown as LegacyUserDefaultTenantWriterClient;
|
||||
|
||||
await expect(updateLegacyUserDefaultTenantId({ defaultTenantId: "tenant_2" }, "", client)).resolves.toBeNull();
|
||||
expect(update).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user