Files
t3code/apps/web/src/diffFileActions.test.ts
T
Julius Marmingeandcodex 361df65ffb Map thread panel into title bar and sidebar
- Add thread-panel presentation logic for inline vs popover layouts
- Move thread details controls into the chat header/sidebar flow
- Add shared wait-for-atom helper and workspace display name parsing

Co-authored-by: codex <[email protected]>
2026-06-24 16:48:28 -07:00

52 lines
1.5 KiB
TypeScript

import { scopeThreadRef } from "@t3tools/client-runtime/environment";
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
import { beforeEach, describe, expect, it, vi } from "vite-plus/test";
import { openDiffFilePrimaryAction } from "./diffFileActions";
import { selectThreadRightPanelState, useRightPanelStore } from "./rightPanelStore";
const THREAD_REF = scopeThreadRef(
EnvironmentId.make("environment-local"),
ThreadId.make("thread-1"),
);
describe("openDiffFilePrimaryAction", () => {
beforeEach(() => {
useRightPanelStore.setState({ byThreadKey: {}, threadPanelVisibilityByThreadKey: {} });
});
it("opens diff files in the thread file viewer", () => {
const openInEditor = vi.fn();
openDiffFilePrimaryAction({
threadRef: THREAD_REF,
filePath: "apps/web/src/components/DiffPanel.tsx",
activeCwd: "/repo/project",
openInEditor,
});
expect(
selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, THREAD_REF),
).toMatchObject({
isOpen: true,
activeSurfaceId: "file:apps/web/src/components/DiffPanel.tsx",
});
expect(openInEditor).not.toHaveBeenCalled();
});
it("falls back to the editor without thread context", () => {
const openInEditor = vi.fn();
openDiffFilePrimaryAction({
threadRef: null,
filePath: "apps/web/src/components/DiffPanel.tsx",
activeCwd: "/repo/project",
openInEditor,
});
expect(openInEditor).toHaveBeenCalledWith(
"/repo/project/apps/web/src/components/DiffPanel.tsx",
);
});
});