B134 — placeholder de rationale quando motivo de nível omitido

Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-08-02 21:40:47 +00:00
parent 28ff9615ce
commit dccca44ddd
No known key found for this signature in database
3 changed files with 6 additions and 2 deletions

View file

@ -3,6 +3,7 @@
import type { Payload } from 'payload'
import {
ENGAGEMENT_LEVEL_NO_RATIONALE_LABEL,
ENGAGEMENT_LEVEL_PATTERN_ID,
EngagementLevelBlockedError,
getEngagementLevelViolations,
@ -205,7 +206,7 @@ export const setMunicipalityEngagementLevelRecord = async (
municipality,
patternId: ENGAGEMENT_LEVEL_PATTERN_ID,
outcome: 'movimento',
rationale: levelNote ?? '',
rationale: levelNote?.trim() ? levelNote : ENGAGEMENT_LEVEL_NO_RATIONALE_LABEL,
// Only the values the decision was taken on — no document dumps
// (the collection caps the serialized snapshot at 16 KB).
snapshot: {

View file

@ -19,6 +19,9 @@ export const ENGAGEMENT_LEVEL_PATTERN_ID = 'nivel'
/** Cap shared by the field, the schema and the textareas, so they agree. */
export const ENGAGEMENT_LEVEL_TEXT_MAX_LENGTH = 2000
/** Filed on `allocationDecision.rationale` when the coordinator omits a motivo (B134). */
export const ENGAGEMENT_LEVEL_NO_RATIONALE_LABEL = 'Sem justificativa registrada.'
export type EngagementLevel = (typeof engagementLevels)[number]
/**

View file

@ -84,7 +84,7 @@ describe('municipality engagement level (E14)', () => {
const decision = decisions.docs[0]!
fixtures.own('allocationDecision', decision.id)
expect(decision.rationale).toBe('')
expect(decision.rationale).toBe('Sem justificativa registrada.')
expect(decision.snapshot).toMatchObject({
from: null,
to: 'n1',