@testver/testver 1.3.1 → 1.4.0
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/bin/testver.js +8 -1
- package/dist/index.js +1414 -793
- package/dist/py-agent/__pycache__/testver_appium.cpython-313.pyc +0 -0
- package/package.json +7 -6
- package/src/ui/static/assets/AIPanel-D09Ni3a4.js +32 -0
- package/src/ui/static/assets/AIRecordPanel-DZtUZnRe.js +40 -0
- package/src/ui/static/assets/AIStreamUI-BsxKziYG.js +9 -0
- package/src/ui/static/assets/AITestGenPage-Cg21-P1W.js +5 -0
- package/src/ui/static/assets/APITestingPage-Cdc8EZz2.js +19 -0
- package/src/ui/static/assets/AboutPage-yJLCr2_q.js +1 -0
- package/src/ui/static/assets/AdvancedPage-DB-6sJ6s.js +3 -0
- package/src/ui/static/assets/AnalyticsPage-gTPFsiLZ.js +1 -0
- package/src/ui/static/assets/AuditLogPage-DE45E_PV.js +1 -0
- package/src/ui/static/assets/ChangesSummary-C-7oi_sx.js +2 -0
- package/src/ui/static/assets/CodeMapPage-DgU6ZYBO.js +3 -0
- package/src/ui/static/assets/ConfirmDialog-DNU3qoAP.js +1 -0
- package/src/ui/static/assets/CoveragePage-BpTjgcdV.js +2 -0
- package/src/ui/static/assets/CronBuilder-DsnX-vRr.js +1 -0
- package/src/ui/static/assets/Dashboard-DRWbVyTb.js +1 -0
- package/src/ui/static/assets/DefectsPage-BtMNbq6Z.js +72 -0
- package/src/ui/static/assets/DiffViewer-DPglzjPH.js +2 -0
- package/src/ui/static/assets/EmptyState-BH_aDO0P.js +1 -0
- package/src/ui/static/assets/ExportButton-Ce_MxnM1.js +1 -0
- package/src/ui/static/assets/FileViewer-iYL0lxyY.js +18 -0
- package/src/ui/static/assets/GitPage-CQqV8JBC.js +12 -0
- package/src/ui/static/assets/ImportExportPage-DXk7Koaq.js +36 -0
- package/src/ui/static/assets/JiraPushDialog-CqftoLh8.js +1 -0
- package/src/ui/static/assets/LiveExecutionView-BD0wE8sz.js +1 -0
- package/src/ui/static/assets/ManagePage-B8iG6Q0B.js +1 -0
- package/src/ui/static/assets/MediaModal-DiSINwmh.js +1 -0
- package/src/ui/static/assets/MobileRunPicker-BNs2lZFf.js +1 -0
- package/src/ui/static/assets/MobileRunTarget-D2Nqcj10.js +6 -0
- package/src/ui/static/assets/ModuleExplorer-BmkoQrHb.js +1 -0
- package/src/ui/static/assets/OutputPage-Dcsr7cmr.js +1 -0
- package/src/ui/static/assets/PipelinesPanel-CMMXCSda.js +1 -0
- package/src/ui/static/assets/ProfilePage-ByshrcwC.js +1 -0
- package/src/ui/static/assets/ProjectExplorer-B9B___ij.js +1 -0
- package/src/ui/static/assets/RemoteFileStrip-DbPnaZ-v.js +1 -0
- package/src/ui/static/assets/ReportCard-BbNfk85h.js +2 -0
- package/src/ui/static/assets/ReportFullView-Cg1rggho.js +1 -0
- package/src/ui/static/assets/ReportsPage-CFv3OAhe.js +48 -0
- package/src/ui/static/assets/ResultsPage-B4LwZH-R.js +115 -0
- package/src/ui/static/assets/RunTargets-C7Vqd4TU.js +1 -0
- package/src/ui/static/assets/ScriptMappingPage-BrANeHv0.js +1 -0
- package/src/ui/static/assets/SearchableDevicePicker-CFJ_DUAA.js +1 -0
- package/src/ui/static/assets/SettingsPage-BwOiebKG.js +83 -0
- package/src/ui/static/assets/SharedReportView-BAbW1WOs.js +1 -0
- package/src/ui/static/assets/SourcesPage-C_QVQwiA.js +14 -0
- package/src/ui/static/assets/TestExplorerPage-BRRWtwde.js +7 -0
- package/src/ui/static/assets/TestManagementPage-Ch4PthuU.js +10 -0
- package/src/ui/static/assets/TestPlansPage-Bno2vpGd.js +5 -0
- package/src/ui/static/assets/TestverCreditsDetail-cSW0SpNx.js +1 -0
- package/src/ui/static/assets/TestverCreditsRing-CUsMGEe3.js +1 -0
- package/src/ui/static/assets/UncommittedDiffViewer-B5HSURk8.js +2 -0
- package/src/ui/static/assets/UserManagementPage-BjY3ftxf.js +10 -0
- package/src/ui/static/assets/WorkflowsPage-BUu-LjZ8.js +83 -0
- package/src/ui/static/assets/aiHandoff-vhtR29Fh.js +1 -0
- package/src/ui/static/assets/ansiToHtml-DYRzYQV1.js +1 -0
- package/src/ui/static/assets/dark-logo-DCPcGDyT.svg +1 -0
- package/src/ui/static/assets/excel-BrxuVus5.js +1 -0
- package/src/ui/static/assets/formatDate-T65-Y6Mi.js +1 -0
- package/src/ui/static/assets/formatTestName-BKd2Uqhs.js +1 -0
- package/src/ui/static/assets/hiddenLlmProviders-setxgY_B.js +1 -0
- package/src/ui/static/assets/index-B0klHYbO.css +1 -0
- package/src/ui/static/assets/index-DpQhqcHv.js +11 -0
- package/src/ui/static/assets/index-DtBWNlVD.js +47 -0
- package/src/ui/static/assets/logo-C7ltqfpq.svg +1 -0
- package/src/ui/static/assets/runSelected-WlgnZcSF.js +1 -0
- package/src/ui/static/assets/sandboxStorage-BrzaG3ny.js +1 -0
- package/src/ui/static/assets/simpleMarkdown-kWs-10D8.js +5 -0
- package/src/ui/static/assets/useChartTheme-BFz2QcND.js +1 -0
- package/src/ui/static/assets/useDebouncedValue-BsHptIvX.js +1 -0
- package/src/ui/static/assets/useFeatureFlags-DqhngqgG.js +1 -0
- package/src/ui/static/assets/useJiraConnector-TM1Rfj1s.js +1 -0
- package/src/ui/static/assets/useOwnership-eW6Egd7X.js +1 -0
- package/src/ui/static/assets/useSuites-CvtMGakZ.js +1 -0
- package/src/ui/static/assets/useTabParam-ChbOedP1.js +1 -0
- package/src/ui/static/assets/useTestExplorer-HqvURJAc.js +1 -0
- package/src/ui/static/assets/useTestLifecycle-CL7-zz0Q.js +1 -0
- package/src/ui/static/assets/useTestManagement-ZTA1_VUm.js +2 -0
- package/src/ui/static/assets/useTestResults-Bm-JyMhB.js +1 -0
- package/src/ui/static/assets/vendor-charts-DWFQlmCz.js +73 -0
- package/src/ui/static/assets/vendor-excel-BFHGVHVC.js +24 -0
- package/src/ui/static/assets/vendor-flow-BnuhLJ6X.css +1 -0
- package/src/ui/static/assets/vendor-flow-YGpC9U9I.js +23 -0
- package/src/ui/static/assets/vendor-icons-B0wLOBoh.js +1421 -0
- package/src/ui/static/assets/vendor-query-BrzmPFT3.js +1 -0
- package/src/ui/static/assets/vendor-quill-CTpA5PSA.css +7 -0
- package/src/ui/static/assets/{index-xlbWNOlh.js → vendor-quill-W-RoQfb6.js} +1 -1
- package/src/ui/static/assets/vendor-react-CTbHBddL.js +61 -0
- package/src/ui/static/assets/visibleInterval-BKsLfJZ3.js +1 -0
- package/src/ui/static/dark-logo.svg +1 -1
- package/src/ui/static/index.html +5 -2
- package/src/ui/static/logo.svg +1 -1
- package/src/ui/static/assets/dark-logo-BddlJH8z.svg +0 -1
- package/src/ui/static/assets/index-8gWK1fNb.js +0 -2250
- package/src/ui/static/assets/index-DMd4ynKJ.css +0 -7
- package/src/ui/static/assets/logo-DwQCjTm_.svg +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{r as o,j as e,b as Kt,u as Ht}from"./vendor-react-CTbHBddL.js";import{a as mt,f as Je}from"./formatDate-T65-Y6Mi.js";import{ImportExportPage as Zt}from"./ImportExportPage-DXk7Koaq.js";import{a as Qt,b as Wt,u as Yt}from"./useTabParam-ChbOedP1.js";import{u as Xt}from"./useDebouncedValue-BsHptIvX.js";import{f as es}from"./formatTestName-BKd2Uqhs.js";import{E as ts,J as ss,K as as,L as rs,D as ns,M as ls,N as is,F as ds,O as os,P as cs,Q as xs,R as ms,S as us,T as ps,U as hs,V as gs,W as bs,X as fs,Y as ys,Z as js,_ as ut,$ as vs,a0 as Ns,a1 as ws,a2 as ks,a3 as Ss,a4 as Ts,a5 as zs,a6 as Cs,a7 as pt,a8 as As,a9 as Ms}from"./useTestManagement-ZTA1_VUm.js";import{E as Rs}from"./ExportButton-Ce_MxnM1.js";import{b as ht,a8 as Ds,gv as $s,x as Es}from"./index-DtBWNlVD.js";import{u as gt,b as Ls,a as Is,c as _s}from"./useJiraConnector-TM1Rfj1s.js";import{h as Fs}from"./aiHandoff-vhtR29Fh.js";import{J as Ps}from"./JiraPushDialog-CqftoLh8.js";import{a as Bs}from"./vendor-query-BrzmPFT3.js";import{B as Us,X as ee,y as ne,v as $e,ak as pe,bu as bt,b as ce,g as Pe,Z as Be,o as me,m as Os,b6 as Me,dh as et,b$ as Js,c as qs,aO as ve,bw as Gs,r as xe,a2 as ft,b9 as ue,bM as tt,a5 as st,cd as Vs,aL as yt,ae as Ue,bc as Ee,t as qe,F as Ks,b2 as Hs,a7 as at,bk as rt,d as nt,b0 as jt,G as _e,u as Fe,be as Zs,a9 as Qs,_ as Ae,ap as je,av as Ws,e as lt,al as it,S as dt,a3 as vt,aa as Ys,ar as ot,b3 as Xs,k as ea,aU as ta,di as sa,cy as aa}from"./vendor-icons-B0wLOBoh.js";import"./excel-BrxuVus5.js";import"./vendor-excel-BFHGVHVC.js";const Nt=["critical","high","medium","low"],wt=["web","ui","api","mobile","database","integration","e2e","security","performance","usability","accessibility","compatibility","localization"],kt=["draft","active","deprecated","archived"],St=["manual","automated","needs_update"],Tt=["draft","in_review","approved","rejected"],Ce=20,ct={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"},Oe={web:"bg-sky-500/20 text-sky-300",ui:"bg-indigo-500/20 text-indigo-300",api:"bg-cyan-500/20 text-cyan-300",mobile:"bg-violet-500/20 text-violet-300",database:"bg-teal-500/20 text-teal-300",integration:"bg-emerald-500/20 text-emerald-300",e2e:"bg-blue-500/20 text-blue-300",security:"bg-red-500/20 text-red-300",performance:"bg-rose-500/20 text-rose-300",usability:"bg-amber-500/20 text-amber-300",accessibility:"bg-fuchsia-500/20 text-fuchsia-300",compatibility:"bg-purple-500/20 text-purple-300",localization:"bg-orange-500/20 text-orange-300"},xt={draft:"bg-gray-500/20 text-gray-300",active:"bg-brand-500/20 text-brand-300",deprecated:"bg-red-500/20 text-red-300",archived:"bg-slate-500/20 text-slate-400"},Re={manual:"Manual",automated:"Automated",needs_update:"Needs Update"},De={draft:"Draft",in_review:"In Review",approved:"Approved",rejected:"Rejected"};function Z(t){const y={api:"API",ui:"UI",e2e:"E2E"};return y[t]?y[t]:t.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase())}function zt({node:t,depth:y,selectedFolderId:u,onSelect:g,onEdit:p,onDelete:b}){const[v,h]=o.useState(!0),[d,j]=o.useState(!1),[f,c]=o.useState(t.name),[N,i]=o.useState(!1),r=t.children&&t.children.length>0,x=u===t.id,T=hs(),z=()=>{f.trim()&&f!==t.name&&T.mutate({id:t.id,data:{name:f.trim()}}),j(!1)};return e.jsxs("div",{children:[e.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded-lg cursor-pointer transition-colors text-sm ${x?"bg-brand-500/15 text-brand-300":"text-gray-300 hover:bg-surface-2"}`,style:{paddingLeft:`${y*16+8}px`},onClick:()=>g(t.id),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[r?e.jsx("button",{onClick:m=>{m.stopPropagation(),h(!v)},className:"p-0.5 hover:bg-white/10 rounded",children:v?e.jsx(ne,{size:14}):e.jsx(qe,{size:14})}):e.jsx("span",{className:"w-5"}),v&&r?e.jsx(Ks,{size:15,className:"text-brand-400 flex-shrink-0"}):e.jsx(ve,{size:15,className:"text-gray-500 flex-shrink-0"}),d?e.jsx("input",{className:"flex-1 bg-surface-2 border border-white/10 rounded px-1.5 py-0.5 text-sm text-gray-200 outline-none focus:border-brand-500",value:f,onChange:m=>c(m.target.value),onBlur:z,onKeyDown:m=>{m.key==="Enter"&&z(),m.key==="Escape"&&j(!1)},onClick:m=>m.stopPropagation(),autoFocus:!0}):e.jsx("span",{className:"flex-1 truncate",children:t.name}),e.jsx("span",{className:"text-xs text-gray-500 mr-1",children:t.testCaseCount??0}),N&&!d&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{onClick:m=>{m.stopPropagation(),c(t.name),j(!0)},className:"p-1 rounded hover:bg-white/10 text-gray-400 hover:text-gray-200",children:e.jsx(Ee,{size:12})}),e.jsx("button",{onClick:m=>{m.stopPropagation(),b(t.id)},className:"p-1 rounded hover:bg-white/10 text-gray-400 hover:text-red-400",children:e.jsx(ue,{size:12})})]})]}),v&&r&&e.jsx("div",{children:t.children.map(m=>e.jsx(zt,{node:m,depth:y+1,selectedFolderId:u,onSelect:g,onEdit:p,onDelete:b},m.id))})]})}function ra({testCase:t,folders:y,tags:u,onClose:g,onSaved:p,currentUserName:b}){var F,Y;const v=!!(t!=null&&t.id),h=gs(),d=bs(),j=fs(),f=ys(),c=js(),{data:N}=ut(t==null?void 0:t.id),[i,r]=o.useState({title:(t==null?void 0:t.title)||"",preconditions:(t==null?void 0:t.preconditions)||"",priority:(t==null?void 0:t.priority)||"medium",type:(t==null?void 0:t.type)||"web",status:(t==null?void 0:t.status)||"draft",automationStatus:(t==null?void 0:t.automationStatus)||"manual",reviewStatus:(t==null?void 0:t.reviewStatus)||"draft",folderId:(t==null?void 0:t.folderId)||"",estimatedDuration:(t==null?void 0:t.estimatedDuration)||""}),[x,T]=o.useState((F=t==null?void 0:t.steps)!=null&&F.length?t.steps.map(n=>({id:n.id,action:n.action||"",expectedResult:n.expectedResult||"",testData:n.testData||""})):[{action:"",expectedResult:"",testData:""}]),[z,m]=o.useState(new Set(((Y=t==null?void 0:t.tags)==null?void 0:Y.map(n=>n.id))||[])),[I,D]=o.useState(""),[G,U]=o.useState(!1);o.useEffect(()=>{const n=(N==null?void 0:N.steps)||[];n.length>0&&v&&T(n.map(w=>({id:w.id,action:w.action||"",expectedResult:w.expectedResult||"",testData:w.testData||""})))},[N,v]);const A=o.useCallback((n,w=0)=>{const k=[];for(const S of n)k.push({id:S.id,name:S.name,depth:w}),S.children&&k.push(...A(S.children,w+1));return k},[]),l=o.useMemo(()=>A(y||[]),[y,A]),P=()=>T([...x,{action:"",expectedResult:"",testData:""}]),V=n=>{x.length>1&&T(x.filter((w,k)=>k!==n))},M=(n,w,k)=>{T(x.map((S,K)=>K===n?{...S,[w]:k}:S))},_=n=>{const w=new Set(z);w.has(n)?w.delete(n):w.add(n),m(w)},B=async()=>{if(!I.trim())return;const n=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899","#06b6d4","#84cc16"],w=n[Math.floor(Math.random()*n.length)];try{const k=await c.mutateAsync({name:I.trim(),color:w});k!=null&&k.id&&m(S=>new Set([...S,k.id])),D("")}catch{}},E=async()=>{var n;if(i.title.trim()){U(!0);try{const w={title:i.title.trim(),preconditions:i.preconditions,priority:i.priority,type:i.type,status:i.status,automationStatus:i.automationStatus,reviewStatus:i.reviewStatus,folderId:i.folderId||null,estimatedDuration:i.estimatedDuration?parseInt(i.estimatedDuration,10):null};let k;if(v)await d.mutateAsync({id:t.id,data:{...w,changedBy:b||""}}),k=t.id;else{const S=await h.mutateAsync({...w,createdBy:b||""});k=(S==null?void 0:S.id)||((n=S==null?void 0:S.testCase)==null?void 0:n.id)}if(k){const S=x.filter(K=>K.action.trim());S.length>0&&await j.mutateAsync({testCaseId:k,steps:S.map((K,le)=>({stepNumber:le+1,action:K.action,expectedResult:K.expectedResult,testData:K.testData}))}),z.size>0&&await f.mutateAsync({testCaseId:k,tagIds:Array.from(z)})}p(),g()}catch(w){console.error("Failed to save test case:",w)}finally{U(!1)}}};return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center overflow-y-auto",children:[e.jsx("div",{className:"absolute inset-0 bg-black/70",onClick:g}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 w-full max-w-3xl my-8 mx-4 animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-white/5",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-100",children:v?"Edit Test Case":"Create Test Case"}),e.jsx("button",{onClick:g,className:"p-1.5 rounded-lg hover:bg-surface-2 text-gray-400 hover:text-gray-200",children:e.jsx(ee,{size:18})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5 max-h-[calc(100vh-200px)] overflow-y-auto",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Title *"}),e.jsx("input",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 transition-colors",value:i.title,onChange:n=>r({...i,title:n.target.value}),placeholder:"Enter test case title..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Preconditions"}),e.jsx("textarea",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 transition-colors resize-none",rows:3,value:i.preconditions,onChange:n=>r({...i,preconditions:n.target.value}),placeholder:"Any preconditions or setup steps..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Priority"}),e.jsx("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.priority,onChange:n=>r({...i,priority:n.target.value}),children:Nt.map(n=>e.jsx("option",{value:n,children:Z(n)},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Type"}),e.jsx("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.type,onChange:n=>r({...i,type:n.target.value}),children:wt.map(n=>e.jsx("option",{value:n,children:Z(n)},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Status"}),e.jsx("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.status,onChange:n=>r({...i,status:n.target.value}),children:kt.map(n=>e.jsx("option",{value:n,children:Z(n)},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Automation Status"}),e.jsx("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.automationStatus,onChange:n=>r({...i,automationStatus:n.target.value}),children:St.map(n=>e.jsx("option",{value:n,children:Re[n]},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Review Status"}),e.jsx("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.reviewStatus,onChange:n=>r({...i,reviewStatus:n.target.value}),children:Tt.map(n=>e.jsx("option",{value:n,children:De[n]},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Folder"}),e.jsxs("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.folderId,onChange:n=>r({...i,folderId:n.target.value}),children:[e.jsx("option",{value:"",children:"No Folder (Uncategorized)"}),l.map(n=>e.jsxs("option",{value:n.id,children:[" ".repeat(n.depth),n.name]},n.id))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Estimated Duration (minutes)"}),e.jsx("input",{type:"number",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.estimatedDuration,onChange:n=>r({...i,estimatedDuration:n.target.value}),placeholder:"e.g. 15",min:0})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("label",{className:"text-sm font-medium text-gray-300",children:"Test Steps"}),e.jsxs("button",{onClick:P,className:"flex items-center gap-1 text-xs text-brand-400 hover:text-brand-300 transition-colors",children:[e.jsx(Me,{size:14}),"Add Step"]})]}),e.jsx("div",{className:"space-y-3",children:x.map((n,w)=>e.jsxs("div",{className:"bg-surface-2 rounded-lg border border-white/5 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-xs font-medium text-gray-400",children:["Step ",w+1]}),x.length>1&&e.jsx("button",{onClick:()=>V(w),className:"p-1 rounded hover:bg-white/10 text-gray-500 hover:text-red-400",children:e.jsx(ue,{size:13})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("textarea",{className:"w-full bg-surface-1 border border-white/10 rounded px-2.5 py-1.5 text-sm text-gray-200 placeholder-gray-500 outline-none focus:border-brand-500 resize-none",rows:2,value:n.action,onChange:k=>M(w,"action",k.target.value),placeholder:"Action / Step description..."}),e.jsx("textarea",{className:"w-full bg-surface-1 border border-white/10 rounded px-2.5 py-1.5 text-sm text-gray-200 placeholder-gray-500 outline-none focus:border-brand-500 resize-none",rows:2,value:n.expectedResult,onChange:k=>M(w,"expectedResult",k.target.value),placeholder:"Expected result..."}),e.jsx("input",{className:"w-full bg-surface-1 border border-white/10 rounded px-2.5 py-1.5 text-sm text-gray-200 placeholder-gray-500 outline-none focus:border-brand-500",value:n.testData,onChange:k=>M(w,"testData",k.target.value),placeholder:"Test data (optional)..."})]})]},w))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:u==null?void 0:u.map(n=>e.jsxs("button",{onClick:()=>_(n.id),className:`inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-medium transition-colors border ${z.has(n.id)?"border-brand-500 bg-brand-500/20 text-brand-300":"border-white/10 bg-surface-2 text-gray-400 hover:text-gray-300"}`,children:[z.has(n.id)&&e.jsx(pe,{size:12}),n.name]},n.id))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none focus:border-brand-500",placeholder:"Create new tag...",value:I,onChange:n=>D(n.target.value),onKeyDown:n=>{n.key==="Enter"&&B()}}),e.jsx("button",{onClick:B,disabled:!I.trim(),className:"px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10 disabled:opacity-40",children:"Add"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 px-6 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:g,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:E,disabled:G||!i.title.trim(),className:"flex items-center gap-2 px-5 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium transition-colors disabled:opacity-50",children:[e.jsx(Hs,{size:15}),G?"Saving...":v?"Update":"Create"]})]})]})]})}function na({testCase:t,versions:y,onToast:u,currentUserName:g}){const[p,b]=o.useState(null),[v,h]=o.useState(null),d=Ms();if(!y||y.length===0)return e.jsxs("div",{className:"text-center py-8 text-gray-500 text-sm",children:[e.jsx(jt,{size:24,className:"mx-auto mb-2 opacity-50"}),"No version history available"]});const j=y.map(i=>{let r={};try{r=JSON.parse(i.snapshot)}catch{}return{...i,snap:r}});function f(i,r){const x=[],T=[{key:"title",label:"Title"},{key:"preconditions",label:"Preconditions"},{key:"priority",label:"Priority"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"automationStatus",label:"Automation Status"},{key:"reviewStatus",label:"Review Status"},{key:"estimatedDuration",label:"Duration (min)"}];for(const l of T){const P=String(i[l.key]??""),V=String(r[l.key]??"");P!==V&&x.push({field:l.label,from:P||"(empty)",to:V||"(empty)"})}const z=(i.tags||[]).map(l=>l.name||l.id).sort().join(", "),m=(r.tags||[]).map(l=>l.name||l.id).sort().join(", ");z!==m&&x.push({field:"Tags",from:z||"(none)",to:m||"(none)"});const I=i.steps||[],D=r.steps||[],G=Math.max(I.length,D.length),U=[];let A=!1;for(let l=0;l<G;l++){const P=I[l],V=D[l],M=E=>E?{action:E.action||"",expectedResult:E.expectedResult||"",testData:E.testData||""}:void 0,_=M(P),B=M(V);if(!_&&B)U.push({type:"added",stepNum:l+1,newStep:B}),A=!0;else if(_&&!B)U.push({type:"removed",stepNum:l+1,oldStep:_}),A=!0;else if(_&&B){const E=_.action!==B.action||_.expectedResult!==B.expectedResult||_.testData!==B.testData;U.push({type:E?"modified":"unchanged",stepNum:l+1,oldStep:_,newStep:B}),E&&(A=!0)}}return{fieldDiffs:x,stepDiffs:U,hasStepChanges:A}}const c=i=>{var r;return i.version===((r=j[0])==null?void 0:r.version)};function N(i){d.mutate({testCaseId:t.id,versionId:i,changedBy:g},{onSuccess:()=>{h(null),b(null),u==null||u(`Test case restored to version ${i} successfully`,"success")},onError:()=>{u==null||u("Failed to restore version. Please try again.","error")}})}return e.jsx("div",{className:"space-y-2",children:j.map((i,r)=>{const x=p===i.version,T=r===0,z=r<j.length-1?j[r+1].snap:{},{fieldDiffs:m,stepDiffs:I,hasStepChanges:D}=f(z,i.snap),G=m.length+(D?1:0),U=v===i.version,A=I.filter(l=>l.type!=="unchanged");return e.jsxs("div",{className:"relative",children:[!T&&e.jsx("div",{className:"absolute left-[15px] -top-2 w-px h-2 bg-white/10"}),r<j.length-1&&e.jsx("div",{className:"absolute left-[15px] -bottom-2 w-px h-2 bg-white/10"}),e.jsx("button",{onClick:()=>b(x?null:i.version),className:`w-full text-left rounded-xl border transition-all ${x?"bg-surface-2 border-brand-500/30 shadow-lg shadow-brand-500/5":"bg-surface-2/60 border-white/5 hover:border-white/10 hover:bg-surface-2"}`,children:e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsxs("div",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold ${T?"bg-brand-500/20 text-brand-300 ring-2 ring-brand-500/30":"bg-surface-0 text-gray-400 ring-1 ring-white/10"}`,children:["v",i.version]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-gray-200",children:i.changeSummary||`Version ${i.version}`}),T&&e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold bg-brand-500/15 text-brand-300 uppercase tracking-wider",children:"Current"}),G>0&&!T&&e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-amber-500/15 text-amber-300",children:[m.length>0&&`${m.length} field${m.length!==1?"s":""}`,m.length>0&&D&&" + ",D&&`${A.length} step${A.length!==1?"s":""}`]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[i.changedBy&&e.jsxs("span",{className:"text-xs text-gray-500",children:["by ",i.changedBy]}),e.jsx("span",{className:"text-xs text-gray-500",children:i.changedAt?Je(i.changedAt):""})]})]}),e.jsx(qe,{size:16,className:`text-gray-500 transition-transform ${x?"rotate-90":""}`})]})}),x&&e.jsxs("div",{className:"mt-1 ml-5 mr-1 rounded-lg border border-white/5 bg-surface-1 overflow-hidden",children:[m.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"px-4 py-2.5 bg-surface-2/50 border-b border-white/5",children:e.jsx("h4",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Field Changes"})}),e.jsx("div",{className:"divide-y divide-white/5",children:m.map((l,P)=>e.jsxs("div",{className:"grid grid-cols-[100px_1fr_24px_1fr] items-start gap-2 px-4 py-2.5",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400 pt-0.5",children:l.field}),e.jsx("div",{className:"bg-red-500/8 border border-red-500/15 rounded px-2 py-1",children:e.jsx("p",{className:"text-xs text-red-300 line-through break-words",children:l.from})}),e.jsx(je,{size:14,className:"text-gray-600 mt-1 flex-shrink-0"}),e.jsx("div",{className:"bg-emerald-500/8 border border-emerald-500/15 rounded px-2 py-1",children:e.jsx("p",{className:"text-xs text-emerald-300 break-words",children:l.to})})]},P))})]}),D&&e.jsxs("div",{className:"border-t border-white/5",children:[e.jsx("div",{className:"px-4 py-2.5 bg-surface-2/50 border-b border-white/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Step Changes"}),e.jsxs("div",{className:"flex items-center gap-3",children:[A.filter(l=>l.type==="added").length>0&&e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-emerald-400",children:[e.jsx(sa,{size:10})," ",A.filter(l=>l.type==="added").length," added"]}),A.filter(l=>l.type==="removed").length>0&&e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-red-400",children:[e.jsx(aa,{size:10})," ",A.filter(l=>l.type==="removed").length," removed"]}),A.filter(l=>l.type==="modified").length>0&&e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-amber-400",children:[e.jsx(Ee,{size:10})," ",A.filter(l=>l.type==="modified").length," modified"]})]})]})}),e.jsx("div",{className:"divide-y divide-white/5",children:I.filter(l=>l.type!=="unchanged").map((l,P)=>e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded-full text-[10px] font-bold ${l.type==="added"?"bg-emerald-500/20 text-emerald-300":l.type==="removed"?"bg-red-500/20 text-red-300":"bg-amber-500/20 text-amber-300"}`,children:l.stepNum}),e.jsx("span",{className:`text-[10px] font-semibold uppercase tracking-wider ${l.type==="added"?"text-emerald-400":l.type==="removed"?"text-red-400":"text-amber-400"}`,children:l.type==="added"?"New Step":l.type==="removed"?"Removed Step":"Modified Step"})]}),l.type==="added"&&l.newStep&&e.jsxs("div",{className:"ml-7 space-y-1.5 bg-emerald-500/5 border border-emerald-500/15 rounded-lg p-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Action:"}),e.jsx("p",{className:"text-xs text-emerald-300 mt-0.5",children:l.newStep.action})]}),l.newStep.expectedResult&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Expected:"}),e.jsx("p",{className:"text-xs text-emerald-300 mt-0.5",children:l.newStep.expectedResult})]}),l.newStep.testData&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Test Data:"}),e.jsx("p",{className:"text-xs text-emerald-300 font-mono mt-0.5",children:l.newStep.testData})]})]}),l.type==="removed"&&l.oldStep&&e.jsxs("div",{className:"ml-7 space-y-1.5 bg-red-500/5 border border-red-500/15 rounded-lg p-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Action:"}),e.jsx("p",{className:"text-xs text-red-300 line-through mt-0.5",children:l.oldStep.action})]}),l.oldStep.expectedResult&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Expected:"}),e.jsx("p",{className:"text-xs text-red-300 line-through mt-0.5",children:l.oldStep.expectedResult})]}),l.oldStep.testData&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Test Data:"}),e.jsx("p",{className:"text-xs text-red-300 line-through font-mono mt-0.5",children:l.oldStep.testData})]})]}),l.type==="modified"&&l.oldStep&&l.newStep&&e.jsxs("div",{className:"ml-7 space-y-2",children:[l.oldStep.action!==l.newStep.action&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium block mb-1",children:"Action"}),e.jsxs("div",{className:"grid grid-cols-[1fr_20px_1fr] gap-1 items-start",children:[e.jsx("div",{className:"bg-red-500/8 border border-red-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-red-300 line-through leading-relaxed",children:l.oldStep.action})}),e.jsx(je,{size:12,className:"text-gray-600 mt-1.5 mx-auto"}),e.jsx("div",{className:"bg-emerald-500/8 border border-emerald-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-emerald-300 leading-relaxed",children:l.newStep.action})})]})]}),l.oldStep.expectedResult!==l.newStep.expectedResult&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium block mb-1",children:"Expected Result"}),e.jsxs("div",{className:"grid grid-cols-[1fr_20px_1fr] gap-1 items-start",children:[e.jsx("div",{className:"bg-red-500/8 border border-red-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-red-300 line-through leading-relaxed",children:l.oldStep.expectedResult||"(empty)"})}),e.jsx(je,{size:12,className:"text-gray-600 mt-1.5 mx-auto"}),e.jsx("div",{className:"bg-emerald-500/8 border border-emerald-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-emerald-300 leading-relaxed",children:l.newStep.expectedResult||"(empty)"})})]})]}),l.oldStep.testData!==l.newStep.testData&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium block mb-1",children:"Test Data"}),e.jsxs("div",{className:"grid grid-cols-[1fr_20px_1fr] gap-1 items-start",children:[e.jsx("div",{className:"bg-red-500/8 border border-red-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-red-300 line-through font-mono leading-relaxed",children:l.oldStep.testData||"(empty)"})}),e.jsx(je,{size:12,className:"text-gray-600 mt-1.5 mx-auto"}),e.jsx("div",{className:"bg-emerald-500/8 border border-emerald-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-emerald-300 font-mono leading-relaxed",children:l.newStep.testData||"(empty)"})})]})]})]})]},P))})]}),m.length===0&&!D&&e.jsx("div",{className:"px-4 py-4 text-center",children:e.jsx("p",{className:"text-xs text-gray-500",children:r===j.length-1?"Initial version — no previous version to compare":"No changes detected"})}),!c(i)&&e.jsx("div",{className:"border-t border-white/5 px-4 py-3 bg-surface-2/20",children:U?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-amber-300 flex-1",children:["Restore test case to version ",i.version,"?"]}),e.jsx("button",{onClick:()=>h(null),className:"px-3 py-1.5 text-xs rounded-lg bg-surface-2 hover:bg-surface-1 text-gray-400 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:()=>N(i.version),disabled:d.isPending,className:"px-3 py-1.5 text-xs rounded-lg bg-amber-600 hover:bg-amber-500 text-white font-medium transition-colors disabled:opacity-50 flex items-center gap-1.5",children:[e.jsx(ot,{size:12,className:d.isPending?"animate-spin":""}),d.isPending?"Restoring...":"Confirm Restore"]})]}):e.jsxs("button",{onClick:()=>h(i.version),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-lg bg-surface-2 hover:bg-amber-500/15 text-gray-400 hover:text-amber-300 border border-white/5 hover:border-amber-500/20 transition-all",children:[e.jsx(ot,{size:12}),"Restore to this version"]})})]})]},i.id)})})}function Ct(t,y,u){const g=(t==null?void 0:t.id)||"",p=(t==null?void 0:t.title)||"(untitled test case)",b=((t==null?void 0:t.preconditions)||"").trim(),v=((t==null?void 0:t.tags)||[]).map(d=>d==null?void 0:d.name).filter(Boolean);if(u==="json")return JSON.stringify({id:g,title:p,priority:t==null?void 0:t.priority,type:t==null?void 0:t.type,preconditions:b||void 0,tags:v.length?v:void 0,steps:y.map((d,j)=>({step:j+1,action:d.action||"",expected:d.expectedResult||d.expected_result||void 0,testData:d.testData||d.test_data||void 0}))},null,2);if(u==="plain"){const d=[];return d.push(`${g?g+" — ":""}${p}`),b&&d.push(`Preconditions: ${b}`),d.push(""),y.forEach((j,f)=>{d.push(`${f+1}. ${j.action||""}`);const c=j.expectedResult||j.expected_result,N=j.testData||j.test_data;c&&d.push(` Expected: ${c}`),N&&d.push(` Test data: ${N}`)}),d.join(`
|
|
2
|
+
`)}const h=[];return h.push(`Test case: ${g?g+" — ":""}${p}`),t!=null&&t.priority&&h.push(`Priority: ${t.priority}`),t!=null&&t.type&&h.push(`Type: ${t.type}`),v.length&&h.push(`Tags: ${v.join(", ")}`),h.push(""),b&&h.push(`Given ${b}`),y.forEach((d,j)=>{const f=j===0&&!b?"Given":j===0?"When":"And",c=d.testData||d.test_data,N=(d.action||"").trim();h.push(`${f} ${N}${c?` (data: ${c})`:""}`);const i=(d.expectedResult||d.expected_result||"").trim();i&&h.push(` Then ${i}`)}),h.join(`
|
|
3
|
+
`)}function la(t,y){return["Please help me automate the following manual test case.","Generate idiomatic, maintainable code with stable locators, reasonable assertions","for each expected outcome, and a clear test/file name derived from the title below.","",Ct(t,y,"gherkin")].join(`
|
|
4
|
+
`)}function ia({testCase:t,steps:y,onToast:u,isAutomated:g}){const p=Ht(),{mode:b}=Es(),[v,h]=o.useState(!1),[d,j]=o.useState(null),f=o.useRef(null);o.useEffect(()=>{if(!v)return;const r=x=>{f.current&&!f.current.contains(x.target)&&h(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[v]);const c=async r=>{try{const x=Ct(t,y,r);await navigator.clipboard.writeText(x),j(r),u==null||u(`Copied as ${r==="gherkin"?"Gherkin":r==="plain"?"text":"JSON"}`),setTimeout(()=>j(null),2e3),h(!1)}catch{u==null||u("Could not copy to clipboard","error")}},N=()=>{Fs(p,{prompt:la(t,y),mode:b==="mobile"?"mobile":"web"})},i=v&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-40 w-56 bg-surface-1 border border-white/10 rounded-lg shadow-xl overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>c("gherkin"),className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-left text-gray-300 hover:bg-surface-2 hover:text-gray-100",children:[d==="gherkin"?e.jsx(xe,{size:13,className:"text-emerald-400"}):e.jsx(dt,{size:13,className:"text-brand-300"}),"Copy as Gherkin (AI-friendly)"]}),e.jsxs("button",{type:"button",onClick:()=>c("plain"),className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-left text-gray-300 hover:bg-surface-2 hover:text-gray-100",children:[d==="plain"?e.jsx(xe,{size:13,className:"text-emerald-400"}):e.jsx(it,{size:13,className:"text-gray-400"}),"Copy as text"]}),e.jsxs("button",{type:"button",onClick:()=>c("json"),className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-left text-gray-300 hover:bg-surface-2 hover:text-gray-100",children:[d==="json"?e.jsx(xe,{size:13,className:"text-emerald-400"}):e.jsx(ta,{size:13,className:"text-sky-400"}),"Copy as JSON"]})]});return g?e.jsxs("div",{ref:f,className:"relative inline-flex",children:[e.jsxs("button",{type:"button",onClick:()=>h(r=>!r),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10 transition-colors",title:"Copy steps in a chosen format",children:[e.jsx(it,{size:13}),"Copy steps",e.jsx(ne,{size:13,className:"text-gray-500"})]}),i]}):e.jsxs("div",{ref:f,className:"relative inline-flex items-stretch",children:[e.jsxs("button",{type:"button",onClick:N,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-l-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",title:"Send these steps to the AI Assistant to generate automation code",children:[e.jsx(dt,{size:13}),"Automate with AI"]}),e.jsx("button",{type:"button",onClick:()=>h(r=>!r),className:"flex items-center px-1.5 py-1.5 rounded-r-lg bg-brand-600 hover:bg-brand-500 text-white border-l border-brand-500/40 transition-colors",title:"Copy steps in another format",children:e.jsx(ne,{size:13})}),i]})}function da({testCase:t,onClose:y,onEdit:u,onToast:g,currentUserName:p}){var ie,O;const[b,v]=Yt("detail",["steps","attachments","links","history","mapping","executions"],"steps"),[h,d]=o.useState(null),{data:j}=ut(t==null?void 0:t.id),{data:f}=vs(t==null?void 0:t.id),{data:c}=Ns(t==null?void 0:t.id),{data:N}=ws(t==null?void 0:t.id),{data:i}=ks(t==null?void 0:t.id),{data:r}=Ss(t==null?void 0:t.id),{data:x}=Ts(t==null?void 0:t.id),T=zs(),z=Cs(),m=pt(),I=As(),D=(j==null?void 0:j.steps)||[],G=(f==null?void 0:f.versions)||[],U=(N==null?void 0:N.attachments)||[],A=(i==null?void 0:i.links)||[],l=(x==null?void 0:x.sources)||[],[P,V]=o.useState(!1),[M,_]=o.useState({title:"",url:"",linkType:"other"}),[B,E]=o.useState(!1),[F,Y]=o.useState(null);if(!t)return null;const n=({size:s=18})=>e.jsxs("svg",{width:s,height:s,viewBox:"0 0 256 256",xmlns:"http://www.w3.org/2000/svg",children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{x1:"98.03%",y1:"0.16%",x2:"58.89%",y2:"40.77%",id:"tmjg1",children:[e.jsx("stop",{stopColor:"#0052CC",offset:"18%"}),e.jsx("stop",{stopColor:"#2684FF",offset:"100%"})]}),e.jsxs("linearGradient",{x1:"100.67%",y1:"0.46%",x2:"55.4%",y2:"44.73%",id:"tmjg2",children:[e.jsx("stop",{stopColor:"#0052CC",offset:"18%"}),e.jsx("stop",{stopColor:"#2684FF",offset:"100%"})]})]}),e.jsxs("g",{children:[e.jsx("path",{d:"M244.658,0 L121.707,0 C121.707,14.72 127.554,28.837 137.963,39.246 C148.372,49.655 162.489,55.502 177.209,55.502 L199.858,55.502 L199.858,77.369 C199.877,107.994 224.699,132.816 255.324,132.836 L255.324,10.667 C255.324,4.776 250.549,0 244.658,0 Z",fill:"#2684FF"}),e.jsx("path",{d:"M183.822,61.262 L60.871,61.262 C60.891,91.887 85.713,116.709 116.338,116.729 L138.987,116.729 L138.987,138.667 C139.026,169.292 163.864,194.098 194.489,194.098 L194.489,71.929 C194.489,66.038 189.713,61.262 183.822,61.262 Z",fill:"url(#tmjg1)"}),e.jsx("path",{d:"M122.951,122.489 L0,122.489 C0,153.142 24.849,177.991 55.502,177.991 L78.222,177.991 L78.222,199.858 C78.242,230.455 103.02,255.266 133.618,255.324 L133.618,133.156 C133.618,127.265 128.842,122.489 122.951,122.489 Z",fill:"url(#tmjg2)"})]})]}),w=({size:s=18})=>e.jsxs("svg",{width:s,height:s,viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"cg1",x1:"28.607",y1:"-60.825",x2:"11.085",y2:"-50.756",gradientTransform:"matrix(1,0,0,-1,0,-29.66)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0.18",stopColor:"#0052cc"}),e.jsx("stop",{offset:"1",stopColor:"#2684ff"})]}),e.jsxs("linearGradient",{id:"cg2",x1:"621.442",y1:"1817.567",x2:"603.915",y2:"1827.64",gradientTransform:"matrix(-1,0,0,1,624.83,-1816.71)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0.18",stopColor:"#0052cc"}),e.jsx("stop",{offset:"1",stopColor:"#2684ff"})]})]}),e.jsx("path",{d:"M3.015,23.087c-.289.472-.614,1.02-.891,1.456a.892.892,0,0,0,.3,1.212l5.792,3.564a.89.89,0,0,0,1.226-.29l.008-.013c.231-.387.53-.891.855-1.43,2.294-3.787,4.6-3.323,8.763-1.336l5.743,2.731A.892.892,0,0,0,26,28.559l.011-.024L28.766,22.3a.891.891,0,0,0-.445-1.167c-1.212-.57-3.622-1.707-5.792-2.754C14.724,14.586,8.09,14.831,3.015,23.087Z",fill:"url(#cg1)"}),e.jsx("path",{d:"M28.985,8.932c.289-.472.614-1.02.891-1.456a.892.892,0,0,0-.3-1.212L23.785,2.7a.89.89,0,0,0-1.236.241.584.584,0,0,0-.033.053c-.232.387-.53.891-.856,1.43-2.294,3.787-4.6,3.323-8.763,1.336L7.172,3.043a.89.89,0,0,0-1.187.421l-.011.024L3.216,9.726a.891.891,0,0,0,.445,1.167c1.212.57,3.622,1.706,5.792,2.753C17.276,17.433,23.91,17.179,28.985,8.932Z",fill:"url(#cg2)"})]}),k=({size:s=18})=>e.jsx("svg",{width:s,height:s,viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M10,0 C15.523,0 20,4.59 20,10.253 C20,14.782 17.138,18.624 13.167,19.981 C12.66,20.082 12.48,19.762 12.48,19.489 C12.48,19.151 12.492,18.047 12.492,16.675 C12.492,15.719 12.172,15.095 11.813,14.777 C14.04,14.523 16.38,13.656 16.38,9.718 C16.38,8.598 15.992,7.684 15.35,6.966 C15.454,6.707 15.797,5.664 15.252,4.252 C15.252,4.252 14.414,3.977 12.505,5.303 C11.706,5.076 10.85,4.962 10,4.958 C9.15,4.962 8.295,5.076 7.497,5.303 C5.586,3.977 4.746,4.252 4.746,4.252 C4.203,5.664 4.546,6.707 4.649,6.966 C4.01,7.684 3.619,8.598 3.619,9.718 C3.619,13.646 5.954,14.526 8.175,14.785 C7.889,15.041 7.63,15.493 7.54,16.156 C6.97,16.418 5.522,16.871 4.63,15.304 C4.63,15.304 4.101,14.319 3.097,14.247 C3.097,14.247 2.122,14.234 3.029,14.87 C3.029,14.87 3.684,15.185 4.139,16.37 C4.139,16.37 4.726,18.2 7.508,17.58 C7.513,18.437 7.522,19.245 7.522,19.489 C7.522,19.76 7.338,20.077 6.839,19.982 C2.865,18.627 0,14.783 0,10.253 C0,4.59 4.478,0 10,0",fill:"currentColor"})}),S={jira:{label:"Jira",color:"text-blue-400"},confluence:{label:"Confluence",color:"text-blue-300"},github:{label:"GitHub",color:"text-gray-300"},docs:{label:"Docs",emoji:"📑",color:"text-emerald-400"},design:{label:"Design",emoji:"🎨",color:"text-purple-400"},other:{label:"Other",emoji:"🔗",color:"text-gray-400"}},K=({type:s,size:C=18})=>{if(s==="jira")return e.jsx(n,{size:C});if(s==="confluence")return e.jsx(w,{size:C});if(s==="github")return e.jsx(k,{size:C});const L=S[s]||S.other;return e.jsx("span",{style:{fontSize:C},children:L.emoji})},le=async s=>{const C=s.target.files;if(!(!C||!(t!=null&&t.id))){for(const L of Array.from(C)){if(L.size>10*1024*1024){g==null||g(`File "${L.name}" exceeds 10MB limit`,"error");continue}const W=new FileReader;W.onload=()=>{const be=W.result.split(",")[1]||"";T.mutate({testCaseId:t.id,data:{fileName:L.name,fileType:L.type,fileSize:L.size,fileData:be,uploadedBy:p||""}})},W.readAsDataURL(L)}s.target.value=""}},Ne=s=>{z.mutate({id:s,testCaseId:t.id})},se=()=>{!M.title.trim()||!M.url.trim()||(m.mutate({testCaseId:t.id,data:{title:M.title.trim(),url:M.url.trim(),linkType:M.linkType,addedBy:p||""}}),_({title:"",url:"",linkType:"other"}),V(!1))},X=s=>{I.mutate({id:s,testCaseId:t.id})},he=s=>{const C=document.createElement("a");C.href=`data:${s.fileType};base64,${s.fileData}`,C.download=s.fileName,C.click()},Le=s=>s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`,te=s=>s.startsWith("image/"),Q=Array.isArray(r==null?void 0:r.history)?r.history:[],we=Q.length>0?Math.round(Q.filter(s=>s.status==="passed").length/Q.length*100):0,ge=[{key:"steps",label:"Steps",icon:ce,count:D.length},{key:"executions",label:"Executions",icon:at,count:Q.length},{key:"attachments",label:"Attachments",icon:rt,count:U.length},{key:"links",label:"Links",icon:nt,count:A.length},{key:"history",label:"History",icon:jt},{key:"mapping",label:"Mapping",icon:_e}];return e.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:y}),e.jsxs("div",{className:"relative bg-surface-1 w-full max-w-3xl border-l border-white/10 animate-slide-in-right overflow-y-auto",children:[e.jsx("div",{className:"sticky top-0 bg-surface-1 z-10 px-6 py-4 border-b border-white/5",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-100 pr-4 break-words",children:t.title}),e.jsxs("div",{className:"flex items-center gap-2.5 mt-2",children:[t.id&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[13px] text-gray-400 font-mono",children:[e.jsx(yt,{size:13,className:"flex-shrink-0"}),t.id]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-[13px] text-gray-400",children:[e.jsx(ve,{size:13,className:"flex-shrink-0"}),((ie=t.folder)==null?void 0:ie.name)||"Uncategorized"]}),D.length>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[13px] text-gray-400",children:[e.jsx(ce,{size:13,className:"flex-shrink-0"}),D.length," step",D.length!==1?"s":""]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("button",{onClick:()=>u(t),title:"Edit test case",className:"p-1.5 rounded-lg hover:bg-surface-2 text-gray-400 hover:text-gray-200 transition-colors",children:e.jsx(Ee,{size:18})}),e.jsx("button",{onClick:y,title:"Close",className:"p-1.5 rounded-lg hover:bg-surface-2 text-gray-400 hover:text-gray-200 transition-colors",children:e.jsx(ee,{size:18})})]})]})}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("span",{className:`inline-flex items-center px-2.5 py-1 rounded-md text-xs font-medium ${ct[t.priority]||ct.medium}`,children:Z(t.priority||"medium")}),e.jsx("span",{className:`inline-flex items-center px-2.5 py-1 rounded-md text-xs font-medium ${Oe[t.type]||Oe.web}`,children:Z(t.type||"web")}),e.jsx("span",{className:`inline-flex items-center px-2.5 py-1 rounded-md text-xs font-medium ${xt[t.status]||xt.draft}`,children:Z(t.status||"draft")}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-md text-xs font-medium bg-surface-2 text-gray-300",children:[e.jsx(Be,{size:12}),Re[t.automationStatus]||"Manual"]}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-md text-xs font-medium bg-surface-2 text-gray-300",children:[e.jsx(Ue,{size:12}),De[t.reviewStatus]||"Not Reviewed"]})]}),t.staleAt?e.jsx(ha,{id:t.id,reason:t.staleReason}):null,t.preconditions&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-1.5",children:"Preconditions"}),e.jsx("p",{className:"text-sm text-gray-300 bg-surface-2 rounded-lg p-3 border border-white/5 whitespace-pre-wrap",children:t.preconditions})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[!!t.estimatedDuration&&e.jsxs("div",{className:"bg-surface-2 rounded-lg p-3 border border-white/5",children:[e.jsx("span",{className:"text-xs text-gray-400 block mb-0.5",children:"Duration"}),e.jsxs("span",{className:"text-sm text-gray-200 flex items-center gap-1.5",children:[e.jsx(Fe,{size:13})," ",t.estimatedDuration," min"]})]}),e.jsxs("div",{className:"bg-surface-2 rounded-lg p-3 border border-white/5",children:[e.jsx("span",{className:"text-xs text-gray-400 block mb-0.5",children:"Folder"}),e.jsxs("span",{className:"text-sm text-gray-200 flex items-center gap-1.5",children:[e.jsx(ve,{size:13})," ",((O=t.folder)==null?void 0:O.name)||"Uncategorized"]})]})]}),t.tags&&t.tags.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-1.5",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.tags.map(s=>e.jsx("span",{className:"inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium bg-surface-2 text-gray-300 border border-white/5",children:s.name},s.id))})]}),e.jsx("div",{className:"flex border-b border-white/5 overflow-x-auto",children:ge.map(s=>e.jsxs("button",{onClick:()=>v(s.key),className:`flex items-center gap-1.5 px-3.5 py-2.5 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${b===s.key?"border-brand-500 text-brand-300":"border-transparent text-gray-400 hover:text-gray-300"}`,children:[e.jsx(s.icon,{size:14}),s.label,"count"in s&&typeof s.count=="number"&&s.count>0&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-bold bg-surface-2 text-gray-400",children:s.count})]},s.key))}),b==="steps"&&e.jsxs("div",{children:[D&&D.length>0&&e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"Test Steps"}),e.jsx(ia,{testCase:t,steps:D,onToast:g,isAutomated:(t==null?void 0:t.automationStatus)==="automated"||(t==null?void 0:t.automation_status)==="automated"||!!(c!=null&&c.scriptPath)})]}),D&&D.length>0?e.jsxs("div",{className:"rounded-xl border border-white/10 overflow-hidden",children:[e.jsxs("div",{className:"grid grid-cols-[48px_1fr_1fr_140px] bg-surface-2/80 border-b border-white/10",children:[e.jsx("div",{className:"px-3 py-2.5 text-xs font-semibold text-gray-400 uppercase tracking-wider text-center",children:"#"}),e.jsx("div",{className:"px-3 py-2.5 text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Action"}),e.jsx("div",{className:"px-3 py-2.5 text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Expected Result"}),e.jsx("div",{className:"px-3 py-2.5 text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Test Data"})]}),D.map((s,C)=>e.jsxs("div",{className:`grid grid-cols-[48px_1fr_1fr_140px] border-b border-white/5 last:border-b-0 transition-colors hover:bg-white/[0.02] ${C%2===0?"bg-surface-1":"bg-surface-2/30"}`,children:[e.jsx("div",{className:"px-3 py-3 flex items-start justify-center",children:e.jsx("span",{className:"w-6 h-6 rounded-full bg-brand-500/20 text-brand-300 text-xs font-bold flex items-center justify-center flex-shrink-0",children:s.stepNumber||C+1})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("p",{className:"text-sm text-gray-200 leading-relaxed whitespace-pre-wrap",children:s.action})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("p",{className:"text-sm text-teal-200 leading-relaxed whitespace-pre-wrap",children:s.expectedResult||e.jsx("span",{className:"text-gray-600 italic",children:"—"})})}),e.jsx("div",{className:"px-3 py-3",children:s.testData?e.jsx("p",{className:"text-sm text-sky-300 font-mono leading-relaxed break-all",children:s.testData}):e.jsx("span",{className:"text-gray-600 text-sm italic",children:"—"})})]},s.id||C)),e.jsx("div",{className:"bg-surface-2/50 px-4 py-2 border-t border-white/10",children:e.jsxs("span",{className:"text-xs text-gray-500",children:[D.length," step",D.length!==1?"s":""," total"]})})]}):e.jsxs("div",{className:"text-center py-8 text-gray-500 text-sm",children:[e.jsx(ce,{size:24,className:"mx-auto mb-2 opacity-50"}),"No steps defined yet"]})]}),b==="attachments"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"Attachments"}),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:[e.jsx(Zs,{size:13}),"Upload Files",e.jsx("input",{type:"file",multiple:!0,accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.csv,.json,.xml,.yaml,.yml,.md",className:"hidden",onChange:le})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"Max 10MB per file. Supported: Images, PDFs, Office documents, text files."}),U.length>0?e.jsx("div",{className:"space-y-2",children:U.map(s=>{var C;return e.jsxs("div",{className:"flex items-center gap-3 bg-surface-2 rounded-lg p-3 border border-white/5 group hover:border-white/10 transition-colors",children:[e.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-surface-1 border border-white/5 flex items-center justify-center overflow-hidden",children:te(s.fileType)?e.jsx("button",{onClick:()=>Y(s),className:"w-full h-full",children:e.jsx("img",{src:`data:${s.fileType};base64,${s.fileData}`,alt:s.fileName,className:"w-full h-full object-cover rounded-lg"})}):(C=s.fileType)!=null&&C.includes("pdf")?e.jsx(Pe,{size:18,className:"text-red-400"}):e.jsx(Pe,{size:18,className:"text-gray-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 font-medium truncate",children:s.fileName}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[e.jsx("span",{children:Le(s.fileSize)}),s.uploadedBy&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:s.uploadedBy})]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:mt(s.createdAt)})]})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[te(s.fileType)&&e.jsx("button",{onClick:()=>Y(s),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-gray-200",title:"Preview",children:e.jsx(Ue,{size:14})}),e.jsx("button",{onClick:()=>he(s),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-gray-200",title:"Download",children:e.jsx(Qs,{size:14})}),e.jsx("button",{onClick:()=>Ne(s.id),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-red-400",title:"Delete",children:e.jsx(ue,{size:14})})]})]},s.id)})}):e.jsxs("div",{className:"text-center py-8 text-gray-500 text-sm",children:[e.jsx(rt,{size:24,className:"mx-auto mb-2 opacity-50"}),"No attachments yet"]}),F&&e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:()=>Y(null),children:e.jsxs("div",{className:"relative max-w-4xl max-h-[90vh] mx-4",onClick:s=>s.stopPropagation(),children:[e.jsx("button",{onClick:()=>Y(null),className:"absolute -top-3 -right-3 z-10 p-1.5 rounded-full bg-surface-2 border border-white/10 text-gray-300 hover:text-white shadow-xl",children:e.jsx(ee,{size:16})}),e.jsx("img",{src:`data:${F.fileType};base64,${F.fileData}`,alt:F.fileName,className:"max-w-full max-h-[85vh] rounded-xl shadow-2xl object-contain"}),e.jsx("p",{className:"text-center text-sm text-gray-400 mt-2",children:F.fileName})]})})]}),b==="links"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"Reference Links"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pa,{testCaseId:t.id,onLinked:()=>{}}),e.jsxs("button",{onClick:()=>V(!P),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 transition-colors",children:[e.jsx(Me,{size:13}),"Add Link"]})]})]}),P&&e.jsxs("div",{className:"bg-surface-2 rounded-lg border border-white/10 p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"Title *"}),e.jsx("input",{className:"w-full bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:M.title,onChange:s=>_({...M,title:s.target.value}),placeholder:"e.g. JIRA-1234 Login Bug, Design Mockup..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"URL *"}),e.jsx("input",{className:"w-full bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:M.url,onChange:s=>_({...M,url:s.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"Type"}),e.jsxs("button",{type:"button",onClick:()=>E(!B),className:"w-full bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 flex items-center gap-2 text-left",children:[e.jsx(K,{type:M.linkType,size:16}),e.jsx("span",{className:"flex-1",children:{jira:"Jira Ticket",confluence:"Confluence Page",github:"GitHub Issue / PR",docs:"Documentation",design:"Design (Figma, etc.)",other:"Other"}[M.linkType]||"Other"}),e.jsx(ne,{size:14,className:`text-gray-400 transition-transform ${B?"rotate-180":""}`})]}),B&&e.jsx("div",{className:"absolute z-20 mt-1 w-full bg-surface-1 border border-white/10 rounded-lg shadow-xl overflow-hidden",children:[{value:"jira",label:"Jira Ticket"},{value:"confluence",label:"Confluence Page"},{value:"github",label:"GitHub Issue / PR"},{value:"docs",label:"Documentation"},{value:"design",label:"Design (Figma, etc.)"},{value:"other",label:"Other"}].map(s=>e.jsxs("button",{type:"button",onClick:()=>{_({...M,linkType:s.value}),E(!1)},className:`w-full flex items-center gap-2.5 px-3 py-2.5 text-sm text-left hover:bg-surface-2 transition-colors ${M.linkType===s.value?"bg-surface-2 text-brand-300":"text-gray-200"}`,children:[e.jsx(K,{type:s.value,size:16}),e.jsx("span",{children:s.label}),M.linkType===s.value&&e.jsx(pe,{size:14,className:"ml-auto text-brand-400"})]},s.value))})]}),e.jsxs("div",{className:"flex gap-2 justify-end pt-1",children:[e.jsx("button",{onClick:()=>{V(!1),_({title:"",url:"",linkType:"other"})},className:"px-3 py-1.5 text-xs rounded-lg bg-surface-1 hover:bg-surface-0 text-gray-400 border border-white/10",children:"Cancel"}),e.jsx("button",{onClick:se,disabled:!M.title.trim()||!M.url.trim(),className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium disabled:opacity-50",children:"Add Link"})]})]}),A.length>0?e.jsx("div",{className:"space-y-2",children:A.map(s=>e.jsxs("div",{className:"flex items-center gap-3 bg-surface-2 rounded-lg p-3 border border-white/5 group hover:border-white/10 transition-colors",children:[e.jsx("div",{className:"flex-shrink-0 w-7 h-7 rounded-md bg-surface-1 border border-white/5 flex items-center justify-center",children:e.jsx(K,{type:s.linkType,size:16})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 font-medium truncate",children:s.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[e.jsx("span",{className:`font-medium ${(S[s.linkType]||S.other).color}`,children:(S[s.linkType]||S.other).label}),e.jsx("span",{children:"·"}),e.jsx("span",{className:"truncate max-w-[200px]",children:s.url}),s.addedBy&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:s.addedBy})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-brand-300",title:"Open Link",children:e.jsx(Ae,{size:14})}),s.linkType==="jira"&&e.jsx(ga,{jiraUrl:s.url,testCaseTitle:t.title||t.name||""}),e.jsx("button",{onClick:()=>X(s.id),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-red-400",title:"Delete",children:e.jsx(ue,{size:14})})]})]},s.id))}):e.jsxs("div",{className:"text-center py-8 text-gray-500 text-sm",children:[e.jsx(nt,{size:24,className:"mx-auto mb-2 opacity-50"}),"No reference links yet"]})]}),b==="history"&&e.jsx(na,{testCase:t,versions:G,onToast:g,currentUserName:p}),b==="mapping"&&e.jsxs("div",{className:"space-y-5",children:[l.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-2",children:"Generated From Sources"}),e.jsx("div",{className:"space-y-1.5",children:l.map(s=>{const C={requirement:"Requirement",nlp:"NLP",jira:"JIRA",document:"Document"},L=()=>{if(s.type==="jira")return e.jsx(n,{size:16});const W={requirement:"📋",nlp:"💬",document:"📎"};return e.jsx("span",{className:"text-sm",children:W[s.type]||"📎"})};return e.jsxs("div",{className:"flex items-center gap-2.5 bg-surface-2 rounded-lg px-3 py-2.5 border border-white/5",children:[e.jsx("span",{className:"flex-shrink-0",children:e.jsx(L,{})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 font-medium truncate",children:s.title}),e.jsx("span",{className:"text-[10px] text-gray-500",children:C[s.type]||"Source"})]}),s.externalUrl&&e.jsx("a",{href:s.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"p-1 rounded hover:bg-white/10 text-gray-400 hover:text-brand-300",children:e.jsx(Ae,{size:12})})]},s.id)})})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-2",children:"Script Mapping"}),c?e.jsxs("div",{className:"bg-surface-2 rounded-lg border border-white/5 px-4 py-3 flex items-start gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-brand-500/10 border border-brand-500/20 flex items-center justify-center shrink-0 mt-0.5",children:e.jsx(_e,{size:16,className:"text-brand-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[c.testName&&e.jsx("p",{className:"text-sm font-medium text-gray-200 mb-0.5",title:c.testName,children:es(c.testName)}),e.jsx("p",{className:"text-xs font-mono text-gray-400 truncate",title:c.scriptPath,children:c.scriptPath}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[c.framework&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-medium bg-sky-500/20 text-sky-200 border border-sky-500/25",children:c.framework}),c.syncStatus&&e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium ${c.syncStatus==="synced"?"bg-emerald-500/15 text-emerald-300 border border-emerald-500/20":c.syncStatus==="case_updated"?"bg-blue-500/15 text-blue-300 border border-blue-500/20":c.syncStatus==="script_updated"?"bg-amber-500/15 text-amber-300 border border-amber-500/20":"bg-red-500/15 text-red-300 border border-red-500/20"}`,children:[c.syncStatus==="synced"?e.jsx(xe,{size:9}):e.jsx(me,{size:9}),Z(c.syncStatus)]}),c.lastSynced&&e.jsxs("span",{className:"text-[10px] text-gray-500",children:["Synced: ",new Date(c.lastSynced).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]})]}),e.jsx("button",{onClick:()=>{const s=c.scriptPath.replace(/\\/g,"/"),C=`/tests?file=${encodeURIComponent(s)}&test=${encodeURIComponent(c.testName||"")}`;window.open(C,"_blank","noopener")},className:"p-2 rounded-lg hover:bg-white/10 text-gray-400 hover:text-brand-400 transition-colors shrink-0",title:"View Script (new tab)",children:e.jsx(Ae,{size:16})})]}):e.jsxs("div",{className:"text-center py-6 text-gray-500 text-sm bg-surface-2 rounded-lg border border-white/5",children:[e.jsx(_e,{size:20,className:"mx-auto mb-1.5 opacity-50"}),"No script mapping configured",e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"Map this test case to a script in the Script Mapping screen"})]})]})]}),b==="executions"&&e.jsxs("div",{className:"space-y-4",children:[Q.length>0&&e.jsxs("div",{className:"bg-surface-2 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"grid grid-cols-4 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xl font-bold text-gray-100",children:Q.length}),e.jsx("div",{className:"text-xs text-gray-500",children:"Total Runs"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xl font-bold text-emerald-400",children:Q.filter(s=>s.status==="passed").length}),e.jsx("div",{className:"text-xs text-gray-500",children:"Passed"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xl font-bold text-red-400",children:Q.filter(s=>s.status==="failed").length}),e.jsx("div",{className:"text-xs text-gray-500",children:"Failed"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-xl font-bold text-brand-400",children:[we,"%"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"Pass Rate"})]})]}),e.jsx("div",{className:"mt-3 h-2 bg-surface-1 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-emerald-500 rounded-full transition-all",style:{width:`${we}%`}})})]}),Q.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(at,{className:"w-8 h-8 text-gray-600 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-500",children:"No executions yet"}),e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"This test case has not been executed in any cycle."})]}):e.jsx("div",{className:"space-y-2",children:Q.map(s=>{var Se,J;const C=h===s.executionId,L={passed:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",failed:"bg-red-500/10 text-red-400 border-red-500/20",blocked:"bg-orange-500/10 text-orange-400 border-orange-500/20",skipped:"bg-gray-500/10 text-gray-400 border-gray-500/20",not_run:"bg-slate-500/10 text-slate-400 border-slate-500/20",in_progress:"bg-blue-500/10 text-blue-400 border-blue-500/20"},W={passed:e.jsx(ea,{className:"w-4 h-4 text-emerald-400"}),failed:e.jsx(ft,{className:"w-4 h-4 text-red-400"}),blocked:e.jsx(me,{className:"w-4 h-4 text-orange-400"}),skipped:e.jsx(Xs,{className:"w-4 h-4 text-gray-400"}),not_run:e.jsx(Fe,{className:"w-4 h-4 text-slate-400"})},be=s.executedAt?Je(s.executedAt):"—",ke=s.duration?`${s.duration}s`:"—";return e.jsxs("div",{className:"bg-surface-2 rounded-xl border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-white/[0.02] transition-colors",onClick:()=>d(C?null:s.executionId),children:[C?e.jsx(ne,{className:"w-4 h-4 text-gray-500 shrink-0"}):e.jsx(qe,{className:"w-4 h-4 text-gray-500 shrink-0"}),W[s.status]||e.jsx(Fe,{className:"w-4 h-4 text-gray-500"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-gray-200 truncate",children:s.planName||"Plan"}),e.jsx(je,{className:"w-3 h-3 text-gray-600 shrink-0"}),e.jsx("span",{className:"text-sm text-gray-300 truncate",children:s.cycleName||"Cycle"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5 text-xs text-gray-500",children:[e.jsx("span",{children:be}),s.executedBy&&e.jsxs("span",{children:["by ",s.executedBy]}),s.duration>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Ws,{className:"w-3 h-3"})," ",ke]})]})]}),e.jsx("span",{className:`text-xs px-2.5 py-1 rounded-full border font-medium capitalize ${L[s.status]||L.not_run}`,children:(s.status||"not_run").replace("_"," ")}),((Se=s.stepSummary)==null?void 0:Se.total)>0&&e.jsxs("span",{className:"text-[10px] text-gray-500 shrink-0",children:[s.stepSummary.passed,"/",s.stepSummary.total," steps"]}),s.defect&&e.jsxs("span",{className:`text-[10px] px-2 py-0.5 rounded border flex items-center gap-1 shrink-0 ${s.defect.status==="open"?"bg-red-500/10 text-red-400 border-red-500/20":s.defect.status==="resolved"?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:[e.jsx(lt,{className:"w-3 h-3"}),s.defect.id]})]}),C&&e.jsxs("div",{className:"border-t border-white/5 px-4 py-3 bg-surface-1/50",children:[((J=s.stepResults)==null?void 0:J.length)>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("th",{className:"text-left px-3 py-2 text-gray-500 font-medium w-8",children:"#"}),e.jsx("th",{className:"text-left px-3 py-2 text-gray-500 font-medium w-16",children:"Status"}),e.jsx("th",{className:"text-left px-3 py-2 text-gray-500 font-medium",children:"Action"}),e.jsx("th",{className:"text-left px-3 py-2 text-gray-500 font-medium",children:"Expected"}),e.jsx("th",{className:"text-left px-3 py-2 text-gray-500 font-medium",children:"Actual"})]})}),e.jsx("tbody",{children:s.stepResults.map((q,Ie)=>e.jsxs("tr",{className:`border-b border-white/5 ${q.status==="failed"?"bg-red-500/5":""}`,children:[e.jsx("td",{className:"px-3 py-2 text-gray-600 font-mono",children:q.stepNumber}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`inline-flex items-center gap-1 ${q.status==="passed"?"text-emerald-400":q.status==="failed"?"text-red-400":q.status==="blocked"?"text-orange-400":"text-gray-500"}`,children:q.status==="passed"?"✅":q.status==="failed"?"❌":q.status==="blocked"?"🚫":q.status==="skipped"?"⏭":"⬜"})}),e.jsx("td",{className:"px-3 py-2 text-gray-300 max-w-[180px]",children:e.jsx("span",{className:"line-clamp-2",children:q.action||"—"})}),e.jsx("td",{className:"px-3 py-2 text-gray-400 max-w-[150px]",children:e.jsx("span",{className:"line-clamp-2",children:q.expectedResult||"—"})}),e.jsx("td",{className:`px-3 py-2 max-w-[150px] ${q.status==="failed"?"text-red-400 font-medium":"text-gray-400"}`,children:e.jsx("span",{className:"line-clamp-2",children:q.actualResult||"—"})})]},Ie))})]})}):e.jsx("p",{className:"text-xs text-gray-500 text-center py-4",children:"No step-level results recorded for this execution."}),s.defect&&e.jsxs("div",{className:`mt-3 p-3 rounded-lg border flex items-center gap-2 ${s.defect.status==="open"?"bg-red-500/5 border-red-500/20":s.defect.status==="resolved"?"bg-emerald-500/5 border-emerald-500/20":"bg-amber-500/5 border-amber-500/20"}`,children:[e.jsx(lt,{className:"w-4 h-4 text-red-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-xs font-medium text-gray-200",children:s.defect.id}),e.jsx("span",{className:"text-xs text-gray-400 ml-2 truncate",children:s.defect.title})]}),e.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full capitalize ${s.defect.status==="open"?"bg-red-500/10 text-red-400":s.defect.status==="resolved"?"bg-emerald-500/10 text-emerald-400":"bg-amber-500/10 text-amber-400"}`,children:s.defect.status.replace("_"," ")}),e.jsx("span",{className:"text-[10px] text-gray-500 capitalize",children:s.defect.severity})]}),s.comments&&e.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-surface-2 border border-white/5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-500 uppercase tracking-wider",children:"Execution Notes"}),e.jsx("p",{className:"text-xs text-gray-300 mt-1",children:s.comments})]})]})]},s.executionId)})})]})]})]})]})}function oa({folders:t,count:y,onMove:u,onClose:g}){const[p,b]=o.useState(""),v=(d,j=0)=>{const f=[];for(const c of d)f.push({id:c.id,name:c.name,depth:j}),c.children&&f.push(...v(c.children,j+1));return f},h=v(t||[]);return 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:g}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 p-6 w-96 animate-fade-in",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100 mb-1",children:["Move ",y," Test Case",y>1?"s":""]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Select a destination folder"}),e.jsxs("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 mb-4",value:p,onChange:d=>b(d.target.value),children:[e.jsx("option",{value:"",children:"Select folder..."}),h.map(d=>e.jsxs("option",{value:d.id,children:[" ".repeat(d.depth),d.name]},d.id))]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:g,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsx("button",{onClick:()=>{p&&u(p)},disabled:!p,className:"px-4 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium disabled:opacity-50",children:"Move"})]})]})]})}function ca({tags:t,count:y,onApply:u,onClose:g}){const[p,b]=o.useState(new Set),v=h=>{const d=new Set(p);d.has(h)?d.delete(h):d.add(h),b(d)};return 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:g}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 p-6 w-96 animate-fade-in",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100 mb-1",children:["Tag ",y," Test Case",y>1?"s":""]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Select tags to apply"}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4 max-h-48 overflow-y-auto",children:[t==null?void 0:t.map(h=>e.jsxs("button",{onClick:()=>v(h.id),className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors border ${p.has(h.id)?"border-brand-500 bg-brand-500/20 text-brand-300":"border-white/10 bg-surface-2 text-gray-400 hover:text-gray-300"}`,children:[p.has(h.id)&&e.jsx(pe,{size:12}),h.name]},h.id)),(!t||t.length===0)&&e.jsx("p",{className:"text-sm text-gray-500",children:"No tags available. Create tags first."})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:g,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsx("button",{onClick:()=>u(Array.from(p)),disabled:p.size===0,className:"px-4 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium disabled:opacity-50",children:"Apply Tags"})]})]})]})}function xa({title:t,message:y,confirmLabel:u="Delete",onConfirm:g,onCancel:p}){return e.jsx("div",{className:"fixed inset-0 z-[110] flex items-center justify-center bg-black/60 backdrop-blur-sm animate-fade-in",children:e.jsxs("div",{className:"bg-surface-2 border border-border-1 rounded-2xl shadow-2xl w-full max-w-md mx-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 pt-6 pb-2",children:[e.jsx("div",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-red-500/15",children:e.jsx(me,{size:20,className:"text-red-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-100",children:t})]}),e.jsx("div",{className:"px-6 py-4",children:e.jsx("p",{className:"text-sm text-gray-400 leading-relaxed",children:y})}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-border-1 bg-surface-1/50",children:[e.jsx("button",{onClick:p,className:"px-4 py-2 text-sm font-medium text-gray-300 bg-surface-1 border border-border-1 rounded-lg hover:bg-surface-2 hover:text-gray-100 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:g,className:"px-4 py-2 text-sm font-medium text-white bg-red-600 rounded-lg hover:bg-red-500 transition-colors shadow-lg shadow-red-600/20",children:u})]})]})})}function ma({tags:t,selectedIds:y,onChange:u}){var i;const[g,p]=o.useState(!1),[b,v]=o.useState(""),h=o.useRef(null);o.useEffect(()=>{if(!g)return;const r=x=>{h.current&&!h.current.contains(x.target)&&p(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[g]);const d=o.useMemo(()=>{const r=b.trim().toLowerCase();return r?t.filter(x=>x.name.toLowerCase().includes(r)):t},[t,b]),j=r=>{const x=new Set(y);x.has(r)?x.delete(r):x.add(r),u(x)},f=r=>{r.stopPropagation(),u(new Set)},c=y.size,N=c===0?"Tags":c===1?((i=t.find(r=>r.id===Array.from(y)[0]))==null?void 0:i.name)||"1 tag":`${c} tags`;return e.jsxs("div",{ref:h,className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>p(r=>!r),className:`flex items-center gap-1.5 bg-surface-1 border rounded-lg px-3 py-2 text-sm outline-none transition-colors ${c>0?"border-brand-500/40 text-gray-200":"border-white/10 text-gray-300 hover:border-white/20"}`,children:[e.jsx(bt,{size:13,className:c>0?"text-brand-400":"text-gray-500"}),e.jsx("span",{children:N}),c>0?e.jsx("span",{onClick:f,role:"button",className:"ml-0.5 p-0.5 rounded hover:bg-white/10 text-gray-400 hover:text-gray-200",title:"Clear tag filter",children:e.jsx(ee,{size:12})}):e.jsx(ne,{size:12,className:"text-gray-500"})]}),g&&e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-40 w-64 bg-surface-1 border border-white/10 rounded-lg shadow-xl overflow-hidden",children:[e.jsx("div",{className:"p-2 border-b border-white/5",children:e.jsxs("div",{className:"relative",children:[e.jsx($e,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{autoFocus:!0,value:b,onChange:r=>v(r.target.value),placeholder:"Search tags…",className:"w-full bg-surface-2 border border-white/10 rounded pl-7 pr-2 py-1.5 text-xs text-gray-200 outline-none focus:border-brand-500"})]})}),e.jsx("div",{className:"max-h-64 overflow-y-auto py-1",children:d.length===0?e.jsx("div",{className:"px-3 py-3 text-xs text-gray-500 text-center",children:"No tags found"}):d.map(r=>{const x=y.has(r.id);return e.jsxs("button",{type:"button",onClick:()=>j(r.id),className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs text-left transition-colors ${x?"bg-brand-500/10 text-gray-100":"text-gray-300 hover:bg-surface-2"}`,children:[e.jsx("span",{className:`w-3.5 h-3.5 rounded border flex items-center justify-center flex-shrink-0 ${x?"bg-brand-600 border-brand-500 text-white":"border-white/20"}`,children:x&&e.jsx(pe,{size:10})}),r.color&&e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:r.color}}),e.jsx("span",{className:"truncate",children:r.name})]},r.id)})}),c>0&&e.jsxs("div",{className:"border-t border-white/5 px-2 py-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] text-gray-500",children:[c," selected"]}),e.jsx("button",{type:"button",onClick:()=>u(new Set),className:"text-[10px] text-gray-400 hover:text-gray-200 px-2 py-0.5 rounded hover:bg-white/5",children:"Clear all"})]})]})]})}function ua({sources:t,selectedId:y,onChange:u}){const[g,p]=o.useState(!1),[b,v]=o.useState(""),h=o.useRef(null),[d,j]=o.useState(!1);o.useEffect(()=>{var m;if(!g)return;const r=(m=h.current)==null?void 0:m.getBoundingClientRect();if(!r)return;const z=r.left+288+16>window.innerWidth;j(z)},[g]),o.useEffect(()=>{if(!g)return;const r=x=>{h.current&&!h.current.contains(x.target)&&p(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[g]);const f=o.useMemo(()=>{const r=b.trim().toLowerCase();return r?t.filter(x=>x.title.toLowerCase().includes(r)):t},[t,b]),c=t.find(r=>r.id===y)||null,N={requirement:"Requirement",nlp:"Notes",jira:"JIRA",document:"Document"},i=c?c.title:"Source";return e.jsxs("div",{ref:h,className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>p(r=>!r),className:`flex items-center gap-1.5 bg-surface-1 border rounded-lg px-3 py-2 text-sm outline-none transition-colors max-w-[220px] ${c?"border-brand-500/40 text-gray-200":"border-white/10 text-gray-300 hover:border-white/20"}`,children:[e.jsx(Us,{size:13,className:c?"text-brand-400":"text-gray-500"}),e.jsx("span",{className:"truncate",children:i}),c?e.jsx("span",{onClick:r=>{r.stopPropagation(),u(null)},role:"button",className:"ml-0.5 p-0.5 rounded hover:bg-white/10 text-gray-400 hover:text-gray-200 flex-shrink-0",title:"Clear source filter",children:e.jsx(ee,{size:12})}):e.jsx(ne,{size:12,className:"text-gray-500 flex-shrink-0"})]}),g&&e.jsxs("div",{className:`absolute top-full mt-1 z-40 w-72 bg-surface-1 border border-white/10 rounded-lg shadow-xl overflow-hidden ${d?"right-0":"left-0"}`,children:[e.jsx("div",{className:"p-2 border-b border-white/5",children:e.jsxs("div",{className:"relative",children:[e.jsx($e,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{autoFocus:!0,value:b,onChange:r=>v(r.target.value),placeholder:"Search sources…",className:"w-full bg-surface-2 border border-white/10 rounded pl-7 pr-2 py-1.5 text-xs text-gray-200 outline-none focus:border-brand-500"})]})}),e.jsx("div",{className:"max-h-64 overflow-y-auto py-1",children:f.length===0?e.jsx("div",{className:"px-3 py-3 text-xs text-gray-500 text-center",children:t.length===0?"No sources have linked test cases yet":"No sources match your search"}):f.map(r=>{const x=r.id===y;return e.jsxs("button",{type:"button",onClick:()=>{u(x?null:r.id),p(!1)},title:r.title,className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs text-left transition-colors ${x?"bg-brand-500/10 text-gray-100":"text-gray-300 hover:bg-surface-2"}`,children:[e.jsx("span",{className:"flex-1 min-w-0 truncate",children:r.title}),e.jsxs("span",{title:`${N[r.type]||r.type} · ${r.testCaseCount} test case${r.testCaseCount===1?"":"s"}`,className:"text-[10px] text-gray-500 flex-shrink-0",children:[N[r.type]||r.type," · ",r.testCaseCount]}),x&&e.jsx(pe,{size:12,className:"text-brand-300 flex-shrink-0"})]},r.id)})})]})]})}function $a(){var Qe,We,Ye;const{toast:t}=ht(),y=o.useCallback((a,R="success")=>{t(R,a)},[t]),{user:u}=Ds(),g=(u==null?void 0:u.displayName)||(u==null?void 0:u.username)||"",[p,b]=o.useState(null),[v,h]=o.useState(""),[d,j]=o.useState(!1);o.useEffect(()=>{if(!d)return;const a=R=>{R.key==="Escape"&&j(!1)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[d]);const[f,c]=o.useState({}),[N,i]=o.useState(new Set),[r,x]=o.useState(null),{data:T}=ts(),z=(T==null?void 0:T.sources)??[],[m,I]=o.useState(new Set),[D,G]=o.useState(!1),[U,A]=o.useState(null),[l]=Qt("tcId"),P=Wt(),[V,M]=o.useState(!1),[_,B]=o.useState(""),[E,F]=o.useState(1),[Y,n]=o.useState(!1),[w,k]=o.useState(!1),[S,K]=o.useState("createdAt"),[le,Ne]=o.useState("desc"),[se,X]=o.useState(null),{data:he,isLoading:Le}=ss(),te=(he==null?void 0:he.tree)||[],Q=as(),we=rs(),{data:ge}=ns(),ie=(ge==null?void 0:ge.tags)||[],{data:O}=ls(),{data:s}=is(),C=(s==null?void 0:s.dots)||{},L=Xt(v,250),[W,be]=o.useState(L),ke=W===L?E:1;o.useEffect(()=>{W!==L&&(be(L),F(1))},[L,W]);const Se=o.useMemo(()=>{const a={page:ke,limit:Ce,sort:S,order:le};return p&&(a.folderId=p),p==="__uncategorized__"&&(a.folderId=null),L.trim()&&(a.search=L.trim()),f.priority&&(a.priority=f.priority),f.type&&(a.type=f.type),f.status&&(a.status=f.status),f.automationStatus&&(a.automationStatus=f.automationStatus),f.reviewStatus&&(a.reviewStatus=f.reviewStatus),N.size>0&&(a.tagIds=Array.from(N)),r&&(a.sourceId=r),a},[p,L,f,N,r,ke,S,le]),{data:J,isLoading:q}=ds(Se),Ie=os(),At=cs(),Mt=xs(),Te=ms(),Rt=us(),H=(J==null?void 0:J.testCases)||[],ae=(J==null?void 0:J.total)||H.length,re=Math.ceil(ae/Ce)||1,Ge=((Qe=J==null?void 0:J.aggregates)==null?void 0:Qe.byPriority)||{},Dt=((We=J==null?void 0:J.aggregates)==null?void 0:We.byAutomation)||{},Ve=o.useMemo(()=>{if(!l)return null;const a=l.toLowerCase();return H.find(R=>{var $;return(($=R.id)==null?void 0:$.toLowerCase())===a})||null},[l,H]),{data:$t}=ps(l&&!Ve?l:null),Ke=Ve||($t??null),He=()=>{_.trim()&&(Q.mutate({name:_.trim(),parentId:p}),B(""),M(!1))},Et=a=>{X({title:"Delete Folder",message:"Are you sure you want to delete this folder? All test cases inside it will become uncategorized. This action cannot be undone.",confirmLabel:"Delete Folder",onConfirm:()=>{we.mutate(a),p===a&&b(null),X(null)}})},Lt=a=>{X({title:"Delete Test Case",message:"Are you sure you want to delete this test case? This action cannot be undone and all associated versions, steps, and data will be permanently removed.",confirmLabel:"Delete Test Case",onConfirm:()=>{Ie.mutate(a),I(R=>{const $=new Set(R);return $.delete(a),$}),X(null)}})},It=()=>{m.size!==0&&X({title:"Delete Selected Test Cases",message:`Are you sure you want to delete ${m.size} selected test case(s)? This action cannot be undone and all associated data will be permanently removed.`,confirmLabel:`Delete ${m.size} Test Case(s)`,onConfirm:()=>{At.mutate(Array.from(m)),I(new Set),X(null)}})},_t=a=>{Mt.mutate({ids:Array.from(m),folderId:a}),I(new Set),n(!1)},Ft=a=>{Rt.mutate({ids:Array.from(m),tagIds:a}),I(new Set),k(!1)},Pt=a=>{I(R=>{const $=new Set(R);return $.has(a)?$.delete(a):$.add(a),$})},Bt=()=>{m.size===H.length?I(new Set):I(new Set(H.map(a=>a.id)))},Ut=a=>{S===a?Ne(R=>R==="asc"?"desc":"asc"):(K(a),Ne("asc"))},fe=(a,R)=>{c($=>{const de={...$};return R?de[a]=R:delete de[a],de}),F(1)},Ot=()=>{c({}),i(new Set),x(null),h(""),F(1)},ze=Object.keys(f).length+(v?1:0)+(N.size>0?1:0)+(r?1:0);((Ye=O==null?void 0:O.byAutomation)==null?void 0:Ye.automated)??(O==null||O.automatedCount);const Ze=(O==null?void 0:O.totalCases)??(O==null?void 0:O.totalCount)??ae??0,Jt=o.useMemo(()=>(te||[]).reduce((a,R)=>a+(R.testCaseCount??0),0),[te]),qt=Math.max(0,Ze-Jt);return e.jsxs("div",{className:"h-full flex flex-col bg-surface-0 animate-fade-in",children:[e.jsx("div",{className:"flex-shrink-0 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"}),"Test Cases"]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[e.jsx("p",{className:"text-sm text-gray-400",children:"Manage, organize, and track your test cases"}),e.jsx("span",{className:"text-xs text-gray-500",children:"|"}),e.jsxs("div",{className:"flex items-center gap-2.5 text-sm",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-brand-500/15 text-brand-300 px-3 py-1 rounded-full font-medium",children:[e.jsx(Pe,{size:14}),ae," Cases"]}),(()=>{const a=Dt.automated??0,R=ae>0?Math.round(a/ae*100):0;return e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-emerald-500/15 text-emerald-300 px-3 py-1 rounded-full font-medium",children:[e.jsx(Be,{size:14}),R,"% Automated"]})})(),(()=>{const a=Ge.critical??0;return a>0?e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-red-500/15 text-red-300 px-3 py-1 rounded-full font-medium",children:[e.jsx(me,{size:14}),a," Critical"]}):null})(),(()=>{const a=Ge.high??0;return a>0?e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-orange-500/15 text-orange-300 px-3 py-1 rounded-full font-medium",children:[e.jsx(Os,{size:14}),a," High"]}):null})()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[m.size>0&&e.jsx(Rs,{type:"test-cases",formats:["docx","xlsx","csv"],label:`Export (${m.size})`,params:{ids:Array.from(m)}}),e.jsxs("button",{onClick:()=>{A(null),G(!0)},className:"inline-flex items-center justify-center gap-2 h-9 px-4 rounded-lg border border-transparent bg-brand-600 hover:bg-brand-500 text-white text-[13px] font-medium leading-none transition-colors",children:[e.jsx(Me,{size:15}),"New Test Case"]}),e.jsxs("button",{onClick:()=>j(!0),className:"inline-flex items-center justify-center gap-2 h-9 px-4 rounded-lg border border-white/10 text-gray-300 hover:text-gray-100 hover:border-white/20 hover:bg-white/[0.03] text-[13px] font-medium leading-none transition-colors",title:"Import test cases from a file or another tool, or export this catalogue",children:[e.jsx(et,{size:15}),"Import / Export"]})]})]})})}),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsxs("div",{className:"w-72 flex-shrink-0 border-r border-white/5 flex flex-col bg-surface-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-white/5",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-300 uppercase tracking-wider",children:"Folders"}),e.jsx("button",{onClick:()=>M(!V),className:"p-1.5 rounded-lg hover:bg-surface-2 text-gray-400 hover:text-brand-300 transition-colors",title:"Add folder",children:e.jsx(Js,{size:16})})]}),V&&e.jsx("div",{className:"px-3 py-2 border-b border-white/5",children:e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("input",{className:"flex-1 bg-surface-2 border border-white/10 rounded-lg px-2.5 py-1.5 text-sm text-gray-200 outline-none focus:border-brand-500",placeholder:"Folder name...",value:_,onChange:a=>B(a.target.value),onKeyDown:a=>{a.key==="Enter"&&He(),a.key==="Escape"&&M(!1)},autoFocus:!0}),e.jsx("button",{onClick:He,disabled:!_.trim(),className:"p-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-40",children:e.jsx(pe,{size:14})})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-2 px-2 space-y-0.5",children:[e.jsxs("button",{onClick:()=>{b(null),F(1)},className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${p===null?"bg-brand-500/15 text-brand-300":"text-gray-300 hover:bg-surface-2"}`,children:[e.jsx(qs,{size:15}),e.jsx("span",{className:"flex-1 text-left",children:"All Test Cases"}),e.jsx("span",{className:"text-xs text-gray-500",children:Ze})]}),Le?e.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500",children:"Loading folders..."}):e.jsx(e.Fragment,{children:(te||[]).map(a=>e.jsx(zt,{node:a,depth:0,selectedFolderId:p,onSelect:R=>{b(R),F(1)},onEdit:()=>{},onDelete:Et},a.id))}),e.jsxs("button",{onClick:()=>{b("__uncategorized__"),F(1)},className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors mt-1 ${p==="__uncategorized__"?"bg-brand-500/15 text-brand-300":"text-gray-400 hover:bg-surface-2"}`,children:[e.jsx(ve,{size:15,className:"text-gray-500"}),e.jsx("span",{className:"flex-1 text-left",children:"Uncategorized"}),e.jsx("span",{className:"text-xs text-gray-500",children:qt})]})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsxs("div",{className:"flex-shrink-0 px-5 py-3 border-b border-white/5 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[e.jsx($e,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{className:"w-full bg-surface-1 border border-white/10 rounded-lg pl-9 pr-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 transition-colors placeholder-gray-500",placeholder:"Search test cases...",value:v,onChange:a=>h(a.target.value)})]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-300 outline-none focus:border-brand-500",value:f.priority||"",onChange:a=>fe("priority",a.target.value),children:[e.jsx("option",{value:"",children:"Priority"}),Nt.map(a=>e.jsx("option",{value:a,children:Z(a)},a))]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-300 outline-none focus:border-brand-500",value:f.type||"",onChange:a=>fe("type",a.target.value),children:[e.jsx("option",{value:"",children:"Type"}),wt.map(a=>e.jsx("option",{value:a,children:Z(a)},a))]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-300 outline-none focus:border-brand-500",value:f.status||"",onChange:a=>fe("status",a.target.value),children:[e.jsx("option",{value:"",children:"Status"}),kt.map(a=>e.jsx("option",{value:a,children:Z(a)},a))]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-300 outline-none focus:border-brand-500",value:f.automationStatus||"",onChange:a=>fe("automationStatus",a.target.value),children:[e.jsx("option",{value:"",children:"Automation"}),St.map(a=>e.jsx("option",{value:a,children:Re[a]},a))]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-300 outline-none focus:border-brand-500",value:f.reviewStatus||"",onChange:a=>fe("reviewStatus",a.target.value),children:[e.jsx("option",{value:"",children:"Review"}),Tt.map(a=>e.jsx("option",{value:a,children:De[a]},a))]}),e.jsx(ma,{tags:ie||[],selectedIds:N,onChange:a=>{i(a),F(1)}}),e.jsx(ua,{sources:z,selectedId:r,onChange:a=>{x(a),F(1)}}),ze>0&&e.jsxs("button",{onClick:Ot,className:"flex items-center gap-1 px-3 py-2 text-sm text-gray-400 hover:text-gray-200 transition-colors",children:[e.jsx(ee,{size:14}),"Clear (",ze,")"]})]}),m.size>0&&e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-brand-500/10 rounded-lg border border-brand-500/20",children:[e.jsxs("span",{className:"text-sm font-medium text-brand-300",children:[m.size," selected"]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsxs("button",{onClick:()=>n(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10 transition-colors",children:[e.jsx(Gs,{size:14}),"Move"]}),e.jsxs("button",{onClick:()=>k(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10 transition-colors",children:[e.jsx(bt,{size:14}),"Tag"]}),e.jsxs("button",{onClick:()=>Te.mutate({ids:Array.from(m),reviewStatus:"approved"},{onError:a=>t("error",(a==null?void 0:a.message)||"Could not approve the test cases")}),disabled:Te.isPending,title:"Mark the selected test cases as approved",className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-emerald-300 border border-white/10 transition-colors disabled:opacity-50",children:[e.jsx(xe,{size:14}),"Approve"]}),e.jsxs("button",{onClick:()=>Te.mutate({ids:Array.from(m),reviewStatus:"rejected"},{onError:a=>t("error",(a==null?void 0:a.message)||"Could not reject the test cases")}),disabled:Te.isPending,title:"Mark the selected test cases as rejected — they are left out of quick plans",className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-amber-300 border border-white/10 transition-colors disabled:opacity-50",children:[e.jsx(ft,{size:14}),"Reject"]}),e.jsx(Ps,{ids:Array.from(m)}),e.jsxs("button",{onClick:It,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-red-600/80 hover:bg-red-600 text-white transition-colors",children:[e.jsx(ue,{size:14}),"Delete"]}),e.jsx("button",{onClick:()=>I(new Set),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-gray-200",children:e.jsx(ee,{size:14})})]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[q?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-8 h-8 border-2 border-brand-500 border-t-transparent rounded-full animate-spin mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Loading test cases..."})]})}):H.length===0?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ce,{size:40,className:"mx-auto mb-3 text-gray-600"}),e.jsx("h3",{className:"text-base font-medium text-gray-300 mb-1",children:"No test cases found"}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:ze>0?"Try adjusting your filters":"Create your first test case to get started"}),ze===0&&e.jsxs("button",{onClick:()=>{A(null),G(!0)},className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium transition-colors",children:[e.jsx(Me,{size:15}),"New Test Case"]})]})}):e.jsxs("div",{className:"rounded-xl border border-white/10 overflow-hidden bg-surface-1 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[40px_1fr_90px_100px_80px_105px_90px_130px_90px] bg-surface-2/80 border-b border-white/10",children:[e.jsx("div",{className:"px-3 py-3 flex items-center justify-center",children:e.jsx("button",{onClick:Bt,role:"checkbox","aria-checked":m.size===H.length&&H.length>0,"aria-label":"Select all test cases on this page",className:"text-gray-400 hover:text-gray-200",children:m.size===H.length&&H.length>0?e.jsx(tt,{size:15,className:"text-brand-500"}):e.jsx(st,{size:15})})}),e.jsx("div",{className:"px-3 py-3",children:e.jsxs("button",{onClick:()=>Ut("title"),className:"flex items-center gap-1.5 text-[11px] font-semibold text-gray-400 uppercase tracking-wider hover:text-gray-200 transition-colors",children:["Test Case",e.jsx(Vs,{size:11,className:"opacity-60"})]})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Priority"})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Type"})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Status"})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Automation"})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Review"})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Executions"})}),e.jsx("div",{className:"px-3 py-3 text-center",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Actions"})})]}),H.map((a,R)=>{var de;const $=m.has(a.id);return e.jsxs("div",{className:`grid grid-cols-[40px_1fr_90px_100px_80px_105px_90px_130px_90px] border-b border-white/5 last:border-b-0 transition-all group ${$?"bg-brand-500/10 border-l-2 border-l-brand-500":R%2===0?"bg-surface-1 hover:bg-white/[0.02]":"bg-surface-2/30 hover:bg-white/[0.04]"}`,children:[e.jsx("div",{className:"px-3 py-3.5 flex items-center justify-center",children:e.jsx("button",{onClick:()=>Pt(a.id),role:"checkbox","aria-checked":$,"aria-label":`Select ${a.title||a.id}`,className:"text-gray-400 hover:text-gray-200 transition-colors",children:$?e.jsx(tt,{size:15,className:"text-brand-500"}):e.jsx(st,{size:15,className:"group-hover:text-gray-300"})})}),e.jsxs("div",{className:"px-3 py-3.5 min-w-0",children:[e.jsx("button",{onClick:()=>P({tcId:a.id,detail:null}),className:"text-sm text-gray-200 hover:text-brand-300 transition-colors text-left font-medium leading-snug line-clamp-2 w-full",children:a.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.id&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-gray-500 font-mono",children:[e.jsx(yt,{size:10,className:"flex-shrink-0"}),a.id]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-gray-500",children:[e.jsx(ve,{size:10,className:"flex-shrink-0"}),((de=a.folder)==null?void 0:de.name)||"Uncategorized"]}),a.steps&&a.steps.length>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-gray-500",children:[e.jsx(ce,{size:10,className:"flex-shrink-0"}),a.steps.length," step",a.steps.length!==1?"s":""]})]})]}),e.jsx("div",{className:"px-3 py-3.5 flex items-center",children:e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-semibold ${a.priority==="critical"?"bg-red-500/20 text-red-300":a.priority==="high"?"bg-orange-500/20 text-orange-300":a.priority==="medium"?"bg-amber-500/20 text-amber-300":"bg-emerald-500/20 text-emerald-300"}`,children:Z(a.priority||"medium")})}),e.jsx("div",{className:"px-3 py-3.5 flex items-center",children:e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-semibold ${Oe[a.type]||"bg-gray-500/20 text-gray-300"}`,children:Z(a.type||"web")})}),e.jsx("div",{className:"px-3 py-3.5 flex items-center",children:e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-semibold ${a.status==="active"?"bg-brand-500/20 text-brand-300":a.status==="draft"?"bg-gray-500/20 text-gray-300":a.status==="deprecated"?"bg-red-500/20 text-red-300":"bg-slate-500/20 text-slate-400"}`,children:Z(a.status||"draft")})}),e.jsx("div",{className:"px-3 py-3.5 flex items-center",children:e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-semibold ${a.automationStatus==="automated"?"bg-emerald-500/20 text-emerald-300":a.automationStatus==="needs_update"?"bg-amber-500/20 text-amber-300":"bg-gray-500/20 text-gray-400"}`,children:[e.jsx(Be,{size:10}),Re[a.automationStatus]||"Manual"]})}),e.jsxs("div",{className:"px-3 py-3.5 flex flex-col items-start justify-center gap-1",children:[a.staleAt?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-semibold bg-amber-500/20 text-amber-300",title:a.staleReason||"The requirement this case was written from changed",children:[e.jsx(me,{size:10}),"Source changed"]}):null,e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-semibold ${a.reviewStatus==="approved"?"bg-emerald-500/20 text-emerald-300":a.reviewStatus==="rejected"?"bg-red-500/20 text-red-300":a.reviewStatus==="in_review"?"bg-sky-500/20 text-sky-300":"bg-gray-500/20 text-gray-400"}`,children:De[a.reviewStatus]||"Draft"})]}),e.jsx("div",{className:"px-3 py-3.5 flex items-center",children:(()=>{const ye=C[a.id];if(!ye||ye.length===0)return e.jsx("span",{className:"text-[10px] text-gray-600 italic",children:"No runs"});const Gt=[...ye].reverse().slice(-5),Xe={passed:"bg-emerald-300/70",failed:"bg-rose-300/70",blocked:"bg-amber-300/70",skipped:"bg-slate-300/60",in_progress:"bg-sky-300/70",not_run:"bg-gray-400/40"};return e.jsx("div",{className:"flex items-center gap-1.5",title:`${ye.length} execution${ye.length!==1?"s":""}`,children:Gt.map((oe,Vt)=>e.jsxs("div",{className:"relative group/dot",children:[e.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${Xe[oe.status]||Xe.not_run} transition-transform hover:scale-150`}),e.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover/dot:block z-50 pointer-events-none",children:e.jsxs("div",{className:"bg-surface-2 text-gray-200 text-[10px] rounded-lg px-2.5 py-1.5 whitespace-nowrap shadow-xl border border-white/10",children:[e.jsx("div",{className:"font-medium capitalize",children:oe.status.replace("_"," ")}),e.jsxs("div",{className:"text-gray-400",children:[oe.planName," > ",oe.cycleName]}),oe.executedAt&&e.jsx("div",{className:"text-gray-500",children:mt(oe.executedAt)})]})})]},Vt))})})()}),e.jsx("div",{className:"px-3 py-3.5 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-0.5 opacity-40 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>P({tcId:a.id,detail:null}),className:"p-1.5 rounded-lg hover:bg-brand-500/10 text-gray-400 hover:text-brand-300 transition-colors",title:"View details",children:e.jsx(Ue,{size:14})}),e.jsx("button",{onClick:()=>{A(a),G(!0)},className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-gray-200 transition-colors",title:"Edit",children:e.jsx(Ee,{size:14})}),e.jsx("button",{onClick:()=>Lt(a.id),className:"p-1.5 rounded-lg hover:bg-red-500/10 text-gray-400 hover:text-red-400 transition-colors",title:"Delete",children:e.jsx(ue,{size:14})})]})})]},a.id)}),e.jsxs("div",{className:"bg-surface-2/50 px-4 py-2 border-t border-white/10 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] text-gray-500",children:[H.length," test case",H.length!==1?"s":""," on this page"]}),m.size>0&&e.jsxs("span",{className:"text-[11px] text-brand-300 font-medium",children:[m.size," selected"]})]})]}),re>1&&e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-t border-white/5",children:[e.jsxs("span",{className:"text-sm text-gray-400",children:["Showing ",(E-1)*Ce+1,"-",Math.min(E*Ce,ae)," of ",ae]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>F(a=>Math.max(1,a-1)),disabled:E<=1,className:"px-3 py-1.5 text-sm rounded-lg bg-surface-1 hover:bg-surface-2 text-gray-300 border border-white/10 disabled:opacity-40 transition-colors",children:"Previous"}),Array.from({length:Math.min(re,7)},(a,R)=>{let $;return re<=7||E<=4?$=R+1:E>=re-3?$=re-6+R:$=E-3+R,e.jsx("button",{onClick:()=>F($),className:`w-8 h-8 text-sm rounded-lg transition-colors ${E===$?"bg-brand-600 text-white":"hover:bg-surface-2 text-gray-400"}`,children:$},$)}),e.jsx("button",{onClick:()=>F(a=>Math.min(re,a+1)),disabled:E>=re,className:"px-3 py-1.5 text-sm rounded-lg bg-surface-1 hover:bg-surface-2 text-gray-300 border border-white/10 disabled:opacity-40 transition-colors",children:"Next"})]})]})]})]})]}),d&&Kt.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 overflow-y-auto",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>j(!1)}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Import and export test cases",className:"relative bg-surface-1 rounded-2xl border border-white/10 w-[1320px] max-w-[96vw] max-h-[92vh] flex flex-col animate-fade-in",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 py-4 border-b border-white/5 flex-shrink-0",children:[e.jsx(et,{size:18,className:"text-brand-300"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-100",children:"Import / Export"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Move test cases in from a file or another tool, or take this catalogue out."})]}),e.jsx("button",{onClick:()=>j(!1),className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors","aria-label":"Close",children:e.jsx(ee,{size:18})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:e.jsx(Zt,{embedded:!0})})]})]}),document.body),D&&e.jsx(ra,{testCase:U,folders:te||[],tags:ie||[],onClose:()=>{G(!1),A(null)},onSaved:()=>{y(U?"Test case updated successfully":"Test case created successfully")},currentUserName:g}),Ke&&e.jsx(da,{testCase:Ke,onClose:()=>P({tcId:null,detail:null}),onEdit:a=>{P({tcId:null,detail:null}),A(a),G(!0)},currentUserName:g,onToast:y}),se&&e.jsx(xa,{title:se.title,message:se.message,confirmLabel:se.confirmLabel,onConfirm:se.onConfirm,onCancel:()=>X(null)}),Y&&e.jsx(oa,{folders:te||[],count:m.size,onMove:_t,onClose:()=>n(!1)}),w&&e.jsx(ca,{tags:ie||[],count:m.size,onApply:Ft,onClose:()=>k(!1)})]})}function pa({testCaseId:t,onLinked:y}){const{connectorId:u,isConfigured:g,baseUrl:p}=gt(),b=Ls(),v=pt(),[h,d]=o.useState(!1),[j,f]=o.useState(""),[c,N]=o.useState([]);if(!g)return null;const i=()=>{if(!u||!j.trim())return;const T=/^[A-Z][A-Z0-9]+-\d+$/i.test(j.trim())?`key = "${j.trim()}"`:`summary ~ "${j.trim()}" ORDER BY updated DESC`;b.mutate({connectorId:u,jql:T,maxResults:10},{onSuccess:z=>N((z==null?void 0:z.issues)||[])})},r=x=>{var m;const T=x.key,z=((m=x.fields)==null?void 0:m.summary)||"";v.mutate({testCaseId:t,data:{title:`${T}: ${z}`,url:_s(p,T),linkType:"jira"}},{onSuccess:()=>{d(!1),f(""),N([]),y()}})};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>d(!h),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-blue-500/10 hover:bg-blue-500/20 text-blue-400 border border-blue-500/20 transition-colors",children:[e.jsx(Ae,{size:12})," Link JIRA"]}),h&&e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>d(!1)}),e.jsxs("div",{className:"relative z-10 bg-surface-1 rounded-xl border border-white/10 shadow-2xl w-full max-w-lg mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/5",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-100",children:"Link JIRA Issue"}),e.jsx("button",{onClick:()=>d(!1),className:"text-gray-400 hover:text-gray-200",children:e.jsx(ee,{size:16})})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:j,onChange:x=>f(x.target.value),onKeyDown:x=>x.key==="Enter"&&i(),placeholder:"Search by JIRA key or text...",className:"flex-1 bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500"}),e.jsx("button",{onClick:i,disabled:b.isPending,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-500 rounded-lg disabled:opacity-50",children:b.isPending?e.jsx(vt,{size:14,className:"animate-spin"}):e.jsx($e,{size:14})})]}),c.length>0&&e.jsx("div",{className:"max-h-[300px] overflow-y-auto divide-y divide-white/5 border border-white/5 rounded-lg",children:c.map(x=>{var T,z,m;return e.jsxs("button",{onClick:()=>r(x),className:"w-full text-left px-4 py-3 hover:bg-brand-500/10 transition-colors flex items-center gap-3",children:[e.jsx("span",{className:"text-xs font-mono text-blue-400 shrink-0",children:x.key}),e.jsx("span",{className:"text-sm text-gray-200 truncate flex-1",children:(T=x.fields)==null?void 0:T.summary}),e.jsx("span",{className:"text-[10px] text-gray-500 shrink-0",children:(m=(z=x.fields)==null?void 0:z.status)==null?void 0:m.name})]},x.key)})}),b.isSuccess&&c.length===0&&e.jsx("p",{className:"text-xs text-gray-500 text-center py-4",children:"No issues found"})]})]})]})]})}function ha({id:t,reason:y}){const u=Bs(),{toast:g}=ht(),[p,b]=o.useState(!1);return e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3",role:"status",children:[e.jsx(me,{size:16,className:"text-amber-300 shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-amber-200",children:"The requirement this case was written from changed"}),y?e.jsx("p",{className:"text-xs text-gray-300 mt-1 leading-relaxed break-words",children:y}):null,e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Update the case to match, then mark it reviewed — or regenerate the changed requirements in AI Test Gen."})]}),e.jsx("button",{disabled:p,onClick:async()=>{b(!0);try{await $s([t]),u.invalidateQueries({queryKey:["tm-test-cases"]}),u.invalidateQueries({queryKey:["tm-test-case",t]}),u.invalidateQueries({queryKey:["tm-sources"]})}catch(v){g("error",(v==null?void 0:v.message)||"Could not mark the case reviewed")}finally{b(!1)}},className:"shrink-0 px-3 py-1.5 text-xs rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-200 border border-white/10 disabled:opacity-50",children:"Mark reviewed"})]})}function ga({jiraUrl:t,testCaseTitle:y}){const{connectorId:u}=gt(),g=Is(),[p,b]=o.useState(!1);if(!u)return null;const v=t.match(/\/browse\/([A-Z][A-Z0-9]+-\d+)/i),h=v?v[1]:null;if(!h)return null;const d=()=>{const j=`🧪 Testver Test Case Update
|
|
5
|
+
|
|
6
|
+
Test Case: ${y}
|
|
7
|
+
Status: Linked in Testver
|
|
8
|
+
Date: ${Je(new Date)}
|
|
9
|
+
|
|
10
|
+
This test case is being tracked in Testver Test Management.`;g.mutate({connectorId:u,issueKey:h,comment:j},{onSuccess:()=>b(!0)})};return e.jsx("button",{onClick:d,disabled:g.isPending||p,className:`p-1.5 rounded-lg hover:bg-white/10 transition-colors ${p?"text-emerald-400":"text-gray-400 hover:text-blue-400"}`,title:p?"Comment posted to JIRA":"Post update to JIRA",children:g.isPending?e.jsx(vt,{size:14,className:"animate-spin"}):p?e.jsx(xe,{size:14}):e.jsx(Ys,{size:14})})}export{ua as SourceSingleSelectFilter,ma as TagMultiSelectFilter,$a as TestManagementPage};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{r,b as we,j as e,R as Rs}from"./vendor-react-CTbHBddL.js";import{f as Bt}from"./formatDate-T65-Y6Mi.js";import{u as et,a as Ps}from"./vendor-query-BrzmPFT3.js";import{u as Nt,a as Je,b as As}from"./useTabParam-ChbOedP1.js";import{b as tt,y as $s,x as Lt,a8 as st,gp as Ut,gq as Ms}from"./index-DtBWNlVD.js";import{C as Ot}from"./ConfirmDialog-DNU3qoAP.js";import{u as Ds}from"./useTestExplorer-HqvURJAc.js";import{u as Es,T as vt}from"./RunTargets-C7Vqd4TU.js";import{u as _s,a as Is,b as Fs,c as zs,d as Bs,e as Ls,f as Us,g as Os,h as qs,i as Hs,j as Ks,k as Qs,l as Vs,m as qt,n as Js,o as Xs,p as Gs,q as Ws,r as Ht,s as Ys,t as Zs,v as ea,w as ta,x as sa,y as aa,z as ra,A as la,B as na,C as ia,D as ca,E as oa,F as da,G as xa,H as ua,I as ma}from"./useTestManagement-ZTA1_VUm.js";import{t as ha,f as wt}from"./formatTestName-BKd2Uqhs.js";import{M as pa}from"./MobileRunPicker-BNs2lZFf.js";import{cl as Ye,X as Z,ba as ga,a0 as ba,by as fa,a3 as se,f as ya,b6 as de,v as at,a7 as Xe,t as ye,U as Ct,bQ as kt,Z as St,ax as ja,a2 as De,r as ve,_ as Kt,J as Tt,de as Rt,o as Qt,b3 as Vt,e as Ee,bc as Ze,b9 as _e,g as Ie,c as Ge,u as Pt,ar as At,R as Na,ap as va,av as wa,ce as Ca,df as ka,aa as Sa,b2 as Jt,bM as $t,a5 as Mt,F as Ta,a1 as Ra,ae as Pa,bk as Aa,be as $a,a9 as Ma}from"./vendor-icons-B0wLOBoh.js";import{R as Da}from"./MobileRunTarget-D2Nqcj10.js";import{u as Ea,a as _a}from"./useJiraConnector-TM1Rfj1s.js";import{TagMultiSelectFilter as Ia,SourceSingleSelectFilter as Fa}from"./TestManagementPage-Ch4PthuU.js";import{L as za}from"./LiveExecutionView-BD0wE8sz.js";import"./SearchableDevicePicker-CFJ_DUAA.js";import"./ImportExportPage-DXk7Koaq.js";import"./excel-BrxuVus5.js";import"./vendor-excel-BFHGVHVC.js";import"./aiHandoff-vhtR29Fh.js";import"./useDebouncedValue-BsHptIvX.js";import"./ExportButton-Ce_MxnM1.js";import"./JiraPushDialog-CqftoLh8.js";const Dt="w-full bg-surface-2 border border-white/10 rounded-lg px-3.5 py-2.5 text-sm text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50";function Et({on:s,onChange:a}){return e.jsx("button",{role:"switch","aria-checked":s,onClick:()=>a(!s),className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${s?"bg-brand-500":"bg-surface-3 border border-white/10"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform ${s?"translate-x-4":""}`})})}function _t({title:s,icon:a,children:l}){return e.jsxs("section",{className:"bg-surface-1 border border-white/5 rounded-xl p-5",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-200 flex items-center gap-2.5 mb-1",children:[e.jsx("span",{className:"text-brand-400 flex-shrink-0",children:a}),s]}),e.jsx("div",{className:"divide-y divide-white/5",children:l})]})}function G({label:s,desc:a,children:l,alignTop:h}){return e.jsxs("div",{className:`flex flex-col md:flex-row gap-1.5 md:gap-6 py-3.5 ${h?"md:items-start":"md:items-center"}`,children:[e.jsxs("div",{className:"md:w-52 flex-shrink-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-200",children:s}),a&&e.jsx("div",{className:"text-[13px] text-gray-500 mt-0.5 leading-snug",children:a})]}),e.jsx("div",{className:"flex-1 min-w-0",children:l})]})}function It({value:s,onChange:a}){const{data:l}=Ds(),[h,c]=r.useState(!1),[C,u]=r.useState(!1),[g,p]=r.useState(""),f=r.useRef(null),y=()=>{c(x=>{if(!x&&f.current){const o=window.innerHeight-f.current.getBoundingClientRect().bottom;u(o<320)}return!x}),p("")},j=r.useMemo(()=>{const x=[];for(const o of(l==null?void 0:l.suites)||[])for(const w of o.tests)x.push({file:o.file,name:w.name,command:w.runCommand||"",suiteName:o.name});return x},[l]),N=g.trim()?j.filter(x=>ha(x.name,g)||`${x.suiteName} ${x.file}`.toLowerCase().includes(g.trim().toLowerCase())):j,A=!!(s!=null&&s.testName);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{ref:f,className:"flex items-center gap-2 bg-surface-2 border border-white/10 rounded-lg pl-2 pr-1.5 py-1 min-h-[40px] focus-within:border-brand-500/50",children:[e.jsx("div",{className:"flex-1 min-w-0 flex items-center",children:A?e.jsxs("span",{className:"flex items-center gap-1.5 bg-surface-3 border border-white/15 rounded-md pl-2 pr-1 py-1 text-xs text-gray-100 min-w-0 max-w-full shadow-sm",children:[e.jsx(ya,{size:9,className:"text-cyan-400 fill-current flex-shrink-0"}),e.jsx("span",{className:"truncate font-medium",title:s.testName,children:wt(s.testName)}),e.jsx("button",{onClick:()=>a(null),title:"Remove test",className:"text-gray-500 hover:text-red-400 flex-shrink-0",children:e.jsx(Z,{size:13})})]}):e.jsx("input",{value:(s==null?void 0:s.command)||"",onChange:x=>a(x.target.value.trim()?{command:x.target.value}:null),placeholder:"Type a command… or pick a test →",className:"w-full bg-transparent text-xs text-gray-200 outline-none font-mono placeholder-gray-600"})}),e.jsxs("button",{onClick:y,title:"Pick a project test",className:"text-[11px] font-medium text-gray-400 hover:text-gray-100 inline-flex items-center gap-1 flex-shrink-0 border border-white/10 rounded-md px-2 py-1 hover:bg-surface-3",children:[e.jsx(de,{size:12})," test"]})]}),h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>c(!1)}),e.jsxs("div",{className:`absolute right-0 z-50 w-80 rounded-xl bg-surface-1 border border-white/10 shadow-2xl p-2 ${C?"bottom-full mb-1":"top-full mt-1"}`,children:[e.jsxs("div",{className:"relative mb-1.5",children:[e.jsx(at,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:g,onChange:x=>p(x.target.value),placeholder:"Search all project tests…",autoFocus:!0,className:"w-full bg-surface-2 border border-white/10 rounded-lg pl-8 pr-2 py-1.5 text-sm text-gray-200 outline-none placeholder-gray-600"})]}),e.jsx("div",{className:"max-h-64 overflow-auto",children:N.length===0?e.jsx("div",{className:"text-xs text-gray-600 py-6 text-center",children:j.length===0?"No tests found in this project.":`No tests match “${g}”.`}):N.slice(0,200).map((x,o)=>e.jsxs("button",{onClick:()=>{a({command:x.command,testName:x.name,file:x.file}),c(!1)},className:"w-full text-left px-2.5 py-1.5 rounded-lg hover:bg-surface-2/60",children:[e.jsx("div",{className:"text-sm text-gray-200 truncate",title:x.name,children:wt(x.name)}),e.jsxs("div",{className:"text-[11px] text-gray-500 truncate",children:[x.suiteName," · ",x.file.split(/[/\\]/).pop()||x.file]})]},`${x.file}::${x.name}::${o}`))})]})]})]})}function Ba({onClose:s}){const{data:a}=_s(),l=Is(),{toast:h}=tt(),{data:c}=et({queryKey:["cloud-providers"],queryFn:$s,staleTime:3e4}),C=((c==null?void 0:c.providers)||[]).filter(F=>F.enabled),u=Lt().mode==="mobile",[g,p]=r.useState(null),[f,y]=r.useState("local"),[j,N]=r.useState(""),[A,x]=r.useState(1),[o,w]=r.useState(0),[I,R]=r.useState(!1),[H,$]=r.useState(""),[Q,V]=r.useState(""),[k,ee]=r.useState(""),[D,B]=r.useState(null),[q,J]=r.useState(null),[U,ae]=r.useState(!0),{browserOpts:re,envOpts:n}=Es(),m=r.useRef(!1);r.useEffect(()=>{!a||m.current||(m.current=!0,y(a.target==="cloud"?"cloud":"local"),N(a.cloudProvider||""),x(a.concurrency||1),w(a.retries||0),R(!!a.headless),$(a.extraArgs||""),V(a.browser||""),ee(a.environment||""),B(a.beforeRun||null),J(a.afterRun||null),ae(a.abortOnSetupFailure??!0))},[a]);const M=()=>{var F;if(u){const _=g==null?void 0:g.payload;return{target:"cloud",cloudProvider:(_==null?void 0:_.cloudProvider)||(a==null?void 0:a.cloudProvider),deviceName:(_==null?void 0:_.deviceName)||void 0,platformName:(_==null?void 0:_.platformName)||void 0,platformVersion:(_==null?void 0:_.platformVersion)||void 0,appId:(_==null?void 0:_.appId)||void 0,appPath:((F=_==null?void 0:_.appPath)==null?void 0:F.trim())||void 0,concurrency:A,retries:o,extraArgs:H.trim()||void 0,environment:k||void 0,beforeRun:D||void 0,afterRun:q||void 0,abortOnSetupFailure:U}}return{target:f,cloudProvider:f==="cloud"&&j||void 0,concurrency:A,retries:o,headless:I,extraArgs:H.trim()||void 0,browser:Q||void 0,environment:k||void 0,beforeRun:D||void 0,afterRun:q||void 0,abortOnSetupFailure:U}},L=()=>{l.mutate(M(),{onSuccess:()=>{h("success","Run settings saved"),s()},onError:()=>h("error","Failed to save run settings")})};return we.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:s}),e.jsxs("div",{className:"relative bg-surface-0 border border-white/10 rounded-2xl shadow-2xl w-full max-w-2xl max-h-[88vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/5",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(Ye,{size:16,className:"text-brand-400"})," Automation Run Settings"]}),e.jsx("p",{className:"text-[13px] text-gray-500 mt-0.5",children:"Applied to all cycles in this project."})]}),e.jsx("button",{onClick:s,className:"text-gray-500 hover:text-gray-200 p-1 rounded-lg hover:bg-surface-2",children:e.jsx(Z,{size:18})})]}),e.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4 space-y-4",children:[e.jsxs(_t,{title:"Run options",icon:e.jsx(Ye,{size:15}),children:[u?!!a&&e.jsx(G,{label:"Device & App",desc:"Runs dispatch through the mobile cloud-bridge with this device + app.",children:e.jsx(pa,{compact:!0,initial:{cloudProvider:a==null?void 0:a.cloudProvider,deviceName:a==null?void 0:a.deviceName,platformName:a==null?void 0:a.platformName,platformVersion:a==null?void 0:a.platformVersion,appId:a==null?void 0:a.appId,appPath:a==null?void 0:a.appPath},onChange:p})}):e.jsxs(e.Fragment,{children:[e.jsx(G,{label:"Where",desc:"Run locally or on a cloud device grid.",children:e.jsxs("div",{className:"flex rounded-lg border border-white/10 overflow-hidden max-w-xs",children:[e.jsxs("button",{onClick:()=>y("local"),className:`flex-1 px-2 py-2 text-xs inline-flex items-center justify-center gap-1.5 ${f==="local"?"bg-brand-500/15 text-brand-300":"text-gray-400"}`,children:[e.jsx(ga,{size:12})," Local"]}),e.jsxs("button",{onClick:()=>y("cloud"),className:`flex-1 px-2 py-2 text-xs inline-flex items-center justify-center gap-1.5 border-l border-white/10 ${f==="cloud"?"bg-cyan-500/15 text-cyan-300":"text-gray-400"}`,children:[e.jsx(ba,{size:12})," Cloud"]})]})}),f==="cloud"&&e.jsx(G,{label:"Provider",children:e.jsxs("select",{value:j,onChange:F=>N(F.target.value),className:`${Dt} max-w-xs`,children:[e.jsx("option",{value:"",children:"Select…"}),C.map(F=>e.jsx("option",{value:F.id,children:F.id.charAt(0).toUpperCase()+F.id.slice(1)},F.id))]})})]}),e.jsx(G,{label:"Concurrency",desc:"How many tests run at once during “Run All”. Single runs ignore this.",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"range",min:1,max:8,value:A,onChange:F=>x(Number(F.target.value)),className:"flex-1 accent-brand-500"}),e.jsxs("span",{className:"text-sm text-gray-300 tabular-nums w-20 text-right",children:[A," at a time"]})]})}),e.jsx(G,{label:"Auto-retry failed",desc:"Re-runs a failed test immediately. Timeouts are not retried.",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"range",min:0,max:3,value:o,onChange:F=>w(Number(F.target.value)),className:"flex-1 accent-brand-500"}),e.jsx("span",{className:"text-sm text-gray-300 tabular-nums w-20 text-right",children:o===0?"off":`${o}×`})]})}),!u&&e.jsx(G,{label:"Headless",desc:"Hide the browser window during the run.",children:e.jsx(Et,{on:I,onChange:R})}),re.length>0&&e.jsx(G,{label:"Browser",desc:"Chosen browser is added as a CLI arg (from the global Run Commands list).",children:e.jsx("div",{className:"max-w-xs",children:e.jsx(vt,{isEnv:!1,value:Q,onChange:V,options:re})})}),n.length>0&&e.jsx(G,{label:"Environment",desc:"Chosen environment is applied as a CLI arg or env var (per the global list).",children:e.jsx("div",{className:"max-w-xs",children:e.jsx(vt,{isEnv:!0,value:k,onChange:ee,options:n})})}),e.jsxs(G,{label:"Extra CLI args",alignTop:!0,desc:"Appended to every test's command — pass a base URL, browser, or any flag.",children:[e.jsx("input",{value:H,onChange:F=>$(F.target.value),placeholder:"-DbaseUrl=https://staging.example.com -Dbrowser=firefox",className:`${Dt} font-mono text-xs`}),e.jsxs("p",{className:"text-[11px] text-gray-600 mt-1.5",children:[e.jsx("span",{className:"text-gray-500",children:"Maven/TestNG"})," ",e.jsx("span",{className:"font-mono",children:"-DbaseUrl=… -Dbrowser=firefox"})," · ",e.jsx("span",{className:"text-gray-500",children:"pytest"})," ",e.jsx("span",{className:"font-mono",children:"--base-url=…"})," · ",e.jsx("span",{className:"text-gray-500",children:"Playwright"})," ",e.jsx("span",{className:"font-mono",children:"--workers=1"})]})]})]}),e.jsxs(_t,{title:"Setup & teardown (Run All)",icon:e.jsx(fa,{size:15}),children:[e.jsx(G,{label:"Before run",desc:"Runs once before the cycle — only for “Run All”.",alignTop:!0,children:e.jsx(It,{value:D,onChange:B})}),e.jsx(G,{label:"After run",desc:"Runs last — even if tests fail.",alignTop:!0,children:e.jsx(It,{value:q,onChange:J})}),e.jsx(G,{label:"Abort on setup failure",desc:"Skip the tests if the before-run hook fails.",children:e.jsx(Et,{on:U,onChange:ae})})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-5 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:s,className:"px-4 py-2 text-sm rounded-lg text-gray-300 border border-white/10 hover:bg-surface-2",children:"Cancel"}),e.jsxs("button",{onClick:L,disabled:l.isPending,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-lg text-brand-200 bg-brand-500/20 border border-brand-500/40 hover:bg-brand-500/30 disabled:opacity-50",children:[l.isPending?e.jsx(se,{size:14,className:"animate-spin"}):null," Save"]})]})]})]}),document.body)}const Xt=["draft","active","completed","archived"],Ft=["not_run","in_progress","passed","failed","blocked","skipped"],Me={draft:"bg-gray-500/20 text-gray-300",active:"bg-blue-500/20 text-blue-300",completed:"bg-emerald-500/20 text-emerald-300",archived:"bg-slate-500/20 text-slate-400"},We={passed:"bg-emerald-500/20 text-emerald-300",failed:"bg-red-500/20 text-red-300",blocked:"bg-orange-500/20 text-orange-300",skipped:"bg-gray-500/20 text-gray-300",not_run:"bg-slate-500/20 text-slate-400",in_progress:"bg-blue-500/20 text-blue-300"},La={passed:"bg-emerald-500",failed:"bg-red-500",blocked:"bg-orange-500",skipped:"bg-gray-500",not_run:"bg-slate-600",in_progress:"bg-blue-500"},Ua={passed:"bg-emerald-500/5",failed:"bg-red-500/5",blocked:"bg-orange-500/5",skipped:"bg-gray-500/5",not_run:""},Fe={critical:"bg-red-500/20 text-red-300",high:"bg-orange-500/20 text-orange-300",medium:"bg-amber-500/20 text-amber-300",low:"bg-emerald-500/20 text-emerald-300"},rt={functional:"bg-sky-500/20 text-sky-300",regression:"bg-violet-500/20 text-violet-300",smoke:"bg-amber-500/20 text-amber-300",integration:"bg-teal-500/20 text-teal-300",e2e:"bg-indigo-500/20 text-indigo-300",api:"bg-cyan-500/20 text-cyan-300",performance:"bg-rose-500/20 text-rose-300",security:"bg-red-500/20 text-red-300"};function z(s){return s.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function Oa(s){return s?new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—"}function qa({executions:s}){const a=r.useMemo(()=>{const h={passed:0,failed:0,blocked:0,skipped:0,not_run:0,in_progress:0};return s.forEach(c=>{h[c.status]=(h[c.status]||0)+1}),h},[s]),l=s.length||1;return e.jsx("div",{className:"w-full h-2 rounded-full bg-surface-2 overflow-hidden flex",children:["passed","failed","blocked","in_progress","skipped","not_run"].map(h=>{const c=a[h]/l*100;return c===0?null:e.jsx("div",{className:`${La[h]} h-full`,style:{width:`${c}%`}},h)})})}function Ha({cycleId:s}){const{data:a}=sa(s);if(!a)return null;const l=a,h=l.passRate??(l.executedCount>0?Math.round(l.passedCount/l.executedCount*100):0),c=l.completionRate??(l.totalCount>0?Math.round((l.totalCount-(l.notRunCount??0))/l.totalCount*100):0),C=l.failedCount??l.failed??0,u=l.totalDuration??0,g=p=>{if(!p||p<=0)return"0s";const f=Math.floor(p/3600),y=Math.floor(p%3600/60),j=p%60;return f>0?`${f}h ${y}m ${j}s`:y>0?`${y}m ${j}s`:`${j}s`};return e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-4",children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 text-center",children:[e.jsx(wa,{className:"w-5 h-5 text-brand-400 mx-auto mb-1"}),e.jsx("div",{className:"text-2xl font-bold text-gray-200",children:g(u)}),e.jsx("div",{className:"text-xs text-gray-400",children:"Total Duration"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 text-center",children:[e.jsx(Ca,{className:"w-5 h-5 text-emerald-400 mx-auto mb-1"}),e.jsxs("div",{className:"text-2xl font-bold text-emerald-300",children:[h,"%"]}),e.jsx("div",{className:"text-xs text-gray-400",children:"Pass Rate"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 text-center",children:[e.jsx(ka,{className:"w-5 h-5 text-blue-400 mx-auto mb-1"}),e.jsxs("div",{className:"text-2xl font-bold text-blue-300",children:[c,"%"]}),e.jsx("div",{className:"text-xs text-gray-400",children:"Completion"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 text-center",children:[e.jsx(De,{className:"w-5 h-5 text-red-400 mx-auto mb-1"}),e.jsx("div",{className:"text-2xl font-bold text-red-300",children:C}),e.jsx("div",{className:"text-xs text-gray-400",children:"Failed"})]})]})}function zt({onClose:s,editingPlan:a}){const[l,h]=r.useState((a==null?void 0:a.name)??""),[c,C]=r.useState((a==null?void 0:a.description)??""),[u,g]=r.useState((a==null?void 0:a.release)??""),[p,f]=r.useState((a==null?void 0:a.sprint)??""),[y,j]=r.useState((a==null?void 0:a.status)??"draft"),N=aa(),A=ra(),x=()=>{if(!l.trim())return;const o={name:l.trim(),description:c.trim(),release:u.trim(),sprint:p.trim(),status:y};a?A.mutate({id:a.id,data:o},{onSuccess:s}):N.mutate(o,{onSuccess:s})};return we.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:s,children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-xl w-full max-w-lg p-6 shadow-2xl",onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:a?"Edit Plan":"New Test Plan"}),e.jsx("button",{onClick:s,className:"text-gray-400 hover:text-gray-200",children:e.jsx(Z,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Plan Name *"}),e.jsx("input",{value:l,onChange:o=>h(o.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50",placeholder:"e.g. Release 2.5 Regression"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Description"}),e.jsx("textarea",{value:c,onChange:o=>C(o.target.value),rows:3,className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50 resize-none",placeholder:"Brief description..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Release"}),e.jsx("input",{value:u,onChange:o=>g(o.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50",placeholder:"e.g. v2.5"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Sprint"}),e.jsx("input",{value:p,onChange:o=>f(o.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50",placeholder:"e.g. Sprint 14"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Status"}),e.jsx("select",{value:y,onChange:o=>j(o.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 focus:outline-none focus:border-brand-500/50",children:Xt.map(o=>e.jsx("option",{value:o,children:z(o)},o))})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx("button",{onClick:s,className:"bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-4 py-2 text-sm",children:"Cancel"}),e.jsxs("button",{onClick:x,disabled:!l.trim()||N.isPending||A.isPending,className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm disabled:opacity-50 flex items-center gap-2",children:[e.jsx(Jt,{className:"w-4 h-4"}),a?"Update Plan":"Create Plan"]})]})]})}),document.body)}function Ka({planId:s,onClose:a,editingCycle:l}){const[h,c]=r.useState((l==null?void 0:l.name)??""),[C,u]=r.useState((l==null?void 0:l.assignedTo)??""),[g,p]=r.useState(l!=null&&l.startDate?new Date(l.startDate).toISOString().split("T")[0]:""),[f,y]=r.useState(l!=null&&l.endDate?new Date(l.endDate).toISOString().split("T")[0]:""),j=la(),N=na(),A=()=>{if(!h.trim())return;const x={name:h.trim(),assignedTo:C.trim()||void 0};g&&(x.startDate=new Date(g).getTime()),f&&(x.endDate=new Date(f).getTime()),l?N.mutate({id:l.id,data:x},{onSuccess:a}):j.mutate({planId:s,data:x},{onSuccess:a})};return we.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:a,children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-xl w-full max-w-md p-6 shadow-2xl",onClick:x=>x.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:l?"Edit Cycle":"New Test Cycle"}),e.jsx("button",{onClick:a,className:"text-gray-400 hover:text-gray-200",children:e.jsx(Z,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Cycle Name *"}),e.jsx("input",{value:h,onChange:x=>c(x.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50",placeholder:"e.g. Cycle 1 - Smoke Tests"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Assigned To"}),e.jsx("input",{value:C,onChange:x=>u(x.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50",placeholder:"e.g. john@example.com"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Start Date"}),e.jsx("input",{type:"date",value:g,onChange:x=>p(x.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 focus:outline-none focus:border-brand-500/50 text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"End Date"}),e.jsx("input",{type:"date",value:f,onChange:x=>y(x.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 focus:outline-none focus:border-brand-500/50 text-sm"})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx("button",{onClick:a,className:"bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-4 py-2 text-sm",children:"Cancel"}),e.jsxs("button",{onClick:A,disabled:!h.trim()||j.isPending||N.isPending,className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm disabled:opacity-50 flex items-center gap-2",children:[e.jsx(Jt,{className:"w-4 h-4"}),l?"Update Cycle":"Create Cycle"]})]})]})}),document.body)}function Qa({planId:s,existingTestCaseIds:a,onClose:l}){const h=ia(),[c,C]=r.useState(new Set),[u,g]=r.useState(""),[p,f]=r.useState(""),[y,j]=r.useState(""),[N,A]=r.useState(""),[x,o]=r.useState(""),[w,I]=r.useState(new Set),[R,H]=r.useState(null),{data:$}=ca(),Q=(Array.isArray($)?$:$==null?void 0:$.tags)??[],{data:V}=oa(),k=(V==null?void 0:V.sources)??[],ee=r.useMemo(()=>{const n={limit:500};return u.trim()&&(n.search=u.trim()),p&&(n.priority=p),y&&(n.type=y),N&&(n.status=N),x&&(n.automationStatus=x),w.size>0&&(n.tagIds=Array.from(w)),R&&(n.sourceId=R),n},[u,p,y,N,x,w,R]),{data:D}=da(ee),B=r.useMemo(()=>{const n=Array.isArray(D)?D:(D==null?void 0:D.testCases)??(D==null?void 0:D.data)??[],m=new Set(a);return n.filter(M=>!m.has(M.id))},[D,a]),q=(p?1:0)+(y?1:0)+(N?1:0)+(x?1:0)+(w.size>0?1:0)+(R?1:0),J=()=>{f(""),j(""),A(""),o(""),I(new Set),H(null)},U=n=>{C(m=>{const M=new Set(m);return M.has(n)?M.delete(n):M.add(n),M})},ae=()=>{c.size===B.length?C(new Set):C(new Set(B.map(n=>n.id)))},re=()=>{c.size!==0&&h.mutate({planId:s,testCaseIds:Array.from(c)},{onSuccess:l})};return we.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:l,children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-xl w-full max-w-4xl p-6 shadow-2xl h-[85vh] flex flex-col",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Add Test Cases to Plan"}),e.jsx("button",{onClick:l,className:"text-gray-400 hover:text-gray-200",children:e.jsx(Z,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx(at,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),e.jsx("input",{value:u,onChange:n=>g(n.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg pl-10 pr-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50 text-sm",placeholder:"Search test cases..."})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-2.5 py-1.5 text-xs text-gray-300 outline-none focus:border-brand-500",value:p,onChange:n=>f(n.target.value),title:"Priority",children:[e.jsx("option",{value:"",children:"Priority"}),e.jsx("option",{value:"critical",children:"Critical"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"low",children:"Low"})]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-2.5 py-1.5 text-xs text-gray-300 outline-none focus:border-brand-500",value:y,onChange:n=>j(n.target.value),title:"Type",children:[e.jsx("option",{value:"",children:"Type"}),["web","ui","api","mobile","database","integration","e2e","security","performance","usability","accessibility","compatibility","localization"].map(n=>e.jsx("option",{value:n,children:n==="api"?"API":n==="ui"?"UI":n==="e2e"?"E2E":z(n)},n))]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-2.5 py-1.5 text-xs text-gray-300 outline-none focus:border-brand-500",value:N,onChange:n=>A(n.target.value),title:"Status",children:[e.jsx("option",{value:"",children:"Status"}),["draft","active","deprecated","archived"].map(n=>e.jsx("option",{value:n,children:z(n)},n))]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-2.5 py-1.5 text-xs text-gray-300 outline-none focus:border-brand-500",value:x,onChange:n=>o(n.target.value),title:"Automation",children:[e.jsx("option",{value:"",children:"Automation"}),e.jsx("option",{value:"manual",children:"Manual"}),e.jsx("option",{value:"automated",children:"Automated"}),e.jsx("option",{value:"needs_update",children:"Needs Update"})]}),e.jsx(Ia,{tags:Q,selectedIds:w,onChange:I}),e.jsx(Fa,{sources:k,selectedId:R,onChange:H}),q>0&&e.jsxs("button",{onClick:J,className:"flex items-center gap-1 px-2 py-1 text-xs text-gray-400 hover:text-gray-200 transition-colors",children:[e.jsx(Z,{className:"w-3 h-3"}),"Clear (",q,")"]})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3 text-sm text-gray-400",children:[e.jsxs("button",{onClick:ae,className:"flex items-center gap-1.5 hover:text-gray-200",children:[c.size===B.length&&B.length>0?e.jsx($t,{className:"w-4 h-4 text-brand-400"}):e.jsx(Mt,{className:"w-4 h-4"}),"Select All"]}),e.jsxs("span",{className:"ml-auto",children:[c.size," selected"]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 min-h-0",children:[B.length===0&&e.jsx("div",{className:"text-center text-gray-500 py-8",children:"No test cases available to add."}),B.map(n=>{var m,M;return e.jsxs("button",{onClick:()=>U(n.id),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-left hover:bg-surface-2 transition-colors ${c.has(n.id)?"bg-brand-500/10 border border-brand-500/20":"border border-transparent"}`,children:[c.has(n.id)?e.jsx($t,{className:"w-4 h-4 text-brand-400 shrink-0"}):e.jsx(Mt,{className:"w-4 h-4 text-gray-500 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.id&&e.jsx("span",{title:"Test Case ID",className:"text-[11px] font-mono text-brand-300 flex-shrink-0",children:n.id}),e.jsx("span",{title:n.title,className:"text-sm text-gray-200 truncate",children:n.title})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[(((m=n.folder)==null?void 0:m.name)||n.folderName)&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-surface-2 text-gray-400 border border-white/5 flex items-center gap-1",children:[e.jsx(Ta,{className:"w-2.5 h-2.5"})," ",((M=n.folder)==null?void 0:M.name)||n.folderName]}),n.status&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${n.status==="active"?"bg-emerald-500/15 text-emerald-300":n.status==="draft"?"bg-sky-500/15 text-sky-300":"bg-gray-500/15 text-gray-400"}`,children:z(n.status)}),n.priority&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${Fe[n.priority]??"bg-gray-500/20 text-gray-400"}`,children:z(n.priority)}),n.type&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${rt[n.type]??"bg-gray-500/20 text-gray-400"}`,children:z(n.type)})]})]})]},n.id)})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-4 pt-4 border-t border-white/5",children:[e.jsx("button",{onClick:l,className:"bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-4 py-2 text-sm",children:"Cancel"}),e.jsxs("button",{onClick:re,disabled:c.size===0||h.isPending,className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm disabled:opacity-50 flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4"}),"Add ",c.size," Test Case",c.size!==1?"s":""]})]})]})}),document.body)}function Va({plan:s,onSelect:a,onEdit:l,onDelete:h}){const c=s.testCaseCount??s.test_case_count??0,C=s.executedCount??s.executed_count??0,u=s.passedCount??s.passed_count??0,g=s.failedCount??s.failed_count??0,p=c>0?Math.round(C/c*100):0,f=c>0?u/c*100:0,y=c>0?g/c*100:0,j=c>0?(C-u-g)/c*100:0;return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 hover:border-white/10 transition-colors group flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsx("button",{onClick:a,className:"text-left flex-1 min-w-0",children:e.jsx("h3",{title:s.name,className:`text-sm font-semibold transition-colors truncate\r
|
|
2
|
+
text-gray-900 group-hover:text-brand-700\r
|
|
3
|
+
dark:text-gray-100 dark:group-hover:text-brand-300`,children:s.name})}),e.jsxs("div",{className:"flex items-center gap-1 ml-2 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:l,className:"p-1 text-gray-500 hover:text-gray-300 rounded",title:"Edit",children:e.jsx(Ze,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:h,className:"p-1 text-gray-500 hover:text-red-400 rounded",title:"Delete",children:e.jsx(_e,{className:"w-3.5 h-3.5"})})]})]}),s.description&&e.jsx("p",{className:"text-xs text-gray-400 mb-3 line-clamp-2",children:s.description}),e.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[s.id&&e.jsx("span",{title:"Test Plan ID",className:"text-xs font-mono px-2 py-0.5 rounded bg-surface-2 text-brand-300 border border-white/5",children:s.id}),s.release&&e.jsx("span",{title:"Release",className:"text-xs px-2 py-0.5 rounded bg-brand-500/15 text-brand-300",children:s.release}),s.sprint&&e.jsx("span",{title:"Sprint",className:"text-xs px-2 py-0.5 rounded bg-indigo-500/15 text-indigo-300",children:s.sprint}),e.jsx("span",{title:"Plan Status",className:`text-xs px-2 py-0.5 rounded ${Me[s.status]??"bg-gray-500/20 text-gray-400"}`,children:z(s.status??"draft")})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-400 mb-1",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ie,{className:"w-3.5 h-3.5"})," ",c," test cases"]}),e.jsxs("span",{children:[C,"/",c," executed (",p,"%)"]})]}),e.jsxs("div",{className:"w-full h-2 rounded-full bg-surface-2 overflow-hidden mb-1 flex",children:[f>0&&e.jsx("div",{className:"bg-emerald-500 h-full transition-all",style:{width:`${f}%`}}),y>0&&e.jsx("div",{className:"bg-red-500 h-full transition-all",style:{width:`${y}%`}}),j>0&&e.jsx("div",{className:"bg-amber-500 h-full transition-all",style:{width:`${j}%`}})]}),C>0&&e.jsxs("div",{className:"flex items-center gap-3 text-xs mb-1",children:[u>0&&e.jsxs("span",{className:"text-emerald-400",children:[u," passed"]}),g>0&&e.jsxs("span",{className:"text-red-400",children:[g," failed"]}),c-C>0&&e.jsxs("span",{className:"text-gray-500",children:[c-C," remaining"]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-auto pt-3",children:[e.jsxs("div",{className:"text-xs text-gray-500 flex items-center gap-1",children:[e.jsx(Ra,{className:"w-3 h-3"}),Oa(s.createdAt??s.created_at)]}),e.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-3 py-1.5 text-xs font-medium transition-colors",children:[e.jsx(Pa,{className:"w-3.5 h-3.5"})," Open Plan"]})]})]})}const Ja=s=>s?s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`:"0 B";function Xa({executionId:s}){const{toast:a}=tt(),{user:l}=st(),h=(l==null?void 0:l.displayName)||(l==null?void 0:l.username)||"",{data:c,isLoading:C}=xa(s),u=ua(),g=ma(),p=r.useRef(null),[f,y]=r.useState(null),j=(c==null?void 0:c.attachments)??[],N=25*1024*1024,A=async o=>{if(!(!o||o.length===0)){for(const w of Array.from(o)){if(w.size>N){a("error",`"${w.name}" exceeds the 25 MB limit and was skipped.`);continue}const I=await new Promise((R,H)=>{const $=new FileReader;$.onload=()=>R(($.result||"").split(",")[1]||""),$.onerror=()=>H($.error),$.readAsDataURL(w)});await u.mutateAsync({executionId:s,data:{fileName:w.name,fileType:w.type,fileSize:w.size,fileData:I,uploadedBy:h}})}p.current&&(p.current.value="")}},x=async o=>{try{const w=await Ms(o.id),I=document.createElement("a");I.href=`data:${o.fileType||"application/octet-stream"};base64,${w.fileData}`,I.download=o.fileName,document.body.appendChild(I),I.click(),document.body.removeChild(I)}catch{a("error","Could not download attachment.")}};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Aa,{className:"w-4 h-4 text-gray-400"}),e.jsx("h3",{className:"text-sm font-medium text-gray-200",children:"Evidence"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[j.length," file",j.length===1?"":"s"]})]}),e.jsxs("label",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-brand-600 hover:bg-brand-500 text-white cursor-pointer transition-colors",children:[u.isPending?e.jsx(se,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx($a,{className:"w-3.5 h-3.5"}),"Attach Files",e.jsx("input",{ref:p,type:"file",multiple:!0,className:"hidden",onChange:o=>A(o.target.files),disabled:u.isPending})]})]}),C?e.jsx("div",{className:"text-xs text-gray-500 py-2",children:"Loading…"}):j.length===0?e.jsxs("div",{className:"text-xs text-gray-500 py-3 text-center border border-dashed border-white/10 rounded-lg",children:["No evidence attached. Use ",e.jsx("span",{className:"text-brand-400",children:"Attach Files"})," to add screenshots, logs, or exports for this run."]}):e.jsx("ul",{className:"space-y-1.5",children:j.map(o=>e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2 bg-surface-2 rounded-lg border border-white/5",children:[e.jsx(Ie,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-gray-200 truncate",children:o.fileName}),e.jsxs("div",{className:"text-[11px] text-gray-500",children:[Ja(o.fileSize),o.uploadedBy?` · ${o.uploadedBy}`:"",o.createdAt?` · ${Bt(o.createdAt)}`:""]})]}),e.jsx("button",{type:"button",onClick:()=>x(o),className:"p-1.5 rounded hover:bg-white/10 text-gray-400 hover:text-gray-200",title:"Download",children:e.jsx(Ma,{className:"w-3.5 h-3.5"})}),e.jsx("button",{type:"button",onClick:()=>y({id:o.id,name:o.fileName}),className:"p-1.5 rounded hover:bg-red-500/10 text-gray-400 hover:text-red-400",title:"Delete",children:e.jsx(_e,{className:"w-3.5 h-3.5"})})]},o.id))}),e.jsx(Ot,{open:!!f,title:"Remove evidence?",description:f?`Delete "${f.name}" from this execution? This cannot be undone.`:"",confirmLabel:"Delete",onCancel:()=>y(null),onConfirm:()=>{f&&(g.mutate({id:f.id,executionId:s}),y(null))}})]})}function Ga({executionId:s,onBack:a,breadcrumbPlanName:l,breadcrumbCycleName:h,onNavigateToPlan:c,onNavigateToCycle:C}){var n;const{user:u}=st(),g=(u==null?void 0:u.displayName)||(u==null?void 0:u.username)||"Unknown",{data:p,isLoading:f}=Zs(s),y=ea(),j=ta(),N=r.useMemo(()=>(Array.isArray(p)?p:(p==null?void 0:p.steps)??(p==null?void 0:p.data)??[]).sort((M,L)=>(M.stepNumber??M.step_number??0)-(L.stepNumber??L.step_number??0)),[p]);qt();const A=Ht(),[x,o]=r.useState(!1),{data:w,refetch:I}=et({queryKey:["exec-defects",s],queryFn:()=>Ut([s])}),R=((n=w==null?void 0:w.defects)==null?void 0:n[s])||null,H=N.filter(m=>m.status==="passed").length,$=N.filter(m=>m.status==="failed").length,Q=N.length,V=()=>{A.mutate({executionId:s,createdBy:g},{onSuccess:()=>I()})},k=p==null?void 0:p.execution,ee=(k==null?void 0:k.testCaseTitle)??"Test Case",D=k==null?void 0:k.testCasePriority,B=k==null?void 0:k.testCaseType,q=k==null?void 0:k.testCasePreconditions;k==null||k.scriptMapping;const J=(m,M)=>{y.mutate({id:m.id,data:{status:M,executedBy:g}})},U=(m,M)=>{y.mutate({id:m.id,data:{actualResult:M,executedBy:g}})},ae=(m,M)=>{y.mutate({id:m.id,data:{comment:M,executedBy:g}})},re=()=>{j.mutate({executionId:s,status:"passed",executedBy:g})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[e.jsx("button",{onClick:()=>{c()},className:"hover:text-gray-100 transition-colors",children:"Test Plans"}),e.jsx(ye,{className:"w-4 h-4"}),e.jsx("button",{onClick:c,className:"hover:text-gray-100 transition-colors truncate max-w-[150px]",children:l}),e.jsx(ye,{className:"w-4 h-4"}),e.jsx("button",{onClick:C,className:"hover:text-gray-100 transition-colors truncate max-w-[150px]",children:h}),e.jsx(ye,{className:"w-4 h-4"}),e.jsx("span",{className:"text-gray-200 truncate max-w-[200px]",children:ee})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200 mb-2",children:ee}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[D&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Fe[D]??"bg-gray-500/20 text-gray-400"}`,children:z(D)}),B&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${rt[B]??"bg-gray-500/20 text-gray-400"}`,children:z(B)})]}),q&&e.jsxs("div",{className:"mt-3 p-3 bg-surface-2 rounded-lg border border-white/5",children:[e.jsx("div",{className:"text-xs text-gray-400 font-medium mb-1",children:"Preconditions"}),e.jsx("div",{className:"text-sm text-gray-300 whitespace-pre-wrap",children:q})]}),!1]}),f?e.jsx("div",{className:"text-center py-12 text-gray-500",children:"Loading steps..."}):N.length===0?e.jsx("div",{className:"text-center py-12 text-gray-500",children:"No steps found for this execution."}):e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-12",children:"#"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400",children:"Action"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400",children:"Expected Result"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-48",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400",children:"Actual Result"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400",children:"Comment"})]})}),e.jsx("tbody",{children:N.map((m,M)=>e.jsxs("tr",{className:`border-b border-white/5 ${Ua[m.status]??""}`,children:[e.jsx("td",{className:"px-4 py-3 text-gray-500 font-mono text-xs",children:m.stepNumber??m.step_number??M+1}),e.jsx("td",{className:"px-4 py-3 text-gray-300 max-w-[200px] align-top",children:e.jsx("div",{className:"whitespace-pre-wrap break-words break-all text-xs",children:m.action??m.stepAction??"—"})}),e.jsx("td",{className:"px-4 py-3 text-gray-400 max-w-[200px] align-top",children:e.jsx("div",{className:"whitespace-pre-wrap break-words break-all text-xs",children:m.expectedResult??m.expected_result??"—"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>J(m,"passed"),className:`p-1.5 rounded text-xs font-medium transition-colors ${m.status==="passed"?"bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/30":"text-gray-500 hover:text-emerald-300 hover:bg-emerald-500/10"}`,title:"Pass",children:e.jsx(ve,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>J(m,"failed"),className:`p-1.5 rounded text-xs font-medium transition-colors ${m.status==="failed"?"bg-red-500/20 text-red-300 ring-1 ring-red-500/30":"text-gray-500 hover:text-red-300 hover:bg-red-500/10"}`,title:"Fail",children:e.jsx(De,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>J(m,"blocked"),className:`p-1.5 rounded text-xs font-medium transition-colors ${m.status==="blocked"?"bg-orange-500/20 text-orange-300 ring-1 ring-orange-500/30":"text-gray-500 hover:text-orange-300 hover:bg-orange-500/10"}`,title:"Block",children:e.jsx(Qt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>J(m,"skipped"),className:`p-1.5 rounded text-xs font-medium transition-colors ${m.status==="skipped"?"bg-gray-500/20 text-gray-300 ring-1 ring-gray-500/30":"text-gray-500 hover:text-gray-300 hover:bg-gray-500/10"}`,title:"Skip",children:e.jsx(Vt,{className:"w-4 h-4"})})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("textarea",{defaultValue:m.actualResult??m.actual_result??"",onBlur:L=>U(m,L.target.value),rows:1,className:"w-full bg-surface-2 border border-white/5 rounded px-2 py-1 text-xs text-gray-300 placeholder-gray-600 focus:outline-none focus:border-brand-500/50 resize-none min-w-[120px]",placeholder:"Actual result..."})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("textarea",{defaultValue:m.comment??"",onBlur:L=>ae(m,L.target.value),rows:1,className:"w-full bg-surface-2 border border-white/5 rounded px-2 py-1 text-xs text-gray-300 placeholder-gray-600 focus:outline-none focus:border-brand-500/50 resize-none min-w-[120px]",placeholder:"Comment..."})})]},m.id))})]})})}),e.jsx(Xa,{executionId:s}),e.jsxs("div",{className:"flex items-center justify-between bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"text-sm text-gray-400",children:[e.jsx("span",{className:"text-emerald-400 font-medium",children:H})," of ",e.jsx("span",{className:"text-gray-200 font-medium",children:Q})," steps passed"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[R?e.jsxs("span",{className:`text-xs px-3 py-2 rounded-lg border flex items-center gap-1.5 ${R.status==="open"?"bg-red-500/10 text-red-400 border-red-500/20":R.status==="in_progress"?"bg-amber-500/10 text-amber-400 border-amber-500/20":R.status==="resolved"?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":"bg-gray-500/10 text-gray-400 border-gray-500/20"}`,title:R.title,children:[e.jsx(Ee,{className:"w-3.5 h-3.5"}),R.id," — ",e.jsx("span",{className:"capitalize",children:R.status.replace("_"," ")})]}):$>0?e.jsxs("button",{onClick:V,disabled:A.isPending,className:"bg-red-600/80 hover:bg-red-600 text-white rounded-lg px-4 py-2 text-sm flex items-center gap-2 disabled:opacity-50",title:"Create a defect with all failed step details",children:[A.isPending?e.jsx(se,{className:"w-4 h-4 animate-spin"}):e.jsx(Ee,{className:"w-4 h-4"}),"Create Defect (",$," failed)"]}):null,e.jsxs("button",{onClick:re,disabled:j.isPending,className:"bg-emerald-600/80 hover:bg-emerald-600 text-white rounded-lg px-4 py-2 text-sm flex items-center gap-2 disabled:opacity-50",children:[e.jsx(ve,{className:"w-4 h-4"}),"Pass All Steps"]}),e.jsxs("button",{onClick:a,className:"bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-4 py-2 text-sm flex items-center gap-2",children:[e.jsx(va,{className:"w-4 h-4 rotate-180"}),"Back to Cycle"]})]})]})]})}function kr(){const{user:s}=st(),a=(s==null?void 0:s.displayName)||(s==null?void 0:s.username)||"Unknown",[l]=Nt("view",["plans","plan-detail","cycle-execution","step-execution"],"plans"),[h]=Je("planId"),[c]=Je("cycleId"),[C]=Je("execId"),u=As(),[g,p]=r.useState(""),[f,y]=r.useState(""),[j,N]=r.useState(!1),[A,x]=r.useState(!1),[o,w]=r.useState(!1),[I,R]=r.useState(null),[H,$]=r.useState(null),[Q,V]=Nt("subtab",["testcases","cycles"],"testcases"),[k,ee]=r.useState(""),[D,B]=r.useState(null),[q,J]=r.useState(""),{data:U,isLoading:ae}=Fs(g||void 0),{data:re}=zs(h??""),{data:n}=Bs(h??""),{data:m}=Ls(h??""),{data:M}=Us(c??""),{data:L}=Os(c??"",f||void 0),F=qs(),_=Hs(),lt=Ks(),nt=Qs(),ze=Vs(),it=r.useMemo(()=>{const t=Array.isArray(U)?U:(U==null?void 0:U.plans)??(U==null?void 0:U.data)??[];if(!k)return t;const i=k.toLowerCase();return t.filter(v=>{var T,E;return((T=v.name)==null?void 0:T.toLowerCase().includes(i))||((E=v.description)==null?void 0:E.toLowerCase().includes(i))})},[U,k]),Ce=r.useMemo(()=>Array.isArray(n)?n:(n==null?void 0:n.testCases)??(n==null?void 0:n.data)??[],[n]),Be=r.useMemo(()=>Array.isArray(m)?m:(m==null?void 0:m.cycles)??(m==null?void 0:m.data)??[],[m]),W=r.useMemo(()=>Array.isArray(L)?L:(L==null?void 0:L.executions)??(L==null?void 0:L.data)??[],[L]),b=re,S=M,Gt=r.useCallback(t=>{u({view:"plan-detail",planId:t,subtab:null})},[u]),Wt=r.useCallback(t=>{y(""),u({view:"cycle-execution",cycleId:t})},[u]),Yt=r.useCallback(t=>{u({view:"step-execution",execId:t})},[u]),Zt=r.useCallback(()=>{l==="step-execution"?u({view:"cycle-execution",execId:null}):l==="cycle-execution"?u({view:"plan-detail",cycleId:null,subtab:"cycles"}):l==="plan-detail"&&u({view:null,planId:null})},[l,u]),es=r.useCallback((t,i)=>{xe({kind:"delete-plan",planId:t,planName:i})},[]),ts=r.useCallback(t=>{F.mutate(t,{onSuccess:()=>{h===t&&u({view:null,planId:null})}})},[F,h]),ss=r.useCallback((t,i)=>{h&&xe({kind:"remove-tc",testCaseId:t,tcTitle:i})},[h]),as=r.useCallback(t=>{h&&_.mutate({planId:h,testCaseIds:[t]})},[_,h]),rs=r.useCallback((t,i)=>{xe({kind:"delete-cycle",cycleId:t,cycleName:i})},[]),ls=r.useCallback(t=>{lt.mutate(t)},[lt]),ct=es,ns=ss,is=rs,je=r.useCallback((t,i)=>{nt.mutate({id:t,data:{status:i,executedBy:a}})},[nt,a]),cs=r.useCallback(()=>{!D||!q.trim()||ze.mutate({cycleId:D,data:{name:q.trim()}},{onSuccess:()=>{B(null),J("")}})},[ze,D,q]),ot=qt(),dt=Js(),Le=Xs(),Ue=Gs(),{toast:me}=tt(),[os,xt]=r.useState(!1),[ds,ut]=r.useState(!0),[ke,xs]=r.useState(null),Oe=r.useRef(null),us=t=>{const i=t.currentTarget.parentElement;if(!i)return;const v=i.getBoundingClientRect();Oe.current={dx:t.clientX-v.left,dy:t.clientY-v.top,h:v.height};const T=P=>{const te=Oe.current;te&&xs({x:Math.max(8,Math.min(window.innerWidth-308,P.clientX-te.dx)),y:Math.max(8,Math.min(window.innerHeight-120,P.clientY-te.dy)),h:te.h})},E=()=>{Oe.current=null,window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",E)};window.addEventListener("pointermove",T),window.addEventListener("pointerup",E)},[Y,qe]=r.useState(null),He=r.useRef(null),{data:le}=Ws(Y,!!Y),[X,he]=r.useState(null),{mode:ms}=Lt(),hs=ms==="mobile",Ke=Ht(),[Ya,Za]=r.useState(new Set),[ne,Qe]=r.useState(new Set),[ie,pe]=r.useState(!1),{data:Se}=Ys(l==="cycle-execution"?c:null,{busy:!!Y||ie||ne.size>0}),ce=r.useMemo(()=>{const t=(Se==null?void 0:Se.executions)??[];return Array.isArray(t)?t:[]},[Se]),[d,xe]=r.useState(null),mt=r.useMemo(()=>W.map(t=>t.id),[W]),ps=r.useMemo(()=>W.map(t=>`${t.id}:${t.status}`).join(","),[W]),{data:Te,refetch:gs}=et({queryKey:["exec-defects",c,ps],queryFn:()=>Ut(mt),enabled:mt.length>0&&l==="cycle-execution"}),bs=r.useMemo(()=>(Te==null?void 0:Te.defects)||{},[Te]),Re=ce.filter(t=>t.hasMappedScript).length,ge=Ps(),Ve=r.useRef("");r.useEffect(()=>{const t=ce.map(i=>`${i.executionId}:${i.automationStatus}`).join(",");Ve.current&&Ve.current!==t&&(ge.invalidateQueries({queryKey:["tm-cycle-executions"]}),ge.invalidateQueries({queryKey:["tm-cycles"]}),ge.invalidateQueries({queryKey:["tm-plans"]}),ge.invalidateQueries({queryKey:["tm-cycle-analytics"]}),ge.invalidateQueries({queryKey:["tm-step-results"]}),ce.forEach(i=>{if(ne.has(i.executionId)&&(i.automationStatus==="completed"||i.automationStatus==="failed")&&i.resultRunId){const v=i.automationStatus==="completed";he({runId:i.resultRunId,passed:v?1:0,failed:v?0:1,total:1,label:i.testCaseTitle}),me(v?"success":"error",`${i.testCaseTitle||"Test"} — ${v?"passed":"failed"}`)}}),Qe(i=>{const v=new Set(i);return ce.forEach(T=>{(T.automationStatus==="completed"||T.automationStatus==="failed")&&v.delete(T.executionId)}),v}),Y||!ce.some(v=>v.automationStatus==="running")&&ie&&pe(!1)),Ve.current=t},[ce,ge,ie,Y,ne,me]),r.useEffect(()=>{var t;if(Y){if(le&&le.running===!1){if(pe(!1),He.current===Y)return;const i=(t=le.run)==null?void 0:t.summary;if(!i){qe(null);return}He.current=Y;const v=i.passed??0,T=i.failed??0,E=i.total??v+T;he({runId:Y,passed:v,failed:T,total:E}),me(T>0?"error":"success",`Automation finished — ${v}/${E} passed${T>0?`, ${T} failed`:""}`);const P=setTimeout(()=>qe(null),1500);return()=>clearTimeout(P)}pe(!0),he(null)}},[le,Y,me]);const ht=r.useMemo(()=>{var T;const i=(((T=le==null?void 0:le.run)==null?void 0:T.results)||[]).find(E=>E.isHook&&E.status==="running");return i?/setup/i.test(i.name||"")?"setup":"teardown":null},[le]),fs=r.useCallback((t,i)=>{xe({kind:"run-single",executionId:t,tcTitle:i})},[]),ys=r.useCallback(t=>{he(null),Qe(i=>new Set(i).add(t)),ot.mutate(t,{onSettled:()=>{setTimeout(()=>{Qe(i=>{const v=new Set(i);return v.delete(t),v})},360*1e3)}})},[ot]),js=fs,Ns=r.useCallback(()=>{c&&xe({kind:"run-all",cycleId:c})},[c]),vs=r.useCallback(()=>{c&&(pe(!0),he(null),He.current=null,dt.mutate(c,{onSuccess:t=>{t!=null&&t.aggregateRunId&&qe(t.aggregateRunId)},onError:()=>pe(!1)}))},[dt,c]),ws=Ns,Cs=ce.some(t=>t.automationStatus==="running"),Ne=ie||ne.size>0||Cs,ks=r.useCallback(()=>{ie&&c&&Le.mutate(c,{onSuccess:()=>setTimeout(()=>pe(!1),2e3)}),ne.forEach(t=>{Ue.mutate(t)}),me("info","Cancelling automation run…")},[Le,Ue,ie,ne,c,me]),K=r.useMemo(()=>{const t={total:0,passed:0,failed:0,blocked:0,skipped:0,not_run:0,in_progress:0};return W.forEach(i=>{t.total++,t[i.status]!==void 0?t[i.status]++:t.not_run++}),t},[W]),Ss=K.total>0?Math.round(K.passed/K.total*100):0,Ts=K.total>0?Math.round((K.total-K.not_run)/K.total*100):0,Pe=e.jsx(Ot,{open:!!d,title:(d==null?void 0:d.kind)==="delete-plan"?"Delete test plan?":(d==null?void 0:d.kind)==="delete-cycle"?"Delete cycle?":(d==null?void 0:d.kind)==="remove-tc"?"Remove test case from plan?":(d==null?void 0:d.kind)==="run-single"?"Run automation script?":(d==null?void 0:d.kind)==="run-all"?"Run all automation scripts in this cycle?":"",description:(d==null?void 0:d.kind)==="delete-plan"?`This will permanently delete "${d.planName??"this test plan"}" along with all its cycles and execution history. This action cannot be undone.`:(d==null?void 0:d.kind)==="delete-cycle"?`This will permanently delete "${d.cycleName??"this cycle"}" along with all its execution results. This action cannot be undone.`:(d==null?void 0:d.kind)==="remove-tc"?`Remove "${d.tcTitle??"this test case"}" from the plan? Existing executions for this test case in any cycle of this plan will also be cleared. The test case itself will not be deleted from the catalog.`:(d==null?void 0:d.kind)==="run-single"?`This will execute the automation script for "${d.tcTitle??"this test case"}" and update its execution status with the result. Long-running scripts may take a few minutes.`:(d==null?void 0:d.kind)==="run-all"?`This will execute every automated test in ${S!=null&&S.name?`"${S.name}"`:"this cycle"} sequentially. Manual test cases are skipped. The cycle's execution status will be updated as each script completes.`:"",confirmLabel:(d==null?void 0:d.kind)==="delete-plan"?"Delete Plan":(d==null?void 0:d.kind)==="delete-cycle"?"Delete Cycle":(d==null?void 0:d.kind)==="remove-tc"?"Remove":(d==null?void 0:d.kind)==="run-single"?"Run Script":(d==null?void 0:d.kind)==="run-all"?"Run All":"Confirm",variant:(d==null?void 0:d.kind)==="run-single"||(d==null?void 0:d.kind)==="run-all"?"primary":"danger",icon:(d==null?void 0:d.kind)==="run-single"||(d==null?void 0:d.kind)==="run-all"?Xe:void 0,onConfirm:()=>{const t=d;xe(null),t&&(t.kind==="delete-plan"?ts(t.planId):t.kind==="delete-cycle"?ls(t.cycleId):t.kind==="remove-tc"?as(t.testCaseId):t.kind==="run-single"?ys(t.executionId):t.kind==="run-all"&&vs())},onCancel:()=>xe(null)});return l==="step-execution"&&C?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-6 max-w-7xl mx-auto",children:e.jsx(Ga,{executionId:C,onBack:()=>Zt(),breadcrumbPlanName:(b==null?void 0:b.name)??"Plan",breadcrumbCycleName:(S==null?void 0:S.name)??"Cycle",onNavigateToPlan:()=>{u({view:"plan-detail",cycleId:null,execId:null})},onNavigateToCycle:()=>{u({view:"cycle-execution",execId:null})}})}),Pe]}):l==="cycle-execution"&&c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-6 max-w-7xl mx-auto space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[e.jsx("button",{onClick:()=>{u({view:null,planId:null,cycleId:null})},className:"hover:text-gray-100 transition-colors",children:"Test Plans"}),e.jsx(ye,{className:"w-4 h-4"}),e.jsx("button",{onClick:()=>{u({view:"plan-detail",cycleId:null})},className:"hover:text-gray-100 transition-colors truncate max-w-[200px]",children:(b==null?void 0:b.name)??"Plan"}),e.jsx(ye,{className:"w-4 h-4"}),e.jsx("span",{className:"text-gray-200 truncate max-w-[200px]",children:(S==null?void 0:S.name)??"Cycle"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:(S==null?void 0:S.name)??"Cycle"}),(S==null?void 0:S.assignedTo)&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-gray-400 mt-1",children:[e.jsx(Ct,{className:"w-3.5 h-3.5"}),S.assignedTo]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[(S==null?void 0:S.id)&&e.jsx("span",{title:"Cycle ID",className:"text-xs font-mono px-2.5 py-1 rounded-lg bg-surface-2 text-brand-300 border border-white/5",children:S.id}),(S==null?void 0:S.status)&&e.jsx("span",{title:"Cycle Status",className:`text-xs px-2.5 py-1 rounded-lg font-medium ${Me[S.status]??We[S.status]??"bg-gray-500/20 text-gray-400"}`,children:z(S.status)})]})]}),e.jsx("div",{className:"mb-4",children:e.jsx(qa,{executions:W})}),e.jsxs("div",{className:"grid grid-cols-3 md:grid-cols-8 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-gray-200",children:K.total}),e.jsx("div",{className:"text-xs text-gray-500",children:"Total"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-emerald-400",children:K.passed}),e.jsx("div",{className:"text-xs text-gray-500",children:"Passed"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-red-400",children:K.failed}),e.jsx("div",{className:"text-xs text-gray-500",children:"Failed"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-orange-400",children:K.blocked}),e.jsx("div",{className:"text-xs text-gray-500",children:"Blocked"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-gray-400",children:K.skipped}),e.jsx("div",{className:"text-xs text-gray-500",children:"Skipped"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-slate-400",children:K.not_run}),e.jsx("div",{className:"text-xs text-gray-500",children:"Not Run"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-lg font-bold text-emerald-300",children:[Ss,"%"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"Pass Rate"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-lg font-bold text-blue-300",children:[Ts,"%"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"Completion"})]})]})]}),e.jsx(Ha,{cycleId:c}),e.jsx("div",{className:"flex items-center gap-1 bg-surface-1 rounded-xl border border-white/5 p-1.5",children:[{label:"All",value:""},...Ft.map(t=>({label:z(t),value:t}))].map(t=>e.jsx("button",{onClick:()=>y(t.value),className:`px-3 py-1.5 text-sm rounded-lg transition-colors ${f===t.value?"bg-brand-500/15 text-brand-300 font-medium":"text-gray-400 hover:text-gray-200 hover:bg-surface-2"}`,children:t.label},t.value))}),Re>0&&e.jsxs("div",{className:"flex items-center justify-between bg-surface-1 rounded-xl border border-white/5 px-4 py-3",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(kt,{className:"w-4 h-4 text-cyan-400"}),e.jsxs("span",{className:"text-gray-300",children:[e.jsx("span",{className:"font-medium text-cyan-300",children:Re})," of ",W.length," test cases have automation scripts"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>xt(!0),disabled:Ne,title:"Run settings & hooks (applies to all cycles)",className:"bg-surface-2 hover:bg-surface-3 disabled:opacity-50 disabled:cursor-not-allowed text-gray-200 border border-white/10 rounded-lg px-3 py-2 text-sm font-medium flex items-center gap-2 transition-colors",children:[e.jsx(Ye,{className:"w-4 h-4"})," Settings"]}),e.jsx("span",{children:e.jsx("button",{onClick:ws,disabled:Ne||Re===0,className:"bg-cyan-600 hover:bg-cyan-500 disabled:bg-gray-600 disabled:cursor-not-allowed text-white rounded-lg px-4 py-2 text-sm font-medium flex items-center gap-2 transition-colors",children:ie?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"w-4 h-4 animate-spin"})," ",ht==="setup"?"Running setup…":ht==="teardown"?"Running teardown…":"Running Automation..."]}):ne.size>0?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"w-4 h-4 animate-spin"})," Running Test…"]}):e.jsxs(e.Fragment,{children:[e.jsx(St,{className:"w-4 h-4"})," Run All Automated (",Re,")"]})})}),Ne&&e.jsxs("button",{onClick:ks,disabled:Le.isPending||Ue.isPending,className:"bg-red-600/90 hover:bg-red-500 disabled:opacity-50 text-white rounded-lg px-3 py-2 text-sm font-medium flex items-center gap-2 transition-colors",children:[e.jsx(ja,{className:"w-4 h-4"})," Cancel"]})]})]}),X&&!ie&&e.jsxs("div",{className:`flex items-center justify-between rounded-xl border px-4 py-3 ${X.failed>0?"bg-red-500/10 border-red-500/20":"bg-emerald-500/10 border-emerald-500/20"}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5 text-sm",children:[X.failed>0?e.jsx(De,{className:"w-4 h-4 text-red-400 flex-shrink-0"}):e.jsx(ve,{className:"w-4 h-4 text-emerald-400 flex-shrink-0"}),e.jsx("span",{className:X.failed>0?"text-red-200":"text-emerald-200",children:X.label?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:X.label})," — ",X.failed>0?"failed":"passed","."]}):e.jsxs(e.Fragment,{children:["Automation run complete — ",e.jsxs("span",{className:"font-semibold",children:[X.passed,"/",X.total]})," passed",X.failed>0?`, ${X.failed} failed`:"","."]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("a",{href:`/results?runId=${encodeURIComponent(X.runId)}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 bg-surface-2 hover:bg-surface-3 text-gray-100 border border-white/10 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors",children:[e.jsx(Kt,{className:"w-3.5 h-3.5"})," View Result"]}),e.jsx("button",{onClick:()=>he(null),title:"Dismiss",className:"text-gray-500 hover:text-gray-200 p-1.5 rounded-lg hover:bg-white/5",children:e.jsx(Z,{className:"w-4 h-4"})})]})]}),hs&&Ne&&(ds?e.jsxs("div",{className:"fixed w-[300px] z-40 flex flex-col rounded-xl border border-white/10 bg-surface-1 shadow-2xl overflow-hidden",style:ke?{left:ke.x,top:ke.y,height:ke.h}:{right:16,top:80,bottom:16},children:[e.jsxs("div",{onPointerDown:us,className:"flex items-center gap-2 px-3 py-2 border-b border-white/5 flex-shrink-0 cursor-move select-none touch-none",title:"Drag to move",children:[e.jsx(Tt,{size:13,className:"text-indigo-400"}),e.jsx("span",{className:"text-xs font-medium text-gray-300 flex-1",children:"Live Device — Execution view"}),e.jsx("button",{onClick:()=>ut(!1),onPointerDown:t=>t.stopPropagation(),className:"p-1 rounded text-gray-500 hover:text-gray-300 hover:bg-white/5",title:"Hide live view",children:e.jsx(Z,{size:13})})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(Da,{testRunning:Ne,hideHeader:!0})})]}):e.jsx("button",{onClick:()=>ut(!0),className:"fixed right-0 top-1/2 -translate-y-1/2 z-40 flex items-center gap-1.5 px-2 py-3 rounded-l-lg border border-r-0 border-white/10 bg-surface-1 text-gray-400 hover:text-gray-200 shadow-xl",title:"Show live device view",children:e.jsx(Tt,{size:14})})),os&&e.jsx(Ba,{onClose:()=>xt(!1)}),e.jsx(Wa,{planName:(b==null?void 0:b.name)||"",cycleName:(S==null?void 0:S.name)||"",execStats:K,executionsList:W}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:W.length===0?e.jsxs("div",{className:"text-center py-12 text-gray-500",children:[e.jsx(Rt,{className:"w-10 h-10 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No executions found."})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("th",{className:"text-left pl-4 pr-1 py-3 text-xs font-medium text-gray-400 w-8"}),e.jsx("th",{className:"text-left pl-1 pr-4 py-3 text-xs font-medium text-gray-400",children:"Test Case"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-24",children:"Priority"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-36",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-44",children:"Quick Actions"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-24",children:"Duration"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-32",children:"Executed By"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-28"})]})}),e.jsx("tbody",{children:W.map(t=>{var be,ue,fe,Ae,$e,pt,gt,bt,ft,yt;const i=t.testCaseTitle??((be=t.testCase)==null?void 0:be.title)??((ue=t.test_case)==null?void 0:ue.title)??t.title??"Untitled",v=t.testCasePriority??((fe=t.testCase)==null?void 0:fe.priority)??((Ae=t.test_case)==null?void 0:Ae.priority)??t.priority;t.testCaseType??(($e=t.testCase)==null?void 0:$e.type)??((pt=t.test_case)==null?void 0:pt.type)??t.type;const T=t.testCaseCode??((gt=t.testCase)==null?void 0:gt.code)??((bt=t.test_case)==null?void 0:bt.code),E=t.testCaseId??((ft=t.testCase)==null?void 0:ft.id)??((yt=t.test_case)==null?void 0:yt.id),P=ce.find(O=>O.executionId===t.id),te=P==null?void 0:P.hasMappedScript,oe=ne.has(t.id)||(P==null?void 0:P.automationStatus)==="running";return e.jsxs(Rs.Fragment,{children:[e.jsxs("tr",{className:"border-b border-white/5 hover:bg-surface-2/50 transition-colors",children:[e.jsx("td",{className:"pl-4 pr-1 py-3 text-center",children:te?e.jsx("span",{title:`Automated (${P==null?void 0:P.framework}) — ${P==null?void 0:P.scriptPath}`,children:e.jsx(kt,{className:"w-4 h-4 text-cyan-400"})}):e.jsx("span",{title:"Manual test",className:"text-gray-600 text-xs",children:"M"})}),e.jsxs("td",{className:"pl-1 pr-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 max-w-[300px]",children:[E&&e.jsx("span",{title:"Test Case ID",className:"text-[11px] font-mono text-brand-300 flex-shrink-0",children:E}),e.jsx("span",{title:i,className:"text-gray-200 font-medium truncate",children:i})]}),T&&e.jsx("div",{className:"text-xs text-gray-500",children:T})]}),e.jsx("td",{className:"px-4 py-3",children:v&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Fe[v]??"bg-gray-500/20 text-gray-400"}`,children:z(v)})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[oe&&e.jsx("span",{title:"Running…",className:"inline-flex items-center gap-1 text-cyan-300 text-xs flex-shrink-0",children:e.jsx(se,{className:"w-3.5 h-3.5 animate-spin"})}),e.jsx("select",{value:t.status??"not_run",onChange:O=>je(t.id,O.target.value),className:`text-xs px-2 py-1 rounded-lg border-0 focus:outline-none focus:ring-1 focus:ring-brand-500/50 cursor-pointer ${oe?"bg-cyan-500/20 text-cyan-300":We[t.status]??"bg-slate-500/20 text-slate-400"}`,children:Ft.map(O=>e.jsx("option",{value:O,children:z(O)},O))})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>je(t.id,"passed"),className:`p-1 rounded transition-colors ${t.status==="passed"?"text-emerald-400":"text-gray-600 hover:text-emerald-400"}`,title:"Pass",children:e.jsx(ve,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>je(t.id,"failed"),className:`p-1 rounded transition-colors ${t.status==="failed"?"text-red-400":"text-gray-600 hover:text-red-400"}`,title:"Fail",children:e.jsx(De,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>je(t.id,"blocked"),className:`p-1 rounded transition-colors ${t.status==="blocked"?"text-orange-400":"text-gray-600 hover:text-orange-400"}`,title:"Block",children:e.jsx(Qt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>je(t.id,"skipped"),className:`p-1 rounded transition-colors ${t.status==="skipped"?"text-gray-300":"text-gray-600 hover:text-gray-300"}`,title:"Skip",children:e.jsx(Vt,{className:"w-4 h-4"})})]})}),e.jsx("td",{className:"px-4 py-3 text-xs text-gray-400",children:t.duration?`${t.duration}s`:"—"}),e.jsx("td",{className:"px-4 py-3 text-xs text-gray-400 max-w-[120px]",children:e.jsx("span",{className:"block truncate",title:t.executedBy??t.executed_by??"",children:t.executedBy??t.executed_by??"—"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[te&&e.jsx("span",{children:e.jsxs("button",{onClick:()=>{var O;return js(t.id,((O=t.testCase)==null?void 0:O.title)||t.title)},disabled:oe,className:"bg-cyan-600 hover:bg-cyan-500 disabled:bg-gray-600 disabled:cursor-not-allowed text-white rounded-lg px-2.5 py-1 text-xs flex items-center gap-1 transition-colors",title:`Run ${P==null?void 0:P.framework} script`,children:[oe?e.jsx(se,{className:"w-3 h-3 animate-spin"}):e.jsx(St,{className:"w-3 h-3"}),oe?"Running":"Run"]})}),e.jsxs("button",{onClick:()=>Yt(t.id),className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-2.5 py-1 text-xs flex items-center gap-1",title:"Manual step execution",children:[e.jsx(Xe,{className:"w-3 h-3"}),"Steps"]}),(()=>{const O=bs[t.id];if(O){const jt={open:"bg-red-500/10 text-red-400 border-red-500/20",in_progress:"bg-amber-500/10 text-amber-400 border-amber-500/20",resolved:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",closed:"bg-gray-500/10 text-gray-400 border-gray-500/20",rejected:"bg-gray-500/10 text-gray-500 border-gray-500/20"};return e.jsxs("span",{className:`text-[10px] px-2 py-1 rounded border inline-flex flex-col items-start leading-tight whitespace-nowrap ${jt[O.status]||jt.open}`,title:O.title,children:[e.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[e.jsx(Ee,{className:"w-3 h-3"}),O.id]}),e.jsx("span",{className:"capitalize opacity-90",children:O.status.replace("_"," ")})]})}return t.status==="failed"||t.status==="blocked"?e.jsxs("button",{onClick:()=>{Ke.mutate({executionId:t.id,createdBy:a},{onSuccess:()=>gs()})},disabled:Ke.isPending,className:"bg-red-600/80 hover:bg-red-600 text-white rounded-lg px-2.5 py-1 text-xs flex items-center gap-1",title:"Create defect from this failed execution",children:[Ke.isPending?e.jsx(se,{className:"w-3 h-3 animate-spin"}):e.jsx(Ee,{className:"w-3 h-3"}),"Defect"]}):null})()]})})]}),oe&&(P==null?void 0:P.resultRunId)&&e.jsx("tr",{className:"border-b border-white/5",children:e.jsx("td",{colSpan:99,className:"px-4 pb-2 pt-0",children:e.jsx(za,{runId:P.resultRunId,layout:"strip",className:"!pl-0 !px-0"})})})]},t.id)})})]})})})]}),Pe]}):l==="plan-detail"&&h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-6 max-w-7xl mx-auto space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[e.jsx("button",{onClick:()=>{u({view:null,planId:null})},className:"hover:text-gray-100 transition-colors",children:"Test Plans"}),e.jsx(ye,{className:"w-4 h-4"}),e.jsx("span",{className:"text-gray-200 truncate max-w-[300px]",children:(b==null?void 0:b.name)??"Plan"})]}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-200 mb-1",children:(b==null?void 0:b.name)??""}),(b==null?void 0:b.description)&&e.jsx("p",{className:"text-sm text-gray-400 mb-3",children:b.description}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[(b==null?void 0:b.id)&&e.jsx("span",{title:"Test Plan ID",className:"text-xs font-mono px-2 py-0.5 rounded bg-surface-2 text-brand-300 border border-white/5",children:b.id}),(b==null?void 0:b.release)&&e.jsx("span",{title:"Release",className:"text-xs px-2 py-0.5 rounded bg-brand-500/15 text-brand-300",children:b.release}),(b==null?void 0:b.sprint)&&e.jsx("span",{title:"Sprint",className:"text-xs px-2 py-0.5 rounded bg-indigo-500/15 text-indigo-300",children:b.sprint}),(b==null?void 0:b.status)&&e.jsx("span",{title:"Plan Status",className:`text-xs px-2 py-0.5 rounded ${Me[b.status]??"bg-gray-500/20 text-gray-400"}`,children:z(b.status)})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsxs("button",{onClick:()=>{R(b),N(!0)},className:"bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-3 py-1.5 text-sm flex items-center gap-1.5",children:[e.jsx(Ze,{className:"w-3.5 h-3.5"})," Edit"]}),e.jsxs("button",{onClick:()=>ct(h,b==null?void 0:b.name),className:"bg-surface-2 hover:bg-red-500/20 text-gray-300 hover:text-red-400 rounded-lg px-3 py-1.5 text-sm flex items-center gap-1.5",children:[e.jsx(_e,{className:"w-3.5 h-3.5"})," Delete"]})]})]})}),e.jsxs("div",{className:"flex items-center gap-1 bg-surface-1 rounded-xl border border-white/5 p-1.5",children:[e.jsxs("button",{onClick:()=>V("testcases"),className:`px-4 py-2 text-sm rounded-lg transition-colors flex items-center gap-2 ${Q==="testcases"?"bg-brand-500/15 text-brand-300 font-medium":"text-gray-400 hover:text-gray-200 hover:bg-surface-2"}`,children:[e.jsx(Ie,{className:"w-4 h-4"})," Test Cases",e.jsx("span",{className:"text-xs bg-surface-2 px-1.5 py-0.5 rounded",children:Ce.length})]}),e.jsxs("button",{onClick:()=>V("cycles"),className:`px-4 py-2 text-sm rounded-lg transition-colors flex items-center gap-2 ${Q==="cycles"?"bg-brand-500/15 text-brand-300 font-medium":"text-gray-400 hover:text-gray-200 hover:bg-surface-2"}`,children:[e.jsx(Ge,{className:"w-4 h-4"})," Cycles",e.jsx("span",{className:"text-xs bg-surface-2 px-1.5 py-0.5 rounded",children:Be.length})]})]}),Q==="testcases"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Test Cases in Plan"}),e.jsxs("button",{onClick:()=>w(!0),className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-3 py-1.5 text-sm flex items-center gap-1.5",children:[e.jsx(de,{className:"w-4 h-4"})," Add Test Cases"]})]}),Ce.length===0?e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-8 text-center",children:[e.jsx(Ie,{className:"w-10 h-10 mx-auto mb-2 text-gray-600"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"No test cases added to this plan yet."}),e.jsxs("button",{onClick:()=>w(!0),className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm inline-flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4"})," Add Test Cases"]})]}):e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400",children:"Title"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-24",children:"Priority"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-28",children:"Type"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-28",children:"Automation"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-400 w-12"})]})}),e.jsx("tbody",{children:Ce.map(t=>{const i=t.testCase??t.test_case??t;return e.jsxs("tr",{className:"border-b border-white/5 hover:bg-surface-2/50 transition-colors",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i.id&&e.jsx("span",{title:"Test Case ID",className:"text-[11px] font-mono text-brand-300 flex-shrink-0",children:i.id}),e.jsx("span",{title:i.title??"Untitled",className:"flex-1 min-w-0 text-gray-200 font-medium truncate",children:i.title??"Untitled"})]}),i.code&&e.jsx("div",{className:"text-xs text-gray-500 mt-0.5",children:i.code})]}),e.jsx("td",{className:"px-4 py-3",children:i.priority&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Fe[i.priority]??"bg-gray-500/20 text-gray-400"}`,children:z(i.priority)})}),e.jsx("td",{className:"px-4 py-3",children:i.type&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${rt[i.type]??"bg-gray-500/20 text-gray-400"}`,children:z(i.type)})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${i.automationStatus==="automated"||i.automation_status==="automated"?"bg-emerald-500/20 text-emerald-300":i.automationStatus==="needs_update"||i.automation_status==="needs_update"?"bg-amber-500/20 text-amber-300":"bg-gray-500/20 text-gray-400"}`,children:z(i.automationStatus??i.automation_status??"manual")})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:()=>ns(i.id,i.title),className:"p-1 text-gray-500 hover:text-red-400 rounded transition-colors",title:"Remove from plan",children:e.jsx(Z,{className:"w-4 h-4"})})})]},t.id??i.id)})})]})})})]}),Q==="cycles"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Test Cycles"}),e.jsxs("button",{onClick:()=>{$(null),x(!0)},className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-3 py-1.5 text-sm flex items-center gap-1.5",children:[e.jsx(de,{className:"w-4 h-4"})," New Cycle"]})]}),Be.length===0?e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-8 text-center",children:[e.jsx(Ge,{className:"w-10 h-10 mx-auto mb-2 text-gray-600"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"No test cycles created yet."}),e.jsxs("button",{onClick:()=>{$(null),x(!0)},className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm inline-flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4"})," Create Cycle"]})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:Be.map(t=>{const i=t.totalCount??t.totalExecutions??t.total_executions??0,v=t.executedCount??t.executed_count??0,T=t.passedCount??t.passed_count??0,E=t.failedCount??t.failed_count??0,P=E>0;return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 hover:border-white/10 transition-colors group",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-200 truncate",children:t.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[t.id&&e.jsx("span",{title:"Cycle ID",className:"text-xs font-mono px-2 py-0.5 rounded bg-surface-2 text-brand-300 border border-white/5",children:t.id}),t.status&&e.jsx("span",{title:"Cycle Status",className:`text-xs px-2 py-0.5 rounded ${Me[t.status]??We[t.status]??"bg-gray-500/20 text-gray-400"}`,children:z(t.status)}),t.assignedTo&&e.jsxs("span",{title:"Assignee",className:"text-xs text-gray-500 flex items-center gap-1",children:[e.jsx(Ct,{className:"w-3 h-3"})," ",t.assignedTo]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-2 shrink-0",children:[t.endDate&&(()=>{const te=new Date(t.endDate).getTime(),oe=Date.now(),be=te-oe;if(be<=0)return e.jsxs("span",{className:"text-xs text-red-400 flex items-center gap-1 px-1.5 py-0.5 rounded bg-red-500/10",children:[e.jsx(Pt,{className:"w-3 h-3"})," Overdue"]});const ue=Math.floor(be/(1e3*60*60*24)),fe=Math.floor(be%(1e3*60*60*24)/(1e3*60*60)),Ae=ue>0?`${ue}d ${fe}h`:fe>0?`${fe}h`:"< 1h",$e=ue===0?"text-orange-400 bg-orange-500/10":ue<=2?"text-amber-400 bg-amber-500/10":"text-gray-400 bg-surface-2";return e.jsxs("span",{className:`text-xs flex items-center gap-1 px-1.5 py-0.5 rounded ${$e}`,children:[e.jsx(Pt,{className:"w-3 h-3"})," ",Ae]})})(),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>{$(t),x(!0)},className:"p-1 text-gray-500 hover:text-gray-300 rounded",title:"Edit",children:e.jsx(Ze,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>is(t.id,t.name),className:"p-1 text-gray-500 hover:text-red-400 rounded",title:"Delete",children:e.jsx(_e,{className:"w-3.5 h-3.5"})})]})]})]}),i>0&&e.jsx("div",{className:"mb-2",children:e.jsxs("div",{className:"w-full h-2 rounded-full bg-surface-2 overflow-hidden flex",children:[T>0&&e.jsx("div",{className:"bg-emerald-500 h-full",style:{width:`${T/i*100}%`}}),E>0&&e.jsx("div",{className:"bg-red-500 h-full",style:{width:`${E/i*100}%`}}),v-T-E>0&&e.jsx("div",{className:"bg-amber-500 h-full",style:{width:`${(v-T-E)/i*100}%`}})]})}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-400 mb-1",children:[e.jsxs("span",{children:[v,"/",i," executed"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[T>0&&e.jsxs("span",{className:"text-emerald-400",children:[T," passed"]}),E>0&&e.jsxs("span",{className:"text-red-400",children:[E," failed"]}),i-v>0&&e.jsxs("span",{className:"text-gray-500",children:[i-v," remaining"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>Wt(t.id),className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-3 py-1.5 text-xs flex items-center gap-1.5",children:[e.jsx(Xe,{className:"w-3.5 h-3.5"})," Execute"]}),P&&e.jsxs("button",{onClick:()=>{B(t.id),J(`${t.name} - Rerun`)},className:"bg-orange-600/80 hover:bg-orange-600 text-white rounded-lg px-3 py-1.5 text-xs flex items-center gap-1.5",children:[e.jsx(At,{className:"w-3.5 h-3.5"})," Re-run Failed"]})]})]},t.id)})})]}),j&&e.jsx(zt,{editingPlan:I,onClose:()=>{N(!1),R(null)}}),A&&h&&e.jsx(Ka,{planId:h,editingCycle:H,onClose:()=>{x(!1),$(null)}}),o&&h&&e.jsx(Qa,{planId:h,existingTestCaseIds:Ce.map(t=>(t.testCase??t.test_case??t).id),onClose:()=>w(!1)}),D&&we.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>B(null),children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-xl w-full max-w-md p-6 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Re-run Failed Tests"}),e.jsx("button",{onClick:()=>B(null),className:"text-gray-400 hover:text-gray-200",children:e.jsx(Z,{className:"w-5 h-5"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"New Cycle Name"}),e.jsx("input",{value:q,onChange:t=>J(t.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50",placeholder:"e.g. Cycle 1 - Rerun"})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[e.jsx("button",{onClick:()=>B(null),className:"bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-4 py-2 text-sm",children:"Cancel"}),e.jsxs("button",{onClick:cs,disabled:!q.trim()||ze.isPending,className:"bg-orange-600 hover:bg-orange-500 text-white rounded-lg px-4 py-2 text-sm disabled:opacity-50 flex items-center gap-2",children:[e.jsx(At,{className:"w-4 h-4"}),"Re-run"]})]})]})}),document.body)]}),Pe]}):e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(Rt,{size:24,className:"text-brand-300"}),"Test Plans"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Manage test plans, cycles, and execution"})]}),e.jsxs("button",{onClick:()=>{R(null),N(!0)},className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-brand-600 hover:bg-brand-500 rounded-lg transition-colors",children:[e.jsx(de,{size:16})," New Plan"]})]})})}),e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-8 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(at,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),e.jsx("input",{value:k,onChange:t=>ee(t.target.value),className:"w-full bg-surface-1 border border-white/5 rounded-lg pl-10 pr-3 py-2 text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50 text-sm",placeholder:"Search plans..."})]}),e.jsx("div",{className:"flex items-center gap-1 bg-surface-1 rounded-lg border border-white/5 p-1",children:[{label:"All",value:""},...Xt.map(t=>({label:z(t),value:t}))].map(t=>e.jsx("button",{onClick:()=>p(t.value),className:`px-3 py-1.5 text-sm rounded-md transition-colors ${g===t.value?"bg-brand-500/15 text-brand-300 font-medium":"text-gray-400 hover:text-gray-200 hover:bg-surface-2"}`,children:t.label},t.value))})]}),ae?e.jsxs("div",{className:"text-center py-16 text-gray-500",children:[e.jsx(Na,{className:"w-8 h-8 mx-auto mb-2 animate-spin opacity-50"}),e.jsx("p",{className:"text-sm",children:"Loading plans..."})]}):it.length===0?e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-12 text-center",children:[e.jsx(Ge,{className:"w-12 h-12 mx-auto mb-3 text-gray-600"}),e.jsx("h3",{className:"text-lg font-medium text-gray-300 mb-1",children:"No test plans found"}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:g?`No plans with status "${z(g)}".`:"Create your first test plan to get started."}),e.jsxs("button",{onClick:()=>{R(null),N(!0)},className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm inline-flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4"})," Create Plan"]})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:it.map(t=>e.jsx(Va,{plan:t,onSelect:()=>Gt(t.id),onEdit:()=>{R(t),N(!0)},onDelete:()=>ct(t.id,t.name)},t.id))}),j&&e.jsx(zt,{editingPlan:I,onClose:()=>{N(!1),R(null)}}),Pe]})]})}function Wa({planName:s,cycleName:a,execStats:l,executionsList:h}){var A,x;const{connectorId:c,isConfigured:C}=Ea(),u=_a(),[g,p]=r.useState(""),[f,y]=r.useState(!1);if(!C)return null;const j=((A=s.match(/([A-Z][A-Z0-9]+-\d+)/))==null?void 0:A[1])||"",N=()=>{const o=g||j;if(!c||!o)return;const w=l.total||0,I=l.failed>0?"❌":"✅",R=l.failed>0?"FAILED":"PASSED",H=w>0?Math.round(l.passed/w*100):0,$={passed:"✅",failed:"❌",blocked:"🚫",skipped:"⏭",not_run:"⬜",in_progress:"🔄"},Q=h.map(k=>`${$[k.status]||"⬜"} ${k.testCaseTitle||"Unknown"} — ${(k.status||"not_run").replace("_"," ").toUpperCase()}`).join(`
|
|
4
|
+
`),V=[`${I} Testver Test Execution — ${R}`,"",`Plan: ${s}`,`Cycle: ${a}`,`Date: ${Bt(new Date)}`,"",`Summary: ${l.passed} passed, ${l.failed} failed, ${l.skipped} skipped, ${l.blocked} blocked (${w} total)`,`Pass Rate: ${H}%`,"","Test Cases:",Q].join(`
|
|
5
|
+
`);u.mutate({connectorId:c,issueKey:o,comment:V},{onSuccess:()=>y(!0)})};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-blue-500/20 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-blue-500/15 flex items-center justify-center",children:e.jsx(Kt,{className:"w-4 h-4 text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-200",children:"Publish Results to JIRA"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Post execution results as a comment on a JIRA ticket"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:g||j,onChange:o=>p(o.target.value),placeholder:"PROJ-123",className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 w-32 focus:outline-none focus:ring-1 focus:ring-brand-500 font-mono"}),e.jsx("button",{onClick:N,disabled:u.isPending||f||!(g||j),className:`flex items-center gap-1.5 px-4 py-1.5 text-sm font-medium rounded-lg transition-colors ${f?"bg-emerald-500/15 text-emerald-400 border border-emerald-500/20":"bg-blue-600 hover:bg-blue-500 text-white disabled:opacity-50"}`,children:u.isPending?e.jsx(se,{size:14,className:"animate-spin"}):f?e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:14})," Published"]}):e.jsxs(e.Fragment,{children:[e.jsx(Sa,{size:14})," Publish"]})})]})]}),u.isError&&e.jsx("p",{className:"text-xs text-red-400 mt-2",children:((x=u.error)==null?void 0:x.message)||"Failed to publish"})]})}export{kr as TestPlansPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s}from"./vendor-react-CTbHBddL.js";import{a as $}from"./formatDate-T65-Y6Mi.js";function L(e,r=new Date){const l=e.totalCredits??0,m=e.usedCredits??0,t=e.remainingCredits??0,n=e.status==="suspended",a=e.status==="paused",i=!n&&!a&&(e.status==="expired"||!!e.paidThrough&&new Date(e.paidThrough)<=r),p=n||i,d=e.cycleAllowanceCredits??l,g=Math.min(e.cycleUsedCredits??m,d),y=i?0:Math.max(0,d-g),x=i?1:d>0?Math.min(1,g/d):0,k=a?"bg-amber-400":t<=0?"bg-red-500":x>=.9?"bg-red-400":x>=.75?"bg-amber-400":"bg-sky-400",c=e.reserveCredits??0,h=e.reserveBoughtCredits??0,f=e.reserveTankCredits??0,j=h>0||c>0,u=Math.max(f>0?f:h,c),w=u>0?Math.min(1,Math.max(0,u-c)/u):0,N=p&&!e.active?"banked — usable after renewal":"never expires";let o=null;if(a){const P=e.seatPausedShareCredits?`, with ${e.seatPausedShareCredits.toLocaleString()} monthly credits,`:"";o={tone:"amber",text:`Your seat in ${e.teamName||"your team"} is paused — AI requests are off. You'll get it back${P} when the team owner gives you a seat.`}}else p?n?o={tone:"red",text:"Plan suspended — AI requests are paused. Contact support."}:e.active?o={tone:"amber",text:"Plan expired — AI keeps running on your extra usage reserve. Renew for monthly plan credits."}:o={tone:"red",text:`Plan expired — AI requests are paused.${c>0?" Your reserve stays banked until you renew.":""}`}:t<=0&&(o={tone:"red",text:"Credits used up — AI requests are paused."});const C=(t<=0||x>=.85||i)&&!n&&!a&&e.billingUrl?{label:i?"Renew at testver.com →":"Top up at testver.com →",href:e.billingUrl}:null;return{total:l,remaining:t,suspended:n,seatPaused:a,planExpired:i,planInactive:p,planTotal:d,planUsed:g,planLeft:y,usedFrac:x,barColor:k,hasReserve:j,reserveLeft:c,reserveDenom:u,reserveFrac:w,reserveNote:N,notice:o,link:C}}function v({frac:e,color:r}){return s.jsx("div",{className:"mt-2 h-1.5 rounded-full bg-black/[0.06] dark:bg-white/[0.08] overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${r}`,style:{width:`${Math.round(e*100)}%`}})})}function b({tone:e,children:r}){const l=e==="ok"?"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-400":"bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-300";return s.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-[11px] font-semibold whitespace-nowrap ${l}`,children:r})}function I({data:e,formatDay:r=t=>$(t),statusBadge:l=!1,className:m=""}){var a;const t=L(e),n=[(a=e.plan)!=null&&a.name?`${e.plan.name} plan`:null,e.teamName||null,t.planExpired?null:`${t.planUsed.toLocaleString()} used this cycle`,e.paidThrough?`${t.planExpired?"ended":"valid until"} ${r(e.paidThrough)}`:null].filter(Boolean).join(" · ");return s.jsxs("div",{className:`space-y-3.5 ${m}`,children:[s.jsxs("div",{"data-testid":"ai-plan-credits",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-0.5 text-sm",children:[s.jsxs("span",{className:"inline-flex items-center gap-2 font-medium text-gray-800 dark:text-gray-200",children:["Plan credits",l&&(t.planInactive||t.seatPaused)&&s.jsx(b,{tone:"warn",children:t.seatPaused?"Seat paused":t.suspended?"Suspended":"Expired"})]}),s.jsxs("span",{className:"ml-auto text-gray-500 dark:text-gray-400",children:[s.jsx("span",{className:"font-semibold text-gray-900 dark:text-gray-100",children:t.planLeft.toLocaleString()})," of ",t.planTotal.toLocaleString()," left"]})]}),s.jsx(v,{frac:t.usedFrac,color:t.barColor}),n&&s.jsx("div",{className:"mt-1.5 text-[13px] text-gray-500 dark:text-gray-400",children:n})]}),t.hasReserve&&s.jsxs("div",{"data-testid":"ai-reserve-credits",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-0.5 text-sm",children:[s.jsxs("span",{className:"inline-flex items-center gap-2 font-medium text-emerald-700 dark:text-emerald-400",children:["Extra usage reserve",e.usingReserve&&s.jsx(b,{tone:"ok",children:"In use now"})]}),s.jsxs("span",{className:"ml-auto text-gray-500 dark:text-gray-400",children:[s.jsx("span",{className:"font-semibold text-gray-900 dark:text-gray-100",children:t.reserveLeft.toLocaleString()})," of ",t.reserveDenom.toLocaleString()," left"]})]}),s.jsx(v,{frac:t.reserveFrac,color:"bg-emerald-400"}),s.jsxs("div",{className:"mt-1.5 text-[13px] text-gray-500 dark:text-gray-400",children:[t.reserveNote.charAt(0).toUpperCase()+t.reserveNote.slice(1),t.planInactive?"":" · spent only after your plan credits run out"]})]}),(e.nextPlan||t.notice||t.link)&&s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[13px]",children:[e.nextPlan&&s.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["Renewed ✓ ",e.nextPlan.name," starts ",r(e.nextPlan.startsAt)]}),t.notice&&s.jsx("span",{className:`font-medium ${t.notice.tone==="amber"?"text-amber-700 dark:text-amber-400":"text-red-600 dark:text-red-400"}`,children:t.notice.text}),t.link&&s.jsx("a",{href:t.link.href,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-sky-600 dark:text-sky-300 hover:text-sky-700 dark:hover:text-sky-200 underline underline-offset-2",children:t.link.label})]})]})}export{I as T,L as t};
|