fix: bar chart in day modal shows that day's field values per subject

Previously showed cumulative success/failure counts across all days.
Now shows the selected field's actual value for each subject on that
specific day — numeric values only, subjects with empty or non-numeric
values are excluded from the chart.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Experiments DB Dev
2026-04-23 12:18:48 -04:00
parent 8b40856205
commit 9b51250d8e
2 changed files with 33 additions and 51 deletions
+8 -13
View File
@@ -248,7 +248,7 @@ describe('day click modal', () => {
// ── Bar chart (inside day modal) ──────────────────────────────────────────────
describe('bar chart inside day modal', () => {
it('renders bar chart inside modal when animals have statuses', async () => {
it('renders bar chart for numeric field values on that day', async () => {
const dateStr = todayStr();
const statuses = [
makeStatus('a1000000-0000-0000-0000-000000000001', dateStr, { 'ww000000-0000-0000-0000-000000000099': '325' }),
@@ -263,21 +263,16 @@ describe('bar chart inside day modal', () => {
});
});
it('does not render bar chart in modal when no animals have overall statuses', async () => {
it('does not render bar chart when selected field is non-numeric', async () => {
const dateStr = todayStr();
// Give Rat A a status today so the day is clickable, but use a different animal not in barData
const statuses = [
makeStatus('a1000000-0000-0000-0000-000000000001', dateStr, { 'ww000000-0000-0000-0000-000000000099': '325' }),
];
// Use animals list with no matching statuses for barData by filtering to empty
// vitals is a text field — not numeric, so no bar chart
const statuses = [makeStatus('a1000000-0000-0000-0000-000000000001', dateStr, {}, 'HR 72')];
render(
<ExperimentCalendar experimentId={EXP_ID} template={TEMPLATE} allStatuses={statuses} animals={[]} />,
);
// No days enabled since animals=[] means no bar chart, but day is also not enabled
// Just verify no bar chart on empty statuses/animals
render(
<ExperimentCalendar experimentId={EXP_ID} template={TEMPLATE} allStatuses={[]} animals={ANIMALS} />,
<ExperimentCalendar experimentId={EXP_ID} template={TEMPLATE} allStatuses={statuses} animals={ANIMALS} />,
);
fireEvent.change(screen.getByTestId('field-select'), { target: { value: 'vitals' } });
fireEvent.click(screen.getByTestId(`day-${dateStr}`));
await waitFor(() => screen.getByRole('dialog'));
expect(screen.queryByTestId('bar-chart')).not.toBeInTheDocument();
});
});