diff --git a/src/lib/__tests__/calendar-a11y.test.ts b/src/lib/__tests__/calendar-a11y.test.ts index 23f25d68..27e6e71d 100644 --- a/src/lib/__tests__/calendar-a11y.test.ts +++ b/src/lib/__tests__/calendar-a11y.test.ts @@ -14,6 +14,8 @@ import { participantRemoveAccessibilityLabel, } from '../calendar-a11y'; import { useSettingsStore } from '../../stores/settings-store'; +import { gregorianCalendar, jalaliCalendar } from '../calendar-system'; +import { displayNow } from '../calendar-timezone'; const t = (_key: string, fallback?: string, params?: Record) => formatMessage(fallback ?? '', params, 'en'); @@ -54,7 +56,28 @@ describe('eventAccessibilityLabel', () => { describe('header and chip buttons', () => { it('names the month button by the month it shows, not "Click to change month"', () => { - expect(monthButtonAccessibilityLabel('October 2026', t)).toBe('October 2026, change month'); + expect(monthButtonAccessibilityLabel(new Date(2026, 9, 15), gregorianCalendar, enUS, t)).toBe('October 2026, change month'); + }); + + it('reads the year also in the current year, where the header leaves it out', () => { + const now = displayNow(); + const month = new Intl.DateTimeFormat('en-US', { month: 'long' }).format(now); + expect(monthButtonAccessibilityLabel(now, gregorianCalendar, enUS, t)).toBe(`${month} ${now.getFullYear()}, change month`); + expect(monthButtonAccessibilityLabel(now, jalaliCalendar, enUS, t)).toMatch(/ \d{4}, change month$/); + }); + + it('has "change month" translated in every app overlay', async () => { + const fs = await import('node:fs'); + const path = await import('node:path'); + const dir = path.resolve(__dirname, '../../../locales/rn'); + const files = fs.readdirSync(dir).filter((f) => f.endsWith('.json')); + expect(files.length).toBeGreaterThanOrEqual(29); + for (const file of files) { + const overlay = JSON.parse(fs.readFileSync(path.join(dir, file), 'utf8')); + const value = overlay.calendar?.change_month_named as string | undefined; + expect(value, file).toContain('{month}'); + if (file !== 'en.json') expect(value, file).not.toContain('change month'); + } }); it('names the cross on a participant chip by the person it removes', () => { diff --git a/src/lib/calendar-a11y.ts b/src/lib/calendar-a11y.ts index 97fcbd6c..c5a6d37e 100644 --- a/src/lib/calendar-a11y.ts +++ b/src/lib/calendar-a11y.ts @@ -3,7 +3,7 @@ import type { Locale } from 'date-fns'; import type { Calendar, CalendarEvent } from '../api/types'; import { getEventDisplayEndDate, getEventStartDate, getPrimaryCalendarId, timePattern } from './calendar-utils'; import { isDeclinedByUser } from './calendar-participants'; -import { formatCalendarDay } from './calendar-system'; +import { formatCalendarDay, monthTitle, type CalendarSystem } from './calendar-system'; type Translate = (key: string, fallback?: string, params?: Record) => string; @@ -14,10 +14,11 @@ type Translate = (key: string, fallback?: string, params?: Record