test: align delivery regressions with removal of public financial example
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-23 11:38:35 +02:00
parent 3c2da0291a
commit ab471454f1
3 changed files with 40 additions and 22 deletions
@@ -1788,7 +1788,7 @@ void test('business plan export carries its assumptions, formulas, period, curre
assert.match(csv, /business-plan-v17/); assert.match(csv, /business-plan-v17/);
assert.match( assert.match(
csv, csv,
/Valores do formulário; os valores iniciais podem ser exemplos demonstrativos/, /Pressupostos introduzidos pelo investidor no formulário/,
); );
assert.match(csv, /Ponte contabilístico-fiscal,incomplete/); assert.match(csv, /Ponte contabilístico-fiscal,incomplete/);
assert.match(csv, /Matéria colectável,indeterminate/); assert.match(csv, /Matéria colectável,indeterminate/);
+11 -5
View File
@@ -196,16 +196,22 @@ function editor(initialSnapshot) {
}; };
} }
void test('annual example snapshot is saved through the existing parent callback and recovered by a fresh editor', () => { void test('legacy example snapshot stays preserved but cannot be loaded from the investor editor', () => {
const form = editor(); const form = editor();
form.edit('Preço por unidade', '100');
const saved = JSON.parse(form.snapshot());
const exampleSnapshot = serializeAnnualExampleSnapshot( const exampleSnapshot = serializeAnnualExampleSnapshot(
newAnnualReferencePlan(), newAnnualReferencePlan(),
); );
form.example().onSnapshotChange(exampleSnapshot); saved.plan.annualExampleSnapshot = exampleSnapshot;
const recovered = editor(form.snapshot()); const recovered = editor(JSON.stringify(saved));
assert.equal(recovered.example().snapshot, exampleSnapshot); assert.equal(recovered.example(), undefined);
recovered.edit('Preço por unidade', '250.50'); recovered.edit('Preço por unidade', '250.50');
assert.equal(recovered.example().snapshot, exampleSnapshot); assert.equal(
JSON.parse(recovered.snapshot()).plan.annualExampleSnapshot,
exampleSnapshot,
);
assert.equal(recovered.field('Preço por unidade').value, '250.50');
}); });
void test('monthly units, unit price, variable cost and operating expenses remain editable after snapshot echo', () => { void test('monthly units, unit price, variable cost and operating expenses remain editable after snapshot echo', () => {
@@ -142,7 +142,7 @@ void test('operating components replace rather than add the old aggregate; capit
assert.equal(reload({ ...p, dividendsByPeriod: [5] }), null); assert.equal(reload({ ...p, dividendsByPeriod: [5] }), null);
}); });
void test('the full example shares the saved snapshot and its eleven tables and exports change together, leaving investor inputs untouched', async () => { void test('archived example preserves its eleven tables but is excluded from investor exports', async () => {
const p = financialReportFixture(13), const p = financialReportFixture(13),
annual = newAnnualReferencePlan(); annual = newAnnualReferencePlan();
annual.years[0].sales = '14537.25'; annual.years[0].sales = '14537.25';
@@ -174,22 +174,21 @@ void test('the full example shares the saved snapshot and its eleven tables and
generatedAt: '2026-11-20T12:00:00Z', generatedAt: '2026-11-20T12:00:00Z',
}, },
); );
const all = report.sections.flatMap((s) => s.tables ?? []); assert.equal(
assert.equal(all.length, 11); report.sections.find((section) => section.id === 'finance').tables
assert.deepEqual( .length,
all.find((t) => t.id === 'sales'), 0,
tables.find((t) => t.id === 'sales'),
); );
const html = await createProjectDossierPrintHtml(report, []); const html = await createProjectDossierPrintHtml(report, []);
assert.match(html, /14 537,25/); assert.doesNotMatch(html, /14 537,25|Exemplo sintético/);
assert.match(html, /Exemplo sintético/); assert.match(html, /Seleccione o plano do investidor/);
const blob = await generateProjectDossierDocx(report, []), const blob = await generateProjectDossierDocx(report, []),
zip = await JSZip.loadAsync( zip = await JSZip.loadAsync(
blob instanceof Blob ? await blob.arrayBuffer() : blob, blob instanceof Blob ? await blob.arrayBuffer() : blob,
), ),
xml = await zip.file('word/document.xml').async('string'); xml = await zip.file('word/document.xml').async('string');
assert.match(xml, /14 537,25/); assert.doesNotMatch(xml, /14 537,25|Exemplo sintético/);
assert.match(xml, /Capital por mobilizar/); assert.match(xml, /Seleccione o plano do investidor/);
recovered.reportSource = 'investor'; recovered.reportSource = 'investor';
assert.equal( assert.equal(
buildIntegralFinancialTables(recovered) buildIntegralFinancialTables(recovered)
@@ -405,12 +404,25 @@ void test('actual editor controls preserve declarations through snapshot reload
field('Planear dividendos').props.onChange({ target: { checked: true } }); field('Planear dividendos').props.onChange({ target: { checked: true } });
field('Dividendos, mês 1').props.onChange({ target: { value: '12.25' } }); field('Dividendos, mês 1').props.onChange({ target: { value: '12.25' } });
assert.equal(plan.dividendsByPeriod[0], '12.25'); assert.equal(plan.dividendsByPeriod[0], '12.25');
const select = () => nodes(render()).find((n) => n.type === 'select'); assert.equal(
select().props.onChange({ target: { value: 'annual_example' } }); nodes(render()).some(
assert.equal(plan.reportSource, 'annual_example'); (n) => n.type === 'option' && n.props.value === 'annual_example',
assert.ok(plan.annualExampleSnapshot); ),
assert.equal(buildAnnualExampleTables(plan).length, 11); false,
select().props.onChange({ target: { value: 'investor' } }); );
plan = {
...plan,
reportSource: 'annual_example',
annualExampleSnapshot: serializeAnnualExampleSnapshot(
newAnnualReferencePlan(),
),
};
nodes(render())
.find(
(n) =>
n.type === 'button' && text(n) === 'Usar plano do investidor',
)
.props.onClick();
assert.equal(plan.reportSource, 'investor'); assert.equal(plan.reportSource, 'investor');
assert.equal(plan.dividendsByPeriod[0], '12.25'); assert.equal(plan.dividendsByPeriod[0], '12.25');
assert.equal(plan.products[0].monthlyUnits, '10'); assert.equal(plan.products[0].monthlyUnits, '10');