Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- **CI Test Failures** — Resolved test failures across multiple packages:
- `@objectstack/service-ai`: Fixed SDK fallback test by mocking `@ai-sdk/openai` dynamic import
(SDK now available as transitive workspace dependency)
- `@objectstack/nuxt`, `@objectstack/nextjs`, `@objectstack/fastify`, `@objectstack/sveltekit`:
Added missing `prefix` argument to `dispatch()` assertion calls in adapter tests
- `@objectstack/plugin-auth`: Updated `dependencies` assertion and added `manifest` service mock
to match current plugin implementation

### Added
- **AIServicePlugin Auto-Detection** — AIServicePlugin now automatically detects and initializes
LLM providers based on environment variables, eliminating the need for manual adapter configuration
Expand Down
2 changes: 2 additions & 0 deletions packages/adapters/fastify/src/fastify.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,6 +96,7 @@ describe('objectStackPlugin', () => {
undefined,
expect.any(Object),
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});

Expand All@@ -112,6 +113,7 @@ describe('objectStackPlugin', () => {
undefined,
expect.any(Object),
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});

Expand Down
9 changes: 9 additions & 0 deletions packages/adapters/nextjs/src/metadata-api.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,6 +132,7 @@ describe('Next.js Metadata API Integration Tests', () => {
undefined,
{},
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});
});
Expand DownExpand Up@@ -159,6 +160,7 @@ describe('Next.js Metadata API Integration Tests', () => {
undefined,
{},
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});
});
Expand All@@ -185,6 +187,7 @@ describe('Next.js Metadata API Integration Tests', () => {
body,
{},
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});
});
Expand All@@ -207,6 +210,7 @@ describe('Next.js Metadata API Integration Tests', () => {
body,
{},
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});
});
Expand DownExpand Up@@ -238,6 +242,7 @@ describe('Next.js Metadata API Integration Tests', () => {
undefined,
{},
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});

Expand All@@ -250,6 +255,7 @@ describe('Next.js Metadata API Integration Tests', () => {
undefined,
{},
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});

Expand All@@ -262,6 +268,7 @@ describe('Next.js Metadata API Integration Tests', () => {
undefined,
{},
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});
});
Expand DownExpand Up@@ -696,6 +703,7 @@ describe('Next.js Metadata API Integration Tests', () => {
undefined,
{},
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});

Expand All@@ -709,6 +717,7 @@ describe('Next.js Metadata API Integration Tests', () => {
undefined,
{},
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});
});
Expand Down
6 changes: 6 additions & 0 deletions packages/adapters/nextjs/src/nextjs.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -284,6 +284,7 @@ describe('createRouteHandler', () => {
undefined,
expect.any(Object),
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});

Expand All@@ -299,6 +300,7 @@ describe('createRouteHandler', () => {
body,
expect.any(Object),
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});

Expand All@@ -314,6 +316,7 @@ describe('createRouteHandler', () => {
body,
expect.any(Object),
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});
});
Expand All@@ -330,6 +333,7 @@ describe('createRouteHandler', () => {
undefined,
expect.any(Object),
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});

Expand All@@ -345,6 +349,7 @@ describe('createRouteHandler', () => {
body,
expect.any(Object),
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});

Expand All@@ -360,6 +365,7 @@ describe('createRouteHandler', () => {
body,
expect.any(Object),
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});

Expand Down
2 changes: 2 additions & 0 deletions packages/adapters/nuxt/src/nuxt.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -106,6 +106,7 @@ describe('createH3Router', () => {
undefined,
expect.any(Object),
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});

Expand All@@ -119,6 +120,7 @@ describe('createH3Router', () => {
undefined,
expect.any(Object),
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});

Expand Down
3 changes: 3 additions & 0 deletions packages/adapters/sveltekit/src/sveltekit.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -176,6 +176,7 @@ describe('createRequestHandler', () => {
undefined,
expect.any(Object),
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});
});
Expand All@@ -191,6 +192,7 @@ describe('createRequestHandler', () => {
undefined,
expect.any(Object),
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});

