Files
gruperly/apps/web/test/home-day.test.ts
Jose Selesan 2d80af082f feat(web): redesign onboarding and home after design critique
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>
2026-11-06 09:58:08 -03:00

55 lines
2.1 KiB
TypeScript

import { describe, expect, test } from 'bun:test'
import type { ClassTodayDto } from '@gruperly/shared'
import { classState, planDay } from '../src/features/home/day'
import { formatClockTime } from '../src/lib/format'
function session(id: string, startsAt: string, hasAttendance = false): ClassTodayDto {
return {
sessionId: id,
groupId: `g-${id}`,
groupName: `Grupo ${id}`,
startsAt,
enrolledCount: 5,
capacity: 10,
availableSlots: 5,
hasAttendance,
}
}
const now = new Date('2026-11-05T22:00:00.000Z')
describe('el día del Inicio', () => {
test('estado de cada clase', () => {
expect(classState(session('a', '2026-11-05T23:00:00.000Z'), now)).toBe('upcoming')
expect(classState(session('b', '2026-11-05T21:00:00.000Z'), now)).toBe('live')
expect(classState(session('c', '2026-11-05T18:00:00.000Z'), now)).toBe('missed')
expect(classState(session('d', '2026-11-05T21:00:00.000Z', true), now)).toBe('taken')
})
test('el hero es la clase en curso o la próxima sin asistencia; el resto va en orden', () => {
const morning = session('m', '2026-11-05T12:00:00.000Z', true)
const live = session('l', '2026-11-05T21:30:00.000Z')
const later = session('n', '2026-11-05T23:30:00.000Z')
const { hero, rest } = planDay([later, morning, live], now)
expect(hero?.sessionId).toBe('l')
expect(rest.map((item) => item.sessionId)).toEqual(['m', 'n'])
})
test('terminado el día no hay hero: las clases quedan en la lista', () => {
const missed = session('x', '2026-11-05T18:00:00.000Z')
const taken = session('y', '2026-11-05T19:00:00.000Z', true)
const { hero, rest } = planDay([taken, missed], now)
expect(hero).toBeNull()
expect(rest.map((item) => item.sessionId)).toEqual(['x', 'y'])
})
})
describe('hora de una clase', () => {
test('24 h en español y portugués', () => {
const date = new Date(2026, 10, 5, 19, 0)
expect(formatClockTime(date, 'es-AR')).toBe('19:00')
expect(formatClockTime(date, 'pt-BR')).toBe('19:00')
expect(formatClockTime(new Date(2026, 10, 5, 9, 5), 'es-419')).toBe('09:05')
})
})