Onboarding: - Keep the current step in ?step= so the device back gesture moves one step back; effectiveStep guards skipping the plan and re-opening the group form after the group exists. Show Back on mobile. - Format prices with the chosen country's currency (form prefix and confirmation). - Welcome describes the real flow and previews the WhatsApp payment reminder; the last step shares the group's invite link instead of listing settings chores. - Accessibility: named stepper steps with aria-current, focus moves to the new step heading, alerts on errors, reduced-motion and direction-aware step animation, 48px primary actions. - Group form split into "classes" and "billing", due day hidden for per-class billing; Stripe skips the empty Pro confirmation; Free features read "in Pro" instead of struck through. Home: - Payments section follows the plan: Free gets a locked preview with an upgrade link and is never asked to link Mercado Pago. - Secondary text meets 4.5:1 contrast; accent-fg for links in dark. - Class times use a 24h clock in Spanish and Portuguese. - Drop the summary tiles; one hero for the current or next class, the rest of the day as compact rows; two columns on desktop. - "Para atender" reads the shared ['attention'] query, so resolved alerts match "Requiere atención", with WhatsApp shortcuts and a link to the full list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
76 lines
3.1 KiB
TypeScript
76 lines
3.1 KiB
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
import type { OnboardingStatusDto } from '@gruperly/shared'
|
|
import { effectiveStep, parseStep, resumeStep, visibleSteps } from '../src/features/onboarding/steps'
|
|
|
|
function status(overrides: Partial<OnboardingStatusDto> = {}): OnboardingStatusDto {
|
|
return {
|
|
step: 'NOT_STARTED',
|
|
paymentConnected: false,
|
|
whatsappConnected: false,
|
|
completed: false,
|
|
planSelected: false,
|
|
selectedPlan: null,
|
|
subscriptionStatus: null,
|
|
country: null,
|
|
...overrides,
|
|
}
|
|
}
|
|
|
|
describe('pasos del onboarding', () => {
|
|
test('con Free no se recorren Cobros ni WhatsApp', () => {
|
|
expect(visibleSteps('FREE')).toEqual(['welcome', 'country', 'plan', 'group', 'done'])
|
|
expect(visibleSteps('PRO')).toEqual(['welcome', 'country', 'plan', 'payment', 'whatsapp', 'group', 'done'])
|
|
expect(visibleSteps(null)).toEqual(visibleSteps('PRO'))
|
|
})
|
|
|
|
test('sin plan elegido arranca de cero', () => {
|
|
expect(resumeStep(status())).toBeNull()
|
|
})
|
|
|
|
test('con Free retoma en el primer grupo', () => {
|
|
expect(resumeStep(status({ planSelected: true, selectedPlan: 'FREE' }))).toBe('group')
|
|
})
|
|
|
|
test('una suscripción a Pro abandonada vuelve al paso Plan', () => {
|
|
expect(
|
|
resumeStep(status({ planSelected: true, selectedPlan: 'PRO', subscriptionStatus: 'PENDING' })),
|
|
).toBe('plan')
|
|
})
|
|
|
|
test('con Pro activo sigue por Cobros, WhatsApp o el grupo', () => {
|
|
const pro = { planSelected: true, selectedPlan: 'PRO' as const, subscriptionStatus: 'AUTHORIZED' as const }
|
|
expect(resumeStep(status(pro))).toBe('payment')
|
|
expect(resumeStep(status({ ...pro, step: 'PAYMENT_CONNECTED', paymentConnected: true }))).toBe('whatsapp')
|
|
expect(
|
|
resumeStep(status({ ...pro, step: 'PAYMENT_CONNECTED', paymentConnected: true, whatsappConnected: true })),
|
|
).toBe('group')
|
|
})
|
|
})
|
|
|
|
describe('paso pedido por la URL', () => {
|
|
test('solo acepta ids de pasos conocidos', () => {
|
|
expect(parseStep('plan')).toBe('plan')
|
|
expect(parseStep('nope')).toBeUndefined()
|
|
expect(parseStep(undefined)).toBeUndefined()
|
|
expect(parseStep(3)).toBeUndefined()
|
|
})
|
|
|
|
test('sin plan elegido no se pasa del paso Plan', () => {
|
|
expect(effectiveStep('group', { plan: null, hasCreatedGroup: false })).toBe('plan')
|
|
expect(effectiveStep('payment', { plan: null, hasCreatedGroup: false })).toBe('plan')
|
|
expect(effectiveStep('country', { plan: null, hasCreatedGroup: false })).toBe('country')
|
|
})
|
|
|
|
test('con Free no se muestran Cobros ni WhatsApp', () => {
|
|
expect(effectiveStep('payment', { plan: 'FREE', hasCreatedGroup: false })).toBe('group')
|
|
expect(effectiveStep('whatsapp', { plan: 'FREE', hasCreatedGroup: false })).toBe('group')
|
|
expect(effectiveStep('payment', { plan: 'PRO', hasCreatedGroup: false })).toBe('payment')
|
|
})
|
|
|
|
test('"Listo" necesita el grupo creado, y con el grupo creado no se vuelve al formulario', () => {
|
|
expect(effectiveStep('done', { plan: 'PRO', hasCreatedGroup: false })).toBe('group')
|
|
expect(effectiveStep('group', { plan: 'PRO', hasCreatedGroup: true })).toBe('done')
|
|
expect(effectiveStep('plan', { plan: 'FREE', hasCreatedGroup: true })).toBe('done')
|
|
})
|
|
})
|