feat(#216): Agenda B2 — soft-cancel, matrice temporelle, cron, ack arrêt
- Soft-cancel événement/carte (plus de DELETE physique applicatif) - Matrice : soin [hier–auj.] + 24h ; edit 7×24h ; congé futur libre - Arrêt accepté dès soumission ; ack parent n’écrit plus sur l’événement - verrouille_le à la soumission ; revision bump si dates congé - Cron horaire : auto-valid congés J+7, soft-cancel refusés J+7 - Respond OK après purge_at ; tri fil COALESCE(remonte_le, cree_le) Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -373,4 +373,80 @@ describe('CardsService (#194)', () => {
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
describe('B2 — #216 soft-cancel + ack arrêt', () => {
|
||||
it('ack arrêt maladie → pas de maj événement + carte traitée', async () => {
|
||||
cardsRepo.findOne.mockResolvedValue({
|
||||
id: 'card-arret',
|
||||
type_code: 'arret_maladie_am',
|
||||
id_placement: 'pl-1',
|
||||
id_evenement: 'ev-arret',
|
||||
cree_par: 'am-1',
|
||||
statut: CardInstanceStatutType.OUVERTE,
|
||||
purge_at: new Date(Date.now() - 60_000), // déjà hors fil
|
||||
payload: {},
|
||||
type: {
|
||||
titre: 'Arrêt',
|
||||
response_mode: CardResponseModeType.ACK,
|
||||
retention_days: 7,
|
||||
},
|
||||
responses: [],
|
||||
audience: [
|
||||
{ id_utilisateur: 'am-1' },
|
||||
{ id_utilisateur: 'p-1' },
|
||||
],
|
||||
});
|
||||
audienceRepo.findOne.mockResolvedValue({
|
||||
id_card: 'card-arret',
|
||||
id_utilisateur: 'p-1',
|
||||
});
|
||||
|
||||
const res = await service.repondre('p-1', RoleType.PARENT, 'card-arret', {
|
||||
action: 'ack' as never,
|
||||
});
|
||||
|
||||
expect(evenementsService.maj).not.toHaveBeenCalled();
|
||||
expect(cardsRepo.update).toHaveBeenCalledWith(
|
||||
{ id: 'card-arret' },
|
||||
expect.objectContaining({ statut: CardInstanceStatutType.TRAITEE }),
|
||||
);
|
||||
expect(res.statut).toBe(CardInstanceStatutType.TRAITEE);
|
||||
});
|
||||
|
||||
it('supprimer carte → soft-cancel (update ANNULEE), pas delete', async () => {
|
||||
cardsRepo.findOne.mockResolvedValue({
|
||||
id: 'card-1',
|
||||
type_code: 'absence_enfant',
|
||||
id_placement: 'pl-1',
|
||||
id_evenement: 'ev-1',
|
||||
cree_par: 'p-1',
|
||||
statut: CardInstanceStatutType.OUVERTE,
|
||||
cree_le: new Date(),
|
||||
audience: [{ id_utilisateur: 'p-1' }, { id_utilisateur: 'am-1' }],
|
||||
type: { retention_days: 14 },
|
||||
});
|
||||
evenementsService.supprimer.mockResolvedValue(undefined);
|
||||
|
||||
await service.supprimer('p-1', RoleType.PARENT, 'card-1');
|
||||
|
||||
expect(cardsRepo.delete).not.toHaveBeenCalled();
|
||||
expect(evenementsService.supprimer).toHaveBeenCalledWith(
|
||||
'p-1',
|
||||
RoleType.PARENT,
|
||||
'ev-1',
|
||||
);
|
||||
expect(cardsRepo.update).toHaveBeenCalledWith(
|
||||
{ id: 'card-1' },
|
||||
expect.objectContaining({
|
||||
statut: CardInstanceStatutType.ANNULEE,
|
||||
}),
|
||||
);
|
||||
expect(realtime.emitToUsers).toHaveBeenCalledWith(
|
||||
expect.any(Array),
|
||||
'card.deleted',
|
||||
'card-1',
|
||||
expect.any(Object),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user