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)
This commit is contained in:
@@ -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 (
|
||||
<>
|
||||
<PageHeader title={title} />
|
||||
{/* md+: powrót do planu, do którego należy dzień (na telefonie „<” w topbarze) */}
|
||||
<PageHeader
|
||||
title={title}
|
||||
actions={
|
||||
dayInfo && <BackButton to={dayInfo.planId ? `/plans/${dayInfo.planId}` : '/calendar'} />
|
||||
}
|
||||
/>
|
||||
|
||||
{error && <ErrorText>{error}</ErrorText>}
|
||||
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user