fix(report): cap dimension scores and match zoom crops to thumbnails
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
const assert=require('node:assert/strict'),S=require('../js/skin-score'),UI=require('../js/report-ui');
|
||||
for(const score of [9.9,9.94,9.95,9.99,10]) {
|
||||
assert.equal(S.capDimensionScore(score),9.9);
|
||||
assert.equal(UI.dimensionScore(score),'9.9','rounding must never display 10.0');
|
||||
}
|
||||
assert.equal(UI.dimensionScore(9.34),'9.3');assert.equal(S.capDimensionScore(null),null);
|
||||
const r={eye_pouch_severity:0,score_info:{wrinkle_score:100,blackhead_score:100,rough_score:100,melanin_score:100,dark_circle_score:100,water_score:100,sensitivity_score:100,acne_score:100},red_spot:{red_spot_area:0}};
|
||||
for(const key of ['closed_comedones','acne','acne_pustule','acne_nodule','acne_mark'])r[key]={count:0};
|
||||
const before=JSON.stringify(r),vm=S.buildViewModel(r,null,{});
|
||||
for(const dim of Object.values(vm.dims)){assert.equal(dim.P,100);assert.equal(dim.S,9.9);}
|
||||
for(const cat of Object.values(vm.cats)){assert.equal(cat.P,100);assert.equal(cat.S,10,'small categories unchanged');}
|
||||
assert.equal(vm.total,99);assert.equal(JSON.stringify(r),before);
|
||||
const legacy={firm:{S:10},vita:{S:9.99},stab:{S:9.97}},saved=JSON.stringify(legacy);
|
||||
assert.equal(S.weightedTotal(legacy),99);assert.equal(JSON.stringify(legacy),saved,'old stored scores not rewritten');
|
||||
console.log('PASS dimension cap: 9.9 for all dimensions, no rounding to 10, subcategories/raw data unchanged, total99 and immutable historical scores');
|
||||
Reference in New Issue
Block a user