@@ -465,6 +465,50 @@ describe(`query extraction`, () => {
465465 expect ( state . trackedQueries . get ( `/bar` ) ) . toEqual ( { dirty : 1 } )
466466 } )
467467
468+ it ( `doesn't mark page query as dirty if component has babel errors` , ( ) => {
469+ // extract to a valid state first and run to reset initial dirty flag
470+ state = editFooQuery ( state , ComponentQueries . foo )
471+ state = reducer (
472+ state ,
473+ queryExtractionBabelError (
474+ { componentPath : `/foo.js` , error : new Error ( `Babel error` ) } ,
475+ { } as any
476+ )
477+ )
478+ expect ( state . trackedQueries . get ( `/foo` ) ?. dirty ) . toEqual ( 0 ) // sanity-check
479+ state = reducer (
480+ state ,
481+ queryExtracted ( { componentPath : `/foo.js` , query : `` } , { } as any )
482+ )
483+ expect ( state . trackedQueries . get ( `/foo` ) ?. dirty ) . toEqual ( 0 )
484+ } )
485+
486+ it ( `recovers after component babel errors` , ( ) => {
487+ // extract to a valid state first and run to reset initial dirty flag
488+ state = editFooQuery ( state , ComponentQueries . foo )
489+ state = reducer (
490+ state ,
491+ queryExtractionBabelError (
492+ { componentPath : `/foo.js` , error : new Error ( `Babel error` ) } ,
493+ { } as any
494+ )
495+ )
496+ state = reducer (
497+ state ,
498+ queryExtracted ( { componentPath : `/foo.js` , query : `` } , { } as any )
499+ )
500+ expect ( state . trackedQueries . get ( `/foo` ) ?. dirty ) . toEqual ( 0 ) // sanity-check
501+ state = reducer (
502+ state ,
503+ queryExtractedBabelSuccess ( { componentPath : `/foo.js` } , { } as any )
504+ )
505+ state = reducer (
506+ state ,
507+ queryExtracted ( ComponentQueries . fooEdited , { } as any )
508+ )
509+ expect ( state . trackedQueries . get ( `/foo` ) ?. dirty ) . toEqual ( 2 )
510+ } )
511+
468512 it ( `marks all page queries associated with the component as dirty when query text changes` , ( ) => {
469513 state = editFooQuery ( state , ComponentQueries . fooEdited )
470514
0 commit comments