同步已上线的智能分析执行协议、来源查询、图表报告与管理页面配套代码。 补齐数据库迁移、运行依赖和回归测试,保留原有指标计算口径。 统一午夜黑及其他主题的控件细节、中文和业务数字字体。 排除本地业务数据、凭据、预览、发布与验收产物。 验证:生产构建通过,320项前端回归通过;本轮仅同步Git,不再次部署。
48 lines
3.3 KiB
JavaScript
48 lines
3.3 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import * as echarts from 'echarts/core';
|
|
import {LineChart,BarChart} from 'echarts/charts';
|
|
import {GridComponent,LegendComponent,TooltipComponent,GraphicComponent,TitleComponent} from 'echarts/components';
|
|
import {SVGRenderer} from 'echarts/renderers';
|
|
import {buildAnalysisVisualExportOption} from '../src/analysisVisualsModel.ts';
|
|
echarts.use([LineChart,BarChart,GridComponent,LegendComponent,TooltipComponent,GraphicComponent,TitleComponent,SVGRenderer]);
|
|
function visual(type='line') {
|
|
const values=[.9025,.8931,.9012,.8671,.8914,.8982,.8606,.8639,.8794];
|
|
return {id:'monthly-export',type,title:'正式指标趋势',unit:'ratio',
|
|
categories:values.map((_,i)=>({key:`2026-${String(i+1).padStart(2,'0')}`,label:`2026-${String(i+1).padStart(2,'0')}`})),
|
|
series:[{key:'composite_rate',label:'综合合格率',values}],scope:{releaseId:'release'},
|
|
period:{start:'2026-01',end:'2026-09',granularity:'month'},metric:'composite_rate',sectionKey:'trend',
|
|
evidenceRefs:['Q12345678'],requiredFields:['black_good_weight','black_total_weight','bright_good_weight','bright_total_weight'],
|
|
coverage:{totalRows:9,returnedRows:9,truncated:false},originTurnId:'export-turn'};
|
|
}
|
|
for(const type of ['line','area'])test(`900px report ${type} keeps a positive plot and the actual monthly vertical movement`,()=>{
|
|
const v=visual(type),out=buildAnalysisVisualExportOption(v,900,'report');
|
|
const chart=echarts.init(null,undefined,{renderer:'svg',width:out.width,height:out.height,ssr:true});
|
|
try {
|
|
chart.setOption(out.option,{notMerge:true});
|
|
const rect=chart.getModel().getComponent('grid').coordinateSystem.getRect();
|
|
assert.ok(rect.height>=180,`plot collapsed: ${rect.height}`);
|
|
assert.ok(rect.y+rect.height+30<out.height,'category labels need space below plot');
|
|
const points=Array.from(chart.getModel().getSeriesByIndex(0).getData().getLayout('points'));
|
|
assert.equal(points.length,18);
|
|
const ys=points.filter((_,i)=>i%2===1);
|
|
assert.ok(Math.max(...ys)-Math.min(...ys)>8,'different rates must not become a flat line');
|
|
ys.forEach((y,i)=>assert.ok(Math.abs(y-(rect.y+rect.height*(1-v.series[0].values[i])))<.001));
|
|
assert.match(chart.renderToSVGString(),/<svg/);
|
|
} finally {chart.dispose();}
|
|
});
|
|
test('report period comparison bars keep enough plot height and preserve their weight ratio',()=>{
|
|
const v={...visual('column'),unit:'kg',metric:'black_total_weight',stage:'black',sectionKey:'stage',
|
|
categories:[{key:'previous',label:'2026-08'},{key:'current',label:'2026-09'}],
|
|
series:[{key:'black_total_weight',label:'黑片投入重量',values:[20,60]}],coverage:{totalRows:2,returnedRows:2,truncated:false}};
|
|
const out=buildAnalysisVisualExportOption(v,900,'report');
|
|
const chart=echarts.init(null,undefined,{renderer:'svg',width:out.width,height:out.height,ssr:true});
|
|
try {
|
|
chart.setOption(out.option,{notMerge:true});
|
|
assert.ok(chart.getModel().getComponent('grid').coordinateSystem.getRect().height>=180);
|
|
const data=chart.getModel().getSeriesByIndex(0).getData();
|
|
const first=Math.abs(data.getItemLayout(0).height),second=Math.abs(data.getItemLayout(1).height);
|
|
assert.ok(first>30&&second>90);assert.ok(Math.abs(second/first-3)<1e-10);
|
|
} finally {chart.dispose();}
|
|
});
|