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
@@ -0,0 +1,49 @@
|
||||
import type { Prisma } from '../../generated/prisma';
|
||||
import { releaseQueenIn } from './colony-lifecycle';
|
||||
|
||||
describe('releaseQueenIn', () => {
|
||||
let tx: {
|
||||
colony: { findUnique: jest.Mock; update: jest.Mock };
|
||||
queenColonyHistory: { updateMany: jest.Mock };
|
||||
};
|
||||
const asTx = () => tx as unknown as Prisma.TransactionClient;
|
||||
const endDate = new Date('2027-03-12T00:00:00.000Z');
|
||||
|
||||
beforeEach(() => {
|
||||
tx = {
|
||||
colony: { findUnique: jest.fn(), update: jest.fn() },
|
||||
queenColonyHistory: { updateMany: jest.fn() },
|
||||
};
|
||||
});
|
||||
|
||||
it('ends the open history with the end date and clears currentQueenId', async () => {
|
||||
tx.colony.findUnique.mockResolvedValue({ currentQueenId: 'queen-1' });
|
||||
|
||||
const released = await releaseQueenIn(asTx(), 'col-1', endDate);
|
||||
|
||||
expect(released).toBe('queen-1');
|
||||
expect(tx.queenColonyHistory.updateMany).toHaveBeenCalledWith({
|
||||
where: { queenId: 'queen-1', colonyId: 'col-1', endDate: null },
|
||||
data: { endDate },
|
||||
});
|
||||
expect(tx.colony.update).toHaveBeenCalledWith({
|
||||
where: { id: 'col-1' },
|
||||
data: { currentQueenId: null },
|
||||
});
|
||||
});
|
||||
|
||||
it('returns null for a colony without a queen and writes nothing', async () => {
|
||||
tx.colony.findUnique.mockResolvedValue({ currentQueenId: null });
|
||||
|
||||
await expect(releaseQueenIn(asTx(), 'col-1', endDate)).resolves.toBeNull();
|
||||
|
||||
expect(tx.queenColonyHistory.updateMany).not.toHaveBeenCalled();
|
||||
expect(tx.colony.update).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('returns null for an unknown colony', async () => {
|
||||
tx.colony.findUnique.mockResolvedValue(null);
|
||||
|
||||
await expect(releaseQueenIn(asTx(), 'gone', endDate)).resolves.toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user