import { describe, it, expect } from 'vitest'; import { mount } from '@vue/test-utils'; import { createVuetify } from 'vuetify'; import { createRouter, createMemoryHistory } from 'vue-router'; import AppShell from '../../resources/js/components/AppShell.vue'; // AppShell мапит meta.layout текущего route'а на layout-компонент. // На default-layout рендерит v-app + v-app-bar; на 'auth' — AuthLayout. const mountWithRouter = async (path: string, defaultMeta: Record = {}) => { const router = createRouter({ history: createMemoryHistory(), routes: [ { path: '/', redirect: '/test' }, { path: '/test', component: { template: '
test view
' }, meta: defaultMeta }, { path: '/login', component: { template: '
login stub
' }, meta: { layout: 'auth' } }, ], }); await router.push(path); await router.isReady(); return mount(AppShell, { global: { plugins: [createVuetify(), router], }, }); }; describe('AppShell.vue', () => { it('монтируется без ошибок на default-layout', async () => { const wrapper = await mountWithRouter('/test'); expect(wrapper.exists()).toBe(true); }); it('рендерит брендовое имя и chip фазы на default-layout', async () => { const wrapper = await mountWithRouter('/test'); expect(wrapper.text()).toContain('Лидерра.'); expect(wrapper.text()).toContain('phase 2'); }); it('переключается на AuthLayout при meta.layout = auth', async () => { const wrapper = await mountWithRouter('/login'); // На auth-layout shell не показывает app-bar и phase-chip — рендерится AuthLayout. expect(wrapper.text()).not.toContain('phase 2'); }); });