import React from "react";
import "@testing-library/jest-dom";
import { fireEvent, render, screen } from "@testing-library/react";
import { CssVarsProvider } from "@mui/material/styles";
import { I18nProvider } from "./i18n/I18nProvider";
import AppShell from "./layout/AppShell";
import { getTheme } from "./theme";
test("notification bell exposes its unread count and keyboard-accessible action", () => {
const open = jest.fn();
render(
undefined}
onToggleDrawer={() => undefined}
drawerOpen={false}
notificationsCount={3}
onOpenNotifications={open}
>
Content
,
);
const bell = screen.getByRole("button", { name: "Notifications" });
expect(screen.getByText("3")).toBeInTheDocument();
fireEvent.click(bell);
expect(open).toHaveBeenCalledTimes(1);
expect(open.mock.calls[0][0]).toBeInstanceOf(HTMLElement);
});
test("shows build metadata only when the caller supplies the admin-only badge", () => {
const commonProps = {
pageTitle: "Dashboard",
breadcrumbs: ["Home"],
pathname: "/dashboard",
nav: [],
navBottom: [],
onNavigate: () => undefined,
onToggleDrawer: () => undefined,
drawerOpen: false,
};
const { rerender } = render(
Content
,
);
expect(screen.getByTestId("admin-version-badge")).toHaveTextContent("v2.4.1");
expect(screen.getByLabelText("Application version 2.4.1, commit abc1234")).toBeInTheDocument();
rerender(
Content
,
);
expect(screen.queryByTestId("admin-version-badge")).not.toBeInTheDocument();
});
test("shell icon controls expose accessible names", () => {
render(
undefined}
onToggleDrawer={() => undefined}
drawerOpen={false}
onOpenSettings={() => undefined}
user={{ userName: "Ada", roleLabel: "Administrator" }}
>
Content
,
);
expect(screen.getByRole("button", { name: "Collapse sidebar" })).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Notifications" })).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Settings" })).toBeInTheDocument();
expect(screen.getByRole("button", { name: "User" })).toBeInTheDocument();
});