fix(aep-15): description, nom et ville du modèle bornés avant la colonne

Checkpoint 22/11, correction 4. Ces trois textes n'étaient bornés que par
leur type. lib/extraction.js::texteBorne les coupe à 300, 200 et 100
caractères (en points de code), une chaîne vide vaut null. Antérieur au
lot, mais le lot touche ces lignes. Tests : texteBorne seul, et un PATCH
à blanc où le modèle rend 1 200 / 450 / 400 caractères.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jules
2026-11-22 11:08:21 +01:00
co-authored by Claude Opus 5.5
parent 7e81b4732a
commit 3a93c84bec
4 changed files with 50 additions and 7 deletions
+15
View File
@@ -365,3 +365,18 @@ describe('checkpoint 22/11 · pagination de la base de R6 (correction 3)', () =>
assert.equal(r.finale(401).sortie.r6.cible.id, 'fiche:2000');
});
});
describe('checkpoint 22/11 · sortie du modèle bornée avant la colonne (correction 4)', () => {
it('description 300, nom 200, ville 100 : jamais plus long dans le PATCH', () => {
const r = jouer({
lignes: [ficheDepuis({ soumis: { url: 'https://exemple.org' } }, 501)],
base: [],
modele: { 501: { nom: 'N'.repeat(450), description: 'D'.repeat(1200), ville: 'V'.repeat(400), objet: 'Exemple', porteurs: [], designations: [], confiance: 'haute' } },
});
const f = r.finale(501);
assert.equal(f.description_enrichie.length, 300);
assert.equal(f.nom.length, 200);
assert.equal(f.localisation_ville.length, 100);
champsTenus(r.patchs);
});
});
+11 -1
View File
@@ -8,7 +8,7 @@ import { readFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { TYPES_ORGANISATION, POSTURES, LIBELLES_TYPE, LIBELLES_POSTURE, proposerType, proposerPostures } from '../lib/taxonomie.js';
import { extractionDepuisModele } from '../lib/extraction.js';
import { extractionDepuisModele, texteBorne, MAX_COLONNES } from '../lib/extraction.js';
const ici = dirname(fileURLToPath(import.meta.url));
const SITE = readFileSync(join(ici, '..', '..', 'utils', 'taxonomie.ts'), 'utf-8');
@@ -98,3 +98,13 @@ describe('lot 15 · extraction rendue par le modèle, bornée', () => {
}
});
});
describe('checkpoint 22/11 · textes du modèle écrits en colonne, bornés (correction 4)', () => {
it('300, 200 et 100 caractères ; coupe en points de code ; vide et non-texte → null', () => {
assert.deepEqual(MAX_COLONNES, { description_enrichie: 300, nom: 200, localisation_ville: 100 });
assert.equal(texteBorne('a'.repeat(500), 300).length, 300);
assert.equal(texteBorne(' Lyon ', 100), 'Lyon');
assert.equal(texteBorne('é'.repeat(99) + '😀😀', 100), 'é'.repeat(99) + '😀', 'jamais la moitié d’un émoji');
for (const v of [null, undefined, 42, {}, ['x'], '', ' ']) assert.equal(texteBorne(v, 100), null);
});
});