import { describe, it, expect } from 'vitest'; import { mount, type VueWrapper } from '@vue/test-utils'; import { createVuetify } from 'vuetify'; import { createRouter, createMemoryHistory } from 'vue-router'; import AppMoreDrawer from '../../resources/js/components/layout/AppMoreDrawer.vue'; // Мобильное «Ещё» открыто (open=true). Drawer/Dialog телепортят/скрывают контент — // стабим их passthrough, чтобы искать пункты и окно в wrapper. async function setup(): Promise { const router = createRouter({ history: createMemoryHistory(), routes: [{ path: '/:pathMatch(.*)*', component: { template: '
' } }], }); router.push('/settings'); await router.isReady(); return mount(AppMoreDrawer, { props: { open: true }, global: { plugins: [createVuetify(), router], stubs: { VNavigationDrawer: { template: '
' }, VDialog: { template: '
' }, }, }, }); } const AD_ITEMS = [ { testid: 'ad-nav-ai-callcenter', title: 'ИИ колцентр' }, { testid: 'ad-nav-sms', title: 'Рассылка СМС' }, { testid: 'ad-nav-yandex-audience', title: 'Яндекс Аудитория' }, { testid: 'ad-nav-vk', title: 'VK Реклама' }, { testid: 'ad-nav-telegram', title: 'Реклама Телеграм' }, ]; // B2-2: Яндекс — уже реальный роут, не заглушка. Остальные 4 — по-прежнему «В разработке». const STUB_ITEMS = AD_ITEMS.filter((i) => i.testid !== 'ad-nav-yandex-audience'); describe('AppMoreDrawer — раздел «Рекламные возможности» на телефоне', () => { it('содержит 5 рекламных пунктов с нужными названиями', async () => { const wrapper = await setup(); for (const item of AD_ITEMS) { const el = wrapper.find(`[data-testid="${item.testid}"]`); expect(el.exists(), `нет пункта ${item.testid}`).toBe(true); expect(el.text()).toContain(item.title); } }); it('пока не кликнули — окно «В разработке» не показано', async () => { const wrapper = await setup(); expect(wrapper.find('[data-testid="ad-stub-dialog"]').exists()).toBe(false); }); it.each(STUB_ITEMS)('клик по «$title» открывает окно с текстом релиза', async ({ testid }) => { const wrapper = await setup(); await wrapper.find(`[data-testid="${testid}"]`).trigger('click'); const dialog = wrapper.find('[data-testid="ad-stub-dialog"]'); expect(dialog.exists()).toBe(true); expect(dialog.text()).toContain('В разработке'); expect(dialog.text()).toContain('01.09.2026'); }); // B2-2: Яндекс Аудитория — теперь реальный переход, не заглушка; клик закрывает «Ещё». it('клик по «Яндекс Аудитория» НЕ открывает заглушку и закрывает «Ещё»', async () => { const wrapper = await setup(); await wrapper.find('[data-testid="ad-nav-yandex-audience"]').trigger('click'); expect(wrapper.find('[data-testid="ad-stub-dialog"]').exists()).toBe(false); expect(wrapper.emitted('update:open')?.at(-1)).toEqual([false]); }); // T19: «Рекламный кошелёк» — реальная ссылка, не заглушка; клик закрывает «Ещё». it('содержит «Рекламный кошелёк», клик НЕ открывает заглушку и закрывает «Ещё»', async () => { const wrapper = await setup(); const link = wrapper.find('[data-testid="ad-nav-wallet"]'); expect(link.exists()).toBe(true); expect(link.text()).toContain('Рекламный кошелёк'); await link.trigger('click'); expect(wrapper.find('[data-testid="ad-stub-dialog"]').exists()).toBe(false); expect(wrapper.emitted('update:open')?.at(-1)).toEqual([false]); }); });