Skip to content

Fix CI build and test errors#952

Merged
hotlong merged 3 commits intomainfrom
copilot/fix-ci-build-test-errors
Mar 22, 2026
Merged

Fix CI build and test errors#952
hotlong merged 3 commits intomainfrom
copilot/fix-ci-build-test-errors

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 22, 2026

CI pipeline broken on main — build fails in service-analytics (TS6133), tests fail in nextjs adapter and plugin-auth due to stale test assertions.

Build fix

  • service-analytics/native-sql-strategy.ts: Remove unused measure variable that fails noUnusedLocals: true. The variable was a leftover from copy-pasting the dimensions block — measures always hardcode type 'number'.

Test fixes

  • nextjs/metadata-api.test.ts (9 tests): Assertions used old dispatch(subPath, context, method, body) signature. Updated to match current implementation:

    // before
    expect(mockDispatcher.dispatch).toHaveBeenCalledWith('objects', expect.objectContaining({ request: expect.anything() }), 'GET', undefined);
    // after
    expect(mockDispatcher.dispatch).toHaveBeenCalledWith('GET', '/meta/objects', undefined, {}, expect.objectContaining({ request: expect.anything() }));
  • plugin-auth/auth-plugin.test.ts (2 tests): .mock.calls.at(-1)[1] resolved to the app.com.objectstack.system service object (second registerService call), not the AuthManager. Added mockClear() before localPlugin.init() so mock.calls[0][1] reliably references the correct AuthManager instance.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 22, 2026

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

Project Deployment Actions Updated (UTC)
objectstack-play Ready Ready Preview, Comment Mar 22, 2026 8:24am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
spec Ignored Ignored Mar 22, 2026 8:24am

Request Review

- Remove unused 'measure' variable in native-sql-strategy.ts (TS6133)
- Update nextjs adapter tests to match current dispatch() signature
- Fix auth-plugin tests to reference correct AuthManager instance

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Agent-Logs-Url: https://github.com/objectstack-ai/spec/sessions/39b2f206-d4bb-4357-98ac-f5f9e1466455
Copilot AI changed the title [WIP] Fix CI build and test errors Fix CI build and test errors Mar 22, 2026
Copilot AI requested a review from hotlong March 22, 2026 08:23
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Mar 22, 2026
@hotlong hotlong marked this pull request as ready for review March 22, 2026 08:38
Copilot AI review requested due to automatic review settings March 22, 2026 08:38
@hotlong hotlong merged commit 56066e4 into main Mar 22, 2026
13 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 breakages on main by addressing a TypeScript unused-local build failure and updating failing tests to match current runtime behavior (notably the HttpDispatcher.dispatch() signature).

Changes:

  • Removed an unused variable in service-analytics that caused TS6133 under noUnusedLocals.
  • Updated Next.js adapter metadata API tests to assert against the current dispatch(method, path, body, queryParams, context) call shape.
  • Stabilized plugin-auth tests by clearing registerService mock call history before re-initializing a local plugin instance.
  • Documented the fixes in CHANGELOG.md.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 11 comments.

File Description
packages/services/service-analytics/src/strategies/native-sql-strategy.ts Removes unused locals to unblock TypeScript build with strict unused checks.
packages/plugins/plugin-auth/src/auth-plugin.test.ts Fixes stale assertions by ensuring registerService mock calls reference the intended plugin instance.
packages/adapters/nextjs/src/metadata-api.test.ts Updates assertions to match current Next.js adapter → dispatcher call signature.
CHANGELOG.md Records CI build/test fixes for traceability.

Comment on lines +237 to 241
'/meta/views',
undefined,
{},
expect.objectContaining({ request: expect.anything() }),
);
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

This assertion hard-codes the query params arg to {}. Consider loosening it to expect.any(Object) / expect.objectContaining({}) to avoid brittleness if the adapter later adds default query keys.

Copilot uses AI. Check for mistakes.
Comment on lines +261 to 265
'/meta/agents',
undefined,
{},
expect.objectContaining({ request: expect.anything() }),
);
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

Query params are asserted as a literal {} here; consider expect.any(Object) / expect.objectContaining({}) to keep this test less coupled to internal query parsing details and aligned with other Next.js adapter tests.

Copilot uses AI. Check for mistakes.
Comment on lines +695 to 699
'/meta/objects/account/fields/name',
undefined,
{},
expect.objectContaining({ request: expect.anything() }),
);
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

This assertion fixes the dispatch signature, but it also hard-codes query params to {}. Using expect.any(Object) (as in packages/adapters/nextjs/src/nextjs.test.ts) makes the test more resilient if query parsing behavior changes.

Copilot uses AI. Check for mistakes.
Comment on lines +708 to 712
'/meta',
undefined,
{},
expect.objectContaining({ request: expect.anything() }),
);
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

Same as the other dispatch assertions: the query params argument is asserted as {}. Consider loosening this to expect.any(Object) / expect.objectContaining({}) to avoid test brittleness and keep consistency with other adapter tests.

Copilot uses AI. Check for mistakes.
Comment on lines +350 to 352
const registeredAuthManager = (mockContext.registerService as any).mock.calls[0][1];
const setRuntimeSpy = vi.spyOn(registeredAuthManager, 'setRuntimeBaseUrl');

Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

Same as above: relying on registerService.mock.calls[0] assumes init() always registers the AuthManager first. Consider selecting the call where the first argument is 'auth' to keep this test resilient if service registration order changes.

Copilot uses AI. Check for mistakes.
Comment on lines +249 to 253
'/meta/flows',
undefined,
{},
expect.objectContaining({ request: expect.anything() }),
);
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

This test asserts the query params argument is exactly {}. For consistency with nextjs.test.ts and to reduce brittleness, prefer expect.any(Object) / expect.objectContaining({}).

Copilot uses AI. Check for mistakes.
Comment on lines +318 to 320
const registeredAuthManager = (mockContext.registerService as any).mock.calls[0][1];
const setRuntimeSpy = vi.spyOn(registeredAuthManager, 'setRuntimeBaseUrl');

Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

Indexing into registerService.mock.calls[0][1] still relies on the ordering of init() registrations (currently auth first, then app.com.objectstack.system). To make the test more robust against future ordering changes, consider locating the call by service name (first arg === 'auth') rather than relying on [0].

Copilot uses AI. Check for mistakes.
Comment on lines +158 to 162
'/meta/objects/account',
undefined,
{},
expect.objectContaining({ request: expect.anything() }),
);
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

The 4th arg to dispatch() is the query params object; asserting a literal {} is brittle and differs from the pattern in packages/adapters/nextjs/src/nextjs.test.ts (uses expect.any(Object)). Consider loosening this assertion to avoid future failures if query parsing adds defaults.

Copilot uses AI. Check for mistakes.
Comment on lines +184 to 188
'/meta/objects',
body,
{},
expect.objectContaining({ request: expect.anything() }),
);
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

Same as above: using a literal {} for the query params arg makes the assertion more fragile than necessary. Prefer expect.any(Object) / expect.objectContaining({}) like other Next.js adapter tests.

Copilot uses AI. Check for mistakes.
Comment on lines +206 to 210
'/meta/objects/account',
body,
{},
expect.objectContaining({ request: expect.anything() }),
);
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

Same concern: the query params argument is asserted as {}. Using expect.any(Object) would keep this test consistent with other adapter tests and less sensitive to internal query parsing changes.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/s tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants