@@ -22,8 +22,6 @@ import {
2222 WorkflowBuilder ,
2323} from '@sim/testing'
2424import { beforeEach , describe , expect , it } from 'vitest'
25- import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
26- import { useSubBlockStore } from '@/stores/workflows/subblock/store'
2725import { useWorkflowStore } from '@/stores/workflows/workflow/store'
2826
2927describe ( 'workflow store' , ( ) => {
@@ -365,30 +363,6 @@ describe('workflow store', () => {
365363 } )
366364 } )
367365
368- describe ( 'duplicateBlock' , ( ) => {
369- it ( 'should duplicate a block' , ( ) => {
370- const { addBlock, duplicateBlock } = useWorkflowStore . getState ( )
371-
372- addBlock ( 'original' , 'agent' , 'Original Agent' , { x : 0 , y : 0 } )
373-
374- duplicateBlock ( 'original' )
375-
376- const { blocks } = useWorkflowStore . getState ( )
377- const blockIds = Object . keys ( blocks )
378-
379- expect ( blockIds . length ) . toBe ( 2 )
380-
381- const duplicatedId = blockIds . find ( ( id ) => id !== 'original' )
382- expect ( duplicatedId ) . toBeDefined ( )
383-
384- if ( duplicatedId ) {
385- expect ( blocks [ duplicatedId ] . type ) . toBe ( 'agent' )
386- expect ( blocks [ duplicatedId ] . name ) . toContain ( 'Original Agent' )
387- expect ( blocks [ duplicatedId ] . position . x ) . not . toBe ( 0 )
388- }
389- } )
390- } )
391-
392366 describe ( 'batchUpdatePositions' , ( ) => {
393367 it ( 'should update block position' , ( ) => {
394368 const { addBlock, batchUpdatePositions } = useWorkflowStore . getState ( )
@@ -452,29 +426,6 @@ describe('workflow store', () => {
452426 expect ( state . loops . loop1 . forEachItems ) . toBe ( '["a", "b", "c"]' )
453427 } )
454428
455- it ( 'should regenerate loops when updateLoopCollection is called' , ( ) => {
456- const { addBlock, updateLoopCollection } = useWorkflowStore . getState ( )
457-
458- addBlock (
459- 'loop1' ,
460- 'loop' ,
461- 'Test Loop' ,
462- { x : 0 , y : 0 } ,
463- {
464- loopType : 'forEach' ,
465- collection : '["item1", "item2"]' ,
466- }
467- )
468-
469- updateLoopCollection ( 'loop1' , '["item1", "item2", "item3"]' )
470-
471- const state = useWorkflowStore . getState ( )
472-
473- expect ( state . blocks . loop1 ?. data ?. collection ) . toBe ( '["item1", "item2", "item3"]' )
474- expect ( state . loops . loop1 ) . toBeDefined ( )
475- expect ( state . loops . loop1 . forEachItems ) . toBe ( '["item1", "item2", "item3"]' )
476- } )
477-
478429 it ( 'should clamp loop count between 1 and 1000' , ( ) => {
479430 const { addBlock, updateLoopCount } = useWorkflowStore . getState ( )
480431
@@ -599,118 +550,6 @@ describe('workflow store', () => {
599550 } )
600551 } )
601552
602- describe ( 'mode switching' , ( ) => {
603- it ( 'should toggle advanced mode on a block' , ( ) => {
604- const { addBlock, toggleBlockAdvancedMode } = useWorkflowStore . getState ( )
605-
606- addBlock ( 'agent1' , 'agent' , 'Test Agent' , { x : 0 , y : 0 } )
607-
608- let state = useWorkflowStore . getState ( )
609- expect ( state . blocks . agent1 ?. advancedMode ) . toBe ( false )
610-
611- toggleBlockAdvancedMode ( 'agent1' )
612- state = useWorkflowStore . getState ( )
613- expect ( state . blocks . agent1 ?. advancedMode ) . toBe ( true )
614-
615- toggleBlockAdvancedMode ( 'agent1' )
616- state = useWorkflowStore . getState ( )
617- expect ( state . blocks . agent1 ?. advancedMode ) . toBe ( false )
618- } )
619-
620- it ( 'should preserve systemPrompt and userPrompt when switching modes' , ( ) => {
621- const { addBlock, toggleBlockAdvancedMode } = useWorkflowStore . getState ( )
622- const { setState : setSubBlockState } = useSubBlockStore
623- useWorkflowRegistry . setState ( { activeWorkflowId : 'test-workflow' } )
624- addBlock ( 'agent1' , 'agent' , 'Test Agent' , { x : 0 , y : 0 } )
625- setSubBlockState ( {
626- workflowValues : {
627- 'test-workflow' : {
628- agent1 : {
629- systemPrompt : 'You are a helpful assistant' ,
630- userPrompt : 'Hello, how are you?' ,
631- } ,
632- } ,
633- } ,
634- } )
635- toggleBlockAdvancedMode ( 'agent1' )
636- let subBlockState = useSubBlockStore . getState ( )
637- expect ( subBlockState . workflowValues [ 'test-workflow' ] . agent1 . systemPrompt ) . toBe (
638- 'You are a helpful assistant'
639- )
640- expect ( subBlockState . workflowValues [ 'test-workflow' ] . agent1 . userPrompt ) . toBe (
641- 'Hello, how are you?'
642- )
643- toggleBlockAdvancedMode ( 'agent1' )
644- subBlockState = useSubBlockStore . getState ( )
645- expect ( subBlockState . workflowValues [ 'test-workflow' ] . agent1 . systemPrompt ) . toBe (
646- 'You are a helpful assistant'
647- )
648- expect ( subBlockState . workflowValues [ 'test-workflow' ] . agent1 . userPrompt ) . toBe (
649- 'Hello, how are you?'
650- )
651- } )
652-
653- it ( 'should preserve memories when switching from advanced to basic mode' , ( ) => {
654- const { addBlock, toggleBlockAdvancedMode } = useWorkflowStore . getState ( )
655- const { setState : setSubBlockState } = useSubBlockStore
656-
657- useWorkflowRegistry . setState ( { activeWorkflowId : 'test-workflow' } )
658-
659- addBlock ( 'agent1' , 'agent' , 'Test Agent' , { x : 0 , y : 0 } )
660-
661- toggleBlockAdvancedMode ( 'agent1' )
662-
663- setSubBlockState ( {
664- workflowValues : {
665- 'test-workflow' : {
666- agent1 : {
667- systemPrompt : 'You are a helpful assistant' ,
668- userPrompt : 'What did we discuss?' ,
669- memories : [
670- { role : 'user' , content : 'My name is John' } ,
671- { role : 'assistant' , content : 'Nice to meet you, John!' } ,
672- ] ,
673- } ,
674- } ,
675- } ,
676- } )
677-
678- toggleBlockAdvancedMode ( 'agent1' )
679-
680- const subBlockState = useSubBlockStore . getState ( )
681- expect ( subBlockState . workflowValues [ 'test-workflow' ] . agent1 . systemPrompt ) . toBe (
682- 'You are a helpful assistant'
683- )
684- expect ( subBlockState . workflowValues [ 'test-workflow' ] . agent1 . userPrompt ) . toBe (
685- 'What did we discuss?'
686- )
687- expect ( subBlockState . workflowValues [ 'test-workflow' ] . agent1 . memories ) . toEqual ( [
688- { role : 'user' , content : 'My name is John' } ,
689- { role : 'assistant' , content : 'Nice to meet you, John!' } ,
690- ] )
691- } )
692-
693- it ( 'should handle mode switching when no subblock values exist' , ( ) => {
694- const { addBlock, toggleBlockAdvancedMode } = useWorkflowStore . getState ( )
695-
696- useWorkflowRegistry . setState ( { activeWorkflowId : 'test-workflow' } )
697-
698- addBlock ( 'agent1' , 'agent' , 'Test Agent' , { x : 0 , y : 0 } )
699-
700- expect ( useWorkflowStore . getState ( ) . blocks . agent1 ?. advancedMode ) . toBe ( false )
701- expect ( ( ) => toggleBlockAdvancedMode ( 'agent1' ) ) . not . toThrow ( )
702-
703- const state = useWorkflowStore . getState ( )
704- expect ( state . blocks . agent1 ?. advancedMode ) . toBe ( true )
705- } )
706-
707- it ( 'should not throw when toggling non-existent block' , ( ) => {
708- const { toggleBlockAdvancedMode } = useWorkflowStore . getState ( )
709-
710- expect ( ( ) => toggleBlockAdvancedMode ( 'non-existent' ) ) . not . toThrow ( )
711- } )
712- } )
713-
714553 describe ( 'workflow state management' , ( ) => {
715554 it ( 'should work with WorkflowBuilder for complex setups' , ( ) => {
716555 const workflowState = WorkflowBuilder . linear ( 3 ) . build ( )
0 commit comments