@@ -672,6 +672,88 @@ test('working-tree mode includes a changed central contract registry', () => {
672672 expect ( report . findings . some ( ( finding ) => finding . file === file ) ) . toBe ( true )
673673} )
674674
675+ test . each ( [ 'before' , 'after' , 'rename' , 'invalid-base' , 'invalid-head' , 'unresolved' ] ) (
676+ 'central inspection coverage preserves the CLI failure boundary: %s' ,
677+ ( scenario ) => {
678+ const { repo } = fixture ( )
679+ const file = 'packages/emcn/src/components/view.tsx'
680+ const renamed = 'packages/emcn/src/components/moved-view.tsx'
681+ const valid = 'const View=()=> <div/>'
682+ const extractionFailure =
683+ "import {constructor} from '../index';const View=()=> <div className={constructor}/>"
684+ const malformed = 'const View=()=> <div className={'
685+ const write = ( name : string , source : string ) => {
686+ mkdirSync ( path . dirname ( path . join ( repo , name ) ) , { recursive : true } )
687+ writeFileSync ( path . join ( repo , name ) , source )
688+ }
689+ write ( ui , valid )
690+ write ( 'packages/emcn/src/index.ts' , 'export {}' )
691+ write (
692+ file ,
693+ scenario === 'invalid-base'
694+ ? malformed
695+ : [ 'before' , 'rename' ] . includes ( scenario )
696+ ? extractionFailure
697+ : valid
698+ )
699+ const base = commit ( repo )
700+ if ( scenario === 'rename' ) git ( repo , [ 'mv' , file , renamed ] )
701+ else
702+ write (
703+ file ,
704+ scenario === 'invalid-head'
705+ ? malformed
706+ : scenario === 'after'
707+ ? extractionFailure
708+ : scenario === 'unresolved'
709+ ? "import {missing} from '../index';const View=()=> <div className={missing}/>"
710+ : valid
711+ )
712+ const head = commit ( repo )
713+ const child = run ( [ '--repo' , repo , '--base' , base , '--head' , head , '--format' , 'json' ] )
714+ const report = JSON . parse ( child . stdout ) as Report
715+ expect ( child . status , child . stdout ) . toBe ( scenario === 'unresolved' ? 0 : 2 )
716+ expect ( report . status ) . toBe ( scenario === 'unresolved' ? 'completed' : 'failed' )
717+ expect ( report . flagged ) . toBe ( scenario === 'unresolved' ? false : null )
718+ if ( [ 'before' , 'after' , 'rename' ] . includes ( scenario ) ) {
719+ const expected =
720+ scenario === 'rename'
721+ ? [
722+ { file, side : 'before' } ,
723+ { file : renamed , side : 'after' } ,
724+ ]
725+ : [ { file, side : scenario } ]
726+ expect ( report . coverageFailures ) . toHaveLength ( expected . length )
727+ expect ( report . coverageFailures ) . toEqual (
728+ expect . arrayContaining (
729+ expected . map ( ( origin ) =>
730+ expect . objectContaining ( {
731+ ...origin ,
732+ reason : expect . stringMatching ( / ^ E x t r a c t i o n f a i l u r e : / ) ,
733+ } )
734+ )
735+ )
736+ )
737+ expect ( report . unchecked ) . toEqual (
738+ expect . arrayContaining (
739+ expected . map ( ( origin ) =>
740+ expect . objectContaining ( {
741+ ...origin ,
742+ reason : expect . stringMatching ( / ^ E x t r a c t i o n f a i l u r e : / ) ,
743+ } )
744+ )
745+ )
746+ )
747+ } else if ( scenario === 'unresolved' ) {
748+ expect ( report . coverageFailures ) . toEqual ( [ ] )
749+ expect (
750+ report . unchecked . some ( ( note ) => note . reason . includes ( 'Imported styling input is unchecked' ) )
751+ ) . toBe ( true )
752+ } else expect ( report . error ) . toMatch ( / p a r s e r f a i l u r e | E x t r a c t i o n f a i l u r e / i)
753+ } ,
754+ 30_000
755+ )
756+
675757test ( 'text, JSON and output files preserve finding identity and normal command exit codes' , ( ) => {
676758 const { repo, base, head } = fixture ( )
677759 const args = [ '--repo' , repo , '--base' , base ]
0 commit comments