From 0a406faefc896e3398030833c551c1a8f58e8a08 Mon Sep 17 00:00:00 2001 From: Shakker Date: Tue, 11 Aug 2026 18:01:17 +0200 Subject: [PATCH] test: remove duplicate tab reorder coverage (#122128) --- ui/src/components/panel-tab-strip.test.ts | 82 ----------------------- 1 file changed, 82 deletions(-) diff --git a/ui/src/components/panel-tab-strip.test.ts b/ui/src/components/panel-tab-strip.test.ts index 2d0bff8aab6b..9ecf602589f5 100644 --- a/ui/src/components/panel-tab-strip.test.ts +++ b/ui/src/components/panel-tab-strip.test.ts @@ -15,15 +15,6 @@ const TAB: PanelTabStripTab = { closeLabel: "Close tab: First tab", }; -type RenderedTab = HTMLElement & { - active: boolean; - panel: string; -}; - -type RenderedTabGroup = HTMLElement & { - active: string; -}; - function renderStrip(options: { tabs?: PanelTabStripTab[]; activeId?: string | null; @@ -48,18 +39,6 @@ function renderStrip(options: { return container; } -function readTabStrip(container: ParentNode): { - group: RenderedTabGroup; - tabs: RenderedTab[]; -} { - const group = container.querySelector("wa-tab-group"); - if (!group) { - throw new Error("expected rendered tab group"); - } - const tabs = [...container.querySelectorAll("wa-tab")]; - return { group, tabs }; -} - afterEach(() => { document.body.replaceChildren(); }); @@ -104,65 +83,4 @@ describe("renderPanelTabStrip", () => { container.querySelector("wa-tab")?.dispatchEvent(new MouseEvent("auxclick", { button: 1 })); expect(onClose).toHaveBeenCalledWith(TAB.id); }); - - it("keeps the controlled active tab coherent when stateful tab elements reorder", async () => { - const first: PanelTabStripTab = { - ...TAB, - id: "a", - domId: "test-tab-a", - label: "Alpha", - title: "https://example.com/a", - }; - const second: PanelTabStripTab = { - ...TAB, - id: "b", - domId: "test-tab-b", - label: "Beta", - title: "https://example.com/b", - }; - const container = renderStrip({ tabs: [first, second], activeId: first.id }); - document.body.append(container); - const initial = readTabStrip(container); - const firstElement = initial.tabs.find((tab) => tab.panel === first.id); - const secondElement = initial.tabs.find((tab) => tab.panel === second.id); - if (!firstElement || !secondElement) { - throw new Error("expected initial active tab"); - } - firstElement.active = true; - firstElement.setAttribute("active", ""); - firstElement.setAttribute("aria-selected", "true"); - firstElement.tabIndex = 0; - secondElement.active = false; - secondElement.removeAttribute("active"); - secondElement.setAttribute("aria-selected", "false"); - secondElement.tabIndex = -1; - - renderStrip({ - container, - tabs: [ - { ...second, label: "Beta navigated", title: "https://example.com/b/next" }, - { ...first, label: "Alpha navigated", title: "https://example.com/a/next" }, - ], - activeId: first.id, - }); - - await vi.waitFor(() => { - const reordered = readTabStrip(container); - const active = reordered.tabs.filter( - (tab) => - tab.active || tab.hasAttribute("active") || tab.getAttribute("aria-selected") === "true", - ); - const reorderedFirst = reordered.tabs.find((tab) => tab.panel === first.id); - - expect(reorderedFirst).toBe(firstElement); - expect(reordered.group.active).toBe(first.id); - expect(active).toEqual([firstElement]); - expect(firstElement.getAttribute("aria-selected")).toBe("true"); - expect(firstElement.tabIndex).toBe(0); - expect(reordered.tabs.find((tab) => tab.panel === second.id)).toMatchObject({ - active: false, - tabIndex: -1, - }); - }); - }); });