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]>
This commit is contained in:
1 parent
02eb16924e
commit
ef33e5549b
122 files changed
+10707
-504
No files matched your search
@@ -25,6 +25,7 @@ describe('WinterChecksService', () => {
|
||||
$queryRaw: jest.Mock;
|
||||
winterCheck: { create: jest.Mock };
|
||||
colony: { update: jest.Mock; findUnique: jest.Mock };
|
||||
queenColonyHistory: { updateMany: jest.Mock };
|
||||
auditLog: { create: jest.Mock };
|
||||
};
|
||||
let prisma: {
|
||||
@@ -50,6 +51,7 @@ describe('WinterChecksService', () => {
|
||||
.fn()
|
||||
.mockResolvedValue({ ...livingColony, status: 'DECEASED' }),
|
||||
},
|
||||
queenColonyHistory: { updateMany: jest.fn() },
|
||||
auditLog: { create: jest.fn() },
|
||||
};
|
||||
prisma = {
|
||||
@@ -112,11 +114,51 @@ describe('WinterChecksService', () => {
|
||||
expect.objectContaining({
|
||||
type: 'ColonyEnded',
|
||||
aggregateId: 'c1',
|
||||
payload: { status: 'DECEASED' },
|
||||
payload: {
|
||||
status: 'DECEASED',
|
||||
endedOn: '2027-03-20',
|
||||
releasedQueenId: null,
|
||||
via: 'WINTER_CHECK',
|
||||
},
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
it('a winter loss with markColonyDeceased releases the queen with the check date', async () => {
|
||||
tx.colony.findUnique.mockResolvedValue({
|
||||
...livingColony,
|
||||
currentQueenId: 'q1',
|
||||
});
|
||||
|
||||
await service.create(lostCheck, 'u1');
|
||||
|
||||
const endDate = new Date('2027-03-20T00:00:00.000Z');
|
||||
expect(tx.queenColonyHistory.updateMany).toHaveBeenCalledWith({
|
||||
where: { queenId: 'q1', colonyId: 'c1', endDate: null },
|
||||
data: { endDate },
|
||||
});
|
||||
expect(tx.colony.update).toHaveBeenCalledWith({
|
||||
where: { id: 'c1' },
|
||||
data: { currentQueenId: null },
|
||||
});
|
||||
expect(events.recordAll).toHaveBeenCalledWith(tx, [
|
||||
expect.anything(),
|
||||
expect.objectContaining({
|
||||
type: 'ColonyEnded',
|
||||
payload: expect.objectContaining({
|
||||
releasedQueenId: 'q1',
|
||||
endedOn: '2027-03-20',
|
||||
}) as object,
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
it('releases no queen when the colony is not marked deceased', async () => {
|
||||
await service.create({ ...lostCheck, markColonyDeceased: false }, 'u1');
|
||||
|
||||
expect(tx.queenColonyHistory.updateMany).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('records no colony event when the colony is not to be marked deceased', async () => {
|
||||
await service.create({ ...lostCheck, markColonyDeceased: false }, 'u1');
|
||||
|
||||
|
||||
Reference in new issue
Block a user