test: document and test analysis_summary bar chart contract

5 tests cover the bar chart rules:
- Shows when analysis_summary.total > 0
- Hidden when no summary or total=0
- Multiple animals each with their own summary
- Animals excluded from day view (empty field) also excluded from chart
- animalsWithData now filters by selected field value (not just record presence)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Experiments DB Dev
2026-04-23 12:31:36 -04:00
parent 5f3ad1d408
commit 6ecc6dc19a
2 changed files with 71 additions and 10 deletions
@@ -48,8 +48,15 @@ function DayPanel({ date, animals, allStatuses, template, experimentId, selected
return map;
}, [allStatuses, dateStr]);
// Only show animals that have a status record for this day
const animalsWithData = animals.filter((a) => statusByAnimal[a.id]);
// Only show animals that have a status record for this day WITH a non-empty selected field
const animalsWithData = animals.filter((a) => {
const s = statusByAnimal[a.id];
if (!s) return false;
if (!selectedField) return true;
const isBuiltin = BUILTIN_KEYS_SET.has(selectedField);
const val = isBuiltin ? s[selectedField] : s.custom_fields?.[selectedField];
return val !== null && val !== undefined && String(val).trim() !== '';
});
const fieldLabel = fieldOptions.find((f) => f.value === selectedField)?.label;