@@ -506,6 +506,81 @@ describe('runStoryTestsTool', () => {
506506 expect ( response . result ?. content [ 0 ] . text ) . toContain ( '## Accessibility Violations' ) ;
507507 } ) ;
508508
509+ it ( 'should collect telemetry with result counts when enabled' , async ( ) => {
510+ const { telemetry } = await import ( 'storybook/internal/telemetry' ) ;
511+ const testContext = {
512+ ...createTestContext ( ) ,
513+ disableTelemetry : false ,
514+ } ;
515+
516+ setupChannelResponse ( {
517+ status : 'completed' ,
518+ result : {
519+ triggeredBy : 'external:addon-mcp' ,
520+ config : { coverage : false , a11y : true } ,
521+ storyIds : [ 'button--primary' ] ,
522+ totalTestCount : 1 ,
523+ startedAt : Date . now ( ) ,
524+ finishedAt : Date . now ( ) ,
525+ coverageSummary : undefined ,
526+ componentTestCount : { success : 1 , error : 0 } ,
527+ a11yCount : { success : 0 , warning : 1 , error : 0 } ,
528+ componentTestStatuses : [
529+ {
530+ storyId : 'button--primary' ,
531+ typeId : 'storybook/component-test' ,
532+ value : 'status-value:success' ,
533+ title : 'Component Test' ,
534+ description : '' ,
535+ } ,
536+ ] ,
537+ a11yStatuses : [ ] ,
538+ a11yReports : {
539+ 'button--primary' : [
540+ {
541+ violations : [
542+ {
543+ id : 'color-contrast' ,
544+ description : 'Color contrast ratio is insufficient' ,
545+ nodes : [
546+ {
547+ html : '<button>Click me</button>' ,
548+ impact : 'critical' ,
549+ failureSummary : '2.5:1 (required: 4.5:1)' ,
550+ linkPath : '/inspect/button--primary?inspectPath=button.0' ,
551+ } ,
552+ ] ,
553+ } ,
554+ ] ,
555+ } ,
556+ ] ,
557+ } ,
558+ unhandledErrors : [ ] ,
559+ } ,
560+ } ) ;
561+
562+ await callTool (
563+ [ { exportName : 'Primary' , relativePath : 'src/Button.stories.tsx' } ] ,
564+ testContext ,
565+ ) ;
566+
567+ expect ( telemetry ) . toHaveBeenCalledWith (
568+ 'addon-mcp' ,
569+ expect . objectContaining ( {
570+ event : 'tool:runStoryTests' ,
571+ mcpSessionId : 'test-session' ,
572+ toolset : 'test' ,
573+ runA11y : true ,
574+ inputStoryCount : 1 ,
575+ matchedStoryCount : 1 ,
576+ passingStoryCount : 1 ,
577+ failingStoryCount : 0 ,
578+ a11yViolationCount : 1 ,
579+ unhandledErrorCount : 0 ,
580+ } ) ,
581+ ) ;
582+ } ) ;
583+
509584 it ( 'should handle unhandled errors' , async ( ) => {
510585 const testContext = createTestContext ( ) ;
511586
0 commit comments