优化:未分类连续维护与柏拉图预汇总,同步已发布修复
This commit is contained in:
@@ -217,9 +217,56 @@ test('stage scrap rates preserve values above 100 percent and expand every ratio
|
||||
assert.equal(buildAnalysisVisualExportOption(below100, 1280, 'report').option.yAxis.max, 100);
|
||||
});
|
||||
|
||||
test('only correctly declared stage scrap-rate metrics accept above-one ratios', () => {
|
||||
test('formal black and composite rates above 100 percent remain visible in live and exported charts', () => {
|
||||
const products = [
|
||||
{ name: '42.1X42.1X35异形+Z', composite: 1.2430959504537282, black: 1.277660594439118 },
|
||||
{ name: 'R43X38.1X9.5X60+Q', composite: 1.0601991884176734, black: 1.1147540983606556 },
|
||||
];
|
||||
const composite = visual({
|
||||
type: 'column', title: '综合合格率', metric: 'composite_rate', dimension: 'product',
|
||||
requiredFields: ['black_good_weight', 'black_total_weight', 'bright_good_weight', 'bright_total_weight'],
|
||||
categories: products.map((item, index) => ({ key: `product-${index}`, label: item.name })),
|
||||
series: [{ key: 'composite_rate', label: '综合合格率', values: products.map(item => item.composite) }],
|
||||
scope: { year: 2026, month: 9, releaseId: 'release-a' }, period: { year: 2026, month: 9 }, comparisonPeriod: undefined,
|
||||
});
|
||||
const parsed = parseAnalysisVisuals([composite]).visuals[0];
|
||||
assert.equal(parsed.chartable, true);
|
||||
assert.deepEqual(parsed.series[0].values, products.map(item => item.composite));
|
||||
const option = buildAnalysisVisualOption(parsed);
|
||||
assert.deepEqual(option.series[0].data.map(item => typeof item === 'number' ? item : item.value), products.map(item => item.composite * 100).map(value => Number(value.toFixed(7))));
|
||||
assert.ok(option.yAxis.max > 124.3);
|
||||
assert.ok(buildAnalysisVisualExportOption(parsed, 1280, 'standalone').option.yAxis.max > 124.3);
|
||||
assert.ok(buildAnalysisVisualExportOption(parsed, 1280, 'report').option.yAxis.max > 124.3);
|
||||
assert.match(formatVisualValue(products[0].composite, 'ratio'), /124\.3/);
|
||||
|
||||
const black = parseAnalysisVisuals([visual({
|
||||
type: 'column', title: '黑片合格率', metric: 'black_rate', stage: 'black',
|
||||
requiredFields: ['black_good_weight', 'black_total_weight'],
|
||||
categories: products.map((item, index) => ({ key: `product-${index}`, label: item.name })),
|
||||
series: [{ key: 'black_rate', label: '黑片合格率', values: products.map(item => item.black) }],
|
||||
scope: { year: 2026, month: 9, releaseId: 'release-a', stage: 'black' }, period: { year: 2026, month: 9 }, comparisonPeriod: undefined,
|
||||
})]).visuals[0];
|
||||
assert.equal(black.chartable, true);
|
||||
assert.ok(buildAnalysisVisualOption(black).yAxis.max > products[0].black * 100);
|
||||
|
||||
const compositeWithoutHeadquarters = parseAnalysisVisuals([visual({
|
||||
title: '综合合格率(不含总部报废)', metric: 'composite_rate_without_headquarters_scrap',
|
||||
requiredFields: ['black_good_weight', 'black_total_weight', 'bright_good_weight', 'bright_total_weight'],
|
||||
series: [{ key: 'composite_rate_without_headquarters_scrap', label: '综合合格率', values: [1.04, 1.02] }],
|
||||
})]).visuals[0];
|
||||
assert.equal(compositeWithoutHeadquarters.chartable, true);
|
||||
assert.ok(buildAnalysisVisualOption(compositeWithoutHeadquarters).yAxis.max > 104);
|
||||
|
||||
const horizontal = parseAnalysisVisuals([{ ...composite, type: 'bar' }]).visuals[0];
|
||||
assert.equal(horizontal.chartable, true);
|
||||
assert.ok(buildAnalysisVisualOption(horizontal).xAxis.max > 124.3);
|
||||
assert.ok(buildAnalysisVisualExportOption(horizontal, 1280, 'report').option.xAxis.max > 124.3);
|
||||
});
|
||||
|
||||
test('only official adjusted-denominator rates accept above-one ratios', () => {
|
||||
for (const input of [
|
||||
visual({ series: [{ key: 'r', label: '率', values: [1.02, null] }] }),
|
||||
visual({ metric: 'bright_rate', stage: 'bright', requiredFields: ['bright_good_weight', 'bright_total_weight'], series: [{ key: 'r', label: '亮片合格率', values: [1.02, null] }] }),
|
||||
scrapRate('black', [1.02, 0.8], { requiredFields: ['bright_scrap_weight', 'bright_total_weight'] }),
|
||||
scrapRate('black', [1.02, 0.8], { unit: 'kg' }),
|
||||
]) {
|
||||
@@ -229,6 +276,12 @@ test('only correctly declared stage scrap-rate metrics accept above-one ratios',
|
||||
const negative = parseAnalysisVisuals([scrapRate('bright', [-0.01, 1.02])]).visuals[0];
|
||||
assert.equal(negative.chartable, false);
|
||||
assert.deepEqual(negative.invalidValueCells, ['0:0']);
|
||||
|
||||
for (const value of [-0.01, Number.NaN, Number.POSITIVE_INFINITY]) {
|
||||
const official = parseAnalysisVisuals([visual({ metric: 'composite_rate', series: [{ key: 'r', label: '综合合格率', values: [value, 0.95] }] })]).visuals[0];
|
||||
assert.equal(official.chartable, false);
|
||||
assert.deepEqual(official.invalidValueCells, ['0:0']);
|
||||
}
|
||||
});
|
||||
|
||||
test('empty subtitle and extra-filter maps survive strict parsing', () => {
|
||||
|
||||
Reference in New Issue
Block a user