同步:完善质量分析工作台并更新主题字体
同步已上线的智能分析执行协议、来源查询、图表报告与管理页面配套代码。 补齐数据库迁移、运行依赖和回归测试,保留原有指标计算口径。 统一午夜黑及其他主题的控件细节、中文和业务数字字体。 排除本地业务数据、凭据、预览、发布与验收产物。 验证:生产构建通过,320项前端回归通过;本轮仅同步Git,不再次部署。
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { publicErrorMessage, readableMetricFormula } from '../web/src/publicDataDisplay.ts';
|
||||
import * as conversation from '../web/src/analysisConversationState.ts';
|
||||
import { sanitizeAnalysisDisplayText } from '../web/src/analysisDisplayText.ts';
|
||||
|
||||
test('gateway HTML is a service failure, never rendered as its raw payload', () => {
|
||||
const error = {message: publicErrorMessage('<html><h1>502 Bad Gateway</h1></html>', 502)};
|
||||
assert.match(error.message, /服务.*暂不可用/);
|
||||
assert.doesNotMatch(error.message, /<html>/);
|
||||
});
|
||||
test('replay duplicates and old snapshots cannot move the event cursor backwards', () => {
|
||||
assert.equal(conversation.acceptAnalysisEvent('12', '12'), false);
|
||||
assert.equal(conversation.acceptAnalysisEvent('11', '12'), false);
|
||||
assert.equal(conversation.acceptAnalysisEvent('13', '12'), true);
|
||||
assert.equal(conversation.acceptAnalysisEvent('9007199254740994', '9007199254740993'), true);
|
||||
});
|
||||
|
||||
test('formula wording translates the service policy without replacing its business calculation', () => {
|
||||
assert.equal(readableMetricFormula('blackRate * brightRate;运算空值=PROPAGATE;零分母=ONE;空结果=NULL'), '黑片合格率 × 亮片合格率;运算中遇到空值:运算结果保持空值;分母为0:取1(率值100%);计算结果为空:保留空值');
|
||||
assert.equal(readableMetricFormula('blackGood / blackTotal * 0.99'), '黑片合格重量 ÷ 黑片总重量 × 0.99');
|
||||
assert.equal(readableMetricFormula(undefined), '当前指标服务未提供公式说明');
|
||||
});
|
||||
|
||||
test('an old contradictory report retains its text and gains an explicit evidence-scope warning', () => {
|
||||
const answer='具体缺陷线索(来源细分,未与正式大类完全对账)。责废缺角增量是黑片报废增长主因。';
|
||||
assert.equal(conversation.hasUnreconciledEvidence({answer}), true);
|
||||
assert.equal(conversation.hasUnreconciledEvidence({answer:'未发现对账差异,已完成核对。'}), false);
|
||||
assert.equal(conversation.hasUnreconciledEvidence({plan:{timeline:[{text:'细分与正式大类未对账:仅作为变化线索'}]}}),true);
|
||||
});
|
||||
|
||||
test('provider whitespace does not duplicate the saved final answer in its event stream', () => {
|
||||
const answer='**2026年9月正式合格率**\n\n综合76.5%,黑片85%,亮片90%。';
|
||||
assert.equal(conversation.duplicatesFinalAnalysisAnswer('\n\n'+answer,answer),true);
|
||||
assert.equal(conversation.duplicatesFinalAnalysisAnswer(answer.slice(0,12),answer),true);
|
||||
assert.equal(conversation.duplicatesFinalAnalysisAnswer('正在核查合成指标。',answer),false);
|
||||
assert.equal(conversation.duplicatesFinalAnalysisAnswer(' ',answer),false);
|
||||
assert.equal(conversation.duplicatesFinalAnalysisAnswer('较早的独立进展',''),false);
|
||||
});
|
||||
|
||||
test('verified VCM coverage supersedes the same scope warning but preserves other unresolved scopes', () => {
|
||||
const key='0123456789abcdef', other='fedcba9876543210';
|
||||
const event=(checks)=>({kind:'tool_result',status:'completed',evidenceChecks:checks});
|
||||
assert.equal(conversation.hasUnreconciledEvidence({answer:'VCM细分未对账',timeline:[event({[key]:'unresolved'}),event({[key]:'expected'})]}),false);
|
||||
assert.equal(conversation.hasUnreconciledEvidence({timeline:[event({[other]:'unresolved'}),event({[key]:'expected'})]}),true);
|
||||
assert.equal(conversation.hasUnreconciledEvidence({timeline:[{kind:'assistant',evidenceChecks:{[other]:'checked'},text:'未对账'}]}),true);
|
||||
});
|
||||
|
||||
test('partial pre-tool notes stay in chronology instead of being repeated as final answers', () => {
|
||||
const note={kind:'assistant',text:'正在核查原表。'}, tool={kind:'tool_result',status:'completed'};
|
||||
assert.equal(conversation.partialAnswerIsOnlyProgress({status:'PARTIAL',answer:note.text,timeline:[note,tool]}),true);
|
||||
assert.equal(conversation.partialAnswerIsOnlyProgress({status:'PARTIAL',answer:'已完成部分比较。',timeline:[tool,{kind:'assistant',text:'已完成部分比较。'}]}),false);
|
||||
assert.equal(conversation.partialAnswerIsOnlyProgress({status:'COMPLETED',answer:note.text,timeline:[note,tool]}),false);
|
||||
assert.equal(conversation.partialAnswerIsOnlyProgress({status:'PARTIAL',answer:note.text}),false);
|
||||
});
|
||||
|
||||
test('each tool start/result pair renders one folded row without merging different calls', () => {
|
||||
const input={mode:'compare',period:{month:9}};
|
||||
const events=[{kind:'tool_start',sequence:1,toolCallId:'a',label:'查询',input},
|
||||
{kind:'tool_start',sequence:2,toolCallId:'b',label:'查询'},
|
||||
{kind:'assistant',sequence:3,text:'继续核查'},
|
||||
{kind:'tool_result',sequence:4,toolCallId:'a',status:'completed',text:'已返回'},
|
||||
{kind:'tool_result',sequence:5,toolCallId:'b',status:'failed',text:'需重试'}];
|
||||
const compact=conversation.compactAnalysisTimeline(events);
|
||||
assert.equal(compact.length,3);
|
||||
assert.deepEqual(compact.map(row=>row.kind),['tool','tool','assistant']);
|
||||
assert.equal(compact[0].status,'completed');assert.deepEqual(compact[0].input,input);
|
||||
assert.equal(compact[1].status,'failed');
|
||||
assert.equal(events[0].kind,'tool_start');
|
||||
const replay=conversation.compactAnalysisTimeline([...events,events[0]]);
|
||||
assert.equal(replay[0].status,'completed');assert.equal(replay.length,3);
|
||||
});
|
||||
|
||||
test('stream updates respect an upward scroll and resume following only at the bottom', () => {
|
||||
assert.equal(conversation.analysisScrollFollows(40,true,'up'),false);
|
||||
assert.equal(conversation.analysisScrollFollows(150,false),false);
|
||||
assert.equal(conversation.analysisScrollFollows(130,false,'down'),false);
|
||||
assert.equal(conversation.analysisScrollFollows(10,false,'down'),true);
|
||||
assert.equal(conversation.analysisScrollFollows(120,true),true);
|
||||
assert.equal(conversation.analysisScrollFollows(10,false),false);
|
||||
});
|
||||
|
||||
test('partial completion explains tool failures separately from model limits', () => {
|
||||
assert.match(conversation.partialAnalysisNotice('mcp_error'),/数据查询未成功/);
|
||||
assert.match(conversation.partialAnalysisNotice('length'),/长度上限/);
|
||||
assert.match(conversation.partialAnalysisNotice('timeout'),/处理时限/);
|
||||
assert.match(conversation.partialAnalysisNotice('evidence_incomplete'),/被标记为部分完成/);
|
||||
assert.doesNotMatch(conversation.partialAnalysisNotice('evidence_incomplete'),/数据尚未齐全/);
|
||||
});
|
||||
|
||||
|
||||
test('provider tool-call markup is hidden while business text stays readable', () => {
|
||||
assert.equal(sanitizeAnalysisDisplayText('<tool_call><function=read><parameter_path>/RULES.md</parameter></function></tool_call>'), '');
|
||||
assert.equal(sanitizeAnalysisDisplayText('已核对。<tool_call><function=read>'), '已核对。');
|
||||
assert.equal(sanitizeAnalysisDisplayText('产品VCM739+Z重量10kg'), '产品VCM739+Z重量10kg');
|
||||
});
|
||||
Reference in New Issue
Block a user