Skip to content

fix: resolve CI test failures across 6 packages - #1077

Merged
hotlong merged 4 commits into
mainfrom
copilot/fix-ci-build-test-errors-another-one
Apr 7, 2026
Merged

fix: resolve CI test failures across 6 packages#1077
hotlong merged 4 commits into
mainfrom
copilot/fix-ci-build-test-errors-another-one

Conversation

CopilotAI commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Tests were out of sync with production code after recent changes to HttpDispatcher.dispatch() signature, AuthPlugin dependencies, and workspace dependency graph.

dispatch() prefix argument — nuxt, nextjs, fastify, sveltekit

HttpDispatcher.dispatch() now takes a 6th prefix argument, but adapter test assertions only checked 5 args. Added '/api' to all toHaveBeenCalledWith calls:

expect(mockDispatcher.dispatch).toHaveBeenCalledWith('GET','/meta/objects',undefined,expect.any(Object),expect.objectContaining({request: expect.anything()}),'/api',// ← was missing);

service-ai SDK fallback test

@ai-sdk/openai is now resolvable as a transitive workspace dependency (via apps/studio), so the "SDK not installed" fallback test was hitting the success path instead. Fixed by mocking the dynamic imports with vi.doMock().

plugin-auth mock context

  • AuthPlugin.dependencies changed to ['com.objectstack.engine.objectql'] — updated assertion
  • AuthPlugin.init() now calls ctx.getService('manifest').register() — added mock manifest service to test context

@vercel

vercelBot commented Apr 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
objectstack-playReadyReadyPreview, CommentApr 7, 2026 6:20am
specReadyReadyPreview, CommentApr 7, 2026 6:20am

Request Review

CopilotAIand others added 2 commits April 7, 2026 06:01
…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>
CopilotAI changed the title [WIP] Fix all CI build and test errorsfix: resolve CI test failures across 6 packagesApr 7, 2026
CopilotAI requested a review from hotlongApril 7, 2026 06:14
@hotlong
hotlong marked this pull request as ready for review April 7, 2026 06:24
CopilotAI review requested due to automatic review settings April 7, 2026 06:24
@hotlong
hotlong merged commit db30cd1 into mainApr 7, 2026
3 checks passed

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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-ai SDK-missing fallback test to reliably simulate missing provider SDKs using vi.doMock() and cleanup via vi.doUnmock().
  • Updated plugin-auth tests to reflect new dependencies and to provide a manifest service mock for init().

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
packages/services/service-ai/src/tests/ai-service.test.tsMocks provider SDK modules to force the “SDK missing” fallback path in auto-detection tests.
packages/plugins/plugin-auth/src/auth-plugin.test.tsUpdates expected dependencies and adds manifest service mocking in the test context.
packages/adapters/sveltekit/src/sveltekit.test.tsAdds '/api' prefix argument to dispatch() assertion expectations.
packages/adapters/nuxt/src/nuxt.test.tsAdds '/api' prefix argument to dispatch() assertion expectations.
packages/adapters/nextjs/src/nextjs.test.tsAdds '/api' prefix argument to dispatch() assertion expectations.
packages/adapters/nextjs/src/metadata-api.test.tsAdds '/api' prefix argument to dispatch() assertion expectations across integration cases.
packages/adapters/fastify/src/fastify.test.tsAdds '/api' prefix argument to dispatch() assertion expectations.
CHANGELOG.mdDocuments the CI test fixes under “Unreleased → Fixed”.

Comment on lines +27 to +31
getService: vi.fn((name: string) => {
if (name === 'manifest') return { register: vi.fn() };
if (name === 'data') return undefined;
return undefined;
}),

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

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.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@hotlong