import test from 'node:test'; import assert from 'node:assert/strict'; import fs from 'node:fs'; import { createRequire } from 'node:module'; import { compileFunction } from 'node:vm'; import React from 'react'; import { renderToStaticMarkup } from 'react-dom/server'; import ts from 'typescript'; import * as presentation from '../../resources/js/lib/public-presentation.ts'; const require = createRequire(import.meta.url); function load(name) { const module = { exports: {} }; const code = ts.transpileModule( fs.readFileSync( new URL( '../../resources/js/components/' + name + '.tsx', import.meta.url, ), 'utf8', ), { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022, jsx: ts.JsxEmit.ReactJSX, }, }, ).outputText; compileFunction(code, ['require', 'module', 'exports'])( (id) => id === '@/lib/public-presentation' ? presentation : id === '@inertiajs/react' ? { Link: ({ children, ...props }) => React.createElement('a', props, children), } : id === './public-reference' ? load('public-reference') : id.startsWith('./') ? { default: () => null } : require(id), module, module.exports, ); return module.exports; } const LocationList = load('structure-geography').LocationList; const base = () => ({ id: 'synthetic', name: 'SYNTHETIC province', role: 'primary', location_type: 'province', path: [{ id: 'p', name: 'SYNTHETIC province', location_type: 'province' }], coordinates: [], boundaries: [], source_reference: 'upgrade do portal de investimentos v4 programacao.docx — 6.1 / 6.6', }); void test('P16 shows every required unknown field without inventing territorial values or exposing internal source paths', () => { const row = base(), before = JSON.stringify(row); const html = renderToStaticMarkup( React.createElement(LocationList, { locations: [row] }), ); assert.match(html, /Posto administrativo<\/dt>