From ab471454f16a2bdaf9c59006fb23e32b3eb2234b Mon Sep 17 00:00:00 2001 From: nala Date: Mon, 23 Nov 2026 11:38:35 +0200 Subject: [PATCH] test: align delivery regressions with removal of public financial example --- .../frontend/business-financial-plan.test.mjs | 2 +- tests/frontend/business-plan-editing.test.mjs | 16 ++++--- ...nancial-plan-pending-requirements.test.mjs | 44 ++++++++++++------- 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/tests/frontend/business-financial-plan.test.mjs b/tests/frontend/business-financial-plan.test.mjs index 50970108..16dfbcdc 100644 --- a/tests/frontend/business-financial-plan.test.mjs +++ b/tests/frontend/business-financial-plan.test.mjs @@ -1788,7 +1788,7 @@ void test('business plan export carries its assumptions, formulas, period, curre assert.match(csv, /business-plan-v17/); assert.match( 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, /Matéria colectável,indeterminate/); diff --git a/tests/frontend/business-plan-editing.test.mjs b/tests/frontend/business-plan-editing.test.mjs index 1ffda193..73432722 100644 --- a/tests/frontend/business-plan-editing.test.mjs +++ b/tests/frontend/business-plan-editing.test.mjs @@ -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(); + form.edit('Preço por unidade', '100'); + const saved = JSON.parse(form.snapshot()); const exampleSnapshot = serializeAnnualExampleSnapshot( newAnnualReferencePlan(), ); - form.example().onSnapshotChange(exampleSnapshot); - const recovered = editor(form.snapshot()); - assert.equal(recovered.example().snapshot, exampleSnapshot); + saved.plan.annualExampleSnapshot = exampleSnapshot; + const recovered = editor(JSON.stringify(saved)); + assert.equal(recovered.example(), undefined); 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', () => { diff --git a/tests/frontend/financial-plan-pending-requirements.test.mjs b/tests/frontend/financial-plan-pending-requirements.test.mjs index 58df91c2..c45da2ec 100644 --- a/tests/frontend/financial-plan-pending-requirements.test.mjs +++ b/tests/frontend/financial-plan-pending-requirements.test.mjs @@ -142,7 +142,7 @@ void test('operating components replace rather than add the old aggregate; capit 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), annual = newAnnualReferencePlan(); 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', }, ); - const all = report.sections.flatMap((s) => s.tables ?? []); - assert.equal(all.length, 11); - assert.deepEqual( - all.find((t) => t.id === 'sales'), - tables.find((t) => t.id === 'sales'), + assert.equal( + report.sections.find((section) => section.id === 'finance').tables + .length, + 0, ); const html = await createProjectDossierPrintHtml(report, []); - assert.match(html, /14 537,25/); - assert.match(html, /Exemplo sintético/); + assert.doesNotMatch(html, /14 537,25|Exemplo sintético/); + assert.match(html, /Seleccione o plano do investidor/); const blob = await generateProjectDossierDocx(report, []), zip = await JSZip.loadAsync( blob instanceof Blob ? await blob.arrayBuffer() : blob, ), xml = await zip.file('word/document.xml').async('string'); - assert.match(xml, /14 537,25/); - assert.match(xml, /Capital por mobilizar/); + assert.doesNotMatch(xml, /14 537,25|Exemplo sintético/); + assert.match(xml, /Seleccione o plano do investidor/); recovered.reportSource = 'investor'; assert.equal( 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('Dividendos, mês 1').props.onChange({ target: { value: '12.25' } }); assert.equal(plan.dividendsByPeriod[0], '12.25'); - const select = () => nodes(render()).find((n) => n.type === 'select'); - select().props.onChange({ target: { value: 'annual_example' } }); - assert.equal(plan.reportSource, 'annual_example'); - assert.ok(plan.annualExampleSnapshot); - assert.equal(buildAnnualExampleTables(plan).length, 11); - select().props.onChange({ target: { value: 'investor' } }); + assert.equal( + nodes(render()).some( + (n) => n.type === 'option' && n.props.value === 'annual_example', + ), + false, + ); + 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.dividendsByPeriod[0], '12.25'); assert.equal(plan.products[0].monthlyUnits, '10');