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
+46
-1
@@ -101,6 +101,7 @@ import {
|
||||
getTenantsInIds,
|
||||
requireTenant,
|
||||
updateTenant,
|
||||
updateTenantAnrede,
|
||||
updateTenantDeactivated,
|
||||
updateTenantTheme,
|
||||
} from "./tenants.db.server";
|
||||
@@ -233,12 +234,40 @@ describe("tenants db wrapper", () => {
|
||||
expect(result.pagination).toEqual({ page: 1, pageSize: 10, totalItems: 3, totalPages: 1 });
|
||||
});
|
||||
|
||||
it("filters for tenants without any type when typeId is 'null' and no base or user filter exists", async () => {
|
||||
vi.mocked(RowFiltersHelper.getFiltersCondition).mockReturnValue(undefined as never);
|
||||
vi.mocked(dbMock.tenant.findMany).mockResolvedValueOnce([] as never);
|
||||
vi.mocked(dbMock.tenant.count).mockResolvedValueOnce(0);
|
||||
|
||||
await adminGetAllTenantsWithUsage({ query: "", properties: [{ name: "typeId", value: "null" }] } as never);
|
||||
|
||||
expect(dbMock.tenant.findMany).toHaveBeenCalledWith(expect.objectContaining({ where: { types: { none: {} } } }));
|
||||
expect(dbMock.tenant.count).toHaveBeenCalledWith({ where: { types: { none: {} } } });
|
||||
});
|
||||
|
||||
it("filters by a concrete tenant type when no base or user filter exists", async () => {
|
||||
vi.mocked(RowFiltersHelper.getFiltersCondition).mockReturnValue(undefined as never);
|
||||
vi.mocked(dbMock.tenant.findMany).mockResolvedValueOnce([] as never);
|
||||
vi.mocked(dbMock.tenant.count).mockResolvedValueOnce(0);
|
||||
|
||||
await adminGetAllTenantsWithUsage({ query: "", properties: [{ name: "typeId", value: "type_pro" }] } as never);
|
||||
|
||||
expect(dbMock.tenant.findMany).toHaveBeenCalledWith(expect.objectContaining({ where: { types: { some: { id: "type_pro" } } } }));
|
||||
});
|
||||
|
||||
it("throws a descriptive error when requireTenant cannot resolve a tenant", async () => {
|
||||
vi.mocked(dbMock.tenant.findUnique).mockResolvedValueOnce(null);
|
||||
|
||||
await expect(requireTenant("tenant_missing")).rejects.toThrow("Tenant not found: tenant_missing");
|
||||
});
|
||||
|
||||
it("returns the resolved tenant when requireTenant finds one", async () => {
|
||||
vi.mocked(dbMock.tenant.findUnique).mockResolvedValueOnce({ id: "tenant_1" } as never);
|
||||
|
||||
await expect(requireTenant("tenant_1")).resolves.toEqual({ id: "tenant_1" });
|
||||
expect(cachified).toHaveBeenCalledWith(expect.objectContaining({ key: "tenant:tenant_1" }));
|
||||
});
|
||||
|
||||
it("returns null early for tenant-with-users and tenant-user lookups without ids", async () => {
|
||||
await expect(getTenantWithUsers()).resolves.toBeNull();
|
||||
await expect(getTenantUser()).resolves.toBeNull();
|
||||
@@ -412,6 +441,23 @@ describe("tenants db wrapper", () => {
|
||||
expect(clearCacheKeyPrefix).toHaveBeenCalledWith("apiKeyHash:");
|
||||
});
|
||||
|
||||
it("updates the tenant Anrede (du/Sie) and invalidates all identity and api-key caches", async () => {
|
||||
vi.mocked(dbMock.tenant.update).mockResolvedValueOnce({ id: "tenant_1", slug: "acme" } as never);
|
||||
|
||||
await updateTenantAnrede("tenant_1", "du");
|
||||
|
||||
expect(dbMock.tenant.update).toHaveBeenCalledWith({
|
||||
where: { id: "tenant_1" },
|
||||
data: { anrede: "du" },
|
||||
});
|
||||
expect(clearCacheKey).toHaveBeenCalledWith("tenant:acme");
|
||||
expect(clearCacheKey).toHaveBeenCalledWith("tenant:tenant_1");
|
||||
expect(clearCacheKey).toHaveBeenCalledWith("tenantIdOrSlug:tenant_1");
|
||||
expect(clearCacheKey).toHaveBeenCalledWith("tenantIdOrSlug:acme");
|
||||
expect(clearCacheKey).toHaveBeenCalledWith("tenantSimple:tenant_1");
|
||||
expect(clearCacheKeyPrefix).toHaveBeenCalledWith("apiKeyHash:");
|
||||
});
|
||||
|
||||
it("adds a tenant type and clears tenant cache keys", async () => {
|
||||
vi.mocked(dbMock.tenant.update).mockResolvedValueOnce({ id: "tenant_1", slug: "acme" } as never);
|
||||
|
||||
@@ -549,7 +595,6 @@ describe("tenants db wrapper", () => {
|
||||
subscription: true,
|
||||
users: true,
|
||||
invitations: true,
|
||||
rows: true,
|
||||
logs: true,
|
||||
apiKeys: true,
|
||||
userRoles: true,
|
||||
|
||||
Reference in new issue
Block a user