From dccca44ddde32ec7f046ff869e87a70f5e49d930 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 2 Aug 2026 21:40:47 +0000 Subject: [PATCH] =?UTF-8?q?B134=20=E2=80=94=20placeholder=20de=20rationale?= =?UTF-8?q?=20quando=20motivo=20de=20n=C3=ADvel=20omitido?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Francisco Solla --- src/app/(campaign)/campanha/actions/municipality.ts | 3 ++- src/lib/engagementLevel.ts | 3 +++ tests/int/campaignMunicipalityEngagementLevel.int.spec.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/(campaign)/campanha/actions/municipality.ts b/src/app/(campaign)/campanha/actions/municipality.ts index 43ad5f00..44033b17 100644 --- a/src/app/(campaign)/campanha/actions/municipality.ts +++ b/src/app/(campaign)/campanha/actions/municipality.ts @@ -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: { diff --git a/src/lib/engagementLevel.ts b/src/lib/engagementLevel.ts index cd93387c..30ea4f0c 100644 --- a/src/lib/engagementLevel.ts +++ b/src/lib/engagementLevel.ts @@ -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] /** diff --git a/tests/int/campaignMunicipalityEngagementLevel.int.spec.ts b/tests/int/campaignMunicipalityEngagementLevel.int.spec.ts index 242b9e35..a2fc9544 100644 --- a/tests/int/campaignMunicipalityEngagementLevel.int.spec.ts +++ b/tests/int/campaignMunicipalityEngagementLevel.int.spec.ts @@ -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',