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,
/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/);
+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();
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', () => {
@@ -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');