Commit f4bc5c26 authored by Tobias Koppers's avatar Tobias Koppers

Skip get_compilation_issues tests in webpack mode

The tool is Turbopack-only; wrapping the suite in the
`IS_TURBOPACK_TEST ? describe : describe.skip` pattern ensures CI
doesn't run it in the webpack dev job where the endpoint state is
unavailable.
Co-Authored-By: 's avatarClaude <noreply@anthropic.com>
parent 3ebfe319
...@@ -2,94 +2,100 @@ import { FileRef, nextTestSetup } from 'e2e-utils' ...@@ -2,94 +2,100 @@ import { FileRef, nextTestSetup } from 'e2e-utils'
import path from 'path' import path from 'path'
import { retry } from 'next-test-utils' import { retry } from 'next-test-utils'
describe('mcp-server get_compilation_issues tool', () => { // get_compilation_issues is Turbopack-only (requires live endpoint state)
const { next, skipped } = nextTestSetup({ ;(process.env.IS_TURBOPACK_TEST ? describe : describe.skip)(
files: new FileRef( 'mcp-server get_compilation_issues tool',
path.join(__dirname, 'fixtures', 'compilation-issues-app') () => {
), const { next, skipped } = nextTestSetup({
skipDeployment: true, files: new FileRef(
}) path.join(__dirname, 'fixtures', 'compilation-issues-app')
),
if (skipped) { skipDeployment: true,
return
}
async function callGetCompilationIssues(): 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: `test-${Date.now()}`,
method: 'tools/call',
params: { name: 'get_compilation_issues', arguments: {} },
}),
}) })
const text = await response.text() if (skipped) {
const match = text.match(/data: ({.*})/s) return
const result = JSON.parse(match![1]) }
return result.result?.content?.[0]?.text
}
it('should return empty issues for a page with no errors', async () => { async function callGetCompilationIssues(): Promise<string> {
await next.browser('/') 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: `test-${Date.now()}`,
method: 'tools/call',
params: { name: 'get_compilation_issues', arguments: {} },
}),
})
let response: any = null const text = await response.text()
await retry(async () => { const match = text.match(/data: ({.*})/s)
const responseText = await callGetCompilationIssues() const result = JSON.parse(match![1])
response = JSON.parse(responseText) return result.result?.content?.[0]?.text
// The '/page' route should be present once the page has been compiled }
expect(response.routes).toHaveProperty('/page')
})
expect(response.routes['/page'].issues).toEqual([]) it('should return empty issues for a page with no errors', async () => {
}) await next.browser('/')
it('should return compilation issues for a page with a syntax error', async () => { let response: any = null
await next.browser('/broken') await retry(async () => {
const responseText = await callGetCompilationIssues()
response = JSON.parse(responseText)
// The '/page' route should be present once the page has been compiled
expect(response.routes).toHaveProperty('/page')
})
let response: any = null expect(response.routes['/page'].issues).toEqual([])
await retry(async () => {
const responseText = await callGetCompilationIssues()
response = JSON.parse(responseText)
expect(response.routes['/broken/page']?.issues?.length).toBeGreaterThan(0)
}) })
const issue = response.routes['/broken/page'].issues[0] it('should return compilation issues for a page with a syntax error', async () => {
expect(issue).toMatchObject({ await next.browser('/broken')
severity: 'error',
filePath: expect.stringContaining('broken/page.tsx'),
})
})
it('should reflect fixed issues after the file is patched', async () => { let response: any = null
await next.browser('/broken') await retry(async () => {
const responseText = await callGetCompilationIssues()
response = JSON.parse(responseText)
expect(response.routes['/broken/page']?.issues?.length).toBeGreaterThan(
0
)
})
// Confirm there are issues before patching const issue = response.routes['/broken/page'].issues[0]
await retry(async () => { expect(issue).toMatchObject({
const resp = JSON.parse(await callGetCompilationIssues()) severity: 'error',
expect(resp.routes['/broken/page']?.issues?.length).toBeGreaterThan(0) filePath: expect.stringContaining('broken/page.tsx'),
})
}) })
// Patch the broken page to a valid implementation it('should reflect fixed issues after the file is patched', async () => {
await next.patchFile( await next.browser('/broken')
'app/broken/page.tsx',
`export default function BrokenPage() { // Confirm there are issues before patching
await retry(async () => {
const resp = JSON.parse(await callGetCompilationIssues())
expect(resp.routes['/broken/page']?.issues?.length).toBeGreaterThan(0)
})
// Patch the broken page to a valid implementation
await next.patchFile(
'app/broken/page.tsx',
`export default function BrokenPage() {
return <div>Fixed</div> return <div>Fixed</div>
}` }`
) )
// After the fix, the issues for '/broken/page' should be empty // After the fix, the issues for '/broken/page' should be empty
await retry(async () => { await retry(async () => {
const resp = JSON.parse(await callGetCompilationIssues()) const resp = JSON.parse(await callGetCompilationIssues())
expect( expect(
resp.routes['/broken/page'] == null || resp.routes['/broken/page'] == null ||
resp.routes['/broken/page'].issues.length === 0 resp.routes['/broken/page'].issues.length === 0
).toBe(true) ).toBe(true)
})
}) })
}) }
}) )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment