faafd99ef8
Auto Tag Develop / tag (push) Successful in 8s
MR unique regroupant tout le module M5 « Tickets de pesée » (remplace les MR empilées #140/#141/#142/#143).
## Périmètre
- **ERP-188** — Page liste des tickets de pesée + export XLSX (colonnes Fournisseur/Client/Autre + Statut).
- **ERP-189** — Écran « Ajouter » (4 champs en haut, 2 blocs de pesée, pesée bascule/manuelle, date+heure horodatée à la validation).
- **ERP-190** — Écran « Modifier » + bouton Imprimer.
- **ERP-191** — i18n + libellés + branchement site courant.
- **ERP-192** — Bon de pesée PDF généré côté back (template Twig → Dompdf), endpoint `GET /api/weighing_tickets/{id}/print.pdf`.
- **ERP-193** — Cycle de vie brouillon/validé (status DRAFT/VALIDATED, numéro attribué à la validation), DSD saisi conservé en pesée manuelle, retours métier design.
## Vérifications
- Back : tests Logistique + architecture verts, php-cs-fixer propre, migrations appliquées (dev + test).
- Front : suite Vitest complète verte, ESLint propre.
Base : `develop` — contient les 16 commits du M5 (rien d'autre).
Reviewed-on: #144
Co-authored-by: tristan <tristan@yuno.malio.fr>
Co-committed-by: tristan <tristan@yuno.malio.fr>
53 lines
2.3 KiB
TypeScript
53 lines
2.3 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { formatDateFr, formatWeightKg, formatPlate } from '../weighingTicketFormat'
|
|
|
|
describe('weighingTicketFormat', () => {
|
|
// ── Date JJ-MM-AAAA ───────────────────────────────────────────────────────
|
|
describe('formatDateFr', () => {
|
|
it('formate un datetime ISO en JJ-MM-AAAA', () => {
|
|
expect(formatDateFr('2026-06-17T09:12:00+02:00')).toBe('17-06-2026')
|
|
})
|
|
|
|
it('zéro-pad le jour et le mois', () => {
|
|
expect(formatDateFr('2026-01-05T00:00:00Z')).toBe('05-01-2026')
|
|
})
|
|
|
|
it('retourne une chaîne vide si absente ou invalide', () => {
|
|
expect(formatDateFr(null)).toBe('')
|
|
expect(formatDateFr(undefined)).toBe('')
|
|
expect(formatDateFr('pas-une-date')).toBe('')
|
|
})
|
|
})
|
|
|
|
// ── Poids « X XXX Kg » ────────────────────────────────────────────────────
|
|
describe('formatWeightKg', () => {
|
|
it('ajoute un séparateur de milliers (espace) et le suffixe Kg', () => {
|
|
expect(formatWeightKg(7150)).toBe('7 150 Kg')
|
|
expect(formatWeightKg(14300)).toBe('14 300 Kg')
|
|
expect(formatWeightKg(1000000)).toBe('1 000 000 Kg')
|
|
})
|
|
|
|
it('gère les petits nombres sans séparateur', () => {
|
|
expect(formatWeightKg(0)).toBe('0 Kg')
|
|
expect(formatWeightKg(999)).toBe('999 Kg')
|
|
})
|
|
|
|
it('retourne une chaîne vide si le poids est absent', () => {
|
|
expect(formatWeightKg(null)).toBe('')
|
|
expect(formatWeightKg(undefined)).toBe('')
|
|
})
|
|
})
|
|
|
|
// ── Immatriculation UPPER ─────────────────────────────────────────────────
|
|
describe('formatPlate', () => {
|
|
it('met en majuscules et trim', () => {
|
|
expect(formatPlate(' ab-123-cd ')).toBe('AB-123-CD')
|
|
})
|
|
|
|
it('retourne une chaîne vide si absente', () => {
|
|
expect(formatPlate(null)).toBe('')
|
|
expect(formatPlate('')).toBe('')
|
|
})
|
|
})
|
|
})
|