@@ -3,8 +3,6 @@ import { vi } from "vitest";
33import  {  ConfigEnhancer  }  from  "../configEnhancer.js" ; 
44
55import  {  ModelService  }  from  "./ModelService.js" ; 
6- import  {  serviceContainer  }  from  "./ServiceContainer.js" ; 
7- import  {  SERVICE_NAMES  }  from  "./types.js" ; 
86import  {  WorkflowService  }  from  "./WorkflowService.js" ; 
97
108// Mock the hubLoader module 
@@ -100,16 +98,6 @@ describe("Workflow Integration Tests", () => {
10098    modelService  =  new  ModelService ( ) ; 
10199    configEnhancer  =  new  ConfigEnhancer ( ) ; 
102100
103-     // Mock service container 
104-     vi . spyOn ( serviceContainer ,  "get" ) . mockImplementation ( 
105-       async  ( serviceName : string )  =>  { 
106-         if  ( serviceName  ===  SERVICE_NAMES . WORKFLOW )  { 
107-           return  workflowService . getState ( ) ; 
108-         } 
109-         throw  new  Error ( `Service ${ serviceName }  ) ; 
110-       } , 
111-     ) ; 
112- 
113101    // Setup default mocks 
114102    mockProcessRule . mockResolvedValue ( "Processed rule content" ) ; 
115103    mockLoadPackagesFromHub . mockResolvedValue ( [ {  name : "test-mcp"  } ] ) ; 
@@ -146,6 +134,7 @@ describe("Workflow Integration Tests", () => {
146134      const  enhancedConfig  =  await  configEnhancer . enhanceConfig ( 
147135        baseConfig  as  any , 
148136        baseOptions , 
137+         workflowState , 
149138      ) ; 
150139
151140      // Should have loaded the workflow model directly via loadPackageFromHub 
@@ -176,6 +165,7 @@ describe("Workflow Integration Tests", () => {
176165      const  enhancedConfig  =  await  configEnhancer . enhanceConfig ( 
177166        baseConfig  as  any , 
178167        baseOptions , 
168+         workflowState , 
179169      ) ; 
180170
181171      // Should not have enhanced with any models 
@@ -206,6 +196,7 @@ describe("Workflow Integration Tests", () => {
206196      const  enhancedConfig  =  await  configEnhancer . enhanceConfig ( 
207197        baseConfig  as  any , 
208198        baseOptions , 
199+         workflowService . getState ( ) , 
209200      ) ; 
210201
211202      // Should process the user model via loadPackagesFromHub 
@@ -246,6 +237,7 @@ describe("Workflow Integration Tests", () => {
246237      const  enhancedConfig  =  await  configEnhancer . enhanceConfig ( 
247238        baseConfig  as  any , 
248239        { } , 
240+         workflowService . getState ( ) , 
249241      ) ; 
250242
251243      // Rules should be processed normally since workflow rules are now added to options.rule 
@@ -269,6 +261,7 @@ describe("Workflow Integration Tests", () => {
269261      const  enhancedConfig  =  await  configEnhancer . enhanceConfig ( 
270262        baseConfig  as  any , 
271263        { } , 
264+         workflowService . getState ( ) , 
272265      ) ; 
273266
274267      expect ( mockProcessRule ) . not . toHaveBeenCalled ( ) ; 
@@ -292,6 +285,7 @@ describe("Workflow Integration Tests", () => {
292285      const  enhancedConfig  =  await  configEnhancer . enhanceConfig ( 
293286        baseConfig  as  any , 
294287        { } , 
288+         workflowService . getState ( ) , 
295289      ) ; 
296290
297291      expect ( mockProcessRule ) . not . toHaveBeenCalled ( ) ; 
@@ -367,6 +361,7 @@ describe("Workflow Integration Tests", () => {
367361      const  enhancedConfig  =  await  configEnhancer . enhanceConfig ( 
368362        baseConfig  as  any , 
369363        { } , 
364+         workflowService . getState ( ) , 
370365      ) ; 
371366
372367      // Should not inject workflow rule but should preserve existing rules 
@@ -389,6 +384,7 @@ describe("Workflow Integration Tests", () => {
389384      const  enhancedConfig  =  await  configEnhancer . enhanceConfig ( 
390385        baseConfig  as  any , 
391386        { } , 
387+         workflowService . getState ( ) , 
392388      ) ; 
393389
394390      // Prompts should be processed at runtime, not injected into config 
@@ -452,27 +448,18 @@ describe("Workflow Integration Tests", () => {
452448      mockLoadPackageFromHub . mockResolvedValue ( mockWorkflowFile ) ; 
453449      await  workflowService . initialize ( "owner/workflow" ) ; 
454450
455-       // Create a spy to verify the internal behavior of ConfigEnhancer 
456-       const  originalGet  =  serviceContainer . get ; 
457-       const  getSpy  =  vi 
458-         . spyOn ( serviceContainer ,  "get" ) 
459-         . mockImplementation ( async  ( serviceName : string )  =>  { 
460-           if  ( serviceName  ===  SERVICE_NAMES . WORKFLOW )  { 
461-             return  workflowService . getState ( ) ; 
462-           } 
463-           return  originalGet . call ( serviceContainer ,  serviceName ) ; 
464-         } ) ; 
465- 
466451      const  baseOptions  =  {  prompt : [ "user-prompt" ]  } ; 
467452
468453      // This should internally modify the options to include workflow prompt 
469-       await  configEnhancer . enhanceConfig ( { }  as  any ,  baseOptions ) ; 
470- 
471-       // The ConfigEnhancer should have been called with workflow service 
472-       expect ( getSpy ) . toHaveBeenCalledWith ( SERVICE_NAMES . WORKFLOW ) ; 
454+       await  configEnhancer . enhanceConfig ( 
455+         { }  as  any , 
456+         baseOptions , 
457+         workflowService . getState ( ) , 
458+       ) ; 
473459
474-       // Clean up 
475-       getSpy . mockRestore ( ) ; 
460+       // Verify that the workflow prompt was added to the options 
461+       // by checking that injectPrompts was called with workflow prompt prefixed 
462+       expect ( baseOptions . prompt ) . toHaveLength ( 1 ) ; 
476463    } ) ; 
477464
478465    it ( "should work end-to-end with workflow prompt processing" ,  async  ( )  =>  { 
@@ -564,6 +551,7 @@ describe("Workflow Integration Tests", () => {
564551      const  enhancedConfig  =  await  configEnhancer . enhanceConfig ( 
565552        baseConfig  as  any , 
566553        { } , 
554+         workflowService . getState ( ) , 
567555      ) ; 
568556
569557      expect ( enhancedConfig . mcpServers ) . toHaveLength ( 3 ) ; 
@@ -588,6 +576,7 @@ describe("Workflow Integration Tests", () => {
588576      const  enhancedConfig  =  await  configEnhancer . enhanceConfig ( 
589577        baseConfig  as  any , 
590578        { } , 
579+         workflowService . getState ( ) , 
591580      ) ; 
592581
593582      expect ( enhancedConfig . mcpServers ) . toHaveLength ( 1 ) ; 
@@ -612,6 +601,7 @@ describe("Workflow Integration Tests", () => {
612601      const  enhancedConfig  =  await  configEnhancer . enhanceConfig ( 
613602        baseConfig  as  any , 
614603        { } , 
604+         workflowService . getState ( ) , 
615605      ) ; 
616606
617607      // Should not deduplicate since we simplified the logic 
0 commit comments