@@ -73,8 +73,8 @@ describe("project.initGit endpoint", () => {
7373 }
7474 } )
7575
76- test ( "does not reload again when the project is already git" , async ( ) => {
77- await using tmp = await tmpdir ( )
76+ test ( "does not reload when the project is already git" , async ( ) => {
77+ await using tmp = await tmpdir ( { git : true } )
7878 const app = Server . App ( )
7979 const seen : { directory ?: string ; payload : { type : string } } [ ] = [ ]
8080 const fn = ( evt : { directory ?: string ; payload : { type : string } } ) => {
@@ -85,36 +85,32 @@ describe("project.initGit endpoint", () => {
8585 GlobalBus . on ( "event" , fn )
8686
8787 try {
88- const first = await app . request ( "/project/git/init" , {
88+ const init = await app . request ( "/project/git/init" , {
8989 method : "POST" ,
9090 headers : {
9191 "x-opencode-directory" : tmp . path ,
9292 } ,
9393 } )
94- expect ( first . status ) . toBe ( 200 )
95- const before = seen . filter (
96- ( evt ) => evt . directory === tmp . path && evt . payload . type === "server.instance.disposed" ,
97- ) . length
98- expect ( reloadSpy ) . toHaveBeenCalledTimes ( 1 )
94+ expect ( init . status ) . toBe ( 200 )
95+ expect ( await init . json ( ) ) . toMatchObject ( {
96+ vcs : "git" ,
97+ worktree : tmp . path ,
98+ } )
99+ expect (
100+ seen . filter ( ( evt ) => evt . directory === tmp . path && evt . payload . type === "server.instance.disposed" ) . length ,
101+ ) . toBe ( 0 )
102+ expect ( reloadSpy ) . toHaveBeenCalledTimes ( 0 )
99103
100- const second = await app . request ( "/project/git/init" , {
101- method : "POST" ,
104+ const current = await app . request ( "/project/current" , {
102105 headers : {
103106 "x-opencode-directory" : tmp . path ,
104107 } ,
105108 } )
106- expect ( second . status ) . toBe ( 200 )
107- expect ( await second . json ( ) ) . toMatchObject ( {
108- id : "global" ,
109+ expect ( current . status ) . toBe ( 200 )
110+ expect ( await current . json ( ) ) . toMatchObject ( {
109111 vcs : "git" ,
110112 worktree : tmp . path ,
111113 } )
112-
113- const after = seen . filter (
114- ( evt ) => evt . directory === tmp . path && evt . payload . type === "server.instance.disposed" ,
115- ) . length
116- expect ( after ) . toBe ( before )
117- expect ( reloadSpy ) . toHaveBeenCalledTimes ( 1 )
118114 } finally {
119115 reloadSpy . mockRestore ( )
120116 GlobalBus . off ( "event" , fn )
0 commit comments