@@ -5,7 +5,10 @@ import { act, type MouseEvent, type ReactNode } from "react";
55import { create , type ReactTestRenderer } from "react-test-renderer" ;
66import { afterEach , beforeEach , describe , expect , it , vi } from "vite-plus/test" ;
77
8+ import type { FileDiffMetadata } from "@pierre/diffs" ;
9+
810import { DiffFileTree , type DiffFileTreeEntry } from "./DiffFileTree" ;
11+ import { diffFileTreeEntries } from "./diffFileTree.logic" ;
912import { useCodeViewFileReveal } from "./useCodeViewFileReveal" ;
1013
1114vi . mock ( "../../hooks/useTheme" , ( ) => ( { useTheme : ( ) => ( { resolvedTheme : "dark" } ) } ) ) ;
@@ -112,6 +115,22 @@ describe("diff tree file activation", () => {
112115 vi . unstubAllGlobals ( ) ;
113116 } ) ;
114117
118+ it ( "mounts a file-to-symlink type change as one tree row" , async ( ) => {
119+ // Git carries a type change as a deletion and an addition of the same path.
120+ const typeChange = diffFileTreeEntries ( [
121+ { type : "deleted" , name : "b/AGENTS.md" , prevName : "a/AGENTS.md" } as FileDiffMetadata ,
122+ { type : "new" , name : "b/AGENTS.md" , prevName : "a/AGENTS.md" } as FileDiffMetadata ,
123+ { type : "change" , name : "b/CLAUDE.md" , prevName : "a/CLAUDE.md" } as FileDiffMetadata ,
124+ ] ) ;
125+ await mount ( { files : [ ...typeChange ] } ) ;
126+
127+ const tree = model ( ) ;
128+ expect ( tree . getItem ( "AGENTS.md" ) ?. isDirectory ( ) ) . toBe ( false ) ;
129+ expect ( tree . getItem ( "CLAUDE.md" ) ?. isDirectory ( ) ) . toBe ( false ) ;
130+ await activate ( "AGENTS.md" ) ;
131+ expect ( targets ) . toEqual ( [ { type : "item" , id : "AGENTS.md\u0000AGENTS.md" , align : "start" } ] ) ;
132+ } ) ;
133+
115134 it ( "reissues the reveal when the sole selected file is activated again" , async ( ) => {
116135 await mount ( ) ;
117136 await activate ( "02-short.ts" ) ;
0 commit comments