feat: T4 waves 1-2 - rule configs, schema, suggestions core, season, rule forms
- Rule configs with typed parsers and registry; Berlin day helpers - Schema: T4 enums, Suggestion table, feed vocabulary (feedStatus as ColonyCondition with legacy text mapping), split queen source, varroa sample size; migration harness for data migrations - SuggestionsService: propose/refresh/resolve/obsolete/expire, accept/dismiss/reopen incl. bulk, lock order, concurrency e2e - SeasonService: phenology-based segments, inspection/varroa due dates, queen age; TimeEventsStep with JobPartialFailure - Frontend: per-rule settings forms with visible value sources Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
7097fcd97c
commit
d99a697739
116 files changed
+11239
-801
No files matched your search
@@ -0,0 +1,58 @@
|
||||
import { DEFAULT_PHENOLOGY_CONFIG } from '../automation/rule-config/phenology.config';
|
||||
import type { DbClient } from '../prisma/db-client';
|
||||
import { SeasonService } from './season.service';
|
||||
|
||||
describe('SeasonService', () => {
|
||||
const findUnique = jest.fn();
|
||||
const db = { automationRule: { findUnique } } as unknown as DbClient;
|
||||
const service = new SeasonService();
|
||||
|
||||
beforeEach(() => {
|
||||
findUnique.mockReset().mockResolvedValue(null);
|
||||
});
|
||||
|
||||
it('gives every apiary the calendar state, reading PHENOLOGY once', async () => {
|
||||
const states = await service.statesFor(
|
||||
db,
|
||||
['apiary-1', 'apiary-2', 'apiary-1'],
|
||||
'2026-05-12',
|
||||
);
|
||||
|
||||
expect([...states.keys()]).toEqual(['apiary-1', 'apiary-2']);
|
||||
expect(states.get('apiary-2')).toMatchObject({
|
||||
apiaryId: 'apiary-2',
|
||||
phaseSource: 'CALENDAR',
|
||||
segment: 'SCHWARMZEIT',
|
||||
});
|
||||
expect(findUnique).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('reads no rule without apiaries', async () => {
|
||||
expect((await service.statesFor(db, [], '2026-05-12')).size).toBe(0);
|
||||
expect(findUnique).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('follows the stored calendar of the PHENOLOGY rule', async () => {
|
||||
findUnique.mockResolvedValue({
|
||||
id: 'rule-1',
|
||||
active: true,
|
||||
actionTemplate: null,
|
||||
config: {
|
||||
...DEFAULT_PHENOLOGY_CONFIG,
|
||||
calendarFallback: {
|
||||
...DEFAULT_PHENOLOGY_CONFIG.calendarFallback,
|
||||
SALWEIDE: '03-01',
|
||||
KIRSCHE: '04-01',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const states = await service.statesFor(db, ['apiary-1'], '2026-04-05');
|
||||
|
||||
expect(states.get('apiary-1')).toMatchObject({
|
||||
segment: 'SCHWARMZEIT',
|
||||
segmentSince: '2026-04-01',
|
||||
springSince: '2026-03-01',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user