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('показывает реальный текст оферты (рабочая редакция под ЮKassa), а не заглушку', async () => {
const wrapper = await mountAt('/legal/offer');
const text = wrapper.text();
// Реальные разделы + дата редакции из content/legalDocs.ts.
expect(text).toContain('Предмет');
expect(text).toContain('Реквизиты Исполнителя');
expect(text).toContain('Редакция от 2026-06-24');
expect(text).not.toContain('готовится');
});
it('политика конфиденциальности содержит реальные разделы (оператор/права субъекта)', async () => {
const wrapper = await mountAt('/legal/privacy');
const text = wrapper.text();
expect(text).toContain('Оператор');
expect(text).toContain('Права субъекта');
expect(text).toContain('Редакция от 2026-06-24');
});
});