Skip to content

Commit 1d68065

Browse files
committed
Test MCP server deployed
1 parent 3186b50 commit 1d68065

File tree

5 files changed

+47
-9
lines changed

5 files changed

+47
-9
lines changed

.github/workflows/deploy-preview.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ jobs:
182182
SITE_BASE_URL: ${{ needs.deploy-v2-cloudflare.outputs.deployment-url }}/url/
183183
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }}
184184
ARGOS_BUILD_NAME: 'customers-v2'
185-
pagespeed-testing-v2:
185+
browserless-testing-v2:
186186
runs-on: ubuntu-latest
187-
name: PageSpeed Testing v1
187+
name: Browserless Testing
188188
needs: deploy-v2-vercel
189189
steps:
190190
- name: Checkout
@@ -195,8 +195,8 @@ jobs:
195195
run: bun install --frozen-lockfile
196196
env:
197197
PUPPETEER_SKIP_DOWNLOAD: 1
198-
- name: Run pagespeed tests
199-
run: bun ./packages/gitbook/tests/pagespeed-testing.ts
198+
- name: Run integration tests
199+
run: cd ./packages/gitbook && bun e2e-browserless
200200
env:
201201
BASE_URL: ${{needs.deploy-v2-vercel.outputs.deployment-url}}
202202
PAGESPEED_API_KEY: ${{ secrets.PAGESPEED_API_KEY }}

packages/gitbook/e2e/mcp.spec.ts

Whitespace-only changes.

packages/gitbook/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
"e2e": "playwright test e2e/internal.spec.ts e2e/pdf.spec.ts --project=chromium",
117117
"e2e-customers": "playwright test e2e/customers.spec.ts --project=chromium",
118118
"unit": "bun test {src,packages} --preload ./tests/preload-bun.ts",
119+
"e2e-browserless": "bun test ./tests/",
119120
"typecheck": "tsc --noEmit"
120121
},
121122
"browserslist": [

packages/gitbook/tests/mcp.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { expect, it } from 'bun:test';
2+
import { Client } from '@modelcontextprotocol/sdk/client';
3+
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
4+
import { getContentTestURL } from './utils';
5+
6+
it('should expose a MCP server', async () => {
7+
const client = new Client({
8+
name: 'test',
9+
version: '1.0.0',
10+
});
11+
12+
await client.connect(
13+
new StreamableHTTPClientTransport(
14+
new URL(getContentTestURL('https://gitbook.com/docs/~gitbook/mcp'))
15+
)
16+
);
17+
18+
const tools = await client.listTools();
19+
expect(tools.tools[0]?.name).toBe('searchDocumentation');
20+
21+
const response = await client.callTool({
22+
name: 'searchDocumentation',
23+
arguments: {
24+
query: 'git',
25+
},
26+
});
27+
28+
// @ts-expect-error - response.content is of type unknown
29+
expect(response.content[0]?.text).toContain('Title:');
30+
});

packages/gitbook/tests/pagespeed-testing.ts renamed to packages/gitbook/tests/pagespeed.test.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { it } from 'bun:test';
12
import psi from 'psi';
23

34
import { getContentTestURL } from './utils';
@@ -25,10 +26,16 @@ const tests: Array<Test> = [
2526
];
2627

2728
for (const test of tests) {
28-
const url = getContentTestURL(test.url);
29-
await psi.output(url, {
30-
strategy: test.strategy,
31-
threshold: test.threshold,
32-
key: process.env.PAGESPEED_API_KEY,
29+
if (!process.env.PAGESPEED_API_KEY && !process.env.CI) {
30+
continue;
31+
}
32+
33+
it(`${test.url} - ${test.strategy}`, async () => {
34+
const url = getContentTestURL(test.url);
35+
await psi.output(url, {
36+
strategy: test.strategy,
37+
threshold: test.threshold,
38+
key: process.env.PAGESPEED_API_KEY,
39+
});
3340
});
3441
}

0 commit comments

Comments
 (0)