Files
ApiCore/ApiCore-Backend/src/withdrawal/withdrawal-span.spec.ts
T
Nick SzaunigandClaude Opus 5.5 ef33e5549b feat: T4 wave 5 - colony end cleanup, withdrawal chain, next steps, inspection takeover UI
- Colony end releases the queen in the same transaction; open
  suggestions become obsolete and a CLEANUP suggestion lists open
  tasks and the queen; apply-cleanup validates evidence and blocks
  reactivated colonies
- Withdrawal chain: plausibility warnings on harvest and bottling,
  conflict notifications also when a treatment is entered or corrected
  after the harvest (naming bottled lots), withdrawal spans in the
  calendar and M365 sync, Berlin-day end events
- Next 3 steps per colony and the "Heute" endpoint with ranking and an
  explicit merge table by intent
- Inspection-triggered rule suggestions follow the colony's latest
  inspection (resolve when the finding is gone, refresh when it stays)
- Frontend: colony card takeover in the inspection form, feed status as
  condition, occupied frames 0-40; legacy offline entries keep syncing
- Notifications and preferences are deleted with their user

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-14 16:28:07 +02:00

44 lines
1.2 KiB
TypeScript

import { withdrawalSpanOf } from './withdrawal-span';
const treatment = (overrides: Record<string, unknown> = {}) => ({
id: 't1',
colonyId: 'c1',
product: 'Oxuvar',
date: new Date('2026-07-31T00:00:00.000Z'),
startDate: null,
endDate: null,
withdrawalPeriodDays: 20,
...overrides,
});
describe('withdrawalSpanOf', () => {
it('is the withdrawal window of a treatment with withdrawal days', () => {
expect(withdrawalSpanOf(treatment())).toEqual({
treatmentId: 't1',
colonyId: 'c1',
product: 'Oxuvar',
fromDay: '2026-07-31',
untilDay: '2026-08-20',
});
});
it('is null without withdrawal days', () => {
expect(
withdrawalSpanOf(treatment({ withdrawalPeriodDays: null })),
).toBeNull();
});
it('is null for a window of zero days, which covers no day to show', () => {
expect(withdrawalSpanOf(treatment({ withdrawalPeriodDays: 0 }))).toBeNull();
});
it('is a span of one day for one withdrawal day', () => {
expect(withdrawalSpanOf(treatment({ withdrawalPeriodDays: 1 }))).toEqual(
expect.objectContaining({
fromDay: '2026-07-31',
untilDay: '2026-08-01',
}),
);
});
});