mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-15 02:23:07 +00:00
O verify do deploy falhava nas 3 tentativas no e2e C104: o clique do dia de término usava getByRole(name: "2 de Outubro de 2026"), e o matcher de nome do Playwright é substring + case-insensitive — casava também os dias 12 e 22 do mesmo grid (strict mode violation) sempre que hoje+1 caía em dia 01–09 do mês (02/10 no run de 2026-10-01). O C104 passa a clicar via calendarDaySelector ([data-day="DD/MM/YYYY"], o contrato do Calendar.tsx) e o guard miss #55 no e2eNavigationConventions bane o padrão antigo em todos os specs, com teste do contrato do helper; TESTING.md, changelog e post-mortem registram a miss. Related #1406
60 lines
2 KiB
TypeScript
60 lines
2 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]}`
|
|
|
|
/**
|
|
* "[data-day=\"DD/MM/YYYY\"]" — the Calendar day cell's stable contract
|
|
* (`Calendar.tsx` DayButton formats the civil date with the pt-BR locale).
|
|
* Click day cells through this selector, never through the accessible name:
|
|
* "2 de outubro de 2026" is a substring of "12…"/"22 de outubro de 2026",
|
|
* so name matching resolves to several cells (strict mode violation).
|
|
*/
|
|
export const calendarDaySelector = (civilDate: string): string => {
|
|
const [year, month, day] = civilDate.split('-')
|
|
return `[data-day="${day}/${month}/${year}"]`
|
|
}
|
|
|
|
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()] ?? ''
|
|
}
|