Uh oh!
There was an error while loading. Please reload this page.
fix: resolve CI test failures across 6 packages - #1077
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…tests
Add the 6th 'prefix' argument ('/api') to all toHaveBeenCalledWith
assertions for dispatcher.dispatch() in fastify, nextjs, and sveltekit
adapter test files.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>…veltekit, and plugin-auth - service-ai: mock @ai-sdk/openai dynamic import for SDK fallback test - nuxt, nextjs, fastify, sveltekit: add missing prefix arg to dispatch assertions - plugin-auth: update dependencies assertion and mock manifest service Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/faa63a9f-127e-42d7-8e7f-a2a058ddde10 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/faa63a9f-127e-42d7-8e7f-a2a058ddde10 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Pull request overview
Fixes CI test failures by aligning multiple package test suites with recent runtime/plugin changes (notably HttpDispatcher.dispatch()’s 6th prefix arg, AuthPlugin dependency updates, and service-ai provider SDK fallback behavior) to keep the monorepo’s adapter/plugin/service tests consistent with production code.
Changes:
- Updated adapter tests (Nuxt/Next.js/Fastify/SvelteKit) to assert the new 6th
dispatch()argument (prefix, e.g.'/api'). - Adjusted
service-aiSDK-missing fallback test to reliably simulate missing provider SDKs usingvi.doMock()and cleanup viavi.doUnmock(). - Updated
plugin-authtests to reflect new dependencies and to provide amanifestservice mock forinit().
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/services/service-ai/src/tests/ai-service.test.ts | Mocks provider SDK modules to force the “SDK missing” fallback path in auto-detection tests. |
| packages/plugins/plugin-auth/src/auth-plugin.test.ts | Updates expected dependencies and adds manifest service mocking in the test context. |
| packages/adapters/sveltekit/src/sveltekit.test.ts | Adds '/api' prefix argument to dispatch() assertion expectations. |
| packages/adapters/nuxt/src/nuxt.test.ts | Adds '/api' prefix argument to dispatch() assertion expectations. |
| packages/adapters/nextjs/src/nextjs.test.ts | Adds '/api' prefix argument to dispatch() assertion expectations. |
| packages/adapters/nextjs/src/metadata-api.test.ts | Adds '/api' prefix argument to dispatch() assertion expectations across integration cases. |
| packages/adapters/fastify/src/fastify.test.ts | Adds '/api' prefix argument to dispatch() assertion expectations. |
| CHANGELOG.md | Documents the CI test fixes under “Unreleased → Fixed”. |
| getService: vi.fn((name: string) => { | ||
| if (name === 'manifest') return { register: vi.fn() }; | ||
| if (name === 'data') return undefined; | ||
| return undefined; | ||
| }), |
There was a problem hiding this comment.
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).
| // Re-import the plugin module so it picks up the mocked imports | ||
| const { AIServicePlugin: FreshPlugin } = await import('../plugin.js'); | ||
| const plugin = new FreshPlugin(); |
There was a problem hiding this comment.
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).
| // 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(); |
Tests were out of sync with production code after recent changes to
HttpDispatcher.dispatch()signature,AuthPlugindependencies, and workspace dependency graph.dispatch()prefix argument — nuxt, nextjs, fastify, sveltekitHttpDispatcher.dispatch()now takes a 6thprefixargument, but adapter test assertions only checked 5 args. Added'/api'to alltoHaveBeenCalledWithcalls:service-aiSDK fallback test@ai-sdk/openaiis now resolvable as a transitive workspace dependency (viaapps/studio), so the "SDK not installed" fallback test was hitting the success path instead. Fixed by mocking the dynamic imports withvi.doMock().plugin-authmock contextAuthPlugin.dependencieschanged to['com.objectstack.engine.objectql']— updated assertionAuthPlugin.init()now callsctx.getService('manifest').register()— added mock manifest service to test context