Skip to content

Commit 3e25000

Browse files
committed
test: align client test protocol names and assertions with downstream enum rename
1 parent 1faec39 commit 3e25000

3 files changed

Lines changed: 11 additions & 12 deletions

File tree

packages/toolbox-core/src/toolbox_core/mcp/v20260618/mcp.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ export class McpHttpTransportV20260618 extends McpHttpTransportBase {
5555
const serverSupported = ((
5656
(errVal as Record<string, unknown>).data as Record<string, unknown>
5757
)?.supported || []) as string[];
58-
const clientSupported = this.supportedProtocols || getSupportedMcpVersions();
58+
const clientSupported =
59+
this.supportedProtocols || getSupportedMcpVersions();
5960
const mutuallySupported = clientSupported.filter(v =>
6061
serverSupported.includes(v),
6162
);
@@ -88,12 +89,15 @@ export class McpHttpTransportV20260618 extends McpHttpTransportBase {
8889

8990
if (isLegacyError) {
9091
// Cascading Fallback
91-
const clientSupported = this.supportedProtocols || getSupportedMcpVersions();
92+
const clientSupported =
93+
this.supportedProtocols || getSupportedMcpVersions();
9294
const currentIdx = clientSupported.indexOf(
9395
this._protocolVersion as Protocol,
9496
);
9597
if (currentIdx !== -1 && currentIdx + 1 < clientSupported.length) {
96-
throw new ProtocolNegotiationError(clientSupported[currentIdx + 1] as Protocol);
98+
throw new ProtocolNegotiationError(
99+
clientSupported[currentIdx + 1] as Protocol,
100+
);
97101
} else {
98102
throw new Error(
99103
"Server threw 'invalid protocol version' but no fallback versions remain in the user's supported protocols array.",
@@ -184,7 +188,6 @@ export class McpHttpTransportV20260618 extends McpHttpTransportBase {
184188
const err = errResult.data.error;
185189
message = `MCP request failed with code ${err.code}: ${err.message}`;
186190
code = String(err.code);
187-
188191
}
189192

190193
throw new AxiosError(

packages/toolbox-core/test/mcp/test.v20260618.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,6 @@ describe('McpHttpTransportV20260618', () => {
563563
await expect(transport.toolsList()).rejects.toThrow(
564564
ProtocolNegotiationError,
565565
);
566-
>>>>>>> df7ce2f (test: resolve unit test and lint compilation issues across downstream protocol branches)
567566
errorSpy.mockRestore();
568567
});
569568

packages/toolbox-core/test/test.client.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {ProtocolNegotiationError} from '../src/toolbox_core/errorUtils.js';
3232
class MockTransport implements ITransport {
3333
readonly baseUrl: string;
3434
protocolVersion = Protocol.MCP;
35+
supportedProtocols?: Protocol[];
3536
toolGet: jest.MockedFunction<ITransport['toolGet']>;
3637
toolsList: jest.MockedFunction<ITransport['toolsList']>;
3738
toolInvoke: jest.MockedFunction<ITransport['toolInvoke']>;
@@ -249,11 +250,7 @@ describe('ToolboxClient', () => {
249250
'2025-11-25',
250251
'DRAFT-2026-v1',
251252
]);
252-
// The array is sorted newer to older by getSupportedMcpVersions order
253-
// so DRAFT-2026-v1 is first.
254-
const mockInstance = (McpHttpTransportV20260618 as jest.Mock).mock
255-
.instances[0] as unknown as Record<string, unknown>;
256-
expect(mockInstance.supportedProtocols).toEqual([
253+
expect(mockTransport.supportedProtocols).toEqual([
257254
'DRAFT-2026-v1',
258255
'2025-11-25',
259256
]);
@@ -677,7 +674,7 @@ describe('ToolboxClient', () => {
677674
testBaseUrl,
678675
undefined,
679676
undefined,
680-
Protocol.MCP_DRAFT_2026_v1,
677+
Protocol.MCP_DRAFT,
681678
);
682679

683680
const tool = await client.loadTool('testTool');
@@ -720,7 +717,7 @@ describe('ToolboxClient', () => {
720717
testBaseUrl,
721718
undefined,
722719
undefined,
723-
Protocol.MCP_DRAFT_2026_v1,
720+
Protocol.MCP_DRAFT,
724721
);
725722

726723
const tools = await client.loadToolset('set');

0 commit comments

Comments
 (0)