import { cleanup, render, screen } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
vi.mock("@kandev/ui/tabs", () => ({
TabsContent: ({ children }: { children: React.ReactNode }) =>
{children}
,
}));
vi.mock("./file-image-viewer", () => ({
FileImageViewer: ({ headerActions }: { headerActions?: React.ReactNode }) => (
{headerActions}
),
}));
vi.mock("./file-binary-viewer", () => ({
FileBinaryViewer: ({ headerActions }: { headerActions?: React.ReactNode }) => (
{headerActions}
),
}));
vi.mock("./file-editor-content", () => ({ FileEditorContent: () => null }));
vi.mock("@/components/editors/external-vcs-file-link", () => ({
ExternalVcsFileLink: (props: Record) => (
),
useExternalVcsFileStatus: () => ({ status: "modified" }),
}));
import { FileTabContent } from "./file-tab-content";
afterEach(cleanup);
const activeSession = { worktree_path: "/tmp/worktree", repository_id: "repo-1" };
describe("FileTabContent external file action", () => {
it.each([
["image", "assets/logo.png", "image/png", "image-viewer"],
["binary", "dist/archive.zip", "binary", "binary-viewer"],
])("shows the shared action for a desktop %s viewer", (_kind, path, content, viewerId) => {
render(
,
);
expect(screen.getByTestId(viewerId)).toBeTruthy();
const props = JSON.parse(
screen.getByTestId("external-vcs-file-link-props").dataset.props ?? "{}",
);
expect(props).toEqual({
filePath: path,
status: "modified",
taskId: "task-1",
sessionId: "session-1",
repositoryName: "frontend",
size: "sm",
});
});
});