import { cleanup, render, screen } from "@testing-library/react"; import type { ReactNode } from "react"; import { afterEach, describe, expect, it, vi } from "vitest"; import { PullDropdown } from "./changes-panel-header"; import { ChangesPanelHeaderOverflowActions } from "./changes-panel-header-actions"; vi.mock("@kandev/ui/button", () => ({ Button: ({ children, ...props }: React.ButtonHTMLAttributes) => ( ), })); vi.mock("@kandev/ui/dropdown-menu", () => ({ DropdownMenu: ({ children }: { children: React.ReactNode }) =>
{children}
, DropdownMenuContent: ({ children }: { children: React.ReactNode }) =>
{children}
, DropdownMenuTrigger: ({ children }: { children: React.ReactNode }) => <>{children}, DropdownMenuItem: ({ children, ...props }: { children: React.ReactNode }) => (
{children}
), })); vi.mock("@kandev/ui/tooltip", () => ({ Tooltip: ({ children }: { children: React.ReactNode }) =>
{children}
, TooltipContent: ({ children }: { children: React.ReactNode }) =>
{children}
, TooltipTrigger: ({ children }: { children: React.ReactNode }) => <>{children}, })); vi.mock("./panel-primitives", () => ({ PanelHeaderBarSplit: ({ left, right, overflow, }: { left?: ReactNode; right?: ReactNode; overflow?: ReactNode; }) => (
{left} {right} {overflow}
), PanelHeaderOverflowMenu: ({ children }: { children: ReactNode }) =>
{children}
, })); vi.mock("./changes-panel-per-repo-menu", () => ({ PerRepoPullMenu: () => null, })); afterEach(cleanup); describe("PullDropdown remote safety", () => { it("keeps the configured-upstream reason reachable while Pull is disabled", () => { render( , ); const pullButton = screen.getByRole("button", { name: /Pull/ }); expect(pullButton).toHaveProperty("disabled", true); expect(pullButton.parentElement?.getAttribute("tabindex")).toBe("0"); expect(screen.getByText("Pull requires a configured upstream for this checkout.")).toBeTruthy(); expect( screen.queryByText( "Current PR history is unavailable. The checkout history is shown without assuming a rewrite.", ), ).toBeNull(); }); }); describe("ChangesPanelHeaderOverflowActions", () => { it("does not expose Diff or Review when the Changes panel has no reviewable content", () => { render( , ); expect(screen.queryByText("Diff")).toBeNull(); expect(screen.queryByText("Review")).toBeNull(); }); it("keeps Diff and Review available when reviewable content exists", () => { render( , ); expect(screen.getByText("Diff")).toBeTruthy(); expect(screen.getByText("Review")).toBeTruthy(); }); });