Expand All@@ -205,6 +207,7 @@ describe('createRequestHandler', () => {
body,
expect.any(Object),
expect.objectContaining({ request: expect.anything() }),
'/api',
);
});

Expand Down
8 changes: 6 additions & 2 deletions packages/plugins/plugin-auth/src/auth-plugin.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,11 @@ describe('AuthPlugin', () => {
beforeEach(() => {
mockContext = {
registerService: vi.fn(),
getService: vi.fn(),
getService: vi.fn((name: string) => {
if (name === 'manifest') return { register: vi.fn() };
if (name === 'data') return undefined;
return undefined;
}),
Comment on lines +27 to +31

CopilotAIApr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PluginContext.getService() is specified to throw when a service is missing (and the real kernel implementations do). This mock currently returns undefined for unknown services (including 'data'), which can mask incorrect service lookups and makes the test context diverge from production behavior. Consider having the mock throw by default and explicitly return only the services this test intends to provide (e.g. manifest), and if AuthPlugin is meant to support “no data engine” mode, simulate that by throwing for 'data' (and update the implementation accordingly).

Copilot uses AI. Check for mistakes.
getServices: vi.fn(() => new Map()),
hook: vi.fn(),
trigger: vi.fn(),
Expand All@@ -47,7 +51,7 @@ describe('AuthPlugin', () => {
expect(authPlugin.name).toBe('com.objectstack.auth');
expect(authPlugin.type).toBe('standard');
expect(authPlugin.version).toBe('1.0.0');
expect(authPlugin.dependencies).toEqual([]);
expect(authPlugin.dependencies).toEqual(['com.objectstack.engine.objectql']);
});
});

Expand Down
14 changes: 13 additions & 1 deletion packages/services/service-ai/src/__tests__/ai-service.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -868,7 +868,16 @@ describe('AIServicePlugin', () => {
});

it('should fallback to MemoryLLMAdapter when provider SDK is not installed', async () => {
const plugin = new AIServicePlugin();
// Mock all provider SDKs to simulate them not being installed.
// In the workspace @ai-sdk/openai may be resolvable as a transitive
// dependency, so we must explicitly make the dynamic import fail.
vi.doMock('@ai-sdk/openai', () => { throw new Error('Cannot find module \'@ai-sdk/openai\''); });
vi.doMock('@ai-sdk/anthropic', () => { throw new Error('Cannot find module \'@ai-sdk/anthropic\''); });
vi.doMock('@ai-sdk/google', () => { throw new Error('Cannot find module \'@ai-sdk/google\''); });

// Re-import the plugin module so it picks up the mocked imports
const { AIServicePlugin: FreshPlugin } = await import('../plugin.js');
const plugin = new FreshPlugin();
Comment on lines +878 to +880

CopilotAIApr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says the module is re-imported “so it picks up the mocked imports”, but import('../plugin.js') will still return the cached module unless vi.resetModules() (or similar) is used. Either reset the module graph before re-importing, or drop the “fresh import” and just instantiate AIServicePlugin after setting vi.doMock(...) (the dynamic provider imports are what need mocking, not the plugin module load).

Suggested change
// Re-import the plugin module so it picks up the mocked imports
const{AIServicePlugin: FreshPlugin}=awaitimport('../plugin.js');
constplugin=newFreshPlugin();
// The provider SDKs are dynamically imported during plugin initialization,
// so mocking those modules is sufficient; the plugin module itself does
// not need to be re-imported here.
constplugin=newAIServicePlugin();

Copilot uses AI. Check for mistakes.
const ctx = createMockContext();

const oldEnv = { ...process.env };
Expand DownExpand Up@@ -897,6 +906,9 @@ describe('AIServicePlugin', () => {
);
} finally {
process.env = oldEnv;
vi.doUnmock('@ai-sdk/openai');
vi.doUnmock('@ai-sdk/anthropic');
vi.doUnmock('@ai-sdk/google');
}
});

Expand Down