import fs from 'node:fs';import assert from 'node:assert/strict';import {createRequire} from 'node:module';import {pathToFileURL} from 'node:url';import {transformWithOxc} from 'vite';import React from 'react';import {renderToStaticMarkup} from 'react-dom/server';import {overviewPage} from '../resources/js/workspace-overview.js'; const require=createRequire(import.meta.url),run=JSON.parse(fs.readFileSync('C:/laragon/data/sgf-tempo/run/modular-regression-current.json')),root=run.root+'/private/receipt-composition-cc50a276c10c',samples=JSON.parse(fs.readFileSync(root+'/overview-samples-private.json'));let code=fs.readFileSync('resources/js/WorkspaceHome.jsx','utf8').replace("from 'react'",'from '+JSON.stringify(pathToFileURL(require.resolve('react')).href)).replace("from './workspace-overview.js'",'from '+JSON.stringify(pathToFileURL(process.cwd()+'/resources/js/workspace-overview.js').href));const compiled=await transformWithOxc(code,'WorkspaceHome.jsx',{jsx:{runtime:'classic'}}),{default:Home,OverviewRecords}=await import('data:text/javascript;base64,'+Buffer.from(compiled.code).toString('base64'));const checks=[],ok=(v,n)=>{assert(v,n);checks.push(n);}; for(const [key,sample]of Object.entries(samples)){const html=renderToStaticMarkup(React.createElement(OverviewRecords,{source:sample.source,result:sample.page,navigate(){}}));ok(html.includes('Evidência')&&html.includes('Abrir consulta completa'),key+' evidence and continuation visible');ok(!html.includes('NaN')&&!html.includes('undefined'),key+' no undefined amounts');} const context={token:'c1',module_id:'commercial',company:{name:'Empresa '},unit:{id:2,name:'Unidade QA'},modules:[{id:'commercial',label:'Comercial'}],single_installation:true};const html=renderToStaticMarkup(React.createElement(Home,{context,groups:[{id:'billing',label:'Facturação',items:[{id:'billing_all',label:'Todos os documentos'}]}]}));ok(html.includes('Do primeiro registo')&&html.includes('Orçamento e rascunho não são receita'),'meaning and interpretation shown');ok(html.includes('Todos os documentos')&&!html.includes('Diário integrado'),'only supplied authorized functions shown');ok(!html.includes('