feat: add optional web and management narratives with F24 QA evidence
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import JSZip from 'jszip';
|
||||
import {
|
||||
simulationFieldGroups,
|
||||
partitionSimulationDraft,
|
||||
restoreSimulationDraft,
|
||||
validateSimulationDraft,
|
||||
} from '../../resources/js/lib/simulation-form.ts';
|
||||
import {
|
||||
buildProjectDossierRows,
|
||||
exportProjectDossierCsv,
|
||||
} from '../../resources/js/lib/project-dossier.ts';
|
||||
import {
|
||||
createProjectDossierReport,
|
||||
createProjectDossierPrintHtml,
|
||||
generateProjectDossierDocx,
|
||||
} from '../../resources/js/lib/project-dossier-report.ts';
|
||||
const texts = {
|
||||
project_summary:
|
||||
'EMPRESA SINTÉTICA QA: organização própria, sem dados da TEMPO.',
|
||||
products_services: 'PRODUTOS QA: prestação de serviços declarada.',
|
||||
competitor_assumption: 'CONCORRÊNCIA QA: hipótese por confirmar.',
|
||||
sales_channel_assumption: 'VENDAS QA: canais propostos pelo investidor.',
|
||||
marketing_approach: 'MARKETING QA: estratégia própria por validar.',
|
||||
web_plan:
|
||||
'WEB QA: <script>não executar</script> & presença digital prevista.',
|
||||
management_summary:
|
||||
'GESTÃO QA: responsabilidades declaradas, sem criar permissões no portal.',
|
||||
};
|
||||
const draft = {
|
||||
journey_type: 'investor',
|
||||
detail_level: 'advanced',
|
||||
purpose: 'simulate_only',
|
||||
...texts,
|
||||
};
|
||||
void test('F24 optional web/management use existing guided business journey and preserve economic roundtrip without required errors', () => {
|
||||
for (const key of ['web_plan', 'management_summary']) {
|
||||
const field = simulationFieldGroups.market.find((f) => f.key === key);
|
||||
assert.ok(field);
|
||||
assert.equal(field.type, 'textarea');
|
||||
assert.equal(field.required, undefined);
|
||||
assert.equal(field.showWhen(draft), true);
|
||||
assert.equal(
|
||||
field.showWhen({ ...draft, journey_type: 'personal' }),
|
||||
false,
|
||||
);
|
||||
}
|
||||
const parts = partitionSimulationDraft(draft, false),
|
||||
recovered = restoreSimulationDraft(
|
||||
parts.personal_snapshot,
|
||||
parts.economic_snapshot,
|
||||
);
|
||||
for (const [key, value] of Object.entries(texts))
|
||||
assert.equal(recovered[key], value);
|
||||
const errors = validateSimulationDraft(
|
||||
{ ...draft, web_plan: '', management_summary: '' },
|
||||
'market',
|
||||
);
|
||||
assert.ok(!errors.web_plan && !errors.management_summary);
|
||||
const legacy = { project_summary: 'Legado próprio' };
|
||||
assert.deepEqual(
|
||||
buildProjectDossierRows({
|
||||
...legacy,
|
||||
web_plan: '',
|
||||
management_summary: '',
|
||||
}),
|
||||
buildProjectDossierRows(legacy),
|
||||
);
|
||||
});
|
||||
void test('F24 own optional texts reach CSV, print and Word as escaped narrative without invented business or financial effects', async () => {
|
||||
const before = JSON.stringify(draft),
|
||||
rows = buildProjectDossierRows(draft),
|
||||
csv = exportProjectDossierCsv(draft);
|
||||
for (const value of Object.values(texts))
|
||||
assert.ok(rows.some((r) => r[2] === value));
|
||||
assert.ok(csv.includes('WEB QA'));
|
||||
assert.ok(csv.includes('GESTÃO QA'));
|
||||
const report = createProjectDossierReport(draft, {
|
||||
selectedSections: new Set(['summary', 'project', 'market', 'team']),
|
||||
generatedAt: '2026-11-22T10:00:00Z',
|
||||
}),
|
||||
html = await createProjectDossierPrintHtml(report, [], true);
|
||||
for (const marker of [
|
||||
'EMPRESA SINTÉTICA',
|
||||
'PRODUTOS QA',
|
||||
'CONCORRÊNCIA QA',
|
||||
'VENDAS QA',
|
||||
'MARKETING QA',
|
||||
'WEB QA',
|
||||
'GESTÃO QA',
|
||||
])
|
||||
assert.ok(html.includes(marker));
|
||||
assert.ok(html.includes('<script>'));
|
||||
assert.ok(!html.includes('<script>não executar'));
|
||||
const zip = await JSZip.loadAsync(
|
||||
await (
|
||||
await generateProjectDossierDocx(report, [], true)
|
||||
).arrayBuffer(),
|
||||
),
|
||||
xml = await zip.file('word/document.xml').async('string');
|
||||
for (const marker of [
|
||||
'EMPRESA SINTÉTICA',
|
||||
'PRODUTOS QA',
|
||||
'CONCORRÊNCIA QA',
|
||||
'VENDAS QA',
|
||||
'MARKETING QA',
|
||||
'WEB QA',
|
||||
'GESTÃO QA',
|
||||
])
|
||||
assert.ok(xml.includes(marker));
|
||||
assert.ok(!report.sections.some((s) => s.id === 'finance'));
|
||||
assert.equal(JSON.stringify(draft), before);
|
||||
});
|
||||
Reference in New Issue
Block a user