codigo0/dist/assets/page-testingpage-D_q9Y_VH.js
planetazuzu 0201f16cf4
Some checks are pending
Auto Deploy to Server / deploy (push) Waiting to run
Update lab configuration 2026-03-22
2026-03-22 22:50:29 +01:00

13 lines
8.9 KiB
JavaScript
Executable file

import{r as h,j as t,L as y,aC as P,C as R,aD as k,o as T}from"./0-vendor-react-DWOJpYrt.js";import{C as f}from"./page-comunicacion-DmHQUHoW.js";import{B as d}from"./page-ajustes-DgawOEJM.js";import{e as i}from"./page-farmacos-BsW3CLyQ.js";import{a as E,b as G}from"./page-rcp-CZ8w6Oz0.js";import{B as S}from"./page-galeriaimagenes-Dnb019dP.js";import"./1-vendor-utils-Delnuc0l.js";import"./2-vendor-markdown-BQlHAcA7.js";function A(){try{const e=i.isAvailable();return{name:"ContentAdapter Disponible",passed:e,message:e?"ContentAdapter está disponible y funcionando":"ContentAdapter no está disponible",details:{adapterType:i.constructor.name}}}catch(e){return{name:"ContentAdapter Disponible",passed:!1,message:`Error verificando ContentAdapter: ${e}`,details:{error:e}}}}function O(){try{const e=i.getAllProtocols(),s=e.length>0;return{name:"Obtener Protocolos",passed:s,message:s?`Se encontraron ${e.length} protocolos`:"No se encontraron protocolos",details:{count:e.length,sample:e.slice(0,3).map(a=>({id:a.id,title:a.title}))}}}catch(e){return{name:"Obtener Protocolos",passed:!1,message:`Error obteniendo protocolos: ${e}`,details:{error:e}}}}function w(){try{const e=i.getAllDrugs(),s=e.length>0;return{name:"Obtener Fármacos",passed:s,message:s?`Se encontraron ${e.length} fármacos`:"No se encontraron fármacos",details:{count:e.length,sample:e.slice(0,3).map(a=>({id:a.id,genericName:a.genericName}))}}}catch(e){return{name:"Obtener Fármacos",passed:!1,message:`Error obteniendo fármacos: ${e}`,details:{error:e}}}}function D(){try{const e=i.getAllGuides(),s=e.length>0;return{name:"Obtener Guías",passed:s,message:s?`Se encontraron ${e.length} guías`:"No se encontraron guías",details:{count:e.length,sample:e.slice(0,3).map(a=>({id:a.id,titulo:a.titulo}))}}}catch(e){return{name:"Obtener Guías",passed:!1,message:`Error obteniendo guías: ${e}`,details:{error:e}}}}function x(e){try{const s=i.getProtocol(e),a=s!==null;return{name:`Obtener Protocolo: ${e}`,passed:a,message:a?`Protocolo "${s?.title}" encontrado correctamente`:`Protocolo "${e}" no encontrado`,details:a?{id:s?.id,title:s?.title,category:s?.category}:null}}catch(s){return{name:`Obtener Protocolo: ${e}`,passed:!1,message:`Error obteniendo protocolo: ${s}`,details:{error:s}}}}function j(e){try{const s=E(e),a=s.guide!==null;return{name:`Relaciones Protocolo → Guía: ${e}`,passed:!0,message:a?`Protocolo tiene guía relacionada: "${s.guide?.titulo}"`:"Protocolo no tiene guía relacionada",details:{hasGuide:a,guide:s.guide?{id:s.guide.id,titulo:s.guide.titulo}:null,hasManual:s.manual!==null}}}catch(s){return{name:`Relaciones Protocolo → Guía: ${e}`,passed:!1,message:`Error verificando relaciones: ${s}`,details:{error:s}}}}function b(e){try{const s=G(e),a=s.protocol!==null;return{name:`Relaciones Guía → Protocolo: ${e}`,passed:!0,message:a?`Guía tiene protocolo relacionado: "${s.protocol?.title}"`:"Guía no tiene protocolo relacionado",details:{hasProtocol:a,protocol:s.protocol?{id:s.protocol.id,title:s.protocol.title}:null,hasManual:s.manual!==null}}}catch(s){return{name:`Relaciones Guía → Protocolo: ${e}`,passed:!1,message:`Error verificando relaciones: ${s}`,details:{error:s}}}}function v(){try{const e=localStorage.getItem("content_pack"),s=localStorage.getItem("content_pack_time");if(!e)return{name:"Cache del Content Pack",passed:!0,message:"No hay Content Pack en cache (normal si es primera carga)",details:{hasCache:!1}};const a=JSON.parse(e),l=s?Date.now()-parseInt(s):null,o=l?(l/(1e3*60*60)).toFixed(2):null,r=l?l>1440*60*1e3:!1;return{name:"Cache del Content Pack",passed:!r,message:r?`Cache expirado (${o} horas)`:`Cache válido (${o} horas)`,details:{hasCache:!0,ageHours:o,isExpired:r,packVersion:a.version,packHash:a.hash?.substring(0,16)+"..."}}}catch(e){return{name:"Cache del Content Pack",passed:!1,message:`Error verificando cache: ${e}`,details:{error:e}}}}function F(){return[A(),O(),w(),D(),x("rcp-adulto-svb"),x("obstruccion-via-aerea"),x("shock-hemorragico"),j("rcp-adulto-svb"),j("obstruccion-via-aerea"),b("rcp-adulto-svb"),b("ovace-adulto"),v()]}function z(e){const s=e.filter(r=>r.passed).length,a=e.length,l=(s/a*100).toFixed(1);let o=`
📊 RESULTADOS DE TESTS
`;return o+=`═══════════════════════════════════════
`,o+=`✅ Pasados: ${s}/${a} (${l}%)
`,o+=`❌ Fallidos: ${a-s}/${a}
`,o+=`═══════════════════════════════════════
`,e.forEach((r,m)=>{const c=r.passed?"✅":"❌";o+=`${c} [${m+1}] ${r.name}
`,o+=` ${r.message}
`,r.details&&Object.keys(r.details).length>0&&(o+=` Detalles: ${JSON.stringify(r.details,null,2)}
`),o+=`
`}),o}function q(){const[e,s]=h.useState([]),[a,l]=h.useState(!1),[o,r]=h.useState(null),m=async()=>{l(!0);try{const n=F();s(n),r(new Date),console.log(z(n))}catch(n){console.error("Error ejecutando tests:",n)}finally{l(!1)}},c=n=>{const g=n();s(C=>[...C.filter($=>$.name!==g.name),g])};h.useEffect(()=>{m()},[]);const p=e.filter(n=>n.passed).length,u=e.length,N=u>0?(p/u*100).toFixed(1):"0";return t.jsxs("div",{className:"space-y-6",children:[t.jsx(S,{to:"/",label:"Volver al inicio"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Testing del Sistema"}),t.jsx("p",{className:"text-muted-foreground",children:"Verificación del sistema de contenido y enlaces bidireccionales"})]}),t.jsxs(f,{className:"p-6",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Resumen de Tests"}),o&&t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Última ejecución: ",o.toLocaleTimeString()]})]}),t.jsx(d,{onClick:m,disabled:a,className:"flex items-center gap-2",children:a?t.jsxs(t.Fragment,{children:[t.jsx(y,{className:"w-4 h-4 animate-spin"}),"Ejecutando..."]}):t.jsxs(t.Fragment,{children:[t.jsx(P,{className:"w-4 h-4"}),"Ejecutar Tests"]})})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsxs("div",{className:"text-center p-4 bg-muted rounded-lg",children:[t.jsx("div",{className:"text-3xl font-bold text-foreground",children:p}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Pasados"})]}),t.jsxs("div",{className:"text-center p-4 bg-muted rounded-lg",children:[t.jsx("div",{className:"text-3xl font-bold text-foreground",children:u-p}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Fallidos"})]}),t.jsxs("div",{className:"text-center p-4 bg-muted rounded-lg",children:[t.jsxs("div",{className:"text-3xl font-bold text-foreground",children:[N,"%"]}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Éxito"})]})]})]}),u>0&&t.jsx("div",{className:"w-full bg-muted rounded-full h-4 overflow-hidden",children:t.jsx("div",{className:"h-full bg-primary transition-all duration-500",style:{width:`${N}%`}})}),t.jsxs(f,{className:"p-6",children:[t.jsx("h2",{className:"text-xl font-semibold text-foreground mb-4",children:"Resultados Detallados"}),e.length===0?t.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[t.jsx(R,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),t.jsx("p",{children:"No hay resultados de tests aún."}),t.jsx("p",{className:"text-sm mt-2",children:'Haz clic en "Ejecutar Tests" para comenzar.'})]}):t.jsx("div",{className:"space-y-3",children:e.map((n,g)=>t.jsx("div",{className:`p-4 rounded-lg border-2 ${n.passed?"bg-green-500/10 border-green-500/30":"bg-red-500/10 border-red-500/30"}`,children:t.jsxs("div",{className:"flex items-start gap-3",children:[n.passed?t.jsx(k,{className:"w-5 h-5 text-green-500 flex-shrink-0 mt-0.5"}):t.jsx(T,{className:"w-5 h-5 text-red-500 flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-semibold text-foreground mb-1",children:n.name}),t.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:n.message}),n.details&&Object.keys(n.details).length>0&&t.jsxs("details",{className:"mt-2",children:[t.jsx("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Ver detalles"}),t.jsx("pre",{className:"mt-2 p-2 bg-muted rounded text-xs overflow-x-auto",children:JSON.stringify(n.details,null,2)})]})]})]})},g))})]}),t.jsxs(f,{className:"p-6",children:[t.jsx("h2",{className:"text-xl font-semibold text-foreground mb-4",children:"Tests Rápidos"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[t.jsx(d,{variant:"outline",size:"sm",onClick:()=>c(()=>x("rcp-adulto-svb")),children:"Test RCP"}),t.jsx(d,{variant:"outline",size:"sm",onClick:()=>c(()=>j("rcp-adulto-svb")),children:"Test Relaciones"}),t.jsx(d,{variant:"outline",size:"sm",onClick:()=>c(()=>b("rcp-adulto-svb")),children:"Test Guía→Protocolo"}),t.jsx(d,{variant:"outline",size:"sm",onClick:()=>c(()=>v()),children:"Test Cache"})]})]})]})]})}export{q as default};