-
Notifications
You must be signed in to change notification settings - Fork 357
Add e2e tests #354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
olaservo
wants to merge
29
commits into
modelcontextprotocol:main
Choose a base branch
from
olaservo:add-integration-tests-take-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add e2e tests #354
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
1424f63
feat: QoL improvements for OAuth Callback
max-stytch 03e89f7
Add minimal test and provider to start
olaservo e1911e4
Fix merger issues
olaservo c8130ea
Refactor tests and test utils to use proxy from sdk
olaservo 3045b64
Leave myself notes on patterns
olaservo 166a706
Fix unused vars
olaservo 6a52938
Fix matcher not found
olaservo ae5709b
Remove unused import
olaservo 15c651d
Update gitignore to ignore testing output files
olaservo 732c486
Set up packages and configs
olaservo ae81492
Add ID to connect button
olaservo e4f8c0a
Remove other test files
olaservo c0cb1f4
Add logging for tests
olaservo 1210f0f
Placeholder test and add clean script
olaservo b65d4b7
Merge branch 'main' into add-integration-tests-take-2
olaservo ccfd631
Update package-lock after install
olaservo 0562df8
Merge branch 'main' into add-integration-tests-take-2
olaservo 3adb5d1
Delete doc
olaservo 3049942
Revert jest config change
olaservo ad7fa0e
Delete test utils
olaservo 37db7a7
Add a passing sse test
olaservo ad629fe
Delete package-lock.json on clean
olaservo c3689c4
Add everything as dev dependency and update test scripts to start ser…
olaservo 4cea627
Add comment
olaservo f55d5ef
Use separate projects for stdio and sse
olaservo b5fd3ad
Add check for initialize response info in history pane
olaservo d1c69c2
Add check for initialize response info in history pane for sse and re…
olaservo 08b9412
Add some placeholder oauth and a few lines from previous attempt
olaservo 8f0750a
Remove root scripts for now
olaservo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,7 @@ dist-ssr | |
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
# Testing output | ||
playwright-report | ||
test-results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('Connect MCP Server Using SSE In Inspector UI', () => { | ||
|
||
test('should connect to test server using SSE and verify echo tool', async ({ page }) => { | ||
// Load the inspector UI | ||
await page.goto('/'); | ||
|
||
// Set server URL and transport type in localStorage | ||
await page.evaluate(() => { | ||
localStorage.setItem('lastSseUrl', 'http://localhost:3001/sse'); | ||
localStorage.setItem('lastTransportType', 'sse'); | ||
}); | ||
await page.reload(); | ||
|
||
// Wait for and click connect button | ||
const connectButton = await page.waitForSelector('[data-testid="connect-button"]', { state: 'visible' }); | ||
await connectButton.click(); | ||
|
||
// Wait for connection status to show connected and verify | ||
const connectedText = page.getByText('Connected'); | ||
await expect(connectedText).toBeVisible({ timeout: 10000 }); | ||
|
||
// Find and expand the initialize entry in History | ||
const initializeEntry = page.getByText('1. initialize'); | ||
await expect(initializeEntry).toBeVisible(); | ||
await initializeEntry.click(); | ||
|
||
// Verify server info content in initialize response from History pane | ||
const jsonView = page.getByTestId('history-entry-0-response') | ||
.locator('.font-mono'); | ||
await expect(jsonView).toBeVisible(); | ||
await expect(jsonView).toContainText('capabilities'); | ||
await expect(jsonView).toContainText('serverInfo'); | ||
await expect(jsonView).toContainText('example-servers/everything'); | ||
await expect(jsonView).toContainText('version'); | ||
|
||
// Navigate to Tools tab and wait for it to be active | ||
const toolsTab = page.getByRole('tab', { name: 'Tools' }); | ||
await toolsTab.click(); | ||
await expect(toolsTab).toHaveAttribute('aria-selected', 'true'); | ||
|
||
// Click the List Tools button to load available tools | ||
const listToolsButton = page.getByRole('button', { name: 'List Tools' }); | ||
await expect(listToolsButton).toBeVisible(); | ||
await listToolsButton.click(); | ||
|
||
// Wait for tools list to be loaded and verify echo tool exists | ||
const echoTool = page.getByText('echo', { exact: true }); | ||
await expect(echoTool).toBeVisible({ timeout: 5000 }); | ||
await echoTool.click(); | ||
|
||
// Wait for message input to be available | ||
const messageInput = page.getByLabel('message'); | ||
await expect(messageInput).toBeVisible(); | ||
await messageInput.fill('Hello MCP!'); | ||
|
||
// Call the tool and wait for response | ||
const callButton = page.getByRole('button', { name: 'Run Tool' }); | ||
await expect(callButton).toBeEnabled(); | ||
await callButton.click(); | ||
|
||
// Verify the response with increased timeout | ||
await expect(page.getByText('Echo: Hello MCP!')).toBeVisible({ timeout: 10000 }); | ||
}); | ||
|
||
test('completes OAuth authentication flow', async ({ page }) => { | ||
/* TODO: Add auth wrapper and reference for tests, then complete the following: | ||
* This test will verify the e2e OAuth authentication flow: | ||
* - Verify 401 Unauthorized triggers OAuth flow | ||
* - Check OAuth metadata endpoint access (no CORS errors) | ||
* - Verify redirect sequence | ||
* | ||
* Post-Auth Verification: | ||
* - Verify successful connection after auth | ||
* - Check server capabilities and tools access | ||
*/ | ||
|
||
// Load the inspector UI | ||
await page.goto('/'); | ||
|
||
// Set server URL and transport type in localStorage | ||
await page.evaluate(() => { | ||
localStorage.setItem('lastSseUrl', 'http://localhost:3001/sse'); | ||
localStorage.setItem('lastTransportType', 'sse'); | ||
}); | ||
await page.reload(); | ||
|
||
// Collect all console messages | ||
const consoleMessages: string[] = []; | ||
page.on('console', msg => { | ||
consoleMessages.push(msg.text()); | ||
}); | ||
|
||
// Wait for and click connect button | ||
const connectButton = await page.waitForSelector('[data-testid="connect-button"]', { state: 'visible' }); | ||
await connectButton.click(); | ||
|
||
// Original assertions from previous implementation attempt for reference: | ||
// Wait for login page redirect to consent UI | ||
// await page.waitForURL(/localhost:3001\/consent/, { timeout: 35000 }); // Increased to account for 30s delay | ||
|
||
// Verify console messages appeared in correct order | ||
expect(consoleMessages).toContainEqual(expect.stringContaining('401 (Unauthorized)')); | ||
// expect(consoleMessages).toContainEqual(expect.stringContaining('Failed to connect to MCP Server via the MCP Inspector Proxy')); | ||
// expect(consoleMessages).toContainEqual(expect.stringContaining('[Auth Flow] Got 401, starting OAuth flow')); | ||
// expect(consoleMessages).toContainEqual(expect.stringContaining('[Auth Flow] Saved server URL:')); | ||
|
||
// Verify OAuth metadata endpoint was accessed successfully (no CORS error) | ||
expect(consoleMessages).not.toContainEqual(expect.stringContaining('blocked by CORS policy')); | ||
|
||
// Verify redirect sequence | ||
// expect(consoleMessages).toContainEqual(expect.stringContaining('[Auth Flow] Redirecting to:')); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('Connect MCP Server Using stdio In Inspector UI', () => { | ||
|
||
test('should connect to test server using stdio and verify echo tool', async ({ page }) => { | ||
// Load the inspector UI | ||
await page.goto('/'); | ||
|
||
// Set transport type in localStorage (stdio is default, no URL needed) | ||
await page.evaluate(() => { | ||
localStorage.setItem('lastTransportType', 'stdio'); | ||
}); | ||
await page.reload(); | ||
|
||
// Wait for and click connect button | ||
const connectButton = await page.waitForSelector('[data-testid="connect-button"]', { state: 'visible' }); | ||
await connectButton.click(); | ||
|
||
// Wait for connection status to show connected and verify | ||
const connectedText = page.getByText('Connected'); | ||
await expect(connectedText).toBeVisible({ timeout: 10000 }); | ||
|
||
// Find and expand the initialize entry in History | ||
const initializeEntry = page.getByText('1. initialize'); | ||
await expect(initializeEntry).toBeVisible(); | ||
await initializeEntry.click(); | ||
|
||
// Verify server info content in initialize response from History pane | ||
const jsonView = page.getByTestId('history-entry-0-response') | ||
.locator('.font-mono'); | ||
await expect(jsonView).toBeVisible(); | ||
await expect(jsonView).toContainText('capabilities'); | ||
await expect(jsonView).toContainText('serverInfo'); | ||
await expect(jsonView).toContainText('example-servers/everything'); | ||
await expect(jsonView).toContainText('version'); | ||
|
||
// Navigate to Tools tab and wait for it to be active | ||
const toolsTab = page.getByRole('tab', { name: 'Tools' }); | ||
await toolsTab.click(); | ||
await expect(toolsTab).toHaveAttribute('aria-selected', 'true'); | ||
|
||
// Click the List Tools button to load available tools | ||
const listToolsButton = page.getByRole('button', { name: 'List Tools' }); | ||
await expect(listToolsButton).toBeVisible(); | ||
await listToolsButton.click(); | ||
|
||
// Wait for tools list to be loaded and verify echo tool exists | ||
const echoTool = page.getByText('echo', { exact: true }); | ||
await expect(echoTool).toBeVisible({ timeout: 5000 }); | ||
await echoTool.click(); | ||
|
||
// Wait for message input to be available | ||
const messageInput = page.getByLabel('message'); | ||
await expect(messageInput).toBeVisible(); | ||
await messageInput.fill('Hello MCP!'); | ||
|
||
// Call the tool and wait for response | ||
const callButton = page.getByRole('button', { name: 'Run Tool' }); | ||
await expect(callButton).toBeEnabled(); | ||
await callButton.click(); | ||
|
||
// Verify the response with increased timeout | ||
await expect(page.getByText('Echo: Hello MCP!')).toBeVisible({ timeout: 10000 }); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"rootDir": ".", | ||
"target": "ES2022", | ||
"module": "Node16", | ||
"moduleResolution": "Node16" | ||
}, | ||
"include": [ | ||
"./**/*.ts" | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
export default defineConfig({ | ||
testDir: './e2e', | ||
timeout: 60 * 1000, | ||
expect: { | ||
timeout: 5000 | ||
}, | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: 1, | ||
reporter: 'list', | ||
use: { | ||
baseURL: process.env.APP_URL || 'http://localhost:6274', | ||
trace: 'on-first-retry', | ||
}, | ||
projects: [ | ||
{ | ||
name: 'sse', | ||
testDir: './e2e/sse', | ||
testMatch: '**/*.spec.ts', | ||
use: { | ||
...devices['Desktop Chrome'], | ||
}, | ||
}, | ||
{ | ||
name: 'stdio', | ||
testDir: './e2e/stdio', | ||
testMatch: '**/*.spec.ts', | ||
use: { | ||
...devices['Desktop Chrome'], | ||
}, | ||
}, | ||
], | ||
webServer: { | ||
command: 'npm run dev', | ||
url: 'http://localhost:6274', | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "./tsconfig.app.json", | ||
"compilerOptions": { | ||
"moduleResolution": "node", | ||
"allowJs": true, | ||
"types": ["node", "@playwright/test"], | ||
"module": "ESNext", | ||
"target": "ESNext" | ||
}, | ||
"include": ["e2e/**/*"] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these dependency updates are probably from a previous attempt on same branch - main ones to pay attention to are importing server-everything and adding Playwright to dev dependences.