feat(cms): require multi-model validation before approving legal translations (MITHOME-113)
Legal pages get a sidebar "legal validation" record (validating models, date, report reference). Their English translation status can only be set to "approved" when at least two distinct models, the date and the report are recorded; page globals are unaffected. The admin description states that model review does not replace legal advice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
822646a82a
commit
329e2e3403
@@ -146,7 +146,8 @@ describe('Payload globals', () => {
|
||||
describe('MITHOME-111 localization rule', () => {
|
||||
// DECISION (design D1): structural values shared across locales.
|
||||
// MITHOME-112: `slug` is the shared URL identifier of LegalPages.
|
||||
const SHARED_TEXT_FIELDS = new Set(['icon', 'id', 'address', 'slug'])
|
||||
// MITHOME-113: `models`/`reportRef` are legal-validation metadata, not copy.
|
||||
const SHARED_TEXT_FIELDS = new Set(['icon', 'id', 'address', 'slug', 'models', 'reportRef'])
|
||||
|
||||
type Node = FieldLike & { localized?: boolean; fields?: Node[] }
|
||||
type Finding = { path: string; type?: string; localized: boolean }
|
||||
@@ -239,3 +240,21 @@ describe('MITHOME-113 English translation status', () => {
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
describe('MITHOME-113 legal validation gate', () => {
|
||||
type Validate = (value: unknown, opts: { siblingData: Record<string, unknown> }) => true | string
|
||||
const statusOf = (doc: { fields: unknown[] }) => findField(doc.fields, 'enTranslationStatus') as unknown as { validate?: Validate }
|
||||
|
||||
it('should block approving a legal page without a validation record', () => {
|
||||
expect(statusOf(LegalPages).validate?.('approved', { siblingData: {} })).toEqual(expect.any(String))
|
||||
expect(findField(LegalPages.fields, 'legalValidation')).toMatchObject({ type: 'group' })
|
||||
})
|
||||
|
||||
it.each([Home, About, Services, Contact, Common].map((g) => [g.slug, g] as const))(
|
||||
'should not add the legal rule to the %s global',
|
||||
(_slug, global) => {
|
||||
expect(statusOf(global).validate).toBeUndefined()
|
||||
expect(findField(global.fields, 'legalValidation')).toBeUndefined()
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user