UNPKG

pulse-dashboard

Version:

A Next.js Dashboard application for real-time monitoring and historical analysis of Playwright test executions, based on playwright-pulse-report. This component provides the UI for visualizing Playwright test results and can be run as a standalone CLI too

1 lines 39 kB
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,18566,(e,s,t)=>{s.exports=e.r(76562)},12042,e=>{"use strict";var s=e.i(43476),t=e.i(18566),a=e.i(87596),r=e.i(15288),l=e.i(19455),n=e.i(67489),i=e.i(71645),d=e.i(81140),o=e.i(30030),c=e.i(42727),m=e.i(96626),h=e.i(48425),u=e.i(86318),x=e.i(69340),p=e.i(10772),g="Tabs",[f,j]=(0,o.createContextScope)(g,[c.createRovingFocusGroupScope]),v=(0,c.createRovingFocusGroupScope)(),[b,N]=f(g),y=i.forwardRef((e,t)=>{let{__scopeTabs:a,value:r,onValueChange:l,defaultValue:n,orientation:i="horizontal",dir:d,activationMode:o="automatic",...c}=e,m=(0,u.useDirection)(d),[g,f]=(0,x.useControllableState)({prop:r,onChange:l,defaultProp:n});return(0,s.jsx)(b,{scope:a,baseId:(0,p.useId)(),value:g,onValueChange:f,orientation:i,dir:m,activationMode:o,children:(0,s.jsx)(h.Primitive.div,{dir:m,"data-orientation":i,...c,ref:t})})});y.displayName=g;var w="TabsList",k=i.forwardRef((e,t)=>{let{__scopeTabs:a,loop:r=!0,...l}=e,n=N(w,a),i=v(a);return(0,s.jsx)(c.Root,{asChild:!0,...i,orientation:n.orientation,dir:n.dir,loop:r,children:(0,s.jsx)(h.Primitive.div,{role:"tablist","aria-orientation":n.orientation,...l,ref:t})})});k.displayName=w;var A="TabsTrigger",C=i.forwardRef((e,t)=>{let{__scopeTabs:a,value:r,disabled:l=!1,...n}=e,i=N(A,a),o=v(a),m=M(i.baseId,r),u=D(i.baseId,r),x=r===i.value;return(0,s.jsx)(c.Item,{asChild:!0,...o,focusable:!l,active:x,children:(0,s.jsx)(h.Primitive.button,{type:"button",role:"tab","aria-selected":x,"aria-controls":u,"data-state":x?"active":"inactive","data-disabled":l?"":void 0,disabled:l,id:m,...n,ref:t,onMouseDown:(0,d.composeEventHandlers)(e.onMouseDown,e=>{l||0!==e.button||!1!==e.ctrlKey?e.preventDefault():i.onValueChange(r)}),onKeyDown:(0,d.composeEventHandlers)(e.onKeyDown,e=>{[" ","Enter"].includes(e.key)&&i.onValueChange(r)}),onFocus:(0,d.composeEventHandlers)(e.onFocus,()=>{let e="manual"!==i.activationMode;x||l||!e||i.onValueChange(r)})})})});C.displayName=A;var T="TabsContent",S=i.forwardRef((e,t)=>{let{__scopeTabs:a,value:r,forceMount:l,children:n,...d}=e,o=N(T,a),c=M(o.baseId,r),u=D(o.baseId,r),x=r===o.value,p=i.useRef(x);return i.useEffect(()=>{let e=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,s.jsx)(m.Presence,{present:l||x,children:({present:a})=>(0,s.jsx)(h.Primitive.div,{"data-state":x?"active":"inactive","data-orientation":o.orientation,role:"tabpanel","aria-labelledby":c,hidden:!a,id:u,tabIndex:0,...d,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:a&&n})})});function M(e,s){return`${e}-trigger-${s}`}function D(e,s){return`${e}-content-${s}`}S.displayName=T;var F=e.i(75157);let L=i.forwardRef(({className:e,...t},a)=>(0,s.jsx)(k,{ref:a,className:(0,F.cn)("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));L.displayName=k.displayName;let I=i.forwardRef(({className:e,...t},a)=>(0,s.jsx)(C,{ref:a,className:(0,F.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));I.displayName=C.displayName;let z=i.forwardRef(({className:e,...t},a)=>(0,s.jsx)(S,{ref:a,className:(0,F.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));z.displayName=S.displayName;var H=e.i(2747),P=e.i(29592),R=e.i(59684),$=e.i(75254);let E=(0,$.default)("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),B=(0,$.default)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);var V=e.i(95468),O=e.i(73884),_=e.i(63209),q=e.i(3116);let G=(0,$.default)("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);var K=e.i(78583);let W=(0,$.default)("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);var J=e.i(52571);let U=(0,$.default)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]),X=(0,$.default)("Film",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]]),Z=(0,$.default)("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);var Y=e.i(68054);let Q=(0,$.default)("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]);var ee=e.i(94918);let es=(0,$.default)("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]),et=(0,$.default)("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]),ea=(0,$.default)("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]),er=(0,$.default)("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]),el=(0,$.default)("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);var en=e.i(57688),ei=e.i(87486),ed=e.i(73443);let eo=(0,$.default)("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);function ec({status:e}){switch("string"==typeof e?e.toLowerCase():""){case"passed":return(0,s.jsx)(V.CheckCircle2,{className:"h-4 w-4 text-green-500 flex-shrink-0"});case"failed":return(0,s.jsx)(O.XCircle,{className:"h-4 w-4 text-destructive flex-shrink-0"});case"skipped":return(0,s.jsx)(_.AlertCircle,{className:"h-4 w-4 text-accent flex-shrink-0"});case"timedout":return(0,s.jsx)(q.Clock,{className:"h-4 w-4 text-destructive flex-shrink-0"});case"pending":return(0,s.jsx)(q.Clock,{className:"h-4 w-4 text-primary animate-pulse flex-shrink-0"});default:return(0,s.jsx)(J.Info,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"})}}function em({step:e,level:t=0}){var a;let r=e.steps&&e.steps.length>0,l=(0,s.jsxs)("div",{className:`flex flex-col space-y-2 ${t>0?"pl-4 border-l border-muted ml-2":""}`,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between space-x-2",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-2 min-w-0",children:[(0,s.jsx)(ec,{status:e.status}),(0,s.jsx)("span",{className:"text-sm font-medium text-foreground truncate",title:e.title,children:e.title}),e.isHook&&(0,s.jsx)(ei.Badge,{variant:"outline",className:"text-xs px-1.5 py-0.5",children:e.hookType||"hook"})]}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:(a=e.duration)<1e3?`${a}ms`:`${(a/1e3).toFixed(2)}s`})]}),e.codeLocation&&(0,s.jsxs)("div",{className:"flex items-center text-xs text-muted-foreground space-x-1 pl-6",children:[(0,s.jsx)(eo,{className:"h-3 w-3"}),(0,s.jsx)("span",{children:e.codeLocation})]}),e.errorMessage&&(0,s.jsxs)("div",{className:"pl-6 mt-1",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-destructive mb-0.5",children:"Error:"}),(0,s.jsx)("pre",{className:"bg-destructive/10 text-xs p-2 rounded-md whitespace-pre-wrap break-all font-code",children:(0,s.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,F.ansiToHtml)(e.errorMessage)}})})]})]});return r?(0,s.jsx)(ed.Accordion,{type:"single",collapsible:!0,className:"w-full py-1",children:(0,s.jsxs)(ed.AccordionItem,{value:`step-${e.id}`,className:"border-none",children:[(0,s.jsx)(ed.AccordionTrigger,{className:"p-1 hover:no-underline hover:bg-muted/50 rounded-md text-left [&[data-state=open]>svg]:rotate-90",children:l}),(0,s.jsx)(ed.AccordionContent,{className:"pt-0 pb-0",children:(0,s.jsx)("div",{className:"mt-1",children:e.steps.map(e=>(0,s.jsx)(em,{step:e,level:t+1},e.id))})})]})}):(0,s.jsx)("div",{className:"py-2 px-1 hover:bg-muted/50 rounded-md",children:l})}var eh=e.i(95187);let eu=(0,eh.createServerReference)("003ef5562612c8d911745f9ca778de12d1263581fc",eh.callServer,void 0,eh.findSourceMapURL,"getRawHistoricalReports");var ex=e.i(44098),ep=e.i(29228),eg=e.i(55706),ef=e.i(85183),ej=e.i(93230),ev=e.i(72526),eb=e.i(34239),eN=e.i(59559);let ey=e=>{let{cx:t,cy:a,payload:r}=e;if(!t||!a||!r)return null;let l="hsl(var(--muted-foreground))";return"passed"===r.status?l="hsl(var(--chart-3))":"failed"===r.status||"timedOut"===r.status?l="hsl(var(--destructive))":"skipped"===r.status&&(l="hsl(var(--accent))"),(0,s.jsx)("circle",{cx:t,cy:a,r:5,fill:l,stroke:"hsl(var(--card))",strokeWidth:1})},ew=({active:e,payload:t,label:a})=>{if(e&&t&&t.length){let e=t[0].payload;return(0,s.jsxs)("div",{className:"bg-card p-3 border border-border rounded-md shadow-lg",children:[(0,s.jsx)("p",{className:"label text-sm font-semibold text-foreground",children:`Date: ${new Date(e.date).toLocaleString()}`}),(0,s.jsx)("p",{className:"text-xs text-foreground",children:`Duration: ${eA(e.duration)}`}),(0,s.jsx)("p",{className:"text-xs",style:{color:"passed"===e.status?"hsl(var(--chart-3))":"failed"===e.status||"timedOut"===e.status?"hsl(var(--destructive))":"hsl(var(--accent))"},children:`Status: ${e.status}`})]})}return null};function ek({status:e}){switch(e){case"passed":return(0,s.jsx)(V.CheckCircle2,{className:"h-6 w-6 text-[hsl(var(--chart-3))]"});case"failed":return(0,s.jsx)(O.XCircle,{className:"h-6 w-6 text-destructive"});case"skipped":return(0,s.jsx)(_.AlertCircle,{className:"h-6 w-6 text-[hsl(var(--accent))]"});case"timedOut":return(0,s.jsx)(q.Clock,{className:"h-6 w-6 text-destructive"});case"pending":return(0,s.jsx)(q.Clock,{className:"h-6 w-6 text-primary animate-pulse"});default:return(0,s.jsx)(J.Info,{className:"h-6 w-6 text-muted-foreground"})}}function eA(e){if(e<1e3)return`${e}ms`;let s=parseFloat((e/1e3).toFixed(2));if(s<60)return`${s}s`;let t=Math.floor(s/60),a=parseFloat((s%60).toFixed(2));return`${t}m ${a}s`}function eC({contentType:e}){let t=e.toLowerCase();return t.includes("html")?(0,s.jsx)(es,{className:"h-6 w-6 text-blue-500"}):t.includes("pdf")?(0,s.jsx)(K.FileText,{className:"h-6 w-6 text-red-500"}):t.includes("json")?(0,s.jsx)(Q,{className:"h-6 w-6 text-yellow-500"}):t.includes("csv")||t.startsWith("text/plain")?(0,s.jsx)(ee.FileSpreadsheet,{className:"h-6 w-6 text-green-500"}):t.startsWith("text/")?(0,s.jsx)(K.FileText,{className:"h-6 w-6 text-gray-500"}):(0,s.jsx)(et,{className:"h-6 w-6 text-gray-400"})}function eT(e,s="Attachment"){return e&&"string"==typeof e&&e.split(/[/\\]/).pop()||s}function eS({testId:e}){let d=(0,t.useRouter)(),{currentRun:o,loadingCurrent:c,errorCurrent:m}=(0,a.useTestData)(),[h,u]=(0,i.useState)(null),[x,p]=(0,i.useState)([]),[g,f]=(0,i.useState)([]),[j,v]=(0,i.useState)(!1),[b,N]=(0,i.useState)(null),w=(0,i.useRef)(null),[k,A]=(0,i.useState)(null),[C,T]=(0,i.useState)(!1),[S,M]=(0,i.useState)(null),[D,$]=(0,i.useState)(!1),[V,O]=(0,i.useState)("current"),q=(0,i.useMemo)(()=>o?.results?.find(s=>s.id===e)||null,[o,e]),ee=async()=>{if(h){T(!0),A(null),M(null);try{let e=await fetch("/api/analyze-test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({testName:h.name,failureLogsAndErrors:h.errorMessage||"",codeSnippet:h.snippet||""})});if(!e.ok){let s=await e.json().catch(()=>({message:"Failed to parse error response"}));throw Error(s.message||`API request failed with status ${e.status}`)}let s=await e.json();A(s)}catch(e){console.error("Error generating AI suggestion:",e),M(e instanceof Error?e.message:"An unknown error occurred.")}finally{T(!1)}}};(0,i.useEffect)(()=>{u(q)},[q]);let ed=(0,i.useCallback)(async()=>{if(e&&!D&&q?.suiteName&&o?.run?.timestamp){v(!0),N(null);try{let s=(await eu()).filter(e=>e.run.timestamp!==o.run.timestamp);p(s);let t=[];s.forEach(s=>{let a=s.results.find(s=>s.id===e&&s.suiteName===q.suiteName);a&&t.push({date:s.run.timestamp,duration:a.duration,status:a.status})}),t.sort((e,s)=>new Date(s.date).getTime()-new Date(e.date).getTime()),f(t),$(!0)}catch(e){console.error("Error fetching test history:",e),N(e instanceof Error?e.message:"Failed to load test history")}finally{v(!1)}}},[e,D,q,o]);(0,i.useEffect)(()=>{if("current"===V)u(q);else{let s=x.find(e=>e.run.timestamp===V);s?.results&&q&&u(s.results.find(s=>s.id===e&&s.suiteName===q.suiteName)||null)}},[V,q,x,e]);let eo=(0,i.useMemo)(()=>h&&Array.isArray(h.screenshots)?h.screenshots.map((e,s)=>({name:eT(e,`Screenshot ${s+1}`),path:e,contentType:"image/png","data-ai-hint":`screenshot ${s+1}`})):[],[h]),ec=(0,i.useMemo)(()=>h&&Array.isArray(h.videoPath)?h.videoPath.map((e,s)=>({name:eT(e,`Video ${s+1}`),path:e,contentType:"video/mp4","data-ai-hint":`video ${s+1}`})):[],[h]),eh=(0,i.useMemo)(()=>h&&"string"==typeof h.tracePath&&h.tracePath?{name:eT(h.tracePath,"trace.zip"),path:h.tracePath,contentType:"application/zip"}:null,[h]),eS=(0,i.useMemo)(()=>h&&Array.isArray(h.attachments)?h.attachments.map((e,s)=>({name:e.name||eT(e.path,`Attachment ${s+1}`),path:e.path,contentType:e.contentType||"application/octet-stream","data-ai-hint":e["data-ai-hint"]})):[],[h]),eM=(0,i.useMemo)(()=>eS.filter(e=>e.contentType.toLowerCase().includes("html")),[eS]),eD=(0,i.useMemo)(()=>eS.filter(e=>e.contentType.toLowerCase().includes("pdf")),[eS]),eF=(0,i.useMemo)(()=>eS.filter(e=>e.contentType.toLowerCase().includes("json")),[eS]),eL=(0,i.useMemo)(()=>eS.filter(e=>e.contentType.toLowerCase().startsWith("text/")||e.contentType.toLowerCase().includes("csv")),[eS]),eI=(0,i.useMemo)(()=>eS.filter(e=>!eM.includes(e)&&!eD.includes(e)&&!eF.includes(e)&&!eL.includes(e)),[eS,eM,eD,eF,eL]),ez=(0,i.useMemo)(()=>eo.length+ec.length+ +!!eh+eS.length,[eo,ec,eh,eS]),eH=h?.status==="failed"||h?.status==="timedOut";if(c&&!h)return(0,s.jsxs)("div",{className:"container mx-auto py-8 space-y-6",children:[(0,s.jsx)(H.Skeleton,{className:"h-10 w-48 mb-4 rounded-md"}),(0,s.jsxs)(r.Card,{className:"shadow-xl rounded-lg",children:[(0,s.jsxs)(r.CardHeader,{children:[(0,s.jsx)(H.Skeleton,{className:"h-8 w-3/4 mb-2 rounded-md"}),(0,s.jsx)(H.Skeleton,{className:"h-4 w-1/2 rounded-md"})]}),(0,s.jsxs)(r.CardContent,{className:"space-y-4",children:[(0,s.jsx)(H.Skeleton,{className:"h-10 w-1/3 mb-4 rounded-md"}),(0,s.jsx)(H.Skeleton,{className:"h-40 w-full rounded-md"})]})]})]});if(m&&!h)return(0,s.jsxs)("div",{className:"container mx-auto px-4 py-8",children:[(0,s.jsxs)(P.Alert,{variant:"destructive",className:"rounded-lg",children:[(0,s.jsx)(P.AlertTitle,{children:"Error loading test data"}),(0,s.jsx)(P.AlertDescription,{children:m})]}),(0,s.jsxs)(l.Button,{onClick:()=>d.push("/"),variant:"outline",className:"mt-4 rounded-lg",children:[(0,s.jsx)(B,{className:"mr-2 h-4 w-4"})," Back"]})]});if(!h)return(0,s.jsxs)("div",{className:"container mx-auto px-4 py-8 text-center",children:[(0,s.jsxs)(P.Alert,{className:"rounded-lg",children:[(0,s.jsx)(P.AlertTitle,{children:"Test Not Found"}),(0,s.jsxs)(P.AlertDescription,{children:["The test with ID '",e,"' could not be found in the current report."]})]}),(0,s.jsxs)(l.Button,{onClick:()=>d.push("/"),className:"mt-6 inline-flex items-center justify-center rounded-xl border bg-transparent px-4 py-2 text-sm font-medium text-muted-foreground shadow-sm transition-all duration-300 ease-in-out hover:-translate-y-0.5 hover:shadow-lg hover:bg-primary hover:text-primary-foreground hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2",children:[(0,s.jsx)(B,{className:"mr-2 h-4 w-4"})," Back to Dashboard"]})]});let eP=function(e){if(!e)return"";let s=e.split(" > ");return s[s.length-1]||e}(h.name);return(0,s.jsxs)("div",{className:"container mx-auto px-4 py-8 space-y-6",children:[(0,s.jsxs)(l.Button,{onClick:()=>d.push("/"),className:"mt-6 inline-flex items-center justify-center rounded-xl border bg-transparent px-4 py-2 text-sm font-medium text-muted-foreground shadow-sm transition-all duration-300 ease-in-out hover:-translate-y-0.5 hover:shadow-lg hover:bg-primary hover:text-primary-foreground hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2",children:[(0,s.jsx)(B,{className:"mr-2 h-4 w-4"})," Back to Dashboard"]}),(0,s.jsxs)(r.Card,{className:"shadow-xl rounded-lg",children:[(0,s.jsxs)(r.CardHeader,{children:[(0,s.jsxs)("div",{className:"flex items-start justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(r.CardTitle,{className:"text-2xl font-headline text-primary flex items-center",title:h.name,children:[(0,s.jsx)(ek,{status:h.status}),(0,s.jsx)("span",{className:"ml-3",children:eP})]}),h.suiteName&&(0,s.jsxs)(r.CardDescription,{className:"mt-1 text-md",children:["From suite: ",h.suiteName]}),(0,s.jsxs)("p",{className:"text-sm text-muted-foreground mt-2",children:["Run Date:"," ","current"===V?c?(0,s.jsx)("span",{className:"text-muted-foreground",children:"Loading..."}):o?.run?.timestamp?(0,s.jsx)("span",{className:"font-medium",children:new Date(o.run.timestamp).toLocaleString()}):m&&!o?.run?.timestamp?(0,s.jsx)("span",{className:"text-destructive font-medium",children:"Error loading date"}):(0,s.jsx)("span",{className:"font-medium",children:"Not available"}):(0,s.jsx)("span",{className:"font-medium",children:new Date(V).toLocaleString()})]}),(0,s.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:[(0,s.jsxs)("p",{children:["ID: ",h.id]}),h.browser&&(0,s.jsxs)("p",{children:["Browser: ",h.browser]})]})]}),(0,s.jsxs)("div",{className:"text-right flex-shrink-0",children:[(0,s.jsx)(ei.Badge,{variant:"outline",className:"capitalize text-sm px-3 py-1 rounded-full border",style:function(e){switch(e){case"passed":return{backgroundColor:"hsl(var(--chart-3))",color:"hsl(var(--primary-foreground))"};case"failed":case"timedOut":return{backgroundColor:"hsl(var(--destructive))",color:"hsl(var(--destructive-foreground))"};case"skipped":return{backgroundColor:"hsl(var(--accent))",color:"hsl(var(--accent-foreground))"};case"pending":return{backgroundColor:"hsl(var(--primary))",color:"hsl(var(--primary-foreground))"};default:return{backgroundColor:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"}}}(h.status),children:h.status}),(0,s.jsxs)("p",{className:"text-sm text-muted-foreground mt-1",children:["Duration: ",eA(h.duration)]}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Retries: ",h.retries]}),h.tags&&h.tags.length>0&&(0,s.jsx)("div",{className:"mt-1 space-x-1",children:h.tags.map(e=>(0,s.jsx)(ei.Badge,{variant:"secondary",className:"text-xs rounded-full",children:e},e))})]})]}),(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsxs)(n.Select,{value:V,onValueChange:O,onOpenChange:e=>{e&&!D&&ed()},children:[(0,s.jsx)(n.SelectTrigger,{className:"w-full md:w-[350px] h-12 rounded-xl bg-card/50 border-2 border-transparent hover:border-primary/30 focus:ring-2 focus:ring-primary/50 focus:ring-offset-2 focus:ring-offset-background transition-colors duration-200 group",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(E,{className:"h-5 w-5 text-muted-foreground transition-colors group-hover:text-primary"}),(0,s.jsx)(n.SelectValue,{placeholder:"Switch to a past run"})]})}),(0,s.jsxs)(n.SelectContent,{sideOffset:8,className:"bg-card/80 backdrop-blur-lg border border-border/50 rounded-xl shadow-2xl data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",children:[(0,s.jsx)(n.SelectItem,{value:"current",className:"rounded-lg",children:"Current Run"}),j&&(0,s.jsx)(n.SelectItem,{value:"loading",disabled:!0,className:"rounded-lg",children:"Loading history..."}),g.map(e=>(0,s.jsx)(n.SelectItem,{value:e.date,className:"rounded-lg",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("span",{className:(0,F.cn)("h-2 w-2 rounded-full",(e=>{switch(e){case"passed":return"bg-green-500";case"failed":case"timedOut":return"bg-red-500";case"skipped":return"bg-yellow-500";default:return"bg-gray-400"}})(e.status)),title:`Status: ${e.status}`}),(0,s.jsxs)("span",{className:"text-sm",children:[new Date(e.date).toLocaleString()," -"," ",(0,s.jsx)("span",{className:"font-medium capitalize",children:e.status})]})]})},e.date))]})]})})]}),(0,s.jsx)(r.CardContent,{children:(0,s.jsxs)(y,{defaultValue:"steps",className:"w-full",onValueChange:e=>{"history"!==e||D||ed()},children:[(0,s.jsxs)(L,{className:(0,F.cn)("grid w-full mb-4 rounded-lg",eH?"grid-cols-2 md:grid-cols-5":"grid-cols-2 md:grid-cols-4"),children:[(0,s.jsxs)(I,{value:"steps",children:["Execution Steps (",h.steps?.length||0,")"]}),(0,s.jsxs)(I,{value:"attachments",children:["Attachments (",ez,")"]}),(0,s.jsxs)(I,{value:"logs",children:[(0,s.jsx)(K.FileText,{className:"h-4 w-4 mr-2"}),"Logs"]}),(0,s.jsx)(I,{value:"history",children:"Test Run History"}),eH&&(0,s.jsxs)(I,{value:"ai-suggestions",children:[(0,s.jsx)(ea,{className:"h-4 w-4 mr-2"}),"AI Suggestions"]})]}),(0,s.jsxs)(z,{value:"steps",className:"mt-4 p-1 md:p-4 border rounded-lg bg-card shadow-inner",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-3 px-3 md:px-0",children:"Test Execution Steps"}),h.errorMessage&&(0,s.jsxs)("div",{className:"mb-4 p-3 md:p-0",children:[(0,s.jsx)("h4",{className:"font-semibold text-md text-destructive mb-1",children:"Overall Test Error:"}),(0,s.jsx)("pre",{className:"bg-destructive/10 text-sm p-4 rounded-lg whitespace-pre-wrap break-all font-code overflow-x-auto",children:(0,s.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,F.ansiToHtml)(h.errorMessage)}})})]}),h.annotations&&h.annotations.length>0&&(0,s.jsx)("div",{className:"mb-4 p-3 md:p-0",children:(0,s.jsxs)("div",{style:{margin:"12px 0",padding:"12px",backgroundColor:"rgba(139, 92, 246, 0.1)",border:"1px solid rgba(139, 92, 246, 0.3)",borderLeft:"4px solid #8b5cf6",borderRadius:"4px"},children:[(0,s.jsx)("h4",{style:{marginTop:0,marginBottom:"10px",color:"#8b5cf6",fontSize:"1.1em"},children:"📌 Annotations"}),h.annotations.map((e,t)=>(0,s.jsxs)("div",{style:{marginBottom:t===h.annotations.length-1?"0":"10px"},children:[(0,s.jsx)("strong",{style:{color:"#8b5cf6"},children:"Type:"})," ",(0,s.jsx)("span",{style:{backgroundColor:"rgba(139, 92, 246, 0.2)",padding:"2px 8px",borderRadius:"4px",fontSize:"0.9em"},children:e.type}),e.description&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("br",{}),(0,s.jsx)("strong",{style:{color:"#8b5cf6"},children:"Description:"})," ",e.description]}),e.location&&(0,s.jsxs)("div",{style:{fontSize:"0.85em",color:"#6b7280",marginTop:"4px"},children:["Location: ",e.location.file,":",e.location.line,":",e.location.column]})]},t))]})}),h.steps&&h.steps.length>0?(0,s.jsx)(R.ScrollArea,{className:"h-[600px] w-full",children:(0,s.jsx)("div",{className:"pr-4",children:h.steps.map((e,t)=>(0,s.jsx)(em,{step:e},e.id||t))})}):(0,s.jsx)("p",{className:"text-muted-foreground p-3 md:p-0",children:"No detailed execution steps available for this test."})]}),(0,s.jsx)(z,{value:"attachments",className:"mt-4 p-1 md:p-4 border rounded-lg bg-card shadow-inner",children:(0,s.jsxs)(y,{defaultValue:"sub-screenshots",className:"w-full",children:[(0,s.jsx)(R.ScrollArea,{className:"w-full whitespace-nowrap rounded-lg",children:(0,s.jsxs)(L,{className:"inline-grid w-max grid-flow-col mb-4 rounded-lg",children:[(0,s.jsxs)(I,{value:"sub-screenshots",disabled:0===eo.length,children:[(0,s.jsx)(G,{className:"h-4 w-4 mr-2"}),"Screenshots (",eo.length,")"]}),(0,s.jsxs)(I,{value:"sub-video",disabled:0===ec.length,children:[(0,s.jsx)(X,{className:"h-4 w-4 mr-2"}),"Videos (",ec.length,")"]}),(0,s.jsxs)(I,{value:"sub-trace",disabled:!eh,children:[(0,s.jsx)(Z,{className:"h-4 w-4 mr-2"}),"Trace ",eh?"(1)":"(0)"]}),(0,s.jsxs)(I,{value:"sub-html",disabled:0===eM.length,children:[(0,s.jsx)(es,{className:"h-4 w-4 mr-2"}),"HTML (",eM.length,")"]}),(0,s.jsxs)(I,{value:"sub-pdf",disabled:0===eD.length,children:[(0,s.jsx)(K.FileText,{className:"h-4 w-4 mr-2"}),"PDF (",eD.length,")"]}),(0,s.jsxs)(I,{value:"sub-json",disabled:0===eF.length,children:[(0,s.jsx)(Q,{className:"h-4 w-4 mr-2"}),"JSON (",eF.length,")"]}),(0,s.jsxs)(I,{value:"sub-text",disabled:0===eL.length,children:[(0,s.jsx)(K.FileText,{className:"h-4 w-4 mr-2"}),"Text/CSV (",eL.length,")"]}),(0,s.jsxs)(I,{value:"sub-other",disabled:0===eI.length,children:[(0,s.jsx)(et,{className:"h-4 w-4 mr-2"}),"Others (",eI.length,")"]})]})}),(0,s.jsxs)(z,{value:"sub-screenshots",className:"mt-4",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"Screenshots"}),eo.length>0?(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:eo.map((e,t)=>{let a=(0,F.getAssetPath)(e.path);return"#"===a?null:(0,s.jsxs)("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"relative aspect-video rounded-lg overflow-hidden group border hover:border-primary transition-all shadow-md hover:shadow-lg",children:[(0,s.jsx)(en.default,{src:a,alt:e.name||`Screenshot ${t+1}`,fill:!0,style:{objectFit:"cover"},className:"group-hover:scale-105 transition-transform duration-300","data-ai-hint":e["data-ai-hint"]||"test screenshot"}),(0,s.jsx)("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-center justify-center p-2",children:(0,s.jsx)("p",{className:"text-white text-xs text-center break-all",children:e.name||`Screenshot ${t+1}`})})]},`img-preview-${t}`)})}):(0,s.jsx)("p",{className:"text-muted-foreground",children:"No screenshots available for this test."})]}),(0,s.jsxs)(z,{value:"sub-video",className:"mt-4",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"Video Recording(s)"}),(0,s.jsx)("div",{className:"space-y-4",children:ec.length>0?ec.map((e,t)=>(0,s.jsxs)("div",{className:"p-4 border rounded-lg bg-muted/30 shadow-sm flex items-center justify-between",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-foreground truncate",title:e.name,children:e.name}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(l.Button,{asChild:!0,variant:"ghost",size:"sm",children:(0,s.jsx)("a",{href:(0,F.getAssetPath)(e.path),target:"_blank",rel:"noopener noreferrer",children:"View"})}),(0,s.jsx)(l.Button,{asChild:!0,variant:"outline",size:"sm",children:(0,s.jsxs)("a",{href:(0,F.getAssetPath)(e.path),download:e.name,children:[(0,s.jsx)(U,{className:"h-4 w-4 mr-2"}),"Download"]})})]})]},`video-${t}`)):(0,s.jsxs)(P.Alert,{className:"rounded-lg",children:[(0,s.jsx)(J.Info,{className:"h-4 w-4"}),(0,s.jsx)(P.AlertTitle,{children:"No Videos Available"}),(0,s.jsx)(P.AlertDescription,{children:"There is no video recording associated with this test run."})]})})]}),(0,s.jsxs)(z,{value:"sub-trace",className:"mt-4",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"Trace File"}),eh?(0,s.jsxs)("div",{className:"p-4 border rounded-lg bg-muted/30 space-y-3 shadow-sm",children:[(0,s.jsxs)("a",{href:(0,F.getAssetPath)(eh.path),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-primary hover:underline text-base",download:eh.name,children:[(0,s.jsx)(U,{className:"h-5 w-5 mr-2"})," Download Trace File (",eh.name,")"]}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Path: ",eh.path]}),(0,s.jsxs)(P.Alert,{className:"rounded-lg",children:[(0,s.jsx)(J.Info,{className:"h-4 w-4"}),(0,s.jsx)(P.AlertTitle,{children:"Using Trace Files"}),(0,s.jsxs)(P.AlertDescription,{children:["Trace files (.zip) can be viewed using the Playwright CLI:"," ",(0,s.jsx)("code",{className:"bg-muted px-1 py-0.5 rounded-sm",children:"npx playwright show-trace /path/to/your/trace.zip"}),". Or by uploading them to"," ",(0,s.jsx)("a",{href:"https://trace.playwright.dev/",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"trace.playwright.dev"}),"."]})]})]}):(0,s.jsxs)(P.Alert,{className:"rounded-lg",children:[(0,s.jsx)(J.Info,{className:"h-4 w-4"}),(0,s.jsx)(P.AlertTitle,{children:"No Trace File Available"}),(0,s.jsx)(P.AlertDescription,{children:"There is no Playwright trace file associated with this test run."})]})]}),[{value:"sub-html",title:"HTML Files",attachments:eM},{value:"sub-pdf",title:"PDF Documents",attachments:eD},{value:"sub-json",title:"JSON Files",attachments:eF},{value:"sub-text",title:"Text & CSV Files",attachments:eL},{value:"sub-other",title:"Other Files",attachments:eI}].map(e=>(0,s.jsxs)(z,{value:e.value,className:"mt-4",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-4",children:e.title}),(0,s.jsx)("div",{className:"space-y-3",children:e.attachments.length>0?e.attachments.map((e,t)=>(0,s.jsxs)("div",{className:"p-3 border rounded-lg bg-muted/30 shadow-sm flex items-center justify-between gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 truncate",children:[(0,s.jsx)(eC,{contentType:e.contentType}),(0,s.jsxs)("div",{className:"truncate",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-foreground truncate",title:e.name,children:e.name}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:e.contentType})]})]}),(0,s.jsxs)("div",{className:"flex items-center flex-shrink-0 gap-2",children:[(0,s.jsx)(l.Button,{asChild:!0,variant:"ghost",size:"sm",children:(0,s.jsx)("a",{href:(0,F.getAssetPath)(e.path),target:"_blank",rel:"noopener noreferrer",children:"View"})}),(0,s.jsx)(l.Button,{asChild:!0,variant:"outline",size:"sm",children:(0,s.jsxs)("a",{href:(0,F.getAssetPath)(e.path),download:e.name,children:[(0,s.jsx)(U,{className:"h-4 w-4 mr-2"}),"Download"]})})]})]},t)):(0,s.jsxs)(P.Alert,{className:"rounded-lg",children:[(0,s.jsx)(J.Info,{className:"h-4 w-4"}),(0,s.jsx)(P.AlertTitle,{children:"No Files Available"}),(0,s.jsx)(P.AlertDescription,{children:"No attachments of this type were found for this test."})]})})]},e.value))]})}),(0,s.jsxs)(z,{value:"logs",className:"mt-4 p-4 border rounded-lg bg-card space-y-6 shadow-inner",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("h3",{className:"text-lg font-semibold text-foreground mb-3 flex items-center",children:[(0,s.jsx)(Y.Terminal,{className:"h-5 w-5 mr-2 text-primary"}),"Console Logs / Standard Output"]}),(0,s.jsx)(R.ScrollArea,{className:"h-48 w-full rounded-lg border p-3 bg-muted/30 shadow-sm",children:(0,s.jsx)("pre",{className:"text-sm whitespace-pre-wrap break-words font-code",children:(0,s.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,F.ansiToHtml)(h.stdout&&Array.isArray(h.stdout)&&h.stdout.length>0?h.stdout.join("\n"):"No standard output logs captured for this test.")}})})})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("h3",{className:"text-lg font-semibold text-foreground mb-3 flex items-center",children:[(0,s.jsx)(_.AlertCircle,{className:"h-5 w-5 mr-2 text-destructive"}),"Error Messages / Standard Error"]}),(0,s.jsx)(R.ScrollArea,{className:"h-48 w-full rounded-lg border bg-destructive/5 shadow-sm",children:(0,s.jsx)("pre",{className:"text-sm p-3 whitespace-pre-wrap break-all font-code",children:(0,s.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,F.ansiToHtml)(h.errorMessage||"No errors captured for this test.")}})})})]}),h.snippet&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("h3",{className:"text-lg font-semibold text-foreground mb-3 flex items-center",children:[(0,s.jsx)(es,{className:"h-5 w-5 mr-2 text-primary"}),"Test Case Snippet"]}),(0,s.jsx)(R.ScrollArea,{className:"h-48 w-full rounded-lg border p-3 bg-muted/30 shadow-sm",children:(0,s.jsx)("pre",{className:"text-sm whitespace-pre-wrap break-words font-code",children:(0,s.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,F.ansiToHtml)(h.snippet)}})})})]})]}),(0,s.jsxs)(z,{value:"history",className:"mt-4 p-4 border rounded-lg bg-card shadow-inner",children:[(0,s.jsx)("div",{className:"flex justify-between items-center mb-3",children:(0,s.jsxs)("h3",{className:"text-lg font-semibold text-foreground flex items-center",children:[(0,s.jsx)(W,{className:"h-5 w-5 mr-2 text-primary"}),"Individual Test Run History"]})}),j&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(H.Skeleton,{className:"h-6 w-3/4 rounded-md"}),(0,s.jsx)(H.Skeleton,{className:"h-64 w-full rounded-lg"})]}),b&&!j&&(0,s.jsxs)(P.Alert,{variant:"destructive",className:"rounded-lg",children:[(0,s.jsx)(_.AlertCircle,{className:"h-4 w-4"}),(0,s.jsx)(P.AlertTitle,{children:"Error Loading Test History"}),(0,s.jsx)(P.AlertDescription,{children:b})]}),!j&&!b&&D&&0===g.length&&(0,s.jsxs)(P.Alert,{className:"rounded-lg",children:[(0,s.jsx)(J.Info,{className:"h-4 w-4"}),(0,s.jsx)(P.AlertTitle,{children:"No Historical Data"}),(0,s.jsxs)(P.AlertDescription,{children:["No historical run data found for this specific test (ID:"," ",e,") in this suite."]})]}),!j&&!b&&g.length>0&&(0,s.jsx)("div",{ref:w,className:"w-full h-[300px] bg-card p-4 rounded-lg shadow-inner",children:(0,s.jsx)(ex.ResponsiveContainer,{width:"100%",height:"100%",children:(0,s.jsxs)(ep.LineChart,{data:[...g].reverse(),margin:{top:5,right:20,left:-20,bottom:5},children:[(0,s.jsx)(ev.CartesianGrid,{strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),(0,s.jsx)(ef.XAxis,{dataKey:"date",tickFormatter:e=>new Date(e).toLocaleDateString("en-CA",{month:"short",day:"numeric"}),stroke:"hsl(var(--muted-foreground))",tick:{fontSize:10},angle:-30,textAnchor:"end",height:40}),(0,s.jsx)(ej.YAxis,{tickFormatter:e=>eA(e),stroke:"hsl(var(--muted-foreground))",tick:{fontSize:10},width:80}),(0,s.jsx)(eb.Tooltip,{content:(0,s.jsx)(ew,{})}),(0,s.jsx)(eN.Legend,{wrapperStyle:{fontSize:"12px"}}),(0,s.jsx)(eg.Line,{type:"monotone",dataKey:"duration",name:"Duration",stroke:"hsl(var(--primary))",strokeWidth:2,dot:(0,s.jsx)(ey,{}),activeDot:{r:7}})]})})})]}),eH&&(0,s.jsx)(z,{value:"ai-suggestions",className:"mt-4 p-4 border rounded-lg bg-card shadow-inner",children:(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center text-center p-2 md:p-6",children:[(0,s.jsxs)("h3",{className:"text-lg font-semibold text-foreground mb-3 flex items-center",children:[(0,s.jsx)(ea,{className:"h-5 w-5 mr-2 text-primary"}),"AI-Powered Failure Analysis"]}),!(C||k||S)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"text-muted-foreground text-sm mb-6 max-w-md",children:"Get suggestions from AI to help diagnose the root cause of this test failure and find potential solutions."}),(0,s.jsxs)(l.Button,{onClick:ee,disabled:C,children:[(0,s.jsx)(ea,{className:"h-4 w-4 mr-2"}),"Generate Suggestion"]})]}),C&&(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-10",children:[(0,s.jsx)(ea,{className:"h-8 w-8 text-primary animate-pulse mb-4"}),(0,s.jsx)("p",{className:"text-muted-foreground",children:"Generating suggestion... Please wait."})]}),S&&(0,s.jsxs)("div",{className:"w-full text-left",children:[(0,s.jsxs)(P.Alert,{variant:"destructive",children:[(0,s.jsx)(P.AlertTitle,{children:"Error Generating Suggestion"}),(0,s.jsx)(P.AlertDescription,{children:S})]}),(0,s.jsxs)(l.Button,{onClick:ee,variant:"outline",size:"sm",className:"mt-4",children:[(0,s.jsx)(ea,{className:"h-4 w-4 mr-2"}),"Try Again"]})]}),k&&(0,s.jsxs)("div",{className:"text-left w-full mt-6 space-y-6",children:[(0,s.jsxs)(P.Alert,{variant:"default",className:"border-primary/30 bg-primary/5",children:[(0,s.jsx)(er,{className:"h-5 w-5 text-primary"}),(0,s.jsx)(P.AlertTitle,{className:"text-primary font-semibold",children:"Root Cause Analysis"}),(0,s.jsx)(P.AlertDescription,{className:"text-primary/90",children:k.rootCause||"No root cause analysis provided."})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-foreground mb-2",children:"Affected Tests:"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:k.affectedTests?.map(e=>(0,s.jsx)(ei.Badge,{variant:"secondary",children:e},e))||(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"N/A"})})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("h4",{className:"font-semibold text-foreground mb-3 flex items-center",children:[(0,s.jsx)(el,{className:"h-4 w-4 mr-2"}),"Suggested Fixes"]}),(0,s.jsxs)("div",{className:"space-y-4",children:[k.suggestedFixes?.map((e,t)=>(0,s.jsxs)(r.Card,{className:"bg-card/50 shadow-md",children:[(0,s.jsx)(r.CardHeader,{children:(0,s.jsxs)(r.CardTitle,{className:"text-base",children:["Suggestion #",t+1]})}),(0,s.jsxs)(r.CardContent,{children:[(0,s.jsx)("p",{className:"text-sm text-muted-foreground mb-3",children:e.description}),e.codeSnippet&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("h5",{className:"text-xs font-semibold text-foreground mb-1 flex items-center",children:[(0,s.jsx)(es,{className:"h-3 w-3 mr-1.5"}),"Code Snippet:"]}),(0,s.jsx)("pre",{className:"bg-muted text-sm p-3 rounded-md whitespace-pre-wrap font-code overflow-x-auto",children:(0,s.jsx)("code",{children:e.codeSnippet})})]})]})]},t)),(!k.suggestedFixes||0===k.suggestedFixes.length)&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No specific fixes were suggested."})]})]}),(0,s.jsxs)(l.Button,{onClick:ee,variant:"outline",size:"sm",className:"mt-4",children:[(0,s.jsx)(ea,{className:"h-4 w-4 mr-2"}),"Regenerate Suggestion"]})]})]})})]})})]})]})}e.s(["TestDetailsClientPage",()=>eS],12042)}]);