Enhance ReportPreviewOverlay to display DOC weight and improve KPI row styling. Update dashboard report payload to include docWeight, and adjust report summary to incorporate it. Add tests for docWeight functionality.

This commit is contained in:
Alberto-Audrix committed 2026-09-07 14:18:32 +07:00
1 parent 75eb218558
commit 3ba6fed189
7 files changed
+123 -18

No files matched your search

+15 -1
View File
@@ -12,6 +12,7 @@ function emptyPayload(overrides: Partial<DashboardReportPayload> = {}): Dashboar
kandangName: 'Kandang 1',
area: 'Area A',
upToDay: 2,
docWeight: null,
generatedAt: '2026-05-03T00:00:00.000Z',
reportType: 'daily',
counting: [],
@@ -46,10 +47,11 @@ describe('latestValidRatio', () => {
});
describe('buildReportSummary', () => {
it('returns 13 metrics in the agreed order with nulls when sections are empty', () => {
it('returns 14 metrics in the agreed order with nulls when sections are empty', () => {
const summary = buildReportSummary(emptyPayload({ upToDay: 5 }));
expect(summary.metrics.map((m) => m.key)).toEqual([
'umur',
'docWeight',
'populasi',
'mortalitas',
'panen',
@@ -171,6 +173,7 @@ describe('buildReportSummary', () => {
ReportSummaryMetric
>;
expect(byKey.umur.value).toBe(2);
expect(byKey.docWeight.value).toBeNull();
expect(byKey.populasi.value).toBe(19875);
expect(byKey.mortalitas.value).toBe(15);
expect(byKey.panen.value).toBe(100);
@@ -203,4 +206,15 @@ describe('buildReportSummary', () => {
);
expect(summary.metrics.find((m) => m.key === 'beratAvg')?.value).toBe(905);
});
it('places Berat DOC beside Umur from payload.docWeight', () => {
const summary = buildReportSummary(emptyPayload({ upToDay: 3, docWeight: 42 }));
expect(summary.metrics[0]).toMatchObject({ key: 'umur', value: 3 });
expect(summary.metrics[1]).toMatchObject({
key: 'docWeight',
label: 'Berat DOC',
value: 42,
unit: 'gram',
});
});
});