mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-27 06:13:06 +00:00
Merge pull request #214 from fsolla/cursor/pool-i194-81175171-d141
B113 — Wizard mobile thumb-zone, títulos e cores nos ícones
This commit is contained in:
commit
b38850b446
18 changed files with 203 additions and 71 deletions
|
|
@ -104,6 +104,8 @@ export const E2E_AFFECTED_MANIFEST = [
|
||||||
'src/components/campaign/advisor',
|
'src/components/campaign/advisor',
|
||||||
'src/components/campaign/demand',
|
'src/components/campaign/demand',
|
||||||
'src/components/campaign/invite',
|
'src/components/campaign/invite',
|
||||||
|
'src/components/campaign/leadership',
|
||||||
|
'src/components/campaign/municipality',
|
||||||
'src/components/campaign/organization',
|
'src/components/campaign/organization',
|
||||||
'src/components/campaign/stateDeputy',
|
'src/components/campaign/stateDeputy',
|
||||||
'src/components/campaign/suggestion',
|
'src/components/campaign/suggestion',
|
||||||
|
|
@ -113,8 +115,13 @@ export const E2E_AFFECTED_MANIFEST = [
|
||||||
'src/components/campaign/auth',
|
'src/components/campaign/auth',
|
||||||
`${CAMPAIGN_APP}/acoes`,
|
`${CAMPAIGN_APP}/acoes`,
|
||||||
'src/components/campaign/shared/WizardMunicipality',
|
'src/components/campaign/shared/WizardMunicipality',
|
||||||
|
'src/components/campaign/shared/WizardExpectedVotesStep',
|
||||||
'src/components/campaign/shared/useWizardNearestMunicipality',
|
'src/components/campaign/shared/useWizardNearestMunicipality',
|
||||||
'src/lib/wizardMunicipalitySuggestMerge',
|
'src/lib/wizardMunicipalitySuggestMerge',
|
||||||
|
'src/lib/wizardThumbGrid',
|
||||||
|
'src/lib/municipalitySignalTypeMeta',
|
||||||
|
'src/lib/politicalTrendWizardMeta',
|
||||||
|
'src/lib/politicalTrendWizardUi',
|
||||||
`${CAMPAIGN_APP}/apoiadores`,
|
`${CAMPAIGN_APP}/apoiadores`,
|
||||||
`${CAMPAIGN_APP}/assessores`,
|
`${CAMPAIGN_APP}/assessores`,
|
||||||
`${CAMPAIGN_APP}/contatos`,
|
`${CAMPAIGN_APP}/contatos`,
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ import {
|
||||||
WIZARD_LEADERSHIP_EMPTY_NOTES,
|
WIZARD_LEADERSHIP_EMPTY_NOTES,
|
||||||
WIZARD_LEADERSHIP_FORM_CREATE_TITLE,
|
WIZARD_LEADERSHIP_FORM_CREATE_TITLE,
|
||||||
WIZARD_LEADERSHIP_FORM_EDIT_TITLE,
|
WIZARD_LEADERSHIP_FORM_EDIT_TITLE,
|
||||||
WIZARD_LEADERSHIP_GRID_TITLE,
|
|
||||||
WIZARD_LEADERSHIP_SAVED_TOAST,
|
WIZARD_LEADERSHIP_SAVED_TOAST,
|
||||||
WIZARD_LEADERSHIP_STATUS_DRAWER_TITLE,
|
WIZARD_LEADERSHIP_STATUS_DRAWER_TITLE,
|
||||||
WIZARD_LEADERSHIP_STATUS_PENDING,
|
WIZARD_LEADERSHIP_STATUS_PENDING,
|
||||||
|
|
@ -72,6 +71,7 @@ import {
|
||||||
resolveWizardLeadershipSkip,
|
resolveWizardLeadershipSkip,
|
||||||
type WizardLeadershipTileViewModel,
|
type WizardLeadershipTileViewModel,
|
||||||
} from '@/lib/wizardLeadershipContract'
|
} from '@/lib/wizardLeadershipContract'
|
||||||
|
import { WIZARD_THUMB_TILE_GRID_CLASS, WIZARD_THUMB_TILE_ITEM_CLASS } from '@/lib/wizardThumbGrid'
|
||||||
import { fieldError } from '@/utilities/campaignFormFields'
|
import { fieldError } from '@/utilities/campaignFormFields'
|
||||||
import { supportStatusLabels } from '@/utilities/leadership/leadershipLabels'
|
import { supportStatusLabels } from '@/utilities/leadership/leadershipLabels'
|
||||||
|
|
||||||
|
|
@ -143,11 +143,11 @@ export const WizardLeadershipStep = ({
|
||||||
)
|
)
|
||||||
|
|
||||||
const stepTitle =
|
const stepTitle =
|
||||||
mode.kind === 'grid'
|
mode.kind === 'form'
|
||||||
? WIZARD_LEADERSHIP_GRID_TITLE
|
? mode.leadership
|
||||||
: mode.leadership
|
|
||||||
? WIZARD_LEADERSHIP_FORM_EDIT_TITLE
|
? WIZARD_LEADERSHIP_FORM_EDIT_TITLE
|
||||||
: WIZARD_LEADERSHIP_FORM_CREATE_TITLE
|
: WIZARD_LEADERSHIP_FORM_CREATE_TITLE
|
||||||
|
: null
|
||||||
|
|
||||||
const trailingAction = skipConfig ? (
|
const trailingAction = skipConfig ? (
|
||||||
<Button variant="ghost" size="sm" className="min-h-11 px-2 text-sm" asChild>
|
<Button variant="ghost" size="sm" className="min-h-11 px-2 text-sm" asChild>
|
||||||
|
|
@ -213,7 +213,8 @@ export const WizardLeadershipStep = ({
|
||||||
municipalityLabel={municipalityName}
|
municipalityLabel={municipalityName}
|
||||||
skip={skipConfig}
|
skip={skipConfig}
|
||||||
trailingAction={trailingAction}
|
trailingAction={trailingAction}
|
||||||
contentFocus={mode.kind === 'form' ? 'none' : 'title'}
|
contentAlign={mode.kind === 'grid' ? 'end' : 'start'}
|
||||||
|
contentFocus={mode.kind === 'form' ? 'none' : undefined}
|
||||||
clientLayer={mode.kind === 'form' ? WIZARD_LEADERSHIP_FORM_LAYER : undefined}
|
clientLayer={mode.kind === 'form' ? WIZARD_LEADERSHIP_FORM_LAYER : undefined}
|
||||||
onPopClientLayer={handlePopFormLayer}
|
onPopClientLayer={handlePopFormLayer}
|
||||||
>
|
>
|
||||||
|
|
@ -231,9 +232,9 @@ export const WizardLeadershipStep = ({
|
||||||
{tiles.length === 0 ? (
|
{tiles.length === 0 ? (
|
||||||
<p className="text-sm text-muted-foreground">{WIZARD_LEADERSHIP_EMPTY_GRID}</p>
|
<p className="text-sm text-muted-foreground">{WIZARD_LEADERSHIP_EMPTY_GRID}</p>
|
||||||
) : null}
|
) : null}
|
||||||
<ul className="grid grid-cols-2 gap-3 md:grid-cols-3 lg:grid-cols-4">
|
<ul className={cn(WIZARD_THUMB_TILE_GRID_CLASS, 'md:grid-cols-3 lg:grid-cols-4')}>
|
||||||
{tiles.map((tile) => (
|
{tiles.map((tile) => (
|
||||||
<li key={tile.id}>
|
<li key={tile.id} className={WIZARD_THUMB_TILE_ITEM_CLASS}>
|
||||||
<LeadershipTileButton
|
<LeadershipTileButton
|
||||||
tile={tile}
|
tile={tile}
|
||||||
onOpen={() => setMode({ kind: 'form', leadership: tile })}
|
onOpen={() => setMode({ kind: 'form', leadership: tile })}
|
||||||
|
|
@ -243,7 +244,7 @@ export const WizardLeadershipStep = ({
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
<li>
|
<li className={WIZARD_THUMB_TILE_ITEM_CLASS}>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="flex aspect-square w-full flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-border bg-transparent p-3 text-center text-sm text-muted-foreground transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
className="flex aspect-square w-full flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-border bg-transparent p-3 text-center text-sm text-muted-foreground transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useRouter } from 'next/navigation'
|
import { useRouter } from 'next/navigation'
|
||||||
import { useActionState } from 'react'
|
import { useActionState, useState } from 'react'
|
||||||
|
|
||||||
import { createMunicipalityListSignalFormAction } from '@/app/(campaign)/campanha/(app)/municipios/municipalityStaffFormActions'
|
import { createMunicipalityListSignalFormAction } from '@/app/(campaign)/campanha/(app)/municipios/municipalityStaffFormActions'
|
||||||
import { WizardSignalSkipTrailing } from '@/components/campaign/municipality/WizardSignalSkipTrailing'
|
import { WizardSignalSkipTrailing } from '@/components/campaign/municipality/WizardSignalSkipTrailing'
|
||||||
|
|
@ -15,18 +15,13 @@ import type { CampaignWizardActionId } from '@/lib/campaignActionRoutes'
|
||||||
import { recordLastActedMunicipality } from '@/lib/campaignLastActedMunicipality'
|
import { recordLastActedMunicipality } from '@/lib/campaignLastActedMunicipality'
|
||||||
import { wizardFlowTitleForSlug } from '@/lib/campaignWizardCopy'
|
import { wizardFlowTitleForSlug } from '@/lib/campaignWizardCopy'
|
||||||
import type { MunicipalitySignalType } from '@/lib/schemas/municipalityUpdate'
|
import type { MunicipalitySignalType } from '@/lib/schemas/municipalityUpdate'
|
||||||
import { municipalitySignalTypeLabels } from '@/lib/schemas/municipalityUpdate'
|
|
||||||
import {
|
import {
|
||||||
resolveWizardChainEntry,
|
resolveWizardChainEntry,
|
||||||
wizardChainContinueHref,
|
wizardChainContinueHref,
|
||||||
wizardChainEndHref,
|
wizardChainEndHref,
|
||||||
} from '@/lib/wizardActionChain'
|
} from '@/lib/wizardActionChain'
|
||||||
import { wizardStepPreviousHref } from '@/lib/wizardBack'
|
import { wizardStepPreviousHref } from '@/lib/wizardBack'
|
||||||
import {
|
import { resolveWizardSignalSkip, WIZARD_SIGNAL_SAVE_LABEL } from '@/lib/wizardSignalUi'
|
||||||
resolveWizardSignalSkip,
|
|
||||||
WIZARD_SIGNAL_BODY_STEP_TITLE_PREFIX,
|
|
||||||
WIZARD_SIGNAL_SAVE_LABEL,
|
|
||||||
} from '@/lib/wizardSignalUi'
|
|
||||||
|
|
||||||
type WizardSignalBodyStepProps = {
|
type WizardSignalBodyStepProps = {
|
||||||
actionSlug: string
|
actionSlug: string
|
||||||
|
|
@ -48,12 +43,13 @@ export const WizardSignalBodyStep = ({
|
||||||
returnPath,
|
returnPath,
|
||||||
}: WizardSignalBodyStepProps) => {
|
}: WizardSignalBodyStepProps) => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const [body, setBody] = useState('')
|
||||||
const [state, submitAction, isPending] = useActionState(
|
const [state, submitAction, isPending] = useActionState(
|
||||||
createMunicipalityListSignalFormAction,
|
createMunicipalityListSignalFormAction,
|
||||||
{},
|
{},
|
||||||
)
|
)
|
||||||
const skip = resolveWizardSignalSkip(entryAction, municipalitySlug, returnPath)
|
const skip = resolveWizardSignalSkip(entryAction, municipalitySlug, returnPath)
|
||||||
const stepTitle = `${WIZARD_SIGNAL_BODY_STEP_TITLE_PREFIX}: ${municipalitySignalTypeLabels[signalType]}`
|
const canSave = body.trim().length > 0 && !isPending
|
||||||
|
|
||||||
useCampaignFormSuccessToast(state, () => {
|
useCampaignFormSuccessToast(state, () => {
|
||||||
recordLastActedMunicipality(municipalitySlug)
|
recordLastActedMunicipality(municipalitySlug)
|
||||||
|
|
@ -67,7 +63,7 @@ export const WizardSignalBodyStep = ({
|
||||||
<CampaignWizardShell
|
<CampaignWizardShell
|
||||||
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
||||||
isEntryStep={false}
|
isEntryStep={false}
|
||||||
stepTitle={stepTitle}
|
stepTitle={null}
|
||||||
previousHref={wizardStepPreviousHref({
|
previousHref={wizardStepPreviousHref({
|
||||||
step: 'signal-body',
|
step: 'signal-body',
|
||||||
actionSlug,
|
actionSlug,
|
||||||
|
|
@ -98,6 +94,8 @@ export const WizardSignalBodyStep = ({
|
||||||
<Textarea
|
<Textarea
|
||||||
id="wizard-signal-body"
|
id="wizard-signal-body"
|
||||||
name="body"
|
name="body"
|
||||||
|
value={body}
|
||||||
|
onChange={(event) => setBody(event.target.value)}
|
||||||
rows={5}
|
rows={5}
|
||||||
maxLength={5000}
|
maxLength={5000}
|
||||||
required
|
required
|
||||||
|
|
@ -111,7 +109,7 @@ export const WizardSignalBodyStep = ({
|
||||||
{state.status !== 'success' ? <CampaignFormActionMessage state={state} /> : null}
|
{state.status !== 'success' ? <CampaignFormActionMessage state={state} /> : null}
|
||||||
|
|
||||||
<div className="flex justify-end">
|
<div className="flex justify-end">
|
||||||
<Button type="submit" disabled={isPending} className="min-h-11 min-w-[7rem]">
|
<Button type="submit" disabled={!canSave} className="min-h-11 min-w-[7rem]">
|
||||||
{isPending ? (
|
{isPending ? (
|
||||||
<>
|
<>
|
||||||
<Spinner data-icon="inline-start" aria-hidden="true" />
|
<Spinner data-icon="inline-start" aria-hidden="true" />
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { Info } from 'lucide-react'
|
import { Info } from 'lucide-react'
|
||||||
import { useState } from 'react'
|
import { useMemo, useState } from 'react'
|
||||||
|
|
||||||
import { WizardSignalSkipTrailing } from '@/components/campaign/municipality/WizardSignalSkipTrailing'
|
import { WizardSignalSkipTrailing } from '@/components/campaign/municipality/WizardSignalSkipTrailing'
|
||||||
import { CampaignWizardNavLink } from '@/components/campaign/shared/CampaignWizardNavLink'
|
import { CampaignWizardNavLink } from '@/components/campaign/shared/CampaignWizardNavLink'
|
||||||
|
|
@ -20,14 +20,19 @@ import type { CampaignWizardActionId } from '@/lib/campaignActionRoutes'
|
||||||
import { wizardSignalHref } from '@/lib/campaignActionRoutes'
|
import { wizardSignalHref } from '@/lib/campaignActionRoutes'
|
||||||
import { wizardFlowTitleForSlug } from '@/lib/campaignWizardCopy'
|
import { wizardFlowTitleForSlug } from '@/lib/campaignWizardCopy'
|
||||||
import {
|
import {
|
||||||
municipalitySignalTypeMeta,
|
|
||||||
municipalitySignalTypeMetaByType,
|
municipalitySignalTypeMetaByType,
|
||||||
|
type MunicipalitySignalTypeMetaEntry,
|
||||||
} from '@/lib/municipalitySignalTypeMeta'
|
} from '@/lib/municipalitySignalTypeMeta'
|
||||||
import type { MunicipalitySignalType } from '@/lib/schemas/municipalityUpdate'
|
import type { MunicipalitySignalType } from '@/lib/schemas/municipalityUpdate'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
import { wizardChainEndHref } from '@/lib/wizardActionChain'
|
import { wizardChainEndHref } from '@/lib/wizardActionChain'
|
||||||
import { wizardStepPreviousHref } from '@/lib/wizardBack'
|
import { wizardStepPreviousHref } from '@/lib/wizardBack'
|
||||||
import { resolveWizardSignalSkip, WIZARD_SIGNAL_TYPE_STEP_TITLE } from '@/lib/wizardSignalUi'
|
import { resolveWizardSignalSkip } from '@/lib/wizardSignalUi'
|
||||||
|
import {
|
||||||
|
WIZARD_THUMB_TILE_GRID_CLASS,
|
||||||
|
WIZARD_THUMB_TILE_ITEM_CLASS,
|
||||||
|
wizardSignalTypesThumbOrder,
|
||||||
|
} from '@/lib/wizardThumbGrid'
|
||||||
|
|
||||||
type WizardSignalTypeStepProps = {
|
type WizardSignalTypeStepProps = {
|
||||||
actionSlug: string
|
actionSlug: string
|
||||||
|
|
@ -48,12 +53,20 @@ export const WizardSignalTypeStep = ({
|
||||||
const infoEntry = infoType ? municipalitySignalTypeMetaByType[infoType] : null
|
const infoEntry = infoType ? municipalitySignalTypeMetaByType[infoType] : null
|
||||||
const skip = resolveWizardSignalSkip(entryAction, municipalitySlug, returnPath)
|
const skip = resolveWizardSignalSkip(entryAction, municipalitySlug, returnPath)
|
||||||
|
|
||||||
|
const thumbOrderedEntries = useMemo(
|
||||||
|
() =>
|
||||||
|
wizardSignalTypesThumbOrder.map(
|
||||||
|
(type) => municipalitySignalTypeMetaByType[type],
|
||||||
|
) satisfies MunicipalitySignalTypeMetaEntry[],
|
||||||
|
[],
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CampaignWizardShell
|
<CampaignWizardShell
|
||||||
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
||||||
isEntryStep={false}
|
isEntryStep={false}
|
||||||
stepTitle={WIZARD_SIGNAL_TYPE_STEP_TITLE}
|
stepTitle={null}
|
||||||
previousHref={wizardStepPreviousHref({
|
previousHref={wizardStepPreviousHref({
|
||||||
step: 'signal-type',
|
step: 'signal-type',
|
||||||
actionSlug,
|
actionSlug,
|
||||||
|
|
@ -65,11 +78,11 @@ export const WizardSignalTypeStep = ({
|
||||||
skip={skip}
|
skip={skip}
|
||||||
trailingAction={skip ? <WizardSignalSkipTrailing skip={skip} /> : undefined}
|
trailingAction={skip ? <WizardSignalSkipTrailing skip={skip} /> : undefined}
|
||||||
>
|
>
|
||||||
<ul className="grid list-none grid-cols-2 gap-3 md:grid-cols-3">
|
<ul className={WIZARD_THUMB_TILE_GRID_CLASS}>
|
||||||
{municipalitySignalTypeMeta.map((entry) => {
|
{thumbOrderedEntries.map((entry) => {
|
||||||
const Icon = entry.icon
|
const Icon = entry.icon
|
||||||
return (
|
return (
|
||||||
<li key={entry.type} className="relative">
|
<li key={entry.type} className={cn('relative', WIZARD_THUMB_TILE_ITEM_CLASS)}>
|
||||||
<CampaignWizardNavLink
|
<CampaignWizardNavLink
|
||||||
href={wizardSignalHref(
|
href={wizardSignalHref(
|
||||||
actionSlug,
|
actionSlug,
|
||||||
|
|
@ -79,13 +92,13 @@ export const WizardSignalTypeStep = ({
|
||||||
returnPath,
|
returnPath,
|
||||||
)}
|
)}
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex aspect-square w-full flex-col justify-between rounded-lg border border-border bg-transparent p-3 pr-10 text-left',
|
'flex aspect-square w-full flex-col justify-between rounded-lg border border-border bg-background p-3 pr-10 text-left text-foreground',
|
||||||
'transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
'transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Icon className="size-5 shrink-0 text-foreground" aria-hidden />
|
<Icon className={cn('size-5 shrink-0', entry.iconClassName)} aria-hidden />
|
||||||
<div className="flex flex-col gap-0.5">
|
<div className="flex flex-col gap-0.5">
|
||||||
<span className="text-sm font-medium text-foreground">{entry.label}</span>
|
<span className="text-sm font-medium">{entry.label}</span>
|
||||||
<span className="line-clamp-2 text-xs text-muted-foreground">
|
<span className="line-clamp-2 text-xs text-muted-foreground">
|
||||||
{entry.shortDescription}
|
{entry.shortDescription}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import { useState } from 'react'
|
||||||
import { WizardTrendSkipTrailing } from '@/components/campaign/municipality/WizardTrendSkipTrailing'
|
import { WizardTrendSkipTrailing } from '@/components/campaign/municipality/WizardTrendSkipTrailing'
|
||||||
import { CampaignWizardNavLink } from '@/components/campaign/shared/CampaignWizardNavLink'
|
import { CampaignWizardNavLink } from '@/components/campaign/shared/CampaignWizardNavLink'
|
||||||
import { CampaignWizardShell } from '@/components/campaign/shared/CampaignWizardShell'
|
import { CampaignWizardShell } from '@/components/campaign/shared/CampaignWizardShell'
|
||||||
|
import { Badge } from '@/components/ui/Badge'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import {
|
import {
|
||||||
Drawer,
|
Drawer,
|
||||||
|
|
@ -26,12 +27,13 @@ import {
|
||||||
import {
|
import {
|
||||||
resolveWizardTrendSkip,
|
resolveWizardTrendSkip,
|
||||||
selectablePoliticalTrendStatuses,
|
selectablePoliticalTrendStatuses,
|
||||||
wizardTrendChoiceStepTitle,
|
WIZARD_CURRENT_TREND_CHIP_LABEL,
|
||||||
} from '@/lib/politicalTrendWizardUi'
|
} from '@/lib/politicalTrendWizardUi'
|
||||||
import type { PoliticalTrendStatusValue } from '@/lib/schemas/municipality'
|
import type { PoliticalTrendStatusValue } from '@/lib/schemas/municipality'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
import { wizardChainEndHref } from '@/lib/wizardActionChain'
|
import { wizardChainEndHref } from '@/lib/wizardActionChain'
|
||||||
import { wizardStepPreviousHref } from '@/lib/wizardBack'
|
import { wizardStepPreviousHref } from '@/lib/wizardBack'
|
||||||
|
import { WIZARD_THUMB_TILE_GRID_CLASS, WIZARD_THUMB_TILE_ITEM_CLASS } from '@/lib/wizardThumbGrid'
|
||||||
|
|
||||||
type WizardTrendChoiceStepProps = {
|
type WizardTrendChoiceStepProps = {
|
||||||
actionSlug: string
|
actionSlug: string
|
||||||
|
|
@ -43,6 +45,30 @@ type WizardTrendChoiceStepProps = {
|
||||||
returnPath?: string
|
returnPath?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CurrentTrendCard = ({ entry }: { entry: PoliticalTrendWizardMetaEntry }) => {
|
||||||
|
const Icon = entry.icon
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'col-span-2 flex items-center justify-between gap-3 rounded-lg border border-border bg-background p-3',
|
||||||
|
WIZARD_THUMB_TILE_ITEM_CLASS,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div className="flex min-w-0 items-center gap-3">
|
||||||
|
<Icon className={cn('size-5 shrink-0', entry.iconClassName)} aria-hidden />
|
||||||
|
<div className="min-w-0">
|
||||||
|
<p className="truncate text-sm font-medium">{entry.label}</p>
|
||||||
|
<p className="line-clamp-2 text-xs text-muted-foreground">{entry.changeDescription}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Badge variant="secondary" className="shrink-0">
|
||||||
|
{WIZARD_CURRENT_TREND_CHIP_LABEL}
|
||||||
|
</Badge>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export const WizardTrendChoiceStep = ({
|
export const WizardTrendChoiceStep = ({
|
||||||
actionSlug,
|
actionSlug,
|
||||||
municipalityName,
|
municipalityName,
|
||||||
|
|
@ -55,13 +81,14 @@ export const WizardTrendChoiceStep = ({
|
||||||
const [infoEntry, setInfoEntry] = useState<PoliticalTrendWizardMetaEntry | null>(null)
|
const [infoEntry, setInfoEntry] = useState<PoliticalTrendWizardMetaEntry | null>(null)
|
||||||
const skip = resolveWizardTrendSkip(entryAction, municipalitySlug, returnPath)
|
const skip = resolveWizardTrendSkip(entryAction, municipalitySlug, returnPath)
|
||||||
const options = selectablePoliticalTrendStatuses(currentStatus)
|
const options = selectablePoliticalTrendStatuses(currentStatus)
|
||||||
|
const currentEntry = currentStatus ? politicalTrendWizardMetaByStatus[currentStatus] : null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CampaignWizardShell
|
<CampaignWizardShell
|
||||||
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
||||||
isEntryStep={false}
|
isEntryStep={false}
|
||||||
stepTitle={wizardTrendChoiceStepTitle(currentStatus)}
|
stepTitle={null}
|
||||||
previousHref={wizardStepPreviousHref({
|
previousHref={wizardStepPreviousHref({
|
||||||
step: 'trend-choice',
|
step: 'trend-choice',
|
||||||
actionSlug,
|
actionSlug,
|
||||||
|
|
@ -71,13 +98,15 @@ export const WizardTrendChoiceStep = ({
|
||||||
municipalityLabel={municipalityName}
|
municipalityLabel={municipalityName}
|
||||||
skip={skip}
|
skip={skip}
|
||||||
trailingAction={skip ? <WizardTrendSkipTrailing skip={skip} /> : undefined}
|
trailingAction={skip ? <WizardTrendSkipTrailing skip={skip} /> : undefined}
|
||||||
|
contentAlign="end"
|
||||||
>
|
>
|
||||||
<ul className="grid list-none grid-cols-2 gap-3 md:grid-cols-3">
|
<ul className={WIZARD_THUMB_TILE_GRID_CLASS}>
|
||||||
|
{currentEntry ? <CurrentTrendCard entry={currentEntry} /> : null}
|
||||||
{options.map((status) => {
|
{options.map((status) => {
|
||||||
const entry = politicalTrendWizardMetaByStatus[status]
|
const entry = politicalTrendWizardMetaByStatus[status]
|
||||||
const Icon = entry.icon
|
const Icon = entry.icon
|
||||||
return (
|
return (
|
||||||
<li key={status} className="relative">
|
<li key={status} className={cn('relative', WIZARD_THUMB_TILE_ITEM_CLASS)}>
|
||||||
<CampaignWizardNavLink
|
<CampaignWizardNavLink
|
||||||
href={wizardTrendHref(
|
href={wizardTrendHref(
|
||||||
actionSlug,
|
actionSlug,
|
||||||
|
|
@ -88,15 +117,14 @@ export const WizardTrendChoiceStep = ({
|
||||||
returnPath,
|
returnPath,
|
||||||
)}
|
)}
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex aspect-square w-full flex-col justify-between rounded-lg border bg-background p-3 pr-10 text-left',
|
'flex aspect-square w-full flex-col justify-between rounded-lg border border-border bg-background p-3 pr-10 text-left text-foreground',
|
||||||
entry.tileClassName,
|
|
||||||
'transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
'transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Icon className="size-5 shrink-0" aria-hidden />
|
<Icon className={cn('size-5 shrink-0', entry.iconClassName)} aria-hidden />
|
||||||
<div className="flex flex-col gap-0.5">
|
<div className="flex flex-col gap-0.5">
|
||||||
<span className="text-sm font-medium">{entry.label}</span>
|
<span className="text-sm font-medium">{entry.label}</span>
|
||||||
<span className="line-clamp-2 text-xs opacity-80">
|
<span className="line-clamp-2 text-xs text-muted-foreground">
|
||||||
{entry.changeDescription}
|
{entry.changeDescription}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import {
|
||||||
WIZARD_VOTES_FINAL_CTA_LABEL,
|
WIZARD_VOTES_FINAL_CTA_LABEL,
|
||||||
WIZARD_VOTES_SAVED_MESSAGE,
|
WIZARD_VOTES_SAVED_MESSAGE,
|
||||||
wizardFlowTitleForSlug,
|
wizardFlowTitleForSlug,
|
||||||
wizardNextStepTitle,
|
|
||||||
} from '@/lib/campaignWizardCopy'
|
} from '@/lib/campaignWizardCopy'
|
||||||
import { type VoteEstimateScenario, type VoteEstimateScenarioViewModel } from '@/lib/voteEstimate'
|
import { type VoteEstimateScenario, type VoteEstimateScenarioViewModel } from '@/lib/voteEstimate'
|
||||||
import {
|
import {
|
||||||
|
|
@ -136,7 +135,7 @@ export const WizardExpectedVotesStep = ({
|
||||||
return (
|
return (
|
||||||
<CampaignWizardShell
|
<CampaignWizardShell
|
||||||
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
||||||
stepTitle={wizardNextStepTitle(actionSlug)}
|
stepTitle={null}
|
||||||
isEntryStep={false}
|
isEntryStep={false}
|
||||||
previousHref={wizardStepPreviousHref({
|
previousHref={wizardStepPreviousHref({
|
||||||
step: 'expected-votes',
|
step: 'expected-votes',
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,6 @@ export const wizardNextStepTitle = (actionSlug: string): string => {
|
||||||
export const wizardNextStepPlaceholder = (_actionSlug: string): string =>
|
export const wizardNextStepPlaceholder = (_actionSlug: string): string =>
|
||||||
WIZARD_NEXT_STEP_GENERIC_PLACEHOLDER
|
WIZARD_NEXT_STEP_GENERIC_PLACEHOLDER
|
||||||
|
|
||||||
export const WIZARD_LEADERSHIP_GRID_TITLE = 'Quem coordena por aqui?' as const
|
|
||||||
|
|
||||||
export const WIZARD_LEADERSHIP_FORM_CREATE_TITLE = 'Nova liderança' as const
|
export const WIZARD_LEADERSHIP_FORM_CREATE_TITLE = 'Nova liderança' as const
|
||||||
|
|
||||||
export const WIZARD_LEADERSHIP_FORM_EDIT_TITLE = 'Atualizar liderança' as const
|
export const WIZARD_LEADERSHIP_FORM_EDIT_TITLE = 'Atualizar liderança' as const
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ export type MunicipalitySignalTypeMetaEntry = {
|
||||||
shortDescription: string
|
shortDescription: string
|
||||||
infoContent: string
|
infoContent: string
|
||||||
icon: LucideIcon
|
icon: LucideIcon
|
||||||
|
iconClassName: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const signalTypeIcons: Record<MunicipalitySignalType, LucideIcon> = {
|
const signalTypeIcons: Record<MunicipalitySignalType, LucideIcon> = {
|
||||||
|
|
@ -30,6 +31,14 @@ const signalTypeIcons: Record<MunicipalitySignalType, LucideIcon> = {
|
||||||
outro: CircleHelp,
|
outro: CircleHelp,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const signalTypeIconClassNames: Record<MunicipalitySignalType, string> = {
|
||||||
|
invasao: 'text-destructive',
|
||||||
|
esfriamento: 'text-sky-600',
|
||||||
|
visita_adversario: 'text-amber-600',
|
||||||
|
proposta_broker: 'text-teal-600',
|
||||||
|
outro: 'text-muted-foreground',
|
||||||
|
}
|
||||||
|
|
||||||
const signalTypeInfoContent: Record<MunicipalitySignalType, string> = {
|
const signalTypeInfoContent: Record<MunicipalitySignalType, string> = {
|
||||||
invasao:
|
invasao:
|
||||||
'O adversário está ocupando espaço que era nosso: reunião, base, narrativa ou presença no território. Consequência: a rede pode esfriar ou a leitura do município muda. Use quando a equipe perceber invasão real, não só boatos.',
|
'O adversário está ocupando espaço que era nosso: reunião, base, narrativa ou presença no território. Consequência: a rede pode esfriar ou a leitura do município muda. Use quando a equipe perceber invasão real, não só boatos.',
|
||||||
|
|
@ -50,6 +59,7 @@ export const municipalitySignalTypeMeta: MunicipalitySignalTypeMetaEntry[] =
|
||||||
shortDescription: municipalitySignalTypeDescriptions[type],
|
shortDescription: municipalitySignalTypeDescriptions[type],
|
||||||
infoContent: signalTypeInfoContent[type],
|
infoContent: signalTypeInfoContent[type],
|
||||||
icon: signalTypeIcons[type],
|
icon: signalTypeIcons[type],
|
||||||
|
iconClassName: signalTypeIconClassNames[type],
|
||||||
}))
|
}))
|
||||||
|
|
||||||
export const municipalitySignalTypeMetaByType = Object.fromEntries(
|
export const municipalitySignalTypeMetaByType = Object.fromEntries(
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ export type PoliticalTrendWizardMetaEntry = {
|
||||||
changeDescription: string
|
changeDescription: string
|
||||||
infoContent: string
|
infoContent: string
|
||||||
icon: LucideIcon
|
icon: LucideIcon
|
||||||
tileClassName: string
|
iconClassName: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const trendIcons: Record<PoliticalTrendStatusValue, LucideIcon> = {
|
const trendIcons: Record<PoliticalTrendStatusValue, LucideIcon> = {
|
||||||
|
|
@ -23,10 +23,10 @@ const trendIcons: Record<PoliticalTrendStatusValue, LucideIcon> = {
|
||||||
desfavoravel: ThumbsDown,
|
desfavoravel: ThumbsDown,
|
||||||
}
|
}
|
||||||
|
|
||||||
const trendTileClassNames: Record<PoliticalTrendStatusValue, string> = {
|
const trendIconClassNames: Record<PoliticalTrendStatusValue, string> = {
|
||||||
favoravel: 'border-estimate-confirmed-foreground text-estimate-confirmed-foreground',
|
favoravel: 'text-estimate-confirmed-foreground',
|
||||||
neutra: 'border-border text-foreground',
|
neutra: 'text-muted-foreground',
|
||||||
desfavoravel: 'border-destructive text-destructive',
|
desfavoravel: 'text-destructive',
|
||||||
}
|
}
|
||||||
|
|
||||||
const trendInfoContent: Record<PoliticalTrendStatusValue, string> = {
|
const trendInfoContent: Record<PoliticalTrendStatusValue, string> = {
|
||||||
|
|
@ -45,7 +45,7 @@ export const politicalTrendWizardMeta: PoliticalTrendWizardMetaEntry[] = politic
|
||||||
changeDescription: `Mudar tendência para ${politicalTrendDisplayLabels[status]}`,
|
changeDescription: `Mudar tendência para ${politicalTrendDisplayLabels[status]}`,
|
||||||
infoContent: trendInfoContent[status],
|
infoContent: trendInfoContent[status],
|
||||||
icon: trendIcons[status],
|
icon: trendIcons[status],
|
||||||
tileClassName: trendTileClassNames[status],
|
iconClassName: trendIconClassNames[status],
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ export const WIZARD_TREND_SAVED_MESSAGE = 'Tendência política registrada.' as
|
||||||
|
|
||||||
export const WIZARD_TREND_UNREGISTERED_TITLE = 'Tendência não registrada' as const
|
export const WIZARD_TREND_UNREGISTERED_TITLE = 'Tendência não registrada' as const
|
||||||
|
|
||||||
|
export const WIZARD_CURRENT_TREND_CHIP_LABEL = 'Atual' as const
|
||||||
|
|
||||||
export type WizardTrendSkipAction = {
|
export type WizardTrendSkipAction = {
|
||||||
label: string
|
label: string
|
||||||
href: string
|
href: string
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,6 @@ import type { CampaignWizardActionId } from '@/lib/campaignActionRoutes'
|
||||||
import { WIZARD_CHAIN_SKIP_LABEL } from '@/lib/campaignWizardCopy'
|
import { WIZARD_CHAIN_SKIP_LABEL } from '@/lib/campaignWizardCopy'
|
||||||
import { resolveWizardChainEntry, wizardChainContinueHref } from '@/lib/wizardActionChain'
|
import { resolveWizardChainEntry, wizardChainContinueHref } from '@/lib/wizardActionChain'
|
||||||
|
|
||||||
export const WIZARD_SIGNAL_TYPE_STEP_TITLE = 'Que tipo de sinal?' as const
|
|
||||||
|
|
||||||
export const WIZARD_SIGNAL_BODY_STEP_TITLE_PREFIX = 'Detalhar sinal' as const
|
|
||||||
|
|
||||||
export const WIZARD_SIGNAL_SAVE_LABEL = 'Salvar' as const
|
export const WIZARD_SIGNAL_SAVE_LABEL = 'Salvar' as const
|
||||||
|
|
||||||
export const WIZARD_SIGNAL_SAVED_MESSAGE = 'Sinal registrado.' as const
|
export const WIZARD_SIGNAL_SAVED_MESSAGE = 'Sinal registrado.' as const
|
||||||
|
|
|
||||||
17
src/lib/wizardThumbGrid.ts
Normal file
17
src/lib/wizardThumbGrid.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
import type { MunicipalitySignalType } from '@/lib/schemas/municipalityUpdate'
|
||||||
|
|
||||||
|
/** Thumb-zone grid: mobile fills from bottom-right; desktop is a normal LTR grid. */
|
||||||
|
export const WIZARD_THUMB_TILE_GRID_CLASS =
|
||||||
|
'grid list-none grid-cols-2 gap-3 place-content-end [direction:rtl] md:grid-cols-3 md:place-content-start md:[direction:ltr]'
|
||||||
|
|
||||||
|
/** Reset text direction inside an RTL thumb grid cell. */
|
||||||
|
export const WIZARD_THUMB_TILE_ITEM_CLASS = '[direction:ltr]'
|
||||||
|
|
||||||
|
/** Signal types ordered for thumb reach — urgency types render last in DOM (= bottom-right on mobile). */
|
||||||
|
export const wizardSignalTypesThumbOrder: MunicipalitySignalType[] = [
|
||||||
|
'invasao',
|
||||||
|
'esfriamento',
|
||||||
|
'visita_adversario',
|
||||||
|
'proposta_broker',
|
||||||
|
'outro',
|
||||||
|
]
|
||||||
|
|
@ -3,6 +3,9 @@ import type { Page } from '@playwright/test'
|
||||||
import { WIZARD_MUNICIPALITY_STEP_TITLE } from '../../src/lib/campaignWizardCopy.js'
|
import { WIZARD_MUNICIPALITY_STEP_TITLE } from '../../src/lib/campaignWizardCopy.js'
|
||||||
import { expect, test } from './fixtures/campaignE2EFixtures.js'
|
import { expect, test } from './fixtures/campaignE2EFixtures.js'
|
||||||
|
|
||||||
|
const wizardMainForFlow = (page: Page, flowTitle: string) =>
|
||||||
|
page.getByRole('main', { name: new RegExp(`Ação: ${flowTitle}`, 'i') })
|
||||||
|
|
||||||
const staffActionLabels = [
|
const staffActionLabels = [
|
||||||
'Ajustar votos',
|
'Ajustar votos',
|
||||||
'Registrar sinal',
|
'Registrar sinal',
|
||||||
|
|
@ -175,7 +178,7 @@ test.describe('Wizard — busca município (B60)', () => {
|
||||||
await search.fill(municipality.name)
|
await search.fill(municipality.name)
|
||||||
|
|
||||||
const results = page.getByRole('region', { name: WIZARD_MUNICIPALITY_STEP_TITLE })
|
const results = page.getByRole('region', { name: WIZARD_MUNICIPALITY_STEP_TITLE })
|
||||||
const hit = results.locator(`a[href*="municipio=${municipality.slug}"]`)
|
const hit = results.locator(`a[href$="municipio=${municipality.slug}"]`)
|
||||||
await expect(hit).toBeVisible({ timeout: 15000 })
|
await expect(hit).toBeVisible({ timeout: 15000 })
|
||||||
await hit.click()
|
await hit.click()
|
||||||
|
|
||||||
|
|
@ -187,13 +190,12 @@ test.describe('Wizard — busca município (B60)', () => {
|
||||||
await expect(
|
await expect(
|
||||||
page.getByLabel(new RegExp(`^Município em atualização: ${municipality.name}`, 'i')),
|
page.getByLabel(new RegExp(`^Município em atualização: ${municipality.name}`, 'i')),
|
||||||
).toBeVisible()
|
).toBeVisible()
|
||||||
await expect(page.getByRole('heading', { name: 'Ajustar votos estimados' })).toBeVisible()
|
await expect(page.getByRole('textbox', { name: 'Média' })).toBeVisible()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test.describe('Wizard — ajuste de votos (B61 / B77)', () => {
|
test.describe('Wizard — ajuste de votos (B61 / B77)', () => {
|
||||||
const wizardVoteStep = (page: Page) =>
|
const wizardVoteStep = (page: Page) => wizardMainForFlow(page, 'Ajustar votos')
|
||||||
page.getByRole('main', { name: /Ajustar votos estimados/i })
|
|
||||||
|
|
||||||
test('shows three scenario inputs and saves without cenario param', async ({
|
test('shows three scenario inputs and saves without cenario param', async ({
|
||||||
campaign,
|
campaign,
|
||||||
|
|
@ -209,10 +211,9 @@ test.describe('Wizard — ajuste de votos (B61 / B77)', () => {
|
||||||
await page.goto(`/campanha/acoes/atualizar-votos?municipio=${municipality.slug}`)
|
await page.goto(`/campanha/acoes/atualizar-votos?municipio=${municipality.slug}`)
|
||||||
|
|
||||||
const step = wizardVoteStep(page)
|
const step = wizardVoteStep(page)
|
||||||
await expect(page.getByRole('heading', { name: 'Ajustar votos estimados' })).toBeVisible({
|
await expect(step.getByRole('textbox', { name: 'Pessimista' })).toBeVisible({
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
})
|
})
|
||||||
await expect(step.getByRole('textbox', { name: 'Pessimista' })).toBeVisible()
|
|
||||||
await expect(step.getByRole('textbox', { name: 'Média' })).toBeVisible()
|
await expect(step.getByRole('textbox', { name: 'Média' })).toBeVisible()
|
||||||
await expect(step.getByRole('textbox', { name: 'Otimista' })).toBeVisible()
|
await expect(step.getByRole('textbox', { name: 'Otimista' })).toBeVisible()
|
||||||
|
|
||||||
|
|
@ -243,11 +244,11 @@ test.describe('Wizard — ajuste de votos (B61 / B77)', () => {
|
||||||
await campaign.login(page, coordinator.email!, coordinator.password)
|
await campaign.login(page, coordinator.email!, coordinator.password)
|
||||||
await page.goto(`/campanha/acoes/atualizar-votos?municipio=${municipality.slug}`)
|
await page.goto(`/campanha/acoes/atualizar-votos?municipio=${municipality.slug}`)
|
||||||
|
|
||||||
await expect(page.getByRole('heading', { name: 'Ajustar votos estimados' })).toBeVisible({
|
const step = wizardVoteStep(page)
|
||||||
|
await expect(step.getByRole('textbox', { name: 'Pessimista' })).toBeVisible({
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
})
|
})
|
||||||
|
|
||||||
const step = wizardVoteStep(page)
|
|
||||||
await step.getByRole('textbox', { name: 'Pessimista' }).fill('900')
|
await step.getByRole('textbox', { name: 'Pessimista' }).fill('900')
|
||||||
await step.getByRole('textbox', { name: 'Média' }).fill('100')
|
await step.getByRole('textbox', { name: 'Média' }).fill('100')
|
||||||
await page.getByRole('button', { name: 'Salvar estimativas →' }).click()
|
await page.getByRole('button', { name: 'Salvar estimativas →' }).click()
|
||||||
|
|
@ -273,7 +274,7 @@ test.describe('Wizard — ajuste de votos (B61 / B77)', () => {
|
||||||
`^https?://[^/]+/campanha/acoes/atualizar-votos\\?municipio=${municipality.slug}$`,
|
`^https?://[^/]+/campanha/acoes/atualizar-votos\\?municipio=${municipality.slug}$`,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
await expect(page.getByRole('heading', { name: 'Ajustar votos estimados' })).toBeVisible({
|
await expect(wizardVoteStep(page).getByRole('textbox', { name: 'Média' })).toBeVisible({
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
@ -291,7 +292,7 @@ test.describe('Wizard — atualizar liderança (B70)', () => {
|
||||||
await campaign.login(page, coordinator.email!, coordinator.password)
|
await campaign.login(page, coordinator.email!, coordinator.password)
|
||||||
await page.goto(`/campanha/acoes/atualizar-lideranca?municipio=${municipality.slug}`)
|
await page.goto(`/campanha/acoes/atualizar-lideranca?municipio=${municipality.slug}`)
|
||||||
|
|
||||||
await expect(page.getByRole('heading', { name: 'Quem coordena por aqui?' })).toBeVisible({
|
await expect(page.getByRole('button', { name: 'Adicionar liderança' })).toBeVisible({
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -302,10 +303,9 @@ test.describe('Wizard — atualizar liderança (B70)', () => {
|
||||||
await page.getByLabel('Celular').fill(`719${suffix}`)
|
await page.getByLabel('Celular').fill(`719${suffix}`)
|
||||||
await page.getByRole('button', { name: 'Salvar' }).click()
|
await page.getByRole('button', { name: 'Salvar' }).click()
|
||||||
|
|
||||||
await expect(page.getByRole('heading', { name: 'Quem coordena por aqui?' })).toBeVisible({
|
await expect(page.getByRole('button', { name: 'Continuar' })).toBeVisible({
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
})
|
})
|
||||||
await expect(page.getByRole('button', { name: 'Continuar' })).toBeVisible()
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'Continuar' }).click()
|
await page.getByRole('button', { name: 'Continuar' }).click()
|
||||||
await page.waitForURL(
|
await page.waitForURL(
|
||||||
|
|
@ -313,11 +313,13 @@ test.describe('Wizard — atualizar liderança (B70)', () => {
|
||||||
`/campanha/acoes/registrar-sinal\\?municipio=${municipality.slug}&entry=update-leadership`,
|
`/campanha/acoes/registrar-sinal\\?municipio=${municipality.slug}&entry=update-leadership`,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
await expect(page.getByRole('heading', { name: 'Que tipo de sinal?' })).toBeVisible()
|
await expect(page.getByRole('link', { name: /Invasão/i })).toBeVisible()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test.describe('Wizard — registrar sinal (B63)', () => {
|
test.describe('Wizard — registrar sinal (B63)', () => {
|
||||||
|
const wizardSignalTypeStep = (page: Page) => wizardMainForFlow(page, 'Registrar sinal')
|
||||||
|
|
||||||
test('standalone flow: type grid, body step, save continues the chain', async ({
|
test('standalone flow: type grid, body step, save continues the chain', async ({
|
||||||
campaign,
|
campaign,
|
||||||
page,
|
page,
|
||||||
|
|
@ -332,15 +334,16 @@ test.describe('Wizard — registrar sinal (B63)', () => {
|
||||||
await campaign.login(page, coordinator.email!, coordinator.password)
|
await campaign.login(page, coordinator.email!, coordinator.password)
|
||||||
await page.goto(`/campanha/acoes/registrar-sinal?municipio=${municipality.slug}`)
|
await page.goto(`/campanha/acoes/registrar-sinal?municipio=${municipality.slug}`)
|
||||||
|
|
||||||
await expect(page.getByRole('heading', { name: 'Que tipo de sinal?' })).toBeVisible({
|
const typeStep = wizardSignalTypeStep(page)
|
||||||
|
await expect(typeStep.getByRole('link', { name: /Invasão/i })).toBeVisible({
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
})
|
})
|
||||||
await expect(page.getByRole('link', { name: 'Pular' })).toHaveCount(0)
|
await expect(page.getByRole('link', { name: 'Pular' })).toHaveCount(0)
|
||||||
|
|
||||||
await page.getByRole('link', { name: /Invasão/i }).click()
|
await typeStep.getByRole('link', { name: /Invasão/i }).click()
|
||||||
await page.waitForURL(/signalType=invasao/)
|
await page.waitForURL(/signalType=invasao/)
|
||||||
|
|
||||||
await expect(page.getByRole('heading', { name: /Detalhar sinal: Invasão/i })).toBeVisible()
|
await expect(page.getByLabel('O que aconteceu?')).toBeVisible()
|
||||||
|
|
||||||
const body = page.getByLabel('O que aconteceu?')
|
const body = page.getByLabel('O que aconteceu?')
|
||||||
await body.fill('Adversário marcou presença no centro do município.')
|
await body.fill('Adversário marcou presença no centro do município.')
|
||||||
|
|
@ -364,7 +367,8 @@ test.describe('Wizard — registrar sinal (B63)', () => {
|
||||||
await campaign.login(page, coordinator.email!, coordinator.password)
|
await campaign.login(page, coordinator.email!, coordinator.password)
|
||||||
await page.goto(`/campanha/acoes/registrar-sinal?municipio=${municipality.slug}`)
|
await page.goto(`/campanha/acoes/registrar-sinal?municipio=${municipality.slug}`)
|
||||||
|
|
||||||
await expect(page.getByRole('heading', { name: 'Que tipo de sinal?' })).toBeVisible({
|
const typeStep = wizardSignalTypeStep(page)
|
||||||
|
await expect(typeStep.getByRole('link', { name: /Invasão/i })).toBeVisible({
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,10 @@ test.describe('Wizard — header mobile (B75)', () => {
|
||||||
await campaign.login(page, coordinator.email!, coordinator.password)
|
await campaign.login(page, coordinator.email!, coordinator.password)
|
||||||
await page.goto(`/campanha/acoes/atualizar-votos?municipio=${municipality.slug}`)
|
await page.goto(`/campanha/acoes/atualizar-votos?municipio=${municipality.slug}`)
|
||||||
|
|
||||||
await expect(page.getByRole('heading', { name: 'Ajustar votos estimados' })).toBeVisible({
|
await expect(page.getByRole('main', { name: /Ação: Ajustar votos/i })).toBeVisible({
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
})
|
})
|
||||||
|
await expect(page.getByRole('textbox', { name: 'Média' })).toBeVisible()
|
||||||
|
|
||||||
const topBar = page.locator('[data-slot="campaign-mobile-top-bar"][data-mode="wizard"]')
|
const topBar = page.locator('[data-slot="campaign-mobile-top-bar"][data-mode="wizard"]')
|
||||||
await expect(topBar.getByText('Ajustar votos', { exact: true })).toBeVisible()
|
await expect(topBar.getByText('Ajustar votos', { exact: true })).toBeVisible()
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ describe('politicalTrendWizardMeta', () => {
|
||||||
expect(entry.changeDescription).toContain(entry.label)
|
expect(entry.changeDescription).toContain(entry.label)
|
||||||
expect(entry.infoContent.length).toBeGreaterThan(20)
|
expect(entry.infoContent.length).toBeGreaterThan(20)
|
||||||
expect(entry.icon).toBeTruthy()
|
expect(entry.icon).toBeTruthy()
|
||||||
expect(entry.tileClassName.length).toBeGreaterThan(0)
|
expect(entry.iconClassName.length).toBeGreaterThan(0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ describe('WizardExpectedVotesStep', () => {
|
||||||
fireEvent.change(screen.getByLabelText('Pessimista'), { target: { value: '900' } })
|
fireEvent.change(screen.getByLabelText('Pessimista'), { target: { value: '900' } })
|
||||||
fireEvent.click(screen.getByRole('button', { name: 'Salvar estimativas →' }))
|
fireEvent.click(screen.getByRole('button', { name: 'Salvar estimativas →' }))
|
||||||
|
|
||||||
const step = screen.getByRole('main', { name: /Ajustar votos estimados/i })
|
const step = screen.getByRole('main', { name: /Ação: Ajustar votos/i })
|
||||||
expect(within(step).getByRole('alert').textContent).toMatch(/Pessimista/i)
|
expect(within(step).getByRole('alert').textContent).toMatch(/Pessimista/i)
|
||||||
expect(screen.getByLabelText('Pessimista').getAttribute('aria-invalid')).toBe('true')
|
expect(screen.getByLabelText('Pessimista').getAttribute('aria-invalid')).toBe('true')
|
||||||
expect(screen.getByLabelText('Média').getAttribute('aria-invalid')).toBe('true')
|
expect(screen.getByLabelText('Média').getAttribute('aria-invalid')).toBe('true')
|
||||||
|
|
@ -88,7 +88,7 @@ describe('WizardExpectedVotesStep', () => {
|
||||||
fireEvent.change(screen.getByLabelText('Pessimista'), { target: { value: '900' } })
|
fireEvent.change(screen.getByLabelText('Pessimista'), { target: { value: '900' } })
|
||||||
fireEvent.click(screen.getByRole('button', { name: 'Salvar estimativas →' }))
|
fireEvent.click(screen.getByRole('button', { name: 'Salvar estimativas →' }))
|
||||||
|
|
||||||
const step = screen.getByRole('main', { name: /Ajustar votos estimados/i })
|
const step = screen.getByRole('main', { name: /Ação: Ajustar votos/i })
|
||||||
expect(within(step).getByRole('alert')).toBeTruthy()
|
expect(within(step).getByRole('alert')).toBeTruthy()
|
||||||
|
|
||||||
fireEvent.change(screen.getByLabelText('Média'), { target: { value: '950' } })
|
fireEvent.change(screen.getByLabelText('Média'), { target: { value: '950' } })
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ describe('municipalitySignalTypeMeta', () => {
|
||||||
expect(entry?.shortDescription.length).toBeGreaterThan(0)
|
expect(entry?.shortDescription.length).toBeGreaterThan(0)
|
||||||
expect(entry?.infoContent.length).toBeGreaterThan(20)
|
expect(entry?.infoContent.length).toBeGreaterThan(20)
|
||||||
expect(entry?.icon).toBeTruthy()
|
expect(entry?.icon).toBeTruthy()
|
||||||
|
expect(entry?.iconClassName.length).toBeGreaterThan(0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
57
tests/unit/wizardThumbGrid.unit.spec.ts
Normal file
57
tests/unit/wizardThumbGrid.unit.spec.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
import { describe, expect, it } from 'vitest'
|
||||||
|
|
||||||
|
import { municipalitySignalTypeMetaByType } from '@/lib/municipalitySignalTypeMeta'
|
||||||
|
import {
|
||||||
|
politicalTrendWizardMeta,
|
||||||
|
politicalTrendWizardMetaByStatus,
|
||||||
|
} from '@/lib/politicalTrendWizardMeta'
|
||||||
|
import { politicalTrendStatuses } from '@/lib/schemas/municipality'
|
||||||
|
import { municipalitySignalTypes } from '@/lib/schemas/municipalityUpdate'
|
||||||
|
import { WIZARD_THUMB_TILE_GRID_CLASS, wizardSignalTypesThumbOrder } from '@/lib/wizardThumbGrid'
|
||||||
|
|
||||||
|
describe('wizardThumbGrid', () => {
|
||||||
|
it('pins thumb-zone grid classes for mobile RTL fill and desktop LTR grid', () => {
|
||||||
|
expect(WIZARD_THUMB_TILE_GRID_CLASS).toContain('list-none')
|
||||||
|
expect(WIZARD_THUMB_TILE_GRID_CLASS).toContain('[direction:rtl]')
|
||||||
|
expect(WIZARD_THUMB_TILE_GRID_CLASS).toContain('place-content-end')
|
||||||
|
expect(WIZARD_THUMB_TILE_GRID_CLASS).toContain('md:[direction:ltr]')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('orders signal types with urgency types first in DOM for thumb reach', () => {
|
||||||
|
expect(wizardSignalTypesThumbOrder[0]).toBe('invasao')
|
||||||
|
expect(wizardSignalTypesThumbOrder[1]).toBe('esfriamento')
|
||||||
|
expect(wizardSignalTypesThumbOrder).toHaveLength(municipalitySignalTypes.length)
|
||||||
|
expect(new Set(wizardSignalTypesThumbOrder)).toEqual(new Set(municipalitySignalTypes))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('municipalitySignalTypeMeta icon colors', () => {
|
||||||
|
it('covers every signal type with a semantic icon class', () => {
|
||||||
|
for (const type of municipalitySignalTypes) {
|
||||||
|
const entry = municipalitySignalTypeMetaByType[type]
|
||||||
|
expect(entry?.iconClassName.length).toBeGreaterThan(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(municipalitySignalTypeMetaByType.invasao.iconClassName).toContain('destructive')
|
||||||
|
expect(municipalitySignalTypeMetaByType.esfriamento.iconClassName).toContain('sky')
|
||||||
|
expect(municipalitySignalTypeMetaByType.visita_adversario.iconClassName).toContain('amber')
|
||||||
|
expect(municipalitySignalTypeMetaByType.proposta_broker.iconClassName).toContain('teal')
|
||||||
|
expect(municipalitySignalTypeMetaByType.outro.iconClassName).toContain('muted-foreground')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('politicalTrendWizardMeta icon colors', () => {
|
||||||
|
it('covers every trend with icon-only semantic classes', () => {
|
||||||
|
expect(politicalTrendWizardMeta).toHaveLength(politicalTrendStatuses.length)
|
||||||
|
|
||||||
|
for (const status of politicalTrendStatuses) {
|
||||||
|
const entry = politicalTrendWizardMetaByStatus[status]
|
||||||
|
expect(entry.iconClassName.length).toBeGreaterThan(0)
|
||||||
|
expect(entry.icon).toBeTruthy()
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(politicalTrendWizardMetaByStatus.favoravel.iconClassName).toContain('estimate-confirmed')
|
||||||
|
expect(politicalTrendWizardMetaByStatus.desfavoravel.iconClassName).toContain('destructive')
|
||||||
|
expect(politicalTrendWizardMetaByStatus.neutra.iconClassName).toContain('muted-foreground')
|
||||||
|
})
|
||||||
|
})
|
||||||
Loading…
Reference in a new issue