feat: refine demo flow measurement results
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { aggregateDemoFlowResults, type DemoFlowSourceResult } from './demoFlowAggregation';
|
||||
import { aggregateDemoFlowResults, demoFlowStatusLabel, type DemoFlowSourceResult } from './demoFlowAggregation';
|
||||
|
||||
function result(id: number, index: number, status: string, resultData: Record<string, unknown>): DemoFlowSourceResult {
|
||||
return { id, type: 'plugin', pluginId: `plugin-${id}`, status, resultData: { demoFlowIndex: index, ...resultData } };
|
||||
@@ -65,6 +65,47 @@ describe('aggregateDemoFlowResults', () => {
|
||||
expect(model.tableRows).toHaveLength(4);
|
||||
});
|
||||
|
||||
it('过滤全流程指定的中间指标,同时保持其他有效测量项的原顺序', () => {
|
||||
const model = aggregateDemoFlowResults([
|
||||
result(10, 1, 'completed', {
|
||||
measurements: [
|
||||
{ name: '车体长度', value: 100, status: 'pass' },
|
||||
{ name: '前后端平移差', value: 0.1, status: 'pass' },
|
||||
{ name: '车体宽度', value: 20, status: 'warning' },
|
||||
{ name: 'ICP fitness', value: 0.98, status: 'pass' },
|
||||
{ name: '配准 RMSE', value: 0.02, status: 'pass' },
|
||||
{ name: '车体高度', value: 30, status: 'fail' },
|
||||
],
|
||||
}),
|
||||
], nameOf);
|
||||
|
||||
expect(model.measurementRows.map((row) => row.measurement.name)).toEqual([
|
||||
'车体长度', '车体宽度', '车体高度',
|
||||
]);
|
||||
});
|
||||
|
||||
it('全流程结果使用统一结论文案,不采用算法自定义文案', () => {
|
||||
expect(demoFlowStatusLabel({ status: 'pass' })).toBe('合格');
|
||||
expect(demoFlowStatusLabel({ status: 'warning' })).toBe('警告');
|
||||
expect(demoFlowStatusLabel({ status: 'fail' })).toBe('超差');
|
||||
expect(demoFlowStatusLabel({ status: 'info' })).toBe('参考');
|
||||
expect(demoFlowStatusLabel({})).toBe('参考');
|
||||
|
||||
const model = aggregateDemoFlowResults([
|
||||
result(10, 1, 'completed', {
|
||||
measurements: [
|
||||
{ name: '通过项', value: 1, status: 'pass', passLabel: '通过' },
|
||||
{ name: '警告项', value: 2, status: 'warning', warningLabel: '部分成功' },
|
||||
{ name: '失败项', value: 3, status: 'fail', failLabel: '失败' },
|
||||
],
|
||||
}),
|
||||
], nameOf);
|
||||
|
||||
expect(model.measurementRows.map((row) => demoFlowStatusLabel(row.measurement))).toEqual([
|
||||
'合格', '警告', '超差',
|
||||
]);
|
||||
});
|
||||
|
||||
it('全部为参考项时进入空测量结果状态,且不生成算法分组行', () => {
|
||||
const model = aggregateDemoFlowResults([
|
||||
result(10, 1, 'completed', {
|
||||
|
||||
Reference in New Issue
Block a user