arm-web/src/widgets/FilesDrawer/documentRows.test.ts
Andrey Epifancev 6f8f04a707 feat: экраны по макету — панель документов [39]/[40], сводная ОСВ [30], проверка распознавания [41]/[41-02], консолидации [34], группы [03], логотип, модалка [42] (H-2, #3)
- [39] таблица документов: формат, период, проверка Период/Контрагент, статус плашкой; шапка с ЮЛ и ИНН
- [30] шапка «ГК — год Кn» со статусом, вкладки (только ОСВ), баннер «Осталось N» с фильтром
  несопоставленных, колонки и двухуровневые заголовки макета, фильтры в заголовках, «—» для нуля
- [41] карточки «Исходный документ» / «Результат распознавания», режим просмотра и «Редактировать»,
  форма как бумажный документ, суммы без копеек
- [34] Дата создания, Дата верификации (—, в API нет), ГСК (—, П-3), квартал «К3»
- [03] Основной РФ — название филиала, а не UUID
- логотип АРМ КА, заголовок вкладки, «Отчётность»; [42] члены ГСК наверху списка

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EAKRDNzXtRrwmWz9z6PZu3
2026-10-08 03:10:34 +04:00

108 lines
3.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { describe, expect, it } from 'vitest';
import type { DocumentBrief, FileOut } from '../../types/api';
import { buildDocumentRows } from './documentRows';
const doc = (over: Partial<DocumentBrief> = {}): DocumentBrief => ({
id: 'd1',
document_type: 'BALANCE',
osv_account_code: null,
period_year: 2024,
period_quarter: 'Q1',
is_cumulative: false,
status: 'CONFIRMED',
period_check: 'UNKNOWN',
counterparty_check: null,
locator: null,
comments_count: 0,
...over,
});
const file = (over: Partial<FileOut> = {}): FileOut => ({
id: 'f1',
legal_entity_id: 'le',
original_name: 'Баланс_2024_К1.pdf',
file_type: 'PDF',
status: 'PROCESSED',
version_no: 1,
size_bytes: 10,
uploaded_at: '2024-03-12T10:00:00Z',
job: null,
documents: [],
...over,
});
describe('buildDocumentRows', () => {
it('документ ББ из PDF', () => {
const rows = buildDocumentRows([file({ documents: [doc()] })]);
expect(rows).toHaveLength(1);
expect(rows[0]).toMatchObject({
key: 'd1',
documentId: 'd1',
name: 'Баланс_2024_К1.pdf',
subtitle: 'Бух. баланс · PDF · 12.03.2024',
period: '2024 К1',
periodCheck: 'UNKNOWN',
counterpartyCheck: null,
status: 'success',
statusLabel: 'Загружен',
linkable: true,
fileType: 'PDF',
});
});
it('два документа одного файла — две строки', () => {
const rows = buildDocumentRows([
file({
file_type: 'XLSX',
documents: [
doc({ id: 'a', document_type: 'OSV', osv_account_code: '60' }),
doc({ id: 'b', document_type: 'OSV', osv_account_code: '62', status: 'NEEDS_CHECK' }),
],
}),
]);
expect(rows.map((r) => r.key)).toEqual(['a', 'b']);
expect(rows[0].subtitle).toBe('ОСВ 60 · XLSX · 12.03.2024');
expect(rows[1].status).toBe('warning');
expect(rows[1].statusLabel).toBe('Требуется проверка');
});
it('файл PROCESSING без документов', () => {
const rows = buildDocumentRows([file({ status: 'PROCESSING' })]);
expect(rows).toHaveLength(1);
expect(rows[0]).toMatchObject({
key: 'f1',
documentId: null,
period: '—',
subtitle: 'PDF · 12.03.2024',
status: 'processing',
statusLabel: 'Обработка',
linkable: false,
});
});
it('файл ERROR с причиной', () => {
const rows = buildDocumentRows([
file({
status: 'ERROR',
job: {
id: 'j',
status: 'FAILED',
error_code: 'E1',
error_message: 'сообщение',
mapping_error: null,
warnings: [],
mapping_warnings: [],
finished_at: null,
} as FileOut['job'],
}),
]);
expect(rows[0]).toMatchObject({ status: 'error', statusLabel: 'Ошибка', errorReason: 'сообщение', linkable: false });
});
it('расшифровка — «Прочий документ», не кликается', () => {
const rows = buildDocumentRows([file({ documents: [doc({ id: 'x', document_type: 'DISCLOSURE' })] })]);
expect(rows[0].subtitle).toBe('Прочий документ · PDF · 12.03.2024');
expect(rows[0].linkable).toBe(false);
});
});