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,49 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
countingAccuracy,
|
||||
sackAccuracy,
|
||||
weightAccuracy,
|
||||
combinedMortality,
|
||||
} from '../reportAccuracy.ts';
|
||||
|
||||
describe('countingAccuracy', () => {
|
||||
it('uses smaller/larger × 100 for IoT vs after-count', () => {
|
||||
expect(countingAccuracy(95, 100)).toBe(95);
|
||||
});
|
||||
|
||||
it('returns no accuracy when after-count is 0', () => {
|
||||
expect(countingAccuracy(95, 0)).toBeNull();
|
||||
});
|
||||
|
||||
it('returns no accuracy when IoT count is missing', () => {
|
||||
expect(countingAccuracy(null, 100)).toBeNull();
|
||||
expect(countingAccuracy(undefined, 100)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('sackAccuracy', () => {
|
||||
it('is 100% when both sides are 0', () => {
|
||||
expect(sackAccuracy(0, 0)).toBe(100);
|
||||
});
|
||||
|
||||
it('is N/A when only IoT is set', () => {
|
||||
expect(sackAccuracy(null, 10)).toBeNull();
|
||||
expect(sackAccuracy(0, 10)).toBeNull();
|
||||
});
|
||||
|
||||
it('is 100% when both sides are 10', () => {
|
||||
expect(sackAccuracy(10, 10)).toBe(100);
|
||||
});
|
||||
});
|
||||
|
||||
describe('weightAccuracy', () => {
|
||||
it('uses smaller/larger × 100 for average IoT vs average manual', () => {
|
||||
expect(weightAccuracy(1000, 900)).toBe(90);
|
||||
});
|
||||
});
|
||||
|
||||
describe('combinedMortality', () => {
|
||||
it('sums mati + afkir and ignores panen', () => {
|
||||
expect(combinedMortality(3, 2, 10)).toBe(5);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user