Issue #390 — entrada operacional staff com FullCalendar v7 route-local (semana/mês/lista), filtros compartilháveis por município/deputado/tag, criação pelo slot, detalhe por URL e remarcação drag/resize sob RBAC, transação e lock por atividade. - /campanha/atividades e giros permanecem como lista/fluxos legados - Sem migration/collection nova; reutiliza activity de C14 - Fuso Bahia, range exclusivo, erro/revert, loading/empty testados - Leader negado, advisor limitado pelo access atual - E2E cobre filtros, drag, mobile 390x844 e slot prefill - Int specs cobrem RBAC, concorrência e defense-in-depth Impl: docs/plans/fullcalendar-agenda-campanha-impl.md
54 lines
2.3 KiB
TypeScript
54 lines
2.3 KiB
TypeScript
// @vitest-environment node
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import { getCampaignNav, isCampaignNavActive } from '@/components/campaign/shell/nav'
|
|
import { CAMPAIGN_AGENDA_HOME } from '@/lib/campaignPaths'
|
|
import { ORGANIZATIONS_LIST_PATH } from '@/lib/campaignQuickActionPaths'
|
|
|
|
describe('organizations sidebar entry', () => {
|
|
it('is offered to staff after Lideranças', () => {
|
|
const hrefs = getCampaignNav('coordinator').map((item) => item.href)
|
|
const leadershipIndex = hrefs.indexOf('/campanha/liderancas')
|
|
const organizationsIndex = hrefs.indexOf(ORGANIZATIONS_LIST_PATH)
|
|
|
|
expect(organizationsIndex).toBeGreaterThan(-1)
|
|
expect(organizationsIndex).toBe(leadershipIndex + 1)
|
|
})
|
|
|
|
it('is visible to advisor and candidate', () => {
|
|
expect(getCampaignNav('advisor').map((item) => item.href)).toContain(ORGANIZATIONS_LIST_PATH)
|
|
expect(getCampaignNav('candidate').map((item) => item.href)).toContain(ORGANIZATIONS_LIST_PATH)
|
|
})
|
|
|
|
it('is hidden from leaders', () => {
|
|
expect(getCampaignNav('leader').map((item) => item.href)).not.toContain(ORGANIZATIONS_LIST_PATH)
|
|
})
|
|
|
|
it('marks list, detail, and nova as active', () => {
|
|
expect(isCampaignNavActive(ORGANIZATIONS_LIST_PATH, ORGANIZATIONS_LIST_PATH)).toBe(true)
|
|
expect(isCampaignNavActive('/campanha/organizacoes/sindmed', ORGANIZATIONS_LIST_PATH)).toBe(
|
|
true,
|
|
)
|
|
expect(isCampaignNavActive('/campanha/organizacoes/nova', ORGANIZATIONS_LIST_PATH)).toBe(true)
|
|
})
|
|
})
|
|
|
|
describe('agenda sidebar entry', () => {
|
|
it('replaces Atividades for staff and stays hidden from leaders', () => {
|
|
for (const role of ['coordinator', 'candidate', 'advisor'] as const) {
|
|
const agenda = getCampaignNav(role).find((item) => item.href === CAMPAIGN_AGENDA_HOME)
|
|
expect(agenda?.title).toBe('Agenda')
|
|
}
|
|
expect(getCampaignNav('leader').map((item) => item.href)).not.toContain(CAMPAIGN_AGENDA_HOME)
|
|
})
|
|
|
|
it('stays active on the agenda and legacy activity routes', () => {
|
|
expect(isCampaignNavActive(CAMPAIGN_AGENDA_HOME, CAMPAIGN_AGENDA_HOME)).toBe(true)
|
|
expect(isCampaignNavActive('/campanha/atividades', CAMPAIGN_AGENDA_HOME)).toBe(true)
|
|
expect(isCampaignNavActive('/campanha/atividades/comicio', CAMPAIGN_AGENDA_HOME)).toBe(true)
|
|
expect(isCampaignNavActive('/campanha/atividades/comicio/editar', CAMPAIGN_AGENDA_HOME)).toBe(
|
|
true,
|
|
)
|
|
})
|
|
})
|