teqo-backup/tests/unit/wizardSignalUi.unit.spec.ts
Cursor Agent 2fa6e7298a
B104 — Wizard: label genérica "Pular" nas ações encadeadas
Substitui as quatro labels longas de skip (votos, tendência, sinal,
liderança) por uma constante compartilhada WIZARD_CHAIN_SKIP_LABEL.
Resolvers e condições de exibição permanecem intactos (B96/B98).

Closes #131

Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
2026-08-01 17:57:12 +00:00

46 lines
2 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { CAMPAIGN_ACTIONS_HOME } from '@/lib/campaignActionRoutes'
import { WIZARD_CHAIN_SKIP_LABEL } from '@/lib/campaignWizardCopy'
import {
municipalitySignalTypeMeta,
municipalitySignalTypeMetaByType,
} from '@/lib/municipalitySignalTypeMeta'
import { municipalitySignalTypes } from '@/lib/schemas/municipalityUpdate'
import { resolveWizardSignalSkip, shouldShowWizardSignalSkip } from '@/lib/wizardSignalUi'
describe('wizardSignalUi', () => {
it('hides skip for standalone register-signal entry', () => {
expect(shouldShowWizardSignalSkip(undefined)).toBe(false)
expect(shouldShowWizardSignalSkip('register-signal')).toBe(false)
expect(resolveWizardSignalSkip(undefined, 'cairu')).toBeUndefined()
expect(resolveWizardSignalSkip('register-signal', 'cairu')).toBeUndefined()
})
it('shows skip to the next chain step when embedded from another wizard', () => {
expect(shouldShowWizardSignalSkip('update-votes')).toBe(true)
expect(shouldShowWizardSignalSkip('change-trend')).toBe(true)
expect(resolveWizardSignalSkip('update-votes', 'cairu')).toEqual({
label: WIZARD_CHAIN_SKIP_LABEL,
href: `${CAMPAIGN_ACTIONS_HOME}/atualizar-lideranca?municipio=cairu&entry=update-votes`,
})
expect(resolveWizardSignalSkip('change-trend', 'cairu')).toEqual({
label: WIZARD_CHAIN_SKIP_LABEL,
href: `${CAMPAIGN_ACTIONS_HOME}/atualizar-votos?municipio=cairu&entry=change-trend`,
})
})
})
describe('municipalitySignalTypeMeta', () => {
it('covers every signal type with icon and info copy', () => {
expect(municipalitySignalTypeMeta).toHaveLength(municipalitySignalTypes.length)
for (const type of municipalitySignalTypes) {
const entry = municipalitySignalTypeMetaByType[type]
expect(entry?.label.length).toBeGreaterThan(0)
expect(entry?.shortDescription.length).toBeGreaterThan(0)
expect(entry?.infoContent.length).toBeGreaterThan(20)
expect(entry?.icon).toBeTruthy()
}
})
})