@@ -205,3 +205,45 @@ test('benchmark - worker CACHE_MAIN_SCRIPTS', async (t) => {
205205
206206 t . pass ( )
207207} )
208+
209+ test ( 'Worker filters out scripts with exclude metadata' , async ( t ) => {
210+ const { msg, worker } = await runWorkerMessage ( {
211+ channel : Channel . CACHE_MAIN_SCRIPTS ,
212+ value : null ,
213+ id : 'test-exclude-filter'
214+ } )
215+
216+ t . is ( msg . channel , Channel . CACHE_MAIN_SCRIPTS )
217+ t . true ( Array . isArray ( msg . scripts ) , 'scripts should be an array' )
218+
219+ // Verify no scripts have exclude property set to true
220+ const excludedScriptsFound = msg . scripts . filter ( ( script : any ) => script . exclude === true )
221+ t . is ( excludedScriptsFound . length , 0 , 'No scripts with exclude:true should be present in cached scripts' )
222+
223+ // Log for debugging
224+ if ( msg . scripts . length > 0 ) {
225+ t . log ( `Total scripts after exclude filter: ${ msg . scripts . length } ` )
226+ }
227+
228+ worker . terminate ( )
229+ } )
230+
231+ test ( 'Worker preserves non-excluded scripts' , async ( t ) => {
232+ const { msg, worker } = await runWorkerMessage ( {
233+ channel : Channel . CACHE_MAIN_SCRIPTS ,
234+ value : null ,
235+ id : 'test-preserve-non-excluded'
236+ } )
237+
238+ t . is ( msg . channel , Channel . CACHE_MAIN_SCRIPTS )
239+ t . true ( Array . isArray ( msg . scripts ) , 'scripts should be an array' )
240+
241+ // Verify that scripts without exclude or with exclude:false are preserved
242+ const nonExcludedScripts = msg . scripts . filter ( ( script : any ) =>
243+ script . exclude === undefined || script . exclude === false
244+ )
245+
246+ t . is ( nonExcludedScripts . length , msg . scripts . length , 'All cached scripts should be non-excluded' )
247+
248+ worker . terminate ( )
249+ } )
0 commit comments