|
1 | 1 | import { defaultTestSuiteConfig, describeWithMongoDB } from "../mongodbHelpers.js"; |
2 | 2 | import { |
3 | | - defaultDriverOptions, |
4 | 3 | getResponseContent, |
5 | 4 | getResponseElements, |
6 | 5 | validateThrowsForInvalidArguments, |
7 | 6 | validateToolMetadata, |
8 | 7 | } from "../../../helpers.js"; |
9 | | -import { defaultTestConfig, setupIntegrationTest } from "../../../helpers.js"; |
| 8 | +import { defaultTestConfig } from "../../../helpers.js"; |
10 | 9 | import { beforeEach, describe, expect, it } from "vitest"; |
11 | 10 |
|
12 | 11 | describeWithMongoDB( |
@@ -141,28 +140,30 @@ describeWithMongoDB("Connect tool", (integration) => { |
141 | 140 | }); |
142 | 141 | }); |
143 | 142 |
|
144 | | -describe("Connect tool when disabled", () => { |
145 | | - const integration = setupIntegrationTest( |
146 | | - () => ({ |
| 143 | +describeWithMongoDB( |
| 144 | + "Connect tool when disabled", |
| 145 | + (integration) => { |
| 146 | + it("is not suggested when querying MongoDB disconnected", async () => { |
| 147 | + const response = await integration.mcpClient().callTool({ |
| 148 | + name: "find", |
| 149 | + arguments: { database: "some-db", collection: "some-collection" }, |
| 150 | + }); |
| 151 | + |
| 152 | + const elements = getResponseElements(response); |
| 153 | + expect(elements).toHaveLength(2); |
| 154 | + expect(elements[0]?.text).toContain( |
| 155 | + "You need to connect to a MongoDB instance before you can access its data." |
| 156 | + ); |
| 157 | + expect(elements[1]?.text).toContain( |
| 158 | + "There are no tools available to connect. Please update the configuration to include a connection string and restart the server." |
| 159 | + ); |
| 160 | + }); |
| 161 | + }, |
| 162 | + { |
| 163 | + ...defaultTestSuiteConfig, |
| 164 | + getUserConfig: () => ({ |
147 | 165 | ...defaultTestConfig, |
148 | 166 | disabledTools: ["connect"], |
149 | 167 | }), |
150 | | - () => defaultDriverOptions |
151 | | - ); |
152 | | - |
153 | | - it("is not suggested when querying MongoDB disconnected", async () => { |
154 | | - const response = await integration.mcpClient().callTool({ |
155 | | - name: "find", |
156 | | - arguments: { database: "some-db", collection: "some-collection" }, |
157 | | - }); |
158 | | - |
159 | | - const elements = getResponseElements(response); |
160 | | - expect(elements).toHaveLength(2); |
161 | | - expect(elements[0]?.text).toContain( |
162 | | - "You need to connect to a MongoDB instance before you can access its data." |
163 | | - ); |
164 | | - expect(elements[1]?.text).toContain( |
165 | | - "There are no tools available to connect. Please update the configuration to include a connection string and restart the server." |
166 | | - ); |
167 | | - }); |
168 | | -}); |
| 168 | + } |
| 169 | +); |
0 commit comments