Rename the operational unit "Praça"/"Núcleo" to "Município" (code identifier `municipality`) and land the 2026-07-23 course changes: - New `candidate` role with unrestricted visibility (`isCampaignStaff` now includes it) alongside coordinator/advisor; leader is locked down to the supporter contact tool only. - Demandas become staff-only; dobradinhas modeled via a `stateDeputy` entity. - Camaçari consolidated to a single município (ZE 170/171 aggregated); Salvador keeps its 19 zone municípios. - Map moves to the staff dashboard; `/campanha/municipios` is list/overview. - Vote pledges keep the declared vs estimated (scenario) asymmetry; leaders never see estimates. Destructive migration for the campaign vertical (drops nucleus/plaza-era tables, wipes campaign rows, seeds 435 municípios). Public-site data untouched. Includes the post-delivery /simplify cleanups: shared reloadStaffActor / reloadCoordinatorActor helpers, req.context cache for getFreshCampaignUser, parallelized dashboard loads, candidate dashboard-copy fix, and dead leader-dashboard / roleKind code removal.
51 lines
2 KiB
TypeScript
51 lines
2 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
buildMunicipalitiesByIbgeCode,
|
|
resolveMunicipalityMapNavigation,
|
|
} from '@/utilities/municipalityMapNavigation'
|
|
|
|
describe('municipalityMapNavigation', () => {
|
|
it('buildMunicipalitiesByIbgeCode groups municipalities by ibgeCode and sorts by name', () => {
|
|
const result = buildMunicipalitiesByIbgeCode([
|
|
{ slug: 'salvador-ze-2', name: 'Salvador ZE 2', ibgeCode: '2927408' },
|
|
{ slug: 'salvador-ze-1', name: 'Salvador ZE 1', ibgeCode: '2927408' },
|
|
{ slug: 'abaira', name: 'Abaíra', ibgeCode: '2900108' },
|
|
])
|
|
|
|
expect(result['2900108']).toEqual([{ slug: 'abaira', name: 'Abaíra' }])
|
|
expect(result['2927408']).toEqual([
|
|
{ slug: 'salvador-ze-1', name: 'Salvador ZE 1' },
|
|
{ slug: 'salvador-ze-2', name: 'Salvador ZE 2' },
|
|
])
|
|
})
|
|
|
|
it('resolveMunicipalityMapNavigation returns none when ibgeCode is missing or empty', () => {
|
|
const byIbge = buildMunicipalitiesByIbgeCode([
|
|
{ slug: 'abaira', name: 'Abaíra', ibgeCode: '2900108' },
|
|
])
|
|
|
|
expect(resolveMunicipalityMapNavigation('9999999', byIbge)).toEqual({ kind: 'none' })
|
|
expect(resolveMunicipalityMapNavigation('2900108', {})).toEqual({ kind: 'none' })
|
|
})
|
|
|
|
it('resolveMunicipalityMapNavigation returns navigate for a single municipality', () => {
|
|
const byIbge = buildMunicipalitiesByIbgeCode([
|
|
{ slug: 'abaira', name: 'Abaíra', ibgeCode: '2900108' },
|
|
])
|
|
|
|
expect(resolveMunicipalityMapNavigation('2900108', byIbge)).toEqual({
|
|
kind: 'navigate',
|
|
slug: 'abaira',
|
|
})
|
|
})
|
|
|
|
it('resolveMunicipalityMapNavigation returns zones for multiple municipalities on the same ibgeCode', () => {
|
|
const byIbge = buildMunicipalitiesByIbgeCode([
|
|
{ slug: 'salvador-ze-1', name: 'Salvador ZE 1', ibgeCode: '2927408' },
|
|
{ slug: 'salvador-ze-2', name: 'Salvador ZE 2', ibgeCode: '2927408' },
|
|
])
|
|
|
|
expect(resolveMunicipalityMapNavigation('2927408', byIbge)).toEqual({ kind: 'zones' })
|
|
})
|
|
})
|