feat(cms): localize legal pages with a lossless migration (MITHOME-112)
Legal page title, last-updated text and section titles/contents become
localized; slug and section ids stay shared. A Payload migration wraps
existing values into { hu: value } on every legal page and its whole
version history, like the globals migration (MITHOME-111).
The migration helper now handles collections as well as globals
(rewriteDocs) and can scope version rewrites to the latest working copy,
which the upcoming English import needs. Migration tests share an
in-memory Mongo fake that honours query filters.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ef93cec935
commit
0eb6594acc
@@ -145,7 +145,8 @@ describe('Payload globals', () => {
|
||||
|
||||
describe('MITHOME-111 localization rule', () => {
|
||||
// DECISION (design D1): structural values shared across locales.
|
||||
const SHARED_TEXT_FIELDS = new Set(['icon', 'id', 'address'])
|
||||
// MITHOME-112: `slug` is the shared URL identifier of LegalPages.
|
||||
const SHARED_TEXT_FIELDS = new Set(['icon', 'id', 'address', 'slug'])
|
||||
|
||||
type Node = FieldLike & { localized?: boolean; fields?: Node[] }
|
||||
type Finding = { path: string; type?: string; localized: boolean }
|
||||
@@ -177,8 +178,8 @@ describe('Payload globals', () => {
|
||||
return !SHARED_TEXT_FIELDS.has(finding.path.split('.').pop()!)
|
||||
}
|
||||
|
||||
it.each([Home, About, Services, Contact, Common].map((g) => [g.slug, g] as const))(
|
||||
'should localize exactly the translatable fields of the %s global',
|
||||
it.each([Home, About, Services, Contact, Common, LegalPages].map((g) => [g.slug, g] as const))(
|
||||
'should localize exactly the translatable fields of %s',
|
||||
(_slug, global) => {
|
||||
const findings = walk(global.fields as Node[], '', [])
|
||||
const wrong = findings.filter((f) => f.localized !== expected(f)).map((f) => f.path)
|
||||
|
||||
Reference in New Issue
Block a user