App: porzadek nawigacji sidebaru - „Panel admina" jako pierwszy wpis nad „Dashboard", etykiety „Plany treningowe" i „Mój profil" (naglowki Topbaru i testy unit + e2e zsynchronizowane)

This commit is contained in:
tisachi
2026-10-27 05:41:17 +01:00
parent 66b2d72f1d
commit a7e1ac8223
22 changed files with 62 additions and 54 deletions

View File

@@ -74,7 +74,7 @@ const ANNOUNCEMENTS_NAV: NavItem = {
icon: Megaphone,
end: false,
};
// Panel admina — zawsze na końcu listy, tylko dla kont z isAdmin=true.
// Panel admina — pierwszy wpis w menu, tylko dla kont z isAdmin=true.
const ADMIN_NAV: NavItem = {
to: ADMIN_URL,
labelKey: 'adminPanel',
@@ -236,8 +236,8 @@ export default function Layout() {
if (isTrainer) navItems = [...navItems.slice(0, -1), TRAINEES_NAV, navItems[navItems.length - 1]];
if (pendingInvitations > 0)
navItems = [...navItems.slice(0, -1), INVITATIONS_NAV, navItems[navItems.length - 1]];
// „Panel admina” — zawsze na samym końcu, tylko dla administratorów.
if (user?.isAdmin) navItems = [...navItems, ADMIN_NAV];
// „Panel admina” — pierwszy wpis w menu, tylko dla administratorów.
if (user?.isAdmin) navItems = [ADMIN_NAV, ...navItems];
const fullName =
[user?.firstName, user?.lastName].filter(Boolean).join(' ') || user?.email || '?';

View File

@@ -1,8 +1,8 @@
{
"dashboard": "Dashboard",
"plans": "Plans",
"plans": "Training plans",
"calendar": "My calendar",
"profile": "Profile",
"profile": "My profile",
"gyms": "Gyms",
"trainees": "Trainees",
"invitations": "Invitations",

View File

@@ -1,8 +1,8 @@
{
"dashboard": "Dashboard",
"plans": "Plany",
"plans": "Plany treningowe",
"calendar": "Mój kalendarz",
"profile": "Profil",
"profile": "Mój profil",
"gyms": "Siłownie",
"trainees": "Podopieczni",
"invitations": "Zaproszenia",

View File

@@ -100,12 +100,17 @@ afterEach(() => {
});
describe('Panel admina w aplikacji', () => {
it('administrator widzi link „Panel admina” w stopce sidebaru', async () => {
it('administrator widzi link „Panel admina” jako pierwszy wpis w menu, nad „Dashboard”', async () => {
await login(user({ isAdmin: true }));
const link = screen.getByRole('link', { name: 'Panel admina' });
expect(link).toBeInTheDocument();
expect(link.getAttribute('href')).toBe(ADMIN_URL);
// pozycja: pierwszy wpis nawigacji, zaraz przed „Dashboard”
const nav = link.closest('nav');
const items = nav ? Array.from(nav.querySelectorAll('a')) : [];
expect(items[0]).toBe(link);
expect(items[1]?.textContent).toBe('Dashboard');
});
it('ikony w railu (przyciemniony sidebar) są tej samej wielkości', async () => {

View File

@@ -193,8 +193,8 @@ async function loginAndOpenPlans(user: userEvent.User, email: string) {
await user.type(password, 'Password123!');
await user.click(screen.getByRole('button', { name: 'Zaloguj' }));
expect(await screen.findByRole('heading', { name: 'Dashboard' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Plany' }));
expect(await screen.findByRole('heading', { name: 'Plany' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Plany treningowe' }));
expect(await screen.findByRole('heading', { name: 'Plany treningowe' })).toBeInTheDocument();
}
beforeEach(async () => {

View File

@@ -142,8 +142,8 @@ async function loginAndOpenNewPlan(user: userEvent.User) {
await user.type(password, 'Password123!');
await user.click(screen.getByRole('button', { name: 'Zaloguj' }));
expect(await screen.findByRole('heading', { name: 'Dashboard' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Plany' }));
expect(await screen.findByRole('heading', { name: 'Plany' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Plany treningowe' }));
expect(await screen.findByRole('heading', { name: 'Plany treningowe' })).toBeInTheDocument();
// „Nowy plan” pojawia się w menu kontekstowym i w pustym stanie listy — klikamy pierwsze (menu)
await user.click(screen.getAllByRole('button', { name: 'Nowy plan' })[0]);
expect(await screen.findByRole('heading', { name: 'Nowy plan' })).toBeInTheDocument();

View File

@@ -109,8 +109,8 @@ async function openPlans(user: userEvent.User) {
await user.type(password, 'Password123!');
await user.click(screen.getByRole('button', { name: 'Zaloguj' }));
expect(await screen.findByRole('heading', { name: 'Dashboard' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Plany' }));
expect(await screen.findByRole('heading', { name: 'Plany' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Plany treningowe' }));
expect(await screen.findByRole('heading', { name: 'Plany treningowe' })).toBeInTheDocument();
}
beforeEach(() => {

View File

@@ -141,12 +141,12 @@ async function loginToProfile(user: userEvent.User) {
await user.type(password, 'Password123!');
await user.click(screen.getByRole('button', { name: 'Zaloguj' }));
expect(await screen.findByRole('heading', { name: 'Dashboard' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Profil' }));
expect(await screen.findByRole('heading', { name: 'Profil' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Mój profil' }));
expect(await screen.findByRole('heading', { name: 'Mój profil' })).toBeInTheDocument();
// body parameters live on their own subpage — open it via the tile
await user.click(await screen.findByRole('link', { name: /Parametry ciała/ }));
// topbar (h1) = rodzic „Profil”, nazwa podstrony niżej jako PageHeader (h2)
expect(await screen.findByRole('heading', { name: 'Profil', level: 1 })).toBeInTheDocument();
// topbar (h1) = rodzic „Mój profil”, nazwa podstrony niżej jako PageHeader (h2)
expect(await screen.findByRole('heading', { name: 'Mój profil', level: 1 })).toBeInTheDocument();
expect(
await screen.findByRole('heading', { name: 'Parametry ciała', level: 2 }),
).toBeInTheDocument();

View File

@@ -82,12 +82,12 @@ async function loginToProfile(user: userEvent.User) {
await user.type(password, 'Password123!');
await user.click(screen.getByRole('button', { name: 'Zaloguj' }));
expect(await screen.findByRole('heading', { name: 'Dashboard' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Profil' }));
expect(await screen.findByRole('heading', { name: 'Profil' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Mój profil' }));
expect(await screen.findByRole('heading', { name: 'Mój profil' })).toBeInTheDocument();
// body parameters live on their own subpage — open it via the tile
await user.click(await screen.findByRole('link', { name: /Parametry ciała/ }));
// topbar (h1) = rodzic „Profil”, nazwa podstrony niżej jako PageHeader (h2)
expect(await screen.findByRole('heading', { name: 'Profil', level: 1 })).toBeInTheDocument();
// topbar (h1) = rodzic „Mój profil”, nazwa podstrony niżej jako PageHeader (h2)
expect(await screen.findByRole('heading', { name: 'Mój profil', level: 1 })).toBeInTheDocument();
expect(
await screen.findByRole('heading', { name: 'Parametry ciała', level: 2 }),
).toBeInTheDocument();

View File

@@ -104,8 +104,8 @@ describe('Profile flow (repro of React #301)', () => {
expect(await screen.findByRole('heading', { name: 'Dashboard' })).toBeInTheDocument();
// navigate to profile overview
await user.click(screen.getByRole('link', { name: 'Profil' }));
expect(await screen.findByRole('heading', { name: 'Profil' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Mój profil' }));
expect(await screen.findByRole('heading', { name: 'Mój profil' })).toBeInTheDocument();
// open the personal data subpage via the section row
await user.click(await screen.findByRole('link', { name: /Dane osobowe/ }));

View File

@@ -115,8 +115,8 @@ async function loginToInfo(user: userEvent.User) {
await user.type(password, 'Password123!');
await user.click(screen.getByRole('button', { name: 'Zaloguj' }));
expect(await screen.findByRole('heading', { name: 'Dashboard' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Profil' }));
expect(await screen.findByRole('heading', { name: 'Profil' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Mój profil' }));
expect(await screen.findByRole('heading', { name: 'Mój profil' })).toBeInTheDocument();
await user.click(await screen.findByRole('link', { name: /Dane osobowe/ }));
expect(
await screen.findByRole('heading', { name: 'Dane osobowe', level: 2 }),

View File

@@ -153,8 +153,8 @@ async function loginToProfile(user: userEvent.User) {
await user.type(password, 'Password123!');
await user.click(screen.getByRole('button', { name: 'Zaloguj' }));
expect(await screen.findByRole('heading', { name: 'Dashboard' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Profil' }));
expect(await screen.findByRole('heading', { name: 'Profil' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Mój profil' }));
expect(await screen.findByRole('heading', { name: 'Mój profil' })).toBeInTheDocument();
}
function renderApp() {
@@ -240,7 +240,7 @@ describe('Profile overview — hero, statystyki i wiersze sekcji', () => {
// wstecz wraca na przegląd („Wstecz” jest w topmenu i w treści — oba prowadzą do /profile)
await user.click(screen.getAllByRole('button', { name: 'Wstecz' })[0]);
expect(await screen.findByRole('heading', { name: 'Profil' })).toBeInTheDocument();
expect(await screen.findByRole('heading', { name: 'Mój profil' })).toBeInTheDocument();
expect(screen.getByRole('link', { name: /Dane osobowe/ })).toBeInTheDocument();
});
});

View File

@@ -26,7 +26,7 @@ async function login(page: import('@playwright/test').Page) {
test('profil: podgląd nicku i social media', async ({ page }) => {
mockApi(page, { me: { user: TEST_USER_WITH_SOCIALS, memberships: [] } });
await login(page);
await page.getByRole('link', { name: 'Profil' }).click();
await page.getByRole('link', { name: 'Mój profil' }).click();
await page.getByRole('link', { name: 'Dane osobowe' }).click();
await expect(page.getByRole('heading', { name: 'Dane osobowe', level: 2 })).toBeVisible();
@@ -44,7 +44,7 @@ test('profil: podgląd nicku i social media', async ({ page }) => {
test('profil: ustawienie nicku i social media w edycji (per sekcja)', async ({ page }) => {
mockApi(page, { me: { user: TEST_USER, memberships: [] } });
await login(page);
await page.getByRole('link', { name: 'Profil' }).click();
await page.getByRole('link', { name: 'Mój profil' }).click();
await page.getByRole('link', { name: 'Dane osobowe' }).click();
await expect(page.getByRole('heading', { name: 'Dane osobowe', level: 2 })).toBeVisible();

View File

@@ -10,7 +10,7 @@ async function login(page: Page) {
}
async function openNewPlan(page: Page) {
await page.getByRole('link', { name: 'Plany' }).click();
await page.getByRole('link', { name: 'Plany treningowe' }).click();
await page.getByRole('button', { name: 'Nowy plan' }).first().click();
await expect(page.getByRole('heading', { name: 'Nowy plan' })).toBeVisible();
}

View File

@@ -16,8 +16,8 @@ async function login(page: Page) {
async function openNewPlan(page: Page) {
// mobile: nawigacja przez hamburgera (drawer)
await page.getByRole('button', { name: 'Otwórz menu' }).click();
await page.getByRole('link', { name: 'Plany' }).click();
await expect(page.getByRole('heading', { name: 'Plany' })).toBeVisible();
await page.getByRole('link', { name: 'Plany treningowe' }).click();
await expect(page.getByRole('heading', { name: 'Plany treningowe' })).toBeVisible();
// akcja „Nowy plan” (Link w grupie „Dodawanie”, nie CTA z topbara)
await page.getByRole('link', { name: 'Nowy plan' }).click();
await expect(page.getByRole('heading', { name: 'Nowy plan' })).toBeVisible();

View File

@@ -94,7 +94,7 @@ test('„Udostępnione mi”: plan read-only — bez akcji statusowych, „Udost
mockRecipientPlans(page);
await login(page);
await page.getByRole('link', { name: 'Plany' }).click();
await page.getByRole('link', { name: 'Plany treningowe' }).click();
await expect(page.getByRole('heading', { name: 'Udostępnione mi' })).toBeVisible();
await expect(page.getByText('udostępnił: Jan Kowalski')).toBeVisible();
@@ -115,7 +115,7 @@ test('właściciel: „Udostępnij” — dialog z podopiecznymi, share = POST /
mockOwnerPlans(page);
await login(page);
await page.getByRole('link', { name: 'Plany' }).click();
await page.getByRole('link', { name: 'Plany treningowe' }).click();
await page.getByRole('link', { name: /Plan masowy/ }).click();
await expect(page.getByRole('heading', { name: 'Plan masowy' })).toBeVisible();

View File

@@ -16,8 +16,8 @@ test('formularz nowego planu ma wybór tygodnia startu i przycisk „Wstecz” w
await login(page);
// nawigacja do listy planów
await page.getByRole('link', { name: 'Plany' }).click();
await expect(page.getByRole('heading', { name: 'Plany' })).toBeVisible();
await page.getByRole('link', { name: 'Plany treningowe' }).click();
await expect(page.getByRole('heading', { name: 'Plany treningowe' })).toBeVisible();
// otwórz formularz nowego planu (akcja „Nowy plan” w menu kontekstowym — na PC inline)
await page.getByRole('button', { name: 'Nowy plan' }).first().click();
@@ -54,7 +54,7 @@ test('walidacja tytułu i podsumowanie w kroku 3', async ({ page }) => {
mockPlans(page);
await login(page);
await page.getByRole('link', { name: 'Plany' }).click();
await page.getByRole('link', { name: 'Plany treningowe' }).click();
await page.getByRole('button', { name: 'Nowy plan' }).first().click();
await expect(page.getByRole('heading', { name: 'Nowy plan' })).toBeVisible();
@@ -82,7 +82,7 @@ test('zakładki tygodni: klik taba przełącza tydzień; lustrzany — podgląd
mockPlans(page);
await login(page);
await page.getByRole('link', { name: 'Plany' }).click();
await page.getByRole('link', { name: 'Plany treningowe' }).click();
await page.getByRole('button', { name: 'Nowy plan' }).first().click();
await expect(page.getByRole('heading', { name: 'Nowy plan' })).toBeVisible();
@@ -109,7 +109,7 @@ test('kopiowanie dni z dowolnego tygodnia („Kopiuj z…”)', async ({ page })
mockPlans(page);
await login(page);
await page.getByRole('link', { name: 'Plany' }).click();
await page.getByRole('link', { name: 'Plany treningowe' }).click();
await page.getByRole('button', { name: 'Nowy plan' }).first().click();
await page.getByPlaceholder('np. Plan masowy 8-tygodniowy').fill('Plan');
await page.getByRole('button', { name: 'Dalej' }).click();
@@ -148,8 +148,8 @@ test('zmiana kolejności ćwiczeń i stepper serii', async ({ page }) => {
mockPlans(page);
await login(page);
await page.getByRole('link', { name: 'Plany' }).click();
await expect(page.getByRole('heading', { name: 'Plany' })).toBeVisible();
await page.getByRole('link', { name: 'Plany treningowe' }).click();
await expect(page.getByRole('heading', { name: 'Plany treningowe' })).toBeVisible();
await page.getByRole('button', { name: 'Nowy plan' }).first().click();
await expect(page.getByRole('heading', { name: 'Nowy plan' })).toBeVisible();

View File

@@ -247,7 +247,7 @@ test('profil → historia treningów: sekcja „Moje wizyty” z listą wizyt',
},
});
await login(page);
await page.getByRole('link', { name: 'Profil' }).click();
await page.getByRole('link', { name: 'Mój profil' }).click();
await page.getByRole('link', { name: /Historia treningów/ }).click();
await expect(page.getByRole('heading', { name: 'Historia treningów', level: 2 })).toBeVisible();

View File

@@ -8,8 +8,8 @@ async function loginToClaims(page: import('@playwright/test').Page) {
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: 'Profil' }).click();
await expect(page.getByRole('heading', { name: 'Profil' })).toBeVisible();
await page.getByRole('link', { name: 'Mój profil' }).click();
await expect(page.getByRole('heading', { name: 'Mój profil' })).toBeVisible();
// kafel „Wnioski” prowadzi na podstronę
await page.getByRole('link', { name: /^Wnioski / }).click();
await expect(page.getByRole('heading', { name: 'Wnioski', level: 2 })).toBeVisible();

View File

@@ -15,8 +15,8 @@ async function login(page: Page) {
async function openProfile(page: Page) {
// mobile: nawigacja przez hamburgera (drawer)
await page.getByRole('button', { name: 'Otwórz menu' }).click();
await page.getByRole('link', { name: 'Profil' }).click();
await expect(page.getByRole('heading', { name: 'Profil' })).toBeVisible();
await page.getByRole('link', { name: 'Mój profil' }).click();
await expect(page.getByRole('heading', { name: 'Mój profil' })).toBeVisible();
}
async function expectNoHorizontalScroll(page: Page, label: string) {
@@ -221,7 +221,10 @@ test('mobile 320px: brak poziomego scrolla na podstronach profilu', async ({ pag
for (const [linkRe, heading] of pages) {
await page.getByRole('link', { name: linkRe }).click();
await expect(
page.getByRole('heading', { name: heading === 'Siłownie' ? 'Siłownie' : 'Profil', level: 1 }),
page.getByRole('heading', {
name: heading === 'Siłownie' ? 'Siłownie' : 'Mój profil',
level: 1,
}),
).toBeVisible();
if (heading !== 'Siłownie') {
await expect(page.getByRole('heading', { name: heading, level: 2 })).toBeVisible();
@@ -230,11 +233,11 @@ test('mobile 320px: brak poziomego scrolla na podstronach profilu', async ({ pag
if (heading === 'Siłownie') {
// /gyms to strona główna nawigacji (bez „Wstecz” w topmenu) — powrót przez menu
await page.getByRole('button', { name: 'Otwórz menu' }).click();
await page.getByRole('link', { name: 'Profil' }).click();
await page.getByRole('link', { name: 'Mój profil' }).click();
} else {
// wstecz na przegląd („<” w topmenu)
await page.locator('header').getByRole('button', { name: 'Wstecz' }).click();
}
await expect(page.getByRole('heading', { name: 'Profil' })).toBeVisible();
await expect(page.getByRole('heading', { name: 'Mój profil' })).toBeVisible();
}
});

View File

@@ -33,7 +33,7 @@ async function openTraineePlansTab(
await expect(page.getByRole('heading', { name: 'Podopieczni' })).toBeVisible();
await page.getByRole('button', { name: 'Anna Nowak' }).click();
await expect(page.getByRole('heading', { name: 'Anna Nowak' })).toBeVisible();
await page.getByRole('button', { name: 'Plany' }).click();
await page.getByRole('button', { name: 'Plany', exact: true }).click();
await expect(page.getByRole('heading', { name: 'Plany podopiecznego' })).toBeVisible();
}

View File

@@ -89,8 +89,8 @@ async function loginToProgress(user: userEvent.User) {
await user.type(password, 'Password123!');
await user.click(screen.getByRole('button', { name: 'Zaloguj' }));
expect(await screen.findByRole('heading', { name: 'Dashboard' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Profil' }));
expect(await screen.findByRole('heading', { name: 'Profil' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: 'Mój profil' }));
expect(await screen.findByRole('heading', { name: 'Mój profil' })).toBeInTheDocument();
await user.click(screen.getByRole('link', { name: /Postępy/ }));
expect(await screen.findByRole('heading', { name: 'Postępy', level: 2 })).toBeInTheDocument();
}