@@ -492,3 +492,56 @@ test('review surfaces truncation info when diff exceeds limit', async t => {
492492 t . true ( userMessage . includes ( 'diff truncated' ) ) ;
493493 t . true ( userMessage . includes ( 'first and last 500 of 1100 lines' ) ) ;
494494} ) ;
495+
496+ test ( 'review falls back to default prompt when prompt file is missing' , async t => {
497+ const { renameSync} = await import ( 'node:fs' ) ;
498+ const { join} = await import ( 'node:path' ) ;
499+ const { fileURLToPath} = await import ( 'node:url' ) ;
500+ const { dirname} = await import ( 'node:path' ) ;
501+
502+ const modulePath = fileURLToPath ( import . meta. url ) ;
503+ const moduleDir = dirname ( modulePath ) ;
504+ const promptPath = join ( moduleDir , '../../source/app/prompts/sections/review.md' ) ;
505+ const backupPath = promptPath + '.bak' ;
506+
507+ renameSync ( promptPath , backupPath ) ;
508+
509+ let systemPrompt = '' ;
510+
511+ const client = {
512+ chat : async ( messages : Message [ ] ) => {
513+ systemPrompt = ( messages [ 0 ] ?. content as string ) || '' ;
514+ return {
515+ choices : [
516+ {
517+ message : {
518+ content : 'Looks good.' ,
519+ } ,
520+ } ,
521+ ] ,
522+ } ;
523+ } ,
524+ } ;
525+
526+ try {
527+ const command = createReviewCommand ( {
528+ execGit : async args => {
529+ if ( args [ 0 ] === 'rev-parse' ) return '' ;
530+ return 'diff --git a/file.ts b/file.ts\n+const x = 1;' ;
531+ } ,
532+ getCurrentBranch : async ( ) => 'feature' ,
533+ getDefaultBranch : async ( ) => 'main' ,
534+ } ) ;
535+
536+ const result = await command . handler ( [ 'feature' ] , baseMessages , {
537+ ...testMetadata ,
538+ client,
539+ } ) ;
540+
541+ t . truthy ( React . isValidElement ( result ) ) ;
542+ t . true ( systemPrompt . includes ( 'senior software engineer' ) ) ;
543+ t . true ( systemPrompt . includes ( 'code review' ) ) ;
544+ } finally {
545+ renameSync ( backupPath , promptPath ) ;
546+ }
547+ } ) ;
0 commit comments