fix: complete executive narrative exports and deduplicate company questionnaire in QA
This commit is contained in:
@@ -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('<script>'));
|
||||
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'));
|
||||
});
|
||||
Reference in New Issue
Block a user