Construction mode hides pages from Markdown, MCP and search; MCP rejects non-object messages
createContentHelpers exposes isPathVisible (built from getConstructionMode) and passes it to markdownRoute and mcpPOST; createSearchRoute, createMcpRoute and createMarkdownRoute accept it. A null/number/string JSON-RPC message now gets -32600 instead of crashing the route. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9a72ebfaff
commit
7c05a1dba9
@@ -87,4 +87,32 @@ describe('under construction — Site Settings → createPageRoute', () => {
|
||||
await expect(open('pl', ['o-nas'])).rejects.toThrow('REDIRECT /pl?notice=construction')
|
||||
await expect(open('pl', ['nie-ma'])).rejects.toThrow('REDIRECT /pl?notice=construction')
|
||||
})
|
||||
|
||||
test('on: Markdown, MCP and search hide the same pages the page route hides', async () => {
|
||||
const helpers = createContentHelpers({ baseUrl: 'https://acme.pl', config: configPromise, i18n })
|
||||
expect((await helpers.getConstructionMode('pl')).enabled).toBe(true)
|
||||
|
||||
const md = (slug: string[]) => helpers.markdownRoute(new Request('https://acme.pl/md'), { params: Promise.resolve({ locale: 'pl', slug }) })
|
||||
expect((await md(['o-nas'])).status).toBe(404)
|
||||
expect((await md(['brief'])).status).toBe(200)
|
||||
|
||||
const rpc = async (name: string, args: Record<string, unknown>) => {
|
||||
const res = await helpers.mcpPOST(
|
||||
new Request('https://acme.pl/api/mcp', {
|
||||
body: JSON.stringify({ id: 1, jsonrpc: '2.0', method: 'tools/call', params: { arguments: args, name } }),
|
||||
headers: { 'content-type': 'application/json', 'x-real-ip': '198.51.100.4' },
|
||||
method: 'POST',
|
||||
}),
|
||||
)
|
||||
return ((await res.json()) as { result: { content: { text: string }[] } }).result.content[0].text
|
||||
}
|
||||
const list = await rpc('list_pages', { locale: 'pl' })
|
||||
expect(list).toContain('/pl/brief')
|
||||
expect(list).not.toContain('/pl/o-nas')
|
||||
expect(await rpc('get_page', { path: '/pl/o-nas' })).toMatch(/No page found/)
|
||||
expect(await rpc('search_content', { locale: 'pl', query: 'nas' })).not.toContain('/pl/o-nas')
|
||||
|
||||
expect(await helpers.isPathVisible('/pl/o-nas', 'pl')).toBe(false)
|
||||
expect(await helpers.isPathVisible('/pl/brief', 'pl')).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user