import { describe, it, expect } from 'vitest'; import { mount } from '@vue/test-utils'; import { createVuetify } from 'vuetify'; import { createRouter, createMemoryHistory, type Router } from 'vue-router'; import LegalDocView from '../../resources/js/views/legal/LegalDocView.vue'; const vuetify = createVuetify(); const buildRouter = (): Router => createRouter({ history: createMemoryHistory(), routes: [ { path: '/legal/:doc(offer|privacy)', name: 'legal', component: LegalDocView }, { path: '/login', name: 'login', component: { template: '
login
' } }, ], }); const mountAt = async (path: string) => { const router = buildRouter(); await router.push(path); await router.isReady(); return mount(LegalDocView, { global: { plugins: [vuetify, router] } }); }; describe('LegalDocView.vue', () => { it('рендерит «Договор-оферта» на /legal/offer', async () => { const wrapper = await mountAt('/legal/offer'); expect(wrapper.text()).toContain('Договор-оферта'); }); it('рендерит «Политика конфиденциальности» на /legal/privacy', async () => { const wrapper = await mountAt('/legal/privacy'); expect(wrapper.text()).toContain('Политика конфиденциальности'); }); it('показывает честную заглушку «документ готовится», а не фейк-текст', async () => { const wrapper = await mountAt('/legal/offer'); const notice = wrapper.find('[data-testid="legal-stub-notice"]'); expect(notice.exists()).toBe(true); expect(notice.text()).toContain('готовится'); }); it('содержит ссылку возврата ко входу', async () => { const wrapper = await mountAt('/legal/privacy'); const back = wrapper.find('a.legal-back'); expect(back.exists()).toBe(true); expect(back.attributes('href')).toBe('/login'); }); });