e067e7a1f6
* feat(web): show file statuses in review * fix(web): address review status feedback * fix(web): deduplicate review sources * fix(web): align review progress identities * fix(web): guard review status labels * fix(web): enforce file status exhaustiveness * perf(web): index review progress sources * fix(web): preserve files during status hydration * fix(web): align multi-repo review progress
78 lines
1.9 KiB
TypeScript
78 lines
1.9 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,
|
|
});
|
|
});
|
|
|
|
it("shows previous-path context for a moved PR file", () => {
|
|
render(
|
|
<PRFilesGroupedList
|
|
files={[
|
|
{
|
|
path: "src/new-name.ts",
|
|
status: "renamed",
|
|
plus: 0,
|
|
minus: 0,
|
|
oldPath: "src/old-name.ts",
|
|
repository_name: "",
|
|
},
|
|
]}
|
|
onOpenDiff={vi.fn()}
|
|
/>,
|
|
);
|
|
|
|
expect(screen.getByRole("img", { name: "Moved from src/old-name.ts" })).toBeTruthy();
|
|
});
|
|
});
|