import test from 'node:test'; import assert from 'node:assert/strict'; import fs from 'node:fs'; import {createRequire} from 'node:module'; import React from 'react'; import {renderToStaticMarkup} from 'react-dom/server'; import ts from 'typescript'; const require=createRequire(import.meta.url), module={exports:{}}; const code=ts.transpileModule(fs.readFileSync(new URL('../../resources/js/pages/management/editorial-workflow.tsx',import.meta.url),'utf8'),{compilerOptions:{module:ts.ModuleKind.CommonJS,jsx:ts.JsxEmit.ReactJSX}}).outputText; new Function('require','module','exports',code)(name=>name==='@/lib/editorial-states'?{states:{}}:name==='@inertiajs/react'?{Link:({href,children,...props})=>React.createElement('a',{href,...props},children),router:{}}:name==='./shared'?{Management:({title,children})=>React.createElement('main',null,React.createElement('h1',null,title),children),Field:({label,children})=>React.createElement('label',null,label,children),button:'',control:''}:require(name),module,module.exports); const base={items:{data:[],current_page:1,last_page:1},notices:[],resourceAccess:true,opportunitiesUrl:'/opportunities-qa',opportunityPending:2,clustersUrl:'/clusters-qa',nativePending:{clusters:3,territories:0,zones:0},subjectsUrl:'/subjects-qa',territorialUrl:'/territories-qa',demographyUrl:'/demography-qa'}; test('dashboard groups authorised activities once with contextual counts and an empty notification state',()=>{ const html=renderToStaticMarkup(React.createElement(module.exports.default,base)); for(const title of ['Conteúdos e oportunidades','Investimentos e competitividade','Território e dados'])assert.match(html,new RegExp(title)); assert.equal((html.match(/href="\/opportunities-qa"/g)??[]).length,1); assert.match(html,/2 pendentes/);assert.match(html,/3 pendentes/); assert.match(html,/Não há notificações neste âmbito/); assert.match(html,/md:grid-cols-2 xl:grid-cols-3/); }); test('restricted dashboard omits unavailable groups, private content controls and counters',()=>{ const html=renderToStaticMarkup(React.createElement(module.exports.default,{items:base.items,notices:[],resourceAccess:false,opportunitiesUrl:null,opportunityPending:0})); assert.doesNotMatch(html,/Fila de conteúdos|kind=legislation|Biblioteca e editores|Investimentos e competitividade|Território e dados/); });