Files
portal/app/tests/Frontend/collectResultMessage.spec.ts
T
Дмитрий 505b8ed059 feat(autopodbor): повторный сбор источников — фронт
Кнопка «🔄 Собрать источники ещё раз» вместо мёртвой «✓ Источники собраны».
Окно предупреждает, что повтор платный (даже если нового нет). Честный итог
после сбора (N новых / M ранее удалённых). Блок «ранее удалённые — вернуть?»
с кнопкой «Вернуть» (box archived→proposal).

- RunDto.result + collectResultMessage (чистый хелпер) + тесты
- store.restoreSource + тест
- компонент RefoundDeletedSources + тест
- FieldCompetitorScreen: кнопка-повтор, честный итог, блок «вернуть», текст окна

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-05 06:08:53 +03:00

35 lines
1.7 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { collectResultMessage } from '../../resources/js/api/autopodbor';
describe('collectResultMessage — честный итог сбора источников', () => {
it('есть и новые, и ранее удалённые', () => {
const m = collectResultMessage({ new_sources: 2, refound_deleted: 1, refound_deleted_ids: [7] });
expect(m).toContain('2');
expect(m).toContain('1');
expect(m.toLowerCase()).toContain('ранее удал');
});
it('только новые', () => {
const m = collectResultMessage({ new_sources: 3, refound_deleted: 0, refound_deleted_ids: [] });
expect(m).toContain('3');
expect(m.toLowerCase()).toContain('предложен');
expect(m.toLowerCase()).not.toContain('ранее удал');
});
it('только ранее удалённые', () => {
const m = collectResultMessage({ new_sources: 0, refound_deleted: 2, refound_deleted_ids: [1, 2] });
expect(m.toLowerCase()).toContain('новых источников нет');
expect(m).toContain('2');
});
it('ничего нового — честно говорим, что всё уже видно', () => {
const m = collectResultMessage({ new_sources: 0, refound_deleted: 0, refound_deleted_ids: [] });
expect(m.toLowerCase()).toContain('не нашл');
expect(m.toLowerCase()).toContain('уже');
});
it('нет итога (null) — пустая строка (первый сбор через общий флеш)', () => {
expect(collectResultMessage(null)).toBe('');
});
});