@@ -1154,6 +1154,7 @@ export class IntegrationTestRunner {
11541154 ) ;
11551155
11561156 let totalPromptTests = 0 ;
1157+ let allPromptTestsPassed = true ;
11571158 for ( const promptName of promptDirs ) {
11581159 if ( ! promptNames . includes ( promptName ) ) {
11591160 this . logger . log ( `Skipping ${ promptName } - prompt not found on server` , "WARN" ) ;
@@ -1169,13 +1170,16 @@ export class IntegrationTestRunner {
11691170 this . logger . log ( `Running ${ testCases . length } test case(s) for prompt ${ promptName } ` ) ;
11701171
11711172 for ( const testCase of testCases ) {
1172- await this . runSinglePromptIntegrationTest ( promptName , testCase , promptDir ) ;
1173+ const passed = await this . runSinglePromptIntegrationTest ( promptName , testCase , promptDir ) ;
11731174 totalPromptTests ++ ;
1175+ if ( ! passed ) {
1176+ allPromptTestsPassed = false ;
1177+ }
11741178 }
11751179 }
11761180
11771181 this . logger . log ( `Total prompt integration tests executed: ${ totalPromptTests } ` ) ;
1178- return true ;
1182+ return totalPromptTests > 0 ? allPromptTestsPassed : true ;
11791183 } catch ( error ) {
11801184 this . logger . log ( `Error running prompt integration tests: ${ error . message } ` , "ERROR" ) ;
11811185 return false ;
@@ -1200,19 +1204,19 @@ export class IntegrationTestRunner {
12001204 // Validate test structure
12011205 if ( ! fs . existsSync ( beforeDir ) ) {
12021206 this . logger . logTest ( testName , false , "Missing before directory" ) ;
1203- return ;
1207+ return false ;
12041208 }
12051209
12061210 if ( ! fs . existsSync ( afterDir ) ) {
12071211 this . logger . logTest ( testName , false , "Missing after directory" ) ;
1208- return ;
1212+ return false ;
12091213 }
12101214
12111215 // Load parameters from before/monitoring-state.json
12121216 const monitoringStatePath = path . join ( beforeDir , "monitoring-state.json" ) ;
12131217 if ( ! fs . existsSync ( monitoringStatePath ) ) {
12141218 this . logger . logTest ( testName , false , "Missing before/monitoring-state.json" ) ;
1215- return ;
1219+ return false ;
12161220 }
12171221
12181222 const monitoringState = JSON . parse ( fs . readFileSync ( monitoringStatePath , "utf8" ) ) ;
@@ -1231,27 +1235,37 @@ export class IntegrationTestRunner {
12311235 const hasMessages = result . messages && result . messages . length > 0 ;
12321236 if ( ! hasMessages ) {
12331237 this . logger . logTest ( testName , false , "Expected messages in prompt response" ) ;
1234- return ;
1238+ return false ;
12351239 }
12361240
12371241 // If the after/monitoring-state.json has expected content checks, validate
12381242 const afterMonitoringPath = path . join ( afterDir , "monitoring-state.json" ) ;
12391243 if ( fs . existsSync ( afterMonitoringPath ) ) {
12401244 const afterState = JSON . parse ( fs . readFileSync ( afterMonitoringPath , "utf8" ) ) ;
1241- if ( afterState . expectedContentPatterns ) {
1245+
1246+ // Support both top-level expectedContentPatterns and sessions[].expectedContentPatterns
1247+ const sessions = afterState . sessions || [ ] ;
1248+ const topLevelPatterns = afterState . expectedContentPatterns || [ ] ;
1249+ const sessionPatterns =
1250+ sessions . length > 0 ? sessions [ 0 ] . expectedContentPatterns || [ ] : [ ] ;
1251+ const expectedPatterns = topLevelPatterns . length > 0 ? topLevelPatterns : sessionPatterns ;
1252+
1253+ if ( expectedPatterns . length > 0 ) {
12421254 const text = result . messages [ 0 ] ?. content ?. text || "" ;
1243- for ( const pattern of afterState . expectedContentPatterns ) {
1255+ for ( const pattern of expectedPatterns ) {
12441256 if ( ! text . includes ( pattern ) ) {
12451257 this . logger . logTest ( testName , false , `Expected response to contain "${ pattern } "` ) ;
1246- return ;
1258+ return false ;
12471259 }
12481260 }
12491261 }
12501262 }
12511263
12521264 this . logger . logTest ( testName , true , `Prompt returned ${ result . messages . length } message(s)` ) ;
1265+ return true ;
12531266 } catch ( error ) {
12541267 this . logger . logTest ( testName , false , `Error: ${ error . message } ` ) ;
1268+ return false ;
12551269 }
12561270 }
12571271
0 commit comments