@@ -54,6 +54,7 @@ const urls = images.map(
5454 ( _ , index ) =>
5555 `https://github.com/user-attachments/assets/${ index + 1 } 0000000-0000-0000-0000-000000000000` ,
5656) ;
57+ const oversizedProse = "x" . repeat ( 65_500 ) ;
5758const beforeProse = "# Prepared change\r\n\r\n Leading text \n\n" ;
5859const afterProse = "\r\n\r\n More prose\n\n\n" ;
5960
@@ -353,6 +354,42 @@ describe("REPL UI evidence publication", () => {
353354 expect ( host . events ) . toEqual ( [ "help" , "help" ] ) ;
354355 } ) ;
355356
357+ it ( "rejects a generated description over the body limit in preview and numbered publish" , function * ( ) {
358+ const input = yield * useFixture ( ) ;
359+ const host = modeledHost ( ( ) => snapshot ( input , oversizedProse ) ) ;
360+ yield * writeTextFile ( join ( input . directory , "preview.md" ) , oversizedProse ) ;
361+ const diagnostic = "The proposed draft description exceeds the GitHub body limit." ;
362+ expect ( String ( yield * raised ( run ( input , host , "dry-run" ) ) ) ) . toContain ( diagnostic ) ;
363+ expect ( host . events ) . toEqual ( [ "help" ] ) ;
364+ host . events . length = 0 ;
365+ expect ( String ( yield * raised ( run ( input , host ) ) ) ) . toContain ( diagnostic ) ;
366+ expect ( host . events ) . toEqual ( [ "help" , "read" ] ) ;
367+ } ) ;
368+
369+ it ( "publishes a PNG with final IDAT padding without changing its approved bytes" , function * ( ) {
370+ const input = yield * useFixture ( ) ;
371+ const padded = Uint8Array . from (
372+ atob (
373+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAEElEQVR4nGP4z8AAAAMBAQAAAAAAOUhUywAAAABJRU5ErkJggg==" ,
374+ ) ,
375+ ( character ) => character . charCodeAt ( 0 ) ,
376+ ) ;
377+ const digest = sha256 ( padded ) ;
378+ yield * until ( writeFile ( input . paths [ 0 ] , padded ) ) ;
379+ yield * writeTextFile (
380+ input . path ,
381+ JSON . stringify ( {
382+ ...input . receipt ,
383+ captures : [ { ...input . receipt . captures [ 0 ] , sha256 : digest } , input . receipt . captures [ 1 ] ] ,
384+ } ) ,
385+ ) ;
386+ const host = modeledHost ( ( ) => snapshot ( input ) ) ;
387+ const result = yield * run ( input , host ) ;
388+ expect ( result . status ) . toBe ( "complete" ) ;
389+ expect ( host . edits [ 0 ] . images [ 0 ] . sha256 ) . toBe ( digest ) ;
390+ expect ( host . bytes . get ( urls [ 0 ] ) ) . toEqual ( padded ) ;
391+ } ) ;
392+
356393 it ( "publishes only staged images and preserves bytes on both sides of the evidence" , function * ( ) {
357394 const input = yield * useFixture ( ) ;
358395 const section = yield * preview ( input ) ;
@@ -645,6 +682,34 @@ describe("REPL UI evidence publication", () => {
645682
646683 host . events . length = 0 ;
647684 host . help = true ;
685+ yield * writeTextFile (
686+ input . path ,
687+ JSON . stringify ( {
688+ ...input . receipt ,
689+ target : {
690+ kind : "create" ,
691+ title : "Prepared title" ,
692+ body : oversizedProse ,
693+ draftRecord : "draft.json" ,
694+ } ,
695+ } ) ,
696+ ) ;
697+ expect ( String ( yield * raised ( run ( input , host , "publish" , setup ) ) ) ) . toContain (
698+ "The proposed draft description exceeds the GitHub body limit." ,
699+ ) ;
700+ expect ( host . events ) . toEqual ( [ "help" ] ) ;
701+ expect ( git . counters . commands ) . toEqual ( [ ] ) ;
702+ expect ( creations ( store ) ) . toBe ( 0 ) ;
703+ expect ( remoteBranch ( remote , "feature" ) ) . toBeUndefined ( ) ;
704+
705+ host . events . length = 0 ;
706+ yield * writeTextFile (
707+ input . path ,
708+ JSON . stringify ( {
709+ ...input . receipt ,
710+ target : { kind : "create" , title : "Prepared title" , body, draftRecord : "draft.json" } ,
711+ } ) ,
712+ ) ;
648713 const result = yield * run ( input , host , "publish" , setup ) ;
649714 expect ( creations ( store ) ) . toBe ( 1 ) ;
650715 expect ( store . pullRequests [ 0 ] ) . toMatchObject ( { title : "Prepared title" , body, draft : true } ) ;
0 commit comments