@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
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{r as s,b as Ce,j as e,R as Ms}from"./vendor-react-CTbHBddL.js";import{f as qt}from"./formatDate-T65-Y6Mi.js";import{u as st,a as Ds}from"./vendor-query-BrzmPFT3.js";import{u as wt,a as Ge,b as Es}from"./useTabParam-ChbOedP1.js";import{b as at,y as Is,x as Ot,a8 as rt,gq as Ht,gr as _s}from"./index-BYVxKLrT.js";import{R as Ct,a as zs,L as Fs,Q as Ls}from"./RunState-ifC4zi6M.js";import{C as Kt}from"./ConfirmDialog-t7mpeeSN.js";import{u as Bs}from"./useTestExplorer-DT8frjCK.js";import{u as Us,T as kt}from"./RunTargets-C7vpCbck.js";import{u as qs,a as Os,b as Hs,c as Ks,d as Qs,e as Vs,f as Js,g as Xs,h as Gs,i as Ws,j as Ys,k as Zs,l as ea,m as Qt,n as ta,o as sa,p as aa,q as ra,r as Vt,s as la,t as na,v as ia,w as oa,x as ca,y as da,z as xa,A as ua,B as ma,C as ha,D as pa,E as ga,F as ba,G as fa,H as ya,I as ja}from"./useTestManagement-Xm4Bcx3u.js";import{t as Na,f as St}from"./formatTestName-BKd2Uqhs.js";import{M as va}from"./MobileRunPicker-0h-N2c6d.js";import{ck as et,X as se,b9 as wa,at as Ca,bx as ka,a0 as xe,f as Sa,b4 as de,v as lt,a2 as We,t as ye,U as Tt,bP as Rt,Z as Pt,av as Ta,ap as Ie,r as we,_ as Jt,J as At,df as $t,o as Xt,b1 as Gt,e as _e,bb as tt,b7 as ze,g as Fe,c as Ye,u as Mt,an as Dt,R as Ra,al as Pa,as as Aa,cd as $a,dg as Ma,a6 as Da,b0 as Wt,bL as Et,b8 as It,F as Ea,a3 as Ia,aa as _a,bj as za,bd as Fa,a5 as La}from"./vendor-icons-BKPiFyYV.js";import{R as Ba}from"./MobileRunTarget-Bo_xekig.js";import{u as Ua,a as qa}from"./useJiraConnector-D5ysBBvz.js";import{TagMultiSelectFilter as Oa,SourceSingleSelectFilter as Ha}from"./TestManagementPage-wqYTKP7W.js";import{L as Ka}from"./LiveExecutionView-D5BRe9jq.js";import"./SearchableDevicePicker-BYxYJNWl.js";import"./ImportExportPage-BcR7IQi9.js";import"./excel-BrxuVus5.js";import"./vendor-excel-BFHGVHVC.js";import"./aiHandoff-vhtR29Fh.js";import"./useDebouncedValue-BsHptIvX.js";import"./ExportButton-Dt5RhL-h.js";import"./JiraPushDialog-C2sP4_4h.js";const _t="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 zt({on:a,onChange:r}){return e.jsx("button",{role:"switch","aria-checked":a,onClick:()=>r(!a),className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${a?"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 ${a?"translate-x-4":""}`})})}function Ft({title:a,icon:r,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:r}),a]}),e.jsx("div",{className:"divide-y divide-white/5",children:l})]})}function Y({label:a,desc:r,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:a}),r&&e.jsx("div",{className:"text-[13px] text-gray-500 mt-0.5 leading-snug",children:r})]}),e.jsx("div",{className:"flex-1 min-w-0",children:l})]})}function Lt({value:a,onChange:r}){const{data:l}=Bs(),[h,o]=s.useState(!1),[k,u]=s.useState(!1),[g,p]=s.useState(""),y=s.useRef(null),N=()=>{o(x=>{if(!x&&y.current){const c=window.innerHeight-y.current.getBoundingClientRect().bottom;u(c<320)}return!x}),p("")},v=s.useMemo(()=>{const x=[];for(const c of(l==null?void 0:l.suites)||[])for(const C of c.tests)x.push({file:c.file,name:C.name,command:C.runCommand||"",suiteName:c.name});return x},[l]),w=g.trim()?v.filter(x=>Na(x.name,g)||`${x.suiteName} ${x.file}`.toLowerCase().includes(g.trim().toLowerCase())):v,A=!!(a!=null&&a.testName);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{ref:y,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(Sa,{size:9,className:"text-cyan-400 fill-current flex-shrink-0"}),e.jsx("span",{className:"truncate font-medium",title:a.testName,children:St(a.testName)}),e.jsx("button",{onClick:()=>r(null),title:"Remove test",className:"text-gray-500 hover:text-red-400 flex-shrink-0",children:e.jsx(se,{size:13})})]}):e.jsx("input",{value:(a==null?void 0:a.command)||"",onChange:x=>r(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:N,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:()=>o(!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 ${k?"bottom-full mb-1":"top-full mt-1"}`,children:[e.jsxs("div",{className:"relative mb-1.5",children:[e.jsx(lt,{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:w.length===0?e.jsx("div",{className:"text-xs text-gray-600 py-6 text-center",children:v.length===0?"No tests found in this project.":`No tests match “${g}”.`}):w.slice(0,200).map((x,c)=>e.jsxs("button",{onClick:()=>{r({command:x.command,testName:x.name,file:x.file}),o(!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:St(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}::${c}`))})]})]})]})}function Qa({onClose:a}){const{data:r}=qs(),l=Os(),{toast:h}=at(),{data:o}=st({queryKey:["cloud-providers"],queryFn:Is,staleTime:3e4}),k=((o==null?void 0:o.providers)||[]).filter(z=>z.enabled),u=Ot().mode==="mobile",[g,p]=s.useState(null),[y,N]=s.useState("local"),[v,w]=s.useState(""),[A,x]=s.useState(1),[c,C]=s.useState(0),[_,R]=s.useState(!1),[K,$]=s.useState(""),[V,J]=s.useState(""),[S,ae]=s.useState(""),[E,L]=s.useState(null),[H,X]=s.useState(null),[q,ne]=s.useState(!0),{browserOpts:ie,envOpts:i}=Us(),m=s.useRef(!1);s.useEffect(()=>{!r||m.current||(m.current=!0,N(r.target==="cloud"?"cloud":"local"),w(r.cloudProvider||""),x(r.concurrency||1),C(r.retries||0),R(!!r.headless),$(r.extraArgs||""),J(r.browser||""),ae(r.environment||""),L(r.beforeRun||null),X(r.afterRun||null),ne(r.abortOnSetupFailure??!0))},[r]);const M=()=>{var z;if(u){const I=g==null?void 0:g.payload;return{target:"cloud",cloudProvider:(I==null?void 0:I.cloudProvider)||(r==null?void 0:r.cloudProvider),deviceName:(I==null?void 0:I.deviceName)||void 0,platformName:(I==null?void 0:I.platformName)||void 0,platformVersion:(I==null?void 0:I.platformVersion)||void 0,appId:(I==null?void 0:I.appId)||void 0,appPath:((z=I==null?void 0:I.appPath)==null?void 0:z.trim())||void 0,concurrency:A,retries:c,extraArgs:K.trim()||void 0,environment:S||void 0,beforeRun:E||void 0,afterRun:H||void 0,abortOnSetupFailure:q}}return{target:y,cloudProvider:y==="cloud"&&v||void 0,concurrency:A,retries:c,headless:_,extraArgs:K.trim()||void 0,browser:V||void 0,environment:S||void 0,beforeRun:E||void 0,afterRun:H||void 0,abortOnSetupFailure:q}},B=()=>{l.mutate(M(),{onSuccess:()=>{h("success","Run settings saved"),a()},onError:()=>h("error","Failed to save run settings")})};return Ce.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:a}),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(et,{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:a,className:"text-gray-500 hover:text-gray-200 p-1 rounded-lg hover:bg-surface-2",children:e.jsx(se,{size:18})})]}),e.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4 space-y-4",children:[e.jsxs(Ft,{title:"Run options",icon:e.jsx(et,{size:15}),children:[u?!!r&&e.jsx(Y,{label:"Device & App",desc:"Runs dispatch through the mobile cloud-bridge with this device + app.",children:e.jsx(va,{compact:!0,initial:{cloudProvider:r==null?void 0:r.cloudProvider,deviceName:r==null?void 0:r.deviceName,platformName:r==null?void 0:r.platformName,platformVersion:r==null?void 0:r.platformVersion,appId:r==null?void 0:r.appId,appPath:r==null?void 0:r.appPath},onChange:p})}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{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:()=>N("local"),className:`flex-1 px-2 py-2 text-xs inline-flex items-center justify-center gap-1.5 ${y==="local"?"bg-brand-500/15 text-brand-300":"text-gray-400"}`,children:[e.jsx(wa,{size:12})," Local"]}),e.jsxs("button",{onClick:()=>N("cloud"),className:`flex-1 px-2 py-2 text-xs inline-flex items-center justify-center gap-1.5 border-l border-white/10 ${y==="cloud"?"bg-cyan-500/15 text-cyan-300":"text-gray-400"}`,children:[e.jsx(Ca,{size:12})," Cloud"]})]})}),y==="cloud"&&e.jsx(Y,{label:"Provider",children:e.jsxs("select",{value:v,onChange:z=>w(z.target.value),className:`${_t} max-w-xs`,children:[e.jsx("option",{value:"",children:"Select…"}),k.map(z=>e.jsx("option",{value:z.id,children:z.id.charAt(0).toUpperCase()+z.id.slice(1)},z.id))]})})]}),e.jsx(Y,{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:z=>x(Number(z.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(Y,{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:c,onChange:z=>C(Number(z.target.value)),className:"flex-1 accent-brand-500"}),e.jsx("span",{className:"text-sm text-gray-300 tabular-nums w-20 text-right",children:c===0?"off":`${c}×`})]})}),!u&&e.jsx(Y,{label:"Headless",desc:"Hide the browser window during the run.",children:e.jsx(zt,{on:_,onChange:R})}),ie.length>0&&e.jsx(Y,{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(kt,{isEnv:!1,value:V,onChange:J,options:ie})})}),i.length>0&&e.jsx(Y,{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(kt,{isEnv:!0,value:S,onChange:ae,options:i})})}),e.jsxs(Y,{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:K,onChange:z=>$(z.target.value),placeholder:"-DbaseUrl=https://staging.example.com -Dbrowser=firefox",className:`${_t} 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(Ft,{title:"Setup & teardown (Run All)",icon:e.jsx(ka,{size:15}),children:[e.jsx(Y,{label:"Before run",desc:"Runs once before the cycle — only for “Run All”.",alignTop:!0,children:e.jsx(Lt,{value:E,onChange:L})}),e.jsx(Y,{label:"After run",desc:"Runs last — even if tests fail.",alignTop:!0,children:e.jsx(Lt,{value:H,onChange:X})}),e.jsx(Y,{label:"Abort on setup failure",desc:"Skip the tests if the before-run hook fails.",children:e.jsx(zt,{on:q,onChange:ne})})]})]}),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:a,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:B,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(xe,{size:14,className:"animate-spin"}):null," Save"]})]})]})]}),document.body)}const Yt=["draft","active","completed","archived"],Bt=["not_run","in_progress","passed","failed","blocked","skipped"],Ee={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"},Ze={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"},Va={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"},Ja={passed:"bg-emerald-500/5",failed:"bg-red-500/5",blocked:"bg-orange-500/5",skipped:"bg-gray-500/5",not_run:""},Le={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"},nt={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 F(a){return a.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function Xa(a){return a?new Date(a).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—"}function Ga({executions:a}){const r=s.useMemo(()=>{const h={passed:0,failed:0,blocked:0,skipped:0,not_run:0,in_progress:0};return a.forEach(o=>{h[o.status]=(h[o.status]||0)+1}),h},[a]),l=a.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 o=r[h]/l*100;return o===0?null:e.jsx("div",{className:`${Va[h]} h-full`,style:{width:`${o}%`}},h)})})}function Wa({cycleId:a}){const{data:r}=ca(a);if(!r)return null;const l=r,h=l.passRate??(l.executedCount>0?Math.round(l.passedCount/l.executedCount*100):0),o=l.completionRate??(l.totalCount>0?Math.round((l.totalCount-(l.notRunCount??0))/l.totalCount*100):0),k=l.failedCount??l.failed??0,u=l.totalDuration??0,g=p=>{if(!p||p<=0)return"0s";const y=Math.floor(p/3600),N=Math.floor(p%3600/60),v=p%60;return y>0?`${y}h ${N}m ${v}s`:N>0?`${N}m ${v}s`:`${v}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(Aa,{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($a,{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(Ma,{className:"w-5 h-5 text-blue-400 mx-auto mb-1"}),e.jsxs("div",{className:"text-2xl font-bold text-blue-300",children:[o,"%"]}),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(Ie,{className:"w-5 h-5 text-red-400 mx-auto mb-1"}),e.jsx("div",{className:"text-2xl font-bold text-red-300",children:k}),e.jsx("div",{className:"text-xs text-gray-400",children:"Failed"})]})]})}function Ut({onClose:a,editingPlan:r}){const[l,h]=s.useState((r==null?void 0:r.name)??""),[o,k]=s.useState((r==null?void 0:r.description)??""),[u,g]=s.useState((r==null?void 0:r.release)??""),[p,y]=s.useState((r==null?void 0:r.sprint)??""),[N,v]=s.useState((r==null?void 0:r.status)??"draft"),w=da(),A=xa(),x=()=>{if(!l.trim())return;const c={name:l.trim(),description:o.trim(),release:u.trim(),sprint:p.trim(),status:N};r?A.mutate({id:r.id,data:c},{onSuccess:a}):w.mutate(c,{onSuccess:a})};return Ce.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-lg p-6 shadow-2xl",onClick:c=>c.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:r?"Edit Plan":"New Test Plan"}),e.jsx("button",{onClick:a,className:"text-gray-400 hover:text-gray-200",children:e.jsx(se,{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:c=>h(c.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:o,onChange:c=>k(c.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:c=>g(c.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:c=>y(c.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:N,onChange:c=>v(c.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:Yt.map(c=>e.jsx("option",{value:c,children:F(c)},c))})]})]}),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:x,disabled:!l.trim()||w.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(Wt,{className:"w-4 h-4"}),r?"Update Plan":"Create Plan"]})]})]})}),document.body)}function Ya({planId:a,onClose:r,editingCycle:l}){const[h,o]=s.useState((l==null?void 0:l.name)??""),[k,u]=s.useState((l==null?void 0:l.assignedTo)??""),[g,p]=s.useState(l!=null&&l.startDate?new Date(l.startDate).toISOString().split("T")[0]:""),[y,N]=s.useState(l!=null&&l.endDate?new Date(l.endDate).toISOString().split("T")[0]:""),v=ua(),w=ma(),A=()=>{if(!h.trim())return;const x={name:h.trim(),assignedTo:k.trim()||void 0};g&&(x.startDate=new Date(g).getTime()),y&&(x.endDate=new Date(y).getTime()),l?w.mutate({id:l.id,data:x},{onSuccess:r}):v.mutate({planId:a,data:x},{onSuccess:r})};return Ce.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,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:r,className:"text-gray-400 hover:text-gray-200",children:e.jsx(se,{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=>o(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:k,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:y,onChange:x=>N(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:r,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()||v.isPending||w.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(Wt,{className:"w-4 h-4"}),l?"Update Cycle":"Create Cycle"]})]})]})}),document.body)}function Za({planId:a,existingTestCaseIds:r,onClose:l}){const h=ha(),[o,k]=s.useState(new Set),[u,g]=s.useState(""),[p,y]=s.useState(""),[N,v]=s.useState(""),[w,A]=s.useState(""),[x,c]=s.useState(""),[C,_]=s.useState(new Set),[R,K]=s.useState(null),{data:$}=pa(),V=(Array.isArray($)?$:$==null?void 0:$.tags)??[],{data:J}=ga(),S=(J==null?void 0:J.sources)??[],ae=s.useMemo(()=>{const i={limit:500};return u.trim()&&(i.search=u.trim()),p&&(i.priority=p),N&&(i.type=N),w&&(i.status=w),x&&(i.automationStatus=x),C.size>0&&(i.tagIds=Array.from(C)),R&&(i.sourceId=R),i},[u,p,N,w,x,C,R]),{data:E}=ba(ae),L=s.useMemo(()=>{const i=Array.isArray(E)?E:(E==null?void 0:E.testCases)??(E==null?void 0:E.data)??[],m=new Set(r);return i.filter(M=>!m.has(M.id))},[E,r]),H=(p?1:0)+(N?1:0)+(w?1:0)+(x?1:0)+(C.size>0?1:0)+(R?1:0),X=()=>{y(""),v(""),A(""),c(""),_(new Set),K(null)},q=i=>{k(m=>{const M=new Set(m);return M.has(i)?M.delete(i):M.add(i),M})},ne=()=>{o.size===L.length?k(new Set):k(new Set(L.map(i=>i.id)))},ie=()=>{o.size!==0&&h.mutate({planId:a,testCaseIds:Array.from(o)},{onSuccess:l})};return Ce.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:i=>i.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(se,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx(lt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),e.jsx("input",{value:u,onChange:i=>g(i.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:i=>y(i.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:N,onChange:i=>v(i.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(i=>e.jsx("option",{value:i,children:i==="api"?"API":i==="ui"?"UI":i==="e2e"?"E2E":F(i)},i))]}),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:w,onChange:i=>A(i.target.value),title:"Status",children:[e.jsx("option",{value:"",children:"Status"}),["draft","active","deprecated","archived"].map(i=>e.jsx("option",{value:i,children:F(i)},i))]}),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:i=>c(i.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(Oa,{tags:V,selectedIds:C,onChange:_}),e.jsx(Ha,{sources:S,selectedId:R,onChange:K}),H>0&&e.jsxs("button",{onClick:X,className:"flex items-center gap-1 px-2 py-1 text-xs text-gray-400 hover:text-gray-200 transition-colors",children:[e.jsx(se,{className:"w-3 h-3"}),"Clear (",H,")"]})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3 text-sm text-gray-400",children:[e.jsxs("button",{onClick:ne,className:"flex items-center gap-1.5 hover:text-gray-200",children:[o.size===L.length&&L.length>0?e.jsx(Et,{className:"w-4 h-4 text-brand-400"}):e.jsx(It,{className:"w-4 h-4"}),"Select All"]}),e.jsxs("span",{className:"ml-auto",children:[o.size," selected"]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 min-h-0",children:[L.length===0&&e.jsx("div",{className:"text-center text-gray-500 py-8",children:"No test cases available to add."}),L.map(i=>{var m,M;return e.jsxs("button",{onClick:()=>q(i.id),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-left hover:bg-surface-2 transition-colors ${o.has(i.id)?"bg-brand-500/10 border border-brand-500/20":"border border-transparent"}`,children:[o.has(i.id)?e.jsx(Et,{className:"w-4 h-4 text-brand-400 shrink-0"}):e.jsx(It,{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:[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,className:"text-sm text-gray-200 truncate",children:i.title})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[(((m=i.folder)==null?void 0:m.name)||i.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(Ea,{className:"w-2.5 h-2.5"})," ",((M=i.folder)==null?void 0:M.name)||i.folderName]}),i.status&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${i.status==="active"?"bg-emerald-500/15 text-emerald-300":i.status==="draft"?"bg-sky-500/15 text-sky-300":"bg-gray-500/15 text-gray-400"}`,children:F(i.status)}),i.priority&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${Le[i.priority]??"bg-gray-500/20 text-gray-400"}`,children:F(i.priority)}),i.type&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${nt[i.type]??"bg-gray-500/20 text-gray-400"}`,children:F(i.type)})]})]})]},i.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:ie,disabled:o.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 ",o.size," Test Case",o.size!==1?"s":""]})]})]})}),document.body)}function er({plan:a,onSelect:r,onEdit:l,onDelete:h}){const o=a.testCaseCount??a.test_case_count??0,k=a.executedCount??a.executed_count??0,u=a.passedCount??a.passed_count??0,g=a.failedCount??a.failed_count??0,p=o>0?Math.round(k/o*100):0,y=o>0?u/o*100:0,N=o>0?g/o*100:0,v=o>0?(k-u-g)/o*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:r,className:"text-left flex-1 min-w-0",children:e.jsx("h3",{title:a.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:a.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(tt,{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(ze,{className:"w-3.5 h-3.5"})})]})]}),a.description&&e.jsx("p",{className:"text-xs text-gray-400 mb-3 line-clamp-2",children:a.description}),e.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[a.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:a.id}),a.release&&e.jsx("span",{title:"Release",className:"text-xs px-2 py-0.5 rounded bg-brand-500/15 text-brand-300",children:a.release}),a.sprint&&e.jsx("span",{title:"Sprint",className:"text-xs px-2 py-0.5 rounded bg-indigo-500/15 text-indigo-300",children:a.sprint}),e.jsx("span",{title:"Plan Status",className:`text-xs px-2 py-0.5 rounded ${Ee[a.status]??"bg-gray-500/20 text-gray-400"}`,children:F(a.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(Fe,{className:"w-3.5 h-3.5"})," ",o," test cases"]}),e.jsxs("span",{children:[k,"/",o," executed (",p,"%)"]})]}),e.jsxs("div",{className:"w-full h-2 rounded-full bg-surface-2 overflow-hidden mb-1 flex",children:[y>0&&e.jsx("div",{className:"bg-emerald-500 h-full transition-all",style:{width:`${y}%`}}),N>0&&e.jsx("div",{className:"bg-red-500 h-full transition-all",style:{width:`${N}%`}}),v>0&&e.jsx("div",{className:"bg-amber-500 h-full transition-all",style:{width:`${v}%`}})]}),k>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"]}),o-k>0&&e.jsxs("span",{className:"text-gray-500",children:[o-k," 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(Ia,{className:"w-3 h-3"}),Xa(a.createdAt??a.created_at)]}),e.jsxs("button",{onClick:r,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(_a,{className:"w-3.5 h-3.5"})," Open Plan"]})]})]})}const tr=a=>a?a<1024?`${a} B`:a<1024*1024?`${(a/1024).toFixed(1)} KB`:`${(a/(1024*1024)).toFixed(1)} MB`:"0 B";function sr({executionId:a}){const{toast:r}=at(),{user:l}=rt(),h=(l==null?void 0:l.displayName)||(l==null?void 0:l.username)||"",{data:o,isLoading:k}=fa(a),u=ya(),g=ja(),p=s.useRef(null),[y,N]=s.useState(null),v=(o==null?void 0:o.attachments)??[],w=25*1024*1024,A=async c=>{if(!(!c||c.length===0)){for(const C of Array.from(c)){if(C.size>w){r("error",`"${C.name}" exceeds the 25 MB limit and was skipped.`);continue}const _=await new Promise((R,K)=>{const $=new FileReader;$.onload=()=>R(($.result||"").split(",")[1]||""),$.onerror=()=>K($.error),$.readAsDataURL(C)});await u.mutateAsync({executionId:a,data:{fileName:C.name,fileType:C.type,fileSize:C.size,fileData:_,uploadedBy:h}})}p.current&&(p.current.value="")}},x=async c=>{try{const C=await _s(c.id),_=document.createElement("a");_.href=`data:${c.fileType||"application/octet-stream"};base64,${C.fileData}`,_.download=c.fileName,document.body.appendChild(_),_.click(),document.body.removeChild(_)}catch{r("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(za,{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:[v.length," file",v.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(xe,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Fa,{className:"w-3.5 h-3.5"}),"Attach Files",e.jsx("input",{ref:p,type:"file",multiple:!0,className:"hidden",onChange:c=>A(c.target.files),disabled:u.isPending})]})]}),k?e.jsx("div",{className:"text-xs text-gray-500 py-2",children:"Loading…"}):v.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:v.map(c=>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(Fe,{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:c.fileName}),e.jsxs("div",{className:"text-[11px] text-gray-500",children:[tr(c.fileSize),c.uploadedBy?` · ${c.uploadedBy}`:"",c.createdAt?` · ${qt(c.createdAt)}`:""]})]}),e.jsx("button",{type:"button",onClick:()=>x(c),className:"p-1.5 rounded hover:bg-white/10 text-gray-400 hover:text-gray-200",title:"Download",children:e.jsx(La,{className:"w-3.5 h-3.5"})}),e.jsx("button",{type:"button",onClick:()=>N({id:c.id,name:c.fileName}),className:"p-1.5 rounded hover:bg-red-500/10 text-gray-400 hover:text-red-400",title:"Delete",children:e.jsx(ze,{className:"w-3.5 h-3.5"})})]},c.id))}),e.jsx(Kt,{open:!!y,title:"Remove evidence?",description:y?`Delete "${y.name}" from this execution? This cannot be undone.`:"",confirmLabel:"Delete",onCancel:()=>N(null),onConfirm:()=>{y&&(g.mutate({id:y.id,executionId:a}),N(null))}})]})}function ar({executionId:a,onBack:r,breadcrumbPlanName:l,breadcrumbCycleName:h,onNavigateToPlan:o,onNavigateToCycle:k}){var i;const{user:u}=rt(),g=(u==null?void 0:u.displayName)||(u==null?void 0:u.username)||"Unknown",{data:p,isLoading:y}=na(a),N=ia(),v=oa(),w=s.useMemo(()=>(Array.isArray(p)?p:(p==null?void 0:p.steps)??(p==null?void 0:p.data)??[]).sort((M,B)=>(M.stepNumber??M.step_number??0)-(B.stepNumber??B.step_number??0)),[p]);Qt();const A=Vt(),[x,c]=s.useState(!1),{data:C,refetch:_}=st({queryKey:["exec-defects",a],queryFn:()=>Ht([a])}),R=((i=C==null?void 0:C.defects)==null?void 0:i[a])||null,K=w.filter(m=>m.status==="passed").length,$=w.filter(m=>m.status==="failed").length,V=w.length,J=()=>{A.mutate({executionId:a,createdBy:g},{onSuccess:()=>_()})},S=p==null?void 0:p.execution,ae=(S==null?void 0:S.testCaseTitle)??"Test Case",E=S==null?void 0:S.testCasePriority,L=S==null?void 0:S.testCaseType,H=S==null?void 0:S.testCasePreconditions;S==null||S.scriptMapping;const X=(m,M)=>{N.mutate({id:m.id,data:{status:M,executedBy:g}})},q=(m,M)=>{N.mutate({id:m.id,data:{actualResult:M,executedBy:g}})},ne=(m,M)=>{N.mutate({id:m.id,data:{comment:M,executedBy:g}})},ie=()=>{v.mutate({executionId:a,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:()=>{o()},className:"hover:text-gray-100 transition-colors",children:"Test Plans"}),e.jsx(ye,{className:"w-4 h-4"}),e.jsx("button",{onClick:o,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:k,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:ae})]}),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:ae}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[E&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Le[E]??"bg-gray-500/20 text-gray-400"}`,children:F(E)}),L&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${nt[L]??"bg-gray-500/20 text-gray-400"}`,children:F(L)})]}),H&&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:H})]}),!1]}),y?e.jsx("div",{className:"text-center py-12 text-gray-500",children:"Loading steps..."}):w.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:w.map((m,M)=>e.jsxs("tr",{className:`border-b border-white/5 ${Ja[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:()=>X(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(we,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>X(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(Ie,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>X(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(Xt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>X(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(Gt,{className:"w-4 h-4"})})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("textarea",{defaultValue:m.actualResult??m.actual_result??"",onBlur:B=>q(m,B.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:B=>ne(m,B.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(sr,{executionId:a}),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:K})," of ",e.jsx("span",{className:"text-gray-200 font-medium",children:V})," 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(_e,{className:"w-3.5 h-3.5"}),R.id," — ",e.jsx("span",{className:"capitalize",children:R.status.replace("_"," ")})]}):$>0?e.jsxs("button",{onClick:J,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(xe,{className:"w-4 h-4 animate-spin"}):e.jsx(_e,{className:"w-4 h-4"}),"Create Defect (",$," failed)"]}):null,e.jsxs("button",{onClick:ie,disabled:v.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(we,{className:"w-4 h-4"}),"Pass All Steps"]}),e.jsxs("button",{onClick:r,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(Pa,{className:"w-4 h-4 rotate-180"}),"Back to Cycle"]})]})]})]})}function Dr(){const{user:a}=rt(),r=(a==null?void 0:a.displayName)||(a==null?void 0:a.username)||"Unknown",[l]=wt("view",["plans","plan-detail","cycle-execution","step-execution"],"plans"),[h]=Ge("planId"),[o]=Ge("cycleId"),[k]=Ge("execId"),u=Es(),[g,p]=s.useState(""),[y,N]=s.useState(""),[v,w]=s.useState(!1),[A,x]=s.useState(!1),[c,C]=s.useState(!1),[_,R]=s.useState(null),[K,$]=s.useState(null),[V,J]=wt("subtab",["testcases","cycles"],"testcases"),[S,ae]=s.useState(""),[E,L]=s.useState(null),[H,X]=s.useState(""),{data:q,isLoading:ne}=Hs(g||void 0),{data:ie}=Ks(h??""),{data:i}=Qs(h??""),{data:m}=Vs(h??""),{data:M}=Js(o??""),{data:B}=Xs(o??"",y||void 0),z=Gs(),I=Ws(),it=Ys(),ot=Zs(),Be=ea(),ct=s.useMemo(()=>{const t=Array.isArray(q)?q:(q==null?void 0:q.plans)??(q==null?void 0:q.data)??[];if(!S)return t;const n=S.toLowerCase();return t.filter(f=>{var j,D;return((j=f.name)==null?void 0:j.toLowerCase().includes(n))||((D=f.description)==null?void 0:D.toLowerCase().includes(n))})},[q,S]),ke=s.useMemo(()=>Array.isArray(i)?i:(i==null?void 0:i.testCases)??(i==null?void 0:i.data)??[],[i]),Ue=s.useMemo(()=>Array.isArray(m)?m:(m==null?void 0:m.cycles)??(m==null?void 0:m.data)??[],[m]),Z=s.useMemo(()=>Array.isArray(B)?B:(B==null?void 0:B.executions)??(B==null?void 0:B.data)??[],[B]),b=ie,T=M,Zt=s.useCallback(t=>{u({view:"plan-detail",planId:t,subtab:null})},[u]),es=s.useCallback(t=>{N(""),u({view:"cycle-execution",cycleId:t})},[u]),ts=s.useCallback(t=>{u({view:"step-execution",execId:t})},[u]),ss=s.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]),as=s.useCallback((t,n)=>{ue({kind:"delete-plan",planId:t,planName:n})},[]),rs=s.useCallback(t=>{z.mutate(t,{onSuccess:()=>{h===t&&u({view:null,planId:null})}})},[z,h]),ls=s.useCallback((t,n)=>{h&&ue({kind:"remove-tc",testCaseId:t,tcTitle:n})},[h]),ns=s.useCallback(t=>{h&&I.mutate({planId:h,testCaseIds:[t]})},[I,h]),is=s.useCallback((t,n)=>{ue({kind:"delete-cycle",cycleId:t,cycleName:n})},[]),os=s.useCallback(t=>{it.mutate(t)},[it]),dt=as,cs=ls,ds=is,je=s.useCallback((t,n)=>{ot.mutate({id:t,data:{status:n,executedBy:r}})},[ot,r]),xs=s.useCallback(()=>{!E||!H.trim()||Be.mutate({cycleId:E,data:{name:H.trim()}},{onSuccess:()=>{L(null),X("")}})},[Be,E,H]),xt=Qt(),ut=ta(),qe=sa(),Oe=aa(),{toast:he}=at(),[us,mt]=s.useState(!1),[ms,ht]=s.useState(!0),[Se,hs]=s.useState(null),He=s.useRef(null),ps=t=>{const n=t.currentTarget.parentElement;if(!n)return;const f=n.getBoundingClientRect();He.current={dx:t.clientX-f.left,dy:t.clientY-f.top,h:f.height};const j=P=>{const le=He.current;le&&hs({x:Math.max(8,Math.min(window.innerWidth-308,P.clientX-le.dx)),y:Math.max(8,Math.min(window.innerHeight-120,P.clientY-le.dy)),h:le.h})},D=()=>{He.current=null,window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",D)};window.addEventListener("pointermove",j),window.addEventListener("pointerup",D)},[ee,Ke]=s.useState(null),Qe=s.useRef(null),{data:U}=ra(ee,!!ee),[G,pe]=s.useState(null),{mode:gs}=Ot(),bs=gs==="mobile",Ve=Vt(),[lr,nr]=s.useState(new Set),[oe,Je]=s.useState(new Set),[re,ge]=s.useState(!1),{data:Te}=la(l==="cycle-execution"?o:null,{busy:!!ee||re||oe.size>0}),ce=s.useMemo(()=>{const t=(Te==null?void 0:Te.executions)??[];return Array.isArray(t)?t:[]},[Te]),[d,ue]=s.useState(null),pt=s.useMemo(()=>Z.map(t=>t.id),[Z]),fs=s.useMemo(()=>Z.map(t=>`${t.id}:${t.status}`).join(","),[Z]),{data:Re,refetch:ys}=st({queryKey:["exec-defects",o,fs],queryFn:()=>Ht(pt),enabled:pt.length>0&&l==="cycle-execution"}),js=s.useMemo(()=>(Re==null?void 0:Re.defects)||{},[Re]),Pe=ce.filter(t=>t.hasMappedScript).length,be=Ds(),Xe=s.useRef("");s.useEffect(()=>{const t=ce.map(n=>`${n.executionId}:${n.automationStatus}`).join(",");Xe.current&&Xe.current!==t&&(be.invalidateQueries({queryKey:["tm-cycle-executions"]}),be.invalidateQueries({queryKey:["tm-cycles"]}),be.invalidateQueries({queryKey:["tm-plans"]}),be.invalidateQueries({queryKey:["tm-cycle-analytics"]}),be.invalidateQueries({queryKey:["tm-step-results"]}),ce.forEach(n=>{if(oe.has(n.executionId)&&(n.automationStatus==="completed"||n.automationStatus==="failed")&&n.resultRunId){const f=n.automationStatus==="completed";pe({runId:n.resultRunId,passed:f?1:0,failed:f?0:1,total:1,label:n.testCaseTitle}),he(f?"success":"error",`${n.testCaseTitle||"Test"} — ${f?"passed":"failed"}`)}}),Je(n=>{const f=new Set(n);return ce.forEach(j=>{(j.automationStatus==="completed"||j.automationStatus==="failed")&&f.delete(j.executionId)}),f}),ee||!ce.some(f=>f.automationStatus==="running")&&re&&ge(!1)),Xe.current=t},[ce,be,re,ee,oe,he]),s.useEffect(()=>{var t;if(ee){if(U&&U.running===!1){if(ge(!1),Qe.current===ee)return;const n=(t=U.run)==null?void 0:t.summary;if(!n){Ke(null);return}Qe.current=ee;const f=n.passed??0,j=n.failed??0,D=n.total??f+j;pe({runId:ee,passed:f,failed:j,total:D}),he(j>0?"error":"success",`Automation finished — ${f}/${D} passed${j>0?`, ${j} failed`:""}`);const P=setTimeout(()=>Ke(null),1500);return()=>clearTimeout(P)}ge(!0),pe(null)}},[U,ee,he]);const Ns=s.useMemo(()=>{var f;const t=new Map;if(!(U!=null&&U.running))return t;const n=((f=U.run)==null?void 0:f.results)||[];for(const j of n)j.isHook||!j.executionId||(j.status==="running"?t.set(j.executionId,"running"):j.status==="pending"&&t.set(j.executionId,"queued"));return t},[U]),W=s.useMemo(()=>{var f;if(!(U!=null&&U.running))return null;const t=(((f=U.run)==null?void 0:f.results)||[]).filter(j=>!j.isHook);if(t.length===0)return null;const n=j=>t.filter(D=>D.status===j).length;return{total:t.length,passed:n("passed"),failed:n("failed"),running:n("running"),queued:n("pending")}},[U]),Ae=s.useMemo(()=>{var j;const n=(((j=U==null?void 0:U.run)==null?void 0:j.results)||[]).find(D=>D.isHook&&D.status==="running");return n?/setup/i.test(n.name||"")?"setup":"teardown":null},[U]),vs=s.useCallback((t,n)=>{ue({kind:"run-single",executionId:t,tcTitle:n})},[]),ws=s.useCallback(t=>{pe(null),Je(n=>new Set(n).add(t)),xt.mutate(t,{onSettled:()=>{setTimeout(()=>{Je(n=>{const f=new Set(n);return f.delete(t),f})},360*1e3)}})},[xt]),Cs=vs,ks=s.useCallback(()=>{o&&ue({kind:"run-all",cycleId:o})},[o]),Ss=s.useCallback(()=>{o&&(ge(!0),pe(null),Qe.current=null,ut.mutate(o,{onSuccess:t=>{t!=null&&t.aggregateRunId&&Ke(t.aggregateRunId)},onError:()=>ge(!1)}))},[ut,o]),Ts=ks,Rs=ce.some(t=>t.automationStatus==="running"),Ne=re||oe.size>0||Rs,Ps=s.useCallback(()=>{re&&o&&qe.mutate(o,{onSuccess:()=>setTimeout(()=>ge(!1),2e3)}),oe.forEach(t=>{Oe.mutate(t)}),he("info","Cancelling automation run…")},[qe,Oe,re,oe,o,he]),Q=s.useMemo(()=>{const t={total:0,passed:0,failed:0,blocked:0,skipped:0,not_run:0,in_progress:0};return Z.forEach(n=>{t.total++,t[n.status]!==void 0?t[n.status]++:t.not_run++}),t},[Z]),As=Q.total>0?Math.round(Q.passed/Q.total*100):0,$s=Q.total>0?Math.round((Q.total-Q.not_run)/Q.total*100):0,$e=e.jsx(Kt,{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 ${T!=null&&T.name?`"${T.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"?We:void 0,onConfirm:()=>{const t=d;ue(null),t&&(t.kind==="delete-plan"?rs(t.planId):t.kind==="delete-cycle"?os(t.cycleId):t.kind==="remove-tc"?ns(t.testCaseId):t.kind==="run-single"?ws(t.executionId):t.kind==="run-all"&&Ss())},onCancel:()=>ue(null)});return l==="step-execution"&&k?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-6 max-w-7xl mx-auto",children:e.jsx(ar,{executionId:k,onBack:()=>ss(),breadcrumbPlanName:(b==null?void 0:b.name)??"Plan",breadcrumbCycleName:(T==null?void 0:T.name)??"Cycle",onNavigateToPlan:()=>{u({view:"plan-detail",cycleId:null,execId:null})},onNavigateToCycle:()=>{u({view:"cycle-execution",execId:null})}})}),$e]}):l==="cycle-execution"&&o?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:(T==null?void 0:T.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:(T==null?void 0:T.name)??"Cycle"}),(T==null?void 0:T.assignedTo)&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-gray-400 mt-1",children:[e.jsx(Tt,{className:"w-3.5 h-3.5"}),T.assignedTo]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[(T==null?void 0:T.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:T.id}),(T==null?void 0:T.status)&&e.jsx("span",{title:"Cycle Status",className:`text-xs px-2.5 py-1 rounded-lg font-medium ${Ee[T.status]??Ze[T.status]??"bg-gray-500/20 text-gray-400"}`,children:F(T.status)})]})]}),e.jsx("div",{className:"mb-4",children:e.jsx(Ga,{executions:Z})}),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:Q.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:Q.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:Q.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:Q.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:Q.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:Q.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:[As,"%"]}),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:[$s,"%"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"Completion"})]})]})]}),e.jsx(Wa,{cycleId:o}),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:""},...Bt.map(t=>({label:F(t),value:t}))].map(t=>e.jsx("button",{onClick:()=>N(t.value),className:`px-3 py-1.5 text-sm rounded-lg transition-colors ${y===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))}),Pe>0&&e.jsxs("div",{className:"flex items-center justify-between bg-surface-1 rounded-xl border border-white/5 px-4 py-3",children:[re&&W?e.jsxs("div",{className:"flex-1 min-w-0 mr-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5 flex-wrap",children:[e.jsx(Ct,{size:"sm",label:Ae==="setup"?"Running setup":Ae==="teardown"?"Running teardown":"Running",detail:`${W.passed+W.failed} of ${W.total}`}),e.jsx(zs,{passed:W.passed,failed:W.failed,running:W.running,queued:W.queued,size:"xs"})]}),e.jsx(Fs,{passed:W.passed,failed:W.failed,running:W.running,total:W.total,className:"w-full max-w-md"})]}):e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Rt,{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:Pe})," of ",Z.length," test cases have automation scripts"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>mt(!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(et,{className:"w-4 h-4"})," Settings"]}),e.jsx("span",{children:e.jsx("button",{onClick:Ts,disabled:Ne||Pe===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:re?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 animate-spin"})," ",Ae==="setup"?"Running setup…":Ae==="teardown"?"Running teardown…":"Running Automation..."]}):oe.size>0?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 animate-spin"})," Running Test…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"w-4 h-4"})," Run All Automated (",Pe,")"]})})}),Ne&&e.jsxs("button",{onClick:Ps,disabled:qe.isPending||Oe.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(Ta,{className:"w-4 h-4"})," Cancel"]})]})]}),G&&!re&&e.jsxs("div",{className:`flex items-center justify-between rounded-xl border px-4 py-3 ${G.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:[G.failed>0?e.jsx(Ie,{className:"w-4 h-4 text-red-400 flex-shrink-0"}):e.jsx(we,{className:"w-4 h-4 text-emerald-400 flex-shrink-0"}),e.jsx("span",{className:G.failed>0?"text-red-200":"text-emerald-200",children:G.label?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:G.label})," — ",G.failed>0?"failed":"passed","."]}):e.jsxs(e.Fragment,{children:["Automation run complete — ",e.jsxs("span",{className:"font-semibold",children:[G.passed,"/",G.total]})," passed",G.failed>0?`, ${G.failed} failed`:"","."]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("a",{href:`/results?runId=${encodeURIComponent(G.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(Jt,{className:"w-3.5 h-3.5"})," View Result"]}),e.jsx("button",{onClick:()=>pe(null),title:"Dismiss",className:"text-gray-500 hover:text-gray-200 p-1.5 rounded-lg hover:bg-white/5",children:e.jsx(se,{className:"w-4 h-4"})})]})]}),bs&&Ne&&(ms?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:Se?{left:Se.x,top:Se.y,height:Se.h}:{right:16,top:80,bottom:16},children:[e.jsxs("div",{onPointerDown:ps,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(At,{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:()=>ht(!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(se,{size:13})})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(Ba,{testRunning:Ne,hideHeader:!0})})]}):e.jsx("button",{onClick:()=>ht(!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(At,{size:14})})),us&&e.jsx(Qa,{onClose:()=>mt(!1)}),e.jsx(rr,{planName:(b==null?void 0:b.name)||"",cycleName:(T==null?void 0:T.name)||"",execStats:Q,executionsList:Z}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:Z.length===0?e.jsxs("div",{className:"text-center py-12 text-gray-500",children:[e.jsx($t,{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:Z.map(t=>{var me,fe,Me,De,gt,bt,ft,yt,jt,Nt;const n=t.testCaseTitle??((me=t.testCase)==null?void 0:me.title)??((fe=t.test_case)==null?void 0:fe.title)??t.title??"Untitled",f=t.testCasePriority??((Me=t.testCase)==null?void 0:Me.priority)??((De=t.test_case)==null?void 0:De.priority)??t.priority;t.testCaseType??((gt=t.testCase)==null?void 0:gt.type)??((bt=t.test_case)==null?void 0:bt.type)??t.type;const j=t.testCaseCode??((ft=t.testCase)==null?void 0:ft.code)??((yt=t.test_case)==null?void 0:yt.code),D=t.testCaseId??((jt=t.testCase)==null?void 0:jt.id)??((Nt=t.test_case)==null?void 0:Nt.id),P=ce.find(O=>O.executionId===t.id),le=P==null?void 0:P.hasMappedScript,ve=Ns.get(t.id),te=ve==="running"||ve!=="queued"&&(oe.has(t.id)||(P==null?void 0:P.automationStatus)==="running");return e.jsxs(Ms.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:le?e.jsx("span",{title:`Automated (${P==null?void 0:P.framework}) — ${P==null?void 0:P.scriptPath}`,children:e.jsx(Rt,{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:[D&&e.jsx("span",{title:"Test Case ID",className:"text-[11px] font-mono text-brand-300 flex-shrink-0",children:D}),e.jsx("span",{title:n,className:"text-gray-200 font-medium truncate",children:n})]}),j&&e.jsx("div",{className:"text-xs text-gray-500",children:j})]}),e.jsx("td",{className:"px-4 py-3",children:f&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Le[f]??"bg-gray-500/20 text-gray-400"}`,children:F(f)})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[te?e.jsx(Ct,{size:"xs"}):ve==="queued"?e.jsx(Ls,{size:"xs"}):null,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 ${te?"bg-sky-500/10 text-sky-300":Ze[t.status]??"bg-slate-500/20 text-slate-400"}`,children:Bt.map(O=>e.jsx("option",{value:O,children:F(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(we,{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(Ie,{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(Xt,{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(Gt,{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:[le&&e.jsx("span",{children:e.jsxs("button",{onClick:()=>{var O;return Cs(t.id,((O=t.testCase)==null?void 0:O.title)||t.title)},disabled:te,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:[te?e.jsx(xe,{className:"w-3 h-3 animate-spin"}):e.jsx(Pt,{className:"w-3 h-3"}),te?"Running":"Run"]})}),e.jsxs("button",{onClick:()=>ts(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(We,{className:"w-3 h-3"}),"Steps"]}),(()=>{const O=js[t.id];if(O){const vt={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 ${vt[O.status]||vt.open}`,title:O.title,children:[e.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[e.jsx(_e,{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:()=>{Ve.mutate({executionId:t.id,createdBy:r},{onSuccess:()=>ys()})},disabled:Ve.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:[Ve.isPending?e.jsx(xe,{className:"w-3 h-3 animate-spin"}):e.jsx(_e,{className:"w-3 h-3"}),"Defect"]}):null})()]})})]}),te&&(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(Ka,{runId:P.resultRunId,layout:"strip",className:"!pl-0 !px-0"})})})]},t.id)})})]})})})]}),$e]}):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 ${Ee[b.status]??"bg-gray-500/20 text-gray-400"}`,children:F(b.status)})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsxs("button",{onClick:()=>{R(b),w(!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(tt,{className:"w-3.5 h-3.5"})," Edit"]}),e.jsxs("button",{onClick:()=>dt(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(ze,{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:()=>J("testcases"),className:`px-4 py-2 text-sm rounded-lg transition-colors flex items-center gap-2 ${V==="testcases"?"bg-brand-500/15 text-brand-300 font-medium":"text-gray-400 hover:text-gray-200 hover:bg-surface-2"}`,children:[e.jsx(Fe,{className:"w-4 h-4"})," Test Cases",e.jsx("span",{className:"text-xs bg-surface-2 px-1.5 py-0.5 rounded",children:ke.length})]}),e.jsxs("button",{onClick:()=>J("cycles"),className:`px-4 py-2 text-sm rounded-lg transition-colors flex items-center gap-2 ${V==="cycles"?"bg-brand-500/15 text-brand-300 font-medium":"text-gray-400 hover:text-gray-200 hover:bg-surface-2"}`,children:[e.jsx(Ye,{className:"w-4 h-4"})," Cycles",e.jsx("span",{className:"text-xs bg-surface-2 px-1.5 py-0.5 rounded",children:Ue.length})]})]}),V==="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:()=>C(!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"]})]}),ke.length===0?e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-8 text-center",children:[e.jsx(Fe,{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:()=>C(!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:ke.map(t=>{const n=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:[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??"Untitled",className:"flex-1 min-w-0 text-gray-200 font-medium truncate",children:n.title??"Untitled"})]}),n.code&&e.jsx("div",{className:"text-xs text-gray-500 mt-0.5",children:n.code})]}),e.jsx("td",{className:"px-4 py-3",children:n.priority&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Le[n.priority]??"bg-gray-500/20 text-gray-400"}`,children:F(n.priority)})}),e.jsx("td",{className:"px-4 py-3",children:n.type&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${nt[n.type]??"bg-gray-500/20 text-gray-400"}`,children:F(n.type)})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${n.automationStatus==="automated"||n.automation_status==="automated"?"bg-emerald-500/20 text-emerald-300":n.automationStatus==="needs_update"||n.automation_status==="needs_update"?"bg-amber-500/20 text-amber-300":"bg-gray-500/20 text-gray-400"}`,children:F(n.automationStatus??n.automation_status??"manual")})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:()=>cs(n.id,n.title),className:"p-1 text-gray-500 hover:text-red-400 rounded transition-colors",title:"Remove from plan",children:e.jsx(se,{className:"w-4 h-4"})})})]},t.id??n.id)})})]})})})]}),V==="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"]})]}),Ue.length===0?e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-8 text-center",children:[e.jsx(Ye,{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:Ue.map(t=>{const n=t.totalCount??t.totalExecutions??t.total_executions??0,f=t.executedCount??t.executed_count??0,j=t.passedCount??t.passed_count??0,D=t.failedCount??t.failed_count??0,P=D>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 ${Ee[t.status]??Ze[t.status]??"bg-gray-500/20 text-gray-400"}`,children:F(t.status)}),t.assignedTo&&e.jsxs("span",{title:"Assignee",className:"text-xs text-gray-500 flex items-center gap-1",children:[e.jsx(Tt,{className:"w-3 h-3"})," ",t.assignedTo]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-2 shrink-0",children:[t.endDate&&(()=>{const le=new Date(t.endDate).getTime(),ve=Date.now(),te=le-ve;if(te<=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(Mt,{className:"w-3 h-3"})," Overdue"]});const me=Math.floor(te/(1e3*60*60*24)),fe=Math.floor(te%(1e3*60*60*24)/(1e3*60*60)),Me=me>0?`${me}d ${fe}h`:fe>0?`${fe}h`:"< 1h",De=me===0?"text-orange-400 bg-orange-500/10":me<=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 ${De}`,children:[e.jsx(Mt,{className:"w-3 h-3"})," ",Me]})})(),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(tt,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>ds(t.id,t.name),className:"p-1 text-gray-500 hover:text-red-400 rounded",title:"Delete",children:e.jsx(ze,{className:"w-3.5 h-3.5"})})]})]})]}),n>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:[j>0&&e.jsx("div",{className:"bg-emerald-500 h-full",style:{width:`${j/n*100}%`}}),D>0&&e.jsx("div",{className:"bg-red-500 h-full",style:{width:`${D/n*100}%`}}),f-j-D>0&&e.jsx("div",{className:"bg-amber-500 h-full",style:{width:`${(f-j-D)/n*100}%`}})]})}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-400 mb-1",children:[e.jsxs("span",{children:[f,"/",n," executed"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[j>0&&e.jsxs("span",{className:"text-emerald-400",children:[j," passed"]}),D>0&&e.jsxs("span",{className:"text-red-400",children:[D," failed"]}),n-f>0&&e.jsxs("span",{className:"text-gray-500",children:[n-f," remaining"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>es(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(We,{className:"w-3.5 h-3.5"})," Execute"]}),P&&e.jsxs("button",{onClick:()=>{L(t.id),X(`${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(Dt,{className:"w-3.5 h-3.5"})," Re-run Failed"]})]})]},t.id)})})]}),v&&e.jsx(Ut,{editingPlan:_,onClose:()=>{w(!1),R(null)}}),A&&h&&e.jsx(Ya,{planId:h,editingCycle:K,onClose:()=>{x(!1),$(null)}}),c&&h&&e.jsx(Za,{planId:h,existingTestCaseIds:ke.map(t=>(t.testCase??t.test_case??t).id),onClose:()=>C(!1)}),E&&Ce.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>L(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:()=>L(null),className:"text-gray-400 hover:text-gray-200",children:e.jsx(se,{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:H,onChange:t=>X(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:()=>L(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:xs,disabled:!H.trim()||Be.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(Dt,{className:"w-4 h-4"}),"Re-run"]})]})]})}),document.body)]}),$e]}):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($t,{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),w(!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(lt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),e.jsx("input",{value:S,onChange:t=>ae(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:""},...Yt.map(t=>({label:F(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))})]}),ne?e.jsxs("div",{className:"text-center py-16 text-gray-500",children:[e.jsx(Ra,{className:"w-8 h-8 mx-auto mb-2 animate-spin opacity-50"}),e.jsx("p",{className:"text-sm",children:"Loading plans..."})]}):ct.length===0?e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-12 text-center",children:[e.jsx(Ye,{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 "${F(g)}".`:"Create your first test plan to get started."}),e.jsxs("button",{onClick:()=>{R(null),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"})," Create Plan"]})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:ct.map(t=>e.jsx(er,{plan:t,onSelect:()=>Zt(t.id),onEdit:()=>{R(t),w(!0)},onDelete:()=>dt(t.id,t.name)},t.id))}),v&&e.jsx(Ut,{editingPlan:_,onClose:()=>{w(!1),R(null)}}),$e]})]})}function rr({planName:a,cycleName:r,execStats:l,executionsList:h}){var A,x;const{connectorId:o,isConfigured:k}=Ua(),u=qa(),[g,p]=s.useState(""),[y,N]=s.useState(!1);if(!k)return null;const v=((A=a.match(/([A-Z][A-Z0-9]+-\d+)/))==null?void 0:A[1])||"",w=()=>{const c=g||v;if(!o||!c)return;const C=l.total||0,_=l.failed>0?"❌":"✅",R=l.failed>0?"FAILED":"PASSED",K=C>0?Math.round(l.passed/C*100):0,$={passed:"✅",failed:"❌",blocked:"🚫",skipped:"⏭",not_run:"⬜",in_progress:"🔄"},V=h.map(S=>`${$[S.status]||"⬜"} ${S.testCaseTitle||"Unknown"} — ${(S.status||"not_run").replace("_"," ").toUpperCase()}`).join(`
|
|
4
|
+
`),J=[`${_} Testver Test Execution — ${R}`,"",`Plan: ${a}`,`Cycle: ${r}`,`Date: ${qt(new Date)}`,"",`Summary: ${l.passed} passed, ${l.failed} failed, ${l.skipped} skipped, ${l.blocked} blocked (${C} total)`,`Pass Rate: ${K}%`,"","Test Cases:",V].join(`
|
|
5
|
+
`);u.mutate({connectorId:o,issueKey:c,comment:J},{onSuccess:()=>N(!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(Jt,{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||v,onChange:c=>p(c.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:w,disabled:u.isPending||y||!(g||v),className:`flex items-center gap-1.5 px-4 py-1.5 text-sm font-medium rounded-lg transition-colors ${y?"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(xe,{size:14,className:"animate-spin"}):y?e.jsxs(e.Fragment,{children:[e.jsx(we,{size:14})," Published"]}):e.jsxs(e.Fragment,{children:[e.jsx(Da,{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{Dr as TestPlansPage};
|
package/src/ui/static/assets/{TestverCreditsRing-CUsMGEe3.js → TestverCreditsRing-DpMzl3h7.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as F,r as d,j as t}from"./vendor-react-CTbHBddL.js";import{a as I}from"./formatDate-T65-Y6Mi.js";import{a as O,u as Q}from"./vendor-query-BrzmPFT3.js";import{b as _,e9 as L}from"./index-
|
|
1
|
+
import{u as F,r as d,j as t}from"./vendor-react-CTbHBddL.js";import{a as I}from"./formatDate-T65-Y6Mi.js";import{a as O,u as Q}from"./vendor-query-BrzmPFT3.js";import{b as _,e9 as L}from"./index-BYVxKLrT.js";async function W(s){try{const a=await L(!0);await s.cancelQueries({queryKey:["testver-status"]}),s.setQueryData(["testver-status"],a)}catch{}}function K(s){return Q({queryKey:["testver-status"],queryFn:()=>L(),refetchInterval:3e4,refetchOnWindowFocus:!0,staleTime:15e3,enabled:(s==null?void 0:s.enabled)??!0})}let x=!1;const M=.75,S=.9;function V({size:s=18,refreshSignal:a,align:U="right"}){var $;const E=F(),{toast:y}=_(),{data:e}=K(),f=d.useRef(!1),w=O(),N=d.useRef(!!a);d.useEffect(()=>{const l=N.current;if(N.current=!!a,l&&!a){const m=setTimeout(()=>void W(w),1500);return()=>clearTimeout(m)}},[a,w]);const n=(e==null?void 0:e.totalCredits)??0,P=(e==null?void 0:e.usedCredits)??0,c=(e==null?void 0:e.remainingCredits)??0,j=!!(e!=null&&e.reserveOnlyMode)&&!!(e!=null&&e.active),C=j||!!(e!=null&&e.usingReserve),i=(e==null?void 0:e.cycleAllowanceCredits)??n,T=Math.min((e==null?void 0:e.cycleUsedCredits)??P,i),h=Math.max(((e==null?void 0:e.reserveTankCredits)??0)>0?e.reserveTankCredits:(e==null?void 0:e.reserveBoughtCredits)??0,(e==null?void 0:e.reserveCredits)??0),p=C?h>0?Math.min(1,Math.max(0,h-((e==null?void 0:e.reserveCredits)??0))/h):0:i>0?Math.min(1,T/i):0,o=(e==null?void 0:e.status)==="paused",r=(e==null?void 0:e.connected)&&n>0&&c<=0&&!o,u=i+((e==null?void 0:e.reserveCredits)??0),v=u>0&&c/u<=1-S,R=u>0&&c/u>=1-M;if(d.useEffect(()=>{!(e!=null&&e.connected)||n<=0||(v&&!r&&!x&&!f.current?(x=!0,f.current=!0,y("error",`Testver credits running low — ${c.toLocaleString()} left. Top up from the credits ring.`)):R&&x&&(x=!1,f.current=!1))},[e==null?void 0:e.connected,v,R,r,c,n,y]),!(e!=null&&e.connected))return null;const D=r?"stroke-red-500":o?"stroke-amber-400":C?"stroke-emerald-400":p>=S?"stroke-red-400":p>=M?"stroke-amber-400":"stroke-sky-400",g=2.5,b=(s-g)/2,k=2*Math.PI*b,A=r?k:k*p,B=!o&&(r||v||!e.active);return t.jsxs("div",{className:"relative group flex-shrink-0 -mr-2 flex items-center gap-1.5",children:[r&&t.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] font-medium text-red-400 whitespace-nowrap",children:["Credits used up",e.billingUrl&&t.jsx("a",{href:e.billingUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sky-400 hover:text-sky-300 underline underline-offset-2",children:"Top up →"})]}),o&&t.jsx("span",{className:"text-[11px] font-medium text-amber-400 whitespace-nowrap",children:"Seat paused"}),t.jsx("button",{onClick:()=>E("/settings?tab=llm"),className:"flex items-center justify-center p-0.5 rounded-lg hover:bg-white/5 transition-colors","aria-label":"Testver credits",children:t.jsxs("svg",{width:s,height:s,viewBox:`0 0 ${s} ${s}`,className:r?"animate-pulse":"",children:[t.jsx("circle",{cx:s/2,cy:s/2,r:b,fill:"none",strokeWidth:g,className:"stroke-gray-300 dark:stroke-white/15"}),t.jsx("circle",{cx:s/2,cy:s/2,r:b,fill:"none",strokeWidth:g,strokeLinecap:"round",strokeDasharray:`${A} ${k}`,transform:`rotate(-90 ${s/2} ${s/2})`,className:`${D} transition-all duration-500`})]})}),t.jsxs("div",{className:`absolute bottom-full ${U==="left"?"left-0":"right-0"} mb-1.5 hidden group-hover:block w-60 bg-surface-1 border border-white/10 rounded-xl shadow-xl z-50 p-3 text-left`,children:[n>0?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"text-sm font-medium text-gray-200",children:[j?"Plan credits ended with the term":`${Math.max(0,i-T).toLocaleString()} of ${i.toLocaleString()} plan credits left`,($=e.plan)!=null&&$.name?t.jsxs("span",{className:"text-gray-500",children:[" · ",e.plan.name]}):null]}),e.teamRole&&e.teamRole!=="owner"&&e.teamName&&t.jsxs("p",{className:"mt-1 text-xs text-gray-500",children:["Allocated by ",e.teamName]}),((e.reserveBoughtCredits??0)>0||(e.reserveCredits??0)>0)&&t.jsxs("p",{className:"mt-1 text-xs text-emerald-400",children:[(()=>{const l=e.reserveCredits??0,m=e.reserveTankCredits??0,q=Math.max(m>0?m:e.reserveBoughtCredits??0,l);return`Reserve: ${l.toLocaleString()} of ${q.toLocaleString()} left`})(),e.usingReserve?" — in use now":e.active===!1&&n>0?" — banked until renewal":""]}),e.reserveOnlyMode&&e.active&&t.jsx("p",{className:"mt-1 text-xs font-medium text-amber-400",children:"Plan expired — running on your extra usage reserve."}),e.active===!1&&n>0&&!r&&!o&&t.jsxs("p",{className:"mt-1 text-xs font-medium text-amber-400",children:["Plan ",e.status==="suspended"?"suspended":"expired"," — AI requests are paused."]}),o&&t.jsxs("p",{className:"mt-1 text-xs font-medium text-amber-400",children:["Your seat in ",e.teamName||"your team"," is paused — the team owner gives it back."]}),e.nextPlan&&t.jsxs("p",{className:"mt-1 text-xs text-gray-400",children:["Renewed ✓ ",e.nextPlan.name," starts ",I(e.nextPlan.startsAt)]}),r&&t.jsx("p",{className:"mt-1 text-xs font-medium text-red-400",children:"Credits used up — AI requests are paused."})]}):t.jsx("p",{className:"text-sm text-gray-400",children:o?`Your seat in ${e.teamName||"your team"} is paused — the team owner gives it back.`:e.active===!1?"No active Testver plan.":"Loading credits…"}),B&&e.billingUrl&&t.jsx("a",{href:e.billingUrl,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-block text-xs font-semibold text-sky-400 hover:text-sky-300 underline underline-offset-2",children:"Top up at testver.com →"})]})]})}export{V as T,W as b,K as u};
|
package/src/ui/static/assets/{UncommittedDiffViewer-B5HSURk8.js → UncommittedDiffViewer-BxS0zi-p.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as p,j as t}from"./vendor-react-CTbHBddL.js";import{
|
|
1
|
+
import{r as p,j as t}from"./vendor-react-CTbHBddL.js";import{ax as T,r as _,f as B,y as F,t as I,b4 as R,cx as H,b7 as K,ab as V,d4 as X,d5 as q,c0 as G}from"./vendor-icons-BKPiFyYV.js";const $=200,x=r=>`${r.staged?"s":"u"}:${r.path}`;function Y({files:r,showGroups:P=!0,defaultExpanded:g=!1,onStageFile:u,onUnstageFile:b,onStageAll:j,onUnstageAll:f,onDiscardFile:N,busy:c=!1}){const[E,w]=p.useState(()=>{if(g){const e={};return r.forEach(s=>{e[x(s)]=!0}),e}return{}}),[v,U]=p.useState(g),[D,A]=p.useState({});if(r.length===0)return null;const y=r.filter(e=>e.staged),C=r.filter(e=>!e.staged),W=()=>{const e=!v;U(e);const s={};r.forEach(n=>{s[x(n)]=e}),w(s)},L=e=>{w(s=>({...s,[e]:!s[e]}))},M=e=>{switch(e){case"added":case"untracked":return t.jsx(G,{size:13,className:"text-emerald-400"});case"deleted":return t.jsx(q,{size:13,className:"text-red-400"});case"renamed":return t.jsx(X,{size:13,className:"text-sky-400"});default:return t.jsx(V,{size:13,className:"text-amber-400"})}},k=(e,s)=>{const n=E[s]??!1,h=!e.staged&&u,m=e.staged&&b;return t.jsxs("div",{className:"rounded-lg border border-white/5 bg-black/20 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 hover:bg-surface-2/50 transition-colors",children:[t.jsxs("button",{onClick:()=>L(s),"aria-expanded":n,className:"flex items-center gap-2 flex-1 text-left min-w-0",children:[t.jsx("span",{className:"text-gray-500 flex-shrink-0",children:n?t.jsx(F,{size:13}):t.jsx(I,{size:13})}),M(e.status),t.jsx("span",{className:"text-sm text-gray-200 font-mono truncate flex-1",children:e.path}),e.additions>0&&t.jsxs("span",{className:"text-xs text-emerald-500 flex-shrink-0 font-medium",children:["+",e.additions]}),e.deletions>0&&t.jsxs("span",{className:"text-xs text-red-500 flex-shrink-0 font-medium",children:["-",e.deletions]}),t.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full flex-shrink-0 font-medium ${e.status==="untracked"||e.status==="added"?"bg-emerald-500/10 text-emerald-500":e.status==="deleted"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-500"}`,children:e.status})]}),h&&t.jsxs("button",{onClick:a=>{a.stopPropagation(),u(e.path)},disabled:c,className:"flex items-center gap-1 px-2.5 py-1.5 rounded text-xs font-medium text-emerald-500 hover:bg-emerald-500/10 border border-emerald-500/20 flex-shrink-0 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:`Stage ${e.path} — put its changes into the next commit`,"aria-label":`Stage ${e.path}`,children:[t.jsx(R,{size:12})," Stage"]}),m&&t.jsxs("button",{onClick:a=>{a.stopPropagation(),b(e.path)},disabled:c,className:"flex items-center gap-1 px-2.5 py-1.5 rounded text-xs font-medium text-gray-400 hover:bg-gray-500/10 border border-white/10 flex-shrink-0 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:`Unstage ${e.path} — take it out of the next commit (your edits stay)`,"aria-label":`Unstage ${e.path}`,children:[t.jsx(H,{size:12})," Unstage"]}),N&&!e.staged&&t.jsxs("button",{onClick:a=>{a.stopPropagation(),N(e)},disabled:c,className:"flex items-center gap-1 px-2.5 py-1.5 rounded text-xs font-medium text-red-500 hover:bg-red-500/10 border border-red-500/20 flex-shrink-0 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:`Discard changes to ${e.path} — throw the edits away for good (can't be undone)`,"aria-label":`Discard changes to ${e.path}`,children:[t.jsx(K,{size:12})," Discard"]})]}),n&&e.patch&&(()=>{const a=e.patch.split(`
|
|
2
2
|
`),l=D[s]??!1,z=l?0:Math.max(0,a.length-$);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-t border-white/5 max-h-[440px] overflow-auto",children:t.jsx("pre",{className:"text-sm font-mono leading-[1.6] whitespace-pre",children:(l?a:a.slice(0,$)).map((d,O)=>{let o="",i="text-gray-400";return d.startsWith("+++")||d.startsWith("---")?(i="text-gray-500 font-bold",o="bg-white/[0.02]"):d.startsWith("@@")?(i="text-sky-400/50",o="bg-sky-500/5"):d.startsWith("+")?(i="text-emerald-500",o="bg-emerald-500/10"):d.startsWith("-")&&(i="text-red-500",o="bg-red-500/10"),t.jsx("div",{className:`px-3 ${o} ${i}`,children:d||" "},O)})})}),z>0&&t.jsxs("button",{onClick:()=>A(d=>({...d,[s]:!0})),className:"w-full px-3 py-1.5 text-xs font-medium text-brand-400 hover:text-brand-300 hover:bg-brand-500/5 border-t border-white/5 transition-colors",children:["Show all ",a.length," lines (",z," more)"]}),e.truncated&&t.jsx("div",{className:"border-t border-white/5 px-3 py-1.5 text-xs text-amber-600 dark:text-amber-400",children:"This diff is too large to show in full — the rest is cut off. Open the file to see all of it."})]})})(),n&&!e.patch&&t.jsx("div",{className:"border-t border-white/5 px-3 py-2 text-xs text-gray-500",children:e.noPreview?"No preview — only the first 50 new files are previewed. Stage and commit work as usual.":"No diff content available."})]},s)},S=(e,s,n,h,m,a)=>e.length===0?null:t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[h,t.jsxs("span",{className:`text-[11px] font-semibold uppercase flex-1 ${m}`,children:[n," (",e.length,")"]}),a&&t.jsx("button",{onClick:a.onClick,disabled:c,className:"text-[11px] text-gray-500 hover:text-gray-300 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:a.label})]}),t.jsx("div",{className:"space-y-1",children:e.map(l=>k(l,x(l)))})]});return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("span",{className:"text-[11px] font-semibold text-gray-400 uppercase",children:[r.length," changed file",r.length!==1?"s":""]}),t.jsxs("button",{onClick:W,className:"flex items-center gap-1 text-[11px] text-gray-500 hover:text-gray-300 transition-colors",children:[t.jsx(T,{size:11}),v?"Collapse All":"Expand All"]})]}),P?t.jsxs("div",{className:"space-y-4",children:[S(y,"s","Staged",t.jsx(_,{size:12,className:"text-emerald-400"}),"text-emerald-400",f&&y.length>0?{label:"Unstage All",onClick:f}:void 0),S(C,"u","Unstaged",t.jsx(B,{size:12,className:"text-amber-400"}),"text-amber-400",j&&C.length>0?{label:"Stage All",onClick:j}:void 0)]}):t.jsx("div",{className:"space-y-1",children:r.map(e=>k(e,x(e)))})]})}export{Y as U};
|
package/src/ui/static/assets/{UserManagementPage-BjY3ftxf.js → UserManagementPage-B5d0uDU_.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as c,j as e,b as N}from"./vendor-react-CTbHBddL.js";import{a as W}from"./formatDate-T65-Y6Mi.js";import{a as Y,u as Z,c as m}from"./vendor-query-BrzmPFT3.js";import{a8 as ee,b as se,fy as te,fz as ae,fA as re,fB as le,fC as ie,fD as ne,fE as de,B as oe,eD as D}from"./index-
|
|
1
|
+
import{r as c,j as e,b as N}from"./vendor-react-CTbHBddL.js";import{a as W}from"./formatDate-T65-Y6Mi.js";import{a as Y,u as Z,c as m}from"./vendor-query-BrzmPFT3.js";import{a8 as ee,b as se,fy as te,fz as ae,fA as re,fB as le,fC as ie,fD as ne,fE as de,B as oe,eD as D}from"./index-BYVxKLrT.js";import{U as ce,b4 as xe,d6 as z,d7 as P,ac as M,o as q,b6 as me,a8 as L,am as $,z as ue,b7 as he,X as be}from"./vendor-icons-BKPiFyYV.js";const pe=[{value:"admin",label:"Admin",description:"Full access + user management (created by the super admin)"},{value:"tester",label:"Tester",description:"Run tests, edit files, use tools"},{value:"viewer",label:"Viewer",description:"Read-only dashboard access"}],ye=t=>t==="superadmin"?"super admin":t,fe=t=>t==="superadmin"?"yellow":t==="admin"?"brand":t==="tester"?"green":"gray";function ke(){const{user:t}=ee(),{toast:l}=se(),u=Y(),{data:v,isLoading:K}=Z({queryKey:["users"],queryFn:te}),[n,p]=c.useState(null),[r,w]=c.useState(null),[h,y]=c.useState(null),[b,f]=c.useState(null),[i,g]=c.useState(null),[a,d]=c.useState({username:"",displayName:"",email:"",password:"",role:"tester"}),[k,S]=c.useState(""),F=(v==null?void 0:v.users)??[],C=(t==null?void 0:t.role)==="superadmin",R=m({mutationFn:()=>ae(a),onSuccess:()=>{u.invalidateQueries({queryKey:["users"]}),l("success","User created successfully"),o()},onError:s=>l("error",s.message)}),A=m({mutationFn:s=>re(s.id,s.updates),onSuccess:()=>{u.invalidateQueries({queryKey:["users"]}),l("success","User updated"),o()},onError:s=>l("error",s.message)}),O=m({mutationFn:le,onSuccess:()=>{u.invalidateQueries({queryKey:["users"]}),l("success","User deleted")},onError:s=>l("error",s.message)}),E=m({mutationFn:()=>ie(r.id,k),onSuccess:()=>{l("success","Password reset successfully"),o()},onError:s=>l("error",s.message)}),T=m({mutationFn:ne,onSuccess:()=>{u.invalidateQueries({queryKey:["users"]}),l("success","Two-factor authentication reset"),f(null)},onError:s=>l("error",s.message)}),Q=m({mutationFn:de,onSuccess:s=>{u.invalidateQueries({queryKey:["users"]}),l("success",`Revoked ${s.sessionsRevoked} session(s)`)},onError:s=>l("error",s.message)});function B(){d({username:"",displayName:"",email:"",password:"",role:"tester"}),p("create")}function I(s){w(s),d({username:s.username,displayName:s.displayName,email:s.email||"",password:"",role:s.role}),p("edit")}function X(s){w(s),S(""),p("reset-password")}function o(){p(null),w(null)}function V(s){y(s)}function _(){h&&(O.mutate(h.id),y(null))}function G(s){g(s)}function H(){i&&(A.mutate({id:i.id,updates:{isActive:!i.isActive}}),g(null))}const x=s=>s.id===(t==null?void 0:t.id)?!0:!(s.role==="superadmin"||s.role==="admin"&&!C),j=s=>s.role==="superadmin",J=s=>!!s.twoFactorEnabled&&s.id!==(t==null?void 0:t.id)&&!j(s)&&x(s);return 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(ce,{size:24,className:"text-brand-300"}),"User Management",e.jsxs("span",{className:"text-sm font-normal bg-brand-500/15 text-brand-300 px-2.5 py-0.5 rounded-full",children:[F.length," users"]})]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Manage user accounts, roles, and access"})]}),e.jsxs("button",{onClick:B,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(xe,{size:16}),"Add User"]})]})})}),e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-8 space-y-6",children:[K?e.jsx("div",{className:"text-sm text-gray-500",children:"Loading users..."}):e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-sm text-gray-500",children:[e.jsx("th",{className:"text-left px-4 py-3 font-medium",children:"User"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium",children:"Email"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium",children:"Role"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium",children:"2FA"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium",children:"Last Login"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium",children:"Sessions"}),e.jsx("th",{className:"text-right px-4 py-3 font-medium",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:F.map(s=>e.jsxs("tr",{className:"hover:bg-white/[0.02]",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-brand-500/20 flex items-center justify-center text-brand-300 text-sm font-semibold",children:s.displayName.charAt(0).toUpperCase()}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-200 font-medium",children:s.displayName}),e.jsxs("p",{className:"text-xs text-gray-500",children:["@",s.username]})]}),s.id===(t==null?void 0:t.id)&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/10 text-brand-400 rounded",children:"you"})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm text-gray-400",children:s.email||e.jsx("span",{className:"text-gray-600 italic",children:"—"})})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(oe,{label:ye(s.role),color:fe(s.role)})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:`flex items-center gap-1.5 text-xs ${s.isActive?"text-emerald-400":"text-gray-500"}`,children:[s.isActive?e.jsx(z,{size:14}):e.jsx(P,{size:14}),s.isActive?"Active":"Disabled"]})}),e.jsx("td",{className:"px-4 py-3","data-testid":`two-factor-${s.username}`,children:s.twoFactorEnabled?e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-emerald-400 whitespace-nowrap",children:[e.jsx(M,{size:14})," On"]}):s.twoFactorRequired?e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-amber-400 whitespace-nowrap",title:"Required by the workspace — they set it up at their next sign-in",children:[e.jsx(q,{size:13,className:"flex-shrink-0"})," Not set up"]}):e.jsx("span",{className:"text-xs text-gray-500",children:"Off"})}),e.jsx("td",{className:"px-4 py-3 text-xs text-gray-500",children:s.lastLoginAt?W(s.lastLoginAt):"Never"}),e.jsx("td",{className:"px-4 py-3 text-xs text-gray-500",children:s.sessions}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{onClick:()=>I(s),className:"p-1.5 rounded hover:bg-surface-2 text-gray-400 hover:text-gray-200 disabled:opacity-30",title:"Edit user",disabled:!x(s),children:e.jsx(me,{size:14})}),e.jsx("button",{onClick:()=>X(s),className:"p-1.5 rounded hover:bg-surface-2 text-gray-400 hover:text-gray-200 disabled:opacity-30",title:"Reset password",disabled:!x(s),children:e.jsx(L,{size:14})}),e.jsx("button",{onClick:()=>f(s),className:"p-1.5 rounded hover:bg-surface-2 text-gray-400 hover:text-amber-400 disabled:opacity-30",title:s.twoFactorEnabled?s.id===(t==null?void 0:t.id)?"Turn your own off from Profile":j(s)?"The super admin's two-factor authentication cannot be reset here":"Reset two-factor authentication":"Two-factor authentication is off",disabled:!J(s),children:e.jsx($,{size:14})}),e.jsx("button",{onClick:()=>Q.mutate(s.id),className:"p-1.5 rounded hover:bg-surface-2 text-gray-400 hover:text-gray-200 disabled:opacity-30",title:"Revoke sessions",disabled:s.sessions===0||!x(s),children:e.jsx(ue,{size:14})}),e.jsx("button",{onClick:()=>G(s),className:`p-1.5 rounded hover:bg-surface-2 disabled:opacity-30 ${s.isActive?"text-gray-400 hover:text-amber-400":"text-gray-400 hover:text-emerald-400"}`,title:s.isActive?"Disable user":"Enable user",disabled:j(s)||!x(s),children:s.isActive?e.jsx(P,{size:14}):e.jsx(z,{size:14})}),e.jsx("button",{onClick:()=>V(s),className:"p-1.5 rounded hover:bg-surface-2 text-gray-400 hover:text-red-400 disabled:opacity-30",title:"Delete user",disabled:s.id===(t==null?void 0:t.id)||j(s)||!x(s),children:e.jsx(he,{size:14})})]})})]},s.id))})]})}),n&&N.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:o}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 p-6 w-full max-w-md animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("h3",{className:"text-xl font-bold text-gray-100",children:n==="create"?"Create User":n==="edit"?"Edit User":"Reset Password"}),e.jsx("button",{onClick:o,className:"p-1 rounded hover:bg-surface-2 text-gray-400",children:e.jsx(be,{size:18})})]}),(n==="create"||n==="edit")&&e.jsxs("form",{onSubmit:s=>{s.preventDefault(),n==="create"?R.mutate():r&&A.mutate({id:r.id,updates:{displayName:a.displayName,email:a.email,role:a.role}})},className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:["Username ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",value:a.username,onChange:s=>d({...a,username:s.target.value}),disabled:n==="edit",className:`w-full px-3 py-2 bg-surface-2 border border-white/10 rounded-xl text-[15px] text-gray-100\r
|
|
2
2
|
focus:outline-none focus:border-brand-500/50 disabled:opacity-50`,placeholder:"username"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:["Display Name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",value:a.displayName,onChange:s=>d({...a,displayName:s.target.value}),className:`w-full px-3 py-2 bg-surface-2 border border-white/10 rounded-xl text-[15px] text-gray-100\r
|
|
3
3
|
focus:outline-none focus:border-brand-500/50`,placeholder:"Display Name"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:["Email ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"email",required:!0,value:a.email,onChange:s=>d({...a,email:s.target.value}),className:`w-full px-3 py-2 bg-surface-2 border border-white/10 rounded-lg text-sm text-gray-100\r
|
|
4
4
|
focus:outline-none focus:border-brand-500/50`,placeholder:"user@example.com"})]}),n==="create"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:["Password ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx(D,{value:a.password,onChange:s=>d({...a,password:s.target.value}),className:`w-full px-3 py-2 bg-surface-2 border border-white/10 rounded-lg text-sm text-gray-100\r
|
|
@@ -7,4 +7,4 @@ import{r as c,j as e,b as N}from"./vendor-react-CTbHBddL.js";import{a as W}from"
|
|
|
7
7
|
${a.role===s.value?"border-brand-500/50 bg-brand-500/5":"border-white/5 hover:border-white/10"}`,children:[e.jsx("input",{type:"radio",name:"role",value:s.value,checked:a.role===s.value,disabled:U,onChange:()=>d({...a,role:s.value}),className:"accent-brand-500"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-gray-200",children:s.label}),e.jsx("p",{className:"text-xs text-gray-500",children:s.description})]})]},s.value)})})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx("button",{type:"button",onClick:o,className:"px-3 py-1.5 text-sm text-gray-400 hover:text-gray-200 rounded-lg hover:bg-surface-2",children:"Cancel"}),e.jsxs("button",{type:"submit",disabled:R.isPending||A.isPending,className:`flex items-center gap-2 px-5 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-[15px] font-medium rounded-xl\r
|
|
8
8
|
disabled:opacity-50 transition-colors`,children:[e.jsx(M,{size:14}),n==="create"?"Create":"Save"]})]})]}),n==="reset-password"&&r&&e.jsxs("form",{onSubmit:s=>{s.preventDefault(),E.mutate()},className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-gray-400",children:["Set a new password for ",e.jsx("span",{className:"text-gray-200 font-medium",children:r.username})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"New Password"}),e.jsx(D,{value:k,onChange:s=>S(s.target.value),className:`w-full px-3 py-2 bg-surface-2 border border-white/10 rounded-xl text-[15px] text-gray-100\r
|
|
9
9
|
focus:outline-none focus:border-brand-500/50`,placeholder:"Min. 6 characters",autoFocus:!0})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx("button",{type:"button",onClick:o,className:"px-3 py-1.5 text-sm text-gray-400 hover:text-gray-200 rounded-lg hover:bg-surface-2",children:"Cancel"}),e.jsxs("button",{type:"submit",disabled:E.isPending||k.length<6,className:`flex items-center gap-2 px-5 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-[15px] font-medium rounded-xl\r
|
|
10
|
-
disabled:opacity-50 transition-colors`,children:[e.jsx(L,{size:14}),"Reset Password"]})]})]})]})]}),document.body),i&&N.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>
|
|
10
|
+
disabled:opacity-50 transition-colors`,children:[e.jsx(L,{size:14}),"Reset Password"]})]})]})]})]}),document.body),i&&N.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>g(null)}),e.jsxs("div",{className:"relative z-10 bg-surface-1 rounded-xl border border-white/10 shadow-2xl w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 py-4 border-b border-white/5",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center shrink-0 ${i.isActive?"bg-amber-500/10":"bg-emerald-500/10"}`,children:i.isActive?e.jsx(P,{size:20,className:"text-amber-400"}):e.jsx(z,{size:20,className:"text-emerald-400"})}),e.jsx("h3",{className:"text-base font-semibold text-gray-100",children:i.isActive?"Disable User":"Enable User"})]}),e.jsx("div",{className:"px-6 py-4",children:e.jsx("p",{className:"text-sm text-gray-300",children:i.isActive?e.jsxs(e.Fragment,{children:["Are you sure you want to disable ",e.jsxs("strong",{className:"text-gray-100",children:['"',i.displayName,'"']}),"? They will not be able to log in and all active sessions will be revoked."]}):e.jsxs(e.Fragment,{children:["Are you sure you want to re-enable ",e.jsxs("strong",{className:"text-gray-100",children:['"',i.displayName,'"']}),"? They will be able to log in again."]})})}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:()=>g(null),className:"px-4 py-2 text-sm text-gray-400 hover:text-gray-200 transition-colors rounded-lg",children:"Cancel"}),e.jsx("button",{onClick:H,className:`px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors ${i.isActive?"bg-amber-600 hover:bg-amber-500":"bg-emerald-600 hover:bg-emerald-500"}`,children:i.isActive?"Disable User":"Enable User"})]})]})]}),document.body),b&&N.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[70] flex items-center justify-center","data-testid":"reset-two-factor-dialog",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>f(null)}),e.jsxs("div",{className:"relative z-10 bg-surface-1 rounded-xl border border-white/10 shadow-2xl w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 py-4 border-b border-white/5",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/10 flex items-center justify-center shrink-0",children:e.jsx($,{size:20,className:"text-amber-400"})}),e.jsx("h3",{className:"text-base font-semibold text-gray-100",children:"Reset two-factor authentication"})]}),e.jsxs("div",{className:"px-6 py-4 space-y-2",children:[e.jsxs("p",{className:"text-sm text-gray-300",children:["Turn off two-factor authentication for ",e.jsx("strong",{className:"text-gray-100",children:b.displayName})," (@",b.username,")?"]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Use this when they lost their phone and their recovery codes. Their authenticator entry, recovery codes and trusted browsers stop working.",b.twoFactorRequired?" The workspace requires two-factor authentication, so they set it up again at their next sign-in.":" They sign in with their password only until they turn it on again."," ","If email is set up, they are told by email."]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:()=>f(null),className:"px-4 py-2 text-sm text-gray-400 hover:text-gray-200 transition-colors rounded-lg",children:"Cancel"}),e.jsx("button",{onClick:()=>T.mutate(b.id),disabled:T.isPending,className:"px-4 py-2 text-sm font-medium text-white bg-amber-600 hover:bg-amber-500 rounded-lg transition-colors disabled:opacity-50",children:"Reset 2FA"})]})]})]}),document.body),h&&N.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>y(null)}),e.jsxs("div",{className:"relative z-10 bg-surface-1 rounded-xl border border-white/10 shadow-2xl w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 py-4 border-b border-white/5",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/10 flex items-center justify-center shrink-0",children:e.jsx(q,{size:20,className:"text-red-400"})}),e.jsx("h3",{className:"text-base font-semibold text-gray-100",children:"Delete User"})]}),e.jsxs("div",{className:"px-6 py-4",children:[e.jsxs("p",{className:"text-sm text-gray-300",children:["Are you sure you want to permanently delete ",e.jsxs("strong",{className:"text-gray-100",children:['"',h.displayName,'"']})," (@",h.username,")?"]}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"This action cannot be undone. The user will be permanently removed along with all their sessions."})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:()=>y(null),className:"px-4 py-2 text-sm text-gray-400 hover:text-gray-200 transition-colors rounded-lg",children:"Cancel"}),e.jsx("button",{onClick:_,className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-500 rounded-lg transition-colors",children:"Delete Permanently"})]})]})]}),document.body)]})]})}export{ke as UserManagementPage};
|