@@ -50,7 +50,10 @@ import {
5050 isProviderOpenAiExtensionRoot ,
5151} from "../test/vitest/vitest.extension-provider-paths.mjs" ;
5252import { isQaExtensionRoot } from "../test/vitest/vitest.extension-qa-paths.mjs" ;
53- import { isTelegramExtensionRoot } from "../test/vitest/vitest.extension-telegram-paths.mjs" ;
53+ import {
54+ isTelegramExtensionRoot ,
55+ telegramExtensionTestRoots ,
56+ } from "../test/vitest/vitest.extension-telegram-paths.mjs" ;
5457import { isVoiceCallExtensionRoot } from "../test/vitest/vitest.extension-voice-call-paths.mjs" ;
5558import { isWhatsAppExtensionRoot } from "../test/vitest/vitest.extension-whatsapp-paths.mjs" ;
5659import { isZaloExtensionRoot } from "../test/vitest/vitest.extension-zalo-paths.mjs" ;
@@ -255,6 +258,10 @@ const UNIT_FAST_FAKE_TIMERS_VITEST_CONFIG = "test/vitest/vitest.unit-fast-fake-t
255258const UNIT_SECURITY_VITEST_CONFIG = "test/vitest/vitest.unit-security.config.ts" ;
256259const UNIT_SRC_VITEST_CONFIG = "test/vitest/vitest.unit-src.config.ts" ;
257260const UNIT_SUPPORT_VITEST_CONFIG = "test/vitest/vitest.unit-support.config.ts" ;
261+ const EXTENSION_TEST_PROCESS_ROOTS = new Map ( [
262+ [ EXTENSION_MATRIX_VITEST_CONFIG , matrixExtensionTestRoots ] ,
263+ [ EXTENSION_TELEGRAM_VITEST_CONFIG , telegramExtensionTestRoots ] ,
264+ ] ) ;
258265
259266const FULL_SUITE_CONFIG_WEIGHT = new Map ( [
260267 [ GATEWAY_VITEST_CONFIG , 180 ] ,
@@ -962,16 +969,15 @@ function createBroadToolingScriptPlans(params: VitestRunPlan & { cwd: string })
962969 : null ;
963970}
964971
965- function createBoundedExtensionPlans (
966- params : Omit < VitestRunPlan , "includePatterns" > & { roots : string [ ] } ,
967- ) {
968- const { config, forwardedArgs, roots, watchMode } = params ;
969- if ( watchMode ) {
970- return null ;
972+ function createBoundedExtensionPlans ( plan : VitestRunPlan ) {
973+ const { config, forwardedArgs, watchMode } = plan ;
974+ const roots = EXTENSION_TEST_PROCESS_ROOTS . get ( config ) ;
975+ if ( watchMode || ! roots ) {
976+ return [ plan ] ;
971977 }
972978 const chunks = createExtensionTestProcessTargetChunks ( config , roots , forwardedArgs ) ;
973979 if ( chunks . length <= 1 ) {
974- return null ;
980+ return [ plan ] ;
975981 }
976982 return chunks . map ( ( includePatterns ) => ( {
977983 config,
@@ -3602,12 +3608,14 @@ export function buildVitestRunPlans(
36023608 "watch mode with mixed test suites is not supported; target one suite at a time or use a dedicated suite command" ,
36033609 ) ;
36043610 }
3605- return explicitConfigTargets . map ( ( config ) => ( {
3606- config,
3607- forwardedArgs : nonTargetArgs ,
3608- includePatterns : null ,
3609- watchMode,
3610- } ) ) ;
3611+ return explicitConfigTargets . flatMap ( ( config ) =>
3612+ createBoundedExtensionPlans ( {
3613+ config,
3614+ forwardedArgs : nonTargetArgs ,
3615+ includePatterns : null ,
3616+ watchMode,
3617+ } ) ,
3618+ ) ;
36113619 }
36123620
36133621 const groupedTargets = new Map < string , string [ ] > ( ) ;
@@ -3718,13 +3726,7 @@ export function buildVitestRunPlans(
37183726 includePatterns : null ,
37193727 watchMode,
37203728 } ;
3721- const boundedPlans = createBoundedExtensionPlans ( {
3722- config,
3723- forwardedArgs : nonTargetArgs ,
3724- roots : matrixExtensionTestRoots ,
3725- watchMode,
3726- } ) ;
3727- plans . push ( ...( boundedPlans ?? [ plan ] ) ) ;
3729+ plans . push ( ...createBoundedExtensionPlans ( plan ) ) ;
37283730 }
37293731 continue ;
37303732 }
@@ -3761,9 +3763,12 @@ export function buildVitestRunPlans(
37613763 plans . push ( ...broadToolingScriptPlans ) ;
37623764 continue ;
37633765 }
3766+ const processRoots = EXTENSION_TEST_PROCESS_ROOTS . get ( config ) ;
37643767 const boundedExtensionRoots = grouped . flatMap ( ( targetArg ) => {
37653768 const root = toRepoRelativeTarget ( targetArg , cwd ) ;
3766- return isMatrixExtensionRoot ( root ) && isExistingDirectoryTarget ( targetArg , cwd ) ? [ root ] : [ ] ;
3769+ return processRoots ?. includes ( root ) && isExistingDirectoryTarget ( targetArg , cwd )
3770+ ? [ root ]
3771+ : [ ] ;
37673772 } ) ;
37683773 const boundedRootsCoverGroupedTargets = grouped . every ( ( targetArg ) => {
37693774 const relativeTarget = toRepoRelativeTarget ( targetArg , cwd ) ;
@@ -3776,7 +3781,7 @@ export function buildVitestRunPlans(
37763781 ? createBoundedExtensionPlans ( {
37773782 config,
37783783 forwardedArgs : forwardedPlanArgs ,
3779- roots : boundedExtensionRoots ,
3784+ includePatterns ,
37803785 watchMode,
37813786 } )
37823787 : null ;
@@ -3856,12 +3861,11 @@ export function buildFullSuiteVitestRunPlans(args: string[], cwd = process.cwd()
38563861 listGatewayServerTestTargets ( cwd ) ,
38573862 GATEWAY_SERVER_TEST_PROCESS_COUNT ,
38583863 ) ;
3859- } else if ( config === EXTENSION_MATRIX_VITEST_CONFIG ) {
3860- chunks = createExtensionTestProcessTargetChunks (
3861- config ,
3862- matrixExtensionTestRoots ,
3863- forwardedArgs ,
3864- ) ;
3864+ } else {
3865+ const roots = EXTENSION_TEST_PROCESS_ROOTS . get ( config ) ;
3866+ if ( roots ) {
3867+ chunks = createExtensionTestProcessTargetChunks ( config , roots , forwardedArgs ) ;
3868+ }
38653869 }
38663870 if ( chunks . length > 0 ) {
38673871 return chunks . map ( ( targets ) => ( {
0 commit comments