File tree Expand file tree Collapse file tree
services/service-ai/src/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,6 +106,7 @@ describe('createH3Router', () => {
106106 undefined ,
107107 expect . any ( Object ) ,
108108 expect . objectContaining ( { request : expect . anything ( ) } ) ,
109+ '/api' ,
109110 ) ;
110111 } ) ;
111112
@@ -119,6 +120,7 @@ describe('createH3Router', () => {
119120 undefined ,
120121 expect . any ( Object ) ,
121122 expect . objectContaining ( { request : expect . anything ( ) } ) ,
123+ '/api' ,
122124 ) ;
123125 } ) ;
124126
Original file line number Diff line number Diff line change @@ -24,7 +24,11 @@ describe('AuthPlugin', () => {
2424 beforeEach ( ( ) => {
2525 mockContext = {
2626 registerService : vi . fn ( ) ,
27- getService : vi . fn ( ) ,
27+ getService : vi . fn ( ( name : string ) => {
28+ if ( name === 'manifest' ) return { register : vi . fn ( ) } ;
29+ if ( name === 'data' ) return undefined ;
30+ return undefined ;
31+ } ) ,
2832 getServices : vi . fn ( ( ) => new Map ( ) ) ,
2933 hook : vi . fn ( ) ,
3034 trigger : vi . fn ( ) ,
@@ -47,7 +51,7 @@ describe('AuthPlugin', () => {
4751 expect ( authPlugin . name ) . toBe ( 'com.objectstack.auth' ) ;
4852 expect ( authPlugin . type ) . toBe ( 'standard' ) ;
4953 expect ( authPlugin . version ) . toBe ( '1.0.0' ) ;
50- expect ( authPlugin . dependencies ) . toEqual ( [ ] ) ;
54+ expect ( authPlugin . dependencies ) . toEqual ( [ 'com.objectstack.engine.objectql' ] ) ;
5155 } ) ;
5256 } ) ;
5357
Original file line number Diff line number Diff line change @@ -868,7 +868,16 @@ describe('AIServicePlugin', () => {
868868 } ) ;
869869
870870 it ( 'should fallback to MemoryLLMAdapter when provider SDK is not installed' , async ( ) => {
871- const plugin = new AIServicePlugin ( ) ;
871+ // Mock all provider SDKs to simulate them not being installed.
872+ // In the workspace @ai -sdk/openai may be resolvable as a transitive
873+ // dependency, so we must explicitly make the dynamic import fail.
874+ vi . doMock ( '@ai-sdk/openai' , ( ) => { throw new Error ( 'Cannot find module \'@ai-sdk/openai\'' ) ; } ) ;
875+ vi . doMock ( '@ai-sdk/anthropic' , ( ) => { throw new Error ( 'Cannot find module \'@ai-sdk/anthropic\'' ) ; } ) ;
876+ vi . doMock ( '@ai-sdk/google' , ( ) => { throw new Error ( 'Cannot find module \'@ai-sdk/google\'' ) ; } ) ;
877+
878+ // Re-import the plugin module so it picks up the mocked imports
879+ const { AIServicePlugin : FreshPlugin } = await import ( '../plugin.js' ) ;
880+ const plugin = new FreshPlugin ( ) ;
872881 const ctx = createMockContext ( ) ;
873882
874883 const oldEnv = { ...process . env } ;
@@ -897,6 +906,9 @@ describe('AIServicePlugin', () => {
897906 ) ;
898907 } finally {
899908 process . env = oldEnv ;
909+ vi . doUnmock ( '@ai-sdk/openai' ) ;
910+ vi . doUnmock ( '@ai-sdk/anthropic' ) ;
911+ vi . doUnmock ( '@ai-sdk/google' ) ;
900912 }
901913 } ) ;
902914
You can’t perform that action at this time.
0 commit comments