Plany: nawigacja wylacznie przez kafelki huba - podstrony (Aktualne/Archiwum/Szablony/Udostepnione) rezygnuja z paska zakladek PlansTabs i deklaruja Wstecz w topbarze do /plans (testy unit przez kafelek + Wstecz)
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Tabs } from '../ui';
|
||||
|
||||
const TAB_PATHS: Record<string, string> = {
|
||||
active: '/plans/current',
|
||||
archive: '/plans/archive',
|
||||
templates: '/plans/templates',
|
||||
shared: '/plans/shared',
|
||||
};
|
||||
|
||||
/** Segment zakładek sekcji planów (Aktualne / Archiwum / Szablony / Udostępnione). */
|
||||
export function PlansTabs() {
|
||||
const { t } = useTranslation('plans');
|
||||
const { pathname } = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const active = pathname.startsWith('/plans/templates')
|
||||
? 'templates'
|
||||
: pathname.startsWith('/plans/shared')
|
||||
? 'shared'
|
||||
: pathname.startsWith('/plans/archive')
|
||||
? 'archive'
|
||||
: 'active';
|
||||
return (
|
||||
<div className="mb-4">
|
||||
<Tabs
|
||||
tabs={[
|
||||
{ id: 'active', label: t('tabs.active') },
|
||||
{ id: 'archive', label: t('tabs.archive') },
|
||||
{ id: 'templates', label: t('tabs.templates') },
|
||||
{ id: 'shared', label: t('tabs.shared') },
|
||||
]}
|
||||
active={active}
|
||||
onChange={(id) => navigate(TAB_PATHS[id] ?? '/plans')}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import { useTranslation } from 'react-i18next';
|
||||
import { FileStack, Layers } from 'lucide-react';
|
||||
import { usePlanTemplates } from '../../api/queries';
|
||||
import { fmtDate } from '../../lib/format';
|
||||
import { PlansTabs } from '../../components/plans/PlansTabs';
|
||||
import { Badge, Button, Card, EmptyState, ErrorText, Skeleton } from '../../components/ui';
|
||||
import { useListSearch } from '../../store/list-search';
|
||||
import { useTopbar } from '../../topbar';
|
||||
@@ -49,6 +48,7 @@ export default function PlanTemplates() {
|
||||
|
||||
useTopbar({
|
||||
title: t('nav:plans'),
|
||||
back: '/plans',
|
||||
search: 'plans',
|
||||
actions: [{ label: t('templates.newTemplate'), to: '/plans/templates/new', icon: FileStack }],
|
||||
});
|
||||
@@ -64,7 +64,6 @@ export default function PlanTemplates() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<PlansTabs />
|
||||
{isLoading && (
|
||||
<div className="flex flex-col gap-4">
|
||||
<Skeleton className="h-20" />
|
||||
|
||||
@@ -8,7 +8,6 @@ import { apiErrorMessage } from '../../lib/errors';
|
||||
import { useToast } from '../../components/toast';
|
||||
import { ActivePlanHero } from '../../components/plans/ActivePlanHero';
|
||||
import { PlanListView, usePlanListFilters } from '../../components/plans/PlanList';
|
||||
import { PlansTabs } from '../../components/plans/PlansTabs';
|
||||
import { NewPlanMenu } from '../../components/plans/NewPlanMenu';
|
||||
import { Button, Card, EmptyState, ErrorText, Skeleton } from '../../components/ui';
|
||||
import { useListSearch } from '../../store/list-search';
|
||||
@@ -30,6 +29,7 @@ export default function PlansActive() {
|
||||
|
||||
useTopbar({
|
||||
title: t('nav:plans'),
|
||||
back: '/plans',
|
||||
search: 'plans',
|
||||
filters,
|
||||
filterActive,
|
||||
@@ -98,7 +98,6 @@ export default function PlansActive() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<PlansTabs />
|
||||
{isLoading && (
|
||||
<div className="flex flex-col gap-4">
|
||||
<Skeleton className="h-20" />
|
||||
|
||||
@@ -3,7 +3,6 @@ import { useTranslation } from 'react-i18next';
|
||||
import { Archive } from 'lucide-react';
|
||||
import { useMe, usePlans } from '../../api/queries';
|
||||
import { PlanListView, usePlanListFilters } from '../../components/plans/PlanList';
|
||||
import { PlansTabs } from '../../components/plans/PlansTabs';
|
||||
import { ErrorText, Skeleton } from '../../components/ui';
|
||||
import { useListSearch } from '../../store/list-search';
|
||||
import { useTopbar } from '../../topbar';
|
||||
@@ -18,6 +17,7 @@ export default function PlansArchive() {
|
||||
|
||||
useTopbar({
|
||||
title: t('nav:plans'),
|
||||
back: '/plans',
|
||||
search: 'plans',
|
||||
filters,
|
||||
filterActive,
|
||||
@@ -45,7 +45,6 @@ export default function PlansArchive() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<PlansTabs />
|
||||
{isLoading && (
|
||||
<div className="flex flex-col gap-4">
|
||||
<Skeleton className="h-20" />
|
||||
|
||||
@@ -3,7 +3,6 @@ import { useTranslation } from 'react-i18next';
|
||||
import { Share2 } from 'lucide-react';
|
||||
import { useSharedByMe, useSharedWithMe } from '../../api/queries';
|
||||
import { H3, Badge, Card, EmptyState, ErrorText, Skeleton } from '../../components/ui';
|
||||
import { PlansTabs } from '../../components/plans/PlansTabs';
|
||||
import { PlanCard } from '../../components/plans/PlanCard';
|
||||
import { useListSearch } from '../../store/list-search';
|
||||
import { useTopbar } from '../../topbar';
|
||||
@@ -35,6 +34,7 @@ export default function PlansShared() {
|
||||
|
||||
useTopbar({
|
||||
title: t('nav:plans'),
|
||||
back: '/plans',
|
||||
search: 'plans',
|
||||
});
|
||||
|
||||
@@ -61,7 +61,6 @@ export default function PlansShared() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<PlansTabs />
|
||||
{loading && (
|
||||
<div className="flex flex-col gap-4">
|
||||
<Skeleton className="h-20" />
|
||||
|
||||
@@ -208,9 +208,9 @@ async function loginAndOpenPlans(user: userEvent.User, email: string) {
|
||||
expect(await screen.findByRole('heading', { name: 'Dashboard' })).toBeInTheDocument();
|
||||
await user.click(screen.getByRole('link', { name: 'Plany treningowe' }));
|
||||
expect(await screen.findByRole('heading', { name: 'Plany treningowe' })).toBeInTheDocument();
|
||||
// hub sekcji → kategoria „Aktualne” (lista z zakładkami)
|
||||
// hub sekcji → kategoria „Aktualne” (powrót „Wstecz” w topbarze do huba)
|
||||
await user.click(await screen.findByRole('link', { name: /^Aktualne/ }));
|
||||
expect(await screen.findByRole('button', { name: 'Archiwum' })).toBeInTheDocument();
|
||||
expect(await screen.findByRole('button', { name: 'Wstecz' })).toBeInTheDocument();
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
@@ -295,7 +295,8 @@ describe('PlanDetail — udostępnianie planów (WP4)', () => {
|
||||
const user = userEvent.setup();
|
||||
renderApp();
|
||||
await loginAndOpenPlans(user, RECIPIENT.email);
|
||||
await user.click(screen.getByRole('button', { name: 'Udostępnione' }));
|
||||
await user.click(screen.getByRole('button', { name: 'Wstecz' }));
|
||||
await user.click(await screen.findByRole('link', { name: /^Udostępnione/ }));
|
||||
|
||||
// sekcja „Udostępnione mi” z etykietą twórcy
|
||||
expect(await screen.findByRole('heading', { name: 'Udostępnione mi' })).toBeInTheDocument();
|
||||
@@ -407,7 +408,8 @@ describe('PlanDetail — statusy i klikalność dni', () => {
|
||||
const user = userEvent.setup();
|
||||
renderApp();
|
||||
await loginAndOpenPlans(user, OWNER.email);
|
||||
await user.click(screen.getByRole('button', { name: 'Archiwum' }));
|
||||
await user.click(screen.getByRole('button', { name: 'Wstecz' }));
|
||||
await user.click(await screen.findByRole('link', { name: /^Archiwum/ }));
|
||||
|
||||
await user.click(await screen.findByRole('link', { name: /Otwórz/ }));
|
||||
expect(await screen.findByRole('heading', { name: 'Plan masowy' })).toBeInTheDocument();
|
||||
@@ -432,7 +434,8 @@ describe('PlanDetail — statusy i klikalność dni', () => {
|
||||
const user = userEvent.setup();
|
||||
renderApp();
|
||||
await loginAndOpenPlans(user, OWNER.email);
|
||||
await user.click(screen.getByRole('button', { name: 'Archiwum' }));
|
||||
await user.click(screen.getByRole('button', { name: 'Wstecz' }));
|
||||
await user.click(await screen.findByRole('link', { name: /^Archiwum/ }));
|
||||
|
||||
await user.click(await screen.findByRole('link', { name: /Plan masowy/ }));
|
||||
expect(await screen.findByRole('heading', { name: 'Plan masowy' })).toBeInTheDocument();
|
||||
@@ -510,7 +513,8 @@ describe('PlanDetail — statusy i klikalność dni', () => {
|
||||
const user = userEvent.setup();
|
||||
renderApp();
|
||||
await loginAndOpenPlans(user, OWNER.email);
|
||||
await user.click(screen.getByRole('button', { name: 'Archiwum' }));
|
||||
await user.click(screen.getByRole('button', { name: 'Wstecz' }));
|
||||
await user.click(await screen.findByRole('link', { name: /^Archiwum/ }));
|
||||
|
||||
await user.click(await screen.findByRole('link', { name: /Otwórz/ }));
|
||||
expect(await screen.findByRole('heading', { name: 'Plan masowy' })).toBeInTheDocument();
|
||||
|
||||
@@ -125,11 +125,11 @@ async function openPlans(user: userEvent.User) {
|
||||
expect(await screen.findByRole('heading', { name: 'Plany treningowe' })).toBeInTheDocument();
|
||||
}
|
||||
|
||||
/** Hub → kategoria „Aktualne” (podstrona z listą i zakładkami). */
|
||||
/** Hub → kategoria „Aktualne” (podstrona z listą; powrót „Wstecz” w topbarze). */
|
||||
async function openCurrentPlans(user: userEvent.User) {
|
||||
await openPlans(user);
|
||||
await user.click(await screen.findByRole('link', { name: /^Aktualne/ }));
|
||||
expect(await screen.findByRole('button', { name: 'Archiwum' })).toBeInTheDocument();
|
||||
expect(await screen.findByRole('button', { name: 'Wstecz' })).toBeInTheDocument();
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -164,7 +164,9 @@ describe('Strona główna sekcji planów (/plans)', () => {
|
||||
|
||||
await user.click(archive);
|
||||
expect(await screen.findByRole('heading', { name: 'Ukończony' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Aktualne' })).toBeInTheDocument();
|
||||
// brak paska zakładek — powrót do huba tylko przez „Wstecz” w topbarze
|
||||
expect(screen.getByRole('button', { name: 'Wstecz' })).toBeInTheDocument();
|
||||
expect(screen.queryByRole('button', { name: 'Aktualne' })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('aktywny plan eksponowany jako hero także na stronie głównej', async () => {
|
||||
@@ -191,16 +193,15 @@ describe('Strona główna sekcji planów (/plans)', () => {
|
||||
});
|
||||
|
||||
describe('Podstrona „Aktualne” (/plans/current)', () => {
|
||||
it('renderuje zakładki sekcji planów', async () => {
|
||||
it('podstrona ma „Wstecz” w topbarze, który wraca do huba z kafelkami', async () => {
|
||||
mockApi();
|
||||
const user = userEvent.setup();
|
||||
renderApp();
|
||||
await openCurrentPlans(user);
|
||||
|
||||
expect(screen.getByRole('button', { name: 'Aktualne' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Archiwum' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Szablony' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Udostępnione' })).toBeInTheDocument();
|
||||
await user.click(screen.getByRole('button', { name: 'Wstecz' }));
|
||||
const templates = await screen.findByRole('link', { name: /^Szablony/ });
|
||||
expect(templates).toHaveAttribute('href', '/plans/templates');
|
||||
});
|
||||
|
||||
it('aktywny plan jest hero: postęp dni, „Tydzień X z Y”, następny trening', async () => {
|
||||
@@ -249,13 +250,13 @@ describe('Podstrona „Aktualne” (/plans/current)', () => {
|
||||
expect(screen.queryByRole('link', { name: /Plan definicyjny/ })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('archiwum: zakładka pokazuje COMPLETED i ABANDONED', async () => {
|
||||
it('archiwum: kafelek huba prowadzi do listy COMPLETED i ABANDONED', async () => {
|
||||
mockApi();
|
||||
const user = userEvent.setup();
|
||||
renderApp();
|
||||
await openCurrentPlans(user);
|
||||
await openPlans(user);
|
||||
|
||||
await user.click(screen.getByRole('button', { name: 'Archiwum' }));
|
||||
await user.click(await screen.findByRole('link', { name: /^Archiwum/ }));
|
||||
expect(await screen.findByRole('heading', { name: 'Ukończony' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('link', { name: /Plan definicyjny/ })).toBeInTheDocument();
|
||||
expect(screen.queryByRole('link', { name: /Plan masowy/ })).not.toBeInTheDocument();
|
||||
|
||||
Reference in New Issue
Block a user