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>
42 lines
1.6 KiB
TypeScript
42 lines
1.6 KiB
TypeScript
import { Decimal } from 'decimal.js';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { Bloc } from '../../src/domain/bloc.js';
|
|
import { Module } from '../../src/domain/module.js';
|
|
|
|
const makeModule = (id: number, h: number) =>
|
|
new Module({ id, blocId: 1, nom: `M${id}`, heuresPrevues: new Decimal(h) });
|
|
|
|
describe('Bloc', () => {
|
|
it('cree un bloc vide', () => {
|
|
const b = new Bloc({ id: 1, formationId: 100, nom: 'B1', heuresPrevues: new Decimal(120) });
|
|
expect(b.modules.length).toBe(0);
|
|
expect(b.heuresAttribuees().toNumber()).toBe(0);
|
|
expect(b.heuresRestantes().toNumber()).toBe(120);
|
|
});
|
|
|
|
it('throw si heuresPrevues < 0', () => {
|
|
expect(
|
|
() => new Bloc({ id: 1, formationId: 100, nom: 'B1', heuresPrevues: new Decimal(-1) }),
|
|
).toThrow();
|
|
});
|
|
|
|
it('ajouterModule rollup correct', () => {
|
|
const b = new Bloc({ id: 1, formationId: 100, nom: 'B1', heuresPrevues: new Decimal(120) });
|
|
b.ajouterModule(makeModule(1, 40));
|
|
b.ajouterModule(makeModule(2, 60));
|
|
expect(b.heuresAttribuees().toNumber()).toBe(100);
|
|
expect(b.heuresRestantes().toNumber()).toBe(20);
|
|
});
|
|
|
|
it('throw si module duplique', () => {
|
|
const b = new Bloc({ id: 1, formationId: 100, nom: 'B1', heuresPrevues: new Decimal(120) });
|
|
b.ajouterModule(makeModule(1, 40));
|
|
expect(() => b.ajouterModule(makeModule(1, 10))).toThrow(/deja present/);
|
|
});
|
|
|
|
it('throw si capacite bloc depassee', () => {
|
|
const b = new Bloc({ id: 1, formationId: 100, nom: 'B1', heuresPrevues: new Decimal(50) });
|
|
b.ajouterModule(makeModule(1, 30));
|
|
expect(() => b.ajouterModule(makeModule(2, 30))).toThrow(/depassee/);
|
|
});
|
|
});
|