mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
These tests won't ever be run in a deployed environment, so this removes `skipDeployment` so it's easier to grok which tests are intentionally disabled because they don't work when deployed.
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import path from 'path'
|
|
import { nextTestSetup } from 'e2e-utils'
|
|
import { retry } from 'next-test-utils'
|
|
|
|
describe('get-logs MCP tool', () => {
|
|
const { next, skipped } = nextTestSetup({
|
|
files: path.join(__dirname, 'fixtures', 'log-file-app'),
|
|
})
|
|
|
|
if (skipped) {
|
|
return
|
|
}
|
|
|
|
async function callGetLogs(id: string): Promise<string> {
|
|
const response = await fetch(`${next.url}/_next/mcp`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
Accept: 'application/json, text/event-stream',
|
|
},
|
|
body: JSON.stringify({
|
|
jsonrpc: '2.0',
|
|
id,
|
|
method: 'tools/call',
|
|
params: { name: 'get_logs', arguments: {} },
|
|
}),
|
|
})
|
|
|
|
const text = await response.text()
|
|
const match = text.match(/data: ({.*})/s)
|
|
const result = JSON.parse(match![1])
|
|
return result.result?.content?.[0]?.text
|
|
}
|
|
|
|
it('should return log file path via MCP get_logs tool', async () => {
|
|
// Generate some logs by visiting pages that create log entries
|
|
await next.browser('/server')
|
|
await next.browser('/client')
|
|
await next.browser('/pages-router-page')
|
|
|
|
await retry(async () => {
|
|
const sessionId = 'test-mcp-logs-' + Date.now()
|
|
const responseText = await callGetLogs(sessionId)
|
|
const response = JSON.parse(responseText)
|
|
|
|
expect(response).toMatchObject({
|
|
logFilePath: expect.stringContaining('logs/next-development.log'),
|
|
})
|
|
})
|
|
})
|
|
})
|