fix(layout): topbar title из route.meta.title для страниц вне sidebar-nav

AppLayout брал заголовок топбара только из sidebar navItems → /reminders и
/import (которых нет в боковом меню) показывали fallback «Страница». Добавлен
fallback на route.meta.title перед «Страница». TDD: AppLayout.spec.ts (RED→GREEN).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Дмитрий
2026-05-20 19:23:58 +03:00
parent 7785f9a744
commit 08ef38ebed
2 changed files with 26 additions and 1 deletions
+7 -1
View File
@@ -41,7 +41,13 @@ const navItems = computed(() => [
]);
const currentPageTitle = computed(() => {
return navItems.value.find((i) => i.to === route.path)?.title ?? 'Страница';
// Сначала короткий title из sidebar-nav (Дашборд/Сделки/…), затем — route.meta.title
// для страниц вне sidebar (Напоминания, Импорт данных), и только потом fallback.
return (
navItems.value.find((i) => i.to === route.path)?.title ??
(route.meta.title as string | undefined) ??
'Страница'
);
});
async function loadNotifications(): Promise<void> {
+19
View File
@@ -59,6 +59,13 @@ const mountAppLayout = async (path = '/dashboard', user: AuthUser | null = mockU
{ path: '/billing', component: { template: '<div>billing</div>' } },
{ path: '/reports', component: { template: '<div>reports</div>' } },
{ path: '/settings', component: { template: '<div>settings</div>' } },
// Не в sidebar nav, но имеют meta.title — topbar должен брать title оттуда.
{
path: '/reminders',
component: { template: '<div>reminders</div>' },
meta: { title: 'Напоминания' },
},
{ path: '/import', component: { template: '<div>import</div>' }, meta: { title: 'Импорт данных' } },
],
});
await router.push(path);
@@ -110,6 +117,18 @@ describe('AppLayout.vue', () => {
expect(wrapper.text()).toContain('Дашборд');
});
it('topbar title для страницы вне sidebar nav берётся из route.meta.title (Напоминания)', async () => {
const wrapper = await mountAppLayout('/reminders');
// Напоминания нет в sidebar nav (см. тест выше) — title должен прийти из meta, не «Страница».
expect(wrapper.text()).toContain('Напоминания');
expect(wrapper.text()).not.toContain('Страница');
});
it('topbar title для /import берётся из route.meta.title (Импорт данных)', async () => {
const wrapper = await mountAppLayout('/import');
expect(wrapper.text()).toContain('Импорт данных');
});
it('user-chip показывает initials и shortName из store user', async () => {
const wrapper = await mountAppLayout();
const text = wrapper.text();