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
+4
-26
@@ -3,13 +3,11 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { LoaderFunctionArgs } from "react-router";
|
||||
import { loader } from "./index";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { findEntityByName } from "~/utils/db/entities/entities.db.server";
|
||||
import { adminGetAllTenantsWithUsage } from "~/utils/db/tenants.db.server";
|
||||
import { getAllTenantTypes } from "~/utils/db/tenants/tenantTypes.db.server";
|
||||
import { adminGetAllUsersNames } from "~/utils/db/users.db.server";
|
||||
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
|
||||
import { getFiltersFromCurrentUrl, getPaginationFromCurrentUrl } from "~/utils/helpers/RowPaginationHelper";
|
||||
import { getStripeInvoices } from "~/utils/stripe.server";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (key: string) => key }),
|
||||
@@ -29,7 +27,6 @@ vi.mock("react-router", async () => {
|
||||
|
||||
vi.mock("~/components/core/tenants/DeactivateTenantModal", () => ({ default: () => null }));
|
||||
vi.mock("~/components/core/tenants/TenantsTable", () => ({ default: () => null }));
|
||||
vi.mock("~/components/entities/rows/RowProperties", () => ({ default: () => null }));
|
||||
vi.mock("~/components/ui/button", () => ({ Button: () => null }));
|
||||
vi.mock("~/components/ui/forms/FormGroup", () => ({ default: () => null }));
|
||||
vi.mock("~/components/ui/input/InputCheckboxWithDescription", () => ({ default: () => null }));
|
||||
@@ -52,7 +49,6 @@ vi.mock("~/utils/api/.server/TenantsApi", () => ({ TenantsApi: { create: vi.fn()
|
||||
vi.mock("~/utils/app/UrlUtils", () => ({ default: { slugify: (value: string) => value.toLowerCase() } }));
|
||||
vi.mock("~/utils/csrf", () => ({ appendCSRFToken: vi.fn() }));
|
||||
vi.mock("~/utils/data/useAppOrAdminData", () => ({ useAppOrAdminData: () => ({}) }));
|
||||
vi.mock("~/utils/db/entities/entities.db.server", () => ({ findEntityByName: vi.fn() }));
|
||||
vi.mock("~/utils/db/permissions/roles.db.server", () => ({ getAllRoles: vi.fn() }));
|
||||
vi.mock("~/utils/db/tenants.db.server", () => ({
|
||||
adminGetAllTenantsWithUsage: vi.fn(),
|
||||
@@ -69,18 +65,13 @@ vi.mock("~/utils/helpers/RowPaginationHelper", () => ({
|
||||
}));
|
||||
vi.mock("~/utils/services/tenantService", () => ({ getExistingSlug: vi.fn() }));
|
||||
vi.mock("~/utils/session.server", () => ({ validateCSRFToken: vi.fn() }));
|
||||
vi.mock("~/utils/stripe.server", () => ({
|
||||
getStripeInvoices: vi.fn(),
|
||||
isStripeTestMode: vi.fn(() => true),
|
||||
}));
|
||||
|
||||
const tenants = [
|
||||
{
|
||||
id: "tenant-1",
|
||||
name: "Acme",
|
||||
slug: "acme",
|
||||
createdAt: new Date("2026-05-01T00:00:00.000Z"),
|
||||
subscription: { stripeCustomerId: "cus_1" },
|
||||
subscription: { billingProviderCustomerId: "cus_1" },
|
||||
},
|
||||
{
|
||||
id: "tenant-2",
|
||||
@@ -99,7 +90,7 @@ function callLoader(url = "https://admin.example.test/accounts") {
|
||||
describe("admin accounts invoice hydration", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
process.env.APP_NAME = "ToolCTRL";
|
||||
process.env.APP_NAME = "HiveGrid";
|
||||
vi.mocked(verifyUserHasPermission).mockResolvedValue(undefined as never);
|
||||
vi.mocked(getTranslations).mockResolvedValue({ t: (key: string) => `translated:${key}` } as never);
|
||||
vi.mocked(adminGetAllUsersNames).mockResolvedValue([] as never);
|
||||
@@ -110,27 +101,14 @@ describe("admin accounts invoice hydration", () => {
|
||||
items: tenants,
|
||||
pagination: { page: 1, pageSize: 10, totalItems: tenants.length, totalPages: 1 },
|
||||
} as never);
|
||||
vi.mocked(findEntityByName).mockResolvedValue(null as never);
|
||||
vi.mocked(getStripeInvoices).mockResolvedValue([{ id: "in_1", customer: "cus_1" }] as never);
|
||||
});
|
||||
|
||||
it("does not load Stripe invoices for the default tenant list", async () => {
|
||||
it("loads the default tenant list without processor invoice hydration", async () => {
|
||||
const response = await callLoader();
|
||||
const body = await response.json();
|
||||
|
||||
expect(verifyUserHasPermission).toHaveBeenCalledWith(expect.any(Request), "admin.accounts.view");
|
||||
expect(getStripeInvoices).not.toHaveBeenCalled();
|
||||
expect(body.tenantInvoices).toBeUndefined();
|
||||
expect(body.includeInvoices).toBe(false);
|
||||
});
|
||||
|
||||
it("loads invoices only when includeInvoices is explicitly requested", async () => {
|
||||
const response = await callLoader("https://admin.example.test/accounts?includeInvoices=true");
|
||||
const body = await response.json();
|
||||
|
||||
expect(getStripeInvoices).toHaveBeenCalledTimes(1);
|
||||
expect(getStripeInvoices).toHaveBeenCalledWith("cus_1", { limit: 10 });
|
||||
expect(body.tenantInvoices).toEqual([{ id: "in_1", customer: "cus_1" }]);
|
||||
expect(body.includeInvoices).toBe(true);
|
||||
expect(body).not.toHaveProperty("includeInvoices");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user