Opt-outs for the secure defaults; isPathVisibleIn in construction/logic

- setUnknownIpFactor (0 = old free pass), UNKNOWN_IP_FACTOR exported
- createContentHelpers({ settingsDepth }) and markdown/mcp isPathVisible overrides
- <RenderRichText safeLinks={false}>
- resolveRedirect({ draft: true }) for preview
- isPathVisibleIn(mode, path), pathOf, PathVisibility exported; page route uses it

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-22 17:35:08 +02:00
co-authored by Claude Opus 5.5
parent 4585e0fc69
commit 0fd57c1d6a
13 changed files with 144 additions and 24 deletions
+31 -1
View File
@@ -7,7 +7,7 @@ import path from 'node:path'
import { buildConfig, getPayload } from 'payload'
import { afterAll, beforeAll, describe, expect, test, vi } from 'vitest'
import { constructionNoticeHref, isPathAllowed, normalizePath } from '../src/modules/construction/logic.js'
import { constructionNoticeHref, isPathAllowed, isPathVisibleIn, normalizePath } from '../src/modules/construction/logic.js'
import { createContentHelpers } from '../src/modules/frontend/createContentHelpers.js'
import { createPageRoute } from '../src/modules/frontend/pageRoute.js'
import { ipalKit } from '../src/plugin.js'
@@ -22,6 +22,12 @@ describe('under construction — path logic', () => {
expect(isPathAllowed('/pl/o-nas', ['/pl', '/pl/brief'])).toBe(false)
expect(constructionNoticeHref('/pl')).toBe('/pl?notice=construction')
})
test('isPathVisibleIn: off → everything; on → allowed paths only', () => {
expect(isPathVisibleIn({ allowedPaths: [], enabled: false }, '/pl/o-nas')).toBe(true)
expect(isPathVisibleIn({ allowedPaths: ['/pl', '/pl/brief'], enabled: true }, '/pl/brief/')).toBe(true)
expect(isPathVisibleIn({ allowedPaths: ['/pl', '/pl/brief'], enabled: true }, '/pl/o-nas')).toBe(false)
})
})
describe('under construction — Site Settings → createPageRoute', () => {
@@ -116,3 +122,27 @@ describe('under construction — Site Settings → createPageRoute', () => {
expect(await helpers.isPathVisible('/pl/brief', 'pl')).toBe(true)
})
})
describe('under construction — opting out per route', () => {
test('a project can pass its own isPathVisible to Markdown / MCP', async () => {
const { createMcpRoute } = await import('../src/modules/mcp/createMcpRoute.js')
const seen: string[] = []
const mcp = createMcpRoute({
config: { defaultLocale: 'pl', locales: [{ code: 'pl', label: 'PL' }, { code: 'en', label: 'EN' }] },
getCachedPayload: async () => ({}) as never,
isPathVisible: (path) => {
seen.push(path)
return false
},
rateLimit: false,
})
const res = await mcp.POST(
new Request('https://x/api/mcp', {
body: JSON.stringify({ id: 1, jsonrpc: '2.0', method: 'tools/call', params: { name: 'get_page', arguments: { path: '/pl/o-nas' } } }),
method: 'POST',
}),
)
expect(JSON.stringify(await res.json())).toContain('No page found')
expect(seen).toEqual(['/pl/o-nas'])
})
})