Track HiveGrid Cloud planning reference

This commit is contained in:
david committed 2026-06-26 20:48:01 +02:00
1 parent b3d5ea6764
commit e341c5938a
5784 files changed
+1104929 -3

No files matched your search

@@ -0,0 +1,55 @@
import "@testing-library/jest-dom";
import { render, screen, within } from "@testing-library/react";
import { MemoryRouter } from "react-router";
import { describe, expect, it, vi } from "vitest";
import { DashboardStats } from "./DashboardStats";
vi.mock("react-i18next", () => ({
useTranslation: () => ({
t: (key: string, options?: Record<string, string>) => {
if (key === "shared.statComparison") {
return `translated from ${options?.[0]}`;
}
return key;
},
}),
}));
function renderDashboardStats() {
return render(
<MemoryRouter>
<DashboardStats
items={[
{
name: "admin.kpi.accounts.name",
hint: "admin.kpi.accounts.hint",
stat: "12",
previousStat: "9",
},
{
name: "admin.kpi.activeUsers.name",
hint: "admin.kpi.activeUsers.hint",
stat: "48",
},
]}
/>
</MemoryRouter>
);
}
describe("DashboardStats", () => {
it("renders translated comparison copy when previousStat is present", () => {
renderDashboardStats();
expect(screen.getByText("translated from 9")).toBeInTheDocument();
});
it("does not render comparison copy for cards without previousStat", () => {
renderDashboardStats();
const activeUsersCard = screen.getByText("admin.kpi.activeUsers.name").closest(".truncate")?.parentElement;
expect(activeUsersCard).not.toBeNull();
expect(within(activeUsersCard as HTMLElement).queryByText(/translated from/i)).not.toBeInTheDocument();
});
});