// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
import React from "react";
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { PageBody, PageHeader, PageShell } from "./PageShell";
describe("PageShell", () => {
it("renders the title as the page's single h1", () => {
render();
const headings = screen.getAllByRole("heading", { level: 1 });
expect(headings).toHaveLength(1);
expect(headings[0]).toHaveTextContent("Aufgaben");
});
it("omits subtitle, icon and actions when not supplied", () => {
const { container } = render();
expect(container.querySelector("p")).toBeNull();
expect(screen.queryByRole("button")).toBeNull();
});
it("renders subtitle, icon and actions when supplied", () => {
render(
}
title="Aufgaben"
subtitle="Alle offenen Aufgaben"
actions={}
/>,
);
expect(screen.getByTestId("icon")).toBeInTheDocument();
expect(screen.getByText("Alle offenen Aufgaben")).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Neu" })).toBeInTheDocument();
});
it("keeps the e2e anchor on the shell so header and body stay inside it", () => {
const { container } = render(
,
);
const shell = container.querySelector('[data-ui-id="ui.tasks.list"]');
expect(shell).not.toBeNull();
expect(shell?.querySelector("h1")).toHaveTextContent("Aufgaben");
expect(shell?.querySelector('[data-ui-id="ui.tasks.list.table"]')).not.toBeNull();
});
});