fix: complete executive narrative exports and deduplicate company questionnaire in QA

This commit is contained in:
2026-11-21 20:45:25 +02:00
parent f5dbd55dfb
commit c144425e77
26 changed files with 875 additions and 36 deletions
@@ -333,3 +333,47 @@ await test('successful save recovers the saved dossier edition and history links
assert.match(html, /dossier-a\/forma-juridica\?revision=event-a/);
assert.match(html, /dossier-a\/forma-juridica\?history_before=100/);
});
await test('C07 keeps one eight-theme questionnaire and one introductory phrase without repeating the pending questions', () => {
const h = harness();
const intro =
'Compare alternativas para discutir a constitui\u00e7\u00e3o; n\u00e3o existe uma forma universalmente prefer\u00edvel.';
const keys = [
'purpose',
'participants',
'participation',
'capital',
'management',
'responsibility',
'listing',
'regulated',
];
const full = Object.fromEntries(
keys.map((key) => [
key,
{
label: 'SYNTHETIC question ' + key,
options: { unknown: 'Por esclarecer' },
},
]),
);
const html = renderToStaticMarkup(
h.render({
definition: { version: 'v1', questions: full },
answers: Object.fromEntries(keys.map((key) => [key, 'unknown'])),
result: {
...props.result,
questions: full,
pending: keys,
route: intro,
},
}),
);
assert.equal(html.split(intro).length - 1, 1);
assert.equal((html.match(/<form\b/g) || []).length, 1);
for (const key of keys)
assert.equal(html.split('name="answers[' + key + ']"').length - 1, 1);
assert.ok(
html.replace(/<[^>]*>/g, '').includes('H\u00e1 8 temas por esclarecer'),
);
assert.doesNotMatch(html, /Por esclarecer:/);
});
+88
View File
@@ -0,0 +1,88 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import JSZip from 'jszip';
import {
createProjectDossierReport,
createProjectDossierPrintHtml,
generateProjectDossierDocx,
} from '../../resources/js/lib/project-dossier-report.ts';
const text =
'Objectivos: testar uma procura declarada. Missao: prestar um servico local. Chaves para o sucesso: qualidade e cumprimento dos prazos.';
const make = () =>
createProjectDossierReport(
{
project_title: 'SYNTHETIC narrative QA',
project_summary: text,
competitor_assumption:
'SYNTHETIC <script>alert(1)</script> & alternatives',
},
{
selectedSections: new Set(['summary', 'project', 'market']),
generatedAt: '2026-11-21T10:00:00Z',
},
);
void test('F23 preserves investor executive objectives, mission and success keys without adopting TEMPO examples', () => {
const r = make();
assert.equal(
r.sections.find((s) => s.id === 'summary').paragraphs[0],
text,
);
assert.ok(
!r.sections
.find((s) => s.id === 'summary')
.paragraphs[0].includes('TEMPO'),
);
});
void test('F26 exports nonfinancial rows as escaped paragraphs in HTML and Word without losing values and provenance', async () => {
const r = make(),
before = JSON.stringify(r);
const html = await createProjectDossierPrintHtml(r, [], true);
assert.doesNotMatch(html, /<table\b/);
assert.ok(html.includes(text));
assert.ok(html.includes('&lt;script&gt;'));
assert.ok(!html.includes('<script>alert'));
const zip = await JSZip.loadAsync(
await (await generateProjectDossierDocx(r, [], true)).arrayBuffer(),
);
const xml = await zip.file('word/document.xml').async('string');
assert.doesNotMatch(xml, /<w:tbl\b/);
assert.ok(xml.includes(text));
assert.match(xml, /Classifica|Origem|origem|introduzido/);
assert.equal(JSON.stringify(r), before);
});
void test('F26 keeps financial metadata tables and detailed financial tables intact alongside narrative paragraphs', async () => {
const r = make();
r.sections.push({
id: 'finance',
title: 'SYNTHETIC finance',
private: true,
paragraphs: [],
rows: [
{
field: 'SYNTHETIC preserved amount',
value: '100.00 MZN',
classification: 'Declared',
origin: 'Synthetic input',
},
],
tables: [
{
id: 'synthetic-core',
title: 'SYNTHETIC core table',
headers: ['Month', 'Cash'],
rows: [['1', '100.00']],
notes: [],
issues: [],
},
],
});
const html = await createProjectDossierPrintHtml(r, [], true);
assert.equal((html.match(/<table\b/g) || []).length, 2);
assert.ok(html.includes('100.00 MZN'));
const zip = await JSZip.loadAsync(
await (await generateProjectDossierDocx(r, [], true)).arrayBuffer(),
);
const xml = await zip.file('word/document.xml').async('string');
assert.equal((xml.match(/<w:tbl\b/g) || []).length, 2);
assert.ok(xml.includes('100.00 MZN'));
});