@@ -281,8 +281,6 @@ Files:
281281 let uiSourceCode : Workspace . UISourceCode . UISourceCode ;
282282 let commitWorkingCopyStub :
283283 sinon . SinonStub < Parameters < typeof Workspace . UISourceCode . UISourceCode . prototype . commitWorkingCopy > > ;
284- let resetWorkingCopyStub :
285- sinon . SinonStub < Parameters < typeof Workspace . UISourceCode . UISourceCode . prototype . resetWorkingCopy > > ;
286284
287285 beforeEach ( ( ) => {
288286 uiSourceCode = createTestFilesystem ( 'file://test' ) . uiSourceCode ;
@@ -296,49 +294,50 @@ Files:
296294
297295 commitWorkingCopyStub =
298296 sinon . stub ( Workspace . UISourceCode . UISourceCode . prototype , 'commitWorkingCopy' ) . callThrough ( ) ;
299- resetWorkingCopyStub =
300- sinon . stub ( Workspace . UISourceCode . UISourceCode . prototype , 'resetWorkingCopy' ) . callThrough ( ) ;
301297 } ) ;
302298
303- it ( 'on apply should call handle function and stash changes ' , async ( ) => {
299+ it ( 'on apply should should not call stashChanges ' , async ( ) => {
304300 const {
305301 view,
306302 widget,
307- } = await createPatchWidget ( { aidaClient : mockAidaClient ( [ [ { explanation : 'patch applied' } ] ] ) } ) ;
303+ } = await createPatchWidget ( {
304+ aidaClient : mockAidaClient ( [ [ { explanation : 'patch applied' } ] ] ) ,
305+ } ) ;
308306 widget . changeSummary = 'body { background-color: red; }' ;
309307 const changeManager = sinon . createStubInstance ( AiAssistanceModel . ChangeManager ) ;
308+ changeManager . stashChanges . returns ( Promise . resolve ( ) ) ;
310309 widget . changeManager = changeManager ;
311310 view . input . onApplyToWorkspace ( ) ;
312311 await view . nextInput ;
313- assert . isTrue ( changeManager . stashChanges . calledOnce ) ;
312+ assert . isTrue ( changeManager . stashChanges . notCalled ) ;
314313 } ) ;
315314
316- it ( 'save all should commit the working copy of the changed UI codes to the disk and render savedToDisk view' ,
317- async ( ) => {
318- const { view , widget } = await createPatchWidgetWithDiffView ( ) ;
319- const changeManager = sinon . createStubInstance ( AiAssistanceModel . ChangeManager ) ;
320- widget . changeManager = changeManager ;
321- uiSourceCode . setWorkingCopy ( 'working copy' ) ;
315+ it ( 'on save should stash changes' , async ( ) => {
316+ const { view , widget } = await createPatchWidgetWithDiffView ( ) ;
317+ const changeManager = sinon . createStubInstance ( AiAssistanceModel . ChangeManager ) ;
318+ changeManager . stashChanges . returns ( Promise . resolve ( ) ) ;
319+ widget . changeManager = changeManager ;
320+ uiSourceCode . setWorkingCopy ( 'working copy' ) ;
322321
323- view . input . onSaveAll ( ) ;
324- const nextInput = await view . nextInput ;
322+ view . input . onSaveAll ( ) ;
323+ const nextInput = await view . nextInput ;
325324
326- assert . isTrue ( nextInput . savedToDisk ) ;
327- assert . isTrue ( commitWorkingCopyStub . called , 'Expected commitWorkingCopy to be called but it is not called' ) ;
328- assert . isTrue ( changeManager . dropStashedChanges . calledOnce ) ;
329- } ) ;
325+ assert . isTrue ( nextInput . savedToDisk ) ;
326+ assert . isTrue ( commitWorkingCopyStub . called , 'Expected commitWorkingCopy to be called but it is not called' ) ;
327+ assert . isTrue ( changeManager . stashChanges . calledOnce ) ;
328+ } ) ;
330329
331330 it ( 'discard should discard the working copy and render the view without patchSuggestion' , async ( ) => {
332331 const { view, widget} = await createPatchWidgetWithDiffView ( ) ;
333332 const changeManager = sinon . createStubInstance ( AiAssistanceModel . ChangeManager ) ;
333+ changeManager . stashChanges . returns ( Promise . resolve ( ) ) ;
334334 widget . changeManager = changeManager ;
335335 uiSourceCode . setWorkingCopy ( 'working copy' ) ;
336336
337337 view . input . onDiscard ( ) ;
338338 const nextInput = await view . nextInput ;
339339
340340 assert . strictEqual ( nextInput . patchSuggestionState , AiAssistance . PatchWidget . PatchSuggestionState . INITIAL ) ;
341- assert . isTrue ( resetWorkingCopyStub . called , 'Expected resetWorkingCopy to be called but it is not called' ) ;
342341 assert . isTrue ( changeManager . popStashedChanges . calledOnce ) ;
343342 } ) ;
344343 } ) ;
0 commit comments