health score

This commit is contained in:
2026-09-04 17:31:57 +05:30
parent 9f1593ff87
commit 37b0833328
3 changed files with 80 additions and 5 deletions

View File

@@ -9,7 +9,7 @@
* npx tsx scripts/checkHealthPanel.ts
*/
import { nutritionApi } from '../src/api/nutrition';
import { nutritionApi, __resolveBrand } from '../src/api/nutrition';
import { facts, present, BAND_LABEL } from '../src/features/store-admin/healthScore';
const CASES: { label: string; brand: string; imageId: string; expect: string }[] = [
@@ -74,3 +74,18 @@ for (const testCase of CASES) {
}
line();
/* ── Brand vocabularies ──────────────────────────────────────────────────── */
/* Our catalogue writes snake_case, theirs writes Title Case with a separator
that is sometimes a space and sometimes a hyphen. A mismatch returns
health_score: null — indistinguishable from an unscored product — so this
checks the resolution rather than trusting it. */
line('─'.repeat(72));
line('Brand resolution: our spelling → theirs');
line('─'.repeat(72));
for (const ours of ['cadbury', 'coca_cola', 'brooke_bond', '24_mantra', 'colgate_palmolive', 'aachi']) {
const theirs = await __resolveBrand(ours);
line(` ${ours.padEnd(20)} → ${theirs}`);
}
line();