@testver/testver 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/bin/testver.js +8 -5
- package/dist/index.js +1483 -1086
- package/dist/vendor/grpc.cjs +24914 -0
- package/package.json +9 -4
- package/src/ui/static/assets/{AIPanel-D09Ni3a4.js → AIPanel-B_R-CbrF.js} +2 -2
- package/src/ui/static/assets/{AIRecordPanel-DZtUZnRe.js → AIRecordPanel-BRQWIU5h.js} +3 -3
- package/src/ui/static/assets/{AIStreamUI-BsxKziYG.js → AIStreamUI-C3D989_6.js} +3 -3
- package/src/ui/static/assets/{AITestGenPage-Cg21-P1W.js → AITestGenPage-D3t2gPAA.js} +5 -5
- package/src/ui/static/assets/{APITestingPage-Cdc8EZz2.js → APITestingPage-Cmwkiiys.js} +1 -1
- package/src/ui/static/assets/{AboutPage-yJLCr2_q.js → AboutPage-CjEqKB-q.js} +1 -1
- package/src/ui/static/assets/AdvancedPage-4kAcpE8Y.js +3 -0
- package/src/ui/static/assets/{AnalyticsPage-gTPFsiLZ.js → AnalyticsPage-64mYNK2v.js} +1 -1
- package/src/ui/static/assets/{AuditLogPage-DE45E_PV.js → AuditLogPage-BQjOzQje.js} +1 -1
- package/src/ui/static/assets/{ChangesSummary-C-7oi_sx.js → ChangesSummary-CY_Vb27i.js} +2 -2
- package/src/ui/static/assets/{CodeMapPage-DgU6ZYBO.js → CodeMapPage-B1ezmnlE.js} +3 -3
- package/src/ui/static/assets/{ConfirmDialog-DNU3qoAP.js → ConfirmDialog-t7mpeeSN.js} +1 -1
- package/src/ui/static/assets/{CoveragePage-BpTjgcdV.js → CoveragePage-YMmCbiBk.js} +2 -2
- package/src/ui/static/assets/{CronBuilder-DsnX-vRr.js → CronBuilder-Nk-K-_8I.js} +1 -1
- package/src/ui/static/assets/Dashboard-BDVxO2V4.js +1 -0
- package/src/ui/static/assets/{DefectsPage-BtMNbq6Z.js → DefectsPage-l8yGeCyR.js} +1 -1
- package/src/ui/static/assets/{DiffViewer-DPglzjPH.js → DiffViewer-BIU09a_i.js} +1 -1
- package/src/ui/static/assets/{EmptyState-BH_aDO0P.js → EmptyState-D1T3JWUr.js} +1 -1
- package/src/ui/static/assets/{ExportButton-Ce_MxnM1.js → ExportButton-Dt5RhL-h.js} +1 -1
- package/src/ui/static/assets/{FileViewer-iYL0lxyY.js → FileViewer-CrKgh_cB.js} +5 -5
- package/src/ui/static/assets/{GitPage-CQqV8JBC.js → GitPage-_4nCEzkJ.js} +5 -5
- package/src/ui/static/assets/{ImportExportPage-DXk7Koaq.js → ImportExportPage-BcR7IQi9.js} +1 -1
- package/src/ui/static/assets/{JiraPushDialog-CqftoLh8.js → JiraPushDialog-C2sP4_4h.js} +1 -1
- package/src/ui/static/assets/KpiTile-inmeEsy3.js +1 -0
- package/src/ui/static/assets/{LiveExecutionView-BD0wE8sz.js → LiveExecutionView-D5BRe9jq.js} +1 -1
- package/src/ui/static/assets/{MediaModal-DiSINwmh.js → MediaModal-C5n6sHYi.js} +1 -1
- package/src/ui/static/assets/{MobileRunPicker-BNs2lZFf.js → MobileRunPicker-0h-N2c6d.js} +1 -1
- package/src/ui/static/assets/{MobileRunTarget-D2Nqcj10.js → MobileRunTarget-Bo_xekig.js} +1 -1
- package/src/ui/static/assets/{ModuleExplorer-BmkoQrHb.js → ModuleExplorer-VGcmK167.js} +1 -1
- package/src/ui/static/assets/{OutputPage-Dcsr7cmr.js → OutputPage-B_1nPPxE.js} +1 -1
- package/src/ui/static/assets/PipelinesPanel-PmmPu8pj.js +1 -0
- package/src/ui/static/assets/{ProfilePage-ByshrcwC.js → ProfilePage-y7tJNNFd.js} +1 -1
- package/src/ui/static/assets/{ProjectExplorer-B9B___ij.js → ProjectExplorer-DbfGhRq0.js} +1 -1
- package/src/ui/static/assets/{RemoteFileStrip-DbPnaZ-v.js → RemoteFileStrip-WuRKtx_h.js} +1 -1
- package/src/ui/static/assets/ReportCard-G52Q6-2i.js +2 -0
- package/src/ui/static/assets/ReportFullView-Bt8UFP2J.js +1 -0
- package/src/ui/static/assets/ReportsPage-DMtDi73Q.js +48 -0
- package/src/ui/static/assets/ResultsPage-BI9jpK2N.js +115 -0
- package/src/ui/static/assets/RunState-ifC4zi6M.js +1 -0
- package/src/ui/static/assets/{RunTargets-C7Vqd4TU.js → RunTargets-C7vpCbck.js} +1 -1
- package/src/ui/static/assets/{ScriptMappingPage-BrANeHv0.js → ScriptMappingPage-7vHuvhQw.js} +1 -1
- package/src/ui/static/assets/{SearchableDevicePicker-CFJ_DUAA.js → SearchableDevicePicker-BYxYJNWl.js} +1 -1
- package/src/ui/static/assets/{SettingsPage-BwOiebKG.js → SettingsPage-DSISg7r7.js} +1 -1
- package/src/ui/static/assets/SharedReportView-BOqKGJmR.js +1 -0
- package/src/ui/static/assets/{SourcesPage-C_QVQwiA.js → SourcesPage-CgqtYGBi.js} +1 -1
- package/src/ui/static/assets/TestExplorerPage-gYLhCD4d.js +7 -0
- package/src/ui/static/assets/{TestManagementPage-Ch4PthuU.js → TestManagementPage-wqYTKP7W.js} +2 -2
- package/src/ui/static/assets/TestPlansPage-DOKX9p6z.js +5 -0
- package/src/ui/static/assets/{TestverCreditsRing-CUsMGEe3.js → TestverCreditsRing-DpMzl3h7.js} +1 -1
- package/src/ui/static/assets/{UncommittedDiffViewer-B5HSURk8.js → UncommittedDiffViewer-BxS0zi-p.js} +1 -1
- package/src/ui/static/assets/{UserManagementPage-BjY3ftxf.js → UserManagementPage-B5d0uDU_.js} +2 -2
- package/src/ui/static/assets/{WorkflowsPage-BUu-LjZ8.js → WorkflowsPage-Bk0DFnFS.js} +17 -17
- package/src/ui/static/assets/{hiddenLlmProviders-setxgY_B.js → hiddenLlmProviders-CdhhNa5G.js} +1 -1
- package/src/ui/static/assets/index-BYVxKLrT.js +47 -0
- package/src/ui/static/assets/index-C2KJt7SI.css +1 -0
- package/src/ui/static/assets/reportMeta-AKcU_qwq.js +1 -0
- package/src/ui/static/assets/{useFeatureFlags-DqhngqgG.js → useFeatureFlags-DNkIctil.js} +1 -1
- package/src/ui/static/assets/{useJiraConnector-TM1Rfj1s.js → useJiraConnector-D5ysBBvz.js} +1 -1
- package/src/ui/static/assets/{useOwnership-eW6Egd7X.js → useOwnership-U0AfKBRo.js} +1 -1
- package/src/ui/static/assets/{useSuites-CvtMGakZ.js → useSuites-DyfN9HVv.js} +1 -1
- package/src/ui/static/assets/{useTestExplorer-HqvURJAc.js → useTestExplorer-DT8frjCK.js} +1 -1
- package/src/ui/static/assets/{useTestLifecycle-CL7-zz0Q.js → useTestLifecycle-OcwQaB1s.js} +1 -1
- package/src/ui/static/assets/{useTestManagement-ZTA1_VUm.js → useTestManagement-Xm4Bcx3u.js} +2 -2
- package/src/ui/static/assets/useTestResults-D5EwGIX9.js +1 -0
- package/src/ui/static/assets/{vendor-icons-B0wLOBoh.js → vendor-icons-BKPiFyYV.js} +1 -1
- package/src/ui/static/index.html +3 -3
- package/dist/py-agent/__pycache__/testver_appium.cpython-313.pyc +0 -0
- package/src/ui/static/assets/AdvancedPage-DB-6sJ6s.js +0 -3
- package/src/ui/static/assets/Dashboard-DRWbVyTb.js +0 -1
- package/src/ui/static/assets/PipelinesPanel-CMMXCSda.js +0 -1
- package/src/ui/static/assets/ReportCard-BbNfk85h.js +0 -2
- package/src/ui/static/assets/ReportFullView-Cg1rggho.js +0 -1
- package/src/ui/static/assets/ReportsPage-CFv3OAhe.js +0 -48
- package/src/ui/static/assets/ResultsPage-B4LwZH-R.js +0 -115
- package/src/ui/static/assets/SharedReportView-BAbW1WOs.js +0 -1
- package/src/ui/static/assets/TestExplorerPage-BRRWtwde.js +0 -7
- package/src/ui/static/assets/TestPlansPage-Bno2vpGd.js +0 -5
- package/src/ui/static/assets/index-B0klHYbO.css +0 -1
- package/src/ui/static/assets/index-DtBWNlVD.js +0 -47
- package/src/ui/static/assets/useTestResults-Bm-JyMhB.js +0 -1
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import{u as ss,r as p,j as e,b as qs,e as Fr}from"./vendor-react-CTbHBddL.js";import{f as it,a as rs}from"./formatDate-T65-Y6Mi.js";import{p as _t,s as Dt}from"./ansiToHtml-DYRzYQV1.js";import{e as as,f as Er,g as Mr,h as Lr,i as Pr,d as Hr,j as Br}from"./useTestResults-Bm-JyMhB.js";import{a as ys,c as Or,b as Ur,u as _r}from"./useTabParam-ChbOedP1.js";import{b as Ws,bR as ns,bY as Dr,bZ as Ks,b_ as Ys,b$ as Vr,j as kt,a8 as Xs,c0 as Qs,c1 as Zs,c2 as Gr,e as qr,c3 as Wr,c4 as Js,c5 as Vt,bN as er,c6 as tr,c7 as Kr,c8 as Yr,c9 as Xr,ca as Qr,cb as js,cc as vs,v as Zr}from"./index-DtBWNlVD.js";import{C as sr}from"./ConfirmDialog-DNU3qoAP.js";import{u as Ve,a as Ft,c as rr}from"./vendor-query-BrzmPFT3.js";import{h as Ct}from"./aiHandoff-vhtR29Fh.js";import{a3 as me,S as de,cn as Jr,co as ws,cp as ea,v as ls,R as ar,h as ta,t as De,ak as Se,bK as sa,_ as ve,r as st,a2 as ze,b3 as Xe,J as rt,cd as ra,m as nr,A as lr,l as aa,k as $t,ar as is,f as na,ax as la,ci as Gt,X as dt,aY as ia,aZ as oa,cq as ca,aG as os,aW as da,o as Ue,aX as xa,a7 as at,ay as xt,u as Qe,cr as ua,K as ma,a9 as Et,c as cs,q as ir,T as pa,a0 as tt,g as pt,al as Ye,y as Oe,a as ot,a$ as qt,e as St,O as or,c2 as ha,b4 as Wt,bh as ga,b5 as fa,cs as ba,by as cr,C as zt,b7 as ds,G as Kt,bA as Yt,b as ya,a1 as xs,c8 as ja,c9 as va,ct as wa,cu as dr,cv as Na,ce as Xt,cw as xr,cx as ka,cy as Ca,a4 as Ns,bP as $a,an as Sa,cz as za,cA as Aa}from"./vendor-icons-B0wLOBoh.js";import{B as us,a as Ke}from"./RunTargets-C7Vqd4TU.js";import{t as Ta,f as Ee}from"./formatTestName-BKd2Uqhs.js";import{b as Ia}from"./useSuites-CvtMGakZ.js";import{L as ur}from"./LiveExecutionView-BD0wE8sz.js";import{d as Ra}from"./useTestExplorer-HqvURJAc.js";import{u as ms}from"./useOwnership-eW6Egd7X.js";import{M as mr}from"./MediaModal-DiSINwmh.js";import{w as Fa,o as Mt}from"./excel-BrxuVus5.js";import{E as Ea}from"./EmptyState-BH_aDO0P.js";const Qt={bug:"Application Bug",environment:"Environment Issue",flaky:"Flaky Test","test-issue":"Test Code Issue",timeout:"Timeout",unknown:"Needs Investigation"},pr={"locator-not-found":"locator not found","strict-mode-violation":"strict mode violation","element-interaction":"element not interactable"},mt={"test-code":"test code",application:"application",environment:"environment",unclear:"unclear"};function hr(t){return t==="bug"?"application":t==="test-issue"?"test-code":t==="environment"?"environment":"unclear"}function Zt(t){var a;const s=(a=t.assessment)==null?void 0:a.layer;if(!s||s==="unclear")return!1;const r=hr(t.category);return r!=="unclear"&&r!==s}function jt(t){var s;return((s=t.later)==null?void 0:s.status)!=="passed"}function ct(t,s=!1){const r=(t||"").toLowerCase();return s||r.includes("appium")?"mobile":r.includes("rest")||r.includes("supertest")||r.includes("karate")||r==="api"?"api":"web"}function gr(t,s){var b;const r=(t||"").toLowerCase(),a=[...new Set(s.map(g=>g.file).filter(g=>!!g))],l=s.map(g=>vt(g.name)).filter(Boolean),i=l.map(Ma).join("|"),d=a.join(" ");if(r.includes("playwright")){const g=l.map(N=>[...N].map(k=>'"$`\\%!'.includes(k)?".":".*+?^{}()|[]".includes(k)?`\\${k}`:k).join("")).join("|");return`npx playwright test${a.map(N=>` "${N}"`).join("")}${g?` -g "${g}"`:""}`}if(r.includes("cypress"))return`npx cypress run${a.length?` --spec "${a.join(",")}"`:""}`;const n=(b=/webdriverio|wdio|pytest|unittest|testng|junit|maven|gradle|selenium|nunit|xunit|mstest|dotnet|rspec|behave|cucumber|robot|appium/.exec(r))==null?void 0:b[0];if(n){const g=s.filter(k=>vt(k.name));return g.length>0?g.map(k=>`run_tests test_name "${vt(k.name).replace(/"/g,'\\"')}"${k.file?` test_file "${k.file}"`:""}`).join("; then "):`run_tests framework "${n==="wdio"?"webdriverio":n}"${a.length?` files "${d}"`:""}`}return r.includes("jest")||r.includes("vitest")?`npx ${r.includes("vitest")?"vitest run":"jest"} ${d}${i?` -t "${i}"`:""}`.trim():r.includes("mocha")?`npx mocha ${d}${i?` --grep "${i}"`:""}`.trim():`run only: ${l.join("; ")||a.join(", ")||"the affected tests"} (scoped by file and name, never the whole suite)`}function vt(t){const s=t.split(/\s+[›>]\s+/);return(s[s.length-1]||t).trim()}function Ma(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/"/g,'\\"')}function fr(t){var a;if(!t)return[];const s=(a=t.files)!=null&&a.length?` in ${t.files.join(", ")}`:"",r=t.from&&t.to?`${t.from} → ${t.to}${s}`:"";switch(t.state){case"suggested":return[`Auto-Heal has a VERIFIED fix waiting: ${r}. If it is right, apply it from Results › Auto-Heal instead of writing a new edit; only change something else if that fix is wrong.`];case"healed":return[`Auto-Heal already changed ${r} and verified it — check whether the test passes now before editing anything.`];case"reverted":return[`Auto-Heal already tried ${r} and it failed verification${t.revertReason?` (${t.revertReason})`:""}. Do not repeat that exact change.`];case"undone":return[`The user undid Auto-Heal's change ${r}. Do not re-apply it.`];default:return t.skipReason?[`Auto-Heal did not heal this automatically: ${t.skipReason}`]:[]}}function br(t){const{group:s,kind:r}=t,a=Qt[s.category]||s.category,l=s.signal?` — ${pr[s.signal]||s.signal}`:"",i=t.tests.filter(jt),d=t.tests.length-i.length,n=i.length?i:t.tests,b=t.runLabel?`run #${t.runId} (${t.runLabel})`:`run #${t.runId}`,g=[];g.push(r==="investigate"?`Investigate the failing tests from ${b} (Failure Analysis, group ${t.groupIndex+1} of ${t.groupCount}). The rule-based classifier and the AI read this failure differently — start by deciding which is right, then fix or report accordingly.`:`Fix the failing tests from ${b} (Failure Analysis, group ${t.groupIndex+1} of ${t.groupCount}).`),g.push(""),g.push(`Classification: ${a}${l}.`),s.assessment&&(g.push(`AI assessment: ${mt[s.assessment.layer]}, ${s.assessment.confidence} confidence${s.assessment.pointer?` — ${s.assessment.pointer}`:""}.`),g.push(`AI summary: ${s.assessment.summary}`)),g.push(`Root cause (rule-based): ${s.rootCause}`);const N=fr(t.autoHeal);N.length&&g.push(...N),g.push("");const k=i.length&&d>0?`Still failing (${i.length} of ${t.tests.length} — the other ${d} passed in a later run):`:i.length?`Failing tests (${i.length}):`:`Affected tests (${t.tests.length} — all passed in a later run; confirm the fix is real, do not redo it):`;g.push(k);for(const T of n)g.push(` - ${T.file?`${T.file} › `:""}${vt(T.name)}`);if(g.push(""),t.errorMessage){g.push("Error:");for(const T of t.errorMessage.trim().split(`
|
|
2
|
-
`).slice(0,25))g.push(` ${T.trim()}`);g.push("")}if(t.stackTrace){g.push("Stack:");for(const T of t.stackTrace.trim().split(`
|
|
3
|
-
`).slice(0,12))g.push(` ${T.trim()}`);g.push("")}return g.push(`Verify with: ${gr(t.framework,n)}`),g.push("Run only these tests, never the whole suite. After the fix passes, say which files changed and why."),g.join(`
|
|
4
|
-
`)}function yr(t){const s=[];return s.push(`Fix the failing test ${t.testFile?`${t.testFile} › `:""}${t.testName} from run #${t.runId}. Its locator no longer matches the page.`),s.push(""),s.push(...fr({state:t.state,from:t.from,to:t.to,files:t.files,revertReason:t.revertReason})),s.push(""),s.push("Find the element the test means on the current page, repair the locator where it is defined (the page object if it lives there), and change nothing else."),s.push(`Verify with: ${gr(t.framework,[{name:t.testName,file:t.testFile}])}`),s.push("Run only this test, never the whole suite."),s.join(`
|
|
5
|
-
`)}const Pe={healed:"Healed",suggested:"Fix ready",reverted:"Reverted",undone:"Undone"},ps={healed:"Locator repaired, verified by re-running the affected tests, and kept.",suggested:"A verified fix is ready — review it and click Apply fix to put it in your code.",reverted:"A fix was tried but the verification re-run failed, so the code was put back.",undone:"The fix was undone — the original locator is back, and this exact change will not be proposed again."},jr="Fix ready — partially verified",hs="The fix got the test past the broken locator; the test then failed on something else. Review before applying — it was never kept unattended.",At={healed:"bg-emerald-500/10 border-emerald-500/30 text-emerald-600 dark:text-emerald-300",suggested:"bg-purple-500/10 border-purple-500/30 text-purple-600 dark:text-purple-300",reverted:"bg-amber-500/10 border-amber-500/30 text-amber-600 dark:text-amber-300",undone:"bg-white/5 border-white/10 text-gray-500 dark:text-gray-400"},vr={"recorded-fallback":"Recorded fallback","snapshot-match":"Snapshot match","trace-match":"Page DOM match","session-capture":"Live session","live-probe":"Live probe","ai-snapshot":"AI"},La={"recorded-fallback":"Recorder's next-best locator (no AI used)","snapshot-match":"Accessibility snapshot at failure (no AI used)","trace-match":"Page DOM from the run (no AI used)","session-capture":"The test's own browser / app session (no AI used)","live-probe":"Live probe of the page","ai-snapshot":"AI, from the page captured at failure"};function wt(t,s=!1){return(s?La:vr)[t]??t}function Nt(t){return typeof t=="number"?`${Math.round(t*100)}%`:"—"}function wr(t,s){if(!t||!s)return!1;const r=Date.parse(t);return Number.isFinite(r)&&Date.now()-r>s*864e5}const Nr=Object.fromEntries(Object.keys(Pe).map(t=>[t,{label:Pe[t],cls:At[t]}])),ks="bg-white/5 border-white/10 text-gray-500 dark:text-gray-400";function Pa(t){return t.state==="suggested"&&!t.actionable?{label:t.staleReason==="expired"?"Expired":"Stale",cls:ks}:Nr[t.state]??{label:t.state,cls:ks}}function Ha(t){const s=t.files.length===1?t.files[0].split(/[\\/]/).pop():`${t.files.length} files`,r=t.groupSize>1?` It was healing ${t.groupSize} tests together, so all of them revert.`:"";return`${t.to} goes back to ${t.from} in ${s} — the locator that was failing, so those tests will most likely fail again.${r} The record becomes "Undone", no Apply button returns for it, and Auto-Heal will never propose this exact change again. Your version control is the way back if you change your mind.`}function Cs(t){return t.actionable||t.state!=="suggested"&&t.state!=="healed"?null:t.state==="suggested"?t.staleReason==="expired"?"The review window has passed — a fresh fix will be suggested from current page evidence the next time this test fails.":"The code has changed since this fix was prepared — the recorded edit no longer matches the files. A fresh fix will be suggested if the test fails again.":t.staleReason==="expired"?"The review window has passed — to revert this change now, use your version control.":"The file has changed since this fix was kept — undo from here is no longer possible; use your version control."}const qe=10;function Ba(t,s){switch(s){case"all":return!0;case"suggested":return t.state==="suggested"&&t.actionable;case"expired":return t.state==="suggested"&&!t.actionable&&t.staleReason==="expired";case"stale":return t.state==="suggested"&&!t.actionable&&t.staleReason==="code-changed";default:return t.state===s}}const ht=t=>`${t.runId}|${t.testName}|${t.at}`,$s=t=>`/results?runId=${encodeURIComponent(t)}`,Ss=t=>t.testFile?`/tests?file=${encodeURIComponent(t.testFile)}&test=${encodeURIComponent(t.testName)}`:`/results?runId=${encodeURIComponent(t.runId)}&testId=${encodeURIComponent(t.testName)}`;function zs(t){const s=new Date(t),r=new Date,a=Math.floor((r.getTime()-s.getTime())/6e4),l=s.toDateString()===r.toDateString(),i=new Date(r);if(i.setDate(r.getDate()-1),l){if(a<1)return"just now";if(a<60)return`${a} min${a===1?"":"s"} ago`;const d=Math.floor(a/60);return`${d} hr${d===1?"":"s"} ago`}return s.toDateString()===i.toDateString()?"Yesterday":rs(t)}const As="hover:bg-black/[0.03] dark:hover:bg-white/[0.04]";function Oa(){const{toast:t}=Ws(),s=ss(),[r,a]=p.useState(null),[l,i]=p.useState(null),{data:d}=Ve({queryKey:["auto-heal-config"],queryFn:ns,staleTime:6e4}),[n,b]=p.useState(null),[g,N]=p.useState("all"),[k,T]=p.useState("all"),[f,v]=p.useState(""),[A,E]=p.useState(null),[P,U]=p.useState(null),[q,x]=p.useState(0),[I,_]=p.useState(0),[H,Y]=p.useState(0),[Z,G]=p.useState(null),re=p.useCallback(()=>{i(null),Dr(200).then(o=>{a(o.entries),b(o.stats),Y(o.total)}).catch(o=>{i(o instanceof Error?o.message:String(o)),a([]),b(null),Y(0)})},[]);p.useEffect(()=>{re()},[re]);const pe=p.useMemo(()=>(r??[]).filter(o=>o.state==="suggested"&&o.actionable),[r]),ge=p.useMemo(()=>{let o=r??[];g!=="all"&&(o=o.filter(O=>Ba(O,g))),k!=="all"&&(o=o.filter(O=>O.source===k));const $=f.trim().toLowerCase();return $&&(o=o.filter(O=>O.testName.toLowerCase().includes($)||O.from.toLowerCase().includes($)||O.to.toLowerCase().includes($)||O.files.some(le=>le.toLowerCase().includes($)))),o},[r,g,k,f]);p.useEffect(()=>{_(0)},[g,k,f]);const C=p.useMemo(()=>{const o=new Map;for(const $ of r??[]){const O=o.get($.testName);o.set($.testName,{n:((O==null?void 0:O.n)??0)+1,runId:(O==null?void 0:O.runId)??$.runId,testFile:(O==null?void 0:O.testFile)??$.testFile})}return[...o.entries()].filter(([,$])=>$.n>=2).sort(($,O)=>O[1].n-$[1].n).slice(0,5)},[r]),R=async(o,$)=>{var le;const O=ht(o);E(O);try{if($==="apply"){const oe=await Ks(o.runId,o.testName);t("info",`Fix applied to ${oe.files.length} file(s)`)}else{const oe=await Ys(o.runId,o.testName);t("info",`Fix undone in ${oe.files.length} file(s)${(le=oe.warnings)!=null&&le.length?` — ${oe.warnings[0]}`:""}`)}U(null),re()}catch(oe){t("error",`${$==="apply"?"Apply":"Undo"} failed: ${oe instanceof Error?oe.message:String(oe)}`)}finally{E(null)}},h=(o,$)=>{var oe;const O=ht(o),le=A===O;return e.jsxs("tr",{className:"border-t border-white/5 bg-surface-2/40",children:[e.jsx("td",{className:"w-8"}),e.jsx("td",{colSpan:$-1,className:"px-4 py-4",children:e.jsxs("div",{className:"space-y-3 max-w-3xl",children:[o.partialNote&&o.state==="suggested"&&e.jsxs("p",{className:"text-sm text-amber-600 dark:text-amber-300 leading-relaxed",children:[jr,": ",o.partialNote]}),o.state==="suggested"&&!o.partialNote&&e.jsx("p",{className:"text-sm text-gray-500 leading-relaxed",children:"Testver tried this locator and the affected tests passed, then put your code back. Nothing in your project has changed yet — Apply writes the change below into your code."}),o.state==="healed"&&e.jsx("p",{className:"text-sm text-gray-500 leading-relaxed",children:"This fix was verified and kept — the change below is in your code. Undo restores the original locator."}),o.state==="reverted"&&o.revertReason&&e.jsxs("p",{className:"text-sm text-amber-600 dark:text-amber-300 leading-relaxed",children:[o.revertReason," — your files are back to how they were."]}),o.rationale&&e.jsx("p",{className:"text-sm text-gray-500 leading-relaxed",children:o.rationale}),Cs(o)&&e.jsx("p",{className:"text-sm text-amber-600 dark:text-amber-300 leading-relaxed",children:Cs(o)}),(oe=o.codeLines)!=null&&oe.length?e.jsx("div",{className:"rounded-lg border border-white/10 overflow-hidden font-mono text-xs",children:o.codeLines.map((fe,ke)=>e.jsxs("div",{children:[(ke===0||o.codeLines[ke-1].file!==fe.file)&&e.jsx("div",{className:"px-3 py-1.5 text-[11px] text-gray-400 bg-surface-2/60 border-b border-white/10",children:fe.file}),e.jsxs("div",{className:"px-3 py-1.5 bg-red-500/10 text-red-600 dark:text-red-300 overflow-x-auto whitespace-pre",children:["− ",fe.before]}),e.jsxs("div",{className:"px-3 py-1.5 bg-emerald-500/10 text-emerald-600 dark:text-emerald-300 overflow-x-auto whitespace-pre",children:["+ ",fe.after]})]},`${fe.file}-${ke}`))}):e.jsxs("div",{className:"rounded-lg border border-white/10 overflow-hidden font-mono text-xs",children:[o.files.map(fe=>e.jsx("div",{className:"px-3 py-1.5 text-[11px] text-gray-400 bg-surface-2/60 border-b border-white/10",children:fe},fe)),e.jsxs("div",{className:"px-3 py-1.5 bg-red-500/10 text-red-600 dark:text-red-300 overflow-x-auto whitespace-pre",children:["− ",o.from]}),e.jsxs("div",{className:"px-3 py-1.5 bg-emerald-500/10 text-emerald-600 dark:text-emerald-300 overflow-x-auto whitespace-pre",children:["+ ",o.to]})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-5 gap-y-1 text-xs text-gray-500",children:[e.jsxs("span",{children:[e.jsx("b",{className:"text-gray-400 font-semibold",children:"Source"})," ",wt(o.source,!0)]}),e.jsxs("span",{children:[e.jsx("b",{className:"text-gray-400 font-semibold",children:"Confidence"})," ",Nt(o.confidence)]}),e.jsxs("span",{children:[e.jsx("b",{className:"text-gray-400 font-semibold",children:"When"})," ",it(o.at)]}),o.groupSize>1&&e.jsxs("span",{children:[e.jsx("b",{className:"text-gray-400 font-semibold",children:"Group"})," healed ",o.groupSize," tests together"]}),o.chain&&o.chain>1&&e.jsxs("span",{children:[e.jsx("b",{className:"text-gray-400 font-semibold",children:"Locators"})," ",o.chain," repaired together in this test"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-1",children:[o.state==="suggested"&&o.actionable&&e.jsxs("button",{onClick:()=>R(o,"apply"),disabled:le,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-purple-500/15 text-purple-600 dark:text-purple-300 border border-purple-500/30 hover:bg-purple-500/25 transition-colors disabled:opacity-40",children:[le?e.jsx(me,{size:12,className:"animate-spin"}):e.jsx(Se,{size:12}),"Apply fix"]}),o.state==="healed"&&o.actionable&&e.jsxs("button",{onClick:()=>G(o),disabled:le,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium text-red-500 dark:text-red-400 border border-red-500/30 hover:bg-red-500/10 transition-colors disabled:opacity-40",children:[le?e.jsx(me,{size:12,className:"animate-spin"}):e.jsx(sa,{size:12}),"Undo this fix"]}),(o.state==="reverted"||o.state==="undone")&&e.jsxs("button",{onClick:()=>Ct(s,{prompt:yr({...o}),mode:ct(void 0),attachedTest:o.testFile?{name:o.testName,file:o.testFile}:void 0}),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-brand-600 text-white hover:bg-brand-500 transition-colors",children:[e.jsx(ws,{size:12}),"Fix in AI Assistant"]}),e.jsxs("a",{href:Ss(o),target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium text-gray-400 border border-white/10 hover:text-gray-200 hover:border-white/25 transition-colors",children:[e.jsx(ve,{size:12}),"Open test"]}),e.jsxs("a",{href:$s(o.runId),target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium text-gray-400 border border-white/10 hover:text-gray-200 hover:border-white/25 transition-colors",children:[e.jsx(ve,{size:12}),"Open run"]}),o.verifyRunId&&e.jsxs("a",{href:$s(o.verifyRunId),target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium text-gray-400 border border-white/10 hover:text-gray-200 hover:border-white/25 transition-colors",children:[e.jsx(ve,{size:12}),"Open verification run"]})]})]})})]})},w=(o,$,O)=>{if(O<=qe)return null;const le=Math.ceil(O/qe);return e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-t border-white/5 text-xs text-gray-500",children:[e.jsxs("span",{children:["Showing ",o*qe+1,"–",Math.min((o+1)*qe,O)," of ",O]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>$(Math.max(0,o-1)),disabled:o===0,className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"‹ Prev"}),e.jsxs("span",{className:"px-2",children:["Page ",e.jsx("span",{className:"text-gray-300 font-medium",children:o+1})," of ",le]}),e.jsx("button",{onClick:()=>$(Math.min(le-1,o+1)),disabled:o>=le-1,className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"Next ›"})]})]})},L=o=>e.jsx(De,{size:14,className:`text-gray-500 transition-transform ${P===o?"rotate-90":""}`}),D=o=>U($=>$===o?null:o),ee=o=>({onClick:()=>D(o),onKeyDown:$=>{($.key==="Enter"||$.key===" ")&&($.preventDefault(),D(o))},tabIndex:0,role:"button","aria-expanded":P===o});if(r===null)return e.jsxs("div",{className:"flex-1 flex items-center justify-center text-gray-500",children:[e.jsx(me,{size:18,className:"animate-spin mr-2"})," Loading Auto-Heal activity…"]});const V=H||r.length,ne=pe.slice(q*qe,(q+1)*qe),je=ge.slice(I*qe,(I+1)*qe);return e.jsxs("div",{className:"flex-1 overflow-y-auto bg-surface-0",children:[e.jsxs("div",{className:"max-w-[1400px] mx-auto w-full px-6 py-6 space-y-8",children:[l&&e.jsxs("div",{className:"rounded-xl border border-red-500/30 bg-red-500/5 px-4 py-3 text-sm text-red-600 dark:text-red-300 flex items-center justify-between gap-3",role:"alert",children:[e.jsxs("span",{children:["Could not load Auto-Heal activity: ",l]}),e.jsx("button",{onClick:re,className:"px-3 py-1 rounded-lg border border-red-500/30 hover:bg-red-500/10 text-xs font-medium",children:"Retry"})]}),r.length===0&&!l&&e.jsxs("div",{className:"py-16 text-center rounded-xl border border-dashed border-white/10",children:[e.jsx(de,{size:32,className:"mx-auto text-gray-600 mb-3"}),e.jsx("p",{className:"text-base font-medium text-gray-300 mb-1",children:"No Auto-Heal activity yet"}),e.jsx("p",{className:"text-sm text-gray-500 max-w-md mx-auto mb-2",children:"When Auto-Heal repairs a broken locator after a failed run, every fix — healed, ready to apply, or reverted — shows up here for review."}),d&&e.jsxs("p",{className:"text-sm text-gray-500 mb-4",children:["Auto-Heal is currently ",e.jsx("b",{className:"text-gray-300",children:d.mode==="off"?"Off":d.mode==="suggest"?"Suggest":"Auto"}),d.mode==="off"?" — turn it on to start repairing broken locators.":"."]}),e.jsx("button",{onClick:()=>s("/settings"),className:"px-4 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:"Configure Auto-Heal →"})]}),r.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2 mb-3",children:[e.jsx(Jr,{size:17,className:"text-purple-600 dark:text-purple-300"})," Overview"]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:[e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:"Total Repairs"}),e.jsx("div",{className:"text-xl font-semibold text-gray-100 mt-0.5",children:V})]}),e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:Pe.healed}),e.jsx("div",{className:"text-xl font-semibold text-emerald-600 dark:text-emerald-400 mt-0.5",children:(n==null?void 0:n.kept)??0})]}),e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:"Fix Ready"}),e.jsx("div",{className:"text-xl font-semibold text-purple-600 dark:text-purple-300 mt-0.5",children:(n==null?void 0:n.suggested)??0})]}),e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:"Reverted"}),e.jsx("div",{className:"text-xl font-semibold text-amber-600 dark:text-amber-400 mt-0.5",children:(n==null?void 0:n.reverted)??0})]}),e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:"Undone"}),e.jsx("div",{className:"text-xl font-semibold text-gray-100 mt-0.5",children:(n==null?void 0:n.undone)??0})]}),e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",title:"Repairs solved by deterministic page-evidence matching alone — no AI call spent",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:"Without AI"}),e.jsx("div",{className:"text-xl font-semibold text-gray-100 mt-0.5",children:V>0?`${Math.round(((n==null?void 0:n.noAi)??0)/V*100)}%`:"—"})]})]})]}),pe.length>0&&e.jsxs("section",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2 mb-1",children:[e.jsx(ws,{size:17,className:"text-purple-600 dark:text-purple-300"}),"Fixes ready for review"]}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"Each fix was verified by re-running the affected tests. Click a row to review the change and apply it."}),e.jsxs("div",{className:"rounded-xl border border-white/5 overflow-hidden bg-surface-1",children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs text-gray-500 uppercase tracking-wide border-b border-white/5",children:[e.jsx("th",{className:"px-4 py-2.5 w-8"}),e.jsx("th",{className:"px-4 py-2.5",children:"Test"}),e.jsx("th",{className:"px-4 py-2.5",children:"File"}),e.jsx("th",{className:"px-4 py-2.5",children:"Source"}),e.jsx("th",{className:"px-4 py-2.5",children:"Confidence"}),e.jsx("th",{className:"px-4 py-2.5",children:"When"})]})}),e.jsx("tbody",{children:ne.map(o=>{var O;const $=ht(o);return e.jsxs(Ts,{children:[e.jsxs("tr",{...ee($),className:`border-t border-white/5 cursor-pointer ${As} transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-purple-400/60`,children:[e.jsx("td",{className:"px-4 py-2.5",children:L($)}),e.jsxs("td",{className:"px-4 py-2.5 max-w-[300px]",children:[e.jsx("span",{className:"text-gray-200 truncate block",children:o.testName}),o.groupSize>1&&e.jsxs("span",{className:"block text-xs text-gray-500",children:["+",o.groupSize-1," more test(s) healed by the same change"]})]}),e.jsx("td",{className:"px-4 py-2.5 max-w-[180px]",children:e.jsxs("code",{className:"text-xs text-gray-500 truncate block",title:o.files.join(`
|
|
6
|
-
`),children:[((O=o.files[0])==null?void 0:O.split(/[\\/]/).pop())||"—",o.files.length>1&&e.jsxs("span",{children:[" +",o.files.length-1]})]})}),e.jsx("td",{className:"px-4 py-2.5 text-gray-400 whitespace-nowrap text-sm",children:wt(o.source)}),e.jsx("td",{className:"px-4 py-2.5 text-gray-400 text-sm",children:Nt(o.confidence)}),e.jsx("td",{className:"px-4 py-2.5 text-gray-400 whitespace-nowrap text-sm",title:it(o.at),children:zs(o.at)})]}),P===$&&h(o,6)]},$)})})]}),w(q,x,pe.length)]})]}),C.length>0&&e.jsxs("section",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2 mb-1",children:[e.jsx(ea,{size:17,className:"text-amber-600 dark:text-amber-400"})," Locator hotspots"]}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"Tests whose locators broke again and again — their locator strategy may need a human look."}),e.jsx("div",{className:"rounded-xl bg-surface-1 border border-white/5 px-4 py-3 flex flex-wrap gap-2",children:C.map(([o,$])=>e.jsxs("a",{href:Ss({testFile:$.testFile,testName:o,runId:$.runId}),target:"_blank",rel:"noopener noreferrer",title:"Open this test in a new tab",className:"inline-flex items-center gap-1.5 text-xs px-2.5 py-1 rounded-full border bg-amber-500/10 border-amber-500/30 text-amber-600 dark:text-amber-300 hover:bg-amber-500/20 transition-colors",children:[o," ",e.jsxs("span",{className:"opacity-70",children:["×",$.n]})]},o))})]}),e.jsxs("section",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2 mb-3",children:[e.jsx(de,{size:17,className:"text-purple-600 dark:text-purple-300"})," Activity"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-3",children:[["all","healed","suggested","reverted","undone","expired","stale"].map(o=>{var $;return e.jsx("button",{onClick:()=>N(o),"aria-pressed":g===o,className:`inline-flex items-center text-xs px-2.5 py-1 rounded-full border transition-colors ${g===o?"bg-purple-500/10 border-purple-500/30 text-purple-600 dark:text-purple-300":"bg-surface-1 border-white/10 text-gray-400 hover:text-gray-200"}`,children:o==="all"?"All":o==="expired"?"Expired":o==="stale"?"Stale":(($=Nr[o])==null?void 0:$.label)??o},o)}),e.jsxs("select",{"aria-label":"Filter by source",value:k,onChange:o=>T(o.target.value),className:"bg-surface-1 border border-white/10 rounded-lg px-2.5 py-1 text-xs text-gray-300 focus:outline-none focus:border-brand-500/40",children:[e.jsx("option",{value:"all",children:"All sources"}),Object.entries(vr).map(([o,$])=>e.jsx("option",{value:o,children:$},o))]}),e.jsxs("div",{className:"relative ml-auto",children:[e.jsx(ls,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:f,onChange:o=>v(o.target.value),placeholder:"Search test, locator, file…","aria-label":"Search Auto-Heal activity",className:"pl-8 pr-3 py-1.5 w-64 bg-surface-1 border border-white/10 rounded-lg text-xs text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/40"})]}),e.jsx("button",{onClick:re,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors",title:"Refresh",children:e.jsx(ar,{size:14})})]}),e.jsxs("div",{className:"rounded-xl border border-white/5 overflow-hidden bg-surface-1",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs text-gray-500 uppercase tracking-wide border-b border-white/5",children:[e.jsx("th",{className:"px-4 py-2.5 w-8"}),e.jsx("th",{className:"px-4 py-2.5",children:"When"}),e.jsx("th",{className:"px-4 py-2.5",children:"Test"}),e.jsx("th",{className:"px-4 py-2.5",children:"File"}),e.jsx("th",{className:"px-4 py-2.5",children:"Source"}),e.jsx("th",{className:"px-4 py-2.5",children:"Conf."}),e.jsx("th",{className:"px-4 py-2.5",children:"Result"})]})}),e.jsxs("tbody",{children:[je.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-6 text-center text-sm text-gray-500",children:"Nothing matches the current filters."})}),je.map(o=>{var le;const $=ht(o),O=Pa(o);return e.jsxs(Ts,{children:[e.jsxs("tr",{...ee($),className:`border-t border-white/5 cursor-pointer ${As} transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-purple-400/60`,children:[e.jsx("td",{className:"px-4 py-2.5",children:L($)}),e.jsx("td",{className:"px-4 py-2.5 text-gray-400 whitespace-nowrap text-sm",title:it(o.at),children:zs(o.at)}),e.jsxs("td",{className:"px-4 py-2.5 max-w-[280px]",children:[e.jsx("span",{className:"text-gray-200 truncate block",children:o.testName}),o.groupSize>1&&e.jsxs("span",{className:"block text-xs text-gray-500",children:["healed ",o.groupSize," tests together"]})]}),e.jsx("td",{className:"px-4 py-2.5 max-w-[180px]",children:e.jsxs("code",{className:"text-xs text-gray-500 truncate block",title:o.files.join(`
|
|
7
|
-
`),children:[((le=o.files[0])==null?void 0:le.split(/[\\/]/).pop())||"—",o.files.length>1&&e.jsxs("span",{children:[" +",o.files.length-1]})]})}),e.jsx("td",{className:"px-4 py-2.5 text-gray-400 whitespace-nowrap text-sm",children:wt(o.source)}),e.jsx("td",{className:"px-4 py-2.5 text-gray-400 text-sm",children:Nt(o.confidence)}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsx("span",{className:`inline-flex items-center text-xs px-2 py-0.5 rounded-full border ${O.cls}`,children:O.label})})]}),P===$&&h(o,7)]},$)})]})]})}),w(I,_,ge.length)]})]}),e.jsxs("p",{className:"text-xs text-gray-500 flex items-center gap-1.5",children:[e.jsx(ta,{size:12}),"Auto-Heal mode, attempts, CI gate, and probe are configured in"," ",e.jsx("button",{onClick:()=>s("/settings"),className:"text-purple-600 dark:text-purple-300 hover:underline transition-colors",children:"Settings → General"})]})]})]}),e.jsx(sr,{open:!!Z,size:"lg",title:"Undo this fix — this cannot be re-applied",description:Z?Ha(Z):"",confirmLabel:"Undo the fix",cancelLabel:"Keep the fix",onConfirm:()=>{const o=Z;G(null),o&&R(o,"undo")},onCancel:()=>G(null)})]})}function Ts({children:t}){return e.jsx(e.Fragment,{children:t})}function Ua(t,s,r,a=!1){return t==="suggested"&&wr(s,r)?{label:"Fix expired",cls:"bg-white/5 text-gray-400 border-white/10",title:"The review window has passed — a fresh fix will be suggested the next time this test fails."}:t==="suggested"&&a?{label:"Auto-Heal: Fix ready (partial)",cls:At[t],title:hs}:{label:`Auto-Heal: ${Pe[t]}`,cls:At[t],title:ps[t]}}const Is={passed:e.jsx($t,{size:14,className:"text-emerald-400"}),failed:e.jsx(ze,{size:14,className:"text-red-400"}),skipped:e.jsx(Xe,{size:14,className:"text-gray-500"}),error:e.jsx(aa,{size:14,className:"text-amber-400"})};function gt({label:t,icon:s,active:r,onClick:a,activeColor:l}){return e.jsxs("button",{onClick:a,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-sm font-medium border transition-colors ${r?l||"text-brand-300 bg-brand-500/15 border-brand-500/30":"text-gray-500 bg-transparent border-transparent hover:text-gray-300 hover:bg-white/5"}`,children:[s,t]})}function _a({tests:t,filter:s,onSelectTest:r,selectedTest:a,displayBrowser:l,displayDevice:i}){const{data:d}=Ve({queryKey:["auto-heal-config"],queryFn:ns,staleTime:6e4}),[n,b]=p.useState(""),[g,N]=p.useState("status"),[k,T]=p.useState("asc"),[f,v]=p.useState(s),A=x=>{g===x?T(I=>I==="asc"?"desc":"asc"):(N(x),T("asc"))},E=p.useMemo(()=>{const x=new Map;return t.forEach((I,_)=>{x.has(I)||x.set(I,_)}),x},[t]),P=p.useMemo(()=>{let x=t;if(f&&(x=x.filter(I=>f==="failed"?I.status==="failed"||I.status==="error":I.status===f)),n){const I=n.toLowerCase();x=x.filter(_=>{var H,Y;return Ta(_.name,n)||((H=_.suite)==null?void 0:H.toLowerCase().includes(I))||((Y=_.tags)==null?void 0:Y.some(Z=>Z.toLowerCase().includes(I)))})}return x=[...x].sort((I,_)=>{let H=0;if(g==="duration")H=(I.duration||0)-(_.duration||0);else if(g==="status"){const Y={failed:0,error:1,passed:2,skipped:3};H=(Y[I.status]??4)-(Y[_.status]??4)}else H=I.name.localeCompare(_.name);return k==="desc"?-H:H}),x},[t,n,f,g,k]),U=p.useMemo(()=>({all:t.length,passed:t.filter(x=>x.status==="passed").length,failed:t.filter(x=>x.status==="failed"||x.status==="error").length,skipped:t.filter(x=>x.status==="skipped").length}),[t]),q=({col:x})=>g!==x?e.jsx(ra,{size:10,className:"text-gray-700"}):k==="asc"?e.jsx(nr,{size:10,className:"text-brand-400"}):e.jsx(lr,{size:10,className:"text-brand-400"});return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-xs",children:[e.jsx(ls,{size:14,className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:n,onChange:x=>b(x.target.value),placeholder:"Search tests...",className:"w-full pl-10 pr-3.5 py-2 bg-surface-2 border border-white/10 rounded-xl text-sm text-gray-200 outline-none placeholder-gray-600 focus:border-brand-400/50"})]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(gt,{label:`All (${U.all})`,active:f===void 0,onClick:()=>v(void 0)}),e.jsx(gt,{label:`Passed (${U.passed})`,icon:e.jsx(st,{size:12}),active:f==="passed",onClick:()=>v("passed"),activeColor:"text-emerald-300 bg-emerald-500/15 border-emerald-500/30"}),e.jsx(gt,{label:`Failed (${U.failed})`,icon:e.jsx(ze,{size:12}),active:f==="failed",onClick:()=>v("failed"),activeColor:"text-red-300 bg-red-500/15 border-red-500/30"}),e.jsx(gt,{label:`Skipped (${U.skipped})`,icon:e.jsx(Xe,{size:12}),active:f==="skipped",onClick:()=>v("skipped"),activeColor:"text-gray-300 bg-gray-500/15 border-gray-500/30"})]})]}),e.jsx("div",{className:"rounded-xl border border-white/5 bg-surface-1 overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-surface-2/50 border-b border-white/5 text-xs text-gray-500 uppercase",children:[e.jsx("th",{className:"px-4 py-2.5 text-left w-10",children:"Status"}),e.jsx("th",{className:"px-4 py-2.5 text-left cursor-pointer hover:text-gray-300 transition-colors",onClick:()=>A("name"),children:e.jsxs("span",{className:"flex items-center gap-1.5",children:["Test Name ",e.jsx(q,{col:"name"})]})}),e.jsx("th",{className:"px-4 py-2.5 text-left",children:"Suite"}),e.jsx("th",{className:"px-4 py-2.5 text-left w-28",children:i?"Device":"Browser"}),e.jsx("th",{className:"px-4 py-2.5 text-left",children:"Tags"}),e.jsx("th",{className:"px-4 py-2.5 text-center w-16",children:"Retries"}),e.jsx("th",{className:"px-4 py-2.5 text-right cursor-pointer hover:text-gray-300 transition-colors w-28",onClick:()=>A("duration"),children:e.jsxs("span",{className:"flex items-center gap-1.5 justify-end",children:["Duration ",e.jsx(q,{col:"duration"})]})})]})}),e.jsxs("tbody",{children:[P.map((x,I)=>{var Z;const _=E.get(x)??-1,H=`${x.name}::${_>=0?_:I}`,Y=x.parameters?Object.entries(x.parameters):[];return e.jsxs("tr",{onClick:()=>r(a===H?null:H),className:`border-t border-white/5 cursor-pointer transition-colors hover:bg-white/[0.03] ${a===H?"ring-2 ring-brand-400 ring-inset":""}`,children:[e.jsx("td",{className:"px-4 py-3",children:Is[x.status]||Is.error}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 max-w-xl",children:[e.jsx("span",{className:"text-sm text-gray-200 truncate min-w-0",title:x.name,children:Ee(x.name)}),Y.length>0&&Y.map(([G,re])=>e.jsx("span",{className:"flex-shrink-0 whitespace-nowrap px-1.5 py-0.5 rounded text-[10px] font-medium bg-blue-500/15 text-blue-300 border border-blue-500/30",children:re},G)),(Z=x.annotations)==null?void 0:Z.map((G,re)=>e.jsxs("span",{className:"flex-shrink-0 whitespace-nowrap px-1.5 py-0 rounded text-[9px] font-medium bg-violet-500/20 text-violet-300",children:["@",G.type]},re)),x.autoHeal&&Pe[x.autoHeal.state]&&(()=>{const G=Ua(x.autoHeal.state,x.autoHeal.at,d==null?void 0:d.reviewWindowDays,!!x.autoHeal.partialNote);return e.jsx("span",{className:`flex-shrink-0 whitespace-nowrap px-1.5 py-0.5 rounded text-[10px] font-medium border ${G.cls}`,title:G.title,children:G.label})})(),!x.autoHeal&&x.autoHealSkip&&e.jsx("span",{className:"flex-shrink-0 whitespace-nowrap px-1.5 py-0.5 rounded text-[10px] font-medium border bg-white/5 text-gray-500 dark:text-gray-400 border-white/10 cursor-help",title:`Why not healed: ${x.autoHealSkip.reason} (open the test for details)`,"aria-label":`Not healed: ${x.autoHealSkip.reason}`,children:"Not healed"})]}),x.errorMessage&&e.jsx("p",{className:"text-xs text-red-400 truncate max-w-xl mt-0.5",title:x.errorMessage,children:x.errorMessage})]}),e.jsx("td",{className:"px-4 py-3 text-gray-500 text-xs truncate max-w-[150px]",children:x.suite||"—"}),e.jsx("td",{className:"px-4 py-3",children:i?e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-gray-300",title:i,children:[e.jsx(rt,{size:13,className:"text-indigo-400 flex-shrink-0"}),e.jsx("span",{className:"truncate max-w-[9rem]",children:i})]}):e.jsxs(e.Fragment,{children:[e.jsx(us,{browser:l||x.browser,size:14,showLabel:!0}),x.browserVersion&&e.jsx("span",{className:"block text-[10px] text-gray-400 mt-0.5",children:x.browserVersion})]})}),e.jsx("td",{className:"px-4 py-3",children:x.tags&&x.tags.length>0?e.jsxs("div",{className:"flex flex-wrap gap-1",children:[x.tags.slice(0,3).map(G=>e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] bg-white/5 text-gray-400 border border-white/10",children:G},G)),x.tags.length>3&&e.jsxs("span",{className:"text-[10px] text-gray-400",children:["+",x.tags.length-3]})]}):e.jsx("span",{className:"text-gray-400 text-xs",children:"—"})}),e.jsx("td",{className:"px-4 py-3 text-center",children:x.retryCount&&x.retryCount>0?e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-amber-500/20 text-amber-300",children:x.retryCount}):e.jsx("span",{className:"text-gray-400 text-xs",children:"—"})}),e.jsx("td",{className:"px-4 py-3 text-right text-gray-500 text-xs",children:x.duration!=null?`${(x.duration/1e3).toFixed(1)}s`:"—"})]},I)}),P.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-10 text-center text-gray-600 text-sm",children:t.length===0?"No test results available":"No tests match current filters"})})]})]})})]})}function Da(t){if(!t||t<0)return"";if(t<1e3)return`${t}ms`;const s=t/1e3;return s<60?`${s.toFixed(1)}s`:`${Math.floor(s/60)}m ${Math.round(s%60)}s`}function Va(t){t&&window.open(`/results?runId=${encodeURIComponent(t)}`,"_blank","noopener")}function Ga({status:t}){switch(t){case"passed":return e.jsx(st,{size:16,className:"text-emerald-400 flex-shrink-0"});case"failed":return e.jsx(ze,{size:16,className:"text-red-400 flex-shrink-0"});case"running":return e.jsx(me,{size:16,className:"text-amber-400 animate-spin flex-shrink-0"});case"cancelled":return e.jsx(la,{size:16,className:"text-gray-500 flex-shrink-0"});default:return e.jsx(na,{size:16,className:"text-gray-600 flex-shrink-0"})}}function kr({run:t}){const s=(t==null?void 0:t.results)??[],r=t==null?void 0:t.summary,a=s.filter(l=>!l.isHook&&l.status!=="pending"&&l.status!=="running").length;return e.jsxs("div",{className:"rounded-xl border border-white/5 bg-surface-1 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-white/5",children:[e.jsx(me,{size:15,className:"text-amber-400 animate-spin"}),e.jsx("span",{className:"text-sm font-medium text-gray-200",children:"Running…"}),r&&e.jsxs("span",{className:"flex items-center gap-2 text-xs",children:[e.jsxs("span",{className:"text-emerald-400",children:[r.passed," passed"]}),r.failed>0&&e.jsxs("span",{className:"text-red-400",children:[r.failed," failed"]}),e.jsxs("span",{className:"text-gray-500",children:["· ",a," of ",r.total," done"]})]}),e.jsx("span",{className:"ml-auto text-[11px] text-gray-600",children:"Live — updates automatically"})]}),s.length===0?e.jsx("div",{className:"px-4 py-10 text-center text-sm text-gray-600",children:"Preparing tests…"}):e.jsx("div",{children:s.map((l,i)=>{const d=l.file.split(/[/\\]/).pop()||l.file,n=l.attemptRuns&&l.attemptRuns.length>1?l.attemptRuns.length-1:0;return e.jsxs("div",{className:"border-b border-white/5 last:border-0",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 group hover:bg-surface-2/30",children:[e.jsx(Ga,{status:l.status}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:`text-sm truncate ${l.isHook?"text-brand-300 font-medium":"text-gray-200"}`,title:l.name,children:l.isHook?l.name:Ee(l.name)}),e.jsxs("div",{className:"text-[11px] text-gray-500 truncate",children:[l.isHook?"lifecycle hook":`${d} · ${l.framework}`,l.message?e.jsxs("span",{className:"text-red-400/80",children:[" · ",l.message]}):""]})]}),n>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded-full bg-amber-500/10 text-amber-300 border border-amber-500/30 flex-shrink-0",children:[e.jsx(is,{size:10})," ",n," ",n===1?"retry":"retries"]}),l.durationMs?e.jsx("span",{className:"text-[11px] text-gray-500 tabular-nums flex-shrink-0",children:Da(l.durationMs)}):l.status==="running"?e.jsx("span",{className:"text-[11px] text-amber-400 flex-shrink-0",children:"running…"}):l.status==="pending"?e.jsx("span",{className:"text-[11px] text-gray-600 flex-shrink-0",children:"queued"}):null,l.runId&&e.jsxs("button",{onClick:()=>Va(l.runId),title:"Open this test's run",className:"text-[11px] text-gray-500 hover:text-cyan-300 inline-flex items-center gap-1 flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:["View Result ",e.jsx(ve,{size:11})]})]}),l.status==="running"&&l.runId&&e.jsx(ur,{runId:l.runId,layout:"strip"})]},`${l.file}::${l.name}::${i}`)})})]})}function qa({suiteId:t}){const{data:s}=Ia(t,!0);return e.jsx(kr,{run:s==null?void 0:s.run})}function Wa({runId:t}){const{data:s}=Ve({queryKey:["cycle-run-status",t],queryFn:()=>Vr(t),enabled:!!t,refetchInterval:1500});return e.jsx(kr,{run:s==null?void 0:s.run})}const Ka=".logo,.product{display:none !important}.hbox.header,.workbench-loader-header{padding-left:148px !important;padding-right:52px !important}.workbench-loader-header{background-color:#000 !important;color:#ccc !important;height:48px !important;min-height:48px !important}.workbench-loader-header .title,.workbench-loader-header .toolbar-button{color:#ccc !important}";function Ya({url:t,onClose:s}){p.useEffect(()=>{const a=l=>{l.key==="Escape"&&s()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[s]);const r=a=>{try{const l=a.currentTarget.contentDocument;if(!l)return;const i=l.createElement("style");i.textContent=Ka,l.head.appendChild(i)}catch{}};return qs.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[100] bg-black animate-fade-in",children:[e.jsx("iframe",{src:t,title:"Trace Viewer",onLoad:r,className:"absolute inset-0 h-full w-full border-0 bg-white"}),e.jsxs("div",{className:"pointer-events-none absolute left-4 top-0 z-10 flex h-11 items-center gap-2 text-[13px] font-semibold text-white/90",children:[e.jsx(Gt,{size:15}),"Trace Viewer"]}),e.jsx("button",{onClick:s,title:"Close (Esc)",className:"absolute right-2 top-0 z-10 flex h-11 w-9 items-center justify-center rounded text-white hover:bg-white/20 transition-colors",style:{color:"#ffffff"},children:e.jsx(dt,{size:20,strokeWidth:2.75,color:"#ffffff"})})]}),document.body)}function Xa(t){return`/trace-viewer/index.html?trace=${encodeURIComponent(window.location.origin+t)}`}function Cr(t){return`[FAIL] ${t.name}`}function $r(t,s){const r=(t.steps||[]).filter(n=>n.status==="failed"),a=t.steps||[],l=n=>String(n??"").replace(/[&<>"]/g,b=>({"&":"&","<":"<",">":">",'"':"""})[b]);let i="<h3>Test Execution Steps:</h3>";a.length>0&&a.forEach((n,b)=>{const g=n.status==="failed"?"❌":n.status==="passed"?"✅":"⏭",N=n.status==="failed",k=`${n.keyword||""} ${n.name||""}`.trim()||"—";i+=`<h3>Step ${b+1} — ${g} ${l(n.status)}</h3>`,i+=`<p><strong>Action:</strong> ${l(k)}</p>`,(N||n.errorMessage)&&(i+=`<p><span style="color:#dc2626;"><strong>Error:</strong> ${l(n.errorMessage||"—")}</span></p>`)}),t.errorMessage&&(i+='<h3><span style="color:#dc2626;">Error Message:</span></h3>',i+=`<pre class="ql-syntax" spellcheck="false">${l(t.errorMessage)}</pre>`),t.stackTrace&&(i+="<h3>Stack Trace:</h3>",i+=`<pre class="ql-syntax" spellcheck="false">${l(t.stackTrace)}</pre>`);const d=t.duration?`${(t.duration/1e3).toFixed(1)}s`:"N/A";return{title:Cr(t),description:`Automation test "${t.name}" failed during execution.
|
|
8
|
-
|
|
9
|
-
Suite: ${t.suite||"N/A"}
|
|
10
|
-
File: ${t.file||"N/A"}
|
|
11
|
-
Browser: ${t.browser||"N/A"}
|
|
12
|
-
Duration: ${d}
|
|
13
|
-
Retries: ${t.retryCount??0}
|
|
14
|
-
|
|
15
|
-
Error: ${t.errorMessage||"N/A"}`,severity:"critical",priority:"high",environment:`${t.browser||"Unknown"} — Automation`,stepsToReproduce:i||t.errorMessage||"See automation results.",expectedResult:"Test should pass without errors",actualResult:t.errorMessage||r.map(n=>`${n.name}: ${n.errorMessage||"Failed"}`).join(`
|
|
16
|
-
`)||"Test failed",reporter:s,createdBy:s}}const ft=.1,Lt=8,bt=1.25,Rs=24;function Qa({path:t,url:s,testName:r,onClose:a}){const l=s||`/api/files/${encodeURIComponent(t||"")}`,i=p.useRef(null),[d,n]=p.useState(null),[b,g]=p.useState(null),[N,k]=p.useState(!0),[T,f]=p.useState(!1),[v,A]=p.useState(!1),E=p.useRef(null),P=()=>{var R;const C=(R=i.current)==null?void 0:R.getBoundingClientRect();return{w:(C==null?void 0:C.width)??0,h:(C==null?void 0:C.height)??0}},U=p.useCallback(C=>{if(!d)return C;const{w:R,h}=P(),w=d.w*C.scale,L=d.h*C.scale,D=w<=R?(R-w)/2:Math.min(0,Math.max(R-w,C.x)),ee=L<=h?(h-L)/2:Math.min(0,Math.max(h-L,C.y));return{scale:C.scale,x:D,y:ee}},[d]),q=p.useCallback(()=>{if(!d)return 1;const{w:C,h:R}=P();return Math.min((C-Rs*2)/d.w,(R-Rs*2)/d.h,1)},[d]),x=p.useCallback((C=!1)=>{f(C),k(!0),g(U({scale:Math.max(ft,q()),x:0,y:0}))},[U,q]),I=p.useCallback((C,R,h,w=!1)=>{g(L=>{if(!L)return L;const{w:D,h:ee}=P(),V=R??D/2,ne=h??ee/2,je=Math.min(Lt,Math.max(ft,C(L.scale))),o=(V-L.x)/L.scale,$=(ne-L.y)/L.scale;return U({scale:je,x:V-o*je,y:ne-$*je})}),f(w),k(!1)},[U]);p.useLayoutEffect(()=>{d&&x()},[d,x]),p.useEffect(()=>{const C=()=>{N?x():g(R=>R&&U(R))};return window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)},[N,x,U]),p.useEffect(()=>{const C=i.current;if(!C)return;const R=h=>{h.preventDefault();const w=C.getBoundingClientRect(),L=Math.exp(-h.deltaY*(h.ctrlKey?.01:.0015));g(D=>{if(!D)return D;const ee=Math.min(Lt,Math.max(ft,D.scale*L)),V=h.clientX-w.left,ne=h.clientY-w.top,je=(V-D.x)/D.scale,o=(ne-D.y)/D.scale;return U({scale:ee,x:V-je*ee,y:ne-o*ee})}),f(!1),k(!1)};return C.addEventListener("wheel",R,{passive:!1}),()=>C.removeEventListener("wheel",R)},[U]);const _=!!(d&&b&&(d.w*b.scale>P().w+.5||d.h*b.scale>P().h+.5)),H=(C,R)=>{f(!0),g(h=>h&&U({...h,x:h.x+C,y:h.y+R}))};p.useEffect(()=>{const C=R=>{if(b){if(R.key==="+"||R.key==="=")I(h=>h*bt,void 0,void 0,!0);else if(R.key==="-"||R.key==="_")I(h=>h/bt,void 0,void 0,!0);else if(R.key==="0")x(!0);else if(R.key==="1")I(()=>1,void 0,void 0,!0);else if(R.key==="ArrowLeft")H(80,0);else if(R.key==="ArrowRight")H(-80,0);else if(R.key==="ArrowUp")H(0,80);else if(R.key==="ArrowDown")H(0,-80);else return;R.preventDefault()}};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)});const Y=C=>{if(!(C.button!==0||!b||!_)){try{C.currentTarget.setPointerCapture(C.pointerId)}catch{}E.current={id:C.pointerId,px:C.clientX,py:C.clientY,x:b.x,y:b.y},A(!0),f(!1)}},Z=C=>{const R=E.current;!R||R.id!==C.pointerId||g(h=>h&&U({...h,x:R.x+(C.clientX-R.px),y:R.y+(C.clientY-R.py)}))},G=C=>{var R;((R=E.current)==null?void 0:R.id)===C.pointerId&&(E.current=null),A(!1)},re=C=>{if(!b)return;const R=i.current.getBoundingClientRect(),h=q();b.scale>h*1.1?x(!0):I(()=>Math.max(1,h*2),C.clientX-R.left,C.clientY-R.top,!0)},pe=b?Math.round(b.scale*100):100,ge="rounded-lg p-1.5 text-gray-500 transition-colors hover:bg-white/10 hover:text-gray-200 disabled:opacity-40";return e.jsx(mr,{title:Ee(r),subtitle:d?`Screenshot · ${d.w} × ${d.h}`:"Screenshot",icon:e.jsx("span",{className:"rounded-md bg-gray-500/15 p-1.5 text-gray-400",children:e.jsx(os,{size:14})}),onClose:a,toolbar:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{className:ge,onClick:()=>I(C=>C/bt,void 0,void 0,!0),disabled:!b||b.scale<=ft,title:"Zoom out (−)","aria-label":"Zoom out",children:e.jsx(ia,{size:16})}),e.jsxs("button",{className:"min-w-[3.5rem] rounded-lg px-2 py-1 text-xs font-medium tabular-nums text-gray-400 hover:bg-white/10 hover:text-gray-200",onClick:()=>x(!0),title:"Fit to window (0)",children:[pe,"%"]}),e.jsx("button",{className:ge,onClick:()=>I(C=>C*bt,void 0,void 0,!0),disabled:!b||b.scale>=Lt,title:"Zoom in (+)","aria-label":"Zoom in",children:e.jsx(oa,{size:16})}),e.jsx("span",{className:"mx-1 h-5 w-px bg-white/10"}),e.jsx("button",{className:`${ge} ${N?"text-brand-400":""}`,onClick:()=>x(!0),title:"Fit to window (0)","aria-label":"Fit to window",children:e.jsx(ca,{size:15})}),e.jsx("button",{className:`rounded-lg px-2 py-1 text-xs font-semibold transition-colors hover:bg-white/10 ${b&&Math.abs(b.scale-1)<.001?"text-brand-400":"text-gray-500 hover:text-gray-200"}`,onClick:()=>I(()=>1,void 0,void 0,!0),title:"Actual size (1)",children:"1:1"}),e.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:ge,title:"Open the original in a new tab","aria-label":"Open the original in a new tab",children:e.jsx(ve,{size:15})})]}),footer:e.jsxs(e.Fragment,{children:["Scroll or pinch to zoom · drag to move · double-click to zoom in or fit · ",e.jsx("kbd",{className:"font-mono",children:"0"})," fit · ",e.jsx("kbd",{className:"font-mono",children:"1"})," actual size"]}),children:e.jsx("div",{ref:i,className:`absolute inset-0 overflow-hidden bg-[repeating-conic-gradient(rgba(128,128,128,0.08)_0%_25%,transparent_0%_50%)] bg-[length:20px_20px] ${_?v?"cursor-grabbing":"cursor-grab":"cursor-zoom-in"}`,style:{touchAction:"none"},onPointerDown:Y,onPointerMove:Z,onPointerUp:G,onPointerCancel:G,onDoubleClick:re,children:e.jsx("img",{src:l,alt:`Screenshot for ${r}`,draggable:!1,onLoad:C=>n({w:C.currentTarget.naturalWidth,h:C.currentTarget.naturalHeight}),className:`absolute left-0 top-0 max-w-none select-none rounded-sm shadow-xl ${T?"transition-transform duration-150 ease-out":""}`,style:{width:d==null?void 0:d.w,height:d==null?void 0:d.h,transformOrigin:"0 0",transform:b?`translate(${b.x}px, ${b.y}px) scale(${b.scale})`:void 0,visibility:b?"visible":"hidden"}})})})}const Za={gray:{chip:"bg-gray-500/15 text-gray-400",ring:"hover:border-gray-400/60"},blue:{chip:"bg-blue-500/15 text-blue-500 dark:text-blue-300",ring:"hover:border-blue-400/60"},purple:{chip:"bg-purple-500/15 text-purple-600 dark:text-purple-300",ring:"hover:border-purple-400/60"}};function lt({children:t,tone:s="plain",title:r}){return e.jsx("span",{title:r,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] font-semibold tabular-nums backdrop-blur-sm ring-1 ${s==="danger"?"bg-red-500/85 text-white ring-red-300/40":"bg-white/15 text-white ring-white/20"}`,children:t})}function Pt({title:t,subtitle:s,icon:r,accent:a,openLabel:l,openIcon:i,onOpen:d,downloadUrl:n,media:b,tags:g,center:N}){const k=Za[a];return e.jsxs("div",{className:`group rounded-xl border border-white/10 bg-surface-1 overflow-hidden shadow-sm transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5 ${k.ring}`,children:[e.jsxs("button",{type:"button",onClick:d,title:l,"aria-label":`${l}: ${t}`,className:"relative block w-full aspect-video bg-surface-2 overflow-hidden focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500",children:[b,e.jsx("span",{className:"pointer-events-none absolute inset-0 ring-1 ring-inset ring-black/5"}),e.jsx("span",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-1/2 bg-gradient-to-t from-black/70 via-black/30 to-transparent transition-opacity duration-200 opacity-90 group-hover:opacity-100"}),e.jsx("span",{className:"pointer-events-none absolute inset-0 bg-black/0 transition-colors duration-200 group-hover:bg-black/15"}),g&&e.jsx("span",{className:"pointer-events-none absolute left-2.5 bottom-2.5 right-2.5 flex flex-wrap items-center gap-1.5",children:g}),e.jsx("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:N??e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-black/65 backdrop-blur-sm px-3.5 py-1.5 text-xs font-semibold text-white shadow-lg ring-1 ring-white/20 opacity-0 translate-y-1 transition-all duration-200 group-hover:opacity-100 group-hover:translate-y-0",children:[e.jsx(i,{size:13})," ",l]})})]}),e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 border-t border-white/5",children:[e.jsx("span",{className:`rounded-md p-1.5 ${k.chip}`,children:e.jsx(r,{size:14})}),e.jsxs("button",{type:"button",onClick:d,className:"min-w-0 flex-1 text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-200 leading-tight",children:t}),e.jsx("p",{className:"text-[11px] text-gray-500 truncate mt-0.5",children:s})]}),n&&e.jsx("a",{href:n,title:`Download ${t.toLowerCase()}`,"aria-label":`Download ${t.toLowerCase()}`,className:"p-1.5 rounded-md text-gray-500 hover:text-gray-200 hover:bg-white/10 transition-colors",children:e.jsx(Et,{size:14})})]})]})}function Ht({icon:t,tint:s,note:r}){return e.jsxs("span",{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 ${s}`,children:[e.jsx(t,{size:28,className:"opacity-60"}),r&&e.jsx("span",{className:"text-[11px] opacity-70",children:r})]})}function Fs(t,s){const[r,a]=p.useState({data:null,failed:!1});return p.useEffect(()=>{if(!t)return;let l=!1,i=null;const d=kt();return fetch(t,{headers:d?{Authorization:`Bearer ${d}`}:{}}).then(n=>n.ok?s==="blob"?n.blob():n.json():Promise.reject(new Error(String(n.status)))).then(n=>{l||(s==="blob"?(i=URL.createObjectURL(n),a({url:t,data:i,failed:!1})):a({url:t,data:n,failed:!1}))}).catch(()=>{l||a({url:t,data:null,failed:!0})}),()=>{l=!0,i&&URL.revokeObjectURL(i)}},[t,s]),r.url===t?{data:r.data,failed:r.failed}:{data:null,failed:!1}}const Jt=t=>{const s=Math.max(0,Math.round(t));return`${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}`},Ja=t=>t<1e3?`${t} ms`:t<6e4?`${(t/1e3).toFixed(1)} s`:Jt(t/1e3),Bt=(t,s)=>`${t} ${s}${t===1?"":"s"}`;function en({screenshotUrl:t,videoUrl:s,traceUrl:r,traceThumbnailUrl:a,traceSummaryUrl:l,failed:i,onOpenScreenshot:d,onOpenVideo:n,onOpenTrace:b}){const[g,N]=p.useState(null),[k,T]=p.useState(null),f=Fs(a,"blob"),v=Fs(l,"json").data,A=g&&g.url===t?g:null,E=k&&k.url===s?k:null,P=(E==null?void 0:E.duration)??null,U=[t,s,r].filter(Boolean).length;return e.jsxs("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-3",style:U<3?{maxWidth:U*360}:void 0,children:[t&&e.jsx(Pt,{title:"Screenshot",subtitle:i?"The page when the test failed":"Captured during the test",icon:os,accent:"gray",openLabel:"View full size",openIcon:da,onOpen:d,downloadUrl:`${t}&download=true`,media:A!=null&&A.broken?e.jsx(Ht,{icon:xa,tint:"bg-surface-2 text-gray-500",note:"Preview unavailable"}):e.jsx("img",{src:t,alt:"Screenshot preview",loading:"lazy",onLoad:q=>N({url:t,w:q.currentTarget.naturalWidth,h:q.currentTarget.naturalHeight}),onError:()=>N({url:t,broken:!0}),className:"absolute inset-0 h-full w-full object-cover object-top transition-transform duration-500 group-hover:scale-[1.04]"}),tags:e.jsxs(e.Fragment,{children:[i&&e.jsxs(lt,{tone:"danger",children:[e.jsx(Ue,{size:11})," Failure"]}),A!=null&&A.w&&A.h?e.jsxs(lt,{title:"Image size",children:[A.w," × ",A.h]}):null]})}),s&&e.jsx(Pt,{title:"Video",subtitle:P?`Full recording · ${Jt(P)}`:"Full recording of the test",icon:xt,accent:"blue",openLabel:"Play",openIcon:at,onOpen:n,downloadUrl:`${s}&download=true`,media:E!=null&&E.broken?e.jsx(Ht,{icon:xt,tint:"bg-blue-500/10 text-blue-500",note:"Preview unavailable"}):e.jsx("video",{src:`${s}#t=1`,preload:"metadata",muted:!0,playsInline:!0,tabIndex:-1,onLoadedMetadata:q=>{const x=q.currentTarget.duration;Number.isFinite(x)&&x>0&&T({url:s,duration:x})},onError:()=>T({url:s,broken:!0}),className:"absolute inset-0 h-full w-full object-cover object-top pointer-events-none scale-[1.02] transition-transform duration-500 group-hover:scale-[1.06]"}),center:e.jsx("span",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-black/55 text-white shadow-xl ring-1 ring-white/30 backdrop-blur-sm transition-transform duration-200 group-hover:scale-110 group-hover:bg-blue-600/90",children:e.jsx(at,{size:20,className:"ml-0.5",fill:"currentColor"})}),tags:P?e.jsxs(lt,{title:"Length",children:[e.jsx(Qe,{size:11})," ",Jt(P)]}):null}),r&&e.jsx(Pt,{title:"Trace",subtitle:(v==null?void 0:v.durationMs)!==void 0?`Step-by-step replay · ${Ja(v.durationMs)}`:"Step-by-step replay with network & console",icon:Gt,accent:"purple",openLabel:"Open Trace Viewer",openIcon:ve,onOpen:b,downloadUrl:`${r}&download=true`,media:f.data?e.jsx("img",{src:f.data,alt:"The page as the trace ended",className:"absolute inset-0 h-full w-full object-cover object-top transition-transform duration-500 group-hover:scale-[1.04]"}):e.jsx(Ht,{icon:Gt,tint:"bg-gradient-to-br from-purple-500/20 via-brand-500/10 to-transparent text-purple-500",note:f.failed?"No page preview in this trace":void 0}),tags:v?e.jsxs(e.Fragment,{children:[e.jsxs(lt,{title:"Browser actions",children:[e.jsx(ua,{size:11})," ",Bt(v.actions,"action")]}),e.jsxs(lt,{title:"Network requests",children:[e.jsx(ma,{size:11})," ",Bt(v.requests,"request")]}),v.errors>0&&e.jsxs(lt,{tone:"danger",title:"Errors in the trace",children:[e.jsx(Ue,{size:11})," ",Bt(v.errors,"error")]})]}):null})]})}function Es(t){const s=t.pairs??[];if(!s.length||s.every(a=>t.from.includes(a.find)))return null;const r=a=>{const l=(a.match(/\(/g)??[]).length-(a.match(/\)/g)??[]).length;return l>0?a+")".repeat(l):a};return s.map(a=>({file:a.file,find:r(a.find),replace:r(a.replace)}))}function We(t,s){const r=new URLSearchParams({path:t.replace(/\\/g,"/")});return er(`/api/results/artifact?${r.toString()}`)}function Ms(t,s,r){const a=new URLSearchParams({path:s.replace(/\\/g,"/")});return r&&a.set("project",r),`/api/results/${t}?${a.toString()}`}function tn(t,s){if(!t||!s)return null;const r=(s.split(/[\\/]/).pop()||s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(r+'[^\\n]*?(?::line |", line |:)(\\d+)');for(const l of t.split(`
|
|
17
|
-
`)){const i=l.match(a);if(i)return parseInt(i[1],10)}return null}function sn(t,s){const r=(s.status||"").toLowerCase(),a=r==="failed"||r==="error"?tn(s.stackTrace,s.file):null,l=t.map((i,d)=>{var b;let n;if(r==="passed")n="passed";else if(r==="skipped")n="skipped";else if(r==="failed"||r==="error")if(a!=null){const g=((b=t[d+1])==null?void 0:b.line)??1/0;i.line<=a&&a<g?n="failed":i.line<a?n="passed":n="skipped"}else n=d===t.length-1?"failed":"passed";else n="undefined";return{keyword:i.keyword,name:i.name,status:n,errorMessage:n==="failed"?s.errorMessage:void 0}});return(r==="failed"||r==="error")&&l.length>0&&!l.some(i=>i.status==="failed")&&(l[l.length-1].status="failed",l[l.length-1].errorMessage=s.errorMessage),l}const Ls={passed:e.jsx($t,{size:14,className:"text-emerald-400 flex-shrink-0"}),failed:e.jsx(ze,{size:14,className:"text-red-400 flex-shrink-0"}),skipped:e.jsx(Xe,{size:14,className:"text-gray-500 flex-shrink-0"}),pending:e.jsx(ha,{size:14,className:"text-amber-400 flex-shrink-0"}),undefined:e.jsx(or,{size:14,className:"text-gray-400 flex-shrink-0"})};function rn({test:t,projectPath:s,runId:r,onClose:a,displayBrowser:l,displayDevice:i,onOpenVideo:d,isChildRun:n,onOpenFailureAnalysis:b}){var J,Ge,Q,be,Fe,Ne,Te,ut;const{user:g}=Xs(),N=Ft(),[k,T]=p.useState(!0),{data:f}=as(r||null),v=ss(),A=p.useMemo(()=>{const u=(f==null?void 0:f.failureAnalysis)||[],M=((t==null?void 0:t.name)||"").trim();if(M)return u.find(ce=>(ce.affectedTests||[]).some(he=>he===M||he.endsWith(M)||M.endsWith(he)))},[f,t==null?void 0:t.name]);function E(){if(!t)return;const u=(f==null?void 0:f.failureAnalysis)||[],M=A?u.indexOf(A):0,ce=A??{errorSignature:t.errorMessage||t.name,category:"unknown",affectedTests:[t.name],rootCause:t.errorMessage||"No error message was captured for this test.",suggestedFix:"",count:1},he=f==null?void 0:f.framework,Ze=br({runId:r||"",runLabel:f==null?void 0:f.suiteName,framework:he,groupIndex:Math.max(0,M),groupCount:Math.max(1,u.length),group:ce,tests:[{name:t.name,file:t.file}],errorMessage:t.errorMessage,stackTrace:t.stackTrace,kind:Zt(ce)?"investigate":"fix",autoHeal:j!=null&&j.autoHeal?{state:j.autoHeal.state,from:j.autoHeal.from,to:j.autoHeal.to,files:j.autoHeal.files,revertReason:j.autoHeal.revertReason}:j!=null&&j.autoHealSkip?{skipReason:j.autoHealSkip.reason}:void 0});Ct(v,{prompt:Ze,mode:ct(he,!!(f!=null&&f.targetDevice)),attachedTest:t.file?{name:t.name,file:t.file,framework:he||void 0}:void 0})}const P=n||!!(f!=null&&f.parentRunId),[U,q]=p.useState(!1),[x,I]=p.useState(null),[_,H]=p.useState(!1),[Y,Z]=p.useState(!1),[G,re]=p.useState(null),[pe,ge]=p.useState(null),[C,R]=p.useState(!1),[h,w]=p.useState(null),L=(t==null?void 0:t.status)==="failed"&&(t!=null&&t.name)?`[FAIL] ${t.name}`:"",{data:D,refetch:ee}=Ve({queryKey:["result-defect",L],queryFn:()=>Qs({search:L}),enabled:!!L}),V=p.useMemo(()=>((D==null?void 0:D.defects)||[]).find(M=>M.title===L)||null,[D,L]),ne=rr({mutationFn:u=>Zs(u),onSuccess:()=>{N.invalidateQueries({queryKey:["tm-defects"]}),ee()}});function je(){if(!t||t.status!=="failed")return;const u=(g==null?void 0:g.displayName)||(g==null?void 0:g.username)||"Automation";ne.mutate($r(t,u))}const[o,$]=p.useState(!1),[O,le]=p.useState(!0),[oe,fe]=p.useState(new Set),[ke,xe]=p.useState(!1),{data:Ie}=Er((t==null?void 0:t.name)||null,t==null?void 0:t.file),{data:Ae,isLoading:Re}=Ra((t==null?void 0:t.file)||null,(t==null?void 0:t.name)||null),W=(Ie==null?void 0:Ie.history)||[],He=(Ae==null?void 0:Ae.humanSteps)||[],{data:Me}=ms(),c=!!(Me!=null&&Me.hideNames),{data:Ce}=Gr((t==null?void 0:t.file)||null),{data:y}=qr((t==null?void 0:t.file)||null,10),{data:S}=Wr((t==null?void 0:t.file)||null),F=(y==null?void 0:y.commits)||[];if(!t)return null;const B=t.variants&&h!=null?t.variants[h]:null,j=B?{...t,status:B.status,duration:B.duration??t.duration,errorMessage:B.errorMessage,stackTrace:B.stackTrace,steps:B.steps,screenshotPath:B.screenshotPath,videoPath:B.videoPath,tracePath:B.tracePath,systemOutput:B.systemOutput,browser:B.browser??t.browser}:t,K=j.steps&&j.steps.length>0?j.steps:He.length>0?sn(He,j):[],X=K.filter(u=>u.status==="passed").length,te=K.filter(u=>u.status==="failed").length,ue=K.filter(u=>u.status==="skipped"||u.status==="pending"||u.status==="undefined").length,ie=K.find(u=>u.status==="failed"),ae=(ie==null?void 0:ie.errorMessage)||j.errorMessage,we=u=>{fe(M=>{const ce=new Set(M);return ce.has(u)?ce.delete(u):ce.add(u),ce})},nt=async()=>{const u=[ae,j.stackTrace?`
|
|
18
|
-
--- Stack Trace ---
|
|
19
|
-
${j.stackTrace}`:""].join("");try{await navigator.clipboard.writeText(u),xe(!0),setTimeout(()=>xe(!1),2e3)}catch{}};return e.jsxs("div",{className:"p-5 space-y-4",children:[x&&e.jsx(Ya,{url:x,onClose:()=>I(null)}),B&&e.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 rounded-lg bg-indigo-500/10 border border-indigo-500/30 text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-indigo-300 min-w-0",children:[e.jsx(cs,{size:13,className:"flex-shrink-0"}),e.jsx("span",{className:"flex-shrink-0",children:"Viewing data set"}),e.jsx("span",{className:"font-mono bg-white/10 px-1.5 py-0.5 rounded border border-indigo-500/30 truncate",title:B.label,children:B.label})]}),e.jsxs("button",{onClick:()=>w(null),className:"flex items-center gap-1 text-indigo-300 hover:text-indigo-200 font-medium flex-shrink-0",children:[e.jsx(dt,{size:11})," Back to summary"]})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-base font-semibold text-gray-200 break-words",title:t.name,children:Ee(t.name)}),t.suite&&e.jsx("p",{className:"text-sm text-gray-500 mt-0.5",title:t.suite,children:Ee(t.suite)}),t.file&&e.jsx("p",{className:"text-xs text-gray-400 mt-0.5 font-mono",children:t.file}),!c&&(Ce==null?void 0:Ce.lastModifiedBy)&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-2 text-[11px] text-gray-400",children:[e.jsx(ir,{size:10,className:"flex-shrink-0"}),e.jsx("span",{children:Ce.lastModifiedBy}),e.jsx("span",{children:"•"}),e.jsx("span",{children:Ps(Ce.lastModifiedAt)}),e.jsx("span",{children:"•"}),e.jsx("span",{className:"font-mono text-gray-500",children:(J=Ce.lastCommitSha)==null?void 0:J.slice(0,7)})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-3 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>{const u=new URLSearchParams;u.set("file",t.file.replace(/\\/g,"/")),u.set("test",t.name),window.open(`/tests?${u.toString()}`,"_blank","noopener")},disabled:!t.file,title:t.file?"Open this test in the Test Explorer (new tab)":"This result has no test file recorded, so it cannot be opened in the Test Explorer",className:"group flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-white/10 text-gray-300 text-xs font-medium hover:bg-white/5 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(pa,{size:14})," Open in Test Explorer",t.file&&e.jsx(ve,{size:12,"aria-hidden":"true",className:"opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 transition-opacity"})]}),e.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-red-300 text-red-600 text-xs font-medium hover:bg-red-500/10 transition-colors",children:[e.jsx(dt,{size:14})," Close"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2.5 mt-3 pt-3 border-t border-white/5 flex-wrap",children:[e.jsx("span",{className:`px-2.5 py-1 rounded-lg text-xs font-semibold ${j.status==="passed"?"bg-emerald-500/15 text-emerald-300":j.status==="failed"?"bg-red-500/15 text-red-300":"bg-white/5 text-gray-400"}`,children:j.status.toUpperCase()}),j.duration!=null&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-gray-500",children:[e.jsx(Qe,{size:11}),(j.duration/1e3).toFixed(2),"s"]}),t.retryCount!=null&&t.retryCount>0&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-amber-600",children:[e.jsx(is,{size:11}),t.retryCount," retries"]}),i?e.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-lg bg-white/5 text-xs text-gray-400",children:[e.jsx(rt,{size:12,className:"text-indigo-400"}),i]}):(l||j.browser)&&e.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-lg bg-white/5 text-xs text-gray-400",children:[e.jsx(us,{browser:l||j.browser,size:12}),l||j.browser]}),K.length>0&&e.jsxs("span",{className:"text-xs text-gray-400",children:[X,"/",K.length," steps passed"]}),t.workerIndex!=null&&e.jsxs("span",{className:"text-xs text-gray-400",children:["Worker #",t.workerIndex]}),t.assertionCount!=null&&t.assertionCount>0&&e.jsxs("span",{className:"text-xs text-gray-400",children:[t.assertionCount," assertions"]})]}),(t.tags&&t.tags.length>0||t.annotations&&t.annotations.length>0||!t.variants&&t.parameters&&Object.keys(t.parameters).length>0)&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-2 flex-wrap",children:[(Ge=t.tags)==null?void 0:Ge.map(u=>e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium bg-white/5 text-gray-400 border border-white/10",children:u},u)),(Q=t.annotations)==null?void 0:Q.map((u,M)=>e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium bg-violet-500/15 text-violet-300 border border-violet-500/30",title:u.description,children:["@",u.type]},M)),!t.variants&&t.parameters&&Object.entries(t.parameters).map(([u,M])=>e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-mono bg-blue-500/15 text-blue-300 border border-blue-500/30",children:[u,"=",M]},u))]})]}),t.retryAttempts&&t.retryAttempts.length>1&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsx("h3",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3",children:"Retry Timeline"}),e.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:t.retryAttempts.map((u,M)=>{const ce=u.status==="passed"?"bg-emerald-500":"bg-red-500";return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:`w-7 h-7 rounded-full ${ce} text-white text-[10px] font-bold flex items-center justify-center`,title:`Attempt ${M+1}: ${u.status} (${(u.duration/1e3).toFixed(1)}s)${u.error?` — ${u.error.slice(0,100)}`:""}`,children:M+1}),M<t.retryAttempts.length-1&&e.jsx("span",{className:"text-gray-300 text-xs",children:"→"})]},M)})}),e.jsxs("div",{className:"mt-2 text-[10px] text-gray-400",children:[t.retryAttempts.length," attempts · Final: ",(be=t.retryAttempts[t.retryAttempts.length-1])==null?void 0:be.status]}),t.retryAttempts.some(u=>u.runId)&&e.jsx("div",{className:"mt-3 rounded-lg border border-white/5 overflow-hidden",children:t.retryAttempts.map((u,M)=>{const ce=M===t.retryAttempts.length-1,he=u.status==="passed"?"bg-emerald-500":u.status==="cancelled"?"bg-gray-500":"bg-red-500";return e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 border-b border-white/5 last:border-0",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${he} flex-shrink-0`}),e.jsxs("span",{className:"text-[12px] text-gray-400 flex-shrink-0",children:["Attempt ",M+1,ce?" · final":""]}),e.jsx("span",{className:"text-[11px] text-gray-500 truncate flex-1",children:u.status==="passed"?"Passed":u.error||u.status}),u.duration>0&&e.jsxs("span",{className:"text-[11px] text-gray-500 tabular-nums flex-shrink-0",children:[(u.duration/1e3).toFixed(1),"s"]}),u.runId&&e.jsxs("button",{onClick:()=>window.open(`/results?runId=${encodeURIComponent(u.runId)}`,"_blank","noopener"),title:"Open this attempt's run",className:"text-[11px] text-gray-500 hover:text-cyan-300 inline-flex items-center gap-1 flex-shrink-0",children:["View Result ",e.jsx(ve,{size:11})]})]},M)})})]}),t.variants&&t.variants.length>0&&e.jsx(an,{variants:t.variants,selectedIdx:h,onSelect:u=>w(M=>M===u?null:u)}),t.coverageData&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsx("h3",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3",children:"Coverage"}),e.jsx("div",{className:"grid grid-cols-4 gap-3",children:["lines","branches","functions","statements"].map(u=>{const M=t.coverageData[u],ce=M>=80?"text-emerald-600":M>=60?"text-amber-600":"text-red-600",he=M>=80?"bg-emerald-500":M>=60?"bg-amber-500":"bg-red-500";return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 uppercase",children:u}),e.jsxs("div",{className:`text-lg font-bold ${ce}`,children:[M,"%"]}),e.jsx("div",{className:"h-1 bg-white/10 rounded-full mt-1",children:e.jsx("div",{className:`h-full ${he} rounded-full`,style:{width:`${Math.min(M,100)}%`}})})]},u)})})]}),P&&(f==null?void 0:f.source)==="cloud"&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(tt,{size:12,className:"text-blue-400"})," Cloud Artifacts"]}),!((Ne=(Fe=f==null?void 0:f.cloudArtifacts)==null?void 0:Fe.sessions)!=null&&Ne.length)&&(f==null?void 0:f.cloudProvider)!=="local-appium"&&e.jsxs("button",{onClick:async()=>{q(!0);try{await Js(r),N.invalidateQueries({queryKey:["result-run",r]})}catch{}finally{q(!1)}},disabled:U,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-blue-500/15 text-blue-300 text-[11px] font-medium hover:bg-blue-500/25 border border-blue-500/20 transition-colors disabled:opacity-50",children:[U?e.jsx(me,{size:10,className:"animate-spin"}):e.jsx(Et,{size:10})," Fetch artifacts"]})]}),(ut=(Te=f==null?void 0:f.cloudArtifacts)==null?void 0:Te.sessions)!=null&&ut.length?e.jsx("div",{className:"space-y-2",children:f.cloudArtifacts.sessions.map(u=>e.jsxs("div",{className:"flex items-center gap-3 rounded-xl bg-surface-2/50 border border-white/5 px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5 flex-1 min-w-0",children:[u.browser&&e.jsx("span",{className:"text-sm font-medium text-gray-200 truncate",children:u.browser}),u.os&&e.jsxs("span",{className:"text-xs text-gray-500 flex-shrink-0",children:[u.os," ",u.osVersion||""]}),u.status&&e.jsx("span",{className:`px-2 py-0.5 rounded-lg text-[11px] font-medium flex-shrink-0 ${u.status==="passed"||u.status==="done"?"bg-emerald-500/15 text-emerald-400":u.status==="failed"||u.status==="error"?"bg-red-500/15 text-red-400":"bg-gray-500/15 text-gray-400"}`,children:u.status}),u.duration!=null&&e.jsxs("span",{className:"text-xs text-gray-500 flex-shrink-0",children:[u.duration,"s"]})]}),e.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[u.videoUrl&&e.jsxs("button",{onClick:()=>{if(d){d(u.videoUrl);return}window.open(u.videoUrl,"_blank")},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-surface-2 text-xs font-medium text-blue-400 hover:text-blue-300 hover:bg-surface-3 transition-colors",children:[e.jsx(xt,{size:13})," Video"]}),u.logsUrl&&(()=>{const M=kt(),ce=u.logsUrl.includes("?")?"&":"?",he=u.logsUrl.startsWith("/api/")&&M?`${u.logsUrl}${ce}token=${encodeURIComponent(M)}`:u.logsUrl;return e.jsxs("a",{href:he,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-surface-2 text-xs font-medium text-gray-400 hover:text-gray-300 hover:bg-surface-3 transition-colors",children:[e.jsx(pt,{size:13})," Logs"]})})(),u.sessionUrl&&e.jsxs("a",{href:u.sessionUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-surface-2 text-xs font-medium text-gray-400 hover:text-gray-300 hover:bg-surface-3 transition-colors",children:[e.jsx(ve,{size:13})," Session"]})]})]},u.sessionId))}):e.jsxs("p",{className:"text-xs text-gray-500",children:["No artifacts fetched yet",(f==null?void 0:f.cloudProvider)==="local-appium"?" (local device runs have no provider artifacts)":" — use Fetch artifacts once the cloud build completes","."]})]}),j.status==="failed"&&(ie||j.errorMessage)&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-red-500/20 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-red-500/15",children:e.jsx(Ue,{size:14,className:"text-red-600"})}),e.jsx("p",{className:"text-xs font-bold text-red-300 uppercase tracking-wide",children:"Root Cause Analysis"}),ae&&e.jsxs("button",{onClick:nt,className:"ml-auto flex items-center gap-1 text-[11px] text-gray-400 hover:text-gray-400 transition-colors px-2 py-1 rounded-lg hover:bg-white/10",title:"Copy error to clipboard",children:[ke?e.jsx(Se,{size:10,className:"text-emerald-500"}):e.jsx(Ye,{size:10}),ke?"Copied!":"Copy"]})]}),ie&&e.jsxs("div",{className:"text-sm",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-gray-500",children:"Failed at step: "}),e.jsxs("span",{className:"text-red-300 font-medium",children:[ie.keyword," ",ie.name]})]}),ue>0&&e.jsxs("p",{className:"mt-1 text-gray-400 text-xs",children:[ue," subsequent step",ue>1?"s":""," skipped due to this failure"]})]}),ae&&e.jsx("pre",{className:"text-xs text-red-300 bg-red-500/10 border border-red-500/20 rounded-lg p-3 overflow-x-auto whitespace-pre-wrap max-h-40 overflow-y-auto leading-relaxed",children:ae}),j.screenshotPath&&e.jsxs("button",{onClick:()=>H(!0),className:"group relative w-full rounded-lg border border-white/10 overflow-hidden cursor-pointer hover:border-red-300 transition-colors",children:[e.jsx("img",{src:We(j.screenshotPath),alt:"Failure screenshot",className:"w-full h-32 object-cover object-top opacity-90 group-hover:opacity-100 transition-opacity"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/50 to-transparent flex items-end p-2",children:e.jsxs("span",{className:"text-[11px] text-white flex items-center gap-1",children:[e.jsx(os,{size:10})," Click to view full screenshot"]})})]})]}),j.autoHeal&&r&&e.jsx(ln,{stamp:j.autoHeal,runId:r,testName:j.name,onHandOff:()=>{const u=f==null?void 0:f.framework,M=j.autoHeal;Ct(v,{prompt:yr({runId:r,testName:j.name,testFile:j.file,framework:u,state:M.state,from:M.from,to:M.to,files:M.files,revertReason:M.revertReason}),mode:ct(u,!!(f!=null&&f.targetDevice)),attachedTest:j.file?{name:j.name,file:j.file,framework:u||void 0}:void 0})}}),!j.autoHeal&&j.autoHealSkip&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 p-4 space-y-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"px-2 py-0.5 rounded-md text-[11px] font-semibold border inline-flex items-center gap-1 bg-white/5 text-gray-400 border-white/10",children:[e.jsx(de,{size:11})," Auto-Heal"]}),e.jsx("p",{className:"text-sm font-semibold text-gray-300",children:"Not healed automatically"})]}),e.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:j.autoHealSkip.reason}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{onClick:E,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium bg-brand-600 text-white hover:bg-brand-500 transition-colors",children:[e.jsx(de,{size:12}),"Fix in AI Assistant"]}),b&&A&&e.jsxs("button",{onClick:b,className:"text-xs text-purple-600 dark:text-purple-300 hover:underline",children:["View group (",A.count," test",A.count===1?"":"s",")"]})]})]}),Re&&t.file&&K.length===0&&e.jsxs("div",{className:"flex items-center gap-2 py-2 text-gray-400 text-xs",children:[e.jsx(me,{size:12,className:"animate-spin"}),e.jsx("span",{children:"Loading test steps..."})]}),K.length>0&&e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>le(!O),className:"flex items-center gap-1 text-xs font-bold text-gray-500 uppercase tracking-wide mb-2 hover:text-gray-300",children:[O?e.jsx(Oe,{size:12}):e.jsx(De,{size:12}),"Steps (",X," passed",te>0?`, ${te} failed`:"",ue>0?`, ${ue} skipped`:"",")"]}),O&&e.jsx("div",{className:"rounded-lg border border-white/10 overflow-hidden bg-surface-1",children:K.map((u,M)=>e.jsxs("div",{className:`border-b border-white/5 last:border-0 ${u.isBackground?"bg-white/[0.03]":u.isHook?"bg-violet-500/10":"bg-transparent"}`,children:[e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 text-xs",children:[e.jsx("div",{className:"mt-0.5",children:Ls[u.status]||Ls.undefined}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{children:[u.isBackground&&e.jsx("span",{className:"text-gray-400 text-[10px] mr-1",children:"[BG]"}),u.isHook&&e.jsx("span",{className:"text-violet-400 text-[10px] mr-1",children:"[Hook]"}),e.jsxs("span",{className:`font-semibold ${u.isHook?"text-violet-300":"text-gray-200"}`,children:[u.keyword," "]}),e.jsx("span",{className:u.status==="passed"?"text-emerald-300":u.status==="failed"?"text-red-300":"text-gray-400",children:u.name}),u.duration!=null&&u.duration>0&&e.jsxs("span",{className:"text-gray-400 ml-1 text-[10px]",children:["(",u.duration,"ms)"]})]}),u.dataTable&&u.dataTable.length>0&&e.jsx("table",{className:"mt-1.5 text-[10px] border-collapse",children:u.dataTable.map((ce,he)=>e.jsx("tr",{children:ce.map((Ze,m)=>he===0?e.jsx("th",{className:"px-2 py-0.5 bg-white/10 border border-white/10 font-semibold text-gray-400",children:Ze},m):e.jsx("td",{className:"px-2 py-0.5 border border-white/10 text-gray-300",children:Ze},m))},he))}),u.errorMessage&&e.jsxs("button",{onClick:()=>we(M),className:"mt-1 text-[10px] text-red-500 hover:text-red-300 flex items-center gap-1",children:[oe.has(M)?e.jsx(Oe,{size:10}):e.jsx(De,{size:10}),oe.has(M)?"Hide error":"Show error details"]})]})]}),u.errorMessage&&oe.has(M)&&e.jsx("div",{className:"px-3 pb-2 ml-7",children:e.jsx("pre",{className:"text-[11px] text-red-300 bg-red-500/10 border border-red-500/20 rounded-lg p-2 whitespace-pre-wrap break-all overflow-x-auto max-h-48 overflow-y-auto",children:u.errorMessage})})]},M))})]}),j.errorMessage&&!ie&&j.status!=="failed"&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsx("p",{className:"text-xs font-bold text-gray-500 uppercase tracking-wide mb-2",children:"Error"}),e.jsx("pre",{className:"text-xs text-red-300 bg-red-500/10 border border-red-500/20 rounded-lg p-3 overflow-x-auto whitespace-pre-wrap",children:j.errorMessage})]}),j.stackTrace&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("button",{onClick:()=>T(!k),className:"flex items-center gap-1.5 text-xs font-bold text-gray-500 uppercase tracking-wide hover:text-gray-300",children:[k?e.jsx(Oe,{size:12}):e.jsx(De,{size:12})," Stack Trace"]}),k&&e.jsx("pre",{className:"mt-3 text-[11px] text-gray-400 bg-surface-2 border border-white/10 rounded-lg p-3 overflow-x-auto whitespace-pre-wrap max-h-48 overflow-y-auto font-mono leading-relaxed",children:j.stackTrace})]}),(j.screenshotPath||j.videoPath||j.tracePath)&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsx("p",{className:"text-xs font-bold text-gray-500 uppercase tracking-wide mb-3",children:"Recordings & Screenshots"}),e.jsx(en,{screenshotUrl:j.screenshotPath?We(j.screenshotPath):void 0,videoUrl:j.videoPath?We(j.videoPath):void 0,traceUrl:j.tracePath?We(j.tracePath):void 0,traceThumbnailUrl:j.tracePath?Ms("trace-thumbnail",j.tracePath,s):void 0,traceSummaryUrl:j.tracePath?Ms("trace-summary",j.tracePath,s):void 0,failed:j.status==="failed"||j.status==="error",onOpenScreenshot:()=>H(!0),onOpenVideo:()=>$(!0),onOpenTrace:()=>I(Xa(We(j.tracePath)))})]}),B?e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-xs font-bold text-gray-500 uppercase tracking-wide flex items-center gap-1.5",children:[e.jsx(ot,{size:12})," Output",e.jsx("span",{className:"font-normal normal-case text-gray-400",children:"· this data set"})]}),B.systemOutput&&e.jsxs("button",{onClick:()=>Z(u=>!u),className:"flex items-center gap-1 text-[11px] text-gray-400 hover:text-gray-400",children:[e.jsx(Oe,{size:11,className:`transition-transform ${Y?"rotate-180":""}`}),Y?"Collapse":"Expand"]})]}),B.systemOutput?Y&&e.jsxs("div",{className:"mt-3 relative",children:[e.jsxs("button",{onClick:async()=>{try{await navigator.clipboard.writeText(B.systemOutput),xe(!0),setTimeout(()=>xe(!1),2e3)}catch{}},className:"absolute top-2 right-2 z-10 flex items-center gap-1 px-2 py-1 rounded-md text-[10px] !text-white transition-colors",title:"Copy output",children:[ke?e.jsx(Se,{size:10}):e.jsx(Ye,{size:10}),ke?"Copied!":"Copy"]}),e.jsx("pre",{className:"text-[11px] font-mono leading-relaxed whitespace-pre-wrap break-words text-white rounded-lg p-3 pr-20 max-h-80 overflow-auto bg-black select-text cursor-text",children:_t(B.systemOutput).map((u,M)=>e.jsx("span",{style:Dt(u.style),children:u.text},M))})]}):e.jsx("p",{className:"mt-2 text-xs text-gray-400 italic",children:"No per-data-set output was captured for this variant. Use “Back to summary” to view the full run output."})]}):r?e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 cursor-pointer hover:bg-white/[0.03] transition-colors",onClick:async()=>{if(G!==null){Z(u=>!u);return}R(!0);try{const u=await Vt(r,P?void 0:t.name);re(u.output),ge(u.note||null),Z(!0)}catch{re(null)}finally{R(!1)}},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-xs font-bold text-gray-500 uppercase tracking-wide flex items-center gap-1.5",children:[e.jsx(ot,{size:12})," Output"]}),e.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-gray-400",children:[C?e.jsx(me,{size:11,className:"animate-spin"}):e.jsx(Oe,{size:11,className:`transition-transform ${Y?"rotate-180":""}`}),Y?"Collapse":"Expand"]})]}),Y&&pe&&e.jsxs("div",{className:"mt-3 flex items-start gap-2 px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/30 text-amber-300 text-[11px]",onClick:u=>u.stopPropagation(),children:[e.jsx(Ue,{size:13,className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{children:pe})]}),Y&&G!==null&&e.jsxs("div",{className:`${pe?"mt-2":"mt-3"} relative`,onClick:u=>u.stopPropagation(),children:[e.jsxs("button",{onClick:async()=>{try{await navigator.clipboard.writeText(G),xe(!0),setTimeout(()=>xe(!1),2e3)}catch{}},className:"absolute top-2 right-2 z-10 flex items-center gap-1 px-2 py-1 rounded-md text-[10px] !text-white transition-colors",title:"Copy console output",children:[ke?e.jsx(Se,{size:10}):e.jsx(Ye,{size:10}),ke?"Copied!":"Copy"]}),e.jsx("pre",{className:"text-[11px] font-mono leading-relaxed whitespace-pre-wrap break-words text-white rounded-lg p-3 pr-20 max-h-80 overflow-auto bg-black select-text cursor-text",children:_t(G).map((u,M)=>e.jsx("span",{style:Dt(u.style),children:u.text},M))})]}),Y&&G===null&&!C&&e.jsx("p",{className:"mt-2 text-xs text-gray-400 italic",children:"Console output not available for this test."})]}):null,W.length>0&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("p",{className:"text-xs font-bold text-gray-500 uppercase tracking-wide mb-3",children:["History (last ",Math.min(W.length,20)," runs)"]}),e.jsx("div",{className:"flex items-center gap-1.5",children:W.slice(0,20).reverse().map((u,M)=>e.jsx("div",{className:`w-4 h-4 rounded ${u.status==="passed"?"bg-emerald-400":u.status==="failed"?"bg-red-400":"bg-gray-300"}`,title:`${u.status} — ${rs(u.timestamp)}`},M))})]}),F.length>0&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("p",{className:"text-xs font-bold text-gray-500 uppercase tracking-wide mb-3 flex items-center gap-1.5",children:[e.jsx(qt,{size:12})," Git History"]}),e.jsx("div",{className:"space-y-2",children:F.slice(0,5).map(u=>e.jsxs("div",{className:"flex items-center gap-2 text-xs px-3 py-2 rounded-lg bg-white/[0.03]",children:[e.jsx("span",{className:"font-mono text-gray-500 w-14 flex-shrink-0",children:u.shortSha}),e.jsx("span",{className:"text-gray-300 truncate flex-1",children:u.message}),e.jsx("span",{className:"text-gray-400 flex-shrink-0 text-[11px]",children:Ps(u.timestamp)})]},u.sha))}),S&&S.churnScore>5&&e.jsxs("div",{className:"mt-3 flex items-center gap-1.5 text-xs text-amber-600 bg-amber-500/10 border border-amber-500/30 rounded-lg px-3 py-2",children:[e.jsx(Ue,{size:11}),"Modified ",S.editCount," times in ",S.daysSpan," days (high churn)"]})]}),t.status==="failed"&&e.jsxs("div",{className:"flex items-center gap-3",children:[V?e.jsxs("div",{className:`flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl border text-sm font-medium ${V.status==="open"?"bg-red-500/10 border-red-500/30 text-red-300":V.status==="in_progress"?"bg-amber-500/10 border-amber-500/30 text-amber-300":V.status==="resolved"?"bg-emerald-500/10 border-emerald-500/30 text-emerald-300":"bg-white/5 border-white/10 text-gray-300"}`,children:[e.jsx(St,{size:14}),V.id," — ",e.jsx("span",{className:"capitalize",children:(V.status||"open").replace("_"," ")})]}):e.jsxs("button",{onClick:je,disabled:ne.isPending,className:"flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl bg-red-500/10 border border-red-500/30 text-red-300 text-sm font-medium hover:bg-red-500/20 transition-colors disabled:opacity-50",children:[ne.isPending?e.jsx(me,{size:14,className:"animate-spin"}):e.jsx(St,{size:14}),"Create Defect"]}),(t.errorMessage||(ie==null?void 0:ie.errorMessage))&&!j.autoHeal&&!j.autoHealSkip&&e.jsxs("button",{onClick:E,title:"Open the AI Assistant with this test, its error, and its failure classification",className:"flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl bg-purple-500/10 border border-purple-500/30 text-purple-600 dark:text-purple-300 text-sm font-medium hover:bg-purple-500/20 transition-colors",children:[e.jsx(de,{size:14})," Fix in AI Assistant"]})]}),_&&j.screenshotPath&&e.jsx(Qa,{url:We(j.screenshotPath),testName:t.name,onClose:()=>H(!1)}),o&&j.videoPath&&e.jsx(mr,{title:Ee(t.name),subtitle:"Video recording",icon:e.jsx("span",{className:"rounded-md bg-blue-500/15 p-1.5 text-blue-500 dark:text-blue-300",children:e.jsx(xt,{size:14})}),onClose:()=>$(!1),toolbar:e.jsx("a",{href:We(j.videoPath),target:"_blank",rel:"noopener noreferrer",className:"rounded-lg p-1.5 text-gray-500 transition-colors hover:bg-white/10 hover:text-gray-200",title:"Open the video in a new tab","aria-label":"Open the video in a new tab",children:e.jsx(ve,{size:15})}),children:e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black p-3",children:e.jsx("video",{src:We(j.videoPath),controls:!0,autoPlay:!0,className:"h-full w-full rounded-lg object-contain",children:"Your browser does not support the video element."},j.videoPath)})})]})}function Ps(t){try{const s=Date.now(),r=new Date(t).getTime(),a=s-r,l=Math.floor(a/6e4);if(l<1)return"just now";if(l<60)return`${l}m ago`;const i=Math.floor(l/60);if(i<24)return`${i}h ago`;const d=Math.floor(i/24);if(d<30)return`${d}d ago`;const n=Math.floor(d/7);return d<90?`${n}w ago`:`${Math.floor(d/30)}mo ago`}catch{return""}}function an({variants:t,selectedIdx:s,onSelect:r}){const a=t.length,l=t.filter(N=>N.status==="passed").length,i=t.filter(N=>N.status==="failed"||N.status==="error").length,d=t.filter(N=>N.status==="skipped").length,n=a?Math.round(l/a*100):0,b=t.reduce((N,k)=>N+(k.duration||0),0),g=Math.max(...t.map(N=>N.duration||0),1);return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 border-b border-white/5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2.5",children:[e.jsxs("h3",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(cs,{size:13,className:"text-gray-400"})," Variations",e.jsxs("span",{className:"text-gray-300 font-normal normal-case lowercase",children:["· ",a," data sets"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] font-medium tabular-nums",children:[e.jsxs("span",{className:"flex items-center gap-1 text-emerald-600",children:[e.jsx($t,{size:12})," ",l]}),i>0&&e.jsxs("span",{className:"flex items-center gap-1 text-red-600",children:[e.jsx(ze,{size:12})," ",i]}),d>0&&e.jsxs("span",{className:"flex items-center gap-1 text-gray-400",children:[e.jsx(Xe,{size:12})," ",d]})]})]}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"flex-1 h-1.5 rounded-full overflow-hidden bg-white/10 flex gap-px",children:t.map((N,k)=>{const T=N.status==="passed"?"bg-emerald-400":N.status==="skipped"?"bg-gray-300":"bg-red-400";return e.jsx("div",{className:T,style:{width:`${100/a}%`},title:`${N.label}: ${N.status}`},k)})}),e.jsxs("span",{className:`text-[11px] font-bold tabular-nums ${n>=90?"text-emerald-600":n>=70?"text-amber-600":"text-red-600"}`,children:[n,"%"]}),e.jsxs("span",{className:"text-[10px] text-gray-400 tabular-nums flex items-center gap-0.5",children:[e.jsx(Qe,{size:10})," ",(b/1e3).toFixed(1),"s"]})]}),e.jsx("p",{className:"mt-2 text-[10px] text-gray-400",children:"Click a data set to view its steps & results below."})]}),e.jsx("div",{className:"divide-y divide-white/5",children:t.map((N,k)=>{const T=N.status==="passed",f=N.status==="skipped",v=T?$t:f?Xe:ze,A=T?"text-emerald-500":f?"text-gray-400":"text-red-500",E=T?"border-l-emerald-400":f?"border-l-gray-300":"border-l-red-400",P=Math.round((N.duration||0)/g*100),U=s===k;return e.jsxs("button",{type:"button",onClick:()=>r(k),title:"View this data set's steps & results",className:`w-full text-left border-l-2 ${E} pl-3 pr-3 py-2.5 flex items-center gap-2.5 transition-colors ${U?"bg-indigo-500/10":"hover:bg-white/[0.03]"}`,children:[e.jsx(v,{size:15,className:`${A} flex-shrink-0`}),e.jsxs("span",{className:"text-[10px] font-mono text-gray-300 tabular-nums flex-shrink-0 w-5",children:["#",k+1]}),e.jsx("span",{className:"min-w-0 flex-1",children:e.jsx("span",{className:`inline-block max-w-full truncate align-middle px-2 py-0.5 rounded-md text-[11px] font-mono border ${U?"bg-indigo-500/20 text-indigo-300 border-indigo-500/30":"bg-white/10 text-gray-300 border-white/10"}`,title:N.label,children:N.label})}),typeof N.duration=="number"&&e.jsxs("span",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("span",{className:"hidden sm:inline-block w-12 h-1 rounded-full bg-white/10 overflow-hidden",children:e.jsx("span",{className:`block h-full ${T?"bg-emerald-300":f?"bg-gray-300":"bg-red-300"}`,style:{width:`${P}%`}})}),e.jsxs("span",{className:"text-[10px] text-gray-400 tabular-nums w-11 text-right",children:[(N.duration/1e3).toFixed(2),"s"]})]}),e.jsx(De,{size:14,className:`flex-shrink-0 ${U?"text-indigo-500":"text-gray-300"}`})]},k)})})]})}const nn={healed:{border:"border-emerald-500/30",badge:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-300 border-emerald-500/30"},suggested:{border:"border-purple-500/30",badge:"bg-purple-500/15 text-purple-600 dark:text-purple-300 border-purple-500/30"},reverted:{border:"border-amber-500/30",badge:"bg-amber-500/15 text-amber-600 dark:text-amber-300 border-amber-500/30"},undone:{border:"border-white/10",badge:"bg-white/5 text-gray-400 border-white/10"}};function ln({stamp:t,runId:s,testName:r,onHandOff:a}){const l=Ft(),[i,d]=p.useState(!1),[n,b]=p.useState(null),[g,N]=p.useState(null),[k,T]=p.useState(!1),f=nn[t.state],{data:v}=Ve({queryKey:["heal-status",s,r,t.state,t.at],queryFn:()=>tr(s,r),staleTime:3e4}),A=(v==null?void 0:v.reviewWindowDays)??7,E=v?v.actionable:!0,P=t.state==="suggested"&&!!t.partialNote,U=v==null?void 0:v.staleReason,q=()=>{l.invalidateQueries({queryKey:["result-run",s]}),l.invalidateQueries({queryKey:["result-runs"]})},x=async(I,_)=>{d(!0),b(null),N(null);try{await I(),N(_),q()}catch(H){b(H instanceof Error?H.message:String(H))}finally{d(!1)}};return e.jsxs("div",{className:`bg-surface-1 rounded-xl border ${f.border} p-4 space-y-3`,children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:`px-2 py-0.5 rounded-md text-[11px] font-semibold border inline-flex items-center gap-1 ${f.badge}`,children:[e.jsx(de,{size:11})," Auto-Heal · ",P?jr:Pe[t.state]]}),e.jsx("p",{className:"text-sm font-semibold text-gray-200",children:P?hs:ps[t.state]})]}),t.rationale&&e.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:t.rationale}),t.state==="reverted"&&t.revertReason&&e.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-300 leading-relaxed",children:[t.revertReason," — your files are back to how they were."]}),P&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-300 leading-relaxed",children:t.partialNote}),t.state==="suggested"&&!P&&e.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"Testver tried this locator and the affected tests passed, then put your code back. Nothing in your project has changed yet."}),e.jsx("div",{className:"rounded-lg border border-white/10 overflow-hidden font-mono text-xs",children:Es(t)?Es(t).map((I,_,H)=>e.jsxs("div",{children:[(_===0||H[_-1].file!==I.file)&&e.jsx("div",{className:"px-3 py-1.5 text-[11px] text-gray-400 bg-surface-2/60 border-b border-white/10",children:I.file}),e.jsxs("div",{className:"px-3 py-1.5 bg-red-500/10 text-red-600 dark:text-red-300 overflow-x-auto whitespace-pre",children:["− ",I.find]}),e.jsxs("div",{className:"px-3 py-1.5 bg-emerald-500/10 text-emerald-600 dark:text-emerald-300 overflow-x-auto whitespace-pre",children:["+ ",I.replace]})]},_)):e.jsxs(e.Fragment,{children:[t.files.map(I=>e.jsx("div",{className:"px-3 py-1.5 text-[11px] text-gray-400 bg-surface-2/60 border-b border-white/10",children:I},I)),e.jsxs("div",{className:"px-3 py-1.5 bg-red-500/10 text-red-600 dark:text-red-300 overflow-x-auto whitespace-pre",children:["− ",t.from]}),e.jsxs("div",{className:"px-3 py-1.5 bg-emerald-500/10 text-emerald-600 dark:text-emerald-300 overflow-x-auto whitespace-pre",children:["+ ",t.to]})]})}),e.jsxs("div",{className:"flex flex-wrap gap-x-5 gap-y-1 text-[11px] text-gray-500",children:[e.jsxs("span",{children:[e.jsx("b",{className:"text-gray-400 font-semibold",children:"Source"})," ",wt(t.source,!0)]}),e.jsxs("span",{children:[e.jsx("b",{className:"text-gray-400 font-semibold",children:"Confidence"})," ",Nt(t.confidence)]}),e.jsxs("span",{children:[e.jsx("b",{className:"text-gray-400 font-semibold",children:"When"})," ",it(t.at)]}),t.chain&&t.chain>1&&e.jsxs("span",{children:[e.jsx("b",{className:"text-gray-400 font-semibold",children:"Locators"})," ",t.chain," repaired together in this test"]})]}),n&&e.jsx("p",{className:"text-xs text-red-500 dark:text-red-400",role:"alert",children:n}),g&&!n&&e.jsx("p",{className:"text-xs text-emerald-600 dark:text-emerald-400",role:"status",children:g}),!E&&(t.state==="suggested"||t.state==="healed")&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-300 leading-relaxed",children:t.state==="suggested"?U==="expired"?`The ${A}-day review window has passed — a fresh fix will be suggested from current page evidence the next time this test fails.`:"The code has changed since this fix was prepared — the recorded edit no longer matches the files. A fresh fix will be suggested if the test fails again.":U==="expired"?`The ${A}-day review window has passed — to revert this change now, use your version control.`:"The file has changed since this fix was kept — undo from here is no longer possible; use your version control."}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-1",children:[t.state==="suggested"&&E&&e.jsxs("button",{onClick:()=>x(()=>Ks(s,r),"Fix applied — the change is now in your code."),disabled:i,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium bg-purple-500/15 text-purple-600 dark:text-purple-300 border border-purple-500/30 hover:bg-purple-500/25 transition-colors disabled:opacity-40",children:[i?e.jsx(me,{size:12,className:"animate-spin"}):e.jsx(Se,{size:12}),"Apply fix"]}),t.state==="healed"&&E&&e.jsxs("button",{onClick:()=>T(!0),disabled:i,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-red-500 dark:text-red-400 border border-red-500/30 hover:bg-red-500/10 transition-colors disabled:opacity-40",children:[i?e.jsx(me,{size:12,className:"animate-spin"}):e.jsx(is,{size:12}),"Undo this fix"]}),(t.state==="reverted"||t.state==="undone")&&e.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium bg-brand-600 text-white hover:bg-brand-500 transition-colors",children:[e.jsx(de,{size:12}),"Fix in AI Assistant"]}),t.verifyRunId&&e.jsxs("a",{href:`/results?runId=${encodeURIComponent(t.verifyRunId)}`,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-gray-400 border border-white/10 hover:text-gray-200 hover:border-white/25 transition-colors",children:[e.jsx(ve,{size:12}),"Open verification run"]})]}),e.jsx(sr,{open:k,size:"lg",title:"Undo this fix — this cannot be re-applied",description:`${t.to} goes back to ${t.from} in ${t.files.length===1?t.files[0].split(/[\\/]/).pop():`${t.files.length} files`} — the locator that was failing, so this test (and any other test healed by the same change) will most likely fail again. The record becomes "Undone", no Apply button returns for it, and Auto-Heal will never propose this exact change again. Your version control is the way back if you change your mind.`,confirmLabel:"Undo the fix",cancelLabel:"Keep the fix",onConfirm:()=>{T(!1),x(()=>Ys(s,r),"Fix undone — the original locator is back.")},onCancel:()=>T(!1)})]})}const on={bug:"Application Bug",environment:"Environment Issue",flaky:"Flaky Test","test-issue":"Test Code Issue",timeout:"Timeout",unknown:"Needs Investigation"};function Tt(t){return on[t]||t||"Unknown"}function Sr(t){const s=[];return t.forEach((r,a)=>{const l=Array.isArray(r.affectedTests)&&r.affectedTests.length>0?r.affectedTests:[""];l.forEach(i=>{const d=r.assessment||{};s.push({"Group #":a+1,Category:Tt(r.category),"Tests in Group":r.count??l.length,"Error Signature":r.errorSignature||"","Root Cause":r.rootCause||"","Suggested Fix":r.suggestedFix||"","AI Layer":d.layer||"","AI Confidence":d.confidence||"","AI Summary":d.summary||"","Affected Test":i||""})})}),s}function gs(t,s){const r=URL.createObjectURL(t),a=document.createElement("a");a.href=r,a.download=s,document.body.appendChild(a),a.click(),document.body.removeChild(a),setTimeout(()=>URL.revokeObjectURL(r),0)}function cn(){return new Date().toISOString().slice(0,10)}function fs(t){return`testver-failure-analysis${t!=null&&t.runId?`-${t.runId.slice(0,8)}`:""}-${cn()}`}function Hs(t){return t==null?"":`"${String(t).replace(/"/g,'""')}"`}function dn(t,s){const r=Sr(t),a=r.length>0?Object.keys(r[0]):["Group #","Category","Tests in Group","Error Signature","Root Cause","Suggested Fix","AI Layer","AI Confidence","AI Summary","Affected Test"],l=[a.map(Hs).join(",")];r.forEach(d=>{l.push(a.map(n=>Hs(d[n])).join(","))});const i="\uFEFF"+l.join(`\r
|
|
20
|
-
`);gs(new Blob([i],{type:"text/csv;charset=utf-8;"}),`${fs(s)}.csv`)}async function xn(t,s){const r=Sr(t),a=t.map((n,b)=>{var g,N,k;return{"Group #":b+1,Category:Tt(n.category),"Tests Affected":n.count??(Array.isArray(n.affectedTests)?n.affectedTests.length:0),"Error Signature":n.errorSignature||"","Root Cause":n.rootCause||"","Suggested Fix":n.suggestedFix||"","AI Layer":((g=n.assessment)==null?void 0:g.layer)||"","AI Confidence":((N=n.assessment)==null?void 0:N.confidence)||"","AI Summary":((k=n.assessment)==null?void 0:k.summary)||"","Affected Tests":Array.isArray(n.affectedTests)?n.affectedTests.join("; "):""}}),l={};t.forEach(n=>{const b=Tt(n.category);l[b]=(l[b]||0)+(n.count??1)});const i=Object.entries(l).map(([n,b])=>({Category:n,"Tests Affected":b})),d=await Fa([{name:"Failures",rows:Mt(r),widths:[8,22,14,40,60,60,14,14,60,48]},{name:"Groups",rows:Mt(a),widths:[8,22,14,40,60,60,14,14,60,60]},{name:"By Category",rows:Mt(i),widths:[28,16]}]);gs(d,`${fs(s)}.xlsx`)}function $e(t){return t==null?"":String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function un(t){const r={bug:"#ef4444",environment:"#0ea5e9",flaky:"#f59e0b","test-issue":"#fb923c",timeout:"#a855f7",unknown:"#94a3b8"}[t]||"#94a3b8";return`<span style="display:inline-block;padding:2px 10px;border-radius:999px;background:${r}1a;color:${r};border:1px solid ${r}40;font-size:12px;font-weight:600;">${$e(Tt(t))}</span>`}function mn(t,s){const r=it(new Date),a=t.reduce((d,n)=>d+(n.count||0),0),l=t.map((d,n)=>{const b=Array.isArray(d.affectedTests)?d.affectedTests:[];return`
|
|
21
|
-
<section class="card">
|
|
22
|
-
<header class="card-head">
|
|
23
|
-
<div class="card-title">
|
|
24
|
-
<span class="num">#${n+1}</span>
|
|
25
|
-
${un(d.category)}
|
|
26
|
-
<span class="count">${d.count??b.length} test${(d.count??b.length)===1?"":"s"}</span>
|
|
27
|
-
</div>
|
|
28
|
-
<code class="sig">${$e(d.errorSignature)}</code>
|
|
29
|
-
</header>
|
|
30
|
-
<div class="card-body">
|
|
31
|
-
<div class="field">
|
|
32
|
-
<h4>Root Cause</h4>
|
|
33
|
-
<p>${$e(d.rootCause).replace(/\n/g,"<br>")}</p>
|
|
34
|
-
</div>
|
|
35
|
-
<div class="field">
|
|
36
|
-
<h4>Suggested Fix</h4>
|
|
37
|
-
<p>${$e(d.suggestedFix).replace(/\n/g,"<br>")}</p>
|
|
38
|
-
</div>
|
|
39
|
-
${d.assessment?`
|
|
40
|
-
<div class="field">
|
|
41
|
-
<h4>AI Assessment — ${$e(d.assessment.layer)} · ${$e(d.assessment.confidence)} confidence${d.assessment.pointer?` · <code>${$e(d.assessment.pointer)}</code>`:""}</h4>
|
|
42
|
-
<p>${$e(d.assessment.summary).replace(/\n/g,"<br>")}</p>
|
|
43
|
-
</div>
|
|
44
|
-
`:""}
|
|
45
|
-
${b.length>0?`
|
|
46
|
-
<div class="field">
|
|
47
|
-
<h4>Affected Tests (${b.length})</h4>
|
|
48
|
-
<ul>
|
|
49
|
-
${b.map(g=>`<li><code>${$e(g)}</code></li>`).join("")}
|
|
50
|
-
</ul>
|
|
51
|
-
</div>
|
|
52
|
-
`:""}
|
|
53
|
-
</div>
|
|
54
|
-
</section>
|
|
55
|
-
`}).join(""),i=`<!doctype html>
|
|
56
|
-
<html lang="en">
|
|
57
|
-
<head>
|
|
58
|
-
<meta charset="utf-8">
|
|
59
|
-
<title>Testver — Failure Analysis Report${s!=null&&s.runLabel?` — ${$e(s.runLabel)}`:""}</title>
|
|
60
|
-
<style>
|
|
61
|
-
:root { color-scheme: light; }
|
|
62
|
-
* { box-sizing: border-box; }
|
|
63
|
-
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #f8fafc; color: #1e293b; }
|
|
64
|
-
.wrap { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }
|
|
65
|
-
header.page { border-bottom: 1px solid #e2e8f0; padding-bottom: 16px; margin-bottom: 24px; }
|
|
66
|
-
header.page h1 { margin: 0 0 4px; font-size: 24px; }
|
|
67
|
-
header.page .meta { color: #64748b; font-size: 13px; }
|
|
68
|
-
.summary { display: flex; gap: 24px; flex-wrap: wrap; margin: 16px 0 24px; padding: 16px; background: white; border: 1px solid #e2e8f0; border-radius: 12px; }
|
|
69
|
-
.summary .stat { display: flex; flex-direction: column; }
|
|
70
|
-
.summary .stat .v { font-size: 22px; font-weight: 700; color: #0f172a; }
|
|
71
|
-
.summary .stat .l { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; }
|
|
72
|
-
.card { background: white; border: 1px solid #e2e8f0; border-radius: 12px; margin-bottom: 16px; overflow: hidden; }
|
|
73
|
-
.card-head { padding: 14px 18px; border-bottom: 1px solid #f1f5f9; background: #fafbfc; }
|
|
74
|
-
.card-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
|
|
75
|
-
.num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #64748b; font-size: 13px; }
|
|
76
|
-
.count { font-size: 12px; color: #475569; background: #f1f5f9; padding: 2px 8px; border-radius: 999px; }
|
|
77
|
-
.sig { font-size: 12px; color: #475569; word-break: break-all; }
|
|
78
|
-
.card-body { padding: 16px 18px; }
|
|
79
|
-
.field { margin-bottom: 14px; }
|
|
80
|
-
.field:last-child { margin-bottom: 0; }
|
|
81
|
-
.field h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: #64748b; font-weight: 700; }
|
|
82
|
-
.field p { margin: 0; font-size: 14px; line-height: 1.55; color: #1e293b; }
|
|
83
|
-
.field ul { margin: 0; padding-left: 18px; }
|
|
84
|
-
.field li { font-size: 13px; line-height: 1.7; }
|
|
85
|
-
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #f1f5f9; padding: 1px 6px; border-radius: 4px; font-size: 12.5px; }
|
|
86
|
-
footer { margin-top: 32px; padding-top: 16px; border-top: 1px solid #e2e8f0; color: #94a3b8; font-size: 12px; text-align: center; }
|
|
87
|
-
@media print {
|
|
88
|
-
body { background: white; }
|
|
89
|
-
.card { break-inside: avoid; }
|
|
90
|
-
}
|
|
91
|
-
</style>
|
|
92
|
-
</head>
|
|
93
|
-
<body>
|
|
94
|
-
<div class="wrap">
|
|
95
|
-
<header class="page">
|
|
96
|
-
<h1>Failure Analysis Report</h1>
|
|
97
|
-
<div class="meta">
|
|
98
|
-
${s!=null&&s.runLabel?`Run: <strong>${$e(s.runLabel)}</strong> · `:""}
|
|
99
|
-
${s!=null&&s.runId?`ID: <code>${$e(s.runId)}</code> · `:""}
|
|
100
|
-
Generated ${$e(r)}
|
|
101
|
-
</div>
|
|
102
|
-
</header>
|
|
103
|
-
<div class="summary">
|
|
104
|
-
<div class="stat"><span class="v">${t.length}</span><span class="l">Root Causes</span></div>
|
|
105
|
-
<div class="stat"><span class="v">${a}</span><span class="l">Tests Affected</span></div>
|
|
106
|
-
</div>
|
|
107
|
-
${l||'<p style="color:#64748b;">No failure groups to display.</p>'}
|
|
108
|
-
<footer>Generated by Testver · ${$e(r)}</footer>
|
|
109
|
-
</div>
|
|
110
|
-
</body>
|
|
111
|
-
</html>`;gs(new Blob([i],{type:"text/html;charset=utf-8;"}),`${fs(s)}.html`)}const yt={bug:e.jsx(St,{size:16,className:"text-red-400"}),environment:e.jsx(tt,{size:16,className:"text-sky-400"}),flaky:e.jsx(Ue,{size:16,className:"text-amber-400"}),"test-issue":e.jsx(cr,{size:16,className:"text-orange-400"}),timeout:e.jsx(Qe,{size:16,className:"text-purple-400"}),unknown:e.jsx(or,{size:16,className:"text-gray-400"})},Bs={bug:"border-red-500/20 bg-red-500/5",environment:"border-sky-500/20 bg-sky-500/5",flaky:"border-amber-500/20 bg-amber-500/5","test-issue":"border-orange-500/20 bg-orange-500/5",timeout:"border-purple-500/20 bg-purple-500/5",unknown:"border-gray-500/20 bg-gray-500/5"},Os={"test-code":"bg-orange-500/15 text-orange-300 border-orange-500/30",application:"bg-red-500/15 text-red-300 border-red-500/30",environment:"bg-sky-500/15 text-sky-300 border-sky-500/30",unclear:"bg-white/5 text-gray-400 border-white/10"},pn={high:"bg-emerald-500/10 text-emerald-300",medium:"bg-amber-500/10 text-amber-300",low:"bg-white/5 text-gray-400"};function Us({text:t}){const s=t.split(`
|
|
112
|
-
`);return s.length<=1?e.jsx("p",{className:"text-sm text-gray-300 leading-relaxed",children:t}):e.jsx("div",{className:"space-y-1",children:s.map((r,a)=>{const l=r.trim();return l?l.startsWith("•")?e.jsxs("div",{className:"flex gap-2 text-sm text-gray-300 leading-relaxed",children:[e.jsx("span",{className:"text-gray-500 flex-shrink-0",children:"•"}),e.jsx("span",{children:l.slice(1).trim()})]},a):e.jsx("p",{className:"text-sm text-gray-300 leading-relaxed",children:l},a):null})})}function hn({runId:t,testName:s,stamp:r}){const{data:a}=Ve({queryKey:["heal-status",t,s,r.state,r.at],queryFn:()=>tr(t,s),staleTime:3e4});if(r.state==="suggested"&&a&&!a.actionable){const d=a.staleReason==="expired";return e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full border inline-flex items-center gap-1 bg-white/5 text-gray-400 border-white/10",title:d?`The ${a.reviewWindowDays}-day review window has passed — a fresh fix will be suggested the next time this test fails.`:"The code has changed since this fix was prepared — a fresh fix will be suggested if the test fails again.",children:[e.jsx(de,{size:11})," ",d?"Fix expired":"Auto-Heal: Stale"]})}const i=r.state==="suggested"&&!!r.partialNote;return e.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full border inline-flex items-center gap-1 ${At[r.state]}`,title:`${i?hs:ps[r.state]} ${r.from} → ${r.to}`,children:[e.jsx(de,{size:11})," Auto-Heal: ",i?"Fix ready (partial)":Pe[r.state]]})}function _s(t,s){const r=t.trim(),a=s.trim();return r===a||r.endsWith(a)||a.endsWith(r)}function gn({runId:t,onClose:s}){const r=ss(),a=Ft(),{user:l}=Xs(),{data:i}=as(t),{data:d}=Mr(t),n=Lr(),b=Pr(),{data:g}=Kr(t),{data:N}=ms(),k=!!(N!=null&&N.hideNames),T=p.useMemo(()=>new Map(((g==null?void 0:g.ownership)||[]).map(y=>[y.testName,y])),[g]),f=(i==null?void 0:i.failureAnalysis)||[],v=(i==null?void 0:i.tests)||[],A=p.useMemo(()=>v.filter(y=>y.status==="failed"||y.status==="error"),[v]),E=(d==null?void 0:d.outcomes)||{},P=i==null?void 0:i.framework,U=!!(i!=null&&i.targetDevice),q=n.isPending,[x,I]=p.useState(0),[_,H]=p.useState(null),[Y,Z]=p.useState(new Set),[G,re]=p.useState(!1),[pe,ge]=p.useState({}),[C,R]=p.useState(null),h=y=>{if((y==null?void 0:y.status)===404)return"This Testver server started before the current build and does not have the assessment route yet — restart `testver serve`, reload, and try again.";const F=String((y==null?void 0:y.message)||y||"");return/provider|api key|llm/i.test(F)?`${F} — check the LLM connection under Settings → LLM.`:F||"The assessment request failed."},[w,L]=p.useState(!1),D=p.useRef(null);p.useEffect(()=>{if(!w)return;const y=S=>{D.current&&!D.current.contains(S.target)&&L(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[w]);const[ee,V]=Fr(),ne=ee.get("focusTest"),[je,o]=p.useState(null);p.useEffect(()=>{if(!ne||f.length===0)return;const y=f.findIndex(S=>(S.affectedTests||[]).some(F=>_s(F,ne)));y>=0&&(I(y),o(y),setTimeout(()=>{var S;(S=document.querySelector(`[data-failure-group="${y}"]`))==null||S.scrollIntoView({behavior:"smooth",block:"start"})},50),setTimeout(()=>o(null),2500)),V(S=>{const F=new URLSearchParams(S);return F.delete("focusTest"),F},{replace:!0})},[ne,f.length]);const $=y=>(y.affectedTests||[]).map(S=>{const F=A.find(j=>_s(j.name,S)),B=E[(F==null?void 0:F.name)||S]||E[S];return{name:S,file:F==null?void 0:F.file,record:F,later:B?{status:B.status,runId:B.runId}:void 0}}),O=y=>{var S;return $(y).map(F=>F.record).find(F=>F==null?void 0:F.errorMessage)||((S=$(y)[0])==null?void 0:S.record)},le=f.reduce((y,S)=>y+S.count,0),oe=Object.values(E).filter(y=>y.status==="passed").length,fe=async y=>{var S;Z(F=>new Set(F).add(y)),ge(F=>{const B={...F};return delete B[y],B});try{const B=(S=(await b.mutateAsync({runId:t,groupIndex:y})).failed)==null?void 0:S.find(j=>j.index===y);B&&ge(j=>({...j,[y]:B.reason}))}catch(F){ge(B=>({...B,[y]:h(F)}))}finally{Z(F=>{const B=new Set(F);return B.delete(y),B})}},ke=async()=>{var y,S;re(!0),R(null);try{const F=await b.mutateAsync({runId:t});if((y=F.failed)!=null&&y.length){const B=[...new Set(F.failed.map(K=>K.reason))],j=((S=F.assessed)==null?void 0:S.length)??0;R((j>0?`${j} explained, ${F.failed.length} not: `:"")+(B.length===1?B[0]:B.map((K,X)=>`(${X+1}) ${K}`).join(" ")))}}catch(F){R(h(F))}finally{re(!1)}},xe=(y,S,F)=>{var ue;const B=$(S),j=F?[F]:B,K=j.find(jt)||j[0],X=F&&((ue=B.find(ie=>ie.name===F.name))==null?void 0:ue.record)||O(S),te=br({runId:t,runLabel:i==null?void 0:i.suiteName,framework:P,groupIndex:y,groupCount:f.length,group:S,tests:j.map(({name:ie,file:ae,later:we})=>({name:ie,file:ae,later:we})),errorMessage:X==null?void 0:X.errorMessage,stackTrace:X==null?void 0:X.stackTrace,kind:Zt(S)?"investigate":"fix",autoHeal:X!=null&&X.autoHeal?{state:X.autoHeal.state,from:X.autoHeal.from,to:X.autoHeal.to,files:X.autoHeal.files,revertReason:X.autoHeal.revertReason}:X!=null&&X.autoHealSkip?{skipReason:X.autoHealSkip.reason}:void 0});Ct(r,{prompt:te,mode:ct(P,U),attachedTest:K!=null&&K.file?{name:K.name,file:K.file,framework:P||void 0}:void 0})},Ie=x!==null&&f[x]?O(f[x]):void 0,Ae=Ie?Cr(Ie):"",{data:Re,refetch:W}=Ve({queryKey:["result-defect",Ae],queryFn:()=>Qs({search:Ae}),enabled:!!Ae}),He=p.useMemo(()=>((Re==null?void 0:Re.defects)||[]).find(S=>S.title===Ae)||null,[Re,Ae]),Me=rr({mutationFn:y=>Zs(y),onSuccess:()=>{a.invalidateQueries({queryKey:["tm-defects"]}),W()}}),c=y=>{const S=O(y);if(!S)return;const F=(l==null?void 0:l.displayName)||(l==null?void 0:l.username)||"Automation";Me.mutate($r(S,F))},Ce=(y,S)=>{var F;(F=navigator.clipboard)==null||F.writeText(S).catch(()=>{}),H(y),setTimeout(()=>H(null),1500)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Wt,{size:18,className:"text-purple-400 flex-shrink-0"}),e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Failure Analysis"}),e.jsx("span",{className:"text-xs text-gray-500 hidden md:inline",children:"Classification and root cause · fixes happen in the AI Assistant"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[f.length>0&&f.some(y=>!y.assessment)&&e.jsxs("button",{onClick:ke,disabled:G,className:"flex items-center gap-1.5 h-8 px-3 rounded-lg text-xs font-medium bg-purple-500/10 text-purple-300 border border-purple-500/25 hover:bg-purple-500/20 transition-colors disabled:opacity-50",title:"One short AI read per group — the error, the stack and the test code",children:[G?e.jsx(me,{size:13,className:"animate-spin"}):e.jsx(de,{size:13}),G?"Explaining…":"Explain all with AI"]}),f.length>0&&e.jsxs("div",{className:"relative",ref:D,children:[e.jsxs("button",{onClick:()=>L(y=>!y),className:"flex items-center gap-1.5 h-8 px-3 rounded-lg text-xs text-gray-400 border border-white/10 hover:text-gray-200 hover:bg-white/5 transition-colors",children:[e.jsx(Et,{size:13})," Export"]}),w&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 w-44 bg-surface-1 border border-white/10 rounded-lg z-40 py-1 shadow-xl",children:[e.jsxs("button",{onClick:()=>{dn(f,{runId:t,runLabel:i==null?void 0:i.suiteName}),L(!1)},className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-gray-300 hover:bg-white/5 text-left",children:[e.jsx(pt,{size:12,className:"text-gray-400"}),"Export as CSV"]}),e.jsxs("button",{onClick:()=>{xn(f,{runId:t,runLabel:i==null?void 0:i.suiteName}).catch(y=>console.error("[export] Excel export failed",y)),L(!1)},className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-gray-300 hover:bg-white/5 text-left",children:[e.jsx(ga,{size:12,className:"text-emerald-400"}),"Export as Excel"]}),e.jsxs("button",{onClick:()=>{mn(f,{runId:t,runLabel:i==null?void 0:i.suiteName}),L(!1)},className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-gray-300 hover:bg-white/5 text-left",children:[e.jsx(fa,{size:12,className:"text-sky-400"}),"Export as HTML"]})]})]}),f.length>0&&e.jsx("button",{onClick:()=>n.mutate(t),disabled:q,className:"text-xs text-purple-400 hover:text-purple-300 transition-colors",children:"Re-analyze"}),e.jsx("button",{onClick:s,className:"text-gray-500 hover:text-gray-300","aria-label":"Close",children:e.jsx(dt,{size:16})})]})]}),C&&e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded-lg bg-red-500/10 border border-red-500/20 text-xs text-red-300 leading-relaxed",children:[e.jsx(Ue,{size:13,className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"flex-1",children:C}),e.jsx("button",{onClick:()=>R(null),className:"text-red-300 opacity-70 hover:opacity-100","aria-label":"Dismiss",children:e.jsx(dt,{size:12})})]}),f.length===0&&!q&&e.jsxs("div",{className:"text-center py-10",children:[e.jsx(Wt,{size:40,className:"mx-auto text-gray-600 mb-4"}),A.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-lg font-semibold text-gray-200 mb-2",children:"Nothing failed in this run"}),e.jsx("p",{className:"text-sm text-gray-400 max-w-md mx-auto",children:"Failure Analysis groups a run's failures by cause. This run has none to group."})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-lg font-semibold text-gray-200 mb-2",children:"Not analysed yet"}),e.jsxs("p",{className:"text-sm text-gray-400 mb-4 max-w-md mx-auto",children:["Runs are classified as they are saved; this one predates that. Analyze it now to group its ",A.length," failure",A.length===1?"":"s"," by cause."]}),e.jsx("button",{onClick:()=>n.mutate(t),className:"px-6 py-3 rounded-lg bg-purple-500/20 text-purple-300 text-base font-medium hover:bg-purple-500/30 transition-colors border border-purple-500/20",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ls,{size:16}),"Analyze Failures"]})})]})]}),q&&e.jsxs("div",{className:"text-center py-10",children:[e.jsx("div",{className:"w-8 h-8 border-2 border-purple-400 border-t-transparent rounded-full animate-spin mx-auto mb-4"}),e.jsx("p",{className:"text-sm text-gray-300",children:"Analyzing failure patterns…"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Grouping errors and identifying root causes"})]}),f.length>0&&!q&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500 flex-wrap",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-gray-200 font-semibold",children:f.length})," root cause",f.length!==1?"s":""]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[e.jsx("strong",{className:"text-gray-200 font-semibold",children:le})," test",le!==1?"s":""," affected"]}),oe>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{children:[e.jsx("strong",{className:"text-emerald-300 font-semibold",children:oe})," fixed since"]})]}),e.jsx("div",{className:"flex-1"}),e.jsx("div",{className:"flex gap-3",children:Object.entries(f.reduce((y,S)=>(y[S.category]=(y[S.category]||0)+S.count,y),{})).map(([y,S])=>e.jsxs("span",{className:"flex items-center gap-1",title:Qt[y]||y,children:[yt[y]||yt.unknown,e.jsx("span",{children:S})]},y))})]}),f.map((y,S)=>{var Ge;const F=x===S,B=Bs[y.category]||Bs.unknown,j=$(y),K=j.filter(Q=>{var be;return((be=Q.later)==null?void 0:be.status)==="passed"}),X=j.filter(jt),te=y.assessment,ue=Zt(y),ie=Y.has(S)||G,ae=O(y),we=[ae==null?void 0:ae.errorMessage,ae==null?void 0:ae.stackTrace].filter(Boolean).join(`
|
|
113
|
-
|
|
114
|
-
`),nt=hr(y.category),J=y.category==="bug"||(te==null?void 0:te.layer)==="application";return e.jsxs("div",{"data-failure-group":S,className:`rounded-xl border overflow-hidden ${B}${je===S?" ring-2 ring-purple-400/70":""}`,children:[e.jsxs("button",{onClick:()=>I(F?null:S),className:"w-full flex items-center gap-3 p-4 hover:bg-white/[0.02] transition-colors text-left",children:[yt[y.category]||yt.unknown,e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"text-sm font-medium text-gray-200",children:Qt[y.category]||y.category}),e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-white/5 text-gray-400",children:[y.count," test",y.count!==1?"s":""]}),y.signal&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-white/5 text-gray-400",title:"A locator signal — Auto-Heal can act on this group",children:pr[y.signal]||y.signal}),(()=>{var Ne;const Q=$(y).map(Te=>Te.record).filter(Te=>!!Te),be=Q.find(Te=>Te.autoHeal);if(be!=null&&be.autoHeal)return e.jsx(hn,{runId:t,testName:be.name,stamp:be.autoHeal});const Fe=(Ne=Q.find(Te=>Te.autoHealSkip))==null?void 0:Ne.autoHealSkip;return Fe?e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-white/5 text-gray-500 dark:text-gray-400 border border-white/10 cursor-help",title:`Not healed: ${Fe.reason}`,children:"Auto-Heal: not healed"}):null})(),te?e.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full border inline-flex items-center gap-1 ${ue?"bg-amber-500/10 text-amber-300 border-amber-500/25":"bg-purple-500/10 text-purple-300 border-purple-500/25"}`,children:[ue?e.jsx(Ue,{size:11}):e.jsx(de,{size:11}),"AI: ",mt[te.layer]," · ",te.confidence,ue?" — differs":""]}):e.jsxs("span",{role:"button",tabIndex:0,onClick:Q=>{Q.stopPropagation(),fe(S)},onKeyDown:Q=>{(Q.key==="Enter"||Q.key===" ")&&(Q.preventDefault(),Q.stopPropagation(),fe(S))},className:"text-[11px] px-2 py-0.5 rounded-full border border-dashed border-purple-500/35 text-purple-300 hover:bg-purple-500/10 inline-flex items-center gap-1",children:[ie?e.jsx(me,{size:11,className:"animate-spin"}):e.jsx(de,{size:11}),ie?"Explaining…":"Explain with AI"]}),K.length>0&&e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-emerald-500/10 text-emerald-300 border border-emerald-500/20 inline-flex items-center gap-1",children:[e.jsx(Se,{size:11}),K.length===j.length?`Fixed in run #${K[0].later.runId}`:`${K.length} of ${j.length} fixed in run #${K[0].later.runId}`]}),K.length===0&&j.some(Q=>Q.later&&Q.later.status!=="passed")&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-red-500/10 text-red-300",children:"still failing"})]}),e.jsx("p",{className:"text-xs text-gray-500 truncate mt-0.5 font-mono",children:y.errorSignature})]}),F?e.jsx(Oe,{size:16,className:"text-gray-500 flex-shrink-0"}):e.jsx(De,{size:16,className:"text-gray-500 flex-shrink-0"})]}),F&&e.jsxs("div",{className:"px-4 pb-4 space-y-4 border-t border-white/5 pt-3",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ba,{size:12,className:"text-amber-400"}),e.jsx("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide",children:"Root cause"}),e.jsx("span",{className:"text-[10.5px] text-gray-600",children:"instant · rule-based"})]}),e.jsx(Us,{text:y.rootCause}),e.jsxs("div",{className:"flex items-center gap-1.5 pt-1",children:[e.jsx(cr,{size:12,className:"text-emerald-400"}),e.jsx("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide",children:"Suggested direction"})]}),e.jsx("div",{className:"bg-surface-1 rounded-lg p-3 border border-white/5",children:e.jsx(Us,{text:y.suggestedFix})})]}),e.jsxs("div",{className:`rounded-lg border p-3 space-y-2 ${ue?"border-amber-500/30 bg-amber-500/5":"border-purple-500/25 bg-purple-500/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx(de,{size:12,className:ue?"text-amber-300":"text-purple-300"}),e.jsx("p",{className:`text-xs font-semibold uppercase tracking-wide ${ue?"text-amber-300":"text-purple-300"}`,children:"AI assessment"}),te&&e.jsxs("span",{className:"text-[10.5px] text-gray-500",children:["read the error",ae!=null&&ae.stackTrace?", the stack":"",(Ge=te.readFiles)!=null&&Ge.length?` and ${te.readFiles.map(Q=>Q.split("/").pop()).join(", ")}`:"",te.elapsedMs?` · ${Math.max(1,Math.round(te.elapsedMs/1e3))} s`:""]}),e.jsx("div",{className:"flex-1"}),te&&e.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full ${pn[te.confidence]}`,children:[te.confidence," confidence"]})]}),te?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-gray-200 leading-relaxed",children:te.summary}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap pt-1",children:[e.jsx("span",{className:"text-[11px] text-gray-500",children:"Likely layer"}),["test-code","application","environment"].map(Q=>e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full border ${te.layer===Q?Os[Q]:"border-white/10 text-gray-500"}`,children:mt[Q].replace(/^\w/,be=>be.toUpperCase())},Q)),te.layer==="unclear"&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full border ${Os.unclear}`,children:"Unclear"}),e.jsx("div",{className:"flex-1"}),te.pointer&&e.jsx("span",{className:"text-[11.5px] font-mono text-purple-300",children:te.pointer})]}),ue&&e.jsxs("p",{className:"text-[11.5px] text-amber-300 leading-relaxed pt-1",children:["The classifier read this as ",e.jsx("strong",{children:mt[nt]}),"; the AI reads it as ",e.jsx("strong",{children:mt[te.layer]}),". The category stays the record — Auto-Heal and trends key on it — but start the investigation from the disagreement."]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-gray-400 leading-relaxed",children:"One short read of the error, the stack and the test code — where the fault most likely is, and why. A second opinion beside the rule-based category, never a replacement for it."}),pe[S]&&e.jsx("p",{className:"text-xs text-red-300",children:pe[S]}),e.jsxs("button",{onClick:()=>void fe(S),disabled:ie,className:"flex items-center gap-1.5 h-8 px-3 rounded-lg text-xs font-medium bg-purple-500/15 text-purple-300 border border-purple-500/25 hover:bg-purple-500/25 transition-colors disabled:opacity-50",children:[ie?e.jsx(me,{size:13,className:"animate-spin"}):e.jsx(de,{size:13}),ie?"Explaining…":"Explain with AI"]})]})]})]}),we&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide",children:"Error"}),e.jsxs("span",{className:"text-[10.5px] text-gray-600",children:[ae!=null&&ae.name?`from “${Ee(ae.name)}”`:"first affected test"," · full message",ae!=null&&ae.stackTrace?" and stack":""]}),e.jsx("div",{className:"flex-1"}),e.jsxs("button",{onClick:()=>Ce(S,we),className:"flex items-center gap-1 text-[11.5px] text-purple-400 hover:text-purple-300",children:[_===S?e.jsx(Se,{size:11}):e.jsx(Ye,{size:11}),_===S?"Copied":"Copy"]})]}),e.jsx("pre",{className:"rounded-lg bg-surface-0 border border-white/5 p-3 text-[11.5px] leading-relaxed text-gray-300 font-mono whitespace-pre-wrap break-words max-h-64 overflow-auto",children:we})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide",children:["Affected tests (",j.length,")"]}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"text-[10.5px] text-gray-600",children:"status from later runs of the same test"})]}),e.jsx("div",{className:"space-y-1",children:j.map((Q,be)=>{const Fe=T.get(Q.name),Ne=Q.later;return e.jsxs("div",{className:"flex items-center gap-2 text-sm min-w-0 px-2.5 py-1.5 rounded-md bg-surface-1 border border-white/5",children:[e.jsx("span",{className:"truncate min-w-0 text-[13px] text-gray-300 flex-1",title:Q.name,children:Ee(Q.name)}),(Ne==null?void 0:Ne.status)==="passed"?e.jsxs("span",{className:"text-[11px] px-2 py-0.5 rounded-full bg-emerald-500/10 text-emerald-300 inline-flex items-center gap-1 flex-shrink-0",children:[e.jsx(Se,{size:10}),"Fixed · passed in run #",Ne.runId]}):Ne?e.jsxs("span",{className:"text-[11px] px-2 py-0.5 rounded-full bg-red-500/10 text-red-300 flex-shrink-0",children:["Still failing · run #",Ne.runId]}):e.jsx("span",{className:"text-[11px] px-2 py-0.5 rounded-full bg-white/5 text-gray-500 flex-shrink-0",children:"Not re-run yet"}),Fe&&!k&&e.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-gray-500 flex-shrink-0",title:Fe.suggestedOwner.reason,children:[e.jsx(ir,{size:9,className:"text-gray-600"}),Fe.suggestedOwner.name]}),e.jsxs("button",{onClick:()=>xe(S,y,Q),className:`flex items-center gap-1 h-6 px-2 rounded-md border text-[11.5px] flex-shrink-0 transition-colors ${jt(Q)?"border-purple-500/30 bg-purple-500/10 text-purple-300 hover:bg-purple-500/20":"border-white/10 text-gray-500 hover:text-gray-300"}`,title:"Open the AI Assistant with just this test",children:["Fix ",e.jsx(ve,{size:10})]})]},be)})})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap pt-3 border-t border-white/5",children:[e.jsxs("button",{onClick:()=>xe(S,y),className:`flex items-center gap-2 h-9 px-4 rounded-lg text-[13px] font-semibold transition-colors ${ue?"border border-purple-500/35 text-purple-300 hover:bg-purple-500/10":"bg-brand-600 text-white hover:bg-brand-500"}`,children:[e.jsx(de,{size:14}),ue?"Investigate in AI Assistant":"Fix in AI Assistant",e.jsx(ve,{size:12})]}),J&&(He&&x===S?e.jsxs("span",{className:"text-xs text-gray-400 inline-flex items-center gap-1.5",children:[e.jsx(Se,{size:12,className:"text-emerald-400"}),"Defect exists: ",e.jsx("span",{className:"font-mono",children:He.id||He.key||Ae})]}):e.jsxs("button",{onClick:()=>c(y),disabled:Me.isPending||!ae,className:"flex items-center gap-2 h-9 px-4 rounded-lg text-[13px] border border-white/10 text-gray-300 hover:bg-white/5 transition-colors disabled:opacity-50",children:[Me.isPending?e.jsx(me,{size:13,className:"animate-spin"}):e.jsx(St,{size:13}),"Raise as defect"]})),e.jsxs("span",{className:"text-xs text-gray-500 leading-relaxed",children:["Opens the Assistant in ",e.jsx("strong",{className:"text-gray-300 font-medium",children:ct(P,U)==="web"?"Web":ct(P,U)==="api"?"API":"Mobile"})," mode with this error, the stack trace and ",X.length>0&&X.length<j.length?`the ${X.length} remaining test${X.length===1?"":"s"}`:"the affected tests"," — the fix and its scoped re-run happen there; this screen picks the result up from the next run."]})]})]})]},y.errorSignature+S)}),e.jsx("p",{className:"text-[11.5px] text-gray-500 leading-relaxed",children:"Categories come from the deterministic classifier and drive Auto-Heal and trends. AI chips are a short read of the error and the test code — a second opinion, never the record. “Fixed” is read from later runs of the same test, not from anything the AI said."})]})]})}const zr={browserstack:"BrowserStack",lambdatest:"LambdaTest",saucelabs:"Sauce Labs","local-appium":"Local Device"},Ar=t=>t==="local-appium",It={running:{stripe:"bg-amber-400",pill:"bg-amber-500/15 text-amber-300 border-amber-500/30",label:"Running",icon:at},completed:{stripe:"bg-emerald-400",pill:"bg-emerald-500/15 text-emerald-300 border-emerald-500/30",label:"Passed",icon:st},failed:{stripe:"bg-red-400",pill:"bg-red-500/15 text-red-300 border-red-500/30",label:"Failed",icon:ze},cancelled:{stripe:"bg-gray-500",pill:"bg-gray-500/15 text-gray-400 border-gray-500/30",label:"Cancelled",icon:Xe}},Ds="testver:results:viewMode",es={scheduler:{label:"Scheduled",icon:xs,variant:"amber"},testplan:{label:"Test Plan",icon:ya,variant:"purple"},suite:{label:"Suite",icon:Yt,variant:"brand"},ci:{label:"CI",icon:Kt,variant:"brand"},"ai-fix":{label:"AI Verify",icon:de,variant:"purple"},"auto-heal":{label:"Heal Verify",icon:de,variant:"purple"}};function Tr(t){return t>=90?"text-emerald-300":t>=70?"text-amber-300":"text-red-300"}function fn(t){return t>=90?"stroke-emerald-400":t>=70?"stroke-amber-400":"stroke-red-400"}function bn(t){return t>=90?"stroke-emerald-400/15":t>=70?"stroke-amber-400/15":"stroke-red-400/15"}function Ir(t){if(!t)return null;const s=t/1e3;if(s<60)return`${s.toFixed(1)}s`;const r=Math.floor(s/60),a=Math.round(s%60);return`${r}m ${a}s`}function Rt(t){const s=new Date(t);return s.toLocaleDateString(void 0,{month:"short",day:"numeric"})+" · "+s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}function Rr(t){const s=Date.now()-new Date(t).getTime(),r=Math.floor(s/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const a=Math.floor(r/60);if(a<24)return`${a}h ago`;const l=Math.floor(a/24);return l<30?`${l}d ago`:rs(t)}function yn(t){const s=new Date(t),r=new Date,a=new Date;a.setDate(a.getDate()-1);const l=(d,n)=>d.getFullYear()===n.getFullYear()&&d.getMonth()===n.getMonth()&&d.getDate()===n.getDate(),i=`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`;return l(s,r)?{key:i,label:"Today"}:l(s,a)?{key:i,label:"Yesterday"}:{key:i,label:s.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"})}}function Vs(t){try{const s=localStorage.getItem(`testver:fixedFailures:${t}`);if(!s)return!1;const r=JSON.parse(s);return Array.isArray(r)&&r.length>0}catch{return!1}}function jn({rate:t,size:s=56,stroke:r=5,total:a}){const l=(s-r)/2,i=2*Math.PI*l,d=a===0,n=d?0:t/100*i;return e.jsxs("div",{className:"relative flex items-center justify-center",style:{width:s,height:s},children:[e.jsxs("svg",{width:s,height:s,className:"-rotate-90",children:[e.jsx("circle",{cx:s/2,cy:s/2,r:l,strokeWidth:r,fill:"none",className:d?"stroke-gray-700/40":bn(t)}),!d&&e.jsx("circle",{cx:s/2,cy:s/2,r:l,strokeWidth:r,fill:"none",strokeLinecap:"round",strokeDasharray:`${n} ${i}`,className:fn(t)})]}),e.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center leading-none",children:d?e.jsx("span",{className:"text-[11px] text-gray-500",children:"—"}):e.jsxs("span",{className:`${s<50?"text-[11px]":"text-sm"} font-bold ${Tr(t)}`,children:[t,"%"]})})]})}function vn({runs:t,total:s,isLoading:r,onSelectRun:a,viewMode:l,onViewModeChange:i,baselineRunId:d,onCompareRuns:n,onSetBaseline:b,filtersActive:g,onClearFilters:N}){const k=l!==void 0&&i!==void 0,[T,f]=p.useState(()=>{try{const h=localStorage.getItem(Ds);return h==="compact"||h==="table"||h==="rich"?h:"rich"}catch{return"rich"}});p.useEffect(()=>{if(!k)try{localStorage.setItem(Ds,T)}catch{}},[T,k]);const v=k?l:T,A=h=>{k?i(h):f(h)},[E,P]=p.useState([]),U=h=>{P(w=>w.includes(h)?w.filter(L=>L!==h):w.length>=2?[w[1],h]:[...w,h])},[q,x]=p.useState(null),I=async(h,w,L)=>{h.stopPropagation();try{await navigator.clipboard.writeText(L),x(w),setTimeout(()=>x(D=>D===w?null:D),1500)}catch{}},[_,H]=p.useState(null),Y=p.useRef(null);p.useEffect(()=>{if(!_)return;const h=w=>{Y.current&&!Y.current.contains(w.target)&&H(null)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[_]);const[Z,G]=p.useState("startTime"),[re,pe]=p.useState("desc"),ge=p.useMemo(()=>{if(v!=="table")return t;const h=[...t],w=re==="asc"?1:-1;return h.sort((L,D)=>{var ne,je;let ee,V;switch(Z){case"duration":ee=L.duration||0,V=D.duration||0;break;case"passRate":ee=((ne=L.summary)==null?void 0:ne.passRate)||0,V=((je=D.summary)==null?void 0:je.passRate)||0;break;case"status":ee=L.status||"",V=D.status||"";break;case"startTime":default:ee=new Date(L.startTime).getTime(),V=new Date(D.startTime).getTime()}return ee<V?-w:ee>V?w:0}),h},[t,Z,re,v]),C=p.useMemo(()=>{if(v==="table")return null;const h=[],w=new Map;return t.forEach(L=>{const{key:D,label:ee}=yn(L.startTime);let V=w.get(D);V===void 0&&(V=h.length,w.set(D,V),h.push({key:D,label:ee,runs:[]})),h[V].runs.push(L)}),h},[t,v]);if(!r&&t.length===0)return g?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center animate-fade-in",children:[e.jsx(zt,{size:36,className:"text-gray-600 mb-3"}),e.jsx("p",{className:"text-sm text-gray-300 mb-1",children:"No runs match the current filters"}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"Try widening the status or source filter."}),N&&e.jsx("button",{onClick:N,className:"px-4 py-2 rounded-lg bg-brand-500/15 text-brand-300 text-sm font-medium hover:bg-brand-500/25 border border-brand-500/20",children:"Clear filters"})]}):e.jsx(Ea,{title:"No Test Runs",description:"Run tests from the Runner page to see results here.",icon:e.jsx(zt,{size:28})});const R=e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 mb-2",children:[e.jsx("span",{className:"text-[11px] text-gray-500 mr-1",children:"View"}),e.jsxs("div",{className:"flex items-center gap-0.5 bg-surface-2 rounded-lg p-0.5 border border-white/5",children:[e.jsx(Ot,{active:v==="rich",onClick:()=>A("rich"),icon:e.jsx(ja,{size:11}),label:"Rich"}),e.jsx(Ot,{active:v==="compact",onClick:()=>A("compact"),icon:e.jsx(va,{size:11}),label:"Compact"}),e.jsx(Ot,{active:v==="table",onClick:()=>A("table"),icon:e.jsx(wa,{size:11}),label:"Table"})]})]});return v==="table"?e.jsxs("div",{className:"animate-fade-in",children:[R,e.jsx("div",{className:"rounded-xl border border-white/5 bg-surface-1 overflow-hidden",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"bg-surface-2/50 border-b border-white/5 text-[11px] uppercase tracking-wide text-gray-500",children:e.jsxs("tr",{children:[e.jsx(Je,{label:"Status",sortKey:"status",current:Z,dir:re,onSort:h=>{G(h),pe(w=>Z===h?w==="asc"?"desc":"asc":"desc")}}),e.jsx(Je,{label:"Run",sortKey:"startTime",current:Z,dir:re,onSort:h=>{G(h),pe(w=>Z===h?w==="asc"?"desc":"asc":"desc")}}),e.jsx(Je,{label:"Pass Rate",sortKey:"passRate",current:Z,dir:re,onSort:h=>{G(h),pe(w=>Z===h?w==="asc"?"desc":"asc":"desc")},className:"text-right"}),e.jsx(Je,{label:"Results",className:"text-right"}),e.jsx(Je,{label:"Duration",sortKey:"duration",current:Z,dir:re,onSort:h=>{G(h),pe(w=>Z===h?w==="asc"?"desc":"asc":"desc")},className:"text-right"}),e.jsx(Je,{label:"Source",className:"text-right"}),e.jsx(Je,{label:""})]})}),e.jsx("tbody",{children:ge.map(h=>{const w=h.summary||{total:0,passed:0,failed:0,skipped:0,passRate:0},L=It[h.status]||It.cancelled,D=d===h.runId,ee=Vs(h.runId);return e.jsxs("tr",{onClick:()=>a(h.runId),className:"border-b border-white/5 last:border-b-0 hover:bg-white/[0.02] cursor-pointer transition-colors",children:[e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium border ${L.pill}`,children:[h.status==="running"?e.jsx(me,{size:10,className:"animate-spin"}):e.jsx(L.icon,{size:10})," ",L.label]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[D&&e.jsx(ds,{size:11,className:"text-amber-400 fill-current"}),e.jsx("span",{className:"text-gray-200 font-medium",children:h.label||Rt(h.startTime)}),h.label&&e.jsxs("span",{className:"text-gray-600",children:["· ",Rt(h.startTime)]}),e.jsxs("span",{className:"text-gray-600 text-[11px]",children:["· ",Rr(h.startTime)]}),ee&&e.jsxs("span",{className:"ml-1 px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-300 text-[10px] flex items-center gap-1",children:[e.jsx(de,{size:9}),"AI fix"]})]})}),e.jsx("td",{className:`px-3 py-2.5 text-right font-semibold ${Tr(w.passRate)}`,children:w.total>0?`${w.passRate}%`:"—"}),e.jsxs("td",{className:"px-3 py-2.5 text-right text-gray-400",children:[e.jsx("span",{className:"text-emerald-400",children:w.passed}),e.jsx("span",{className:"text-gray-600 mx-1",children:"/"}),e.jsx("span",{className:w.failed>0?"text-red-400":"text-gray-600",children:w.failed}),e.jsx("span",{className:"text-gray-600 mx-1",children:"/"}),e.jsx("span",{className:"text-gray-500",children:w.skipped}),e.jsxs("span",{className:"text-gray-600 ml-2",children:["(",w.total,")"]})]}),e.jsx("td",{className:"px-3 py-2.5 text-right text-gray-400",children:Ir(h.duration)||"—"}),e.jsx("td",{className:"px-3 py-2.5 text-right",children:e.jsxs("span",{className:"inline-flex items-center justify-end gap-1.5 flex-wrap",children:[es[h.origin]&&(()=>{const V=es[h.origin],ne=V.icon;return e.jsxs("span",{className:`inline-flex items-center gap-1 text-[10px] font-medium ${V.variant==="amber"?"text-amber-300":V.variant==="brand"?"text-brand-300":"text-purple-300"}`,children:[e.jsx(ne,{size:10})," ",V.label]})})(),h.source==="cloud"&&!Ar(h.cloudProvider)?e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-blue-500/15 text-blue-300 text-[10px] font-medium",children:[e.jsx(tt,{size:10})," ",zr[h.cloudProvider]||h.cloudProvider||"Cloud"]}):h.source==="cloud"?e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-surface-2 text-gray-400 text-[10px] font-medium",children:[e.jsx(rt,{size:10})," Local Device"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-surface-2 text-gray-400 text-[10px] font-medium",children:[e.jsx(at,{size:10})," Local"]}),h.targetDevice?e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-surface-2 text-gray-300 text-[10px] font-medium",title:`Device: ${h.targetDevice}`,children:[e.jsx(rt,{size:10,className:"text-indigo-400"})," ",h.targetDevice]}):h.targetBrowser&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-surface-2 text-gray-300 text-[10px] font-medium",title:`Browser: ${h.targetBrowser}`,children:[e.jsx(Ke,{name:h.targetBrowser,isEnv:!1,size:10})," ",h.targetBrowser]}),h.targetEnvironment&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-surface-2 text-gray-300 text-[10px] font-medium",title:`Environment: ${h.targetEnvironment}`,children:[e.jsx(Ke,{name:h.targetEnvironment,isEnv:!0,size:10})," ",h.targetEnvironment]})]})}),e.jsx("td",{className:"px-3 py-2.5 text-right",children:e.jsx(De,{size:14,className:"text-gray-600 inline"})})]},h.runId)})})]})}),E.length>0&&e.jsx(Gs,{selected:E,onClear:()=>P([]),onCompare:n?(h,w)=>{n(h,w),P([])}:void 0})]}):e.jsxs("div",{className:"animate-fade-in",children:[R,e.jsx("div",{className:"space-y-6",children:C.map(h=>e.jsxs("div",{children:[e.jsx(wn,{label:h.label,count:h.runs.length}),e.jsx("div",{className:v==="compact"?"space-y-1.5 mt-2":"space-y-2.5 mt-2",children:h.runs.map(w=>e.jsx(Nn,{run:w,compact:v==="compact",isBaseline:d===w.runId,isSelected:E.includes(w.runId),isSelectable:E.length>0,isAiFixed:Vs(w.runId),onOpen:()=>a(w.runId),onToggleSelect:()=>U(w.runId),onCompare:()=>U(w.runId),onSetBaseline:b?()=>b(w.runId):void 0,copiedCommand:q===w.runId,onCopyCommand:L=>I(L,w.runId,w.command||""),menuOpen:_===w.runId,onToggleMenu:L=>{L.stopPropagation(),H(D=>D===w.runId?null:w.runId)},menuRef:_===w.runId?Y:void 0},w.runId))})]},h.key))}),E.length>0&&e.jsx(Gs,{selected:E,onClear:()=>P([]),onCompare:n?(h,w)=>{n(h,w),P([])}:void 0})]})}function wn({label:t,count:s}){const r=p.useRef(null),[a,l]=p.useState(!1);return p.useEffect(()=>{const i=r.current;if(!i||typeof IntersectionObserver>"u")return;let d=i.parentElement;for(;d;){const b=getComputedStyle(d).overflowY;if(b==="auto"||b==="scroll")break;d=d.parentElement}const n=new IntersectionObserver(([b])=>l(!(b!=null&&b.isIntersecting)),{root:d,threshold:0});return n.observe(i),()=>n.disconnect()},[]),e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:r,"aria-hidden":"true",className:"h-px -mt-px"}),e.jsxs("div",{className:`sticky top-0 z-20 -mx-5 px-5 py-2 flex items-center gap-2 transition-colors duration-150 ${a?"bg-surface-1 border-b border-white/10 shadow-sm":"bg-transparent border-b border-transparent"}`,children:[e.jsx("span",{className:`text-[11px] uppercase tracking-wider font-semibold ${a?"text-gray-300":"text-gray-400"}`,children:t}),e.jsx("span",{className:"text-[11px] text-gray-500",children:"·"}),e.jsxs("span",{className:"text-[11px] text-gray-500",children:[s," run",s===1?"":"s"]}),e.jsx("div",{className:"flex-1 h-px bg-white/5 ml-2"})]})]})}function Ot({active:t,onClick:s,icon:r,label:a}){return e.jsxs("button",{onClick:s,className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] font-medium transition-colors ${t?"bg-surface-1 text-gray-200 shadow-sm":"text-gray-500 hover:text-gray-300"}`,children:[r," ",a]})}function Je({label:t,sortKey:s,current:r,dir:a,onSort:l,className:i}){const d=!!s&&!!l,n=s&&r===s;return e.jsx("th",{onClick:d?()=>l(s):void 0,className:`px-3 py-2 text-left font-semibold ${d?"cursor-pointer hover:text-gray-300 select-none":""} ${i||""}`,children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[t,n&&(a==="asc"?e.jsx(nr,{size:10}):e.jsx(lr,{size:10}))]})})}function Gs({selected:t,onClear:s,onCompare:r}){return e.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-30 bg-surface-1 border border-white/10 rounded-full shadow-2xl px-4 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-gray-300",children:t.length===1?"Select one more run to compare":`Compare ${t.length} runs`}),e.jsx("div",{className:"h-4 w-px bg-white/10"}),e.jsxs("button",{onClick:()=>{t.length===2&&r&&r(t[0],t[1])},disabled:t.length<2||!r,className:"flex items-center gap-1.5 px-3 py-1 rounded-full bg-brand-500/20 hover:bg-brand-500/30 text-brand-200 text-xs font-medium border border-brand-500/30 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(dr,{size:11})," Compare"]}),e.jsx("button",{onClick:s,className:"text-xs text-gray-500 hover:text-gray-300",children:"Clear"})]})}function Nn(t){const{run:s,compact:r,isBaseline:a,isSelected:l,isAiFixed:i,onOpen:d,onToggleSelect:n,onCompare:b,onSetBaseline:g,copiedCommand:N,onCopyCommand:k,menuOpen:T,onToggleMenu:f,menuRef:v}=t,A=s.summary||{total:0,passed:0,failed:0,skipped:0,passRate:0},E=A.total||1,P=A.passed/E*100,U=A.failed/E*100,q=A.skipped/E*100,x=It[s.status]||It.cancelled,I=s.status==="failed"?"shadow-[0_0_0_1px_rgba(239,68,68,0.15),0_4px_16px_rgba(239,68,68,0.04)]":s.status==="running"?"shadow-[0_0_0_1px_rgba(245,158,11,0.20)]":"";return e.jsxs("div",{onClick:d,className:`group relative w-full text-left bg-surface-1 rounded-xl border ${l?"border-brand-500/40 bg-brand-500/[0.03]":"border-white/5"} hover:border-white/15 hover:bg-surface-2/40 transition-all cursor-pointer overflow-hidden ${I}`,children:[i&&e.jsx("div",{className:"absolute inset-x-0 top-0 h-[2px] bg-gradient-to-r from-emerald-500/0 via-emerald-400/60 to-emerald-500/0"}),e.jsx("button",{onClick:_=>{_.stopPropagation(),n()},className:`absolute top-2 left-2.5 z-10 w-4 h-4 rounded border transition-all flex items-center justify-center ${l?"bg-brand-500 border-brand-500 opacity-100":"border-white/20 bg-surface-1/80 backdrop-blur-sm hover:border-white/40 opacity-0 group-hover:opacity-100"}`,title:l?"Deselect":"Select to compare",children:l&&e.jsx(Se,{size:10,className:"text-white"})}),e.jsxs("div",{className:`flex items-center gap-4 ${r?"p-3 pl-5":"p-4 pl-5"}`,children:[e.jsx(jn,{rate:A.passRate||0,total:A.total||0,size:r?44:56,stroke:r?4:5}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[a&&e.jsx("span",{title:"Baseline",className:"flex-shrink-0",children:e.jsx(ds,{size:12,className:"text-amber-400 fill-current"})}),e.jsx("span",{className:"text-sm font-semibold text-gray-100 truncate",children:s.label||Rt(s.startTime)}),s.label&&e.jsx("span",{className:"text-[11px] text-gray-500",children:Rt(s.startTime)}),e.jsxs("span",{className:"text-[11px] text-gray-600",children:["· ",Rr(s.startTime)]}),e.jsxs("span",{className:`ml-auto inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium border ${x.pill}`,children:[s.status==="running"?e.jsx(me,{size:10,className:"animate-spin"}):e.jsx(x.icon,{size:10})," ",x.label]})]}),s.command&&!r&&e.jsxs("div",{className:"flex items-center gap-1.5 mb-2 min-w-0",children:[e.jsx(ot,{size:11,className:"text-gray-600 flex-shrink-0"}),e.jsx("code",{className:"text-[11px] text-gray-400 font-mono truncate min-w-0",title:s.command,children:s.command}),e.jsx("button",{onClick:k,title:"Copy command",className:"flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity text-gray-500 hover:text-gray-300 ml-0.5",children:N?e.jsx(Se,{size:11,className:"text-emerald-400"}):e.jsx(Ye,{size:11})})]}),A.total>0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1 flex h-1.5 rounded-full overflow-hidden bg-surface-2 min-w-[80px]",children:[A.passed>0&&e.jsx("div",{className:"bg-gradient-to-r from-emerald-500/60 to-emerald-400/40",style:{width:`${P}%`}}),A.failed>0&&e.jsx("div",{className:"bg-gradient-to-r from-red-500/60 to-red-400/40",style:{width:`${U}%`}}),A.skipped>0&&e.jsx("div",{className:"bg-gray-600/40",style:{width:`${q}%`}})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0 text-sm",children:[e.jsxs("span",{className:"text-emerald-300 flex items-center gap-1 font-medium",children:[e.jsx(st,{size:13})," ",A.passed]}),A.failed>0&&e.jsxs("span",{className:"text-red-300 flex items-center gap-1 font-medium",children:[e.jsx(ze,{size:13})," ",A.failed]}),A.skipped>0&&e.jsxs("span",{className:"text-gray-400 flex items-center gap-1 font-medium",children:[e.jsx(Xe,{size:13})," ",A.skipped]}),e.jsxs("span",{className:"text-gray-500 text-xs",children:["· ",A.total," total"]}),s.duration&&e.jsxs("span",{className:"text-gray-300 flex items-center gap-1 ml-1 font-medium",children:[e.jsx(Qe,{size:13})," ",Ir(s.duration)]})]})]}),r&&(s.targetBrowser||s.targetEnvironment)&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 flex-wrap",children:[s.targetBrowser&&e.jsxs(Le,{children:[e.jsx(Ke,{name:s.targetBrowser,isEnv:!1,size:11})," ",s.targetBrowser]}),s.targetEnvironment&&e.jsxs(Le,{children:[e.jsx(Ke,{name:s.targetEnvironment,isEnv:!0,size:11})," ",s.targetEnvironment]})]}),!r&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-3 flex-wrap",children:[s.framework&&e.jsx(Le,{children:s.framework}),s.source==="cloud"&&!Ar(s.cloudProvider)?e.jsxs(Le,{variant:"cloud",children:[e.jsx(tt,{size:11})," ",zr[s.cloudProvider]||s.cloudProvider||"Cloud"]}):s.source==="cloud"?e.jsxs(Le,{children:[e.jsx(rt,{size:11})," Local Device"]}):e.jsxs(Le,{children:[e.jsx(at,{size:11})," Local"]}),e.jsx(kn,{origin:s.origin}),s.targetBrowser&&e.jsxs(Le,{children:[e.jsx(Ke,{name:s.targetBrowser,isEnv:!1,size:11})," ",s.targetBrowser]}),s.targetEnvironment&&e.jsxs(Le,{children:[e.jsx(Ke,{name:s.targetEnvironment,isEnv:!0,size:11})," ",s.targetEnvironment]}),s.cloudBuildName&&e.jsxs(Le,{variant:"amber",children:[e.jsx(xs,{size:11})," ",s.cloudBuildName]}),s.hasAnalysis&&e.jsxs(Le,{variant:"purple",children:[e.jsx(de,{size:11})," Analyzed"]}),i&&e.jsxs(Le,{variant:"emerald",children:[e.jsx(de,{size:11})," Has AI Fix"]})]})]}),e.jsxs("div",{className:"flex flex-col items-center gap-1 flex-shrink-0 relative",children:[b&&e.jsx("button",{onClick:_=>{_.stopPropagation(),b()},className:`p-1.5 rounded-md hover:bg-white/5 transition-all opacity-0 group-hover:opacity-100 ${l?"text-brand-300 opacity-100":"text-gray-500 hover:text-gray-200"}`,title:l?"Remove from compare selection":"Add to compare selection",children:e.jsx(dr,{size:14})}),e.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Cn,{menuOpen:T,onToggleMenu:f,menuRef:v,isBaseline:a,onSetBaseline:g,command:s.command,copiedCommand:N,onCopyCommand:k,onOpen:d})}),e.jsx(De,{size:14,className:"text-gray-600"})]})]})]})}function kn({origin:t}){const s=t?es[t]:void 0;if(!s)return null;const r=s.icon,a=s.variant==="amber"?"text-amber-300 border-amber-500/30":s.variant==="brand"?"text-brand-300 border-brand-500/30":"text-purple-300 border-purple-500/30";return e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium border ${a}`,children:[e.jsx(r,{size:11})," ",s.label]})}function Le({children:t,className:s,variant:r="neutral"}){const a={neutral:"bg-white/[0.06] text-gray-200 border-white/15",cloud:"bg-sky-500/15 text-sky-200 border-sky-500/30",amber:"bg-amber-500/15 text-amber-200 border-amber-500/30",purple:"bg-purple-500/15 text-purple-200 border-purple-500/30",emerald:"bg-emerald-500/15 text-emerald-200 border-emerald-500/30"}[r];return e.jsx("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium border ${s||a}`,children:t})}function Cn({menuOpen:t,onToggleMenu:s,menuRef:r,isBaseline:a,onSetBaseline:l,command:i,copiedCommand:d,onCopyCommand:n,onOpen:b}){const g=p.useRef(null),[N,k]=p.useState(null);return p.useEffect(()=>{if(!t||!g.current){k(null);return}const T=g.current.getBoundingClientRect();k({top:T.bottom+6,right:Math.max(8,window.innerWidth-T.right)})},[t]),e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:g,onClick:s,className:"p-1.5 rounded-md hover:bg-white/5 text-gray-500 hover:text-gray-200",title:"More actions",children:e.jsx(Na,{size:14})}),t&&N&&qs.createPortal(e.jsxs("div",{ref:r,style:{position:"fixed",top:N.top,right:N.right},className:"w-48 bg-surface-1 border border-white/10 rounded-lg shadow-2xl z-[100] py-1",onClick:T=>T.stopPropagation(),children:[l&&e.jsx(Ut,{icon:e.jsx(ds,{size:11}),onClick:T=>{T.stopPropagation(),l()},children:a?"Clear baseline":"Set as baseline"}),i&&e.jsx(Ut,{icon:d?e.jsx(Se,{size:11,className:"text-emerald-400"}):e.jsx(Ye,{size:11}),onClick:n,children:d?"Copied!":"Copy command"}),e.jsx(Ut,{icon:e.jsx(De,{size:11}),onClick:T=>{T.stopPropagation(),b()},children:"Open detail"})]}),document.body)]})}function Ut({icon:t,onClick:s,children:r}){return e.jsxs("button",{onClick:s,className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-gray-300 hover:bg-white/5 text-left",children:[t," ",r]})}function $n({runId1:t,runId2:s,run1Label:r,run2Label:a,onClose:l}){const[i,d]=p.useState(null),[n,b]=p.useState(!0),[g,N]=p.useState(null),[k,T]=p.useState("regressions");p.useEffect(()=>{b(!0),N(null),Yr(t,s).then(d).catch(x=>N((x==null?void 0:x.message)||"Failed to load comparison")).finally(()=>b(!1))},[t,s]);const f=x=>x<1e3?`${x}ms`:x<6e4?`${(x/1e3).toFixed(1)}s`:`${(x/6e4).toFixed(1)}m`,v=r||`#${t.slice(0,8)}`,A=a||`#${s.slice(0,8)}`;if(n)return e.jsxs("div",{className:"flex items-center justify-center py-20",children:[e.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-brand-500 border-t-transparent rounded-full"}),e.jsx("span",{className:"ml-3 text-sm text-gray-400",children:"Comparing runs..."})]});if(g||!i)return e.jsx("div",{className:"text-center py-12 text-red-400 text-sm",children:g||"Comparison data not available"});const E=i.summary.deltaPassRate,P=E>0?"text-emerald-400":E<0?"text-red-400":"text-gray-400",U=E>0?Xt:E<0?ka:Ca,q=[{key:"regressions",label:"Regressions",icon:ze,color:"text-red-400",bgColor:"bg-red-500/10",borderColor:"border-red-500/20",count:i.regressions.length,items:i.regressions},{key:"newFailures",label:"New Failures",icon:Ue,color:"text-amber-400",bgColor:"bg-amber-500/10",borderColor:"border-amber-500/20",count:i.newFailures.length,items:i.newFailures},{key:"fixed",label:"Fixed",icon:st,color:"text-emerald-400",bgColor:"bg-emerald-500/10",borderColor:"border-emerald-500/20",count:i.fixed.length,items:i.fixed.map(x=>({name:x}))},{key:"newPasses",label:"New Passes",icon:Xt,color:"text-cyan-400",bgColor:"bg-cyan-500/10",borderColor:"border-cyan-500/20",count:i.newPasses.length,items:i.newPasses.map(x=>({name:x}))}];return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xr,{size:16,className:"text-brand-400"}),e.jsx("span",{className:"text-sm font-medium text-gray-200",children:"Run Comparison"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[v," ",e.jsx("span",{className:"text-gray-600",children:"vs"})," ",A]})]}),e.jsx("button",{onClick:l,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-300 hover:bg-white/5",children:e.jsx(dt,{size:14})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 p-4 rounded-xl bg-surface-1 border border-white/5",children:[e.jsxs("div",{className:"text-center flex-1",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Baseline"}),e.jsxs("div",{className:"text-2xl font-bold text-gray-200",children:[i.summary.run1PassRate,"%"]}),e.jsx("div",{className:"text-[10px] text-gray-600",children:v})]}),e.jsxs("div",{className:"text-center px-4",children:[e.jsx(U,{size:20,className:P}),e.jsxs("div",{className:`text-sm font-bold ${P}`,children:[E>=0?"+":"",E,"%"]})]}),e.jsxs("div",{className:"text-center flex-1",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Current"}),e.jsxs("div",{className:"text-2xl font-bold text-gray-200",children:[i.summary.run2PassRate,"%"]}),e.jsx("div",{className:"text-[10px] text-gray-600",children:A})]})]}),e.jsx("div",{className:"grid grid-cols-4 gap-2",children:q.map(x=>e.jsxs("div",{className:`text-center p-3 rounded-lg ${x.bgColor} border ${x.borderColor}`,children:[e.jsx("div",{className:`text-xl font-bold ${x.color}`,children:x.count}),e.jsx("div",{className:"text-[10px] text-gray-400",children:x.label})]},x.key))}),q.filter(x=>x.count>0).map(x=>{const I=x.icon,_=k===x.key;return e.jsxs("div",{className:`rounded-xl border ${x.borderColor} overflow-hidden`,children:[e.jsxs("button",{onClick:()=>T(_?null:x.key),className:`w-full flex items-center gap-2.5 px-4 py-2.5 ${x.bgColor} hover:bg-white/5 transition-colors`,children:[e.jsx(I,{size:14,className:x.color}),e.jsx("span",{className:`text-sm font-medium ${x.color}`,children:x.label}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",x.count,")"]}),e.jsx("span",{className:"ml-auto",children:_?e.jsx(Ns,{size:14,className:"text-gray-500"}):e.jsx(Oe,{size:14,className:"text-gray-500"})})]}),_&&e.jsx("div",{className:"bg-surface-1",children:x.items.map((H,Y)=>e.jsxs("div",{className:"flex items-start gap-2 px-4 py-2 border-t border-white/[0.03] text-sm",children:[e.jsx("span",{className:"text-gray-300 flex-1 min-w-0 truncate",title:H.name,children:Ee(H.name)}),H.error&&e.jsx("span",{className:"text-xs text-gray-600 max-w-[300px] truncate flex-shrink-0",children:H.error})]},Y))})]},x.key)}),i.durationChanges.length>0&&e.jsxs("div",{className:"rounded-xl border border-white/10 overflow-hidden",children:[e.jsxs("button",{onClick:()=>T(k==="duration"?null:"duration"),className:"w-full flex items-center gap-2.5 px-4 py-2.5 bg-surface-1 hover:bg-white/5 transition-colors",children:[e.jsx(Qe,{size:14,className:"text-amber-400"}),e.jsx("span",{className:"text-sm font-medium text-amber-400",children:"Duration Changes"}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",i.durationChanges.length,")"]}),e.jsx("span",{className:"ml-auto",children:k==="duration"?e.jsx(Ns,{size:14,className:"text-gray-500"}):e.jsx(Oe,{size:14,className:"text-gray-500"})})]}),k==="duration"&&e.jsxs("div",{className:"bg-surface-1",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_80px_80px_80px] gap-0 px-4 py-1.5 text-[10px] font-semibold text-gray-500 uppercase tracking-wider border-t border-white/5",children:[e.jsx("span",{children:"Test"}),e.jsx("span",{className:"text-right",children:"Before"}),e.jsx("span",{className:"text-right",children:"After"}),e.jsx("span",{className:"text-right",children:"Change"})]}),i.durationChanges.map((x,I)=>e.jsxs("div",{className:"grid grid-cols-[1fr_80px_80px_80px] gap-0 px-4 py-2 border-t border-white/[0.03] text-sm",children:[e.jsx("span",{className:"text-gray-300 truncate pr-2",title:x.name,children:Ee(x.name)}),e.jsx("span",{className:"text-right text-gray-500 text-xs",children:f(x.before)}),e.jsx("span",{className:"text-right text-gray-500 text-xs",children:f(x.after)}),e.jsxs("span",{className:`text-right text-xs font-medium ${x.deltaPercent>0?"text-red-400":"text-emerald-400"}`,children:[x.deltaPercent>0?"+":"",x.deltaPercent,"%"]})]},I))]})]}),i.regressions.length===0&&i.newFailures.length===0&&i.fixed.length===0&&i.newPasses.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 text-sm",children:"No significant differences between these runs."})]})]})}const Sn={browserstack:"BS",lambdatest:"LT",saucelabs:"SL"};function zn({name:t}){var n,b;const{data:s}=Ve({queryKey:["run-commands-config"],queryFn:Zr,staleTime:3e4}),r=(((b=(n=s==null?void 0:s.configured)==null?void 0:n.environments)==null?void 0:b.options)||[]).find(g=>g.name===t),a=(r==null?void 0:r.value)||"",[l,i]=p.useState(!1),d=async()=>{if(a)try{await navigator.clipboard.writeText(a),i(!0),setTimeout(()=>i(!1),1200)}catch{}};return e.jsxs("button",{type:"button",onClick:d,disabled:!a,title:a?`${a}
|
|
115
|
-
Click to copy`:t,className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl bg-surface-2/50 border border-white/5 hover:border-white/15 disabled:cursor-default transition-colors",children:[e.jsx(Ke,{name:t,isEnv:!0,size:12}),e.jsx("span",{className:"text-sm text-gray-400",children:t}),a&&(l?e.jsx(Se,{size:11,className:"text-emerald-400"}):e.jsx(Ye,{size:11,className:"text-gray-500"}))]})}function An({view:t,setView:s}){const r=(a,l,i)=>e.jsxs("button",{onClick:()=>s(a),className:`flex items-center gap-1.5 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${t===a?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200 hover:border-white/10"}`,children:[i,l]});return e.jsxs("div",{className:"flex items-center gap-1 px-5 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[r("runs","Runs",e.jsx(zt,{size:15})),r("auto-heal","Auto-Heal",e.jsx(de,{size:15}))]})}function et({label:t,icon:s,active:r,onClick:a,activeColor:l}){return e.jsxs("button",{onClick:a,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-sm font-medium border transition-colors ${r?l||"text-brand-300 bg-brand-500/15 border-brand-500/30":"text-gray-500 bg-transparent border-transparent hover:text-gray-300 hover:bg-white/5"}`,children:[s,t]})}function Be({label:t,value:s,icon:r,color:a}){return e.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 rounded-xl bg-surface-2/50 border border-white/5",children:[r&&e.jsx("span",{className:a||"text-gray-400",children:r}),e.jsx("span",{className:`text-[15px] font-bold ${a||"text-gray-200"}`,children:s}),e.jsx("span",{className:"text-[13px] text-gray-500",children:t})]})}function Tn({command:t}){const[s,r]=p.useState(!1),a=l=>{l.stopPropagation(),navigator.clipboard.writeText(t).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})};return e.jsx("button",{onClick:a,title:s?"Copied!":"Copy command",className:"flex-shrink-0 p-1 rounded text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:s?e.jsx(Se,{size:12,className:"text-emerald-400"}):e.jsx(Ye,{size:12})})}function ts({url:t,onClose:s}){return t?e.jsxs("div",{className:"fixed inset-0 bg-black/90 z-50 flex flex-col",onClick:s,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-white/10 bg-surface-1/80 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xt,{size:16,className:"text-white"}),e.jsx("span",{className:"text-sm font-semibold text-white",children:"Cloud Recording"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),className:"px-2.5 py-1 text-[11px] text-white/70 hover:text-white rounded-md hover:bg-white/5 transition-colors",children:"Open in new tab ↗"}),e.jsx("button",{onClick:s,className:"p-1.5 text-white/70 hover:text-red-400 transition-colors rounded-lg hover:bg-white/5","aria-label":"Close video",children:e.jsx(ze,{size:18})})]})]}),e.jsx("div",{className:"flex-1 min-h-0 flex items-center justify-center p-6",onClick:r=>r.stopPropagation(),children:e.jsx("video",{src:t,controls:!0,autoPlay:!0,className:"h-full w-full object-contain rounded-xl"},t)})]}):null}function In(t){if(!t)return"";const s=Date.parse(t);if(!Number.isFinite(s))return"";const r=Date.now()-s,a=Math.floor(r/6e4);if(a<1)return"just now";if(a<60)return`${a} min ago`;const l=Math.floor(a/60);if(l<24)return`${l}h ago`;const i=new Date(s),d=new Date;return d.setDate(d.getDate()-1),i.toDateString()===d.toDateString()?"yesterday":i.toLocaleDateString("en-US",{month:"short",day:"numeric"})}const Rn={chromium:"bg-blue-400",firefox:"bg-orange-400",webkit:"bg-purple-400"};function Fn({buildName:t,currentRunId:s,runs:r,onSelect:a}){const[l,i]=p.useState(!1),d=p.useMemo(()=>r.filter(n=>n.cloudProvider==="testver-grid"&&n.cloudBuildName===t).sort((n,b)=>Date.parse(b.startTime||0)-Date.parse(n.startTime||0)),[r,t]);return d.length<2?null:e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>i(n=>!n),className:`flex items-center gap-2 px-3.5 py-2 rounded-xl border transition-colors ${l?"bg-surface-2 border-white/15 text-gray-200":"bg-surface-2/50 border-white/5 text-gray-300 hover:border-white/15"}`,children:[e.jsx(cs,{size:11,className:"text-emerald-400"}),e.jsxs("span",{className:"text-sm",children:["Matrix ",e.jsx("span",{className:"text-gray-500",children:"·"})," ",e.jsxs("span",{className:"font-medium",children:["“",t,"”"]})]}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-md bg-white/10 text-gray-400",children:d.length}),e.jsx(Oe,{size:12,className:`text-gray-500 transition-transform ${l?"rotate-180":""}`})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>i(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-2 z-50 w-[340px] rounded-xl border border-white/10 bg-surface-1 shadow-2xl overflow-hidden",children:[e.jsxs("div",{className:"px-3.5 py-2.5 border-b border-white/5 text-[10px] font-semibold uppercase tracking-wide text-gray-500",children:["Runs in build “",t,"”"]}),e.jsx("div",{className:"max-h-72 overflow-y-auto py-1",children:d.map(n=>{var k;const b=n.runId===s,g=(((k=n.summary)==null?void 0:k.failed)??0)>0,N=n.status==="running";return e.jsxs("button",{disabled:b,onClick:()=>{i(!1),a(n.runId)},className:`w-full flex items-center gap-2.5 px-3.5 py-2.5 text-left transition-colors ${b?"bg-white/[0.03] cursor-default":"hover:bg-white/5"}`,children:[e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${N?"bg-blue-400 animate-pulse":g?"bg-red-400":"bg-emerald-400"}`}),e.jsxs("span",{className:"flex items-center gap-1.5 w-24 shrink-0",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Rn[n.gridBrowser]||"bg-gray-400"}`}),e.jsx("span",{className:"text-sm text-gray-200 capitalize",children:n.gridBrowser||"run"})]}),e.jsxs("span",{className:"text-xs text-gray-500 flex-1",children:[N?"running…":n.summary?`${n.summary.passed??0}/${(n.summary.passed??0)+(n.summary.failed??0)+(n.summary.skipped??0)} passed`:n.status,typeof n.duration=="number"&&!N&&e.jsxs("span",{className:"text-gray-600",children:[" · ",(n.duration/1e3).toFixed(1),"s"]})]}),e.jsx("span",{className:"text-[11px] text-gray-500 shrink-0",children:In(n.startTime)}),b&&e.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wide text-emerald-400 bg-emerald-500/10 border border-emerald-500/20 rounded px-1.5 py-0.5 shrink-0",children:"current"})]},n.runId)})})]})]})]})}function En(){var Ge,Q,be,Fe,Ne,Te,ut,u,M,ce,he,Ze;const{data:t}=Ve({queryKey:["auto-heal-config"],queryFn:ns,staleTime:6e4}),[s,r]=p.useState(0),[a,l]=p.useState(20),[i,d]=p.useState(()=>{try{const m=localStorage.getItem("testver:results:viewMode");return m==="compact"||m==="table"||m==="rich"?m:"rich"}catch{return"rich"}});p.useEffect(()=>{try{localStorage.setItem("testver:results:viewMode",i)}catch{}},[i]);const[n,b]=p.useState("all"),[g,N]=p.useState("all"),k=p.useMemo(()=>({status:n!=="all"?n:void 0,source:g==="cloud"||g==="local"?g:void 0}),[n,g]),{data:T,refetch:f}=Hr(a,s*a,k),{data:v}=Br(k.source),A=(T==null?void 0:T.runs)||[],E=(T==null?void 0:T.total)||0,P=Math.max(1,Math.ceil(E/a)),U=m=>{l(m),r(0)},q=m=>{b(m),r(0)},x=m=>{N(m),r(0)},[I,_]=ys("runId"),[H]=ys("testId"),[Y,Z]=Or("analysis"),G=Ur(),[re,pe]=_r("view",["runs","auto-heal"],"runs"),[ge,C]=p.useState(!1),[R,h]=p.useState(!1),[w,L]=p.useState(null),[D,ee]=p.useState(!1),[V,ne]=p.useState(null),[je,o]=p.useState({}),{toast:$}=Ws(),O=Ft(),[le,oe]=p.useState(!1),[fe,ke]=p.useState(null),[xe,Ie]=p.useState(null),[Ae,Re]=p.useState(null);p.useEffect(()=>{let m=!1;return Xr().then(z=>{!m&&z.baseline&&Ie(z.baseline.runId)}).catch(()=>{}),()=>{m=!0}},[]);const W=I,He=fe&&W&&fe.forRun===W?fe.target:null,Me=(m,z=W)=>ke(m&&z?{target:m,forRun:z}:null),{data:c}=as(W),{data:Ce}=Qr(W),y=c==null?void 0:c.origin,S=(y==="suite"||y==="ci")&&(c==null?void 0:c.status)==="running"&&!!(c!=null&&c.suiteId),F=(y==="testplan"||y==="ci"&&!(c!=null&&c.suiteId))&&(c==null?void 0:c.status)==="running"&&!!(c!=null&&c.cycleId),{data:B}=ms(),j=!!(B!=null&&B.hideNames),K=p.useMemo(()=>{var m,z,se,ye,_e;return{totalRuns:((m=v==null?void 0:v.stats)==null?void 0:m.totalRuns)??0,failedRuns:((z=v==null?void 0:v.stats)==null?void 0:z.failedRuns)??0,completedRuns:((se=v==null?void 0:v.status)==null?void 0:se.completed)??0,avgPassRate:((ye=v==null?void 0:v.stats)==null?void 0:ye.avgPassRate)??0,avgDuration:((_e=v==null?void 0:v.stats)==null?void 0:_e.avgDurationSec)??0}},[v]),X=p.useMemo(()=>{var m,z,se,ye;return{all:((m=v==null?void 0:v.status)==null?void 0:m.all)??0,completed:((z=v==null?void 0:v.status)==null?void 0:z.completed)??0,failed:((se=v==null?void 0:v.status)==null?void 0:se.failed)??0,running:((ye=v==null?void 0:v.status)==null?void 0:ye.running)??0}},[v]),te=p.useMemo(()=>{var m,z,se;return{all:((m=v==null?void 0:v.source)==null?void 0:m.all)??0,local:((z=v==null?void 0:v.source)==null?void 0:z.local)??0,cloud:((se=v==null?void 0:v.source)==null?void 0:se.cloud)??0}},[v]),ue=A,ie=m=>m>=90?"text-emerald-400":m>=70?"text-amber-400":"text-red-400",ae=async()=>{if(W){C(!0);try{const m=await Js(W);m.artifacts?($("success",m.message),O.invalidateQueries({queryKey:["result-run",W]})):$("info",m.message)}catch(m){$("error",`Failed to fetch artifacts: ${m}`)}finally{C(!1)}}},we=(c==null?void 0:c.childRuns)||[];p.useEffect(()=>{L(null),ne(null),o({})},[W]);const nt=async m=>{const z=je[m];if(z!==void 0){ne(m),L(z);return}const se=await Vt(m);o(ye=>({...ye,[m]:se.output})),ne(m),L(se.output)};if(!I)return e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",children:[e.jsx(An,{view:re,setView:pe}),re==="auto-heal"?e.jsx(Oa,{}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsx(zt,{size:22,className:"text-brand-400 flex-shrink-0"}),e.jsx("h1",{className:"text-xl font-bold text-gray-100 flex-shrink-0",children:"Test Results"}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-4",children:[e.jsx(et,{label:`All ${X.all}`,active:n==="all",onClick:()=>q("all")}),e.jsx(et,{label:`Passed ${X.completed}`,icon:e.jsx(st,{size:12}),active:n==="completed",onClick:()=>q("completed"),activeColor:"text-emerald-300 bg-emerald-500/15 border-emerald-500/30"}),e.jsx(et,{label:`Failed ${X.failed}`,icon:e.jsx(ze,{size:12}),active:n==="failed",onClick:()=>q("failed"),activeColor:"text-red-300 bg-red-500/15 border-red-500/30"}),X.running>0&&e.jsx(et,{label:`Running ${X.running}`,icon:e.jsx(at,{size:12}),active:n==="running",onClick:()=>q("running"),activeColor:"text-amber-300 bg-amber-500/15 border-amber-500/30"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-2",children:[e.jsx($a,{size:13,className:"text-gray-600"}),e.jsx(et,{label:`All ${te.all}`,active:g==="all",onClick:()=>x("all")}),e.jsx(et,{label:`Local ${te.local}`,icon:e.jsx(at,{size:12}),active:g==="local",onClick:()=>x("local")}),e.jsx(et,{label:`Cloud ${te.cloud}`,icon:e.jsx(tt,{size:12}),active:g==="cloud",onClick:()=>x("cloud"),activeColor:"text-blue-300 bg-blue-500/15 border-blue-500/30"})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-gray-600",children:[E," run",E===1?"":"s",(n!=="all"||g!=="all")&&e.jsx("span",{className:"ml-1 text-gray-500",children:"(filtered)"})]}),e.jsx("button",{onClick:()=>f(),className:"p-2 rounded-xl hover:bg-white/5 text-gray-500 hover:text-gray-300 transition-colors",title:"Refresh",children:e.jsx(ar,{size:16})})]})]}),e.jsxs("div",{className:"flex items-stretch gap-2 px-4 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsx(Be,{label:"Total Runs",value:K.totalRuns,icon:e.jsx(Yt,{size:11})}),e.jsx(Be,{label:"Avg Pass Rate",value:K.totalRuns>0?`${K.avgPassRate}%`:"-",icon:e.jsx(Xt,{size:11}),color:K.totalRuns>0?ie(K.avgPassRate):"text-gray-500"}),e.jsx(Be,{label:"Failed",value:K.failedRuns,icon:e.jsx(ze,{size:11}),color:K.failedRuns>0?"text-red-400":"text-gray-500"}),e.jsx(Be,{label:"Avg Duration",value:K.avgDuration>0?`${K.avgDuration}s`:"-",icon:e.jsx(Qe,{size:11})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-5 pb-5",children:e.jsx(vn,{runs:ue,total:(T==null?void 0:T.total)||0,isLoading:!T,onSelectRun:m=>{G({runId:m,testId:null})},viewMode:i,onViewModeChange:d,baselineRunId:xe,onCompareRuns:(m,z)=>{Me(m,z),G({runId:z,testId:null})},onSetBaseline:async m=>{if(m===xe){try{await js()}catch{}Ie(null)}else{try{await vs(m)}catch{}Ie(m)}},filtersActive:n!=="all"||g!=="all",onClearFilters:()=>{q("all"),x("all")}})}),E>0&&e.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 border-t border-white/5 bg-surface-1 flex-shrink-0 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[e.jsx("span",{children:"Rows per page:"}),e.jsxs("select",{value:a,onChange:m=>U(Number(m.target.value)),className:"bg-surface-2 border border-white/10 rounded px-2 py-1 text-gray-300 focus:outline-none focus:border-brand-500/40",children:[e.jsx("option",{value:10,children:"10"}),e.jsx("option",{value:20,children:"20"}),e.jsx("option",{value:50,children:"50"}),e.jsx("option",{value:100,children:"100"}),e.jsx("option",{value:200,children:"200"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[e.jsx("span",{children:E===0?"0 runs":`Showing ${s*a+1}–${Math.min((s+1)*a,E)} of ${E} run${E===1?"":"s"}`}),e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsx("button",{onClick:()=>r(0),disabled:s===0,title:"First page",className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"«"}),e.jsx("button",{onClick:()=>r(m=>Math.max(0,m-1)),disabled:s===0,title:"Previous page",className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"‹ Prev"}),e.jsxs("span",{className:"px-2 text-gray-400",children:["Page ",e.jsx("span",{className:"text-gray-200 font-medium",children:s+1})," of ",P]}),e.jsx("button",{onClick:()=>r(m=>Math.min(P-1,m+1)),disabled:s>=P-1,title:"Next page",className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"Next ›"}),e.jsx("button",{onClick:()=>r(P-1),disabled:s>=P-1,title:"Last page",className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"»"})]})]})]})]})]});const J=A.find(m=>{var z;return I&&((z=m.runId)==null?void 0:z.toLowerCase())===I.toLowerCase()});if(H&&c){let m=null;const z=H.lastIndexOf("::");if(z>0){const se=parseInt(H.slice(z+2),10);!isNaN(se)&&((Ge=c.tests)!=null&&Ge[se])&&(m=c.tests[se])}if(!m){const se=z>0?H.slice(0,z):H;m=(Q=c.tests)==null?void 0:Q.find(ye=>ye.name===se)}return e.jsxs("div",{className:"h-full flex flex-col animate-fade-in overflow-y-auto",children:[e.jsx(rn,{test:m,projectPath:c.projectPath,runId:(m==null?void 0:m.childRunId)||I||void 0,isChildRun:!!(m!=null&&m.childRunId),onClose:()=>G({testId:null}),onOpenFailureAnalysis:m!=null&&m.name?()=>G({testId:null,analysis:"1",focusTest:m.name}):void 0,displayBrowser:c==null?void 0:c.targetBrowser,displayDevice:c==null?void 0:c.targetDevice,onOpenVideo:se=>{Re(er(se))}}),e.jsx(ts,{url:Ae,onClose:()=>Re(null)})]})}return e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>{G({runId:null,testId:null,analysis:null,focusTest:null})},className:"flex items-center gap-1.5 text-sm text-gray-400 hover:text-gray-200 transition-colors flex-shrink-0",children:[e.jsx(Sa,{size:16}),"Back"]}),e.jsx("span",{className:"text-gray-700 flex-shrink-0",children:"|"}),e.jsx("span",{className:"text-sm text-gray-300 font-medium flex-shrink-0",children:J?J.label||it(J.startTime):"Run Details"}),J&&e.jsx("span",{className:`px-2 py-0.5 rounded-lg text-[11px] font-medium flex-shrink-0 ${J.status==="completed"?"bg-emerald-500/15 text-emerald-400":J.status==="failed"?"bg-red-500/15 text-red-400":J.status==="running"?"bg-amber-500/15 text-amber-400":"bg-gray-500/15 text-gray-400"}`,children:J.status}),(J==null?void 0:J.origin)==="suite"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg text-[11px] font-medium flex-shrink-0 bg-brand-500/15 text-brand-300 border border-brand-500/30 inline-flex items-center gap-1",children:[e.jsx(Yt,{size:11})," Suite"]}),(J==null?void 0:J.origin)==="ci"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg text-[11px] font-medium flex-shrink-0 bg-blue-500/15 text-blue-300 border border-blue-500/30 inline-flex items-center gap-1",title:[J.ciProvider,J.ciPipeline,J.gitBranch,(be=J.gitCommitSha)==null?void 0:be.slice(0,7)].filter(Boolean).join(" · "),children:[e.jsx(Kt,{size:11})," CI",J.ciPipeline?` · ${J.ciPipeline}`:"",J.ciBuildNumber?` #${J.ciBuildNumber}`:""]}),(J==null?void 0:J.ciBuildUrl)&&e.jsxs("a",{href:J.ciBuildUrl,target:"_blank",rel:"noopener noreferrer",className:"px-2 py-0.5 rounded-lg text-[11px] font-medium flex-shrink-0 text-gray-400 hover:text-blue-300 border border-white/10 hover:border-blue-500/30 inline-flex items-center gap-1 transition-colors",children:[e.jsx(ve,{size:10})," CI build"]}),(()=>{const m=(c==null?void 0:c.tests)??[],z={healed:0,suggested:0,reverted:0,undone:0,expired:0};for(const ye of m){const _e=ye.autoHeal;_e&&(_e.state==="suggested"&&wr(_e.at,t==null?void 0:t.reviewWindowDays)?z.expired++:z[_e.state]++)}if(z.healed+z.suggested+z.reverted+z.undone+z.expired===0)return null;const se=[z.healed>0?`${z.healed} ${Pe.healed.toLowerCase()}`:"",z.suggested>0?`${z.suggested} ${Pe.suggested.toLowerCase()}`:"",z.reverted>0?`${z.reverted} ${Pe.reverted.toLowerCase()}`:"",z.undone>0?`${z.undone} ${Pe.undone.toLowerCase()}`:"",z.expired>0?`${z.expired} expired`:""].filter(Boolean).join(", ");return e.jsxs("span",{className:"px-2 py-0.5 rounded-lg text-[11px] font-medium flex-shrink-0 bg-purple-500/15 text-purple-600 dark:text-purple-300 border border-purple-500/30 inline-flex items-center gap-1",title:"Auto-Heal repaired locators after this run — open a stamped test for the diff and Undo",children:[e.jsx(de,{size:11})," Auto-Heal · ",se]})})(),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs("button",{onClick:async()=>{if(we.length>0){ee(!0);try{await nt(V||we[0].runId),h(!0)}catch{$("error","Console output not available for this run")}finally{ee(!1)}return}if(w){h(!0);return}ee(!0);try{const m=await Vt(W);L(m.output),h(!0)}catch{$("error","Console output not available for this run")}finally{ee(!1)}},disabled:D,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-white/5 text-gray-400 border border-white/10 text-sm font-medium hover:bg-white/10 hover:text-gray-300 transition-colors disabled:opacity-50",children:[D?e.jsx(me,{size:13,className:"animate-spin"}):e.jsx(ot,{size:13}),"Console"]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>oe(!le),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-white/5 text-gray-400 border border-white/10 text-sm font-medium hover:bg-white/10 hover:text-gray-300 transition-colors",children:[e.jsx(za,{size:13}),"Export",e.jsx(Oe,{size:11})]}),le&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>oe(!1)}),e.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 w-48 rounded-lg bg-surface-1 border border-white/10 shadow-xl py-1",children:[{label:"HTML Report",url:`/api/results/runs/${W}/report`},{label:"CSV",url:`/api/results/runs/${W}/export/csv`},{label:"Excel (XLSX)",url:`/api/results/runs/${W}/export/xlsx`}].map(m=>e.jsx("button",{onClick:()=>{window.open(m.url,"_blank"),$("success",`${m.label} export started`),oe(!1)},className:"w-full text-left px-3 py-2 text-sm text-gray-300 hover:bg-white/5 transition-colors",children:m.label},m.label))})]})]}),xe&&W&&xe!==W&&e.jsxs("button",{onClick:()=>Me(xe),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-brand-500/10 text-brand-300 border border-brand-500/20 text-sm font-medium hover:bg-brand-500/20 transition-colors",children:[e.jsx(xr,{size:13}),"vs Baseline"]}),e.jsxs("button",{onClick:async()=>{W&&(xe===W?(await js(),Ie(null),$("success","Baseline cleared")):(await vs(W),Ie(W),$("success","Baseline set")))},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-sm font-medium transition-colors ${xe===W?"bg-amber-500/10 text-amber-300 border border-amber-500/20":"bg-white/5 text-gray-400 border border-white/10 hover:bg-white/10 hover:text-gray-300"}`,title:xe===W?"Clear baseline":"Set as baseline",children:[e.jsx(Aa,{size:13}),xe===W?"Baseline ✓":"Set Baseline"]}),(c==null?void 0:c.source)==="cloud"&&c.cloudProvider!=="local-appium"&&c.cloudProvider!=="testver-grid"&&!c.cloudArtifacts&&we.length===0&&e.jsxs("button",{onClick:ae,disabled:ge,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-blue-500/15 text-blue-300 text-sm font-medium hover:bg-blue-500/25 border border-blue-500/20 transition-colors disabled:opacity-50",children:[ge?e.jsx(me,{size:13,className:"animate-spin"}):e.jsx(Et,{size:13}),"Fetch Artifacts"]}),((c==null?void 0:c.tests)||[]).some(m=>m.status==="failed"||m.status==="error")&&e.jsxs("button",{onClick:()=>Z(!Y),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-white/5 text-gray-400 border border-white/10 text-sm font-medium hover:bg-white/10 hover:text-gray-300 transition-colors",children:[e.jsx(Wt,{size:13}),Y?"Show Tests":"Analyze Failures"]})]})]}),c&&e.jsxs("div",{className:"flex items-stretch gap-2 px-4 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0 flex-wrap",children:[e.jsx(Be,{label:"Total",value:((Fe=c.summary)==null?void 0:Fe.total)||0}),e.jsx(Be,{label:"Passed",value:((Ne=c.summary)==null?void 0:Ne.passed)||0,icon:e.jsx(st,{size:11}),color:"text-emerald-400"}),e.jsx(Be,{label:"Failed",value:((Te=c.summary)==null?void 0:Te.failed)||0,icon:e.jsx(ze,{size:11}),color:((ut=c.summary)==null?void 0:ut.failed)>0?"text-red-400":"text-gray-500"}),e.jsx(Be,{label:"Skipped",value:((u=c.summary)==null?void 0:u.skipped)||0,icon:e.jsx(Xe,{size:11}),color:"text-gray-500"}),e.jsx(Be,{label:"Pass Rate",value:`${((M=c.summary)==null?void 0:M.passRate)||0}%`,color:ie(((ce=c.summary)==null?void 0:ce.passRate)||0)}),c.duration&&e.jsx(Be,{label:"Duration",value:`${(c.duration/1e3).toFixed(1)}s`,icon:e.jsx(Qe,{size:11})}),c.source==="cloud"&&c.cloudProvider==="local-appium"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl bg-surface-2/60 border border-white/10",children:[e.jsx(rt,{size:11,className:"text-gray-300"}),e.jsx("span",{className:"text-sm font-medium text-gray-300",children:"Local Device"})]}),c.source==="cloud"&&c.cloudProvider&&c.cloudProvider!=="local-appium"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl bg-blue-500/10 border border-blue-500/20",children:[e.jsx(tt,{size:11,className:"text-blue-400"}),e.jsx("span",{className:"text-sm font-medium text-blue-400",children:Sn[c.cloudProvider]||c.cloudProvider})]}),c.gridBrowser&&e.jsx("div",{className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl bg-emerald-500/10 border border-emerald-500/20",children:e.jsx("span",{className:"text-sm font-medium text-emerald-400 capitalize",children:c.gridBrowser})}),c.cloudProvider==="testver-grid"&&c.cloudBuildName&&e.jsx(Fn,{buildName:c.cloudBuildName,currentRunId:c.runId,runs:A,onSelect:_}),c.targetDevice&&e.jsxs("div",{className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl bg-surface-2/50 border border-white/5",children:[e.jsx(rt,{size:12,className:"text-indigo-400"}),e.jsx("span",{className:"text-sm text-gray-400",children:c.targetDevice})]}),!c.targetDevice&&c.targetBrowser&&e.jsxs("div",{className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl bg-surface-2/50 border border-white/5",children:[e.jsx(Ke,{name:c.targetBrowser,isEnv:!1,size:12}),e.jsx("span",{className:"text-sm text-gray-400",children:c.targetBrowser})]}),c.targetEnvironment&&e.jsx(zn,{name:c.targetEnvironment}),!c.targetBrowser&&!c.targetDevice&&[...new Set((c.tests||[]).map(z=>z.browser).filter(Boolean))].map(z=>e.jsxs("div",{className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl bg-surface-2/50 border border-white/5",children:[e.jsx(us,{browser:z,size:12}),e.jsx("span",{className:"text-sm text-gray-400",children:z})]},z))]}),c&&(c.command||c.cloudBuildName||c.gitBranch||c.gitCommitSha)&&e.jsxs("div",{className:"flex items-center gap-3 px-5 py-2.5 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[c.command&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-gray-500 font-mono min-w-0",children:[e.jsx(ot,{size:11,className:"text-gray-600 flex-shrink-0"}),e.jsx("span",{className:"truncate",title:c.command,children:c.command}),e.jsx(Tn,{command:c.command})]}),c.cloudBuildName&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-amber-400/70 flex-shrink-0",children:[e.jsx(xs,{size:11}),c.cloudBuildName]}),c.gitBranch&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-brand-400/70 flex-shrink-0",children:[e.jsx(Kt,{size:11}),c.gitBranch]}),c.gitCommitSha&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-gray-500 font-mono flex-shrink-0",children:[e.jsx(qt,{size:11}),c.gitCommitSha,c.gitCommitMessage&&e.jsxs("span",{className:"text-gray-600 font-sans truncate max-w-48",children:["— ",c.gitCommitMessage]})]})]}),(Ce==null?void 0:Ce.correlations)&&Ce.correlations.length>0&&(()=>{const m=Ce.correlations.filter(ye=>ye.confidence==="high"||ye.confidence==="medium");if(m.length===0)return null;const z=m.reduce((ye,_e)=>{var bs;return ye+(((bs=_e.newFailures)==null?void 0:bs.length)||0)},0);if(z===0)return null;const se=m[0];return e.jsxs("div",{className:"mx-5 mt-3 px-4 py-2.5 rounded-xl bg-amber-500/10 border border-amber-500/20 flex items-center gap-2 text-xs text-amber-300",children:[e.jsx(qt,{size:12,className:"flex-shrink-0"}),e.jsxs("span",{children:[z," failure",z!==1?"s":""," likely introduced by commit"," ",e.jsx("code",{className:"text-amber-200",children:se.commit.shortSha}),!j&&e.jsxs(e.Fragment,{children:[" ","by ",se.commit.author]})]}),e.jsx("span",{className:`ml-auto px-1.5 py-0.5 rounded text-[10px] font-medium ${se.confidence==="high"?"bg-red-500/20 text-red-300":"bg-amber-500/20 text-amber-300"}`,children:se.confidence})]})})(),e.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[(c==null?void 0:c.source)==="cloud"&&c.cloudProvider!=="local-appium"&&(c==null?void 0:c.cloudExecution)&&!c.cloudExecution.observed&&e.jsxs("div",{className:`mb-4 rounded-xl border px-4 py-3 flex items-start gap-3 ${c.cloudExecution.final&&!c.cloudExecution.unverified?"border-amber-500/40 bg-amber-500/10":"border-white/10 bg-surface-1"}`,children:[c.cloudExecution.final?e.jsx(Ue,{size:16,className:`${c.cloudExecution.unverified?"text-gray-400":"text-amber-400"} mt-0.5 shrink-0`}):e.jsx(me,{size:16,className:"text-gray-400 mt-0.5 shrink-0 animate-spin"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:`text-sm font-semibold ${c.cloudExecution.final&&!c.cloudExecution.unverified?"text-amber-300":"text-gray-300"}`,children:c.cloudExecution.final?c.cloudExecution.unverified?"Cloud execution not verified":c.targetDevice?"No device session found on the provider":"Cloud run executed locally":"Verifying cloud execution…"}),e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:c.cloudExecution.note})]})]}),((he=c==null?void 0:c.cloudArtifacts)==null?void 0:he.sessions)&&c.cloudArtifacts.sessions.length>0&&e.jsxs("div",{className:"mb-4 rounded-xl border border-white/5 bg-surface-1 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("p",{className:"text-xs font-semibold text-gray-400 uppercase flex items-center gap-1.5",children:[e.jsx(tt,{size:12,className:c.cloudArtifacts.provider==="browserstack"?"text-orange-400":c.cloudArtifacts.provider==="lambdatest"?"text-purple-400":c.cloudArtifacts.provider==="saucelabs"?"text-red-400":c.cloudArtifacts.provider==="testver-grid"?"text-emerald-400":"text-blue-400"}),"Cloud Session — ",c.cloudArtifacts.provider==="browserstack"?"BrowserStack":c.cloudArtifacts.provider==="lambdatest"?"LambdaTest":c.cloudArtifacts.provider==="saucelabs"?"Sauce Labs":c.cloudArtifacts.provider==="testver-grid"?"Testver Grid":c.cloudArtifacts.provider]}),c.cloudArtifacts.buildUrl&&e.jsxs("a",{href:c.cloudArtifacts.buildUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-brand-400 hover:text-brand-300 transition-colors",children:[e.jsx(ve,{size:10})," View Build"]})]}),e.jsx("div",{className:"space-y-2",children:c.cloudArtifacts.sessions.map(m=>e.jsxs("div",{className:"flex items-center gap-3 rounded-xl bg-surface-2/50 border border-white/5 px-4 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs flex-1 min-w-0",children:[m.browser&&e.jsx("span",{className:"text-gray-300",children:m.browser}),m.os&&e.jsxs("span",{className:"text-gray-500",children:[m.os," ",m.osVersion||""]}),m.status&&e.jsx("span",{className:`px-1.5 py-0.5 rounded-lg text-[10px] font-medium ${m.status==="passed"||m.status==="done"?"bg-emerald-500/15 text-emerald-400":m.status==="failed"||m.status==="error"?"bg-red-500/15 text-red-400":"bg-gray-500/15 text-gray-400"}`,children:m.status}),m.duration!=null&&e.jsxs("span",{className:"text-gray-600 text-[10px]",children:[m.duration,"s"]})]}),e.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[m.videoUrl&&e.jsxs("button",{onClick:()=>{if(m.videoUrl.startsWith("/api/")){const z=kt(),se=m.videoUrl.includes("?")?"&":"?";Re(z?`${m.videoUrl}${se}token=${encodeURIComponent(z)}`:m.videoUrl)}else Re(m.videoUrl)},className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-surface-2 text-xs text-blue-400 hover:text-blue-300 hover:bg-surface-3 transition-colors",children:[e.jsx(xt,{size:10})," Video"]}),m.logsUrl&&(m.logsUrl.startsWith("/api/")?(()=>{const z=kt(),se=m.logsUrl.includes("?")?"&":"?",ye=z?`${m.logsUrl}${se}token=${encodeURIComponent(z)}`:m.logsUrl;return e.jsxs("a",{href:ye,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-surface-2 text-xs text-gray-400 hover:text-gray-300 hover:bg-surface-3 transition-colors",children:[e.jsx(pt,{size:10})," Logs"]})})():e.jsxs("a",{href:m.logsUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-surface-2 text-xs text-gray-400 hover:text-gray-300 hover:bg-surface-3 transition-colors",children:[e.jsx(pt,{size:10})," Logs"]})),m.sessionUrl&&e.jsxs("a",{href:m.sessionUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-surface-2 text-xs text-gray-400 hover:text-gray-300 hover:bg-surface-3 transition-colors",children:[e.jsx(ve,{size:10})," Session"]})]})]},m.sessionId))})]}),He&&W?e.jsx($n,{runId1:He,runId2:W,run1Label:He===xe?"Baseline":void 0,onClose:()=>Me(null)}):Y&&W?e.jsx(gn,{runId:W,onClose:()=>Z(!1)}):S?e.jsx(qa,{suiteId:c.suiteId}):F?e.jsx(Wa,{runId:W}):e.jsxs(e.Fragment,{children:[(c==null?void 0:c.status)==="running"&&W&&e.jsx(ur,{runId:W,layout:"inline"}),e.jsx(_a,{tests:(c==null?void 0:c.tests)||[],filter:void 0,onSelectTest:m=>G({testId:m}),selectedTest:H,displayBrowser:c==null?void 0:c.targetBrowser,displayDevice:c==null?void 0:c.targetDevice})]})]}),e.jsx(ts,{url:Ae,onClose:()=>Re(null)}),R&&w!==null&&e.jsxs("div",{className:"fixed inset-0 bg-black/90 z-50 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-white/10 bg-[#161a22] flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ot,{size:16,className:"text-white"}),e.jsx("span",{className:"text-sm font-semibold text-white",children:"Console Output"}),e.jsx("span",{className:"text-xs text-white/40",children:"|"}),e.jsx("span",{className:"text-xs text-white/70 truncate max-w-[24rem]",children:V?Ee(((Ze=we.find(m=>m.runId===V))==null?void 0:Ze.label)||V):W}),e.jsx("span",{className:"text-xs text-white/40",children:"|"}),e.jsxs("span",{className:"text-xs text-white/60",children:[(w.length/1024).toFixed(1)," KB"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>{navigator.clipboard.writeText(w),$("success","Console output copied")},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs text-white/70 hover:text-white hover:bg-white/5 transition-colors",children:[e.jsx(pt,{size:12}),"Copy"]}),e.jsx("button",{onClick:()=>h(!1),className:"p-1.5 text-white/70 hover:text-red-400 transition-colors rounded-lg hover:bg-white/5",children:e.jsx(ze,{size:18})})]})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[we.length>0&&e.jsxs("div",{className:"w-72 flex-shrink-0 border-r border-white/10 bg-[#12151c] overflow-y-auto py-2",children:[e.jsxs("p",{className:"px-3 pb-1.5 text-[10px] uppercase tracking-wider text-white/40",children:["Tests (",we.length,")"]}),we.map(m=>e.jsxs("button",{onClick:()=>{nt(m.runId).catch(()=>$("error","Console output not available for this test"))},className:`w-full flex items-center gap-2 px-3 py-2 text-left text-xs transition-colors ${V===m.runId?"bg-white/10 text-white":"text-white/60 hover:bg-white/5 hover:text-white/90"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${m.status==="completed"?"bg-emerald-400":m.status==="failed"?"bg-red-400":"bg-gray-500"}`}),e.jsx("span",{className:"truncate flex-1",title:m.label,children:Ee(m.label)}),m.duration!=null&&e.jsxs("span",{className:"text-[10px] text-white/30 flex-shrink-0",children:[(m.duration/1e3).toFixed(1),"s"]})]},m.runId))]}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx("pre",{className:"text-xs text-white font-mono leading-relaxed whitespace-pre-wrap break-words bg-[#0b0d12] rounded-lg p-4",children:_t(w).map((m,z)=>e.jsx("span",{style:Dt(m.style),children:m.text},z))})})]})]})]})}const el=Object.freeze(Object.defineProperty({__proto__:null,CloudVideoModal:ts,ResultsPage:En},Symbol.toStringTag,{value:"Module"}));export{ts as C,el as R,Qa as S,rn as T,Ya as a,Xa as t};
|