teqo-backup/tests/e2e/helpers/agendaPeriodLabels.ts
Francisco Solla 51fb715ec7 feat(C101): agenda mobile com cara de app nativo — contexto no header, swipe, filtro sticky, dia na hora atual
- toolbar do FullCalendar some no mobile; título do header mostra o período
  ("9 Agosto", "3–9 Agosto", "Agosto", "Agenda") e tap volta ao hoje
- navegação por arrasto horizontal (useAgendaSwipeNavigation): limiar 48px,
  claim 12px com preventDefault, touchcancel sintético contra o long-press
  do FC, dateClick do dia suprimido (C91/C15 intactos)
- filtro vira strip edge-to-edge sem rótulo, sticky sob a barra do app
  (containing block via :has no padding do scroll container)
- visão de dia com scroll interno (height fixa), 08:00 na abertura,
  cabeçalho do dia fixo, scroll preservado ao trocar de dia
- desktop inalterado; impl plan + plano pós-critique (C101-ux)
2026-08-09 22:09:47 -03:00

48 lines
1.5 KiB
TypeScript

/**
* Agenda mobile (C101) — the header period label is computed from the
* calendar's current date, so the e2e specs derive the expected label from
* "today" instead of hardcoding it. Shared by the agenda mobile spec and the
* C95 view-switching spec. Production vocabulary lives in
* `src/utilities/activityUi.ts`; these helpers only mirror the label FORMAT
* for assertions (the unit spec pins the literal strings).
*/
export const ptBrMonthNames = [
'Janeiro',
'Fevereiro',
'Março',
'Abril',
'Maio',
'Junho',
'Julho',
'Agosto',
'Setembro',
'Outubro',
'Novembro',
'Dezembro',
]
const ptBrWeekdays = [
'domingo',
'segunda-feira',
'terça-feira',
'quarta-feira',
'quinta-feira',
'sexta-feira',
'sábado',
]
/** "2026-08-09" → "9 Agosto" (the mobile header period label). */
export const dayLabelFor = (civilDate: string): string =>
`${Number(civilDate.slice(8, 10))} ${ptBrMonthNames[Number(civilDate.slice(5, 7)) - 1]}`
export const civilDatePlusDays = (civilDate: string, days: number): string => {
const [year, month, day] = civilDate.split('-').map(Number)
const date = new Date(Date.UTC(year, month - 1, day + days))
return `${date.getUTCFullYear()}-${String(date.getUTCMonth() + 1).padStart(2, '0')}-${String(date.getUTCDate()).padStart(2, '0')}`
}
export const weekdayOf = (civilDate: string): string => {
const [year, month, day] = civilDate.split('-').map(Number)
return ptBrWeekdays[new Date(Date.UTC(year, month - 1, day)).getUTCDay()] ?? ''
}