PD-279 — Revue des Tests (7b)¶
Producteur : ChatGPT Date : 2026-03-01 Contexte : PD-279 — Restitution ISO 14641 d'un document archivé (statut RESTITUTED)
Prompt de revue¶
Tu es un QA engineer senior spécialisé en tests de conformité pour des applications NestJS avec exigences ISO 14641 et traçabilité probatoire. Tu effectues une revue des tests pour la story PD-279.
Contexte¶
PD-279 implémente le statut RESTITUTED avec 5 fichiers de test couvrant : - Tests unitaires du service (RestitutionService) - Tests unitaires du controller (RestitutionController) - Tests unitaires du scheduler SLA (RestitutionSlaScheduler) - Tests d'intégration cross-module (state machine, config, enums) - Tests contractuels de la matrice de transitions
Mapping tests contractuels (plan d'implémentation)¶
| Test ID | Référence spec | Mécanisme(s) | Niveau |
|---|---|---|---|
| TC-NOM-01 | INV-279-01, INV-279-02, INV-279-05, CA-279-01/03/09 | RestitutionService.restitute() | Unit |
| TC-NOM-02 | INV-279-03, CA-279-05 | RestitutionService.returnFromRestitution() | Unit |
| TC-NOM-03 | INV-279-05, CA-279-10 | RestitutionSlaScheduler | Unit |
| TC-NOM-04 | INV-279-04, CA-279-07 | lifecycle_log payload structure | Integration |
| TC-NOM-05 | INV-279-06, INV-279-10, CA-279-08 | EligibilityService | Unit + Integration |
| TC-NOM-06 | INV-279-08, CA-279-02 | Migration up/down | Integration (CI) |
| TC-NOM-07 | CA-279-11 | TLA+ model | Formal |
| TC-ERR-01 | §6 (400) | ParseUUIDPipe | Unit |
| TC-ERR-02 | §6 (404) | Document not found | Unit |
| TC-ERR-03 | INV-279-02, CA-279-12 | Ownership guard restitute | Unit |
| TC-ERR-04 | INV-279-03, CA-279-12 | Ownership guard return | Unit |
| TC-ERR-05 | INV-279-02, INV-279-07, CA-279-04 | State guard SEALED | Unit |
| TC-ERR-06 | INV-279-02, CA-279-04 | geo_copy_count < 2 | Unit |
| TC-ERR-07 | INV-279-02, CA-279-04 | legal_lock = true | Unit |
| TC-ERR-08 | INV-279-03, INV-279-07, CA-279-06 | State guard return | Unit |
| TC-ERR-09 | INV-279-05 | Joi config validation | Unit |
| TC-ERR-10 | INV-279-09 | Transaction failure + rollback | Unit |
| TC-INV-09A | INV-279-09 | Transaction interruption | Unit |
| TC-INV-09B | INV-279-09 | SLA scheduler idempotence | Unit |
| TC-NR-01/02/03/04 | Non-régression | State machine transitions | Integration |
| TC-IDEMP-01 | INV-279-11 | Idempotent restitute | Unit |
| TC-IDEMP-02 | INV-279-11 | Idempotent return | Unit |
| TC-NEG-01 | Adversarial | Concurrent calls (SELECT FOR UPDATE) | Integration |
| TC-NEG-02 | Adversarial, INV-279-11 | Replay return | Unit |
| TC-NEG-03 | Adversarial | Mixed-case UUID | Unit |
| TC-NEG-04 | Adversarial | Invalid security_level | Unit |
| TC-NEG-05 | Adversarial | Error code completeness | Integration |
Fichiers de test à revoir¶
1. restitution.service.spec.ts (15 tests)¶
// TC-NOM-01: SEALED → RESTITUTED nominal
// TC-NOM-02: RESTITUTED → SEALED nominal
// TC-ERR-02: Document not found (both endpoints)
// TC-ERR-03: Ownership guard restitute
// TC-ERR-04: Ownership guard return
// TC-ERR-05: State guard restitute (PENDING, EXPIRED)
// TC-ERR-06: geo_copy_count < 2 (two cases: 1 and 0)
// TC-ERR-07: legal_lock = true
// TC-ERR-08: State guard return (PENDING)
// TC-ERR-10/TC-INV-09A: Transaction rollback
// TC-IDEMP-01: Idempotent restitute
// TC-IDEMP-02: Idempotent return
// TC-NEG-03: Mixed-case UUID
2. restitution.controller.spec.ts (9 tests)¶
// Controller delegation (restitute + return)
// Default security_level fallback
// Exception propagation (404, 403, 409)
3. restitution-sla.scheduler.spec.ts (8 tests)¶
// TC-NOM-03a: No documents
// TC-NOM-03b: 80% alert
// TC-NOM-03c: Overdue (3 events)
// TC-INV-09B: Idempotence via digest
// TC-NOM-03d: Below threshold
// TC-NOM-03e: Edge cases (zero duration, multiple docs)
// onModuleInit
4. restitution.integration.spec.ts (26 tests, 1 FAIL)¶
// TC-NOM-04: lifecycle_log payload structure
// TC-NOM-05: Destruction guard enum/error code
// TC-NR-01/02/03/04: State machine authorized + forbidden transitions
// TC-ERR-09: Joi config validation (9 cases — 1 FAIL on 3.5)
// TC-NEG-05: Error code completeness
// DocumentStatus enum membership
FAIL connu : should reject RESTITUTION_MAX_DURATION_DAYS=3.5 (non-integer) — le code utilise Number.parseInt('3.5', 10) qui retourne 3 (troncature silencieuse), donc la valeur est acceptée au lieu d'être rejetée.
5. state-transitions.spec.ts (34 tests)¶
// PD-250 forbidden transitions (5)
// Additional forbidden from terminal states (5)
// PD-279 authorized transitions SEALED↔RESTITUTED (2)
// PD-279 forbidden transitions (8)
// Self-transitions (3)
// Authorized transitions (5)
// Error details (2)
// Complete matrix coverage (3)
Grille d'analyse¶
Pour chaque fichier de test, analyser :
- Couverture des invariants : Chaque INV-279-XX a-t-il au moins un test dédié ?
- Couverture des critères d'acceptation : Chaque CA-279-XX est-il couvert ?
- Qualité des assertions : Les assertions vérifient-elles le bon observable (pas de
toBeDefined()trivial) ? - Tests négatifs : Vérifie-t-on ce qui NE doit PAS arriver (pas d'attestation en idempotent, pas de commit en rollback) ?
- Indépendance des tests : Pas de dépendance d'ordre d'exécution ?
- Fixtures : Spread operator pour copier, pas de mutation de références partagées ?
- TC-IDs : Correspondance 1:1 avec le plan d'implémentation ?
- Tests manquants : Y a-t-il des scénarios du plan non couverts ?
Points d'attention spécifiques¶
- TC-NOM-06 (migration up/down) : absent des tests (CI uniquement ?), est-ce acceptable ?
- TC-NOM-07 (TLA+) : absent (repo séparé), est-ce tracé ?
- TC-NEG-01 (concurrence) : pas de test d'intégration DB réel — SELECT FOR UPDATE non prouvable avec mocks
- TC-NEG-04 (security_level invalide) : pas de test trouvé
- TC-ERR-01 (ParseUUIDPipe 400) : testé implicitement via ParseUUIDPipe NestJS, pas de test explicite
- Test FAIL sur
3.5: bug dans le code config ou dans le test ?
Résultats des tests (run 2026-03-01)¶
Test Suites: 4 passed, 1 failed (restitution.integration.spec.ts), 5 total
Tests: 1 failed, 66 passed, 67 total
FAIL: should reject RESTITUTION_MAX_DURATION_DAYS=3.5 (non-integer)
Received function did not throw
at restitution.integration.spec.ts:213:8
Format de sortie attendu¶
## Verdict : OK / OK AVEC RESERVES / NON CONFORME
### Couverture TC → INV/CA
| TC-ID | INV/CA couverts | Statut | Commentaire |
|-------|-----------------|--------|-------------|
| ... | ... | PASS/FAIL/ABSENT | ... |
### Ecarts identifiés
| ID | Fichier test | Gravité | Description |
|----|-------------|---------|-------------|
| ... | ... | BLOQUANT/MAJEUR/MINEUR | ... |
### Tests manquants
- [liste]
### Recommandations
- [liste]