同步:完善质量分析工作台并更新主题字体
同步已上线的智能分析执行协议、来源查询、图表报告与管理页面配套代码。 补齐数据库迁移、运行依赖和回归测试,保留原有指标计算口径。 统一午夜黑及其他主题的控件细节、中文和业务数字字体。 排除本地业务数据、凭据、预览、发布与验收产物。 验证:生产构建通过,320项前端回归通过;本轮仅同步Git,不再次部署。
This commit is contained in:
@@ -101,3 +101,96 @@ test('scoped comparisons cannot enter a global overview or stage chapter',()=>{
|
||||
const matched=buildAnalysisNarrative(`总体变化。[Q1234ABCD]\n\n### 重点产品\n${product} 的变化。`,[visual(),local,stage]);
|
||||
assert.equal(matched.sections.find(s=>s.kind==='product').visuals.length,2);
|
||||
});
|
||||
|
||||
const productTable = ({ product = '16.33X15.5X3.75+T', ref = 'Q9594C354', stage = '', delta = '+758.76', change = '下降1.95个百分点', weight = '1,286.11', rate = '97.11%→95.16%', input = '黑片投入17,361.74→26,276.07 kg;亮片投入19,009.25→26,288.80 kg', order = '报废增量' } = {}) => {
|
||||
const name = stage ? `${stage}合格率` : '综合率';
|
||||
return `### ${stage}${order === '合格率降幅' ? '产品率变化线索' : '重点产品'}(按${order},本次返回前5)\n\n| 规格 | 本期报废 / 增量(kg) | ${name}:比较期→本期 / 变化 | 阶段投入:比较期→本期(kg) |\n| --- | --- | --- | --- |\n| ${product.replaceAll('|', '\\|')} | ${weight} / ${delta} | ${rate};${change} | ${input} |\n\n[${ref}] 查询共有3566个对象,保留分阶段投入。`;
|
||||
};
|
||||
const productFact = ({ product = '16.33X15.5X3.75+T', ref = 'Q9594C354', delta = '+758.76', change = '下降1.95个百分点', stage = '', input = '黑片投入17,361.74→26,276.07 kg;亮片投入19,009.25→26,288.80 kg' } = {}) =>
|
||||
`- ${product}:${stage}报废527.35→1,286.11 kg,增量${delta} kg;${stage ? `${stage}合格率` : '综合率'}97.11%→95.16%,${change};${input}。[${ref}]`;
|
||||
|
||||
test('selected product facts become a cited comparison immediately after the overview without recalculation', () => {
|
||||
const first = { product: 'A', ref: 'Q11111111', delta: '+758.76' };
|
||||
const second = { product: 'B', ref: 'Q22222222', delta: '+757.56', change: '下降0.68个百分点' };
|
||||
const source = `整体下降。[Q1234ABCD]\n\n${productTable(first)}\n\n${productTable(second)}\n\n### 重点关注\n\n${productFact(second)}\n${productFact(first)}\n\n范围:当前授权范围,默认不含未分类。`;
|
||||
const model = buildAnalysisNarrative(source, [visual()]);
|
||||
assert.equal(model.sections[0].kind, 'overview');
|
||||
const focused = model.sections[1];
|
||||
assert.equal(focused.id, 'focus-product-summary');
|
||||
assert.deepEqual(focused.focusProducts.map(row => [row.product, row.scrapDelta, row.rateChange, row.basis]), [
|
||||
['B', '+757.56', '下降0.68个百分点', '按报废增量排序'],
|
||||
['A', '+758.76', '下降1.95个百分点', '按报废增量排序'],
|
||||
]);
|
||||
assert.equal(focused.focusProducts[0].detail, productFact(second).slice(2));
|
||||
assert.match(focused.focusProducts[0].detail, /黑片投入17,361.74→26,276.07 kg/);
|
||||
assert.equal(model.sections.filter(section => section.narrative.includes('B:')).length, 0);
|
||||
assert.ok(model.sections.some(section => section.narrative.includes('默认不含未分类')));
|
||||
assert.equal(model.sections.flatMap(section => section.tables).length, 2);
|
||||
assert.equal(model.sections.flatMap(section => section.visuals).length, 1);
|
||||
assert.equal(model.evidenceLabels.Q22222222, '依据 3');
|
||||
});
|
||||
|
||||
test('unrecognized old product reports and uncited focus prose remain intact', () => {
|
||||
for (const focus of ['- A:这是旧格式的分析。', '- 另一规格:增量+758.76 kg,下降1.95个百分点。[Q9594C354]', '- 16.33X15.5X3.75+T:增量+758.76 kg,下降1.95个百分点。[Q00000000]']) {
|
||||
const model = buildAnalysisNarrative(`${productTable()}\n\n### 重点关注\n\n${focus}`, []);
|
||||
assert.ok(!model.sections.some(section => section.focusProducts));
|
||||
assert.equal(model.sections.at(-1).narrative, focus);
|
||||
}
|
||||
});
|
||||
|
||||
test('missing values are retained as unavailable and never converted to zero', () => {
|
||||
const data = { delta: '—', weight: '—', rate: '—→—', change: '不可比', input: '黑片投入—→— kg;亮片投入—→— kg' };
|
||||
const model = buildAnalysisNarrative(`总体比较。\n\n${productTable(data)}\n\n### 重点关注\n\n${productFact(data)}`, []);
|
||||
const row = model.sections.find(section => section.focusProducts).focusProducts[0];
|
||||
assert.equal(row.scrapDelta, '—'); assert.equal(row.rateChange, '不可比');
|
||||
assert.match(row.detail, /黑片投入—→— kg/);
|
||||
});
|
||||
|
||||
test('stage and ordering context follow the exact cited row, including rate-only leads', () => {
|
||||
const black = { product: 'A', ref: 'Q11111111', stage: '黑片', delta: '+20.00', change: '下降5.00个百分点', order: '合格率降幅' };
|
||||
const bright = { product: 'A', ref: 'Q22222222', stage: '亮片', delta: '+40.00', change: '下降2.00个百分点', order: '当前报废重量' };
|
||||
const model = buildAnalysisNarrative(`概况。\n\n${productTable(black)}\n\n${productTable(bright)}\n\n### 重点关注\n\n${productFact(black)}\n${productFact(bright)}`, []);
|
||||
const rows = model.sections.find(section => section.focusProducts).focusProducts;
|
||||
assert.deepEqual(rows.map(row => row.rateLabel), ['黑片合格率', '亮片合格率']);
|
||||
assert.deepEqual(rows.map(row => row.basis), ['黑片 · 按合格率降幅排序,仅作率变化线索', '亮片 · 按当前报废重量排序']);
|
||||
assert.deepEqual(rows.map(row => row.evidenceRefs[0]), ['Q11111111', 'Q22222222']);
|
||||
});
|
||||
|
||||
test('ambiguous references, changed numbers, and unknown table fields fall back to full original prose', () => {
|
||||
const fact = productFact();
|
||||
const cases = [
|
||||
`${productTable()}\n\n${productTable()}`,
|
||||
productTable({ delta: '+999.99' }),
|
||||
productTable().replace('阶段投入:比较期→本期(kg)', '其他数据'),
|
||||
];
|
||||
for (const tables of cases) {
|
||||
const model = buildAnalysisNarrative(`${tables}\n\n### 重点关注\n\n${fact}`, []);
|
||||
assert.ok(!model.sections.some(section => section.focusProducts));
|
||||
assert.equal(model.sections.at(-1).narrative, fact);
|
||||
}
|
||||
});
|
||||
|
||||
test('mixed focus items and fenced examples are retained while recognized products move', () => {
|
||||
const other = '- 核对责废分类是否完整。[Q1234ABCD]';
|
||||
const code = `\`\`\`text\n${productFact()}\n\`\`\``;
|
||||
const model = buildAnalysisNarrative(`${productTable()}\n\n### 重点关注\n\n${productFact()}\n${other}\n\n${code}`, []);
|
||||
assert.equal(model.sections.find(section => section.focusProducts).focusProducts.length, 1);
|
||||
assert.equal(model.sections.at(-1).kind, 'action');
|
||||
assert.ok(model.sections.at(-1).narrative.includes(other));
|
||||
assert.ok(model.sections.at(-1).narrative.includes(code));
|
||||
});
|
||||
|
||||
test('long specifications and escaped Markdown delimiters remain literal product data', () => {
|
||||
const product = 'R127.985X57.516X15.786X75.485X32.232°X5.5|<img src=x onerror=alert(1)>';
|
||||
const model = buildAnalysisNarrative(`${productTable({ product })}\n\n### 重点关注\n\n${productFact({ product })}`, []);
|
||||
const row = model.sections.find(section => section.focusProducts).focusProducts[0];
|
||||
assert.equal(row.product, product); assert.equal(row.detail, productFact({ product }).slice(2));
|
||||
});
|
||||
|
||||
test('more than five selected products remain available in original order for expanded details', () => {
|
||||
const data = Array.from({ length: 6 }, (_, index) => ({ product: `规格${index + 1}`, ref: `Q1111111${index}` }));
|
||||
const model = buildAnalysisNarrative(`总体变化。\n\n${data.map(item => productTable(item)).join('\n\n')}\n\n### 重点关注\n\n${data.map(item => productFact(item)).join('\n')}`, []);
|
||||
const rows = model.sections.find(section => section.focusProducts).focusProducts;
|
||||
assert.equal(rows.length, 6); assert.deepEqual(rows.map(row => row.product), data.map(item => item.product));
|
||||
assert.equal(model.evidence.length, 6);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user