61 lines
2.0 KiB
TypeScript
61 lines
2.0 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import type { ImportedDataset } from '../../src/domain/dataset';
|
|
import { makeSheet } from '../../src/importers/sheet-factory';
|
|
import { summarizeImportQuality } from '../../src/features/import-insights/import-quality';
|
|
|
|
const sheet = makeSheet('Findings', [['Title', 'Status'], ['A', 'Open']], '', 'sample.csv');
|
|
const confidence = { level: 'medium' as const, score: 0.68, reasons: ['Multiple matching signals detected.'] };
|
|
const dataset: ImportedDataset = {
|
|
fileName: 'sample.csv',
|
|
fileSize: 100,
|
|
lastModified: 0,
|
|
format: 'CSV',
|
|
rawText: '',
|
|
sheets: [sheet],
|
|
profileId: 'generic',
|
|
profileVersion: '1.0.0',
|
|
scanTool: 'Tabular Data',
|
|
recognition: {
|
|
version: 1,
|
|
source: {
|
|
selected: { toolId: 'unknown', toolName: 'Unknown', confidence, evidence: [] },
|
|
candidates: [],
|
|
decisionSource: 'fallback',
|
|
requiresConfirmation: false
|
|
},
|
|
tables: [{
|
|
tableId: sheet.id,
|
|
tableIndex: 0,
|
|
tableName: sheet.name,
|
|
selected: true,
|
|
confidence,
|
|
evidence: [],
|
|
decisionSource: 'automatic',
|
|
requiresConfirmation: true
|
|
}],
|
|
fields: [{
|
|
tableId: sheet.id,
|
|
tableIndex: 0,
|
|
columnIndex: 0,
|
|
sourceHeader: 'Title',
|
|
proposedRole: 'title',
|
|
appliedRole: 'additional',
|
|
alternatives: [],
|
|
confidence: { level: 'low', score: 0.35, reasons: ['Only a weak signal detected.'] },
|
|
evidence: [],
|
|
decisionSource: 'automatic',
|
|
requiresConfirmation: true
|
|
}]
|
|
}
|
|
};
|
|
|
|
describe('import quality summary', () => {
|
|
it('makes mapping confidence and pending confirmations visible', () => {
|
|
const summary = summarizeImportQuality(dataset, sheet);
|
|
expect(summary).toMatchObject({ tone: 'warning', mappingsToReview: 2 });
|
|
expect(summary?.label).toContain('Recognition medium (68 %)');
|
|
expect(summary?.label).toContain('2 mappings to review');
|
|
expect(summary?.details).toContain('Multiple matching signals');
|
|
});
|
|
});
|