Some checks are pending
CI / Lint bridge (Biome) (push) Waiting to run
CI / Type-check bridge (push) Blocked by required conditions
CI / Tests unit bridge (push) Blocked by required conditions
CI / Tests integration bridge (push) Blocked by required conditions
CI / Security scan (push) Waiting to run
CI / Docker build + healthcheck (push) Blocked by required conditions
Modele OO complet (cf docs/12-uml-class-diagram.md) en TypeScript strict :
- Personne (pivot multi-roles, splits formation/agence, heuresRestantes*)
- Formation -> Bloc -> Module composition + heuresRestantes rollup
- Module.creerAttribution avec validation RG-01 (capacite) + role formateur
- Attribution lifecycle : demarrer/saisirHeuresRealisees/cloturer/annuler
- Client -> Projet -> Tache composition + lierFormationPedagogique
- Tache.creerIntervention avec validation role developpeur + heures > 0 + actif
- Schemas zod pour runtime validation (z.infer types exposes)
- Decimal.js partout pour les heures (zero erreur flottante)
Patterns appliques :
- Statuts comme discriminated unions ('actif' | 'inactif' | ...)
- Statuts annules exclus des rollups (annulation libere capacite)
- _appliquerHeures* en pseudo-private (convention underscore, pas de friend en TS)
- Warn surcharge Personne non bloquant (overbooking volontaire possible) — RG-01 Module reste bloquante
Tests : 111 pass / 0 fail. Coverage domain : 97.86% lines, 98.57% funcs.
tsc strict EXIT 0, biome ci EXIT 0.
Hors scope (a venir) :
- Repository pattern (Bloc 3 avec routes Hono)
- rapportPDF (Phase 2.4)
- Tests adapters Bloc 1 (Bloc 6 via bridge-tester)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
66 lines
2.4 KiB
TypeScript
66 lines
2.4 KiB
TypeScript
import { Decimal } from 'decimal.js';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { Bloc } from '../../src/domain/bloc.js';
|
|
import { Formation } from '../../src/domain/formation.js';
|
|
|
|
describe('Formation', () => {
|
|
it('cree une formation valide', () => {
|
|
const f = new Formation({ id: 1, nom: 'BTS SIO', heuresTotales: new Decimal(1400) });
|
|
expect(f.statut).toBe('draft');
|
|
expect(f.heuresRestantes().toNumber()).toBe(1400);
|
|
});
|
|
|
|
it('throw si heuresTotales < 0', () => {
|
|
expect(() => new Formation({ id: 1, nom: 'X', heuresTotales: new Decimal(-1) })).toThrow();
|
|
});
|
|
|
|
it('throw si dateFin < dateDebut', () => {
|
|
expect(
|
|
() =>
|
|
new Formation({
|
|
id: 1,
|
|
nom: 'X',
|
|
heuresTotales: new Decimal(100),
|
|
dateDebut: new Date('2026-09-01'),
|
|
dateFin: new Date('2026-08-01'),
|
|
}),
|
|
).toThrow();
|
|
});
|
|
|
|
it('activer / archiver transitions', () => {
|
|
const f = new Formation({ id: 1, nom: 'X', heuresTotales: new Decimal(100) });
|
|
f.activer();
|
|
expect(f.statut).toBe('actif');
|
|
f.archiver();
|
|
expect(f.statut).toBe('archive');
|
|
});
|
|
|
|
it('activer apres archive est interdit', () => {
|
|
const f = new Formation({ id: 1, nom: 'X', heuresTotales: new Decimal(100) });
|
|
f.archiver();
|
|
expect(() => f.activer()).toThrow();
|
|
});
|
|
|
|
it('ajouterBloc + heuresRestantes rollup', () => {
|
|
const f = new Formation({ id: 1, nom: 'X', heuresTotales: new Decimal(300) });
|
|
const b1 = new Bloc({ id: 1, formationId: 1, nom: 'B1', heuresPrevues: new Decimal(100) });
|
|
const b2 = new Bloc({ id: 2, formationId: 1, nom: 'B2', heuresPrevues: new Decimal(150) });
|
|
f.ajouterBloc(b1);
|
|
f.ajouterBloc(b2);
|
|
expect(f.heuresAttribuees().toNumber()).toBe(250);
|
|
expect(f.heuresRestantes().toNumber()).toBe(50);
|
|
});
|
|
|
|
it('throw si bloc duplique', () => {
|
|
const f = new Formation({ id: 1, nom: 'X', heuresTotales: new Decimal(300) });
|
|
const b = new Bloc({ id: 1, formationId: 1, nom: 'B1', heuresPrevues: new Decimal(100) });
|
|
f.ajouterBloc(b);
|
|
expect(() => f.ajouterBloc(b)).toThrow(/deja present/);
|
|
});
|
|
|
|
it('throw si depassement capacite formation', () => {
|
|
const f = new Formation({ id: 1, nom: 'X', heuresTotales: new Decimal(100) });
|
|
const b = new Bloc({ id: 1, formationId: 1, nom: 'B1', heuresPrevues: new Decimal(150) });
|
|
expect(() => f.ajouterBloc(b)).toThrow(/depassee/);
|
|
});
|
|
});
|