import { mount, flushPromises } from '@vue/test-utils'; import { createVuetify } from 'vuetify'; import { describe, expect, it, vi, beforeEach } from 'vitest'; vi.mock('../../resources/js/api/sales', () => ({ listProspects: vi.fn().mockResolvedValue({ prospects: [ { id: 1, sales_user_id: 1, stage: 'new', firm_name: 'ООО Демо', city: 'Ростов', phone: null, site: null, inn: null, rating_label: 'горячая', payload: {}, next_call_at: null, reason: null, registered_email: null, notes: null, }, ], by_stage: {}, stages: [], }), updateProspect: vi.fn().mockResolvedValue({ id: 1, stage: 'negotiation' }), extractSalesErrorMessage: () => 'err', })); import SalesProspectsView from '../../resources/js/views/sales/SalesProspectsView.vue'; import { listProspects } from '../../resources/js/api/sales'; const vuetify = createVuetify(); describe('SalesProspectsView', () => { beforeEach(() => vi.clearAllMocks()); it('загружает и показывает карточки менеджера', async () => { const w = mount(SalesProspectsView, { global: { plugins: [vuetify] } }); await flushPromises(); expect(listProspects).toHaveBeenCalledWith(undefined); expect(w.text()).toContain('ООО Демо'); }); });