From 0569eb36f182cb1c6fdaaadfe28b2af98b89cc2e Mon Sep 17 00:00:00 2001 From: tisachi Date: Fri, 6 Nov 2026 01:10:42 +0100 Subject: [PATCH] App: przycisk Wstecz w tresni strony dnia prowadzi do planu dnia - BackButton w PageHeader DayExecution = /plans/{planId} (md+; na telefonie zostaje < w topbarze), fallback /calendar gdy dzien bez planu (mock GET /days/:id z planId; unit) --- app/src/pages/DayExecution.tsx | 9 ++++++++- app/test/DayExecution.test.tsx | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/app/src/pages/DayExecution.tsx b/app/src/pages/DayExecution.tsx index 20ac729..6e91356 100644 --- a/app/src/pages/DayExecution.tsx +++ b/app/src/pages/DayExecution.tsx @@ -48,6 +48,7 @@ import { useTopbar } from '../topbar'; import StartTrainingPresenceModal from '../components/presence/StartTrainingPresenceModal'; import { Badge, + BackButton, Button, Card, ConfirmDialog, @@ -1156,7 +1157,13 @@ export default function DayExecution() { return ( <> - + {/* md+: powrót do planu, do którego należy dzień (na telefonie „<” w topbarze) */} + + } + /> {error && {error}} diff --git a/app/test/DayExecution.test.tsx b/app/test/DayExecution.test.tsx index 725b220..c71a589 100644 --- a/app/test/DayExecution.test.tsx +++ b/app/test/DayExecution.test.tsx @@ -297,6 +297,8 @@ function mockApi( date: '2026-08-24', status: completed ? 'COMPLETED' : daySkipped ? 'SKIPPED' : 'PLANNED', dayOfWeek: 1, + planId: 'plan-1', + plan: { id: 'plan-1', gym: null }, sessions: [ { id: 'sess-1', @@ -1136,3 +1138,23 @@ describe('Porzucenie sesji', () => { expect(await screen.findByRole('button', { name: 'Rozpocznij sesję' })).toBeInTheDocument(); }); }); + +describe('Nawigacja „Wstecz” na stronie dnia', () => { + it('ukończony trening: przycisk „Wstecz” w treści prowadzi do planu dnia (/plans/:id)', async () => { + mockApi({ 'ss-1': 10, 'ss-2': 8, 'ss-3': 6 }, {}, { completed: true }); + const user = userEvent.setup(); + renderApp(); + expect(await screen.findByRole('heading', { name: 'FitOS' })).toBeInTheDocument(); + const email = document.querySelector('input[type="email"]') as HTMLInputElement; + const password = document.querySelector('input[type="password"]') as HTMLInputElement; + await user.type(email, 'jan@test.local'); + await user.type(password, 'Password123!'); + await user.click(screen.getByRole('button', { name: 'Zaloguj' })); + await screen.findByRole('heading', { name: 'Dashboard' }); + await user.click(screen.getByRole('link', { name: 'Trening', exact: true })); + expect(await screen.findByText('Ukończona')).toBeInTheDocument(); + + const back = await screen.findByRole('link', { name: 'Wstecz' }); + expect(back).toHaveAttribute('href', '/plans/plan-1'); + }); +});