9c73a2d8c3
* fix: keep diff previews tied to the correct file * fix: handle legacy file editor panel restores * test: align file editor image mock * fix: ignore sibling repo editor sync changes * test: use repo scoped file keys in save tests * fix: guard file editor preview restoration * fix: remove redundant preview path fallback * test: cover repo scoped image previews * test: use repo scoped keys in sync tests * fix: guard stale file editor open fetches * fix: distinguish repeated file editor requests * fix: open single-repo PR diffs without repo filter * fix: keep pending file opens alive
58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
import { describe, it, expect, vi, afterEach } from "vitest";
|
|
import { render, fireEvent, screen, cleanup } from "@testing-library/react";
|
|
import { PRFilesGroupedList } from "./changes-panel-pr-files";
|
|
|
|
describe("PRFilesGroupedList", () => {
|
|
afterEach(() => cleanup());
|
|
|
|
it("passes diff source + repository context on open diff", () => {
|
|
const onOpenDiff = vi.fn();
|
|
render(
|
|
<PRFilesGroupedList
|
|
files={[
|
|
{
|
|
path: "README.md",
|
|
status: "modified",
|
|
plus: 1,
|
|
minus: 0,
|
|
oldPath: undefined,
|
|
repository_name: "backend",
|
|
},
|
|
]}
|
|
onOpenDiff={onOpenDiff}
|
|
/>,
|
|
);
|
|
|
|
fireEvent.click(screen.getByText("README.md"));
|
|
expect(onOpenDiff).toHaveBeenCalledWith("README.md", {
|
|
source: "pr",
|
|
repositoryName: "backend",
|
|
});
|
|
});
|
|
|
|
it("does not pass an empty single-repo stamp as repository context", () => {
|
|
const onOpenDiff = vi.fn();
|
|
render(
|
|
<PRFilesGroupedList
|
|
files={[
|
|
{
|
|
path: "README.md",
|
|
status: "modified",
|
|
plus: 1,
|
|
minus: 0,
|
|
oldPath: undefined,
|
|
repository_name: "",
|
|
},
|
|
]}
|
|
onOpenDiff={onOpenDiff}
|
|
/>,
|
|
);
|
|
|
|
fireEvent.click(screen.getByText("README.md"));
|
|
expect(onOpenDiff).toHaveBeenCalledWith("README.md", {
|
|
source: "pr",
|
|
repositoryName: undefined,
|
|
});
|
|
});
|
|
});
|