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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user