@@ -11,10 +11,15 @@ import type { BlockStateController } from '@/executor/execution/types'
1111import { LoopOrchestrator } from '@/executor/orchestrators/loop'
1212import type { ExecutionContext } from '@/executor/types'
1313
14- const { mockUploadFile } = vi . hoisted ( ( ) => ( {
14+ const { mockExecuteInIsolatedVM, mockUploadFile } = vi . hoisted ( ( ) => ( {
15+ mockExecuteInIsolatedVM : vi . fn ( ) ,
1516 mockUploadFile : vi . fn ( ) ,
1617} ) )
1718
19+ vi . mock ( '@/lib/execution/isolated-vm' , ( ) => ( {
20+ executeInIsolatedVM : mockExecuteInIsolatedVM ,
21+ } ) )
22+
1823vi . mock ( '@/lib/uploads' , ( ) => ( {
1924 StorageService : {
2025 uploadFile : mockUploadFile ,
@@ -83,6 +88,7 @@ describe('LoopOrchestrator', () => {
8388 beforeEach ( ( ) => {
8489 vi . clearAllMocks ( )
8590 clearLargeValueCacheForTests ( )
91+ mockExecuteInIsolatedVM . mockResolvedValue ( { result : true } )
8692 mockUploadFile . mockImplementation ( async ( { customKey } ) => ( { key : customKey } ) )
8793 } )
8894
@@ -275,6 +281,7 @@ describe('LoopOrchestrator', () => {
275281 it ( 'marks while loops with false initial conditions as skipped at start' , async ( ) => {
276282 const state = createState ( )
277283 const resolver = { resolveSingleReference : vi . fn ( ) . mockResolvedValue ( false ) }
284+ mockExecuteInIsolatedVM . mockResolvedValueOnce ( { result : false } )
278285 const orchestrator = new LoopOrchestrator (
279286 { loopConfigs : new Map ( ) , parallelConfigs : new Map ( ) , nodes : new Map ( ) } ,
280287 state ,
@@ -294,6 +301,11 @@ describe('LoopOrchestrator', () => {
294301 expect ( shouldExecute ) . toBe ( false )
295302 expect ( scope . skippedAtStart ) . toBe ( true )
296303 expect ( state . setBlockOutput ) . not . toHaveBeenCalled ( )
304+ expect ( mockExecuteInIsolatedVM ) . toHaveBeenCalledWith (
305+ expect . objectContaining ( {
306+ code : 'return Boolean(false)' ,
307+ } )
308+ )
297309 } )
298310
299311 it ( 'exits doWhile loops when the configured iteration cap is reached' , async ( ) => {
0 commit comments