diff --git a/src/app/(campaign)/campanha/actions/municipality.ts b/src/app/(campaign)/campanha/actions/municipality.ts index fb0603a2..b27c255a 100644 --- a/src/app/(campaign)/campanha/actions/municipality.ts +++ b/src/app/(campaign)/campanha/actions/municipality.ts @@ -297,6 +297,8 @@ export const assignMunicipalityAdvisorsRecord = async ( await acquireTextAdvisoryLocks(payload, req, [`municipality-advisors:${municipality}`]) if (enforceCas && baseUpdatedAt !== undefined) { + // Intentional admin bypass: unrestricted role verified above; advisors + // field access would otherwise hide `updatedAt` from some actors. const current = await payload.findByID({ collection: 'municipality', id: municipality, diff --git a/src/components/campaign/opsSync/opsMirrorClient.ts b/src/components/campaign/opsSync/opsMirrorClient.ts index b9436535..9667b659 100644 --- a/src/components/campaign/opsSync/opsMirrorClient.ts +++ b/src/components/campaign/opsSync/opsMirrorClient.ts @@ -48,8 +48,6 @@ const municipalityUpdatesCollection = createRowCollection 'ops-municipality-updates', ) -export { municipalityUpdatesCollection } - let goalsMirror: OpsGoals | null = null let revisedAtMirror: string = new Date(0).toISOString() let schemaVersionMirror: number = OPS_MIRROR_SCHEMA_VERSION diff --git a/src/components/campaign/opsSync/opsMunicipalityOutbox.ts b/src/components/campaign/opsSync/opsMunicipalityOutbox.ts index dca3c3d2..7f3103f4 100644 --- a/src/components/campaign/opsSync/opsMunicipalityOutbox.ts +++ b/src/components/campaign/opsSync/opsMunicipalityOutbox.ts @@ -381,7 +381,6 @@ export const enqueueDeclareVotes = async (input: { const run = executor.createOfflineAction({ mutationFnName: DECLARE_MUTATION_FN, - metadata: { declareKey: id }, onMutate: (variables) => { const next: OpsDeclareVotesOutboxRow = { id, @@ -428,7 +427,6 @@ export const enqueueMunicipalityUpdate = async (input: { const executor = await getOpsMunicipalityOfflineExecutor() const run = executor.createOfflineAction({ mutationFnName: MUNICIPALITY_UPDATE_MUTATION_FN, - metadata: { clientId: input.clientId }, onMutate: (variables) => { const next: OpsMunicipalityUpdateOutboxRow = { id: variables.clientId, @@ -465,7 +463,6 @@ export const enqueuePoliticalTrend = async (input: { const executor = await getOpsMunicipalityOfflineExecutor() const run = executor.createOfflineAction({ mutationFnName: TREND_MUTATION_FN, - metadata: { municipalityId: input.municipalityId }, onMutate: (variables) => { const next: OpsPoliticalTrendOutboxRow = { municipalityId: variables.municipalityId, @@ -503,7 +500,6 @@ export const enqueueEngagementLevel = async (input: { const executor = await getOpsMunicipalityOfflineExecutor() const run = executor.createOfflineAction({ mutationFnName: ENGAGEMENT_MUTATION_FN, - metadata: { municipalityId: input.municipalityId }, onMutate: (variables) => { const next: OpsEngagementLevelOutboxRow = { municipalityId: variables.municipalityId, @@ -537,7 +533,6 @@ export const enqueueAdvisorsAssignment = async (input: { const executor = await getOpsMunicipalityOfflineExecutor() const run = executor.createOfflineAction({ mutationFnName: ADVISORS_MUTATION_FN, - metadata: { municipalityId: input.municipalityId }, onMutate: (variables) => { const next: OpsAdvisorsOutboxRow = { municipalityId: variables.municipalityId, diff --git a/tests/unit/campaignComponents.unit.spec.ts b/tests/unit/campaignComponents.unit.spec.ts index 1f761b7f..3588b6ba 100644 --- a/tests/unit/campaignComponents.unit.spec.ts +++ b/tests/unit/campaignComponents.unit.spec.ts @@ -194,6 +194,7 @@ describe('campaign visual foundation', () => { priority: 'alta', lastUpdateAt: null, lastSignalAt: null, + updatedAt: '2026-08-01T00:00:00.000Z', expectedVotes: { pessimistic: null, central: 1500, optimistic: null }, politicalTrendStatus: 'favoravel', politicalTrendNote: null, @@ -237,6 +238,7 @@ describe('campaign visual foundation', () => { priority: 'normal', lastUpdateAt: null, lastSignalAt: null, + updatedAt: '2026-08-01T00:00:00.000Z', expectedVotes: toVoteEstimateScenarioViewModel(null), politicalTrendStatus: null, politicalTrendNote: null, @@ -377,6 +379,7 @@ describe('campaign visual foundation', () => { priority: 'alta', lastUpdateAt: staleSignal, lastSignalAt: staleSignal, + updatedAt: '2026-08-01T00:00:00.000Z', expectedVotes: toVoteEstimateScenarioViewModel(null), politicalTrendStatus: null, politicalTrendNote: null, @@ -421,6 +424,7 @@ describe('campaign visual foundation', () => { priority: 'normal', lastUpdateAt: null, lastSignalAt: null, + updatedAt: '2026-08-01T00:00:00.000Z', expectedVotes: toVoteEstimateScenarioViewModel(null), politicalTrendStatus: null, politicalTrendNote: null, @@ -462,6 +466,7 @@ describe('campaign visual foundation', () => { priority: 'normal', lastUpdateAt: null, lastSignalAt: null, + updatedAt: '2026-08-01T00:00:00.000Z', expectedVotes: toVoteEstimateScenarioViewModel(null), politicalTrendStatus: null, politicalTrendNote: null, @@ -509,6 +514,7 @@ describe('campaign visual foundation', () => { priority: 'alta', lastUpdateAt: null, lastSignalAt: null, + updatedAt: '2026-08-01T00:00:00.000Z', expectedVotes: toVoteEstimateScenarioViewModel(null), politicalTrendStatus: null, politicalTrendNote: null, @@ -582,6 +588,7 @@ describe('campaign visual foundation', () => { priority: 'normal' as const, lastUpdateAt: null, lastSignalAt: null, + updatedAt: '2026-08-01T00:00:00.000Z', expectedVotes: toVoteEstimateScenarioViewModel(null), politicalTrendStatus: null, politicalTrendNote: null,