@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,5 +0,0 @@
|
|
|
1
|
-
import{r,b as we,j as e,R as Rs}from"./vendor-react-CTbHBddL.js";import{f as Bt}from"./formatDate-T65-Y6Mi.js";import{u as et,a as Ps}from"./vendor-query-BrzmPFT3.js";import{u as Nt,a as Je,b as As}from"./useTabParam-ChbOedP1.js";import{b as tt,y as $s,x as Lt,a8 as st,gp as Ut,gq as Ms}from"./index-DtBWNlVD.js";import{C as Ot}from"./ConfirmDialog-DNU3qoAP.js";import{u as Ds}from"./useTestExplorer-HqvURJAc.js";import{u as Es,T as vt}from"./RunTargets-C7Vqd4TU.js";import{u as _s,a as Is,b as Fs,c as zs,d as Bs,e as Ls,f as Us,g as Os,h as qs,i as Hs,j as Ks,k as Qs,l as Vs,m as qt,n as Js,o as Xs,p as Gs,q as Ws,r as Ht,s as Ys,t as Zs,v as ea,w as ta,x as sa,y as aa,z as ra,A as la,B as na,C as ia,D as ca,E as oa,F as da,G as xa,H as ua,I as ma}from"./useTestManagement-ZTA1_VUm.js";import{t as ha,f as wt}from"./formatTestName-BKd2Uqhs.js";import{M as pa}from"./MobileRunPicker-BNs2lZFf.js";import{cl as Ye,X as Z,ba as ga,a0 as ba,by as fa,a3 as se,f as ya,b6 as de,v as at,a7 as Xe,t as ye,U as Ct,bQ as kt,Z as St,ax as ja,a2 as De,r as ve,_ as Kt,J as Tt,de as Rt,o as Qt,b3 as Vt,e as Ee,bc as Ze,b9 as _e,g as Ie,c as Ge,u as Pt,ar as At,R as Na,ap as va,av as wa,ce as Ca,df as ka,aa as Sa,b2 as Jt,bM as $t,a5 as Mt,F as Ta,a1 as Ra,ae as Pa,bk as Aa,be as $a,a9 as Ma}from"./vendor-icons-B0wLOBoh.js";import{R as Da}from"./MobileRunTarget-D2Nqcj10.js";import{u as Ea,a as _a}from"./useJiraConnector-TM1Rfj1s.js";import{TagMultiSelectFilter as Ia,SourceSingleSelectFilter as Fa}from"./TestManagementPage-Ch4PthuU.js";import{L as za}from"./LiveExecutionView-BD0wE8sz.js";import"./SearchableDevicePicker-CFJ_DUAA.js";import"./ImportExportPage-DXk7Koaq.js";import"./excel-BrxuVus5.js";import"./vendor-excel-BFHGVHVC.js";import"./aiHandoff-vhtR29Fh.js";import"./useDebouncedValue-BsHptIvX.js";import"./ExportButton-Ce_MxnM1.js";import"./JiraPushDialog-CqftoLh8.js";const Dt="w-full bg-surface-2 border border-white/10 rounded-lg px-3.5 py-2.5 text-sm text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50";function Et({on:s,onChange:a}){return e.jsx("button",{role:"switch","aria-checked":s,onClick:()=>a(!s),className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${s?"bg-brand-500":"bg-surface-3 border border-white/10"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform ${s?"translate-x-4":""}`})})}function _t({title:s,icon:a,children:l}){return e.jsxs("section",{className:"bg-surface-1 border border-white/5 rounded-xl p-5",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-200 flex items-center gap-2.5 mb-1",children:[e.jsx("span",{className:"text-brand-400 flex-shrink-0",children:a}),s]}),e.jsx("div",{className:"divide-y divide-white/5",children:l})]})}function G({label:s,desc:a,children:l,alignTop:h}){return e.jsxs("div",{className:`flex flex-col md:flex-row gap-1.5 md:gap-6 py-3.5 ${h?"md:items-start":"md:items-center"}`,children:[e.jsxs("div",{className:"md:w-52 flex-shrink-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-200",children:s}),a&&e.jsx("div",{className:"text-[13px] text-gray-500 mt-0.5 leading-snug",children:a})]}),e.jsx("div",{className:"flex-1 min-w-0",children:l})]})}function It({value:s,onChange:a}){const{data:l}=Ds(),[h,c]=r.useState(!1),[C,u]=r.useState(!1),[g,p]=r.useState(""),f=r.useRef(null),y=()=>{c(x=>{if(!x&&f.current){const o=window.innerHeight-f.current.getBoundingClientRect().bottom;u(o<320)}return!x}),p("")},j=r.useMemo(()=>{const x=[];for(const o of(l==null?void 0:l.suites)||[])for(const w of o.tests)x.push({file:o.file,name:w.name,command:w.runCommand||"",suiteName:o.name});return x},[l]),N=g.trim()?j.filter(x=>ha(x.name,g)||`${x.suiteName} ${x.file}`.toLowerCase().includes(g.trim().toLowerCase())):j,A=!!(s!=null&&s.testName);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{ref:f,className:"flex items-center gap-2 bg-surface-2 border border-white/10 rounded-lg pl-2 pr-1.5 py-1 min-h-[40px] focus-within:border-brand-500/50",children:[e.jsx("div",{className:"flex-1 min-w-0 flex items-center",children:A?e.jsxs("span",{className:"flex items-center gap-1.5 bg-surface-3 border border-white/15 rounded-md pl-2 pr-1 py-1 text-xs text-gray-100 min-w-0 max-w-full shadow-sm",children:[e.jsx(ya,{size:9,className:"text-cyan-400 fill-current flex-shrink-0"}),e.jsx("span",{className:"truncate font-medium",title:s.testName,children:wt(s.testName)}),e.jsx("button",{onClick:()=>a(null),title:"Remove test",className:"text-gray-500 hover:text-red-400 flex-shrink-0",children:e.jsx(Z,{size:13})})]}):e.jsx("input",{value:(s==null?void 0:s.command)||"",onChange:x=>a(x.target.value.trim()?{command:x.target.value}:null),placeholder:"Type a command… or pick a test →",className:"w-full bg-transparent text-xs text-gray-200 outline-none font-mono placeholder-gray-600"})}),e.jsxs("button",{onClick:y,title:"Pick a project test",className:"text-[11px] font-medium text-gray-400 hover:text-gray-100 inline-flex items-center gap-1 flex-shrink-0 border border-white/10 rounded-md px-2 py-1 hover:bg-surface-3",children:[e.jsx(de,{size:12})," test"]})]}),h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>c(!1)}),e.jsxs("div",{className:`absolute right-0 z-50 w-80 rounded-xl bg-surface-1 border border-white/10 shadow-2xl p-2 ${C?"bottom-full mb-1":"top-full mt-1"}`,children:[e.jsxs("div",{className:"relative mb-1.5",children:[e.jsx(at,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:g,onChange:x=>p(x.target.value),placeholder:"Search all project tests…",autoFocus:!0,className:"w-full bg-surface-2 border border-white/10 rounded-lg pl-8 pr-2 py-1.5 text-sm text-gray-200 outline-none placeholder-gray-600"})]}),e.jsx("div",{className:"max-h-64 overflow-auto",children:N.length===0?e.jsx("div",{className:"text-xs text-gray-600 py-6 text-center",children:j.length===0?"No tests found in this project.":`No tests match “${g}”.`}):N.slice(0,200).map((x,o)=>e.jsxs("button",{onClick:()=>{a({command:x.command,testName:x.name,file:x.file}),c(!1)},className:"w-full text-left px-2.5 py-1.5 rounded-lg hover:bg-surface-2/60",children:[e.jsx("div",{className:"text-sm text-gray-200 truncate",title:x.name,children:wt(x.name)}),e.jsxs("div",{className:"text-[11px] text-gray-500 truncate",children:[x.suiteName," · ",x.file.split(/[/\\]/).pop()||x.file]})]},`${x.file}::${x.name}::${o}`))})]})]})]})}function Ba({onClose:s}){const{data:a}=_s(),l=Is(),{toast:h}=tt(),{data:c}=et({queryKey:["cloud-providers"],queryFn:$s,staleTime:3e4}),C=((c==null?void 0:c.providers)||[]).filter(F=>F.enabled),u=Lt().mode==="mobile",[g,p]=r.useState(null),[f,y]=r.useState("local"),[j,N]=r.useState(""),[A,x]=r.useState(1),[o,w]=r.useState(0),[I,R]=r.useState(!1),[H,$]=r.useState(""),[Q,V]=r.useState(""),[k,ee]=r.useState(""),[D,B]=r.useState(null),[q,J]=r.useState(null),[U,ae]=r.useState(!0),{browserOpts:re,envOpts:n}=Es(),m=r.useRef(!1);r.useEffect(()=>{!a||m.current||(m.current=!0,y(a.target==="cloud"?"cloud":"local"),N(a.cloudProvider||""),x(a.concurrency||1),w(a.retries||0),R(!!a.headless),$(a.extraArgs||""),V(a.browser||""),ee(a.environment||""),B(a.beforeRun||null),J(a.afterRun||null),ae(a.abortOnSetupFailure??!0))},[a]);const M=()=>{var F;if(u){const _=g==null?void 0:g.payload;return{target:"cloud",cloudProvider:(_==null?void 0:_.cloudProvider)||(a==null?void 0:a.cloudProvider),deviceName:(_==null?void 0:_.deviceName)||void 0,platformName:(_==null?void 0:_.platformName)||void 0,platformVersion:(_==null?void 0:_.platformVersion)||void 0,appId:(_==null?void 0:_.appId)||void 0,appPath:((F=_==null?void 0:_.appPath)==null?void 0:F.trim())||void 0,concurrency:A,retries:o,extraArgs:H.trim()||void 0,environment:k||void 0,beforeRun:D||void 0,afterRun:q||void 0,abortOnSetupFailure:U}}return{target:f,cloudProvider:f==="cloud"&&j||void 0,concurrency:A,retries:o,headless:I,extraArgs:H.trim()||void 0,browser:Q||void 0,environment:k||void 0,beforeRun:D||void 0,afterRun:q||void 0,abortOnSetupFailure:U}},L=()=>{l.mutate(M(),{onSuccess:()=>{h("success","Run settings saved"),s()},onError:()=>h("error","Failed to save run settings")})};return we.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:s}),e.jsxs("div",{className:"relative bg-surface-0 border border-white/10 rounded-2xl shadow-2xl w-full max-w-2xl max-h-[88vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/5",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(Ye,{size:16,className:"text-brand-400"})," Automation Run Settings"]}),e.jsx("p",{className:"text-[13px] text-gray-500 mt-0.5",children:"Applied to all cycles in this project."})]}),e.jsx("button",{onClick:s,className:"text-gray-500 hover:text-gray-200 p-1 rounded-lg hover:bg-surface-2",children:e.jsx(Z,{size:18})})]}),e.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4 space-y-4",children:[e.jsxs(_t,{title:"Run options",icon:e.jsx(Ye,{size:15}),children:[u?!!a&&e.jsx(G,{label:"Device & App",desc:"Runs dispatch through the mobile cloud-bridge with this device + app.",children:e.jsx(pa,{compact:!0,initial:{cloudProvider:a==null?void 0:a.cloudProvider,deviceName:a==null?void 0:a.deviceName,platformName:a==null?void 0:a.platformName,platformVersion:a==null?void 0:a.platformVersion,appId:a==null?void 0:a.appId,appPath:a==null?void 0:a.appPath},onChange:p})}):e.jsxs(e.Fragment,{children:[e.jsx(G,{label:"Where",desc:"Run locally or on a cloud device grid.",children:e.jsxs("div",{className:"flex rounded-lg border border-white/10 overflow-hidden max-w-xs",children:[e.jsxs("button",{onClick:()=>y("local"),className:`flex-1 px-2 py-2 text-xs inline-flex items-center justify-center gap-1.5 ${f==="local"?"bg-brand-500/15 text-brand-300":"text-gray-400"}`,children:[e.jsx(ga,{size:12})," Local"]}),e.jsxs("button",{onClick:()=>y("cloud"),className:`flex-1 px-2 py-2 text-xs inline-flex items-center justify-center gap-1.5 border-l border-white/10 ${f==="cloud"?"bg-cyan-500/15 text-cyan-300":"text-gray-400"}`,children:[e.jsx(ba,{size:12})," Cloud"]})]})}),f==="cloud"&&e.jsx(G,{label:"Provider",children:e.jsxs("select",{value:j,onChange:F=>N(F.target.value),className:`${Dt} max-w-xs`,children:[e.jsx("option",{value:"",children:"Select…"}),C.map(F=>e.jsx("option",{value:F.id,children:F.id.charAt(0).toUpperCase()+F.id.slice(1)},F.id))]})})]}),e.jsx(G,{label:"Concurrency",desc:"How many tests run at once during “Run All”. Single runs ignore this.",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"range",min:1,max:8,value:A,onChange:F=>x(Number(F.target.value)),className:"flex-1 accent-brand-500"}),e.jsxs("span",{className:"text-sm text-gray-300 tabular-nums w-20 text-right",children:[A," at a time"]})]})}),e.jsx(G,{label:"Auto-retry failed",desc:"Re-runs a failed test immediately. Timeouts are not retried.",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"range",min:0,max:3,value:o,onChange:F=>w(Number(F.target.value)),className:"flex-1 accent-brand-500"}),e.jsx("span",{className:"text-sm text-gray-300 tabular-nums w-20 text-right",children:o===0?"off":`${o}×`})]})}),!u&&e.jsx(G,{label:"Headless",desc:"Hide the browser window during the run.",children:e.jsx(Et,{on:I,onChange:R})}),re.length>0&&e.jsx(G,{label:"Browser",desc:"Chosen browser is added as a CLI arg (from the global Run Commands list).",children:e.jsx("div",{className:"max-w-xs",children:e.jsx(vt,{isEnv:!1,value:Q,onChange:V,options:re})})}),n.length>0&&e.jsx(G,{label:"Environment",desc:"Chosen environment is applied as a CLI arg or env var (per the global list).",children:e.jsx("div",{className:"max-w-xs",children:e.jsx(vt,{isEnv:!0,value:k,onChange:ee,options:n})})}),e.jsxs(G,{label:"Extra CLI args",alignTop:!0,desc:"Appended to every test's command — pass a base URL, browser, or any flag.",children:[e.jsx("input",{value:H,onChange:F=>$(F.target.value),placeholder:"-DbaseUrl=https://staging.example.com -Dbrowser=firefox",className:`${Dt} font-mono text-xs`}),e.jsxs("p",{className:"text-[11px] text-gray-600 mt-1.5",children:[e.jsx("span",{className:"text-gray-500",children:"Maven/TestNG"})," ",e.jsx("span",{className:"font-mono",children:"-DbaseUrl=… -Dbrowser=firefox"})," · ",e.jsx("span",{className:"text-gray-500",children:"pytest"})," ",e.jsx("span",{className:"font-mono",children:"--base-url=…"})," · ",e.jsx("span",{className:"text-gray-500",children:"Playwright"})," ",e.jsx("span",{className:"font-mono",children:"--workers=1"})]})]})]}),e.jsxs(_t,{title:"Setup & teardown (Run All)",icon:e.jsx(fa,{size:15}),children:[e.jsx(G,{label:"Before run",desc:"Runs once before the cycle — only for “Run All”.",alignTop:!0,children:e.jsx(It,{value:D,onChange:B})}),e.jsx(G,{label:"After run",desc:"Runs last — even if tests fail.",alignTop:!0,children:e.jsx(It,{value:q,onChange:J})}),e.jsx(G,{label:"Abort on setup failure",desc:"Skip the tests if the before-run hook fails.",children:e.jsx(Et,{on:U,onChange:ae})})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-5 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:s,className:"px-4 py-2 text-sm rounded-lg text-gray-300 border border-white/10 hover:bg-surface-2",children:"Cancel"}),e.jsxs("button",{onClick:L,disabled:l.isPending,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-lg text-brand-200 bg-brand-500/20 border border-brand-500/40 hover:bg-brand-500/30 disabled:opacity-50",children:[l.isPending?e.jsx(se,{size:14,className:"animate-spin"}):null," Save"]})]})]})]}),document.body)}const Xt=["draft","active","completed","archived"],Ft=["not_run","in_progress","passed","failed","blocked","skipped"],Me={draft:"bg-gray-500/20 text-gray-300",active:"bg-blue-500/20 text-blue-300",completed:"bg-emerald-500/20 text-emerald-300",archived:"bg-slate-500/20 text-slate-400"},We={passed:"bg-emerald-500/20 text-emerald-300",failed:"bg-red-500/20 text-red-300",blocked:"bg-orange-500/20 text-orange-300",skipped:"bg-gray-500/20 text-gray-300",not_run:"bg-slate-500/20 text-slate-400",in_progress:"bg-blue-500/20 text-blue-300"},La={passed:"bg-emerald-500",failed:"bg-red-500",blocked:"bg-orange-500",skipped:"bg-gray-500",not_run:"bg-slate-600",in_progress:"bg-blue-500"},Ua={passed:"bg-emerald-500/5",failed:"bg-red-500/5",blocked:"bg-orange-500/5",skipped:"bg-gray-500/5",not_run:""},Fe={critical:"bg-red-500/20 text-red-300",high:"bg-orange-500/20 text-orange-300",medium:"bg-amber-500/20 text-amber-300",low:"bg-emerald-500/20 text-emerald-300"},rt={functional:"bg-sky-500/20 text-sky-300",regression:"bg-violet-500/20 text-violet-300",smoke:"bg-amber-500/20 text-amber-300",integration:"bg-teal-500/20 text-teal-300",e2e:"bg-indigo-500/20 text-indigo-300",api:"bg-cyan-500/20 text-cyan-300",performance:"bg-rose-500/20 text-rose-300",security:"bg-red-500/20 text-red-300"};function z(s){return s.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function Oa(s){return s?new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—"}function qa({executions:s}){const a=r.useMemo(()=>{const h={passed:0,failed:0,blocked:0,skipped:0,not_run:0,in_progress:0};return s.forEach(c=>{h[c.status]=(h[c.status]||0)+1}),h},[s]),l=s.length||1;return e.jsx("div",{className:"w-full h-2 rounded-full bg-surface-2 overflow-hidden flex",children:["passed","failed","blocked","in_progress","skipped","not_run"].map(h=>{const c=a[h]/l*100;return c===0?null:e.jsx("div",{className:`${La[h]} h-full`,style:{width:`${c}%`}},h)})})}function Ha({cycleId:s}){const{data:a}=sa(s);if(!a)return null;const l=a,h=l.passRate??(l.executedCount>0?Math.round(l.passedCount/l.executedCount*100):0),c=l.completionRate??(l.totalCount>0?Math.round((l.totalCount-(l.notRunCount??0))/l.totalCount*100):0),C=l.failedCount??l.failed??0,u=l.totalDuration??0,g=p=>{if(!p||p<=0)return"0s";const f=Math.floor(p/3600),y=Math.floor(p%3600/60),j=p%60;return f>0?`${f}h ${y}m ${j}s`:y>0?`${y}m ${j}s`:`${j}s`};return e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-4",children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 text-center",children:[e.jsx(wa,{className:"w-5 h-5 text-brand-400 mx-auto mb-1"}),e.jsx("div",{className:"text-2xl font-bold text-gray-200",children:g(u)}),e.jsx("div",{className:"text-xs text-gray-400",children:"Total Duration"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 text-center",children:[e.jsx(Ca,{className:"w-5 h-5 text-emerald-400 mx-auto mb-1"}),e.jsxs("div",{className:"text-2xl font-bold text-emerald-300",children:[h,"%"]}),e.jsx("div",{className:"text-xs text-gray-400",children:"Pass Rate"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 text-center",children:[e.jsx(ka,{className:"w-5 h-5 text-blue-400 mx-auto mb-1"}),e.jsxs("div",{className:"text-2xl font-bold text-blue-300",children:[c,"%"]}),e.jsx("div",{className:"text-xs text-gray-400",children:"Completion"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 text-center",children:[e.jsx(De,{className:"w-5 h-5 text-red-400 mx-auto mb-1"}),e.jsx("div",{className:"text-2xl font-bold text-red-300",children:C}),e.jsx("div",{className:"text-xs text-gray-400",children:"Failed"})]})]})}function zt({onClose:s,editingPlan:a}){const[l,h]=r.useState((a==null?void 0:a.name)??""),[c,C]=r.useState((a==null?void 0:a.description)??""),[u,g]=r.useState((a==null?void 0:a.release)??""),[p,f]=r.useState((a==null?void 0:a.sprint)??""),[y,j]=r.useState((a==null?void 0:a.status)??"draft"),N=aa(),A=ra(),x=()=>{if(!l.trim())return;const o={name:l.trim(),description:c.trim(),release:u.trim(),sprint:p.trim(),status:y};a?A.mutate({id:a.id,data:o},{onSuccess:s}):N.mutate(o,{onSuccess:s})};return we.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:s,children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-xl w-full max-w-lg p-6 shadow-2xl",onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:a?"Edit Plan":"New Test Plan"}),e.jsx("button",{onClick:s,className:"text-gray-400 hover:text-gray-200",children:e.jsx(Z,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Plan Name *"}),e.jsx("input",{value:l,onChange:o=>h(o.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50",placeholder:"e.g. Release 2.5 Regression"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Description"}),e.jsx("textarea",{value:c,onChange:o=>C(o.target.value),rows:3,className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50 resize-none",placeholder:"Brief description..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Release"}),e.jsx("input",{value:u,onChange:o=>g(o.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50",placeholder:"e.g. v2.5"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Sprint"}),e.jsx("input",{value:p,onChange:o=>f(o.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50",placeholder:"e.g. Sprint 14"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Status"}),e.jsx("select",{value:y,onChange:o=>j(o.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 focus:outline-none focus:border-brand-500/50",children:Xt.map(o=>e.jsx("option",{value:o,children:z(o)},o))})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx("button",{onClick:s,className:"bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-4 py-2 text-sm",children:"Cancel"}),e.jsxs("button",{onClick:x,disabled:!l.trim()||N.isPending||A.isPending,className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm disabled:opacity-50 flex items-center gap-2",children:[e.jsx(Jt,{className:"w-4 h-4"}),a?"Update Plan":"Create Plan"]})]})]})}),document.body)}function Ka({planId:s,onClose:a,editingCycle:l}){const[h,c]=r.useState((l==null?void 0:l.name)??""),[C,u]=r.useState((l==null?void 0:l.assignedTo)??""),[g,p]=r.useState(l!=null&&l.startDate?new Date(l.startDate).toISOString().split("T")[0]:""),[f,y]=r.useState(l!=null&&l.endDate?new Date(l.endDate).toISOString().split("T")[0]:""),j=la(),N=na(),A=()=>{if(!h.trim())return;const x={name:h.trim(),assignedTo:C.trim()||void 0};g&&(x.startDate=new Date(g).getTime()),f&&(x.endDate=new Date(f).getTime()),l?N.mutate({id:l.id,data:x},{onSuccess:a}):j.mutate({planId:s,data:x},{onSuccess:a})};return we.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:a,children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-xl w-full max-w-md p-6 shadow-2xl",onClick:x=>x.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:l?"Edit Cycle":"New Test Cycle"}),e.jsx("button",{onClick:a,className:"text-gray-400 hover:text-gray-200",children:e.jsx(Z,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Cycle Name *"}),e.jsx("input",{value:h,onChange:x=>c(x.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50",placeholder:"e.g. Cycle 1 - Smoke Tests"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Assigned To"}),e.jsx("input",{value:C,onChange:x=>u(x.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50",placeholder:"e.g. john@example.com"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Start Date"}),e.jsx("input",{type:"date",value:g,onChange:x=>p(x.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 focus:outline-none focus:border-brand-500/50 text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"End Date"}),e.jsx("input",{type:"date",value:f,onChange:x=>y(x.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 focus:outline-none focus:border-brand-500/50 text-sm"})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx("button",{onClick:a,className:"bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-4 py-2 text-sm",children:"Cancel"}),e.jsxs("button",{onClick:A,disabled:!h.trim()||j.isPending||N.isPending,className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm disabled:opacity-50 flex items-center gap-2",children:[e.jsx(Jt,{className:"w-4 h-4"}),l?"Update Cycle":"Create Cycle"]})]})]})}),document.body)}function Qa({planId:s,existingTestCaseIds:a,onClose:l}){const h=ia(),[c,C]=r.useState(new Set),[u,g]=r.useState(""),[p,f]=r.useState(""),[y,j]=r.useState(""),[N,A]=r.useState(""),[x,o]=r.useState(""),[w,I]=r.useState(new Set),[R,H]=r.useState(null),{data:$}=ca(),Q=(Array.isArray($)?$:$==null?void 0:$.tags)??[],{data:V}=oa(),k=(V==null?void 0:V.sources)??[],ee=r.useMemo(()=>{const n={limit:500};return u.trim()&&(n.search=u.trim()),p&&(n.priority=p),y&&(n.type=y),N&&(n.status=N),x&&(n.automationStatus=x),w.size>0&&(n.tagIds=Array.from(w)),R&&(n.sourceId=R),n},[u,p,y,N,x,w,R]),{data:D}=da(ee),B=r.useMemo(()=>{const n=Array.isArray(D)?D:(D==null?void 0:D.testCases)??(D==null?void 0:D.data)??[],m=new Set(a);return n.filter(M=>!m.has(M.id))},[D,a]),q=(p?1:0)+(y?1:0)+(N?1:0)+(x?1:0)+(w.size>0?1:0)+(R?1:0),J=()=>{f(""),j(""),A(""),o(""),I(new Set),H(null)},U=n=>{C(m=>{const M=new Set(m);return M.has(n)?M.delete(n):M.add(n),M})},ae=()=>{c.size===B.length?C(new Set):C(new Set(B.map(n=>n.id)))},re=()=>{c.size!==0&&h.mutate({planId:s,testCaseIds:Array.from(c)},{onSuccess:l})};return we.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:l,children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-xl w-full max-w-4xl p-6 shadow-2xl h-[85vh] flex flex-col",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Add Test Cases to Plan"}),e.jsx("button",{onClick:l,className:"text-gray-400 hover:text-gray-200",children:e.jsx(Z,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx(at,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),e.jsx("input",{value:u,onChange:n=>g(n.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg pl-10 pr-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50 text-sm",placeholder:"Search test cases..."})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-2.5 py-1.5 text-xs text-gray-300 outline-none focus:border-brand-500",value:p,onChange:n=>f(n.target.value),title:"Priority",children:[e.jsx("option",{value:"",children:"Priority"}),e.jsx("option",{value:"critical",children:"Critical"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"low",children:"Low"})]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-2.5 py-1.5 text-xs text-gray-300 outline-none focus:border-brand-500",value:y,onChange:n=>j(n.target.value),title:"Type",children:[e.jsx("option",{value:"",children:"Type"}),["web","ui","api","mobile","database","integration","e2e","security","performance","usability","accessibility","compatibility","localization"].map(n=>e.jsx("option",{value:n,children:n==="api"?"API":n==="ui"?"UI":n==="e2e"?"E2E":z(n)},n))]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-2.5 py-1.5 text-xs text-gray-300 outline-none focus:border-brand-500",value:N,onChange:n=>A(n.target.value),title:"Status",children:[e.jsx("option",{value:"",children:"Status"}),["draft","active","deprecated","archived"].map(n=>e.jsx("option",{value:n,children:z(n)},n))]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-2.5 py-1.5 text-xs text-gray-300 outline-none focus:border-brand-500",value:x,onChange:n=>o(n.target.value),title:"Automation",children:[e.jsx("option",{value:"",children:"Automation"}),e.jsx("option",{value:"manual",children:"Manual"}),e.jsx("option",{value:"automated",children:"Automated"}),e.jsx("option",{value:"needs_update",children:"Needs Update"})]}),e.jsx(Ia,{tags:Q,selectedIds:w,onChange:I}),e.jsx(Fa,{sources:k,selectedId:R,onChange:H}),q>0&&e.jsxs("button",{onClick:J,className:"flex items-center gap-1 px-2 py-1 text-xs text-gray-400 hover:text-gray-200 transition-colors",children:[e.jsx(Z,{className:"w-3 h-3"}),"Clear (",q,")"]})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3 text-sm text-gray-400",children:[e.jsxs("button",{onClick:ae,className:"flex items-center gap-1.5 hover:text-gray-200",children:[c.size===B.length&&B.length>0?e.jsx($t,{className:"w-4 h-4 text-brand-400"}):e.jsx(Mt,{className:"w-4 h-4"}),"Select All"]}),e.jsxs("span",{className:"ml-auto",children:[c.size," selected"]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 min-h-0",children:[B.length===0&&e.jsx("div",{className:"text-center text-gray-500 py-8",children:"No test cases available to add."}),B.map(n=>{var m,M;return e.jsxs("button",{onClick:()=>U(n.id),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-left hover:bg-surface-2 transition-colors ${c.has(n.id)?"bg-brand-500/10 border border-brand-500/20":"border border-transparent"}`,children:[c.has(n.id)?e.jsx($t,{className:"w-4 h-4 text-brand-400 shrink-0"}):e.jsx(Mt,{className:"w-4 h-4 text-gray-500 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.id&&e.jsx("span",{title:"Test Case ID",className:"text-[11px] font-mono text-brand-300 flex-shrink-0",children:n.id}),e.jsx("span",{title:n.title,className:"text-sm text-gray-200 truncate",children:n.title})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[(((m=n.folder)==null?void 0:m.name)||n.folderName)&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-surface-2 text-gray-400 border border-white/5 flex items-center gap-1",children:[e.jsx(Ta,{className:"w-2.5 h-2.5"})," ",((M=n.folder)==null?void 0:M.name)||n.folderName]}),n.status&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${n.status==="active"?"bg-emerald-500/15 text-emerald-300":n.status==="draft"?"bg-sky-500/15 text-sky-300":"bg-gray-500/15 text-gray-400"}`,children:z(n.status)}),n.priority&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${Fe[n.priority]??"bg-gray-500/20 text-gray-400"}`,children:z(n.priority)}),n.type&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${rt[n.type]??"bg-gray-500/20 text-gray-400"}`,children:z(n.type)})]})]})]},n.id)})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-4 pt-4 border-t border-white/5",children:[e.jsx("button",{onClick:l,className:"bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-4 py-2 text-sm",children:"Cancel"}),e.jsxs("button",{onClick:re,disabled:c.size===0||h.isPending,className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm disabled:opacity-50 flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4"}),"Add ",c.size," Test Case",c.size!==1?"s":""]})]})]})}),document.body)}function Va({plan:s,onSelect:a,onEdit:l,onDelete:h}){const c=s.testCaseCount??s.test_case_count??0,C=s.executedCount??s.executed_count??0,u=s.passedCount??s.passed_count??0,g=s.failedCount??s.failed_count??0,p=c>0?Math.round(C/c*100):0,f=c>0?u/c*100:0,y=c>0?g/c*100:0,j=c>0?(C-u-g)/c*100:0;return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 hover:border-white/10 transition-colors group flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsx("button",{onClick:a,className:"text-left flex-1 min-w-0",children:e.jsx("h3",{title:s.name,className:`text-sm font-semibold transition-colors truncate\r
|
|
2
|
-
text-gray-900 group-hover:text-brand-700\r
|
|
3
|
-
dark:text-gray-100 dark:group-hover:text-brand-300`,children:s.name})}),e.jsxs("div",{className:"flex items-center gap-1 ml-2 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:l,className:"p-1 text-gray-500 hover:text-gray-300 rounded",title:"Edit",children:e.jsx(Ze,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:h,className:"p-1 text-gray-500 hover:text-red-400 rounded",title:"Delete",children:e.jsx(_e,{className:"w-3.5 h-3.5"})})]})]}),s.description&&e.jsx("p",{className:"text-xs text-gray-400 mb-3 line-clamp-2",children:s.description}),e.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[s.id&&e.jsx("span",{title:"Test Plan ID",className:"text-xs font-mono px-2 py-0.5 rounded bg-surface-2 text-brand-300 border border-white/5",children:s.id}),s.release&&e.jsx("span",{title:"Release",className:"text-xs px-2 py-0.5 rounded bg-brand-500/15 text-brand-300",children:s.release}),s.sprint&&e.jsx("span",{title:"Sprint",className:"text-xs px-2 py-0.5 rounded bg-indigo-500/15 text-indigo-300",children:s.sprint}),e.jsx("span",{title:"Plan Status",className:`text-xs px-2 py-0.5 rounded ${Me[s.status]??"bg-gray-500/20 text-gray-400"}`,children:z(s.status??"draft")})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-400 mb-1",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ie,{className:"w-3.5 h-3.5"})," ",c," test cases"]}),e.jsxs("span",{children:[C,"/",c," executed (",p,"%)"]})]}),e.jsxs("div",{className:"w-full h-2 rounded-full bg-surface-2 overflow-hidden mb-1 flex",children:[f>0&&e.jsx("div",{className:"bg-emerald-500 h-full transition-all",style:{width:`${f}%`}}),y>0&&e.jsx("div",{className:"bg-red-500 h-full transition-all",style:{width:`${y}%`}}),j>0&&e.jsx("div",{className:"bg-amber-500 h-full transition-all",style:{width:`${j}%`}})]}),C>0&&e.jsxs("div",{className:"flex items-center gap-3 text-xs mb-1",children:[u>0&&e.jsxs("span",{className:"text-emerald-400",children:[u," passed"]}),g>0&&e.jsxs("span",{className:"text-red-400",children:[g," failed"]}),c-C>0&&e.jsxs("span",{className:"text-gray-500",children:[c-C," remaining"]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-auto pt-3",children:[e.jsxs("div",{className:"text-xs text-gray-500 flex items-center gap-1",children:[e.jsx(Ra,{className:"w-3 h-3"}),Oa(s.createdAt??s.created_at)]}),e.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-3 py-1.5 text-xs font-medium transition-colors",children:[e.jsx(Pa,{className:"w-3.5 h-3.5"})," Open Plan"]})]})]})}const Ja=s=>s?s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`:"0 B";function Xa({executionId:s}){const{toast:a}=tt(),{user:l}=st(),h=(l==null?void 0:l.displayName)||(l==null?void 0:l.username)||"",{data:c,isLoading:C}=xa(s),u=ua(),g=ma(),p=r.useRef(null),[f,y]=r.useState(null),j=(c==null?void 0:c.attachments)??[],N=25*1024*1024,A=async o=>{if(!(!o||o.length===0)){for(const w of Array.from(o)){if(w.size>N){a("error",`"${w.name}" exceeds the 25 MB limit and was skipped.`);continue}const I=await new Promise((R,H)=>{const $=new FileReader;$.onload=()=>R(($.result||"").split(",")[1]||""),$.onerror=()=>H($.error),$.readAsDataURL(w)});await u.mutateAsync({executionId:s,data:{fileName:w.name,fileType:w.type,fileSize:w.size,fileData:I,uploadedBy:h}})}p.current&&(p.current.value="")}},x=async o=>{try{const w=await Ms(o.id),I=document.createElement("a");I.href=`data:${o.fileType||"application/octet-stream"};base64,${w.fileData}`,I.download=o.fileName,document.body.appendChild(I),I.click(),document.body.removeChild(I)}catch{a("error","Could not download attachment.")}};return 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-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Aa,{className:"w-4 h-4 text-gray-400"}),e.jsx("h3",{className:"text-sm font-medium text-gray-200",children:"Evidence"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[j.length," file",j.length===1?"":"s"]})]}),e.jsxs("label",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-brand-600 hover:bg-brand-500 text-white cursor-pointer transition-colors",children:[u.isPending?e.jsx(se,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx($a,{className:"w-3.5 h-3.5"}),"Attach Files",e.jsx("input",{ref:p,type:"file",multiple:!0,className:"hidden",onChange:o=>A(o.target.files),disabled:u.isPending})]})]}),C?e.jsx("div",{className:"text-xs text-gray-500 py-2",children:"Loading…"}):j.length===0?e.jsxs("div",{className:"text-xs text-gray-500 py-3 text-center border border-dashed border-white/10 rounded-lg",children:["No evidence attached. Use ",e.jsx("span",{className:"text-brand-400",children:"Attach Files"})," to add screenshots, logs, or exports for this run."]}):e.jsx("ul",{className:"space-y-1.5",children:j.map(o=>e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2 bg-surface-2 rounded-lg border border-white/5",children:[e.jsx(Ie,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-gray-200 truncate",children:o.fileName}),e.jsxs("div",{className:"text-[11px] text-gray-500",children:[Ja(o.fileSize),o.uploadedBy?` · ${o.uploadedBy}`:"",o.createdAt?` · ${Bt(o.createdAt)}`:""]})]}),e.jsx("button",{type:"button",onClick:()=>x(o),className:"p-1.5 rounded hover:bg-white/10 text-gray-400 hover:text-gray-200",title:"Download",children:e.jsx(Ma,{className:"w-3.5 h-3.5"})}),e.jsx("button",{type:"button",onClick:()=>y({id:o.id,name:o.fileName}),className:"p-1.5 rounded hover:bg-red-500/10 text-gray-400 hover:text-red-400",title:"Delete",children:e.jsx(_e,{className:"w-3.5 h-3.5"})})]},o.id))}),e.jsx(Ot,{open:!!f,title:"Remove evidence?",description:f?`Delete "${f.name}" from this execution? This cannot be undone.`:"",confirmLabel:"Delete",onCancel:()=>y(null),onConfirm:()=>{f&&(g.mutate({id:f.id,executionId:s}),y(null))}})]})}function Ga({executionId:s,onBack:a,breadcrumbPlanName:l,breadcrumbCycleName:h,onNavigateToPlan:c,onNavigateToCycle:C}){var n;const{user:u}=st(),g=(u==null?void 0:u.displayName)||(u==null?void 0:u.username)||"Unknown",{data:p,isLoading:f}=Zs(s),y=ea(),j=ta(),N=r.useMemo(()=>(Array.isArray(p)?p:(p==null?void 0:p.steps)??(p==null?void 0:p.data)??[]).sort((M,L)=>(M.stepNumber??M.step_number??0)-(L.stepNumber??L.step_number??0)),[p]);qt();const A=Ht(),[x,o]=r.useState(!1),{data:w,refetch:I}=et({queryKey:["exec-defects",s],queryFn:()=>Ut([s])}),R=((n=w==null?void 0:w.defects)==null?void 0:n[s])||null,H=N.filter(m=>m.status==="passed").length,$=N.filter(m=>m.status==="failed").length,Q=N.length,V=()=>{A.mutate({executionId:s,createdBy:g},{onSuccess:()=>I()})},k=p==null?void 0:p.execution,ee=(k==null?void 0:k.testCaseTitle)??"Test Case",D=k==null?void 0:k.testCasePriority,B=k==null?void 0:k.testCaseType,q=k==null?void 0:k.testCasePreconditions;k==null||k.scriptMapping;const J=(m,M)=>{y.mutate({id:m.id,data:{status:M,executedBy:g}})},U=(m,M)=>{y.mutate({id:m.id,data:{actualResult:M,executedBy:g}})},ae=(m,M)=>{y.mutate({id:m.id,data:{comment:M,executedBy:g}})},re=()=>{j.mutate({executionId:s,status:"passed",executedBy:g})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[e.jsx("button",{onClick:()=>{c()},className:"hover:text-gray-100 transition-colors",children:"Test Plans"}),e.jsx(ye,{className:"w-4 h-4"}),e.jsx("button",{onClick:c,className:"hover:text-gray-100 transition-colors truncate max-w-[150px]",children:l}),e.jsx(ye,{className:"w-4 h-4"}),e.jsx("button",{onClick:C,className:"hover:text-gray-100 transition-colors truncate max-w-[150px]",children:h}),e.jsx(ye,{className:"w-4 h-4"}),e.jsx("span",{className:"text-gray-200 truncate max-w-[200px]",children:ee})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200 mb-2",children:ee}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[D&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Fe[D]??"bg-gray-500/20 text-gray-400"}`,children:z(D)}),B&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${rt[B]??"bg-gray-500/20 text-gray-400"}`,children:z(B)})]}),q&&e.jsxs("div",{className:"mt-3 p-3 bg-surface-2 rounded-lg border border-white/5",children:[e.jsx("div",{className:"text-xs text-gray-400 font-medium mb-1",children:"Preconditions"}),e.jsx("div",{className:"text-sm text-gray-300 whitespace-pre-wrap",children:q})]}),!1]}),f?e.jsx("div",{className:"text-center py-12 text-gray-500",children:"Loading steps..."}):N.length===0?e.jsx("div",{className:"text-center py-12 text-gray-500",children:"No steps found for this execution."}):e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",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:"border-b border-white/5",children:[e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-12",children:"#"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400",children:"Action"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400",children:"Expected Result"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-48",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400",children:"Actual Result"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400",children:"Comment"})]})}),e.jsx("tbody",{children:N.map((m,M)=>e.jsxs("tr",{className:`border-b border-white/5 ${Ua[m.status]??""}`,children:[e.jsx("td",{className:"px-4 py-3 text-gray-500 font-mono text-xs",children:m.stepNumber??m.step_number??M+1}),e.jsx("td",{className:"px-4 py-3 text-gray-300 max-w-[200px] align-top",children:e.jsx("div",{className:"whitespace-pre-wrap break-words break-all text-xs",children:m.action??m.stepAction??"—"})}),e.jsx("td",{className:"px-4 py-3 text-gray-400 max-w-[200px] align-top",children:e.jsx("div",{className:"whitespace-pre-wrap break-words break-all text-xs",children:m.expectedResult??m.expected_result??"—"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>J(m,"passed"),className:`p-1.5 rounded text-xs font-medium transition-colors ${m.status==="passed"?"bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/30":"text-gray-500 hover:text-emerald-300 hover:bg-emerald-500/10"}`,title:"Pass",children:e.jsx(ve,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>J(m,"failed"),className:`p-1.5 rounded text-xs font-medium transition-colors ${m.status==="failed"?"bg-red-500/20 text-red-300 ring-1 ring-red-500/30":"text-gray-500 hover:text-red-300 hover:bg-red-500/10"}`,title:"Fail",children:e.jsx(De,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>J(m,"blocked"),className:`p-1.5 rounded text-xs font-medium transition-colors ${m.status==="blocked"?"bg-orange-500/20 text-orange-300 ring-1 ring-orange-500/30":"text-gray-500 hover:text-orange-300 hover:bg-orange-500/10"}`,title:"Block",children:e.jsx(Qt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>J(m,"skipped"),className:`p-1.5 rounded text-xs font-medium transition-colors ${m.status==="skipped"?"bg-gray-500/20 text-gray-300 ring-1 ring-gray-500/30":"text-gray-500 hover:text-gray-300 hover:bg-gray-500/10"}`,title:"Skip",children:e.jsx(Vt,{className:"w-4 h-4"})})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("textarea",{defaultValue:m.actualResult??m.actual_result??"",onBlur:L=>U(m,L.target.value),rows:1,className:"w-full bg-surface-2 border border-white/5 rounded px-2 py-1 text-xs text-gray-300 placeholder-gray-600 focus:outline-none focus:border-brand-500/50 resize-none min-w-[120px]",placeholder:"Actual result..."})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("textarea",{defaultValue:m.comment??"",onBlur:L=>ae(m,L.target.value),rows:1,className:"w-full bg-surface-2 border border-white/5 rounded px-2 py-1 text-xs text-gray-300 placeholder-gray-600 focus:outline-none focus:border-brand-500/50 resize-none min-w-[120px]",placeholder:"Comment..."})})]},m.id))})]})})}),e.jsx(Xa,{executionId:s}),e.jsxs("div",{className:"flex items-center justify-between bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"text-sm text-gray-400",children:[e.jsx("span",{className:"text-emerald-400 font-medium",children:H})," of ",e.jsx("span",{className:"text-gray-200 font-medium",children:Q})," steps passed"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[R?e.jsxs("span",{className:`text-xs px-3 py-2 rounded-lg border flex items-center gap-1.5 ${R.status==="open"?"bg-red-500/10 text-red-400 border-red-500/20":R.status==="in_progress"?"bg-amber-500/10 text-amber-400 border-amber-500/20":R.status==="resolved"?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":"bg-gray-500/10 text-gray-400 border-gray-500/20"}`,title:R.title,children:[e.jsx(Ee,{className:"w-3.5 h-3.5"}),R.id," — ",e.jsx("span",{className:"capitalize",children:R.status.replace("_"," ")})]}):$>0?e.jsxs("button",{onClick:V,disabled:A.isPending,className:"bg-red-600/80 hover:bg-red-600 text-white rounded-lg px-4 py-2 text-sm flex items-center gap-2 disabled:opacity-50",title:"Create a defect with all failed step details",children:[A.isPending?e.jsx(se,{className:"w-4 h-4 animate-spin"}):e.jsx(Ee,{className:"w-4 h-4"}),"Create Defect (",$," failed)"]}):null,e.jsxs("button",{onClick:re,disabled:j.isPending,className:"bg-emerald-600/80 hover:bg-emerald-600 text-white rounded-lg px-4 py-2 text-sm flex items-center gap-2 disabled:opacity-50",children:[e.jsx(ve,{className:"w-4 h-4"}),"Pass All Steps"]}),e.jsxs("button",{onClick:a,className:"bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-4 py-2 text-sm flex items-center gap-2",children:[e.jsx(va,{className:"w-4 h-4 rotate-180"}),"Back to Cycle"]})]})]})]})}function kr(){const{user:s}=st(),a=(s==null?void 0:s.displayName)||(s==null?void 0:s.username)||"Unknown",[l]=Nt("view",["plans","plan-detail","cycle-execution","step-execution"],"plans"),[h]=Je("planId"),[c]=Je("cycleId"),[C]=Je("execId"),u=As(),[g,p]=r.useState(""),[f,y]=r.useState(""),[j,N]=r.useState(!1),[A,x]=r.useState(!1),[o,w]=r.useState(!1),[I,R]=r.useState(null),[H,$]=r.useState(null),[Q,V]=Nt("subtab",["testcases","cycles"],"testcases"),[k,ee]=r.useState(""),[D,B]=r.useState(null),[q,J]=r.useState(""),{data:U,isLoading:ae}=Fs(g||void 0),{data:re}=zs(h??""),{data:n}=Bs(h??""),{data:m}=Ls(h??""),{data:M}=Us(c??""),{data:L}=Os(c??"",f||void 0),F=qs(),_=Hs(),lt=Ks(),nt=Qs(),ze=Vs(),it=r.useMemo(()=>{const t=Array.isArray(U)?U:(U==null?void 0:U.plans)??(U==null?void 0:U.data)??[];if(!k)return t;const i=k.toLowerCase();return t.filter(v=>{var T,E;return((T=v.name)==null?void 0:T.toLowerCase().includes(i))||((E=v.description)==null?void 0:E.toLowerCase().includes(i))})},[U,k]),Ce=r.useMemo(()=>Array.isArray(n)?n:(n==null?void 0:n.testCases)??(n==null?void 0:n.data)??[],[n]),Be=r.useMemo(()=>Array.isArray(m)?m:(m==null?void 0:m.cycles)??(m==null?void 0:m.data)??[],[m]),W=r.useMemo(()=>Array.isArray(L)?L:(L==null?void 0:L.executions)??(L==null?void 0:L.data)??[],[L]),b=re,S=M,Gt=r.useCallback(t=>{u({view:"plan-detail",planId:t,subtab:null})},[u]),Wt=r.useCallback(t=>{y(""),u({view:"cycle-execution",cycleId:t})},[u]),Yt=r.useCallback(t=>{u({view:"step-execution",execId:t})},[u]),Zt=r.useCallback(()=>{l==="step-execution"?u({view:"cycle-execution",execId:null}):l==="cycle-execution"?u({view:"plan-detail",cycleId:null,subtab:"cycles"}):l==="plan-detail"&&u({view:null,planId:null})},[l,u]),es=r.useCallback((t,i)=>{xe({kind:"delete-plan",planId:t,planName:i})},[]),ts=r.useCallback(t=>{F.mutate(t,{onSuccess:()=>{h===t&&u({view:null,planId:null})}})},[F,h]),ss=r.useCallback((t,i)=>{h&&xe({kind:"remove-tc",testCaseId:t,tcTitle:i})},[h]),as=r.useCallback(t=>{h&&_.mutate({planId:h,testCaseIds:[t]})},[_,h]),rs=r.useCallback((t,i)=>{xe({kind:"delete-cycle",cycleId:t,cycleName:i})},[]),ls=r.useCallback(t=>{lt.mutate(t)},[lt]),ct=es,ns=ss,is=rs,je=r.useCallback((t,i)=>{nt.mutate({id:t,data:{status:i,executedBy:a}})},[nt,a]),cs=r.useCallback(()=>{!D||!q.trim()||ze.mutate({cycleId:D,data:{name:q.trim()}},{onSuccess:()=>{B(null),J("")}})},[ze,D,q]),ot=qt(),dt=Js(),Le=Xs(),Ue=Gs(),{toast:me}=tt(),[os,xt]=r.useState(!1),[ds,ut]=r.useState(!0),[ke,xs]=r.useState(null),Oe=r.useRef(null),us=t=>{const i=t.currentTarget.parentElement;if(!i)return;const v=i.getBoundingClientRect();Oe.current={dx:t.clientX-v.left,dy:t.clientY-v.top,h:v.height};const T=P=>{const te=Oe.current;te&&xs({x:Math.max(8,Math.min(window.innerWidth-308,P.clientX-te.dx)),y:Math.max(8,Math.min(window.innerHeight-120,P.clientY-te.dy)),h:te.h})},E=()=>{Oe.current=null,window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",E)};window.addEventListener("pointermove",T),window.addEventListener("pointerup",E)},[Y,qe]=r.useState(null),He=r.useRef(null),{data:le}=Ws(Y,!!Y),[X,he]=r.useState(null),{mode:ms}=Lt(),hs=ms==="mobile",Ke=Ht(),[Ya,Za]=r.useState(new Set),[ne,Qe]=r.useState(new Set),[ie,pe]=r.useState(!1),{data:Se}=Ys(l==="cycle-execution"?c:null,{busy:!!Y||ie||ne.size>0}),ce=r.useMemo(()=>{const t=(Se==null?void 0:Se.executions)??[];return Array.isArray(t)?t:[]},[Se]),[d,xe]=r.useState(null),mt=r.useMemo(()=>W.map(t=>t.id),[W]),ps=r.useMemo(()=>W.map(t=>`${t.id}:${t.status}`).join(","),[W]),{data:Te,refetch:gs}=et({queryKey:["exec-defects",c,ps],queryFn:()=>Ut(mt),enabled:mt.length>0&&l==="cycle-execution"}),bs=r.useMemo(()=>(Te==null?void 0:Te.defects)||{},[Te]),Re=ce.filter(t=>t.hasMappedScript).length,ge=Ps(),Ve=r.useRef("");r.useEffect(()=>{const t=ce.map(i=>`${i.executionId}:${i.automationStatus}`).join(",");Ve.current&&Ve.current!==t&&(ge.invalidateQueries({queryKey:["tm-cycle-executions"]}),ge.invalidateQueries({queryKey:["tm-cycles"]}),ge.invalidateQueries({queryKey:["tm-plans"]}),ge.invalidateQueries({queryKey:["tm-cycle-analytics"]}),ge.invalidateQueries({queryKey:["tm-step-results"]}),ce.forEach(i=>{if(ne.has(i.executionId)&&(i.automationStatus==="completed"||i.automationStatus==="failed")&&i.resultRunId){const v=i.automationStatus==="completed";he({runId:i.resultRunId,passed:v?1:0,failed:v?0:1,total:1,label:i.testCaseTitle}),me(v?"success":"error",`${i.testCaseTitle||"Test"} — ${v?"passed":"failed"}`)}}),Qe(i=>{const v=new Set(i);return ce.forEach(T=>{(T.automationStatus==="completed"||T.automationStatus==="failed")&&v.delete(T.executionId)}),v}),Y||!ce.some(v=>v.automationStatus==="running")&&ie&&pe(!1)),Ve.current=t},[ce,ge,ie,Y,ne,me]),r.useEffect(()=>{var t;if(Y){if(le&&le.running===!1){if(pe(!1),He.current===Y)return;const i=(t=le.run)==null?void 0:t.summary;if(!i){qe(null);return}He.current=Y;const v=i.passed??0,T=i.failed??0,E=i.total??v+T;he({runId:Y,passed:v,failed:T,total:E}),me(T>0?"error":"success",`Automation finished — ${v}/${E} passed${T>0?`, ${T} failed`:""}`);const P=setTimeout(()=>qe(null),1500);return()=>clearTimeout(P)}pe(!0),he(null)}},[le,Y,me]);const ht=r.useMemo(()=>{var T;const i=(((T=le==null?void 0:le.run)==null?void 0:T.results)||[]).find(E=>E.isHook&&E.status==="running");return i?/setup/i.test(i.name||"")?"setup":"teardown":null},[le]),fs=r.useCallback((t,i)=>{xe({kind:"run-single",executionId:t,tcTitle:i})},[]),ys=r.useCallback(t=>{he(null),Qe(i=>new Set(i).add(t)),ot.mutate(t,{onSettled:()=>{setTimeout(()=>{Qe(i=>{const v=new Set(i);return v.delete(t),v})},360*1e3)}})},[ot]),js=fs,Ns=r.useCallback(()=>{c&&xe({kind:"run-all",cycleId:c})},[c]),vs=r.useCallback(()=>{c&&(pe(!0),he(null),He.current=null,dt.mutate(c,{onSuccess:t=>{t!=null&&t.aggregateRunId&&qe(t.aggregateRunId)},onError:()=>pe(!1)}))},[dt,c]),ws=Ns,Cs=ce.some(t=>t.automationStatus==="running"),Ne=ie||ne.size>0||Cs,ks=r.useCallback(()=>{ie&&c&&Le.mutate(c,{onSuccess:()=>setTimeout(()=>pe(!1),2e3)}),ne.forEach(t=>{Ue.mutate(t)}),me("info","Cancelling automation run…")},[Le,Ue,ie,ne,c,me]),K=r.useMemo(()=>{const t={total:0,passed:0,failed:0,blocked:0,skipped:0,not_run:0,in_progress:0};return W.forEach(i=>{t.total++,t[i.status]!==void 0?t[i.status]++:t.not_run++}),t},[W]),Ss=K.total>0?Math.round(K.passed/K.total*100):0,Ts=K.total>0?Math.round((K.total-K.not_run)/K.total*100):0,Pe=e.jsx(Ot,{open:!!d,title:(d==null?void 0:d.kind)==="delete-plan"?"Delete test plan?":(d==null?void 0:d.kind)==="delete-cycle"?"Delete cycle?":(d==null?void 0:d.kind)==="remove-tc"?"Remove test case from plan?":(d==null?void 0:d.kind)==="run-single"?"Run automation script?":(d==null?void 0:d.kind)==="run-all"?"Run all automation scripts in this cycle?":"",description:(d==null?void 0:d.kind)==="delete-plan"?`This will permanently delete "${d.planName??"this test plan"}" along with all its cycles and execution history. This action cannot be undone.`:(d==null?void 0:d.kind)==="delete-cycle"?`This will permanently delete "${d.cycleName??"this cycle"}" along with all its execution results. This action cannot be undone.`:(d==null?void 0:d.kind)==="remove-tc"?`Remove "${d.tcTitle??"this test case"}" from the plan? Existing executions for this test case in any cycle of this plan will also be cleared. The test case itself will not be deleted from the catalog.`:(d==null?void 0:d.kind)==="run-single"?`This will execute the automation script for "${d.tcTitle??"this test case"}" and update its execution status with the result. Long-running scripts may take a few minutes.`:(d==null?void 0:d.kind)==="run-all"?`This will execute every automated test in ${S!=null&&S.name?`"${S.name}"`:"this cycle"} sequentially. Manual test cases are skipped. The cycle's execution status will be updated as each script completes.`:"",confirmLabel:(d==null?void 0:d.kind)==="delete-plan"?"Delete Plan":(d==null?void 0:d.kind)==="delete-cycle"?"Delete Cycle":(d==null?void 0:d.kind)==="remove-tc"?"Remove":(d==null?void 0:d.kind)==="run-single"?"Run Script":(d==null?void 0:d.kind)==="run-all"?"Run All":"Confirm",variant:(d==null?void 0:d.kind)==="run-single"||(d==null?void 0:d.kind)==="run-all"?"primary":"danger",icon:(d==null?void 0:d.kind)==="run-single"||(d==null?void 0:d.kind)==="run-all"?Xe:void 0,onConfirm:()=>{const t=d;xe(null),t&&(t.kind==="delete-plan"?ts(t.planId):t.kind==="delete-cycle"?ls(t.cycleId):t.kind==="remove-tc"?as(t.testCaseId):t.kind==="run-single"?ys(t.executionId):t.kind==="run-all"&&vs())},onCancel:()=>xe(null)});return l==="step-execution"&&C?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-6 max-w-7xl mx-auto",children:e.jsx(Ga,{executionId:C,onBack:()=>Zt(),breadcrumbPlanName:(b==null?void 0:b.name)??"Plan",breadcrumbCycleName:(S==null?void 0:S.name)??"Cycle",onNavigateToPlan:()=>{u({view:"plan-detail",cycleId:null,execId:null})},onNavigateToCycle:()=>{u({view:"cycle-execution",execId:null})}})}),Pe]}):l==="cycle-execution"&&c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-6 max-w-7xl mx-auto space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[e.jsx("button",{onClick:()=>{u({view:null,planId:null,cycleId:null})},className:"hover:text-gray-100 transition-colors",children:"Test Plans"}),e.jsx(ye,{className:"w-4 h-4"}),e.jsx("button",{onClick:()=>{u({view:"plan-detail",cycleId:null})},className:"hover:text-gray-100 transition-colors truncate max-w-[200px]",children:(b==null?void 0:b.name)??"Plan"}),e.jsx(ye,{className:"w-4 h-4"}),e.jsx("span",{className:"text-gray-200 truncate max-w-[200px]",children:(S==null?void 0:S.name)??"Cycle"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:(S==null?void 0:S.name)??"Cycle"}),(S==null?void 0:S.assignedTo)&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-gray-400 mt-1",children:[e.jsx(Ct,{className:"w-3.5 h-3.5"}),S.assignedTo]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[(S==null?void 0:S.id)&&e.jsx("span",{title:"Cycle ID",className:"text-xs font-mono px-2.5 py-1 rounded-lg bg-surface-2 text-brand-300 border border-white/5",children:S.id}),(S==null?void 0:S.status)&&e.jsx("span",{title:"Cycle Status",className:`text-xs px-2.5 py-1 rounded-lg font-medium ${Me[S.status]??We[S.status]??"bg-gray-500/20 text-gray-400"}`,children:z(S.status)})]})]}),e.jsx("div",{className:"mb-4",children:e.jsx(qa,{executions:W})}),e.jsxs("div",{className:"grid grid-cols-3 md:grid-cols-8 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-gray-200",children:K.total}),e.jsx("div",{className:"text-xs text-gray-500",children:"Total"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-emerald-400",children:K.passed}),e.jsx("div",{className:"text-xs text-gray-500",children:"Passed"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-red-400",children:K.failed}),e.jsx("div",{className:"text-xs text-gray-500",children:"Failed"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-orange-400",children:K.blocked}),e.jsx("div",{className:"text-xs text-gray-500",children:"Blocked"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-gray-400",children:K.skipped}),e.jsx("div",{className:"text-xs text-gray-500",children:"Skipped"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-slate-400",children:K.not_run}),e.jsx("div",{className:"text-xs text-gray-500",children:"Not Run"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-lg font-bold text-emerald-300",children:[Ss,"%"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"Pass Rate"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-lg font-bold text-blue-300",children:[Ts,"%"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"Completion"})]})]})]}),e.jsx(Ha,{cycleId:c}),e.jsx("div",{className:"flex items-center gap-1 bg-surface-1 rounded-xl border border-white/5 p-1.5",children:[{label:"All",value:""},...Ft.map(t=>({label:z(t),value:t}))].map(t=>e.jsx("button",{onClick:()=>y(t.value),className:`px-3 py-1.5 text-sm rounded-lg transition-colors ${f===t.value?"bg-brand-500/15 text-brand-300 font-medium":"text-gray-400 hover:text-gray-200 hover:bg-surface-2"}`,children:t.label},t.value))}),Re>0&&e.jsxs("div",{className:"flex items-center justify-between bg-surface-1 rounded-xl border border-white/5 px-4 py-3",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(kt,{className:"w-4 h-4 text-cyan-400"}),e.jsxs("span",{className:"text-gray-300",children:[e.jsx("span",{className:"font-medium text-cyan-300",children:Re})," of ",W.length," test cases have automation scripts"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>xt(!0),disabled:Ne,title:"Run settings & hooks (applies to all cycles)",className:"bg-surface-2 hover:bg-surface-3 disabled:opacity-50 disabled:cursor-not-allowed text-gray-200 border border-white/10 rounded-lg px-3 py-2 text-sm font-medium flex items-center gap-2 transition-colors",children:[e.jsx(Ye,{className:"w-4 h-4"})," Settings"]}),e.jsx("span",{children:e.jsx("button",{onClick:ws,disabled:Ne||Re===0,className:"bg-cyan-600 hover:bg-cyan-500 disabled:bg-gray-600 disabled:cursor-not-allowed text-white rounded-lg px-4 py-2 text-sm font-medium flex items-center gap-2 transition-colors",children:ie?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"w-4 h-4 animate-spin"})," ",ht==="setup"?"Running setup…":ht==="teardown"?"Running teardown…":"Running Automation..."]}):ne.size>0?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"w-4 h-4 animate-spin"})," Running Test…"]}):e.jsxs(e.Fragment,{children:[e.jsx(St,{className:"w-4 h-4"})," Run All Automated (",Re,")"]})})}),Ne&&e.jsxs("button",{onClick:ks,disabled:Le.isPending||Ue.isPending,className:"bg-red-600/90 hover:bg-red-500 disabled:opacity-50 text-white rounded-lg px-3 py-2 text-sm font-medium flex items-center gap-2 transition-colors",children:[e.jsx(ja,{className:"w-4 h-4"})," Cancel"]})]})]}),X&&!ie&&e.jsxs("div",{className:`flex items-center justify-between rounded-xl border px-4 py-3 ${X.failed>0?"bg-red-500/10 border-red-500/20":"bg-emerald-500/10 border-emerald-500/20"}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5 text-sm",children:[X.failed>0?e.jsx(De,{className:"w-4 h-4 text-red-400 flex-shrink-0"}):e.jsx(ve,{className:"w-4 h-4 text-emerald-400 flex-shrink-0"}),e.jsx("span",{className:X.failed>0?"text-red-200":"text-emerald-200",children:X.label?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:X.label})," — ",X.failed>0?"failed":"passed","."]}):e.jsxs(e.Fragment,{children:["Automation run complete — ",e.jsxs("span",{className:"font-semibold",children:[X.passed,"/",X.total]})," passed",X.failed>0?`, ${X.failed} failed`:"","."]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("a",{href:`/results?runId=${encodeURIComponent(X.runId)}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 bg-surface-2 hover:bg-surface-3 text-gray-100 border border-white/10 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors",children:[e.jsx(Kt,{className:"w-3.5 h-3.5"})," View Result"]}),e.jsx("button",{onClick:()=>he(null),title:"Dismiss",className:"text-gray-500 hover:text-gray-200 p-1.5 rounded-lg hover:bg-white/5",children:e.jsx(Z,{className:"w-4 h-4"})})]})]}),hs&&Ne&&(ds?e.jsxs("div",{className:"fixed w-[300px] z-40 flex flex-col rounded-xl border border-white/10 bg-surface-1 shadow-2xl overflow-hidden",style:ke?{left:ke.x,top:ke.y,height:ke.h}:{right:16,top:80,bottom:16},children:[e.jsxs("div",{onPointerDown:us,className:"flex items-center gap-2 px-3 py-2 border-b border-white/5 flex-shrink-0 cursor-move select-none touch-none",title:"Drag to move",children:[e.jsx(Tt,{size:13,className:"text-indigo-400"}),e.jsx("span",{className:"text-xs font-medium text-gray-300 flex-1",children:"Live Device — Execution view"}),e.jsx("button",{onClick:()=>ut(!1),onPointerDown:t=>t.stopPropagation(),className:"p-1 rounded text-gray-500 hover:text-gray-300 hover:bg-white/5",title:"Hide live view",children:e.jsx(Z,{size:13})})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(Da,{testRunning:Ne,hideHeader:!0})})]}):e.jsx("button",{onClick:()=>ut(!0),className:"fixed right-0 top-1/2 -translate-y-1/2 z-40 flex items-center gap-1.5 px-2 py-3 rounded-l-lg border border-r-0 border-white/10 bg-surface-1 text-gray-400 hover:text-gray-200 shadow-xl",title:"Show live device view",children:e.jsx(Tt,{size:14})})),os&&e.jsx(Ba,{onClose:()=>xt(!1)}),e.jsx(Wa,{planName:(b==null?void 0:b.name)||"",cycleName:(S==null?void 0:S.name)||"",execStats:K,executionsList:W}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:W.length===0?e.jsxs("div",{className:"text-center py-12 text-gray-500",children:[e.jsx(Rt,{className:"w-10 h-10 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No executions found."})]}):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:"border-b border-white/5",children:[e.jsx("th",{className:"text-left pl-4 pr-1 py-3 text-xs font-medium text-gray-400 w-8"}),e.jsx("th",{className:"text-left pl-1 pr-4 py-3 text-xs font-medium text-gray-400",children:"Test Case"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-24",children:"Priority"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-36",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-44",children:"Quick Actions"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-24",children:"Duration"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-32",children:"Executed By"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-28"})]})}),e.jsx("tbody",{children:W.map(t=>{var be,ue,fe,Ae,$e,pt,gt,bt,ft,yt;const i=t.testCaseTitle??((be=t.testCase)==null?void 0:be.title)??((ue=t.test_case)==null?void 0:ue.title)??t.title??"Untitled",v=t.testCasePriority??((fe=t.testCase)==null?void 0:fe.priority)??((Ae=t.test_case)==null?void 0:Ae.priority)??t.priority;t.testCaseType??(($e=t.testCase)==null?void 0:$e.type)??((pt=t.test_case)==null?void 0:pt.type)??t.type;const T=t.testCaseCode??((gt=t.testCase)==null?void 0:gt.code)??((bt=t.test_case)==null?void 0:bt.code),E=t.testCaseId??((ft=t.testCase)==null?void 0:ft.id)??((yt=t.test_case)==null?void 0:yt.id),P=ce.find(O=>O.executionId===t.id),te=P==null?void 0:P.hasMappedScript,oe=ne.has(t.id)||(P==null?void 0:P.automationStatus)==="running";return e.jsxs(Rs.Fragment,{children:[e.jsxs("tr",{className:"border-b border-white/5 hover:bg-surface-2/50 transition-colors",children:[e.jsx("td",{className:"pl-4 pr-1 py-3 text-center",children:te?e.jsx("span",{title:`Automated (${P==null?void 0:P.framework}) — ${P==null?void 0:P.scriptPath}`,children:e.jsx(kt,{className:"w-4 h-4 text-cyan-400"})}):e.jsx("span",{title:"Manual test",className:"text-gray-600 text-xs",children:"M"})}),e.jsxs("td",{className:"pl-1 pr-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 max-w-[300px]",children:[E&&e.jsx("span",{title:"Test Case ID",className:"text-[11px] font-mono text-brand-300 flex-shrink-0",children:E}),e.jsx("span",{title:i,className:"text-gray-200 font-medium truncate",children:i})]}),T&&e.jsx("div",{className:"text-xs text-gray-500",children:T})]}),e.jsx("td",{className:"px-4 py-3",children:v&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Fe[v]??"bg-gray-500/20 text-gray-400"}`,children:z(v)})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[oe&&e.jsx("span",{title:"Running…",className:"inline-flex items-center gap-1 text-cyan-300 text-xs flex-shrink-0",children:e.jsx(se,{className:"w-3.5 h-3.5 animate-spin"})}),e.jsx("select",{value:t.status??"not_run",onChange:O=>je(t.id,O.target.value),className:`text-xs px-2 py-1 rounded-lg border-0 focus:outline-none focus:ring-1 focus:ring-brand-500/50 cursor-pointer ${oe?"bg-cyan-500/20 text-cyan-300":We[t.status]??"bg-slate-500/20 text-slate-400"}`,children:Ft.map(O=>e.jsx("option",{value:O,children:z(O)},O))})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>je(t.id,"passed"),className:`p-1 rounded transition-colors ${t.status==="passed"?"text-emerald-400":"text-gray-600 hover:text-emerald-400"}`,title:"Pass",children:e.jsx(ve,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>je(t.id,"failed"),className:`p-1 rounded transition-colors ${t.status==="failed"?"text-red-400":"text-gray-600 hover:text-red-400"}`,title:"Fail",children:e.jsx(De,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>je(t.id,"blocked"),className:`p-1 rounded transition-colors ${t.status==="blocked"?"text-orange-400":"text-gray-600 hover:text-orange-400"}`,title:"Block",children:e.jsx(Qt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>je(t.id,"skipped"),className:`p-1 rounded transition-colors ${t.status==="skipped"?"text-gray-300":"text-gray-600 hover:text-gray-300"}`,title:"Skip",children:e.jsx(Vt,{className:"w-4 h-4"})})]})}),e.jsx("td",{className:"px-4 py-3 text-xs text-gray-400",children:t.duration?`${t.duration}s`:"—"}),e.jsx("td",{className:"px-4 py-3 text-xs text-gray-400 max-w-[120px]",children:e.jsx("span",{className:"block truncate",title:t.executedBy??t.executed_by??"",children:t.executedBy??t.executed_by??"—"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[te&&e.jsx("span",{children:e.jsxs("button",{onClick:()=>{var O;return js(t.id,((O=t.testCase)==null?void 0:O.title)||t.title)},disabled:oe,className:"bg-cyan-600 hover:bg-cyan-500 disabled:bg-gray-600 disabled:cursor-not-allowed text-white rounded-lg px-2.5 py-1 text-xs flex items-center gap-1 transition-colors",title:`Run ${P==null?void 0:P.framework} script`,children:[oe?e.jsx(se,{className:"w-3 h-3 animate-spin"}):e.jsx(St,{className:"w-3 h-3"}),oe?"Running":"Run"]})}),e.jsxs("button",{onClick:()=>Yt(t.id),className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-2.5 py-1 text-xs flex items-center gap-1",title:"Manual step execution",children:[e.jsx(Xe,{className:"w-3 h-3"}),"Steps"]}),(()=>{const O=bs[t.id];if(O){const jt={open:"bg-red-500/10 text-red-400 border-red-500/20",in_progress:"bg-amber-500/10 text-amber-400 border-amber-500/20",resolved:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",closed:"bg-gray-500/10 text-gray-400 border-gray-500/20",rejected:"bg-gray-500/10 text-gray-500 border-gray-500/20"};return e.jsxs("span",{className:`text-[10px] px-2 py-1 rounded border inline-flex flex-col items-start leading-tight whitespace-nowrap ${jt[O.status]||jt.open}`,title:O.title,children:[e.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[e.jsx(Ee,{className:"w-3 h-3"}),O.id]}),e.jsx("span",{className:"capitalize opacity-90",children:O.status.replace("_"," ")})]})}return t.status==="failed"||t.status==="blocked"?e.jsxs("button",{onClick:()=>{Ke.mutate({executionId:t.id,createdBy:a},{onSuccess:()=>gs()})},disabled:Ke.isPending,className:"bg-red-600/80 hover:bg-red-600 text-white rounded-lg px-2.5 py-1 text-xs flex items-center gap-1",title:"Create defect from this failed execution",children:[Ke.isPending?e.jsx(se,{className:"w-3 h-3 animate-spin"}):e.jsx(Ee,{className:"w-3 h-3"}),"Defect"]}):null})()]})})]}),oe&&(P==null?void 0:P.resultRunId)&&e.jsx("tr",{className:"border-b border-white/5",children:e.jsx("td",{colSpan:99,className:"px-4 pb-2 pt-0",children:e.jsx(za,{runId:P.resultRunId,layout:"strip",className:"!pl-0 !px-0"})})})]},t.id)})})]})})})]}),Pe]}):l==="plan-detail"&&h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-6 max-w-7xl mx-auto space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[e.jsx("button",{onClick:()=>{u({view:null,planId:null})},className:"hover:text-gray-100 transition-colors",children:"Test Plans"}),e.jsx(ye,{className:"w-4 h-4"}),e.jsx("span",{className:"text-gray-200 truncate max-w-[300px]",children:(b==null?void 0:b.name)??"Plan"})]}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-200 mb-1",children:(b==null?void 0:b.name)??""}),(b==null?void 0:b.description)&&e.jsx("p",{className:"text-sm text-gray-400 mb-3",children:b.description}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[(b==null?void 0:b.id)&&e.jsx("span",{title:"Test Plan ID",className:"text-xs font-mono px-2 py-0.5 rounded bg-surface-2 text-brand-300 border border-white/5",children:b.id}),(b==null?void 0:b.release)&&e.jsx("span",{title:"Release",className:"text-xs px-2 py-0.5 rounded bg-brand-500/15 text-brand-300",children:b.release}),(b==null?void 0:b.sprint)&&e.jsx("span",{title:"Sprint",className:"text-xs px-2 py-0.5 rounded bg-indigo-500/15 text-indigo-300",children:b.sprint}),(b==null?void 0:b.status)&&e.jsx("span",{title:"Plan Status",className:`text-xs px-2 py-0.5 rounded ${Me[b.status]??"bg-gray-500/20 text-gray-400"}`,children:z(b.status)})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsxs("button",{onClick:()=>{R(b),N(!0)},className:"bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-3 py-1.5 text-sm flex items-center gap-1.5",children:[e.jsx(Ze,{className:"w-3.5 h-3.5"})," Edit"]}),e.jsxs("button",{onClick:()=>ct(h,b==null?void 0:b.name),className:"bg-surface-2 hover:bg-red-500/20 text-gray-300 hover:text-red-400 rounded-lg px-3 py-1.5 text-sm flex items-center gap-1.5",children:[e.jsx(_e,{className:"w-3.5 h-3.5"})," Delete"]})]})]})}),e.jsxs("div",{className:"flex items-center gap-1 bg-surface-1 rounded-xl border border-white/5 p-1.5",children:[e.jsxs("button",{onClick:()=>V("testcases"),className:`px-4 py-2 text-sm rounded-lg transition-colors flex items-center gap-2 ${Q==="testcases"?"bg-brand-500/15 text-brand-300 font-medium":"text-gray-400 hover:text-gray-200 hover:bg-surface-2"}`,children:[e.jsx(Ie,{className:"w-4 h-4"})," Test Cases",e.jsx("span",{className:"text-xs bg-surface-2 px-1.5 py-0.5 rounded",children:Ce.length})]}),e.jsxs("button",{onClick:()=>V("cycles"),className:`px-4 py-2 text-sm rounded-lg transition-colors flex items-center gap-2 ${Q==="cycles"?"bg-brand-500/15 text-brand-300 font-medium":"text-gray-400 hover:text-gray-200 hover:bg-surface-2"}`,children:[e.jsx(Ge,{className:"w-4 h-4"})," Cycles",e.jsx("span",{className:"text-xs bg-surface-2 px-1.5 py-0.5 rounded",children:Be.length})]})]}),Q==="testcases"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Test Cases in Plan"}),e.jsxs("button",{onClick:()=>w(!0),className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-3 py-1.5 text-sm flex items-center gap-1.5",children:[e.jsx(de,{className:"w-4 h-4"})," Add Test Cases"]})]}),Ce.length===0?e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-8 text-center",children:[e.jsx(Ie,{className:"w-10 h-10 mx-auto mb-2 text-gray-600"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"No test cases added to this plan yet."}),e.jsxs("button",{onClick:()=>w(!0),className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm inline-flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4"})," Add Test Cases"]})]}):e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",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:"border-b border-white/5",children:[e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400",children:"Title"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-24",children:"Priority"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-28",children:"Type"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-28",children:"Automation"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-12"})]})}),e.jsx("tbody",{children:Ce.map(t=>{const i=t.testCase??t.test_case??t;return e.jsxs("tr",{className:"border-b border-white/5 hover:bg-surface-2/50 transition-colors",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i.id&&e.jsx("span",{title:"Test Case ID",className:"text-[11px] font-mono text-brand-300 flex-shrink-0",children:i.id}),e.jsx("span",{title:i.title??"Untitled",className:"flex-1 min-w-0 text-gray-200 font-medium truncate",children:i.title??"Untitled"})]}),i.code&&e.jsx("div",{className:"text-xs text-gray-500 mt-0.5",children:i.code})]}),e.jsx("td",{className:"px-4 py-3",children:i.priority&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Fe[i.priority]??"bg-gray-500/20 text-gray-400"}`,children:z(i.priority)})}),e.jsx("td",{className:"px-4 py-3",children:i.type&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${rt[i.type]??"bg-gray-500/20 text-gray-400"}`,children:z(i.type)})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${i.automationStatus==="automated"||i.automation_status==="automated"?"bg-emerald-500/20 text-emerald-300":i.automationStatus==="needs_update"||i.automation_status==="needs_update"?"bg-amber-500/20 text-amber-300":"bg-gray-500/20 text-gray-400"}`,children:z(i.automationStatus??i.automation_status??"manual")})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:()=>ns(i.id,i.title),className:"p-1 text-gray-500 hover:text-red-400 rounded transition-colors",title:"Remove from plan",children:e.jsx(Z,{className:"w-4 h-4"})})})]},t.id??i.id)})})]})})})]}),Q==="cycles"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Test Cycles"}),e.jsxs("button",{onClick:()=>{$(null),x(!0)},className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-3 py-1.5 text-sm flex items-center gap-1.5",children:[e.jsx(de,{className:"w-4 h-4"})," New Cycle"]})]}),Be.length===0?e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-8 text-center",children:[e.jsx(Ge,{className:"w-10 h-10 mx-auto mb-2 text-gray-600"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"No test cycles created yet."}),e.jsxs("button",{onClick:()=>{$(null),x(!0)},className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm inline-flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4"})," Create Cycle"]})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:Be.map(t=>{const i=t.totalCount??t.totalExecutions??t.total_executions??0,v=t.executedCount??t.executed_count??0,T=t.passedCount??t.passed_count??0,E=t.failedCount??t.failed_count??0,P=E>0;return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 hover:border-white/10 transition-colors group",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-200 truncate",children:t.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[t.id&&e.jsx("span",{title:"Cycle ID",className:"text-xs font-mono px-2 py-0.5 rounded bg-surface-2 text-brand-300 border border-white/5",children:t.id}),t.status&&e.jsx("span",{title:"Cycle Status",className:`text-xs px-2 py-0.5 rounded ${Me[t.status]??We[t.status]??"bg-gray-500/20 text-gray-400"}`,children:z(t.status)}),t.assignedTo&&e.jsxs("span",{title:"Assignee",className:"text-xs text-gray-500 flex items-center gap-1",children:[e.jsx(Ct,{className:"w-3 h-3"})," ",t.assignedTo]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-2 shrink-0",children:[t.endDate&&(()=>{const te=new Date(t.endDate).getTime(),oe=Date.now(),be=te-oe;if(be<=0)return e.jsxs("span",{className:"text-xs text-red-400 flex items-center gap-1 px-1.5 py-0.5 rounded bg-red-500/10",children:[e.jsx(Pt,{className:"w-3 h-3"})," Overdue"]});const ue=Math.floor(be/(1e3*60*60*24)),fe=Math.floor(be%(1e3*60*60*24)/(1e3*60*60)),Ae=ue>0?`${ue}d ${fe}h`:fe>0?`${fe}h`:"< 1h",$e=ue===0?"text-orange-400 bg-orange-500/10":ue<=2?"text-amber-400 bg-amber-500/10":"text-gray-400 bg-surface-2";return e.jsxs("span",{className:`text-xs flex items-center gap-1 px-1.5 py-0.5 rounded ${$e}`,children:[e.jsx(Pt,{className:"w-3 h-3"})," ",Ae]})})(),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>{$(t),x(!0)},className:"p-1 text-gray-500 hover:text-gray-300 rounded",title:"Edit",children:e.jsx(Ze,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>is(t.id,t.name),className:"p-1 text-gray-500 hover:text-red-400 rounded",title:"Delete",children:e.jsx(_e,{className:"w-3.5 h-3.5"})})]})]})]}),i>0&&e.jsx("div",{className:"mb-2",children:e.jsxs("div",{className:"w-full h-2 rounded-full bg-surface-2 overflow-hidden flex",children:[T>0&&e.jsx("div",{className:"bg-emerald-500 h-full",style:{width:`${T/i*100}%`}}),E>0&&e.jsx("div",{className:"bg-red-500 h-full",style:{width:`${E/i*100}%`}}),v-T-E>0&&e.jsx("div",{className:"bg-amber-500 h-full",style:{width:`${(v-T-E)/i*100}%`}})]})}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-400 mb-1",children:[e.jsxs("span",{children:[v,"/",i," executed"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[T>0&&e.jsxs("span",{className:"text-emerald-400",children:[T," passed"]}),E>0&&e.jsxs("span",{className:"text-red-400",children:[E," failed"]}),i-v>0&&e.jsxs("span",{className:"text-gray-500",children:[i-v," remaining"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>Wt(t.id),className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-3 py-1.5 text-xs flex items-center gap-1.5",children:[e.jsx(Xe,{className:"w-3.5 h-3.5"})," Execute"]}),P&&e.jsxs("button",{onClick:()=>{B(t.id),J(`${t.name} - Rerun`)},className:"bg-orange-600/80 hover:bg-orange-600 text-white rounded-lg px-3 py-1.5 text-xs flex items-center gap-1.5",children:[e.jsx(At,{className:"w-3.5 h-3.5"})," Re-run Failed"]})]})]},t.id)})})]}),j&&e.jsx(zt,{editingPlan:I,onClose:()=>{N(!1),R(null)}}),A&&h&&e.jsx(Ka,{planId:h,editingCycle:H,onClose:()=>{x(!1),$(null)}}),o&&h&&e.jsx(Qa,{planId:h,existingTestCaseIds:Ce.map(t=>(t.testCase??t.test_case??t).id),onClose:()=>w(!1)}),D&&we.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>B(null),children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-xl w-full max-w-md p-6 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Re-run Failed Tests"}),e.jsx("button",{onClick:()=>B(null),className:"text-gray-400 hover:text-gray-200",children:e.jsx(Z,{className:"w-5 h-5"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"New Cycle Name"}),e.jsx("input",{value:q,onChange:t=>J(t.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50",placeholder:"e.g. Cycle 1 - Rerun"})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[e.jsx("button",{onClick:()=>B(null),className:"bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-4 py-2 text-sm",children:"Cancel"}),e.jsxs("button",{onClick:cs,disabled:!q.trim()||ze.isPending,className:"bg-orange-600 hover:bg-orange-500 text-white rounded-lg px-4 py-2 text-sm disabled:opacity-50 flex items-center gap-2",children:[e.jsx(At,{className:"w-4 h-4"}),"Re-run"]})]})]})}),document.body)]}),Pe]}):e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(Rt,{size:24,className:"text-brand-300"}),"Test Plans"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Manage test plans, cycles, and execution"})]}),e.jsxs("button",{onClick:()=>{R(null),N(!0)},className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-brand-600 hover:bg-brand-500 rounded-lg transition-colors",children:[e.jsx(de,{size:16})," New Plan"]})]})})}),e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-8 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(at,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),e.jsx("input",{value:k,onChange:t=>ee(t.target.value),className:"w-full bg-surface-1 border border-white/5 rounded-lg pl-10 pr-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50 text-sm",placeholder:"Search plans..."})]}),e.jsx("div",{className:"flex items-center gap-1 bg-surface-1 rounded-lg border border-white/5 p-1",children:[{label:"All",value:""},...Xt.map(t=>({label:z(t),value:t}))].map(t=>e.jsx("button",{onClick:()=>p(t.value),className:`px-3 py-1.5 text-sm rounded-md transition-colors ${g===t.value?"bg-brand-500/15 text-brand-300 font-medium":"text-gray-400 hover:text-gray-200 hover:bg-surface-2"}`,children:t.label},t.value))})]}),ae?e.jsxs("div",{className:"text-center py-16 text-gray-500",children:[e.jsx(Na,{className:"w-8 h-8 mx-auto mb-2 animate-spin opacity-50"}),e.jsx("p",{className:"text-sm",children:"Loading plans..."})]}):it.length===0?e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-12 text-center",children:[e.jsx(Ge,{className:"w-12 h-12 mx-auto mb-3 text-gray-600"}),e.jsx("h3",{className:"text-lg font-medium text-gray-300 mb-1",children:"No test plans found"}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:g?`No plans with status "${z(g)}".`:"Create your first test plan to get started."}),e.jsxs("button",{onClick:()=>{R(null),N(!0)},className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm inline-flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4"})," Create Plan"]})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:it.map(t=>e.jsx(Va,{plan:t,onSelect:()=>Gt(t.id),onEdit:()=>{R(t),N(!0)},onDelete:()=>ct(t.id,t.name)},t.id))}),j&&e.jsx(zt,{editingPlan:I,onClose:()=>{N(!1),R(null)}}),Pe]})]})}function Wa({planName:s,cycleName:a,execStats:l,executionsList:h}){var A,x;const{connectorId:c,isConfigured:C}=Ea(),u=_a(),[g,p]=r.useState(""),[f,y]=r.useState(!1);if(!C)return null;const j=((A=s.match(/([A-Z][A-Z0-9]+-\d+)/))==null?void 0:A[1])||"",N=()=>{const o=g||j;if(!c||!o)return;const w=l.total||0,I=l.failed>0?"❌":"✅",R=l.failed>0?"FAILED":"PASSED",H=w>0?Math.round(l.passed/w*100):0,$={passed:"✅",failed:"❌",blocked:"🚫",skipped:"⏭",not_run:"⬜",in_progress:"🔄"},Q=h.map(k=>`${$[k.status]||"⬜"} ${k.testCaseTitle||"Unknown"} — ${(k.status||"not_run").replace("_"," ").toUpperCase()}`).join(`
|
|
4
|
-
`),V=[`${I} Testver Test Execution — ${R}`,"",`Plan: ${s}`,`Cycle: ${a}`,`Date: ${Bt(new Date)}`,"",`Summary: ${l.passed} passed, ${l.failed} failed, ${l.skipped} skipped, ${l.blocked} blocked (${w} total)`,`Pass Rate: ${H}%`,"","Test Cases:",Q].join(`
|
|
5
|
-
`);u.mutate({connectorId:c,issueKey:o,comment:V},{onSuccess:()=>y(!0)})};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-blue-500/20 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-blue-500/15 flex items-center justify-center",children:e.jsx(Kt,{className:"w-4 h-4 text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-200",children:"Publish Results to JIRA"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Post execution results as a comment on a JIRA ticket"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:g||j,onChange:o=>p(o.target.value),placeholder:"PROJ-123",className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 w-32 focus:outline-none focus:ring-1 focus:ring-brand-500 font-mono"}),e.jsx("button",{onClick:N,disabled:u.isPending||f||!(g||j),className:`flex items-center gap-1.5 px-4 py-1.5 text-sm font-medium rounded-lg transition-colors ${f?"bg-emerald-500/15 text-emerald-400 border border-emerald-500/20":"bg-blue-600 hover:bg-blue-500 text-white disabled:opacity-50"}`,children:u.isPending?e.jsx(se,{size:14,className:"animate-spin"}):f?e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:14})," Published"]}):e.jsxs(e.Fragment,{children:[e.jsx(Sa,{size:14})," Publish"]})})]})]}),u.isError&&e.jsx("p",{className:"text-xs text-red-400 mt-2",children:((x=u.error)==null?void 0:x.message)||"Failed to publish"})]})}export{kr as TestPlansPage};
|