2026-09-04 19:06:19 +02:00
|
|
|
import { test, expect } from './fixtures';
|
|
|
|
|
import { mockApi, TEST_DAY, TEST_SESSION } from './mock-api';
|
|
|
|
|
|
|
|
|
|
const ACTIVE_SESSION = {
|
|
|
|
|
id: 'sess-1',
|
|
|
|
|
dayId: 'day-1',
|
|
|
|
|
dayDate: '2026-08-24',
|
|
|
|
|
dayOfWeek: 1,
|
|
|
|
|
planTitle: 'Plan testowy',
|
|
|
|
|
startedAt: '2026-08-24T07:00:00.000Z',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
test('aktywna sesja — skrót „Trening” w menu bocznym i na dashboardzie', async ({ page }) => {
|
|
|
|
|
mockApi(page, { activeSession: { session: ACTIVE_SESSION } });
|
|
|
|
|
page.route('**/api/v1/days/day-1', (route) =>
|
|
|
|
|
route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ day: TEST_DAY }) }),
|
|
|
|
|
);
|
|
|
|
|
page.route('**/api/v1/sessions/sess-1', (route) =>
|
|
|
|
|
route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ session: TEST_SESSION }) }),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
// dashboard: karta „Trwa trening” ze skrótem do dnia sesji
|
|
|
|
|
await expect(page.getByText('Trwa trening')).toBeVisible();
|
2026-09-13 21:12:00 +02:00
|
|
|
// karta „Następny trening” wskazuje ten sam dzień co aktywna sesja —
|
|
|
|
|
// oba CTA to „Wróć do treningu” (nie „Wykonaj trening”)
|
|
|
|
|
await expect(page.getByRole('link', { name: /Wróć do treningu/ })).toHaveCount(2);
|
|
|
|
|
await expect(page.getByRole('button', { name: 'Wykonaj trening' })).toHaveCount(0);
|
2026-09-04 19:06:19 +02:00
|
|
|
|
|
|
|
|
// menu boczne: link „Trening” prowadzi do dnia aktywnego treningu (exact — „Wróć/Wykonaj trening” to inne linki)
|
|
|
|
|
const sidebarLink = page.getByRole('link', { name: 'Trening', exact: true });
|
|
|
|
|
await expect(sidebarLink).toBeVisible();
|
|
|
|
|
await sidebarLink.click();
|
|
|
|
|
// tytuł PageHeader z danymi dnia (unikalny — Layout ma osobny h1 „Dzień treningowy”)
|
|
|
|
|
await expect(page.getByRole('heading', { name: 'Poniedziałek · 24.08.2026' })).toBeVisible();
|
|
|
|
|
// pasek sesji: status + start + postęp normy
|
|
|
|
|
await expect(page.getByText('W trakcie')).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('brak aktywnej sesji — bez skrótu „Trening”', async ({ page }) => {
|
|
|
|
|
mockApi(page);
|
|
|
|
|
|
|
|
|
|
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 expect(page.getByRole('link', { name: 'Trening', exact: true })).toHaveCount(0);
|
|
|
|
|
await expect(page.getByText('Trwa trening')).toHaveCount(0);
|
|
|
|
|
});
|