-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Description
Summary
The MCP integration tests in src/toolsets/tests/stackone.mcp-fetch.spec.ts currently use vi.fn() to mock the RpcClient.actions.rpcAction method directly. This approach should be refactored to use MSW (Mock Service Worker) for consistency with other tests in the codebase.
Current Implementation
const rpcClient = {
actions: {
rpcAction: vi.fn(async () => ({ actionsRpcResponse: { data: null } })),
},
} as unknown as RpcClient;Issues with Current Approach
- Type assertion (
as unknown as RpcClient) - This bypasses TypeScript's type checking - Inconsistent with other tests - Other tests use MSW handlers for HTTP mocking
- Response structure mismatch - The mock returns
{ actionsRpcResponse: { data: null } }which doesn't match the actual server response structure{ data: null, next?: string } - Test is excluded from vitest - The file is in
excludearray invitest.config.ts, so MSW setup doesn't apply
Proposed Changes
- Remove the test file from vitest's
excludearray - Replace
vi.fn()mocks with MSW handlers inmocks/handlers.ts - Update mock responses to match the correct
RpcActionResponsetype:// Correct response structure { data: Record<string, unknown> | Record<string, unknown>[] | null, next?: string }
- Remove the
as unknown as RpcClienttype assertions
Related Context
This issue was identified during the RPC client type improvements in #152, where the response type was corrected to match the server's ActionsRpcResponseApiModel.
Acceptance Criteria
- MCP tests use MSW for HTTP mocking
- No
vi.fn()mocks forRpcClientmethods - No type assertions for
RpcClient - Mock responses match actual server response structure
- All tests pass
Metadata
Metadata
Assignees
Labels
No labels