@@ -561,7 +561,9 @@ it("a claim the server refused is logged, and the write stays undoable as a chan
561561 files : { "index.html" : { before : "A" , after : "B" } } ,
562562 } ) ,
563563 ) ;
564- expect ( logged ) . toHaveBeenCalledWith ( '"Moved Title" was not recorded as your edit: disk full' ) ;
564+ expect ( logged ) . toHaveBeenCalledWith (
565+ '[history] 500: "Moved Title" was not recorded as your edit: disk full' ,
566+ ) ;
565567 restoreFetch ( ) ;
566568 expect ( await act ( ( ) => hook ( ) . undo ( { readFile } ) ) ) . toMatchObject ( {
567569 ok : true ,
@@ -570,6 +572,46 @@ it("a claim the server refused is logged, and the write stays undoable as a chan
570572 expect ( file ( ) ) . toBe ( "A" ) ;
571573} ) ;
572574
575+ it . each ( [
576+ [
577+ "the server refused" ,
578+ 409 ,
579+ ( ) => answer ( "/history/claim" , 409 , { error : "newer edit" } ) ,
580+ "newer edit" ,
581+ ] ,
582+ [
583+ "could not reach the server" ,
584+ 0 ,
585+ ( ) => {
586+ const real = globalThis . fetch ;
587+ vi . stubGlobal ( "fetch" , ( url : string , init ?: RequestInit ) =>
588+ url . endsWith ( "/history/claim" )
589+ ? Promise . reject ( new TypeError ( "fetch failed" ) )
590+ : real ( url , init ) ,
591+ ) ;
592+ } ,
593+ "Studio could not reach its server." ,
594+ ] ,
595+ ] as const ) (
596+ "a claim that %s logs under [history] with its status" ,
597+ async ( _ , status , stub , reason ) => {
598+ const { hook, save } = await studio ( ) ;
599+ const logged = vi . spyOn ( console , "error" ) . mockImplementation ( ( ) => { } ) ;
600+ cleanup . push ( ( ) => logged . mockRestore ( ) ) ;
601+ stub ( ) ;
602+ save ( "B" ) ;
603+ await act ( ( ) =>
604+ hook ( ) . recordEdit ( {
605+ label : "Moved Title" ,
606+ files : { "index.html" : { before : "A" , after : "B" } } ,
607+ } ) ,
608+ ) ;
609+ expect ( logged ) . toHaveBeenCalledWith (
610+ `[history] ${ status } : "Moved Title" was not recorded as your edit: ${ reason } ` ,
611+ ) ;
612+ } ,
613+ ) ;
614+
573615it ( "a step whose reply cannot be read says so, instead of throwing" , async ( ) => {
574616 const { hook, readFile } = await studio ( ) ;
575617 answer ( "/history/step" , 200 , "<html>" ) ;
0 commit comments