// @vitest-environment jsdom import { screen } from "@testing-library/react"; import { useContext } from "react"; import { describe, expect, it } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; import Container from "./container"; import { BlockHighlightContext } from "./highlight-context"; function Dummy({ label }) { return
; } function HighlightProbe() { const value = useContext(BlockHighlightContext); return
; } describe("components/services/widget/container", () => { it("filters children based on widget.fields (auto-namespaced by widget type)", () => { renderWithProviders( , { settings: {} }, ); expect(screen.getByTestId("omada.connectedAp")).toBeInTheDocument(); expect(screen.getByTestId("omada.alerts")).toBeInTheDocument(); expect(screen.queryByTestId("omada.activeUser")).toBeNull(); }); it("accepts widget.fields as a JSON string", () => { renderWithProviders( , { settings: {} }, ); expect(screen.getByTestId("omada.alerts")).toBeInTheDocument(); expect(screen.queryByTestId("omada.connectedAp")).toBeNull(); }); it("supports aliased widget types when filtering (hoarder -> karakeep)", () => { renderWithProviders( , { settings: {} }, ); expect(screen.getByTestId("karakeep.count")).toBeInTheDocument(); }); it("supports seerr aliases when filtering (jellyseerr/overseerr -> seerr)", () => { renderWithProviders( , { settings: {} }, ); expect(screen.getByTestId("seerr.pending")).toBeInTheDocument(); renderWithProviders( , { settings: {} }, ); expect(screen.getByTestId("seerr.processing")).toBeInTheDocument(); }); it("returns null when errors are hidden via settings.hideErrors", () => { const { container } = renderWithProviders( , { settings: { hideErrors: true } }, ); expect(container).toBeEmptyDOMElement(); }); it("skips the highlight provider when highlight levels are fully disabled", () => { renderWithProviders( , { settings: { blockHighlights: { levels: { good: null, warn: null, danger: null } }, }, }, ); expect(screen.getByTestId("highlight-probe").getAttribute("data-highlight")).toBe("no"); }); });