teqo-backup/tests/unit/politicalTrendWizardUi.unit.spec.ts
fsolla 7faf3ed27f feat(campanha): B168 — desfazer encadeamento automático das ações rápidas do wizard
Ações de ajuste (votos, tendência, atualização, liderança) agora retornam à
origem ao salvar (toast + from allowlist B110 / Início), sem avançar sozinhas
para outro wizard. Removidos fila de encadeamento (wizardActionChain.ts),
param entry, skip/Pular (chrome mobile sempre X) e prefill de nota sem
produtor. Liderança: botão pós-save 'Continuar' → 'Concluir' (origem).
Sem migration.
2026-08-08 14:10:47 -03:00

47 lines
1.9 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
politicalTrendWizardMeta,
politicalTrendWizardMetaByStatus,
} from '@/lib/politicalTrendWizardMeta'
import {
resolveWizardTrendNoteDestination,
selectablePoliticalTrendStatuses,
WIZARD_TREND_UNREGISTERED_TITLE,
wizardTrendChoiceStepTitle,
} from '@/lib/politicalTrendWizardUi'
import { politicalTrendStatuses } from '@/lib/schemas/municipality'
describe('politicalTrendWizardUi', () => {
it('titles the choice step from the current status', () => {
expect(wizardTrendChoiceStepTitle(null)).toBe(WIZARD_TREND_UNREGISTERED_TITLE)
expect(wizardTrendChoiceStepTitle('favoravel')).toBe('Tendência Favorável')
})
it('filters out the current trend from selectable options', () => {
expect(selectablePoliticalTrendStatuses(null)).toEqual(politicalTrendStatuses)
expect(selectablePoliticalTrendStatuses('neutra')).toEqual(['favoravel', 'desfavoravel'])
expect(selectablePoliticalTrendStatuses('desfavoravel')).toEqual(['favoravel', 'neutra'])
})
it('resolves the note-step destination without looping to choice after save', () => {
expect(resolveWizardTrendNoteDestination('favoravel', 'neutra')).toBe('note')
expect(resolveWizardTrendNoteDestination('favoravel', 'favoravel')).toBe('home')
expect(resolveWizardTrendNoteDestination('favoravel', null)).toBe('note')
})
})
describe('politicalTrendWizardMeta', () => {
it('covers every trend with icon, copy and info content', () => {
expect(politicalTrendWizardMeta).toHaveLength(politicalTrendStatuses.length)
for (const status of politicalTrendStatuses) {
const entry = politicalTrendWizardMetaByStatus[status]
expect(entry.label.length).toBeGreaterThan(0)
expect(entry.changeDescription).toContain(entry.label)
expect(entry.infoContent.length).toBeGreaterThan(20)
expect(entry.icon).toBeTruthy()
expect(entry.tileClassName.length).toBeGreaterThan(0)
}
})
})