d640631d3f
Колонка «Взят в работу» сразу после «Новые» (9 колонок). Открытие карточки из «Новые» само шлёт action=opened; в карточке кнопка «Вернуть в Новые» (только на этой стадии). Бейдж на карточке: «своя» / «от начальника». Новый диалог «Добавить кандидата» (название обязательно, пустые поля → null) + кнопка на доске менеджера. У начальника селект «Происхождение» (все/из поиска/свои). Гейты: фронт 30/30. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
90 lines
3.2 KiB
TypeScript
90 lines
3.2 KiB
TypeScript
import { mount, flushPromises } from '@vue/test-utils';
|
|
import { createVuetify } from 'vuetify';
|
|
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
|
|
|
function card(overrides: Record<string, unknown> = {}) {
|
|
return {
|
|
id: 1,
|
|
sales_user_id: 1,
|
|
stage: 'new',
|
|
source: 'search',
|
|
firm_name: 'ООО Демо',
|
|
city: 'Ростов',
|
|
phone: null,
|
|
site: null,
|
|
inn: null,
|
|
rating_label: 'горячая',
|
|
payload: {},
|
|
next_call_at: null,
|
|
reason: null,
|
|
registered_email: null,
|
|
notes: null,
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
vi.mock('../../resources/js/api/sales', () => ({
|
|
listProspects: vi.fn().mockResolvedValue({ prospects: [], by_stage: {}, stages: [] }),
|
|
updateProspect: vi.fn().mockResolvedValue({ id: 1, stage: 'in_work' }),
|
|
createProspect: vi.fn().mockResolvedValue({ id: 2, stage: 'new', source: 'manager' }),
|
|
extractSalesErrorMessage: () => 'err',
|
|
}));
|
|
|
|
import SalesProspectsView from '../../resources/js/views/sales/SalesProspectsView.vue';
|
|
import { listProspects, updateProspect, createProspect } from '../../resources/js/api/sales';
|
|
|
|
const vuetify = createVuetify();
|
|
|
|
interface ViewVm {
|
|
open: (p: unknown) => Promise<void> | void;
|
|
createCandidate: (p: Record<string, unknown>) => Promise<void>;
|
|
}
|
|
|
|
describe('SalesProspectsView', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
(listProspects as ReturnType<typeof vi.fn>).mockResolvedValue({
|
|
prospects: [card()],
|
|
by_stage: {},
|
|
stages: [],
|
|
});
|
|
});
|
|
|
|
it('загружает и показывает карточки менеджера', async () => {
|
|
const w = mount(SalesProspectsView, { global: { plugins: [vuetify] } });
|
|
await flushPromises();
|
|
expect(listProspects).toHaveBeenCalledWith(undefined);
|
|
expect(w.text()).toContain('ООО Демо');
|
|
});
|
|
|
|
it('открытие карточки из «Новые» помечает её взятой в работу (action=opened)', async () => {
|
|
const w = mount(SalesProspectsView, { global: { plugins: [vuetify] } });
|
|
await flushPromises();
|
|
|
|
await (w.vm as unknown as ViewVm).open(card({ id: 7, stage: 'new' }));
|
|
await flushPromises();
|
|
|
|
expect(updateProspect).toHaveBeenCalledWith(7, { action: 'opened' });
|
|
});
|
|
|
|
it('открытие карточки НЕ из «Новые» ничего не помечает', async () => {
|
|
const w = mount(SalesProspectsView, { global: { plugins: [vuetify] } });
|
|
await flushPromises();
|
|
|
|
await (w.vm as unknown as ViewVm).open(card({ id: 8, stage: 'negotiation' }));
|
|
await flushPromises();
|
|
|
|
expect(updateProspect).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('создаёт своего кандидата через createProspect', async () => {
|
|
const w = mount(SalesProspectsView, { global: { plugins: [vuetify] } });
|
|
await flushPromises();
|
|
|
|
await (w.vm as unknown as ViewVm).createCandidate({ firm_name: 'ООО Своя', city: 'Омск' });
|
|
await flushPromises();
|
|
|
|
expect(createProspect).toHaveBeenCalledWith({ firm_name: 'ООО Своя', city: 'Омск' });
|
|
});
|
|
});
|