import { render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import MainLayout from "./main-layout";
vi.mock("@/components/layout/app-sidebar", () => ({
AppSidebar: () => ,
}));
vi.mock("@/components/shared/cloud-upgrade-modal", () => ({
CloudUpgradeModal: () =>
,
}));
describe("MainLayout", () => {
it("mounts the shared Cloud upgrade modal with page content", () => {
render(
Page content
,
);
expect(screen.getByTestId("cloud-upgrade-modal")).toBeInTheDocument();
expect(screen.getByTestId("sidebar")).toBeInTheDocument();
expect(screen.getByText("Page content")).toBeVisible();
expect(screen.getByRole("main")).toBeVisible();
});
it("keeps the desktop sidebar offset based on the viewport", () => {
// Given / When
render(
Page content
,
);
// Then: a right panel may narrow main, but the desktop sidebar stays open.
// Margin reaches the sidebar edge; the 16px gutter is padding so the
// navbar's bled border-b paints instead of being clipped by the scroller.
expect(screen.getByText("Page content").parentElement).toHaveClass(
"min-[64rem]:ml-[264px]",
"pl-4",
);
});
it("marks main as the responsive container for pushed page content", () => {
// Given / When
render(
Page content
,
);
// Then
expect(screen.getByText("Page content").parentElement).toHaveAttribute(
"data-responsive-container",
);
});
});