import { test, expect } from './fixtures'; import { mockApi } from './mock-api'; test('dzień treningowy zapisany jako lokalna północ renderuje się w prawidłowej komórce', async ({ page }) => { const now = new Date(); const localMidnight = new Date(now.getFullYear(), now.getMonth(), now.getDate()); const month = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}`; const dayNumber = now.getDate(); mockApi(page); // API zwraca datę jako ISO (UTC) lokalnej północy — np. 2026-08-24T00:00+02:00 → 2026-08-23T22:00Z. // Wycięcie prefiksu z ISO przesunęłoby dzień o jeden w strefach przed UTC (np. Polska). page.route(`**/api/v1/calendar?month=${month}`, (route) => route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ month, days: [ { id: 'day-cal', date: localMidnight.toISOString(), status: 'PLANNED', dayOfWeek: 1, exercises: [{ name: 'Przysiady', muscle: 'legs' }], }, ], }), }), ); await page.goto('/login'); await page.locator('input[type="email"]').fill('test@fitos.pl'); await page.locator('input[type="password"]').fill('haslo123'); await page.getByRole('button', { name: 'Zaloguj' }).click(); await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible(); await page.getByRole('link', { name: 'Mój kalendarz' }).click(); const chip = page.getByText('Zaplanowany: 1 ćw.').first(); await expect(chip).toBeVisible(); // Chip musi być w komórce o numerze dnia równym dzisiejszemu dniu LOKALNEMU. const cell = chip.locator('xpath=..'); await expect(cell.locator('div').first()).toHaveText(String(dayNumber)); });