Files
portal/app/tests/Frontend/AppMoreDrawerAdvertising.spec.ts
T
Дмитрий bbbc4b4b90 feat(реклама-фронт): роут /advertising/yandex + витрина Яндекса ведёт на реальный экран
Канал «Яндекс Аудитория» в разделе «Рекламные возможности» (сайдбар +
мобильное «Ещё») больше не заглушка: клик ведёт на новый роут
/advertising/yandex со скелетом экрана (заголовок + вкладки «Мои
кампании» / «Новая реклама»). Остальные 4 канала — без изменений
(по-прежнему открывают AdStubDialog).
2026-07-25 00:57:03 +03:00

71 lines
3.5 KiB
TypeScript

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<VueWrapper> {
const router = createRouter({
history: createMemoryHistory(),
routes: [{ path: '/:pathMatch(.*)*', component: { template: '<div />' } }],
});
router.push('/settings');
await router.isReady();
return mount(AppMoreDrawer, {
props: { open: true },
global: {
plugins: [createVuetify(), router],
stubs: {
VNavigationDrawer: { template: '<div><slot /></div>' },
VDialog: { template: '<div><slot /></div>' },
},
},
});
}
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]);
});
});