test: align deployment checks with accepted diagnostics and public presentation
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-22 08:59:38 +02:00
parent 7fc4f2569f
commit eada56aa18
14 changed files with 158 additions and 35 deletions
+51 -9
View File
@@ -7,14 +7,53 @@ import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import ts from 'typescript';
import * as forms from '../../resources/js/lib/fiscal-form-preparation.ts';
const require=createRequire(import.meta.url);
const source=fs.readFileSync(new URL('../../resources/js/pages/portal/fiscal-forms.tsx',import.meta.url),'utf8');
const compiled=ts.transpileModule(source,{compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022,jsx:ts.JsxEmit.ReactJSX}}).outputText;
const module={exports:{}};
new Function('require','module','exports',compiled)(name=>name==='@inertiajs/react'?{Head:()=>null,Link:({href,children,...props})=>React.createElement('a',{href,...props},children),router:{on:()=>()=>{}}}:name==='@/components/portal-menu'?{PortalMenu:()=>null}:name==='@/lib/fiscal-form-preparation'?forms:require(name),module,module.exports);
test('fiscal entry renders labelled editable fields and a guided preparation rather than legislation',()=>{
const html=renderToStaticMarkup(React.createElement(module.exports.default));
for(const label of ['Identificação e período','Nome ou designação social','NUIT','Período — ano e mês','Conferir e guardar','Guardar ficheiro para continuar','Recuperar ficheiro guardado','Confirmar recuperação']) {
const require = createRequire(import.meta.url);
const source = fs.readFileSync(
new URL(
'../../resources/js/pages/portal/fiscal-forms.tsx',
import.meta.url,
),
'utf8',
);
const compiled = ts.transpileModule(source, {
compilerOptions: {
module: ts.ModuleKind.CommonJS,
target: ts.ScriptTarget.ES2022,
jsx: ts.JsxEmit.ReactJSX,
},
}).outputText;
const module = { exports: {} };
new Function('require', 'module', 'exports', compiled)(
(name) =>
name === '@inertiajs/react'
? {
Head: () => null,
Link: ({ href, children, ...props }) =>
React.createElement('a', { href, ...props }, children),
router: { on: () => () => {} },
}
: name === '@/components/portal-menu'
? { PortalMenu: () => null }
: name === '@/lib/fiscal-form-preparation'
? forms
: require(name),
module,
module.exports,
);
test('fiscal entry renders labelled editable fields and a guided preparation rather than legislation', () => {
const html = renderToStaticMarkup(
React.createElement(module.exports.default),
);
for (const label of [
'Identificação e período',
'Nome ou designação social',
'NUIT',
'Período — ano e mês',
'Conferir e guardar',
'Guardar ficheiro para continuar',
'Recuperar ficheiro guardado',
'Confirmar recuperação',
]) {
// Confirmation appears only after a compatible file is selected.
if (label !== 'Confirmar recuperação')
assert.ok(html.includes(label), label);
@@ -29,7 +68,10 @@ void test('IRPC entry opens the requested form directly and keeps its partial co
React.createElement(module.exports.default, { initialTax: 'irpc' }),
);
assert.match(html, /IRPC — Modelo 22/);
assert.match(html, /L8 permanece parcial/);
assert.match(
html,
/não há apuramento automático nem confirmação de elegibilidade/,
);
assert.match(html, /303 — Dupla tributação económica/);
assert.match(html, /304 — Dupla tributação internacional/);
assert.match(html, /Não utilize a mesma parcela/);