feat(#215): Agenda B1 — GET :id + DTO enrichi
Closes #215 Co-authored-by: Julien Martin <julien.martin@ptits-pas.fr>
This commit was merged in pull request #231.
This commit is contained in:
@@ -165,4 +165,121 @@ describe('EvenementsAgendaService (#172)', () => {
|
||||
}),
|
||||
).rejects.toBeInstanceOf(BadRequestException);
|
||||
});
|
||||
|
||||
it('getById enrichit le DTO — #215', async () => {
|
||||
absencesRepo.findOne.mockResolvedValue({
|
||||
id: 'ev-1',
|
||||
id_placement: 'pl-1',
|
||||
id_lot: 'lot-1',
|
||||
id_card_instance: 'card-1',
|
||||
type: TypeEvenementAgendaType.SOIN_ENFANT,
|
||||
date_debut: '2026-10-16',
|
||||
date_fin: '2026-10-16',
|
||||
heure: '18:19:00',
|
||||
statut: StatutEvenementAgendaType.ACCEPTE,
|
||||
expire_at: new Date('9999-12-31'),
|
||||
cree_par: 'am-1',
|
||||
motif: 'Piqûre',
|
||||
cree_le: new Date(),
|
||||
modifie_le: new Date(),
|
||||
lot: null,
|
||||
placement: {
|
||||
enfantId: 'e-1',
|
||||
amId: 'am-1',
|
||||
child: { id: 'e-1', first_name: 'Léo' },
|
||||
am: { user: { prenom: 'Marie', nom: 'AM' } },
|
||||
},
|
||||
});
|
||||
amChildrenRepo.findOne.mockResolvedValue({
|
||||
id: 'pl-1',
|
||||
amId: 'am-1',
|
||||
enfantId: 'e-1',
|
||||
date_fin: '2026-12-01',
|
||||
});
|
||||
parentsChildrenRepo.findOne.mockResolvedValue({
|
||||
parentId: 'p-1',
|
||||
enfantId: 'e-1',
|
||||
});
|
||||
|
||||
const res = await service.getById('ev-1', 'p-1', RoleType.PARENT);
|
||||
expect(res.id_lot).toBe('lot-1');
|
||||
expect(res.id_card_instance).toBe('card-1');
|
||||
expect(res.heure).toBe('18:19');
|
||||
expect(res.statut_effectif).toBe(StatutEvenementAgendaType.ACCEPTE);
|
||||
expect(res.actions.peut_ack).toBe(true);
|
||||
expect(res.actions.peut_accepter_refuser).toBe(false);
|
||||
});
|
||||
|
||||
it('getById autorise placement terminé (historique) — #215', async () => {
|
||||
absencesRepo.findOne.mockResolvedValue({
|
||||
id: 'ev-old',
|
||||
id_placement: 'pl-ended',
|
||||
type: TypeEvenementAgendaType.ABSENCE_ENFANT,
|
||||
date_debut: '2026-01-01',
|
||||
date_fin: '2026-01-05',
|
||||
statut: StatutEvenementAgendaType.ACCEPTE,
|
||||
expire_at: new Date('9999-12-31'),
|
||||
cree_par: 'p-1',
|
||||
cree_le: new Date(),
|
||||
modifie_le: new Date(),
|
||||
placement: {
|
||||
enfantId: 'e-1',
|
||||
amId: 'am-1',
|
||||
child: { id: 'e-1', first_name: 'Léo' },
|
||||
am: { user: { prenom: 'Marie', nom: 'AM' } },
|
||||
},
|
||||
});
|
||||
amChildrenRepo.findOne.mockResolvedValue({
|
||||
id: 'pl-ended',
|
||||
amId: 'am-1',
|
||||
enfantId: 'e-1',
|
||||
date_fin: '2026-06-01',
|
||||
});
|
||||
parentsChildrenRepo.findOne.mockResolvedValue({
|
||||
parentId: 'p-1',
|
||||
enfantId: 'e-1',
|
||||
});
|
||||
|
||||
const res = await service.getById('ev-old', 'p-1', RoleType.PARENT);
|
||||
expect(res.id).toBe('ev-old');
|
||||
expect(res.actions.peut_modifier).toBe(true);
|
||||
});
|
||||
|
||||
it('libelle_refus n’expose pas l’auteur — #215', async () => {
|
||||
absencesRepo.findOne.mockResolvedValue({
|
||||
id: 'ev-ref',
|
||||
id_placement: 'pl-1',
|
||||
type: TypeEvenementAgendaType.CONGE_AM,
|
||||
date_debut: '2026-11-01',
|
||||
date_fin: '2026-11-10',
|
||||
statut: StatutEvenementAgendaType.REFUSE,
|
||||
expire_at: new Date(),
|
||||
cree_par: 'am-1',
|
||||
motif: 'Vacances scolaires',
|
||||
cree_le: new Date(),
|
||||
modifie_le: new Date(),
|
||||
lot: { statut: 'refuse' },
|
||||
placement: {
|
||||
enfantId: 'e-1',
|
||||
amId: 'am-1',
|
||||
child: { id: 'e-1', first_name: 'Léo' },
|
||||
am: { user: { prenom: 'Marie', nom: 'AM' } },
|
||||
},
|
||||
});
|
||||
amChildrenRepo.findOne.mockResolvedValue({
|
||||
id: 'pl-1',
|
||||
amId: 'am-1',
|
||||
enfantId: 'e-1',
|
||||
date_fin: null,
|
||||
});
|
||||
parentsChildrenRepo.findOne.mockResolvedValue({
|
||||
parentId: 'p-1',
|
||||
enfantId: 'e-1',
|
||||
});
|
||||
|
||||
const res = await service.getById('ev-ref', 'p-1', RoleType.PARENT);
|
||||
expect(res.libelle_refus).toBe('Refusé par une autre famille');
|
||||
expect(res.statut_effectif).toBe(StatutEvenementAgendaType.REFUSE);
|
||||
expect(res.libelle_refus).not.toMatch(/p-2|Dupont|famille B/i);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user