fix: day modal bar chart plots that session's field values per animal
X-axis: animal names, Y-axis: the selected field's numeric value recorded that specific day. Animals with empty or non-numeric values are excluded. Each day's chart is independent — different animals, different values. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -248,7 +248,7 @@ describe('day click modal', () => {
|
||||
// ── Bar chart (inside day modal) ──────────────────────────────────────────────
|
||||
|
||||
describe('bar chart inside day modal', () => {
|
||||
it('renders session stats bar chart when animals have valid field data', async () => {
|
||||
it('renders bar chart with that day\'s numeric field values', async () => {
|
||||
const dateStr = todayStr();
|
||||
const statuses = [
|
||||
makeStatus('a1000000-0000-0000-0000-000000000001', dateStr, { 'ww000000-0000-0000-0000-000000000099': '325' }),
|
||||
@@ -258,14 +258,13 @@ describe('bar chart inside day modal', () => {
|
||||
);
|
||||
fireEvent.click(screen.getByTestId(`day-${dateStr}`));
|
||||
await waitFor(() => {
|
||||
const dialog = screen.getByRole('dialog');
|
||||
expect(within(dialog).getByTestId('bar-chart')).toBeInTheDocument();
|
||||
expect(within(screen.getByRole('dialog')).getByTestId('bar-chart')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('excludes animals with no valid field data from bar chart', async () => {
|
||||
it('omits animals with empty or non-numeric field value from bar chart', async () => {
|
||||
const dateStr = todayStr();
|
||||
// Rat A has weight data; Rat B has only empty custom_fields — should be excluded from chart
|
||||
// Rat A has numeric weight; Rat B has empty weight — Rat B excluded from chart but shown in day list
|
||||
const statuses = [
|
||||
makeStatus('a1000000-0000-0000-0000-000000000001', dateStr, { 'ww000000-0000-0000-0000-000000000099': '325' }),
|
||||
makeStatus('a2000000-0000-0000-0000-000000000002', dateStr, {}),
|
||||
@@ -275,7 +274,19 @@ describe('bar chart inside day modal', () => {
|
||||
);
|
||||
fireEvent.click(screen.getByTestId(`day-${dateStr}`));
|
||||
await waitFor(() => screen.getByRole('dialog'));
|
||||
// Both animals are in the day view (both have records), but bar chart only has Rat A
|
||||
expect(screen.getByTestId('bar-chart')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('hides bar chart when no animals have a numeric value for the selected field that day', async () => {
|
||||
const dateStr = todayStr();
|
||||
// vitals is text — no bar chart
|
||||
const statuses = [makeStatus('a1000000-0000-0000-0000-000000000001', dateStr, {}, 'HR 72')];
|
||||
render(
|
||||
<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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user