+ entryAction != null && entryAction !== 'update-votes'
+
+export const resolveWizardVotesSkip = (
+ entryAction: CampaignWizardActionId | undefined,
+ municipalitySlug: string,
+): WizardVotesSkipAction | undefined =>
+ shouldShowWizardVotesSkip(entryAction)
+ ? {
+ label: WIZARD_VOTES_SKIP_LABEL,
+ href: wizardChainContinueHref(
+ resolveWizardChainEntry(entryAction, 'update-votes'),
+ 'update-votes',
+ municipalitySlug,
+ ),
+ }
+ : undefined
+
export const wizardNextStepTitle = (actionSlug: string): string => {
if (actionSlug === CAMPAIGN_WIZARD_ACTION_SLUGS['update-votes']) {
return 'Ajustar votos estimados'
@@ -44,12 +68,8 @@ export const wizardNextStepTitle = (actionSlug: string): string => {
return 'Continuar'
}
-export const wizardNextStepPlaceholder = (actionSlug: string): string => {
- if (actionSlug === CAMPAIGN_WIZARD_ACTION_SLUGS['update-votes']) {
- return WIZARD_VOTES_NEXT_FLOW_PLACEHOLDER
- }
- return WIZARD_NEXT_STEP_GENERIC_PLACEHOLDER
-}
+export const wizardNextStepPlaceholder = (_actionSlug: string): string =>
+ WIZARD_NEXT_STEP_GENERIC_PLACEHOLDER
export const WIZARD_LEADERSHIP_GRID_TITLE = 'Quem coordena por aqui?' as const
diff --git a/src/lib/politicalTrendWizardUi.ts b/src/lib/politicalTrendWizardUi.ts
index d4d81031..5c33dfae 100644
--- a/src/lib/politicalTrendWizardUi.ts
+++ b/src/lib/politicalTrendWizardUi.ts
@@ -1,10 +1,10 @@
import type { CampaignWizardActionId } from '@/lib/campaignActionRoutes'
-import { CAMPAIGN_HOME } from '@/lib/campaignPaths'
import { politicalTrendStatuses, type PoliticalTrendStatusValue } from '@/lib/schemas/municipality'
import {
municipalitySignalTypeLabels,
type MunicipalitySignalType,
} from '@/lib/schemas/municipalityUpdate'
+import { resolveWizardChainEntry, wizardChainContinueHref } from '@/lib/wizardActionChain'
const politicalTrendDisplayLabels: Record
= {
favoravel: 'Favorável',
@@ -69,9 +69,17 @@ export const shouldShowWizardTrendSkip = (
export const resolveWizardTrendSkip = (
entryAction: CampaignWizardActionId | undefined,
+ municipalitySlug: string,
): WizardTrendSkipAction | undefined =>
shouldShowWizardTrendSkip(entryAction)
- ? { label: WIZARD_TREND_SKIP_LABEL, href: CAMPAIGN_HOME }
+ ? {
+ label: WIZARD_TREND_SKIP_LABEL,
+ href: wizardChainContinueHref(
+ resolveWizardChainEntry(entryAction, 'change-trend'),
+ 'change-trend',
+ municipalitySlug,
+ ),
+ }
: undefined
export type PoliticalTrendNotePrefillSource =
diff --git a/src/lib/wizardActionChain.ts b/src/lib/wizardActionChain.ts
new file mode 100644
index 00000000..bb68d083
--- /dev/null
+++ b/src/lib/wizardActionChain.ts
@@ -0,0 +1,97 @@
+/**
+ * B98 — ordered sub-flow queue after the principal wizard action succeeds.
+ * Pure navigation helpers; each link still writes via its existing action.
+ */
+
+import {
+ CAMPAIGN_WIZARD_ACTION_SLUGS,
+ type CampaignWizardActionId,
+ wizardActionHref,
+ wizardSignalHref,
+ wizardTrendHref,
+} from '@/lib/campaignActionRoutes'
+import { CAMPAIGN_HOME } from '@/lib/campaignPaths'
+
+/** Actions that participate in the v1 adjustment chain (excludes demand). */
+export type WizardChainActionId = Exclude
+
+const WIZARD_CHAIN_AFTER = {
+ 'update-votes': ['change-trend', 'register-signal', 'update-leadership'],
+ 'register-signal': ['change-trend', 'update-votes', 'update-leadership'],
+ 'change-trend': ['register-signal', 'update-votes', 'update-leadership'],
+ 'update-leadership': ['register-signal', 'update-votes', 'change-trend'],
+} as const satisfies Record
+
+export const isWizardChainActionId = (
+ id: CampaignWizardActionId | undefined,
+): id is WizardChainActionId => id != null && id in WIZARD_CHAIN_AFTER
+
+/**
+ * Remaining chained steps after `completedAction` in a session owned by `entryAction`.
+ * When `completedAction` is the principal (or omitted), returns the full queue.
+ */
+export const wizardChainAfter = (
+ entryAction: WizardChainActionId,
+ completedAction?: WizardChainActionId,
+): WizardChainActionId[] => {
+ const queue: WizardChainActionId[] = [...WIZARD_CHAIN_AFTER[entryAction]]
+ if (!completedAction || completedAction === entryAction) {
+ return queue
+ }
+ const index = queue.indexOf(completedAction)
+ if (index === -1) {
+ return []
+ }
+ return queue.slice(index + 1)
+}
+
+export const nextWizardChainStep = (
+ entryAction: WizardChainActionId,
+ completedAction: WizardChainActionId,
+): WizardChainActionId | undefined => wizardChainAfter(entryAction, completedAction)[0]
+
+const wizardHrefForChainStep = (
+ action: WizardChainActionId,
+ municipalitySlug: string,
+ entryAction: WizardChainActionId,
+): string => {
+ const actionSlug = CAMPAIGN_WIZARD_ACTION_SLUGS[action]
+ switch (action) {
+ case 'update-votes':
+ case 'update-leadership':
+ return wizardActionHref(actionSlug, municipalitySlug, { entryAction })
+ case 'register-signal':
+ return wizardSignalHref(actionSlug, municipalitySlug, undefined, entryAction)
+ case 'change-trend':
+ return wizardTrendHref(actionSlug, municipalitySlug, undefined, entryAction)
+ default: {
+ const exhaustive: never = action
+ return exhaustive
+ }
+ }
+}
+
+/**
+ * Href for the next chained wizard after completing/skipping `completedAction`,
+ * or Início when the queue is empty / entry is not chainable.
+ */
+export const wizardChainContinueHref = (
+ entryAction: CampaignWizardActionId,
+ completedAction: WizardChainActionId,
+ municipalitySlug: string,
+): string => {
+ if (!isWizardChainActionId(entryAction)) {
+ return CAMPAIGN_HOME
+ }
+ const next = nextWizardChainStep(entryAction, completedAction)
+ if (!next) {
+ return CAMPAIGN_HOME
+ }
+ return wizardHrefForChainStep(next, municipalitySlug, entryAction)
+}
+
+/** Session owner for navigation: explicit `entry` query, else the current principal. */
+export const resolveWizardChainEntry = (
+ entryAction: CampaignWizardActionId | undefined,
+ currentAction: WizardChainActionId,
+): WizardChainActionId => (isWizardChainActionId(entryAction) ? entryAction : currentAction)
diff --git a/src/lib/wizardLeadershipContract.ts b/src/lib/wizardLeadershipContract.ts
index e1958a62..7d936dbd 100644
--- a/src/lib/wizardLeadershipContract.ts
+++ b/src/lib/wizardLeadershipContract.ts
@@ -1,5 +1,7 @@
import type { CampaignWizardActionId } from '@/lib/campaignActionRoutes'
+import { WIZARD_LEADERSHIP_SKIP_LABEL } from '@/lib/campaignWizardCopy'
import type { SupportStatus } from '@/lib/schemas/leadership'
+import { resolveWizardChainEntry, wizardChainContinueHref } from '@/lib/wizardActionChain'
/** Client-safe tile payload for the B70 leadership wizard grid. */
export type WizardLeadershipTileViewModel = {
@@ -12,7 +14,27 @@ export type WizardLeadershipTileViewModel = {
notes: string | null
}
+export type WizardLeadershipSkipAction = {
+ label: string
+ href: string
+}
+
export const showLeadershipWizardSkip = (entryAction?: CampaignWizardActionId): boolean => {
const effectiveEntry = entryAction ?? 'update-leadership'
return effectiveEntry !== 'update-leadership'
}
+
+export const resolveWizardLeadershipSkip = (
+ entryAction: CampaignWizardActionId | undefined,
+ municipalitySlug: string,
+): WizardLeadershipSkipAction | undefined =>
+ showLeadershipWizardSkip(entryAction)
+ ? {
+ label: WIZARD_LEADERSHIP_SKIP_LABEL,
+ href: wizardChainContinueHref(
+ resolveWizardChainEntry(entryAction, 'update-leadership'),
+ 'update-leadership',
+ municipalitySlug,
+ ),
+ }
+ : undefined
diff --git a/src/lib/wizardSignalUi.ts b/src/lib/wizardSignalUi.ts
index 816fd1b9..d561af99 100644
--- a/src/lib/wizardSignalUi.ts
+++ b/src/lib/wizardSignalUi.ts
@@ -1,5 +1,5 @@
import type { CampaignWizardActionId } from '@/lib/campaignActionRoutes'
-import { CAMPAIGN_HOME } from '@/lib/campaignPaths'
+import { resolveWizardChainEntry, wizardChainContinueHref } from '@/lib/wizardActionChain'
export const WIZARD_SIGNAL_TYPE_STEP_TITLE = 'Que tipo de sinal?' as const
@@ -22,7 +22,15 @@ export const shouldShowWizardSignalSkip = (
export const resolveWizardSignalSkip = (
entryAction: CampaignWizardActionId | undefined,
+ municipalitySlug: string,
): WizardSignalSkipAction | undefined =>
shouldShowWizardSignalSkip(entryAction)
- ? { label: WIZARD_SIGNAL_SKIP_LABEL, href: CAMPAIGN_HOME }
+ ? {
+ label: WIZARD_SIGNAL_SKIP_LABEL,
+ href: wizardChainContinueHref(
+ resolveWizardChainEntry(entryAction, 'register-signal'),
+ 'register-signal',
+ municipalitySlug,
+ ),
+ }
: undefined
diff --git a/tests/e2e/campaignHomeActions.e2e.spec.ts b/tests/e2e/campaignHomeActions.e2e.spec.ts
index 49d3a612..3f4d943b 100644
--- a/tests/e2e/campaignHomeActions.e2e.spec.ts
+++ b/tests/e2e/campaignHomeActions.e2e.spec.ts
@@ -219,6 +219,11 @@ test.describe('Wizard — ajuste de votos (B61 / B77)', () => {
await step.getByRole('textbox', { name: 'Otimista' }).fill('350')
await page.getByRole('button', { name: 'Salvar estimativas →' }).click()
+ await page.waitForURL(
+ new RegExp(
+ `/campanha/acoes/mudar-tendencia\\?municipio=${municipality.slug}&entry=update-votes`,
+ ),
+ )
await expect(page.getByText('Votos estimados atualizados.')).toBeVisible({ timeout: 15000 })
expect(page.url()).not.toContain('cenario=')
})
@@ -273,7 +278,7 @@ test.describe('Wizard — ajuste de votos (B61 / B77)', () => {
})
test.describe('Wizard — atualizar liderança (B70)', () => {
- test('create leadership, save, and continue to home', async ({ campaign, page }) => {
+ test('create leadership, save, and continue into the chain', async ({ campaign, page }) => {
const { fixtures } = campaign
const coordinator = await fixtures.createCampaignUser('coordinator', {
name: fixtures.value('Coordenadora Geral'),
@@ -301,13 +306,17 @@ test.describe('Wizard — atualizar liderança (B70)', () => {
await expect(page.getByRole('button', { name: 'Continuar' })).toBeVisible()
await page.getByRole('button', { name: 'Continuar' }).click()
- await page.waitForURL('/campanha')
- await expect(page.getByLabel('Buscar na campanha')).toBeVisible()
+ await page.waitForURL(
+ new RegExp(
+ `/campanha/acoes/registrar-sinal\\?municipio=${municipality.slug}&entry=update-leadership`,
+ ),
+ )
+ await expect(page.getByRole('heading', { name: 'Que tipo de sinal?' })).toBeVisible()
})
})
test.describe('Wizard — registrar sinal (B63)', () => {
- test('standalone flow: type grid, body step, save returns to Início', async ({
+ test('standalone flow: type grid, body step, save continues the chain', async ({
campaign,
page,
}) => {
@@ -335,7 +344,11 @@ test.describe('Wizard — registrar sinal (B63)', () => {
await body.fill('Adversário marcou presença no centro do município.')
await page.getByRole('button', { name: 'Salvar' }).click()
- await page.waitForURL(/\/campanha$/)
+ await page.waitForURL(
+ new RegExp(
+ `/campanha/acoes/mudar-tendencia\\?municipio=${municipality.slug}&entry=register-signal`,
+ ),
+ )
await expect(page.getByText('Sinal registrado.')).toBeVisible()
})
@@ -362,7 +375,7 @@ test.describe('Wizard — registrar sinal (B63)', () => {
await expect(page.getByRole('dialog')).toHaveCount(0)
})
- test('embedded flow shows skip link', async ({ campaign, page }) => {
+ test('embedded flow shows skip link to the next chain step', async ({ campaign, page }) => {
const { fixtures } = campaign
const coordinator = await fixtures.createCampaignUser('coordinator', {
name: fixtures.value('Coordenadora Geral'),
@@ -374,8 +387,11 @@ test.describe('Wizard — registrar sinal (B63)', () => {
`/campanha/acoes/registrar-sinal?municipio=${municipality.slug}&entry=update-votes`,
)
- await expect(page.getByRole('link', { name: 'Pular registro de sinal' })).toBeVisible({
- timeout: 15000,
- })
+ const skip = page.getByRole('link', { name: 'Pular registro de sinal' })
+ await expect(skip).toBeVisible({ timeout: 15000 })
+ await expect(skip).toHaveAttribute(
+ 'href',
+ `/campanha/acoes/atualizar-lideranca?municipio=${municipality.slug}&entry=update-votes`,
+ )
})
})
diff --git a/tests/unit/politicalTrendWizardUi.unit.spec.ts b/tests/unit/politicalTrendWizardUi.unit.spec.ts
index 7c9d0d12..699dd68e 100644
--- a/tests/unit/politicalTrendWizardUi.unit.spec.ts
+++ b/tests/unit/politicalTrendWizardUi.unit.spec.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
-import { CAMPAIGN_HOME } from '@/lib/campaignPaths'
+import { CAMPAIGN_ACTIONS_HOME } from '@/lib/campaignActionRoutes'
import {
politicalTrendWizardMeta,
politicalTrendWizardMetaByStatus,
@@ -39,16 +39,16 @@ describe('politicalTrendWizardUi', () => {
it('hides skip for standalone change-trend entry', () => {
expect(shouldShowWizardTrendSkip(undefined)).toBe(false)
expect(shouldShowWizardTrendSkip('change-trend')).toBe(false)
- expect(resolveWizardTrendSkip(undefined)).toBeUndefined()
- expect(resolveWizardTrendSkip('change-trend')).toBeUndefined()
+ expect(resolveWizardTrendSkip(undefined, 'cairu')).toBeUndefined()
+ expect(resolveWizardTrendSkip('change-trend', 'cairu')).toBeUndefined()
})
- it('shows skip when embedded from another wizard action', () => {
+ it('shows skip to the next chain step when embedded from another wizard', () => {
expect(shouldShowWizardTrendSkip('update-votes')).toBe(true)
expect(shouldShowWizardTrendSkip('register-signal')).toBe(true)
- expect(resolveWizardTrendSkip('update-votes')).toEqual({
+ expect(resolveWizardTrendSkip('update-votes', 'cairu')).toEqual({
label: WIZARD_TREND_SKIP_LABEL,
- href: CAMPAIGN_HOME,
+ href: `${CAMPAIGN_ACTIONS_HOME}/registrar-sinal?municipio=cairu&entry=update-votes`,
})
})
diff --git a/tests/unit/wizardActionChain.unit.spec.ts b/tests/unit/wizardActionChain.unit.spec.ts
new file mode 100644
index 00000000..8ca05a10
--- /dev/null
+++ b/tests/unit/wizardActionChain.unit.spec.ts
@@ -0,0 +1,80 @@
+import { describe, expect, it } from 'vitest'
+
+import { CAMPAIGN_ACTIONS_HOME } from '@/lib/campaignActionRoutes'
+import { CAMPAIGN_HOME } from '@/lib/campaignPaths'
+import {
+ isWizardChainActionId,
+ nextWizardChainStep,
+ resolveWizardChainEntry,
+ wizardChainAfter,
+ wizardChainContinueHref,
+} from '@/lib/wizardActionChain'
+
+describe('wizardActionChain', () => {
+ it('excludes register-demand from the chainable set', () => {
+ expect(isWizardChainActionId('update-votes')).toBe(true)
+ expect(isWizardChainActionId('register-demand')).toBe(false)
+ expect(isWizardChainActionId(undefined)).toBe(false)
+ })
+
+ it('returns the full queue after the principal action', () => {
+ expect(wizardChainAfter('update-votes')).toEqual([
+ 'change-trend',
+ 'register-signal',
+ 'update-leadership',
+ ])
+ expect(wizardChainAfter('update-votes', 'update-votes')).toEqual([
+ 'change-trend',
+ 'register-signal',
+ 'update-leadership',
+ ])
+ expect(wizardChainAfter('register-signal', 'register-signal')).toEqual([
+ 'change-trend',
+ 'update-votes',
+ 'update-leadership',
+ ])
+ expect(wizardChainAfter('change-trend', 'change-trend')).toEqual([
+ 'register-signal',
+ 'update-votes',
+ 'update-leadership',
+ ])
+ expect(wizardChainAfter('update-leadership', 'update-leadership')).toEqual([
+ 'register-signal',
+ 'update-votes',
+ 'change-trend',
+ ])
+ })
+
+ it('slices the remaining queue after a chained step', () => {
+ expect(wizardChainAfter('update-votes', 'change-trend')).toEqual([
+ 'register-signal',
+ 'update-leadership',
+ ])
+ expect(wizardChainAfter('update-votes', 'register-signal')).toEqual(['update-leadership'])
+ expect(wizardChainAfter('update-votes', 'update-leadership')).toEqual([])
+ expect(nextWizardChainStep('change-trend', 'register-signal')).toBe('update-votes')
+ expect(nextWizardChainStep('update-leadership', 'change-trend')).toBeUndefined()
+ })
+
+ it('builds continue hrefs with entry + municipio, or Início at the end', () => {
+ expect(wizardChainContinueHref('update-votes', 'update-votes', 'cairu')).toBe(
+ `${CAMPAIGN_ACTIONS_HOME}/mudar-tendencia?municipio=cairu&entry=update-votes`,
+ )
+ expect(wizardChainContinueHref('update-votes', 'change-trend', 'cairu')).toBe(
+ `${CAMPAIGN_ACTIONS_HOME}/registrar-sinal?municipio=cairu&entry=update-votes`,
+ )
+ expect(wizardChainContinueHref('register-signal', 'change-trend', 'cairu')).toBe(
+ `${CAMPAIGN_ACTIONS_HOME}/atualizar-votos?municipio=cairu&entry=register-signal`,
+ )
+ expect(wizardChainContinueHref('change-trend', 'update-leadership', 'cairu')).toBe(
+ CAMPAIGN_HOME,
+ )
+ expect(wizardChainContinueHref('register-demand', 'update-votes', 'cairu')).toBe(CAMPAIGN_HOME)
+ })
+
+ it('resolves session entry from query or current principal', () => {
+ expect(resolveWizardChainEntry(undefined, 'update-votes')).toBe('update-votes')
+ expect(resolveWizardChainEntry('register-signal', 'update-votes')).toBe('register-signal')
+ expect(resolveWizardChainEntry('register-demand', 'change-trend')).toBe('change-trend')
+ })
+})
diff --git a/tests/unit/wizardExpectedVotesStep.unit.spec.tsx b/tests/unit/wizardExpectedVotesStep.unit.spec.tsx
index d491e428..ab980709 100644
--- a/tests/unit/wizardExpectedVotesStep.unit.spec.tsx
+++ b/tests/unit/wizardExpectedVotesStep.unit.spec.tsx
@@ -3,12 +3,15 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
import { WizardExpectedVotesStep } from '@/components/campaign/shared/WizardExpectedVotesStep'
import { CampaignWizardChromeProvider } from '@/components/campaign/shell/CampaignWizardChromeContext'
+import { CAMPAIGN_ACTIONS_HOME } from '@/lib/campaignActionRoutes'
import { postCampaignJson } from '@/lib/campaignJsonRequest'
+const replaceMock = vi.fn()
+
vi.mock('next/navigation', () => ({
useRouter: () => ({
push: vi.fn(),
- replace: vi.fn(),
+ replace: replaceMock,
}),
}))
@@ -16,6 +19,10 @@ vi.mock('@/lib/campaignJsonRequest', () => ({
postCampaignJson: vi.fn(),
}))
+vi.mock('sonner', () => ({
+ toast: { success: vi.fn() },
+}))
+
const defaultProps = {
actionSlug: 'atualizar-votos',
municipalityId: 1,
@@ -35,6 +42,7 @@ describe('WizardExpectedVotesStep', () => {
afterEach(() => {
cleanup()
vi.mocked(postCampaignJson).mockReset()
+ replaceMock.mockReset()
})
it('applies shortcuts to the focused scenario', () => {
@@ -73,7 +81,7 @@ describe('WizardExpectedVotesStep', () => {
expect(screen.getByLabelText('Pessimista').getAttribute('aria-invalid')).toBeNull()
})
- it('posts batch expected votes when estimates are coherent', async () => {
+ it('posts batch expected votes and continues the wizard chain', async () => {
vi.mocked(postCampaignJson).mockResolvedValue({
ok: true,
payload: {
@@ -97,7 +105,18 @@ describe('WizardExpectedVotesStep', () => {
})
await waitFor(() => {
- expect(screen.getByRole('status').textContent).toMatch(/Votos estimados atualizados/i)
+ expect(replaceMock).toHaveBeenCalledWith(
+ `${CAMPAIGN_ACTIONS_HOME}/mudar-tendencia?municipio=cairu&entry=update-votes`,
+ )
})
})
+
+ it('shows skip to the next chain step when votes is chained', () => {
+ renderVotesStep({ ...defaultProps, entryAction: 'register-signal' })
+
+ const skip = screen.getByRole('link', { name: /Pular ajuste de votos/i })
+ expect(skip.getAttribute('href')).toBe(
+ `${CAMPAIGN_ACTIONS_HOME}/atualizar-lideranca?municipio=cairu&entry=register-signal`,
+ )
+ })
})
diff --git a/tests/unit/wizardLeadershipStep.unit.spec.ts b/tests/unit/wizardLeadershipStep.unit.spec.ts
index 0942e9fd..d30de245 100644
--- a/tests/unit/wizardLeadershipStep.unit.spec.ts
+++ b/tests/unit/wizardLeadershipStep.unit.spec.ts
@@ -1,6 +1,11 @@
import { describe, expect, it } from 'vitest'
-import { showLeadershipWizardSkip } from '@/lib/wizardLeadershipContract'
+import { CAMPAIGN_HOME } from '@/lib/campaignPaths'
+import { WIZARD_LEADERSHIP_SKIP_LABEL } from '@/lib/campaignWizardCopy'
+import {
+ resolveWizardLeadershipSkip,
+ showLeadershipWizardSkip,
+} from '@/lib/wizardLeadershipContract'
describe('showLeadershipWizardSkip', () => {
it('hides skip for standalone entry (implicit update-leadership)', () => {
@@ -15,3 +20,18 @@ describe('showLeadershipWizardSkip', () => {
expect(showLeadershipWizardSkip('update-votes')).toBe(true)
})
})
+
+describe('resolveWizardLeadershipSkip', () => {
+ it('returns undefined for standalone entry', () => {
+ expect(resolveWizardLeadershipSkip(undefined, 'cairu')).toBeUndefined()
+ expect(resolveWizardLeadershipSkip('update-leadership', 'cairu')).toBeUndefined()
+ })
+
+ it('points skip to Início when leadership is the last chained step', () => {
+ // In the v1 matrix, leadership is always the final chained elo.
+ expect(resolveWizardLeadershipSkip('update-votes', 'cairu')).toEqual({
+ label: WIZARD_LEADERSHIP_SKIP_LABEL,
+ href: CAMPAIGN_HOME,
+ })
+ })
+})
diff --git a/tests/unit/wizardSignalUi.unit.spec.ts b/tests/unit/wizardSignalUi.unit.spec.ts
index e3c58467..53eda322 100644
--- a/tests/unit/wizardSignalUi.unit.spec.ts
+++ b/tests/unit/wizardSignalUi.unit.spec.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
-import { CAMPAIGN_HOME } from '@/lib/campaignPaths'
+import { CAMPAIGN_ACTIONS_HOME } from '@/lib/campaignActionRoutes'
import {
municipalitySignalTypeMeta,
municipalitySignalTypeMetaByType,
@@ -16,16 +16,20 @@ describe('wizardSignalUi', () => {
it('hides skip for standalone register-signal entry', () => {
expect(shouldShowWizardSignalSkip(undefined)).toBe(false)
expect(shouldShowWizardSignalSkip('register-signal')).toBe(false)
- expect(resolveWizardSignalSkip(undefined)).toBeUndefined()
- expect(resolveWizardSignalSkip('register-signal')).toBeUndefined()
+ expect(resolveWizardSignalSkip(undefined, 'cairu')).toBeUndefined()
+ expect(resolveWizardSignalSkip('register-signal', 'cairu')).toBeUndefined()
})
- it('shows skip when embedded from another wizard action', () => {
+ 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')).toEqual({
+ expect(resolveWizardSignalSkip('update-votes', 'cairu')).toEqual({
label: WIZARD_SIGNAL_SKIP_LABEL,
- href: CAMPAIGN_HOME,
+ href: `${CAMPAIGN_ACTIONS_HOME}/atualizar-lideranca?municipio=cairu&entry=update-votes`,
+ })
+ expect(resolveWizardSignalSkip('change-trend', 'cairu')).toEqual({
+ label: WIZARD_SIGNAL_SKIP_LABEL,
+ href: `${CAMPAIGN_ACTIONS_HOME}/atualizar-votos?municipio=cairu&entry=change-trend`,
})
})
})