mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
parent
3975c8d8a9
commit
362359cc3c
2 changed files with 30 additions and 5 deletions
14
src/__mocks__/@modelcontextprotocol/sdk/client/sse.js
Normal file
14
src/__mocks__/@modelcontextprotocol/sdk/client/sse.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
class SSEClientTransport {
|
||||
constructor(url, options = {}) {
|
||||
this.url = url
|
||||
this.options = options
|
||||
this.onerror = null
|
||||
this.connect = jest.fn().mockResolvedValue()
|
||||
this.close = jest.fn().mockResolvedValue()
|
||||
this.start = jest.fn().mockResolvedValue()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
SSEClientTransport,
|
||||
}
|
||||
|
|
@ -71,6 +71,7 @@ describe("McpHub", () => {
|
|||
JSON.stringify({
|
||||
mcpServers: {
|
||||
"test-server": {
|
||||
type: "stdio",
|
||||
command: "node",
|
||||
args: ["test.js"],
|
||||
alwaysAllow: ["allowed-tool"],
|
||||
|
|
@ -87,6 +88,7 @@ describe("McpHub", () => {
|
|||
const mockConfig = {
|
||||
mcpServers: {
|
||||
"test-server": {
|
||||
type: "stdio",
|
||||
command: "node",
|
||||
args: ["test.js"],
|
||||
alwaysAllow: [],
|
||||
|
|
@ -109,6 +111,7 @@ describe("McpHub", () => {
|
|||
const mockConfig = {
|
||||
mcpServers: {
|
||||
"test-server": {
|
||||
type: "stdio",
|
||||
command: "node",
|
||||
args: ["test.js"],
|
||||
alwaysAllow: ["existing-tool"],
|
||||
|
|
@ -131,6 +134,7 @@ describe("McpHub", () => {
|
|||
const mockConfig = {
|
||||
mcpServers: {
|
||||
"test-server": {
|
||||
type: "stdio",
|
||||
command: "node",
|
||||
args: ["test.js"],
|
||||
},
|
||||
|
|
@ -155,6 +159,7 @@ describe("McpHub", () => {
|
|||
const mockConfig = {
|
||||
mcpServers: {
|
||||
"test-server": {
|
||||
type: "stdio",
|
||||
command: "node",
|
||||
args: ["test.js"],
|
||||
disabled: false,
|
||||
|
|
@ -294,6 +299,7 @@ describe("McpHub", () => {
|
|||
it("should validate timeout values", () => {
|
||||
// Test valid timeout values
|
||||
const validConfig = {
|
||||
type: "stdio",
|
||||
command: "test",
|
||||
timeout: 60,
|
||||
}
|
||||
|
|
@ -301,9 +307,9 @@ describe("McpHub", () => {
|
|||
|
||||
// Test invalid timeout values
|
||||
const invalidConfigs = [
|
||||
{ command: "test", timeout: 0 }, // Too low
|
||||
{ command: "test", timeout: 3601 }, // Too high
|
||||
{ command: "test", timeout: -1 }, // Negative
|
||||
{ type: "stdio", command: "test", timeout: 0 }, // Too low
|
||||
{ type: "stdio", command: "test", timeout: 3601 }, // Too high
|
||||
{ type: "stdio", command: "test", timeout: -1 }, // Negative
|
||||
]
|
||||
|
||||
invalidConfigs.forEach((config) => {
|
||||
|
|
@ -315,7 +321,7 @@ describe("McpHub", () => {
|
|||
const mockConnection: McpConnection = {
|
||||
server: {
|
||||
name: "test-server",
|
||||
config: JSON.stringify({ command: "test" }), // No timeout specified
|
||||
config: JSON.stringify({ type: "stdio", command: "test" }), // No timeout specified
|
||||
status: "connected",
|
||||
},
|
||||
client: {
|
||||
|
|
@ -338,7 +344,7 @@ describe("McpHub", () => {
|
|||
const mockConnection: McpConnection = {
|
||||
server: {
|
||||
name: "test-server",
|
||||
config: JSON.stringify({ command: "test", timeout: 120 }), // 2 minutes
|
||||
config: JSON.stringify({ type: "stdio", command: "test", timeout: 120 }), // 2 minutes
|
||||
status: "connected",
|
||||
},
|
||||
client: {
|
||||
|
|
@ -363,6 +369,7 @@ describe("McpHub", () => {
|
|||
const mockConfig = {
|
||||
mcpServers: {
|
||||
"test-server": {
|
||||
type: "stdio",
|
||||
command: "node",
|
||||
args: ["test.js"],
|
||||
timeout: 60,
|
||||
|
|
@ -385,6 +392,7 @@ describe("McpHub", () => {
|
|||
const mockConfig = {
|
||||
mcpServers: {
|
||||
"test-server": {
|
||||
type: "stdio",
|
||||
command: "node",
|
||||
args: ["test.js"],
|
||||
timeout: 60,
|
||||
|
|
@ -406,6 +414,7 @@ describe("McpHub", () => {
|
|||
server: {
|
||||
name: "test-server",
|
||||
config: JSON.stringify({
|
||||
type: "stdio",
|
||||
command: "node",
|
||||
args: ["test.js"],
|
||||
timeout: 3601, // Invalid timeout
|
||||
|
|
@ -435,6 +444,7 @@ describe("McpHub", () => {
|
|||
const mockConfig = {
|
||||
mcpServers: {
|
||||
"test-server": {
|
||||
type: "stdio",
|
||||
command: "node",
|
||||
args: ["test.js"],
|
||||
timeout: 60,
|
||||
|
|
@ -458,6 +468,7 @@ describe("McpHub", () => {
|
|||
const mockConfig = {
|
||||
mcpServers: {
|
||||
"test-server": {
|
||||
type: "stdio",
|
||||
command: "node",
|
||||
args: ["test.js"],
|
||||
timeout: 60,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue