@@ -343,6 +343,62 @@ async function createQaLabRepoRootFixture(params?: {
343343 return repoRoot ;
344344}
345345
346+ type QaLabSuiteScenarioFixture = {
347+ name : string ;
348+ status : "pass" | "fail" | "skip" ;
349+ steps : unknown [ ] ;
350+ details ?: string ;
351+ } ;
352+
353+ async function createQaLabSuiteResultFixture ( params ?: {
354+ scenarios ?: QaLabSuiteScenarioFixture [ ] ;
355+ watchUrl ?: string ;
356+ } ) {
357+ const outputDir = await mkdtemp ( path . join ( os . tmpdir ( ) , "qa-lab-suite-result-" ) ) ;
358+ cleanups . push ( async ( ) => {
359+ await rm ( outputDir , { recursive : true , force : true } ) ;
360+ } ) ;
361+ const scenarios = params ?. scenarios ?? [
362+ { name : "Channel chat baseline" , status : "pass" as const , steps : [ ] } ,
363+ ] ;
364+ const report = "# QA report\n" ;
365+ const evidencePath = path . join ( outputDir , "qa-evidence.json" ) ;
366+ const reportPath = path . join ( outputDir , "qa-suite-report.md" ) ;
367+ const summaryPath = path . join ( outputDir , "qa-suite-summary.json" ) ;
368+ await Promise . all ( [
369+ writeFile (
370+ evidencePath ,
371+ JSON . stringify ( {
372+ entries : scenarios . map ( ( scenario ) => ( { result : { status : scenario . status } } ) ) ,
373+ } ) ,
374+ "utf8" ,
375+ ) ,
376+ writeFile ( reportPath , report , "utf8" ) ,
377+ writeFile (
378+ summaryPath ,
379+ JSON . stringify ( {
380+ counts : {
381+ total : scenarios . length ,
382+ passed : scenarios . filter ( ( scenario ) => scenario . status === "pass" ) . length ,
383+ failed : scenarios . filter ( ( scenario ) => scenario . status === "fail" ) . length ,
384+ skipped : scenarios . filter ( ( scenario ) => scenario . status === "skip" ) . length ,
385+ } ,
386+ scenarios,
387+ } ) ,
388+ "utf8" ,
389+ ) ,
390+ ] ) ;
391+ return {
392+ evidencePath,
393+ outputDir,
394+ report,
395+ reportPath,
396+ scenarios,
397+ summaryPath,
398+ ...( params ?. watchUrl ? { watchUrl : params . watchUrl } : { } ) ,
399+ } ;
400+ }
401+
346402describe ( "qa-lab server" , ( ) => {
347403 it ( "dispatches explicit mixed-kind selections through the suite planner" , async ( ) => {
348404 const lab = await startQaLabServerForTest ( ) ;
@@ -351,14 +407,7 @@ describe("qa-lab server", () => {
351407 } ) ;
352408 suiteLaunchMock . runQaSuite . mockResolvedValue ( {
353409 executionKind : "suite" ,
354- result : {
355- evidencePath : "/tmp/qa-evidence.json" ,
356- outputDir : "/tmp/qa-output" ,
357- report : "# QA report\n" ,
358- reportPath : "/tmp/qa-report.md" ,
359- scenarios : [ ] ,
360- summaryPath : "/tmp/qa-summary.json" ,
361- } ,
410+ result : await createQaLabSuiteResultFixture ( ) ,
362411 } ) ;
363412
364413 const response = await fetch ( `${ lab . baseUrl } /api/scenario/suite` , {
@@ -431,22 +480,156 @@ describe("qa-lab server", () => {
431480 } ) ;
432481 } ) ;
433482
483+ it . each ( [
484+ { label : "failed" , status : "fail" as const } ,
485+ { label : "skipped" , status : "skip" as const } ,
486+ ] ) (
487+ "marks $label suite results failed while preserving generated artifacts" ,
488+ async ( { status } ) => {
489+ const lab = await startQaLabServerForTest ( ) ;
490+ cleanups . push ( async ( ) => {
491+ await lab . stop ( ) ;
492+ } ) ;
493+ const result = await createQaLabSuiteResultFixture ( {
494+ scenarios : [ { name : "Channel chat baseline" , status, steps : [ ] } ] ,
495+ } ) ;
496+ suiteLaunchMock . runQaSuite . mockResolvedValue ( { executionKind : "flow" , result } ) ;
497+
498+ const response = await fetch ( `${ lab . baseUrl } /api/scenario/suite` , {
499+ method : "POST" ,
500+ headers : { "content-type" : "application/json" } ,
501+ body : JSON . stringify ( {
502+ channelDriver : "crabline" ,
503+ providerMode : "live-frontier" ,
504+ scenarioIds : [ "dm-chat-baseline" ] ,
505+ } ) ,
506+ } ) ;
507+
508+ expect ( response . status ) . toBe ( 202 ) ;
509+ await vi . waitFor ( async ( ) => {
510+ const bootstrap = ( await ( await fetchWithRetry ( `${ lab . baseUrl } /api/bootstrap` ) ) . json ( ) ) as {
511+ latestReport : { outputPath : string ; markdown : string } ;
512+ runner : {
513+ status : string ;
514+ error : string ;
515+ artifacts : {
516+ outputDir : string ;
517+ evidencePath : string ;
518+ reportPath : string ;
519+ summaryPath : string ;
520+ } ;
521+ } ;
522+ } ;
523+ expect ( bootstrap . runner . status ) . toBe ( "failed" ) ;
524+ expect ( bootstrap . runner . error ) . toBe ( "QA suite reported 1 failed or skipped scenario(s)." ) ;
525+ expect ( bootstrap . runner . artifacts ) . toEqual (
526+ expect . objectContaining ( {
527+ outputDir : result . outputDir ,
528+ evidencePath : result . evidencePath ,
529+ reportPath : result . reportPath ,
530+ summaryPath : result . summaryPath ,
531+ } ) ,
532+ ) ;
533+ expect ( bootstrap . latestReport ) . toEqual (
534+ expect . objectContaining ( { outputPath : result . reportPath , markdown : result . report } ) ,
535+ ) ;
536+ } ) ;
537+ } ,
538+ ) ;
539+
540+ it . each ( [
541+ {
542+ label : "invalid" ,
543+ summary : "{invalid-summary" ,
544+ expectedError : "Could not parse QA summary JSON" ,
545+ } ,
546+ {
547+ label : "empty" ,
548+ summary : JSON . stringify ( {
549+ counts : { total : 0 , passed : 0 , failed : 0 , skipped : 0 } ,
550+ scenarios : [ ] ,
551+ } ) ,
552+ expectedError : "did not include any executed scenarios" ,
553+ } ,
554+ ] ) (
555+ "fails closed on an $label suite summary while preserving artifacts" ,
556+ async ( invalidResult ) => {
557+ const lab = await startQaLabServerForTest ( ) ;
558+ cleanups . push ( async ( ) => {
559+ await lab . stop ( ) ;
560+ } ) ;
561+ const result = await createQaLabSuiteResultFixture ( ) ;
562+ await writeFile ( result . summaryPath , invalidResult . summary , "utf8" ) ;
563+ suiteLaunchMock . runQaSuite . mockResolvedValue ( { executionKind : "flow" , result } ) ;
564+
565+ const response = await fetch ( `${ lab . baseUrl } /api/scenario/suite` , {
566+ method : "POST" ,
567+ headers : { "content-type" : "application/json" } ,
568+ body : JSON . stringify ( {
569+ channelDriver : "crabline" ,
570+ providerMode : "live-frontier" ,
571+ scenarioIds : [ "dm-chat-baseline" ] ,
572+ } ) ,
573+ } ) ;
574+
575+ expect ( response . status ) . toBe ( 202 ) ;
576+ await vi . waitFor ( async ( ) => {
577+ const bootstrap = ( await ( await fetchWithRetry ( `${ lab . baseUrl } /api/bootstrap` ) ) . json ( ) ) as {
578+ runner : { status : string ; error : string ; artifacts : { summaryPath : string } } ;
579+ } ;
580+ expect ( bootstrap . runner . status ) . toBe ( "failed" ) ;
581+ expect ( bootstrap . runner . error ) . toContain ( invalidResult . expectedError ) ;
582+ expect ( bootstrap . runner . artifacts . summaryPath ) . toBe ( result . summaryPath ) ;
583+ } ) ;
584+ } ,
585+ ) ;
586+
587+ it ( "keeps implicit suites green for catalog-verified report-only optional skips" , async ( ) => {
588+ const lab = await startQaLabServerForTest ( ) ;
589+ cleanups . push ( async ( ) => {
590+ await lab . stop ( ) ;
591+ } ) ;
592+ const result = await createQaLabSuiteResultFixture ( {
593+ scenarios : [
594+ { name : "Channel chat baseline" , status : "pass" , steps : [ ] } ,
595+ {
596+ name : "Runtime tool fixture — image_generate" ,
597+ status : "skip" ,
598+ steps : [ ] ,
599+ details : "image_generate mock provider report-only: tool unavailable" ,
600+ } ,
601+ ] ,
602+ } ) ;
603+ suiteLaunchMock . runQaSuite . mockResolvedValue ( { executionKind : "flow" , result } ) ;
604+
605+ const response = await fetch ( `${ lab . baseUrl } /api/scenario/suite` , {
606+ method : "POST" ,
607+ headers : { "content-type" : "application/json" } ,
608+ body : JSON . stringify ( {
609+ profile : "all" ,
610+ channelDriver : "crabline" ,
611+ providerMode : "live-frontier" ,
612+ } ) ,
613+ } ) ;
614+
615+ expect ( response . status ) . toBe ( 202 ) ;
616+ await vi . waitFor ( async ( ) => {
617+ const bootstrap = ( await ( await fetchWithRetry ( `${ lab . baseUrl } /api/bootstrap` ) ) . json ( ) ) as {
618+ runner : { status : string ; error : string | null } ;
619+ } ;
620+ expect ( bootstrap . runner . status ) . toBe ( "completed" ) ;
621+ expect ( bootstrap . runner . error ) . toBeNull ( ) ;
622+ } ) ;
623+ } ) ;
624+
434625 it ( "keeps mock providers independent from real channel adapters" , async ( ) => {
435626 const lab = await startQaLabServerForTest ( ) ;
436627 cleanups . push ( async ( ) => {
437628 await lab . stop ( ) ;
438629 } ) ;
439630 suiteLaunchMock . runQaSuite . mockResolvedValue ( {
440631 executionKind : "flow" ,
441- result : {
442- evidencePath : "/tmp/qa-evidence.json" ,
443- outputDir : "/tmp/qa-output" ,
444- report : "# QA report\n" ,
445- reportPath : "/tmp/qa-report.md" ,
446- scenarios : [ ] ,
447- summaryPath : "/tmp/qa-summary.json" ,
448- watchUrl : "http://runtime-watch.invalid" ,
449- } ,
632+ result : await createQaLabSuiteResultFixture ( { watchUrl : "http://runtime-watch.invalid" } ) ,
450633 } ) ;
451634
452635 const response = await fetch ( `${ lab . baseUrl } /api/scenario/suite` , {
@@ -509,14 +692,7 @@ describe("qa-lab server", () => {
509692 expect ( suiteLaunchMock . runQaSuite ) . toHaveBeenCalledTimes ( 1 ) ;
510693 finishSuite ?.( {
511694 executionKind : "flow" ,
512- result : {
513- evidencePath : "/tmp/qa-evidence.json" ,
514- outputDir : "/tmp/qa-output" ,
515- report : "# QA report\n" ,
516- reportPath : "/tmp/qa-report.md" ,
517- scenarios : [ ] ,
518- summaryPath : "/tmp/qa-summary.json" ,
519- } ,
695+ result : await createQaLabSuiteResultFixture ( ) ,
520696 } ) ;
521697 await vi . waitFor ( async ( ) => {
522698 const bootstrap = ( await ( await fetchWithRetry ( `${ lab . baseUrl } /api/bootstrap` ) ) . json ( ) ) as {
@@ -550,15 +726,7 @@ describe("qa-lab server", () => {
550726 } ) ;
551727 suiteLaunchMock . runQaSuite . mockResolvedValue ( {
552728 executionKind : "flow" ,
553- result : {
554- evidencePath : "/tmp/qa-evidence.json" ,
555- outputDir : "/tmp/qa-output" ,
556- report : "# QA report\n" ,
557- reportPath : "/tmp/qa-report.md" ,
558- scenarios : [ ] ,
559- summaryPath : "/tmp/qa-summary.json" ,
560- watchUrl : lab . baseUrl ,
561- } ,
729+ result : await createQaLabSuiteResultFixture ( { watchUrl : lab . baseUrl } ) ,
562730 } ) ;
563731
564732 const response = await fetch ( `${ lab . baseUrl } /api/scenario/suite` , {
0 commit comments