Add dashboard report snapshots feature with CRUD operations. Implemented new database migrations for dashboard_report_snapshots, including report type handling. Updated backend routes and models to support snapshot retrieval and upsert functionality. Enhanced frontend components to integrate report snapshot management, including UI for daily and end-cycle reports. Added tests for new functionality to ensure reliability.
CI / lint-and-test (push) Canceled after 0s
CI / lint-and-test (push) Canceled after 0s
This commit is contained in:
1 parent
059087be1d
commit
34336b9bd1
41 files changed
+4824
-178
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
reportDayToDate,
|
||||
dateToReportDay,
|
||||
feedOrWeightDayToReportDay,
|
||||
formatLocalDate,
|
||||
} from '../reportDay.ts';
|
||||
|
||||
/** Same instant PdfReportHeader tests use: 22 Mei 2026 00:00 WIB. */
|
||||
const START = '2026-05-21T17:00:00.000Z';
|
||||
|
||||
describe('reportDayToDate', () => {
|
||||
it('maps day 0 to the cycle start date', () => {
|
||||
const date = reportDayToDate(START, 0);
|
||||
expect(formatLocalDate(date)).toBe('2026-05-22');
|
||||
});
|
||||
|
||||
it('maps day 1 to the day after cycle start', () => {
|
||||
const date = reportDayToDate(START, 1);
|
||||
expect(formatLocalDate(date)).toBe('2026-05-23');
|
||||
});
|
||||
});
|
||||
|
||||
describe('dateToReportDay', () => {
|
||||
it('maps cycle start calendar date to report day 0', () => {
|
||||
expect(dateToReportDay(START, reportDayToDate(START, 0))).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('feedOrWeightDayToReportDay', () => {
|
||||
it('maps 1-based feed day 1 on cycle start to report day 0', () => {
|
||||
expect(feedOrWeightDayToReportDay(1)).toBe(0);
|
||||
const start = reportDayToDate(START, 0);
|
||||
expect(dateToReportDay(START, start)).toBe(0);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user