@@ -382,15 +382,15 @@ describe('StudioRecorderProvider preview recording', () => {
382382 }
383383 } ) ;
384384
385- it ( 'falls back from aiDescribe failed events to recorderAI descriptions' , async ( ) => {
385+ it ( 'falls back from truly failed aiDescribe events to recorderAI descriptions' , async ( ) => {
386386 const event = {
387387 type : 'click' ,
388388 source : 'studio-preview' ,
389389 actionType : 'Click' ,
390390 semantic : {
391391 source : 'aiDescribe' ,
392392 status : 'failed' ,
393- error : 'aiDescribe verification failed .' ,
393+ error : 'Active agent does not support describeElementAtPoint .' ,
394394 } ,
395395 elementRect : { x : 10 , y : 20 } ,
396396 pageInfo : { width : 1200 , height : 800 } ,
@@ -420,7 +420,69 @@ describe('StudioRecorderProvider preview recording', () => {
420420 fallbackFrom : {
421421 source : 'aiDescribe' ,
422422 status : 'failed' ,
423- error : 'aiDescribe verification failed.' ,
423+ error : 'Active agent does not support describeElementAtPoint.' ,
424+ } ,
425+ } ,
426+ } ) ;
427+
428+ await mounted . cleanup ( ) ;
429+ } ) ;
430+
431+ it ( 'keeps aiDescribe when only verification fails and does not fallback to recorderAI' , async ( ) => {
432+ const event = {
433+ type : 'click' ,
434+ source : 'studio-preview' ,
435+ actionType : 'Click' ,
436+ elementRect : { x : 10 , y : 20 } ,
437+ pageInfo : { width : 1200 , height : 800 } ,
438+ screenshotAfter : 'data:image/png;base64,shot' ,
439+ timestamp : 123 ,
440+ hashId : 'click-ai-describe-verify-failed' ,
441+ } ;
442+ const describeRecorderEventAtPoint = vi . fn ( async ( ) => ( {
443+ ok : false ,
444+ error : 'aiDescribe verification failed.' ,
445+ trace : {
446+ elementDescription : 'Submit button in the form footer' ,
447+ verifyPassed : false ,
448+ centerDistance : 24 ,
449+ point : [ 10 , 20 ] ,
450+ verifyResult : {
451+ pass : false ,
452+ center : [ 30 , 20 ] ,
453+ centerDistance : 24 ,
454+ } ,
455+ annotatedScreenshotRef : {
456+ path : '/tmp/verify-failed-annotated.png' ,
457+ } ,
458+ } ,
459+ } ) ) ;
460+ const { context } = createConnectedStudioContext ( {
461+ events : [ event ] ,
462+ describeRecorderEventAtPoint,
463+ } ) ;
464+ const mounted = await mountRecorder ( context ) ;
465+
466+ await act ( async ( ) => {
467+ await mounted . recorder ?. startRecording ( ) ;
468+ } ) ;
469+ await flushPromises ( ) ;
470+ await flushPromises ( ) ;
471+
472+ expect ( describeStudioRecorderEventsWithAI ) . not . toHaveBeenCalled ( ) ;
473+ expect ( mounted . recorder ?. currentSession ?. events [ 0 ] ) . toMatchObject ( {
474+ hashId : 'click-ai-describe-verify-failed' ,
475+ semantic : {
476+ source : 'aiDescribe' ,
477+ status : 'ready' ,
478+ elementDescription : 'Submit button in the form footer' ,
479+ aiDescribe : {
480+ verifyPrompt : true ,
481+ verifyPassed : false ,
482+ centerDistance : 24 ,
483+ expectedCenter : [ 10 , 20 ] ,
484+ actualCenter : [ 30 , 20 ] ,
485+ annotatedScreenshotPath : '/tmp/verify-failed-annotated.png' ,
424486 } ,
425487 } ,
426488 } ) ;
@@ -1140,7 +1202,7 @@ describe('StudioRecorderProvider preview recording', () => {
11401202 semantic : {
11411203 source : 'aiDescribe' ,
11421204 status : 'failed' ,
1143- error : 'aiDescribe verification failed .' ,
1205+ error : 'Active agent does not support describeElementAtPoint .' ,
11441206 } ,
11451207 } ,
11461208 } ) ) ;
@@ -1238,7 +1300,7 @@ describe('StudioRecorderProvider preview recording', () => {
12381300 fallbackFrom : {
12391301 source : 'aiDescribe' ,
12401302 status : 'failed' ,
1241- error : 'aiDescribe verification failed .' ,
1303+ error : 'Active agent does not support describeElementAtPoint .' ,
12421304 } ,
12431305 } ,
12441306 } ) ;
0 commit comments