B129 — Simplify cleanup after overview removal

Fix duplicated JSDoc, trim stale int test, defer perf follow-ups in impl plan.

Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-08-02 19:05:41 +00:00
parent b4f2e2fa0a
commit 76597292c9
No known key found for this signature in database
3 changed files with 4 additions and 37 deletions

View file

@ -41,6 +41,7 @@ Appetite restante: remoção cirúrgica (sem redesign)
- Redesenhar `loading.tsx` (fora do aceite).
- Tocar `SupporterListOverview` ou dashboard.
- **Defer:** escopo de `loadMunicipalityGoalCoverageBundle` ao page slice quando `isPagedByPayload` (gatilho: perf review pós-B129); skip `aggregateByScenario` no loader de lista (gatilho: 2º consumidor de rows-only).
## Riscos e mitigação

View file

@ -87,8 +87,7 @@ type MunicipalityFacetRow = Pick<Municipality, 'slug' | 'region' | 'advisors'>
* class is derived from the committed TSE artifact, not stored), so every
* place that would otherwise trust `where` — the page query and the facets —
* has to apply this predicate itself. Returns `null` when no class is selected,
* when no class is selected, which is also the signal to keep the cheap
* database-paginated path.
* which is also the signal to keep the cheap database-paginated path.
*/
const territorialClassFilterPredicate = (
state: MunicipalityListState,

View file

@ -9,8 +9,6 @@ import { territorialClassSortWeight } from '@/lib/territorialClassSortWeight'
import config from '@/payload.config'
import { loadMunicipalityListPageBundle } from '@/utilities/municipality/municipalityPageData'
import { computeMunicipalityTerritorialClass } from '@/utilities/municipality/municipalityTerritorialClass'
import { aggregatePledgesByMunicipality } from '@/utilities/votePledgeData'
import { rollupMunicipalityStaffVotes } from '@/utilities/votePledgeViews'
import { installCampaignFixtures } from '../helpers/campaignFixtures'
@ -36,43 +34,12 @@ describe('loadMunicipalityListPageBundle', () => {
expect(bundle.totalDocs).toBe(0)
})
it('rolls up staffVoteTotal from expectedVotes when no pledge overrides apply', async () => {
it('includes 2022 vote position on list rows', async () => {
const fixtures = campaignFixtures()
const coordinator = await fixtures.createCampaignUser('coordinator')
const municipality = await fixtures.getMunicipality()
fixtures.touchMunicipality(municipality.id)
await payload.update({
collection: 'municipality',
id: municipality.id,
data: { expectedVotes: { pessimistic: null, central: 1_500, optimistic: null } },
depth: 0,
overrideAccess: true,
})
const contact = await fixtures.createContact()
const leadership = await fixtures.createLeadership({
contact: contact.id,
municipalities: [municipality.id],
supportStatus: 'engajado',
})
await fixtures.createVotePledge({
leadership: leadership.id,
municipality: municipality.id,
declaredVotes: 80,
estimatedVotes: { pessimistic: null, central: 120, optimistic: null },
})
const refreshedMunicipality = await payload.findByID({
collection: 'municipality',
id: municipality.id,
depth: 0,
overrideAccess: true,
})
const aggregates = await aggregatePledgesByMunicipality(payload, [municipality.id])
const rollup = rollupMunicipalityStaffVotes([refreshedMunicipality], aggregates)
expect(rollup.staffVoteTotal).toBe(1_500)
const bundle = await loadMunicipalityListPageBundle(payload, coordinator, {
q: municipality.name,
})
@ -278,7 +245,7 @@ describe('loadMunicipalityListPageBundle', () => {
* cannot be a Payload constraint. The bundle must still agree with itself —
* rows and `totalDocs` counting the filtered scope.
*/
it('filters by the derived territorial class and keeps the overview honest', async () => {
it('filters by the derived territorial class and keeps totals honest', async () => {
const fixtures = campaignFixtures()
const coordinator = await fixtures.createCampaignUser('coordinator')