feat: add first e2e test for REST => MCP origin tool call

pull/715/head
Travis Fischer 2025-06-06 04:32:06 +07:00
rodzic e13308f801
commit 2b131ee901
4 zmienionych plików z 46 dodań i 19 usunięć

Wyświetl plik

@ -36,6 +36,15 @@ et est aut quod aut provident voluptas autem voluptas",
} }
`; `;
exports[`Basic MCP origin tool call success > 5.0: POST @dev/test-basic-mcp/add 1`] = `
[
{
"text": "42",
"type": "text",
},
]
`;
exports[`Basic OpenAPI getPost success > 0.0: POST @dev/test-basic-openapi/getPost 1`] = ` exports[`Basic OpenAPI getPost success > 0.0: POST @dev/test-basic-openapi/getPost 1`] = `
{ {
"body": "quia et suscipit "body": "quia et suscipit

Wyświetl plik

@ -32,6 +32,7 @@ for (const [i, fixtureSuite] of fixtureSuites.entries()) {
} = fixture.response ?? {} } = fixture.response ?? {}
const { snapshot = status >= 200 && status < 300 } = const { snapshot = status >= 200 && status < 300 } =
fixture.response ?? {} fixture.response ?? {}
const debugFixture = !!(fixture.debug ?? fixtureSuite.debug)
let testFn = fixture.only ? test.only : test let testFn = fixture.only ? test.only : test
if (fixtureSuite.sequential) { if (fixtureSuite.sequential) {
@ -94,10 +95,12 @@ for (const [i, fixtureSuite] of fixtureSuites.entries()) {
} }
} }
// console.log(`${i}.${j}: ${method} ${fixture.path} => ${status}`, { if (debugFixture) {
// body, console.log(`${i}.${j}: ${method} ${fixture.path} => ${status}`, {
// headers: Object.fromEntries(res.headers.entries()) body,
// }) headers: Object.fromEntries(res.headers.entries())
})
}
} }
) )
} }

Wyświetl plik

@ -7,6 +7,9 @@ export type E2ETestFixture = {
/** @default false */ /** @default false */
only?: boolean only?: boolean
/** @default false */
debug?: boolean
request?: { request?: {
/** @default 'GET' */ /** @default 'GET' */
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' method?: 'GET' | 'POST' | 'PUT' | 'DELETE'
@ -41,6 +44,9 @@ export type E2ETestFixtureSuite = {
/** @default false */ /** @default false */
compareResponseBodies?: boolean compareResponseBodies?: boolean
/** @default false */
debug?: boolean
} }
export const fixtureSuites: E2ETestFixtureSuite[] = [ export const fixtureSuites: E2ETestFixtureSuite[] = [
@ -342,20 +348,26 @@ export const fixtureSuites: E2ETestFixtureSuite[] = [
} }
} }
] ]
},
{
title: 'Basic MCP origin tool call success',
compareResponseBodies: true,
only: true,
debug: true,
fixtures: [
{
path: '@dev/test-basic-mcp/add',
request: {
method: 'POST',
json: {
a: 22,
b: 20
}
},
response: {
body: [{ type: 'text', text: '42' }]
}
}
]
} }
// {
// title: 'Basic MCP origin tool call success',
// compareResponseBodies: true,
// fixtures: [
// {
// path: '@dev/test-basic-openapi@fc856666/get_post',
// request: {
// method: 'POST',
// json: {
// postId: 13
// }
// }
// },
// ]
// }
] ]

Wyświetl plik

@ -31,6 +31,9 @@
- add username / team name blacklist - add username / team name blacklist
- admin, internal, mcp, sse, etc - admin, internal, mcp, sse, etc
- API gateway - API gateway
- `cfValidateJsonSchemaObject` relax object constraint for output validation
- tool call outputs might not be objects
- keep the object validation for tool input params
- public MCP interface - public MCP interface
- MCP origin server support - MCP origin server support
- add support for custom headers on responses - add support for custom headers on responses