优化:整理指标目标并支持中文字段公式编辑
黑片和亮片按结果展示完整公式,在同一窗口维护条件与未匹配取值。支持中文字段选择、运算符和求和,并保留原计算语义及特殊策略。 移除重复账号入口与配置说明,统一紧凑表格。保留仓库既有权限判断,不包含此前未同步的角色迁移、预览快照或运行数据。 验证:前端构建及68项相关检查通过。
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { chineseFormula, compileChineseFormula, formulaFieldReference, insertFormulaPart, rowFormulaFields, metricFormulaFields } from '../src/formulaLanguage.ts';
|
||||
const schema={sourceFields:{black:{platingWeight:'送电镀重量',shipmentWeight:'黑片出货重量',inspectionNote:'检验备注',issueLocation:'发料地点'},bright:{scrapWeight:'检包入废品库重量',applicability:'是否电镀来料/二等品库来料'}},rowTargets:{black:['black_good_weight','black_scrap_weight','black_total_weight'],bright:['bright_scrap_weight']},componentLabels:{black_good_weight:'黑片合格重量',black_scrap_weight:'黑片报废重量',black_total_weight:'黑片总重量',bright_scrap_weight:'亮片报废重量'},metricCodes:['blackRate','brightRate','compositeRate'],metricLabels:{blackRate:'黑片合格率',brightRate:'亮片合格率'}};
|
||||
const fields=rowFormulaFields(schema,'black');
|
||||
test('formula catalogs are stage-specific, exclude text, and forbid future metric references',()=>{
|
||||
assert.ok(fields.some(f=>f.key==='platingWeight'));assert.ok(!fields.some(f=>['inspectionNote','issueLocation','scrapWeight'].includes(f.key)));
|
||||
assert.ok(rowFormulaFields(schema,'bright').some(f=>f.key==='scrapWeight'));
|
||||
assert.deepEqual(metricFormulaFields(schema,'brightRate').filter(f=>f.group==='已计算指标').map(f=>f.key),['blackRate']);
|
||||
assert.ok(!metricFormulaFields(schema,'blackRate').some(f=>f.key==='compositeRate'));
|
||||
});
|
||||
test('existing formulas display Chinese references, including SUM and arithmetic',()=>{
|
||||
assert.equal(chineseFormula('platingWeight + shipmentWeight',fields),'[送电镀重量] + [黑片出货重量]');
|
||||
assert.equal(chineseFormula('SUM(black_good_weight, black_scrap_weight) / black_total_weight',fields),'求和([黑片合格重量], [黑片报废重量]) ÷ [黑片总重量]');
|
||||
});
|
||||
test('raw formulas round-trip exactly, including whitespace, numbers and nesting',()=>{
|
||||
for(const source of ['platingWeight + shipmentWeight','SUM(black_good_weight, black_scrap_weight) / black_total_weight',' ( -platingWeight + .50 ) * 2.00\n','0']){
|
||||
assert.deepEqual(compileChineseFormula(chineseFormula(source,fields),fields),{formula:source});
|
||||
assert.deepEqual(compileChineseFormula(source,fields),{formula:source});
|
||||
}
|
||||
});
|
||||
test('users can type Chinese names with or without field brackets',()=>{
|
||||
assert.equal(compileChineseFormula('送电镀重量 + 黑片出货重量',fields).formula,'platingWeight + shipmentWeight');
|
||||
assert.equal(compileChineseFormula('求和([黑片合格重量],[黑片报废重量]) ÷ [黑片总重量]',fields).formula,'SUM(black_good_weight,black_scrap_weight) / black_total_weight');
|
||||
assert.equal(compileChineseFormula('−[送电镀重量] × 2 + 1',fields).formula,'-platingWeight * 2 + 1');
|
||||
});
|
||||
test('longest field name wins without rewriting raw alias prefixes',()=>{
|
||||
const catalog=[{key:'a',label:'重量',group:'来源字段'},{key:'ab',label:'重量合计',group:'来源字段'},{key:'goodWeight',label:'合格',group:'来源字段'},{key:'g',label:'good',group:'计算结果'}];
|
||||
assert.equal(compileChineseFormula('重量合计 - 重量',catalog).formula,'ab - a');
|
||||
assert.equal(compileChineseFormula('goodWeight + g',catalog).formula,'goodWeight + g');
|
||||
});
|
||||
test('duplicate display names require a qualified Chinese selection',()=>{
|
||||
const catalog=[{key:'source',label:'合格重量',group:'来源字段'},{key:'result',label:'合格重量',group:'计算结果'}];
|
||||
assert.match(compileChineseFormula('[合格重量]',catalog).error,/重名/);
|
||||
assert.equal(chineseFormula('source + result',catalog),'[来源字段·合格重量] + [计算结果·合格重量]');
|
||||
assert.equal(compileChineseFormula('[来源字段·合格重量] + [计算结果·合格重量]',catalog).formula,'source + result');
|
||||
});
|
||||
test('field references escape closing brackets and never translate identifiers inside a label',()=>{
|
||||
const catalog=[{key:'a',label:'字段]a',group:'来源字段'}];
|
||||
const reference=formulaFieldReference(catalog[0],catalog);assert.equal(reference,'[字段]]a]');
|
||||
assert.equal(chineseFormula(reference,catalog),reference);assert.equal(compileChineseFormula(reference,catalog).formula,'a');
|
||||
});
|
||||
test('unrecognized and text fields cannot be silently dropped',()=>{
|
||||
for(const text of ['[不存在] + 1','[检验备注]','missingWeight','[送电镀重量'])assert.ok(compileChineseFormula(text,fields).error,text);
|
||||
assert.match(compileChineseFormula('compositeRate',metricFormulaFields(schema,'blackRate')).error,/找不到字段/);
|
||||
});
|
||||
test('syntax validation catches incomplete arithmetic and unsupported functions without evaluating',()=>{
|
||||
for(const text of ['','[送电镀重量] +','([送电镀重量]','[送电镀重量][黑片出货重量]','求和()','求和(1,)','1,2','1.2.3','2[送电镀重量]','IF(1,2,3)','1e3'])assert.ok(compileChineseFormula(text,fields).error,text);
|
||||
for(const text of ['1 / 0','[送电镀重量] - -2','SUM(1,2,(3+4))'])assert.equal(compileChineseFormula(text,fields).error,undefined,text);
|
||||
});
|
||||
test('editor validation mirrors engine bounds on length, nesting, function arguments and numbers',()=>{
|
||||
assert.match(compileChineseFormula('('.repeat(33)+'1'+')'.repeat(33),fields).error,/32/);
|
||||
assert.match(compileChineseFormula('求和('+Array(21).fill('1').join(',')+')',fields).error,/20/);
|
||||
assert.match(compileChineseFormula('1'.repeat(51),fields).error,/50/);
|
||||
assert.match(compileChineseFormula('[送电镀重量] + 1',fields,10).error,/最多10/);
|
||||
assert.equal(compileChineseFormula('求和('+Array(20).fill('1').join(',')+')',fields).error,undefined);
|
||||
});
|
||||
test('inserting fields replaces only the selected range and returns the new caret',()=>{
|
||||
const text='[送电镀重量] + [黑片出货重量]',start=text.indexOf('[黑片出货重量]');
|
||||
assert.deepEqual(insertFormulaPart(text,start,text.length,'[黑片报废重量]'),{text:'[送电镀重量] + [黑片报废重量]',caret:start+'[黑片报废重量]'.length});
|
||||
assert.deepEqual(insertFormulaPart('1 + 2',4,5,'',true),{text:'1 + 求和(2)',caret:8});
|
||||
assert.deepEqual(insertFormulaPart('',0,0,'',true),{text:'求和()',caret:3});
|
||||
});
|
||||
@@ -0,0 +1,73 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { stageResultFormulas, describeResultFormula, replaceResultFormula, planResultMove, newResultIssue } from '../src/resultFormulas.ts';
|
||||
const row=(stage,target,formula,when)=>({stage,target,formula,...(when?{when}:{}),nullPolicy:'PROPAGATE',zeroDenominatorPolicy:'ONE',nullResultPolicy:'NULL'});
|
||||
const condition=value=>({field:'issueLocation',operator:'CONTAINS',value});
|
||||
const schema={sourceFields:{black:{goodWeight:'合格重量',externalScrap:'外废重量',inspectionNote:'检验备注',issueLocation:'发料地点'},bright:{goodWeight:'合格重量',scrapWeight:'检包入废品库重量',applicability:'是否电镀来料/二等品库来料'}},componentLabels:{good:'黑片合格重量',scrap:'黑片报废重量',external:'黑片外废',reuse:'利用料报废扣减',reuseGood:'利用料合格扣减',total:'黑片总重量',brightGood:'亮片合格重量',brightScrap:'亮片报废重量'},rowTargets:{black:['good','external','scrap','reuse','reuseGood','total'],bright:['brightGood','brightScrap']},conditionOperators:['EQ','CONTAINS','IS_BLANK'],metricCodes:[]};
|
||||
const base={schemaVersion:'v1',sourceFields:{black:{externalScrap:'外废重量'}},rowRules:[
|
||||
row('black','good','goodWeight'),row('black','external','externalScrap'),row('black','external','0',{field:'inspectionNote',operator:'CONTAINS',value:'过账'}),row('black','scrap','external'),
|
||||
row('black','reuse','0'),row('black','reuseGood','0'),row('black','reuse','scrap',condition('利用料')),row('black','reuseGood','good',condition('利用料')),row('black','reuse','scrap',condition('废品')),row('black','reuseGood','good',condition('废品')),
|
||||
row('black','total','good + scrap - reuse - reuseGood'),row('bright','brightGood','0'),row('bright','brightGood','goodWeight',{field:'applicability',operator:'EQ',value:'是'}),row('bright','brightScrap','0'),row('bright','brightScrap','scrapWeight',{field:'applicability',operator:'EQ',value:'是'})
|
||||
],metricRules:{}};
|
||||
const result=(def,stage,target)=>stageResultFormulas(def,stage).find(row=>row.target===target);
|
||||
test('one result per row retains every noncontiguous original step without mutation',()=>{
|
||||
const before=JSON.stringify(base),black=stageResultFormulas(base,'black'),bright=stageResultFormulas(base,'bright');
|
||||
assert.equal(black.length,6);assert.equal(bright.length,2);assert.deepEqual(result(base,'black','reuse').indexes,[4,6,8]);
|
||||
const all=[...black,...bright].flatMap(r=>r.rules.map((rule,i)=>({rule,index:r.indexes[i]}))).sort((a,b)=>a.index-b.index);
|
||||
assert.deepEqual(all.map(r=>r.rule),base.rowRules);assert.equal(JSON.stringify(base),before);
|
||||
});
|
||||
test('opening and applying every result is byte-identical, including omitted policies and metadata',()=>{
|
||||
const def=structuredClone(base);delete def.rowRules[0].nullPolicy;def.rowRules[0].custom='preserve';def.rowRules[2].when.custom='condition metadata';
|
||||
const text=JSON.stringify(def);let current=def;
|
||||
for(const stage of ['black','bright'])for(const item of stageResultFormulas(def,stage))current=replaceResultFormula(current,item,structuredClone(item.rules));
|
||||
assert.equal(current,def);assert.equal(JSON.stringify(current),text);
|
||||
});
|
||||
test('full formula includes default and conditional values for black and bright',()=>{
|
||||
assert.equal(describeResultFormula(result(base,'black','external'),schema),'若检验备注包含“过账”,取0;否则取外废重量');
|
||||
assert.equal(describeResultFormula(result(base,'black','reuse'),schema),'若发料地点包含“废品” 或 发料地点包含“利用料”,取黑片报废重量;否则取0');
|
||||
assert.equal(describeResultFormula(result(base,'bright','brightScrap'),schema),'若是否电镀来料/二等品库来料等于“是”,取检包入废品库重量;否则取0');
|
||||
});
|
||||
test('different overlapping branches preserve later-write priority and explicit otherwise formulas',()=>{
|
||||
const item=result(base,'black','reuse');item.rules=structuredClone(item.rules);item.rules[2].formula='2';
|
||||
assert.equal(describeResultFormula(item,schema),'若发料地点包含“废品”,取2;否则(若发料地点包含“利用料”,取黑片报废重量;否则取0)');
|
||||
item.rules[2].otherwiseFormula='3';assert.equal(describeResultFormula(item,schema),'若发料地点包含“废品”,取2;否则取3');
|
||||
});
|
||||
test('conditions with differing special policies are never coalesced',()=>{
|
||||
const item=structuredClone(result(base,'black','reuse'));item.rules[2].nullResultPolicy='ERROR';
|
||||
assert.match(describeResultFormula(item,schema),/否则(若/);assert.doesNotMatch(describeResultFormula(item,schema),/ 或 /);
|
||||
});
|
||||
test('self references retain the previous value in the combined expression',()=>{
|
||||
const item={stage:'black',target:'reuse',indexes:[0,1],rules:[row('black','reuse','4'),row('black','reuse','reuse + 1',condition('利用料'))]};
|
||||
assert.equal(describeResultFormula(item,schema),'若发料地点包含“利用料”,取(4) + 1;否则取4');
|
||||
});
|
||||
test('editing one branch preserves every other rule and field, including interleaved results',()=>{
|
||||
const item=result(base,'black','reuse'),rules=structuredClone(item.rules);rules[2].formula='scrap + 1';const next=replaceResultFormula(base,item,rules);
|
||||
assert.equal(next.rowRules[8].formula,'scrap + 1');for(let i=0;i<base.rowRules.length;i++)if(i!==8)assert.deepEqual(next.rowRules[i],base.rowRules[i]);
|
||||
assert.equal(base.rowRules[8].formula,'scrap');assert.equal(next.metricRules,base.metricRules);assert.equal(next.sourceFields,base.sourceFields);
|
||||
});
|
||||
test('adding or removing conditions keeps other results and their relative order intact',()=>{
|
||||
const item=result(base,'black','reuse'),rules=[...item.rules,row('black','reuse','1',condition('新条件'))];const added=replaceResultFormula(base,item,rules);
|
||||
assert.equal(result(added,'black','reuse').rules.length,4);assert.deepEqual(added.rowRules.filter(r=>r.target!=='reuse'),base.rowRules.filter(r=>r.target!=='reuse'));
|
||||
const removed=replaceResultFormula(added,item,rules.slice(0,1));assert.equal(result(removed,'black','reuse').rules.length,1);assert.deepEqual(removed.rowRules.filter(r=>r.target!=='reuse'),base.rowRules.filter(r=>r.target!=='reuse'));
|
||||
});
|
||||
test('conditional-only legacy formulas retain their original fallback rather than acquiring a zero default',()=>{
|
||||
const item={stage:'black',target:'reuse',indexes:[0],rules:[row('black','reuse','2',condition('利用料'))]};
|
||||
assert.equal(describeResultFormula(item,schema),'若发料地点包含“利用料”,取2;否则取原计算结果');
|
||||
assert.equal(replaceResultFormula({rowRules:item.rules},item,item.rules).rowRules.length,1);
|
||||
});
|
||||
test('whole-result moves retain all branches and reject totals ahead of dependencies',()=>{
|
||||
const moved=planResultMove(base,'black','good',1,schema);assert.ok(moved.definition);assert.equal(stageResultFormulas(moved.definition,'black')[0].target,'external');
|
||||
assert.deepEqual(result(moved.definition,'black','external').rules,result(base,'black','external').rules);
|
||||
assert.deepEqual(planResultMove(moved.definition,'black','good',-1,schema).definition,base);
|
||||
assert.match(planResultMove(base,'black','total',-1,schema).reason,/后面还会修改/);
|
||||
assert.equal(planResultMove(base,'bright','brightGood',-1,schema).definition,undefined);
|
||||
});
|
||||
test('new results stay in their stage and mismatched branches cannot be merged',()=>{
|
||||
const next=replaceResultFormula(base,{stage:'black',target:'added'},[row('black','added','0')]);
|
||||
assert.equal(next.rowRules[11].target,'added');assert.equal(next.rowRules[12].stage,'bright');
|
||||
assert.throws(()=>replaceResultFormula(base,{stage:'black',target:'reuse'},[row('bright','reuse','0')]),/同一个/);
|
||||
});
|
||||
test('invalid branch variables remain blocked by the existing rule checker',()=>{
|
||||
const item=result(base,'bright','brightScrap'),rules=structuredClone(item.rules);rules[1].formula='missingWeight';const next=replaceResultFormula(base,item,rules);
|
||||
assert.match(newResultIssue(base,next,schema),/不可用的公式变量/);assert.equal(result(base,'bright','brightScrap').rules[1].formula,'scrapWeight');
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { ruleLogicIssues, planRuleMove, neighboringRuleIndex, displayRowFormula, isDefaultAssignment } from '../src/ruleEditing.ts';
|
||||
const schema={sourceFields:{black:{platingWeight:'送电镀重量',shipmentWeight:'黑片出货重量',responsibilityScrap:'责废总重量',materialScrap:'料废重量',externalScrap:'外废重量',inspectionNote:'检验备注'},bright:{goodWeight:'合格重量',scrapWeight:'检包入废品库重量',applicability:'是否电镀来料/二等品库来料'}},rowTargets:{black:['black_good_weight','black_responsibility_scrap','black_material_scrap','black_external_scrap','black_scrap_weight','black_total_weight'],bright:['bright_good_weight','bright_scrap_weight']},componentLabels:{black_good_weight:'黑片合格重量',black_scrap_weight:'黑片报废重量',black_total_weight:'黑片总重量'},conditionOperators:['EQ','CONTAINS','GT','IS_BLANK'],metricCodes:['blackRate','brightRate','compositeRate'],metricLabels:{blackRate:'黑片合格率'}};
|
||||
const base={schemaVersion:'unchanged',sourceFields:{},rowRules:[
|
||||
{stage:'black',target:'black_good_weight',formula:'platingWeight + shipmentWeight'},
|
||||
{stage:'black',target:'black_responsibility_scrap',formula:'responsibilityScrap'},
|
||||
{stage:'black',target:'black_material_scrap',formula:'materialScrap'},
|
||||
{stage:'black',target:'black_external_scrap',formula:'externalScrap'},
|
||||
{stage:'black',target:'black_external_scrap',formula:'0',when:{field:'inspectionNote',operator:'CONTAINS',value:'过账'}},
|
||||
{stage:'black',target:'black_scrap_weight',formula:'SUM(black_responsibility_scrap, black_material_scrap, black_external_scrap)'},
|
||||
{stage:'black',target:'black_total_weight',formula:'black_good_weight + black_scrap_weight'},
|
||||
{stage:'bright',target:'bright_good_weight',formula:'0'},
|
||||
{stage:'bright',target:'bright_good_weight',formula:'goodWeight',when:{field:'applicability',operator:'EQ',value:'是'}},
|
||||
{stage:'bright',target:'bright_scrap_weight',formula:'0'},
|
||||
{stage:'bright',target:'bright_scrap_weight',formula:'scrapWeight',when:{field:'applicability',operator:'EQ',value:'是'}},
|
||||
],metricRules:{blackRate:{formula:'blackGood / blackTotal'},brightRate:{formula:'brightGood / brightTotal'},compositeRate:{formula:'blackRate * brightRate'}}};
|
||||
test('baseline formulas and ordered conditional assignments remain valid without any mutation',()=>{const text=JSON.stringify(base);assert.deepEqual(ruleLogicIssues(base,schema),[]);assert.equal(JSON.stringify(base),text);});
|
||||
test('a move swaps exactly two same-stage rows, retaining every other row and metadata',()=>{
|
||||
const text=JSON.stringify(base),result=planRuleMove(base,0,1,schema);assert.ok(result.definition);assert.equal(result.definition.rowRules[0].target,'black_responsibility_scrap');assert.equal(result.definition.rowRules[1].target,'black_good_weight');
|
||||
assert.deepEqual(result.definition.rowRules.slice(2),base.rowRules.slice(2));assert.equal(JSON.stringify(base),text);assert.deepEqual(planRuleMove(result.definition,1,-1,schema).definition,base);
|
||||
});
|
||||
test('moves do not cross stage boundaries',()=>{assert.equal(neighboringRuleIndex(base.rowRules,6,1),undefined);assert.equal(neighboringRuleIndex(base.rowRules,7,-1),undefined);assert.equal(planRuleMove(base,7,-1,schema).definition,undefined);});
|
||||
test('moving a conditional assignment above its default is rejected',()=>{const result=planRuleMove(base,8,-1,schema);assert.equal(result.definition,undefined);assert.match(result.reason,/默认值应放在条件覆盖之前/);});
|
||||
test('moving totals ahead of their component assignments is rejected',()=>{const result=planRuleMove(base,5,-1,schema);assert.equal(result.definition,undefined);assert.match(result.reason,/后面还会修改/);});
|
||||
test('unknown variables, text arithmetic and forward metric references are caught',()=>{
|
||||
for(const formula of ['typoWeight','inspectionNote + 1']){const def=structuredClone(base);def.rowRules[0].formula=formula;assert.ok(ruleLogicIssues(def,schema).some(issue=>issue.key.startsWith('variable:')));}
|
||||
const def=structuredClone(base);def.metricRules.blackRate.formula='compositeRate';assert.ok(ruleLogicIssues(def,schema).some(issue=>issue.key.startsWith('metric-variable:')));
|
||||
});
|
||||
test('duplicate conditions with different formulas are rejected regardless of JSON property order',()=>{const def=structuredClone(base);def.rowRules.push({stage:'bright',target:'bright_scrap_weight',formula:'1',when:{value:'是',operator:'EQ',field:'applicability'}});assert.ok(ruleLogicIssues(def,schema).some(issue=>issue.key.startsWith('duplicate:')));});
|
||||
test('legacy partial overrides keep access to baseline components',()=>{const def={rowRules:[{stage:'black',target:'black_total_weight',formula:'black_good_weight + black_scrap_weight'}]};assert.deepEqual(ruleLogicIssues(def,schema),[]);});
|
||||
test('source aliases are rendered in Chinese while the original formula is retained',()=>{const row=base.rowRules[10];assert.equal(displayRowFormula(row,schema),'检包入废品库重量');assert.equal(row.formula,'scrapWeight');assert.equal(isDefaultAssignment(base.rowRules[9],9,base.rowRules),true);assert.equal(isDefaultAssignment(row,10,base.rowRules),false);});
|
||||
@@ -0,0 +1,20 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { displayFormula, stageRuleRows, ruleChangeSummary, matchingTarget, policyDescription } from '../src/rulePresentation.ts';
|
||||
const original={sourceFields:{black:{platingWeight:'送电镀重量'},bright:{goodWeight:'合格重量'}},rowRules:Array.from({length:22},(_,i)=>({stage:i<13?'black':'bright',target:i%3===0?'black_good_weight':i%3===1?'black_scrap_weight':'black_reuse_good',formula:String(i),when:{field:'inspectionNote',operator:'CONTAINS',value:'过账'}})),metricRules:{blackRate:{formula:'blackGood / blackTotal'}}};
|
||||
test('stage tables keep every execution index and full rule unchanged',()=>{
|
||||
const before=JSON.stringify(original);const all=[...stageRuleRows(original,'black'),...stageRuleRows(original,'bright')].sort((a,b)=>a.index-b.index);
|
||||
assert.equal(all.length,22);assert.deepEqual(all.map(({index,...row})=>row),original.rowRules);assert.equal(JSON.stringify(original),before);assert.deepEqual(ruleChangeSummary(original,structuredClone(original)),[]);
|
||||
});
|
||||
test('business formula translation explains percentages without mutating source rules',()=>{
|
||||
assert.equal(displayFormula('blackRate * brightRate'),'黑片合格率 × 亮片合格率');assert.match(policyDescription({zeroDenominatorPolicy:'ONE',nullResultPolicy:'NULL'}),/分母为0:按100%处理/);assert.match(policyDescription({zeroDenominatorPolicy:'ONE'},false),/分母为0:取1/);
|
||||
const next=structuredClone(original);next.metricRules.blackRate.formula='(blackGood / blackTotal)';assert.deepEqual(ruleChangeSummary(original,next),['合格率公式 1 项']);assert.notEqual(original.metricRules.blackRate.formula,next.metricRules.blackRate.formula);
|
||||
});
|
||||
test('target display preserves existing specificity and group tie-break precedence',()=>{
|
||||
const overall={dimensions:{},value:.955},department={dimensions:{department:'A'},value:.96},group={dimensions:{group:'G'},value:.97},specific={dimensions:{department:'A',group:'G'},value:.98};const list=[overall,department,group,specific];const before=JSON.stringify(list);
|
||||
assert.equal(matchingTarget(list,{department:'A',group:'G'}),specific);assert.equal(matchingTarget(list.slice(0,3),{department:'A',group:'G'}),group);assert.equal(matchingTarget(list,{department:'A',group:'OTHER'}),department);assert.equal(matchingTarget(list,{department:'B'}),overall);assert.equal(JSON.stringify(list),before);
|
||||
});
|
||||
test('stage table reflects the actual row order without business grouping',()=>{
|
||||
const definition={rowRules:[{stage:'black',target:'black_responsibility_scrap',formula:'1'},{stage:'black',target:'black_good_weight',formula:'2'},{stage:'black',target:'black_material_scrap',formula:'3'}]};
|
||||
assert.deepEqual(stageRuleRows(definition,'black').map(row=>row.target),['black_responsibility_scrap','black_good_weight','black_material_scrap']);
|
||||
});
|
||||
Reference in New Issue
Block a user