From b63e5a624dd7b68f7942448c9f290d7c08d742e5 Mon Sep 17 00:00:00 2001 From: Dotta Date: Thu, 9 Jul 2026 17:53:46 +0000 Subject: [PATCH] Fix sidebar nav class token assertion Co-Authored-By: Paperclip --- ui/src/components/SidebarNavItem.test.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ui/src/components/SidebarNavItem.test.tsx b/ui/src/components/SidebarNavItem.test.tsx index 959a80fd1b5..cd99a274cc7 100644 --- a/ui/src/components/SidebarNavItem.test.tsx +++ b/ui/src/components/SidebarNavItem.test.tsx @@ -68,6 +68,10 @@ describe("SidebarNavItem", () => { return container.querySelector("a") as HTMLAnchorElement; } + function classTokens(element: Element | null | undefined) { + return element?.className.toString().split(/\s+/).filter(Boolean) ?? []; + } + it("shows the full label and numeric badge when expanded", () => { render(); @@ -89,8 +93,8 @@ describe("SidebarNavItem", () => { const label = Array.from(container.querySelectorAll("span")).find((el) => el.textContent === "Inbox"); expect(label).toBeTruthy(); expect(label?.className).not.toContain("sr-only"); - expect(label?.className).toContain("w-0"); - expect(label?.className).toContain("overflow-hidden"); + expect(classTokens(label)).toContain("w-0"); + expect(classTokens(label)).toContain("overflow-hidden"); // The numeric count is no longer rendered as text; it is a dot with an // accessible text equivalent on the link. @@ -142,8 +146,8 @@ describe("SidebarNavItem", () => { ); const label = Array.from(container.querySelectorAll("span")).find((el) => el.textContent === "Inbox"); - expect(label?.className).not.toContain("w-0"); - expect(label?.className).toContain("flex-1"); + expect(classTokens(label)).not.toContain("w-0"); + expect(classTokens(label)).toContain("flex-1"); // Full numeric badge, no rail aria-label, no tooltip wrapper. expect(container.textContent).toContain("28"); expect(link().getAttribute("aria-label")).toBeNull();