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,102 @@
import "@testing-library/jest-dom";
import { render, screen } from "@testing-library/react";
import { MemoryRouter } from "react-router";
import { describe, expect, it, vi } from "vitest";
import { SidebarProvider } from "~/components/ui/sidebar";
import { NavSecondary } from "./nav-secondary";
vi.mock("~/hooks/use-mobile", () => ({
useIsMobile: () => false,
}));
describe("NavSecondary", () => {
it("renders permitted collapsible parents as links with separate toggle controls", () => {
render(
<MemoryRouter initialEntries={["/settings/profile"]}>
<SidebarProvider>
<NavSecondary
item={{
id: "ui.nav.admin.secondary",
title: "",
items: [
{
id: "ui.nav.admin.settings",
title: "Settings",
path: "/settings",
isActive: true,
items: [
{
id: "ui.nav.admin.settings.profile",
title: "Profile",
path: "/settings/profile",
},
],
},
],
}}
/>
</SidebarProvider>
</MemoryRouter>
);
expect(screen.getByRole("link", { name: "Settings" })).toHaveAttribute("href", "/settings");
expect(screen.getByRole("link", { name: "Settings" })).toHaveAttribute("data-active", "true");
expect(screen.getByRole("button", { name: "Toggle Settings" })).toBeInTheDocument();
expect(screen.getByRole("link", { name: "Profile" })).toHaveAttribute("href", "/settings/profile");
});
it("hides disabled secondary items and honors redirect targets", () => {
render(
<MemoryRouter initialEntries={["/settings/profile"]}>
<SidebarProvider>
<NavSecondary
item={{
title: "",
items: [
{
title: "Settings",
path: "/settings",
isActive: true,
items: [
{ title: "Profile", path: "/settings", redirectTo: "/settings/profile" },
{ title: "Disabled Plugin", path: "/disabled-plugin", disabled: true },
],
},
{ title: "Disabled Root", path: "/disabled-root", disabled: true },
],
}}
/>
</SidebarProvider>
</MemoryRouter>
);
expect(screen.getByRole("link", { name: "Profile" })).toHaveAttribute("href", "/settings/profile");
expect(screen.queryByRole("link", { name: "Disabled Plugin" })).not.toBeInTheDocument();
expect(screen.queryByRole("link", { name: "Disabled Root" })).not.toBeInTheDocument();
});
it("does not turn parents with only disabled children into links", () => {
render(
<MemoryRouter initialEntries={["/settings"]}>
<SidebarProvider>
<NavSecondary
item={{
title: "",
items: [
{
title: "Settings",
path: "/settings",
items: [{ title: "Disabled Plugin", path: "/settings/plugin", disabled: true }],
},
],
}}
/>
</SidebarProvider>
</MemoryRouter>
);
expect(screen.queryByRole("link", { name: "Settings" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: /Settings/ })).not.toBeInTheDocument();
expect(screen.queryByRole("link", { name: "Disabled Plugin" })).not.toBeInTheDocument();
});
});