import type { Page } from '@playwright/test' import { expect } from '@playwright/test' // Swedish labels from src/i18n/sv/calendar.ts — the suite pins // `locale: 'sv-SE'` in playwright.config.ts so these are stable. const MONTH_SELECT_LABEL = 'Välj månad' const YEAR_SELECT_LABEL = 'Välj år' /** Navigate the Calendar page to the month containing `date` (UTC). */ export async function goToCalendarMonth(page: Page, date: Date): Promise { await page.goto('/calendar') await expect(page.getByTestId('calendar')).toBeVisible() await page.getByLabel(YEAR_SELECT_LABEL).selectOption(String(date.getUTCFullYear())) await page.getByLabel(MONTH_SELECT_LABEL).selectOption(String(date.getUTCMonth())) } /** The exact `data-testid="calendar-day"` cell for an ISO date, wherever it * falls in the currently-displayed grid (including a leading/trailing day * from an adjacent month). */ export function calendarDayCell(page: Page, isoDate: string) { return page.locator(`[data-testid="calendar-day"][aria-label^="${isoDate}"]`) }