From 428f30aabebfa9c787a6449e2a120da8bf546b52 Mon Sep 17 00:00:00 2001 From: tristan Date: Thu, 18 Jun 2026 16:25:46 +0200 Subject: [PATCH] =?UTF-8?q?test(date)=20:=20garde=20de=20non-r=C3=A9gressi?= =?UTF-8?q?on=20sur=20le=20masque=20born=C3=A9=20du=20DateTime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le DateTime partage CalendarField, donc buildBoundedMask bornait déjà sa saisie (heure 0-2, minute 0-5) — couvert par maskTemplate.test.ts. Ce test rend la garantie explicite côté composant : 99/99/9999 99:99 ne peut pas être tapé et n'émet aucun datetime. Co-Authored-By: Claude Opus 4.8 (1M context) --- app/components/malio/date/DateTime.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/components/malio/date/DateTime.test.ts b/app/components/malio/date/DateTime.test.ts index 054977b..e328f10 100644 --- a/app/components/malio/date/DateTime.test.ts +++ b/app/components/malio/date/DateTime.test.ts @@ -153,6 +153,19 @@ describe('MalioDateTime', () => { expect(wrapper.text()).toContain('Date invalide') }) + it('empêche la frappe d\'un datetime absurde (99/99/9999 99:99 borné par le masque)', async () => { + const wrapper = mountDateTime({editable: true}) + const input = wrapper.get('[data-test="date-input"]') + await input.setValue('99/99/9999 99:99') + await input.trigger('blur') + // Le masque borne le 1er chiffre de chaque champ (jour 0-3, mois 0-1, + // heure 0-2, minute 0-5) : « 9 » est rejeté partout, rien ne s'inscrit + // et aucun datetime réel n'est émis. + expect((input.element as HTMLInputElement).value).not.toContain('99') + const emitted = wrapper.emitted('update:modelValue') ?? [] + expect(emitted.every(([value]) => value === null)).toBe(true) + }) + it('passe en erreur si le datetime saisi est hors min/max', async () => { const wrapper = mountDateTime({editable: true, min: '2026-05-10T00:00:00', max: '2026-05-20T00:00:00'}) const input = wrapper.get('[data-test="date-input"]')