Corrige validacao, recuperacao e acesso ao calculo do rascunho
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
const {
|
||||
chromium,
|
||||
} = require('C:/Users/macbook/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/playwright');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
(async () => {
|
||||
const b = await chromium.launch({
|
||||
headless: true,
|
||||
executablePath:
|
||||
'C:/Users/macbook/AppData/Local/ms-playwright/chromium-1243/chrome-win64/chrome.exe',
|
||||
});
|
||||
try {
|
||||
const p = await b.newPage();
|
||||
await p.addInitScript(() =>
|
||||
sessionStorage.setItem(
|
||||
'investmoz-simulation-draft-v1',
|
||||
JSON.stringify({
|
||||
journey_type: 'personal',
|
||||
detail_level: 'simple',
|
||||
purpose: 'simulate_only',
|
||||
preferred_language: 'pt-MZ',
|
||||
fiscal_period: '2026',
|
||||
fiscal_periodicity: 'annual',
|
||||
fiscal_component: 'inss',
|
||||
fiscal_scenario_mode: 'approved_parameters',
|
||||
}),
|
||||
),
|
||||
);
|
||||
let calculations = 0;
|
||||
p.on('request', (r) => {
|
||||
if (r.request) return;
|
||||
if (
|
||||
r.method() === 'POST' &&
|
||||
new URL(r.url()).pathname === '/api/v1/simulations'
|
||||
)
|
||||
calculations++;
|
||||
});
|
||||
const r = await p.goto('http://127.0.0.1:18092/simulador-fiscal');
|
||||
assert.equal(
|
||||
r.headers()['x-investmoz-qa-target'],
|
||||
'investmoz_v2_20261008_test:55441',
|
||||
);
|
||||
await p
|
||||
.getByRole('button', { name: '3. Revisão', exact: true })
|
||||
.click();
|
||||
await p
|
||||
.getByRole('button', { name: 'Validar este rascunho', exact: true })
|
||||
.click();
|
||||
const summary = p.locator('#draft-validation-summary');
|
||||
assert.ok(
|
||||
(await summary.locator('dt').allTextContents()).every(Boolean),
|
||||
);
|
||||
assert.ok(
|
||||
(await summary.locator('dd').allTextContents()).every(Boolean),
|
||||
);
|
||||
await p
|
||||
.getByRole('button', {
|
||||
name: 'Consultar parâmetros fiscais',
|
||||
exact: true,
|
||||
})
|
||||
.click();
|
||||
await p
|
||||
.getByText('Ferramentas de planeamento financeiro', { exact: true })
|
||||
.waitFor();
|
||||
await p
|
||||
.getByText('Faltam parâmetros aprovados para', { exact: false })
|
||||
.waitFor();
|
||||
assert.equal(
|
||||
await p.evaluate(
|
||||
() =>
|
||||
JSON.parse(
|
||||
sessionStorage.getItem('investmoz-simulation-draft-v1'),
|
||||
).fiscal_scenario_mode,
|
||||
),
|
||||
'approved_parameters',
|
||||
);
|
||||
assert.match(await p.locator('body').innerText(), /Indeterminado/);
|
||||
assert.equal(calculations, 0);
|
||||
fs.writeFileSync(
|
||||
'storage/app/private/investmoz-v2/summary-values-approved.json',
|
||||
JSON.stringify(
|
||||
{
|
||||
qa: true,
|
||||
modeUnchanged: true,
|
||||
calculationPosts: calculations,
|
||||
contents: (await p.locator('body').innerText()).slice(
|
||||
-5000,
|
||||
),
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
await b.close();
|
||||
}
|
||||
})().catch((e) => {
|
||||
console.error(e);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
Reference in New Issue
Block a user