@testver/testver 1.4.3 → 1.5.1
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/LICENSE +88 -69
- package/README.md +6 -2
- package/bin/testver.js +9 -1
- package/dist/index.js +38415 -21751
- package/package.json +179 -178
- package/src/ui/static/agents/antigravity.svg +76 -0
- package/src/ui/static/agents/codex.svg +3 -0
- package/src/ui/static/agents/gemini.svg +1 -0
- package/src/ui/static/agents/opencode.svg +4 -0
- package/src/ui/static/agents/vscode.svg +17 -0
- package/src/ui/static/assets/{AIPanel-KQFq4c0Q.js → AIPanel-RWO8Cd9w.js} +32 -32
- package/src/ui/static/assets/{AIRecordPanel-CAs8fXyS.js → AIRecordPanel-DnreS585.js} +40 -40
- package/src/ui/static/assets/{AIStreamUI-p_sMTEDQ.js → AIStreamUI-C1gHJtlF.js} +9 -9
- package/src/ui/static/assets/{AITestGenPage-CHaHfmu4.js → AITestGenPage-C8bWUelu.js} +5 -5
- package/src/ui/static/assets/{APITestingPage-BSGJY_hd.js → APITestingPage-DwL67hqL.js} +19 -19
- package/src/ui/static/assets/AboutPage-CynLB95E.js +1 -0
- package/src/ui/static/assets/AccessTokensTab-BdevOmpE.js +1 -0
- package/src/ui/static/assets/AdvancedPage-BeM7aB8b.js +3 -0
- package/src/ui/static/assets/{AnalyticsPage-Lm8noJqC.js → AnalyticsPage-C5ddYfRk.js} +1 -1
- package/src/ui/static/assets/AuditLogPage-DYcUdJoj.js +1 -0
- package/src/ui/static/assets/{ChangesSummary-Cu0_4Ucf.js → ChangesSummary-BjNMwGIZ.js} +3 -3
- package/src/ui/static/assets/{CodeMapPage-uEjuo3fk.js → CodeMapPage-BQOEtv-R.js} +3 -3
- package/src/ui/static/assets/{ConfirmDialog-DtotgVmI.js → ConfirmDialog-D_N9188T.js} +1 -1
- package/src/ui/static/assets/{CoveragePage-jNkQJA1P.js → CoveragePage-8bDSphY1.js} +2 -2
- package/src/ui/static/assets/{CronBuilder-D2fERHt9.js → CronBuilder-C7_JADb7.js} +1 -1
- package/src/ui/static/assets/{Dashboard-BaIj_IdQ.js → Dashboard-B22yRPyV.js} +1 -1
- package/src/ui/static/assets/{DefectsPage-DH0njYFG.js → DefectsPage-Arv4Ac-b.js} +72 -72
- package/src/ui/static/assets/{EmptyState-utxlJ0fu.js → EmptyState-BShNSbLf.js} +1 -1
- package/src/ui/static/assets/{ExportButton-ouKqn9CU.js → ExportButton-xrS_AnfS.js} +1 -1
- package/src/ui/static/assets/{FileViewer-mU3JloJ6.js → FileViewer-Bcr9T1jW.js} +18 -18
- package/src/ui/static/assets/{GitPage-TrX-RqNC.js → GitPage-DXL2Sv40.js} +12 -12
- package/src/ui/static/assets/{ImportExportPage-CIhK_raX.js → ImportExportPage-BcjzRd7T.js} +36 -36
- package/src/ui/static/assets/{JiraPushDialog-DgEZS-0u.js → JiraPushDialog-DNYU9Ce0.js} +1 -1
- package/src/ui/static/assets/{KpiTile-BHLE3HVj.js → KpiTile-BKlWqjgN.js} +1 -1
- package/src/ui/static/assets/{LiveExecutionView-CaIf7Jux.js → LiveExecutionView-1LlyEDEe.js} +1 -1
- package/src/ui/static/assets/{MediaModal-DNM45Uz2.js → MediaModal-Dyy_iHl9.js} +1 -1
- package/src/ui/static/assets/MobileRunPicker-Cf5rm469.js +1 -0
- package/src/ui/static/assets/MobileRunTarget-C4M4YJJh.js +6 -0
- package/src/ui/static/assets/{ModuleExplorer-rni7JbsL.js → ModuleExplorer-BKVbxFZK.js} +1 -1
- package/src/ui/static/assets/{OutputPage-Cn2WCpJ6.js → OutputPage-Bi-28tJi.js} +1 -1
- package/src/ui/static/assets/PipelinesPanel-BtO3iSJ4.js +1 -0
- package/src/ui/static/assets/{ProfilePage-BKNdkSnx.js → ProfilePage-BgZ4VDC-.js} +1 -1
- package/src/ui/static/assets/{ProjectExplorer-5e7J8t-o.js → ProjectExplorer-BVGbmVP7.js} +1 -1
- package/src/ui/static/assets/{RemoteFileStrip-C1S2aclP.js → RemoteFileStrip-dzPInzgb.js} +1 -1
- package/src/ui/static/assets/{ReportCard-D4EElEe9.js → ReportCard-LOf1PXlb.js} +2 -2
- package/src/ui/static/assets/{ReportFullView-2w2ysKRg.js → ReportFullView-Ce4OI8lf.js} +1 -1
- package/src/ui/static/assets/{ReportsPage-9Fx-IEwV.js → ReportsPage-DFxCQ8cY.js} +48 -48
- package/src/ui/static/assets/{ResultsPage-DPkfGh-K.js → ResultsPage-DD-uj8gk.js} +115 -115
- package/src/ui/static/assets/{RunState-CRuS_bC2.js → RunState-DDwFB4tA.js} +1 -1
- package/src/ui/static/assets/{RunTargets-CPKBrefj.js → RunTargets-CkIpY3v3.js} +1 -1
- package/src/ui/static/assets/ScriptMappingPage-DQQoR6sR.js +1 -0
- package/src/ui/static/assets/{SearchableDevicePicker-DubIldKj.js → SearchableDevicePicker-CenIxD7b.js} +1 -1
- package/src/ui/static/assets/{SettingsPage-BuZrrlW2.js → SettingsPage-DAV_0y0m.js} +83 -83
- package/src/ui/static/assets/{SharedReportView-ig5hECRk.js → SharedReportView-CqSLFKT1.js} +1 -1
- package/src/ui/static/assets/{SourcesPage-BPkqRqkC.js → SourcesPage-BvqC9oKw.js} +14 -14
- package/src/ui/static/assets/TestExplorerPage-Bdnll77k.js +7 -0
- package/src/ui/static/assets/{TestManagementPage-DJiWpCne.js → TestManagementPage-CCNE688A.js} +10 -10
- package/src/ui/static/assets/{TestPlansPage-G1lvK1C0.js → TestPlansPage-T6D25i6-.js} +5 -5
- package/src/ui/static/assets/{TestverCreditsRing-CEBSy3w3.js → TestverCreditsRing-CoDk5eAS.js} +1 -1
- package/src/ui/static/assets/TestverMcpPage-Dte0qSXp.js +34 -0
- package/src/ui/static/assets/{UncommittedDiffViewer-FKvUZcRi.js → UncommittedDiffViewer-BNroxCoo.js} +2 -2
- package/src/ui/static/assets/{UserManagementPage-gDGhaHE4.js → UserManagementPage-BU4MuDJZ.js} +10 -10
- package/src/ui/static/assets/{WorkflowsPage-BACdnU-1.js → WorkflowsPage-BP5k7AqE.js} +83 -83
- package/src/ui/static/assets/clipboard-BIEd7Ccc.js +1 -0
- package/src/ui/static/assets/{hiddenLlmProviders-DzwaR-b9.js → hiddenLlmProviders-BPORgy-e.js} +1 -1
- package/src/ui/static/assets/index-BlA8ntjb.js +47 -0
- package/src/ui/static/assets/index-Co4_SlGD.css +1 -0
- package/src/ui/static/assets/{reportMeta-3kxT7BIT.js → reportMeta-B9ZRW6ts.js} +1 -1
- package/src/ui/static/assets/runSelected-BoPm1sz-.js +1 -0
- package/src/ui/static/assets/{useFeatureFlags-DrhvBp0C.js → useFeatureFlags-B4Otsv-N.js} +1 -1
- package/src/ui/static/assets/{useJiraConnector-Dwj69Rfh.js → useJiraConnector--JZhbYrT.js} +1 -1
- package/src/ui/static/assets/{useOwnership-C1CmzcvJ.js → useOwnership-BhPOiYzy.js} +1 -1
- package/src/ui/static/assets/useSuites-GN_K2mHc.js +1 -0
- package/src/ui/static/assets/{useTestExplorer-CUqC18DV.js → useTestExplorer-BGhkGHKy.js} +1 -1
- package/src/ui/static/assets/{useTestLifecycle-C2S_vaX2.js → useTestLifecycle-DX5ES6x8.js} +1 -1
- package/src/ui/static/assets/{useTestManagement-DW6AW2mt.js → useTestManagement-ommXjx0q.js} +2 -2
- package/src/ui/static/assets/{useTestResults-yjH1aUy-.js → useTestResults-DWjvm8gm.js} +1 -1
- package/src/ui/static/assets/{vendor-icons-D_Dmmj8d.js → vendor-icons-Cm92aSc5.js} +1426 -1416
- package/src/ui/static/index.html +479 -479
- package/src/ui/static/assets/AboutPage-CDa24SCJ.js +0 -1
- package/src/ui/static/assets/AdvancedPage-BqXP0FLg.js +0 -3
- package/src/ui/static/assets/AuditLogPage-BvldSIik.js +0 -1
- package/src/ui/static/assets/MobileRunPicker-DFKm6_nU.js +0 -1
- package/src/ui/static/assets/MobileRunTarget-DHDoDZ_F.js +0 -6
- package/src/ui/static/assets/PipelinesPanel-D6zWcLtD.js +0 -1
- package/src/ui/static/assets/ScriptMappingPage-C3K_uyf0.js +0 -1
- package/src/ui/static/assets/TestExplorerPage-C_jl93GR.js +0 -7
- package/src/ui/static/assets/index-D6sQYc_0.js +0 -47
- package/src/ui/static/assets/index-aInN0yoR.css +0 -1
- package/src/ui/static/assets/runSelected-WlgnZcSF.js +0 -1
- package/src/ui/static/assets/useSuites-V0AxZYex.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as C,j as e,L as te,R as Te}from"./vendor-react-DOVfxdUy.js";import{E as Le}from"./ExportButton-
|
|
2
|
-
`),S=new Blob([O],{type:"text/csv;charset=utf-8"}),E=URL.createObjectURL(S),T=`coverage-matrix_${a.sourceTitle.replace(/[^a-z0-9]+/gi,"-").toLowerCase()||a.sourceId}.csv`,d=document.createElement("a");d.href=E,d.download=T,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(E)},ve=(t,n,w,j="")=>{const S=(t.testCasesByStrategy[n]||[]).length;return S===0?e.jsx("td",{className:`px-1.5 py-2.5 text-center text-gray-700 transition-colors ${j}`,children:e.jsx(se,{size:10,className:"inline"})},`${n}`):e.jsx("td",{className:`px-1.5 py-2.5 text-center transition-colors ${j}`,title:`${S} test case${S===1?"":"s"} for ${n} — expand the row to see them`,children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5",children:[e.jsx(G,{size:12,className:"text-emerald-400"}),e.jsx("span",{className:"text-sm text-gray-200 tabular-nums",children:S})]})},`${n}`)};return e.jsxs("div",{className:"space-y-4 relative",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-brand-500/10 border border-brand-500/20 flex items-center justify-center",children:e.jsx(D,{size:18,className:"text-brand-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-200",children:a.sourceTitle||"Source"}),e.jsxs("p",{className:"text-sm text-gray-500",children:[P.reqCount," requirement",P.reqCount===1?"":"s"," · ",e.jsxs("span",{className:"text-gray-300",children:[P.testCount+a.manuallyLinkedTotal," Test Case",P.testCount+a.manuallyLinkedTotal===1?"":"s"]})," · ",P.testCount," generated",a.manuallyLinkedTotal>0&&e.jsxs("span",{className:"text-amber-400",children:[" · ",a.manuallyLinkedTotal," manually linked"]}),a.legacyCount>0&&e.jsxs("span",{className:"ml-2 text-amber-400",children:["(+ ",a.legacyCount," legacy uncategorized)"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:Ne,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-surface-2 hover:bg-surface-3 text-gray-300 rounded-lg border border-white/10 transition-colors",title:"Export coverage matrix as CSV",children:[e.jsx(Ue,{className:"w-4 h-4"}),"Export CSV"]}),u&&e.jsx("button",{onClick:u,className:"p-1.5 rounded text-gray-400 hover:text-gray-200 hover:bg-surface-2 transition-colors",title:"Close",children:e.jsx(re,{size:16})})]})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[e.jsxs("div",{className:"relative flex-1 min-w-[220px]",children:[e.jsx(ne,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500 pointer-events-none"}),e.jsx("input",{type:"text",value:i,onChange:t=>p(t.target.value),placeholder:"Search requirements or test case titles…",className:"w-full pl-10 pr-3 py-2 text-sm rounded-lg bg-surface-2 border border-white/5 text-gray-200 placeholder-gray-500 focus:outline-none focus:ring-1 focus:ring-brand-500"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-gray-400",children:[e.jsx(Qe,{size:14}),e.jsxs("select",{value:M,onChange:t=>$(t.target.value),className:"px-2.5 py-1.5 text-sm rounded bg-surface-2 border border-white/5 text-gray-200 focus:outline-none focus:ring-1 focus:ring-brand-500",children:[e.jsx("option",{value:"recent",children:"Recently generated"}),e.jsx("option",{value:"coverage-asc",children:"Least covered first"}),e.jsx("option",{value:"priority-desc",children:"Highest priority first"}),e.jsx("option",{value:"tests-desc",children:"Most tests first"}),e.jsx("option",{value:"tests-asc",children:"Fewest tests first"})]})]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-sm text-gray-400 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:A,onChange:t=>I(t.target.checked),className:"rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),"Uncovered only"]}),a.personas.length>0&&e.jsxs("label",{className:"flex items-center gap-1.5 text-sm text-gray-400 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:f,onChange:t=>m(t.target.checked),className:"rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),e.jsx(oe,{size:13})," Per-persona columns"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-sm text-gray-500 mr-1",children:"Priority:"}),["critical","high","medium","low"].map(t=>{const n=r.has(t);return e.jsx("button",{onClick:()=>q(r,t,v),className:`text-sm px-3 py-1 rounded-full border transition-colors ${n?"bg-amber-500/20 text-amber-200 border-amber-400/40":"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"}`,children:t},t)})]}),a.personas.length>0&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-sm text-gray-500 mr-1",children:"Persona:"}),a.personas.map(t=>{const n=y.has(t);return e.jsx("button",{onClick:()=>q(y,t,g),className:`text-sm px-3 py-1 rounded-full border transition-colors ${n?"bg-violet-500/20 text-violet-200 border-violet-400/40":"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"}`,children:t},t)})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-500",children:[e.jsxs("span",{children:["Showing ",e.jsx("span",{className:"text-gray-300",children:z.length})," of ",e.jsx("span",{className:"text-gray-300",children:a.requirements.length})," requirements"]}),je&&e.jsx("button",{onClick:ce,className:"text-brand-400 hover:text-brand-300",children:"Clear filters"})]})]}),z.length===0&&a.manuallyLinkedTotal===0?e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-12 text-center",children:[e.jsx(H,{className:"w-8 h-8 mx-auto mb-3 text-amber-400"}),e.jsx("p",{className:"text-sm text-gray-400",children:"No requirements match the current filters."}),e.jsx("button",{onClick:ce,className:"mt-3 text-sm text-brand-400 hover:text-brand-300",children:"Clear filters"})]}):e.jsxs("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:"text-xs uppercase tracking-wide text-gray-500 border-b border-white/5",children:[e.jsx("th",{className:"text-left font-medium px-3 py-2.5 sticky left-0 bg-surface-1 z-10",children:"Requirement"}),e.jsx("th",{className:"text-right font-medium px-2 py-2.5",children:"Tests"}),e.jsx("th",{className:"text-right font-medium px-2 py-2.5",children:"Last Gen"}),X.filter(t=>a.strategies.includes(t)).map(t=>e.jsx("th",{className:"text-center font-medium px-1.5 py-2.5",title:t,children:We[t]||t},t)),f&&a.personas.map(t=>e.jsx("th",{className:"text-center font-medium px-1.5 py-2.5 border-l border-white/5",title:`Persona: ${t}`,children:e.jsx("div",{className:"text-violet-300",children:t})},`persona-${t}`))]})}),e.jsxs("tbody",{children:[z.map(t=>{Math.max(1,a.strategies.length),a.strategies.filter(d=>(t.byStrategy[d]||0)>0).length;const n=Date.now()-(t.lastGeneratedAt||0),w=t.lastGeneratedAt?n<6e4?"just now":n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`:"—",j=x.has(t.bucketKey),L=new Map;for(const d of Object.values(t.testCasesByStrategy))for(const N of d)L.set(N.priority,(L.get(N.priority)||0)+1);const O=o===t.bucketKey,S=j||O,E=S?"bg-surface-2":"",T=S?"bg-surface-2":"bg-surface-1";return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onMouseEnter:()=>k(t.bucketKey),onMouseLeave:()=>k(null),className:"border-b border-white/5 transition-colors",children:[e.jsx("td",{className:`px-3 py-2.5 sticky left-0 z-10 max-w-md transition-colors ${T}`,children:e.jsxs("button",{onClick:()=>B(t.bucketKey),className:"flex items-start gap-1.5 text-left w-full",children:[j?e.jsx(Z,{size:13,className:"text-gray-400 flex-shrink-0 mt-0.5"}):e.jsx(Q,{size:13,className:"text-gray-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:t.requirementId&&e.jsx("span",{className:"font-mono text-brand-300 text-sm",children:t.requirementId})}),e.jsx("div",{className:"text-gray-300 text-sm truncate",title:t.title,children:t.title}),t.sourceQuote&&t.sourceQuote.length>t.title.length&&e.jsxs("div",{className:"text-xs text-gray-500 truncate mt-0.5",title:t.sourceQuote,children:["“",t.sourceQuote.slice(0,100),t.sourceQuote.length>100?"…":"","”"]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[Array.from(L.entries()).map(([d,N])=>e.jsxs("span",{className:`text-[10px] px-1.5 py-0 rounded ${W[d]||"text-gray-500"}`,children:[d[0],":",N]},d)),t.personas.map(d=>e.jsx("span",{className:"text-[10px] px-1.5 py-0 rounded bg-violet-500/15 text-violet-300",children:d},d))]})]})]})}),e.jsx("td",{className:`px-2 py-2.5 text-right tabular-nums text-sm text-gray-300 transition-colors ${E}`,children:t.totalTests}),e.jsxs("td",{className:`px-2 py-2.5 text-right text-xs text-gray-500 transition-colors ${E}`,title:t.lastGeneratedAt?Fe(t.lastGeneratedAt):"",children:[e.jsx(He,{size:11,className:"inline mr-0.5"}),w]}),X.filter(d=>a.strategies.includes(d)).map(d=>ve(t,d,void 0,E)),f&&a.personas.map(d=>{const N=Object.values(t.testCasesByStrategy).flat().filter(R=>R.persona===d).length;return N===0?e.jsx("td",{className:`px-1.5 py-2.5 text-center text-gray-700 border-l border-white/5 transition-colors ${E}`,children:e.jsx(se,{size:10,className:"inline"})},`persona-${d}`):e.jsx("td",{className:`px-1.5 py-2.5 text-center border-l border-white/5 transition-colors ${E}`,title:`${N} test case${N===1?"":"s"} for persona ${d} — expand the row to see them`,children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5",children:[e.jsx(oe,{size:11,className:"text-violet-400"}),e.jsx("span",{className:"text-sm text-gray-200 tabular-nums",children:N})]})},`persona-${d}`)})]},t.bucketKey),j&&e.jsx("tr",{onMouseEnter:()=>k(t.bucketKey),onMouseLeave:()=>k(null),className:"border-b border-white/5 bg-surface-2",children:e.jsx("td",{colSpan:3+X.filter(d=>a.strategies.includes(d)).length+(f?a.personas.length:0),className:"px-4 py-4",children:e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:Object.entries(t.testCasesByStrategy).map(([d,N])=>e.jsxs("div",{className:"bg-surface-1 rounded-lg border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2.5 bg-white/5 border-b border-white/10",children:[e.jsx("span",{className:"font-mono text-sm text-gray-200 font-semibold",children:d}),e.jsxs("span",{className:"text-xs text-gray-500 tabular-nums",children:[N.length," test",N.length===1?"":"s"]})]}),e.jsx("div",{className:"divide-y divide-white/5",children:N.map(R=>e.jsxs(te,{to:`/test-cases?tcId=${R.id}`,className:"flex items-center gap-2.5 px-3 py-2.5 hover:bg-surface-2/60 transition-colors",title:R.title,children:[e.jsx("span",{className:"font-mono text-xs text-gray-500 flex-shrink-0",children:R.id}),e.jsx("span",{className:"text-sm text-gray-300 hover:text-brand-300 truncate flex-1",children:R.title}),R.priority&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium flex-shrink-0 ${W[R.priority]||""}`,children:R.priority}),R.persona&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-violet-500/15 text-violet-300 flex-shrink-0",children:R.persona})]},R.id))})]},d))})})},`${t.bucketKey}-expanded`)]})}),a.manuallyLinkedTotal>0&&(()=>{const t="__manually_linked__",n=x.has(t),j=n||o===t,L=j?"bg-surface-2":"",O=j?"bg-surface-2":"bg-surface-1",S=new Map;for(const T of a.manuallyLinkedRequirements)for(const d of T.testCases)S.set(d.priority,(S.get(d.priority)||0)+1);const E=X.filter(T=>a.strategies.includes(T)).length+(f?a.personas.length:0);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onMouseEnter:()=>k(t),onMouseLeave:()=>k(null),className:"border-b border-white/5 transition-colors",children:[e.jsx("td",{className:`px-3 py-2.5 sticky left-0 z-10 max-w-md transition-colors ${O}`,children:e.jsxs("button",{onClick:()=>B(t),className:"flex items-start gap-1.5 text-left w-full",children:[n?e.jsx(Z,{size:13,className:"text-gray-400 flex-shrink-0 mt-0.5"}):e.jsx(Q,{size:13,className:"text-gray-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx("span",{className:"text-amber-300 text-xs uppercase tracking-wide font-semibold",children:"Manually Linked"})}),e.jsxs("div",{className:"text-gray-300 text-sm mt-0.5",children:[a.manuallyLinkedTotal," test case",a.manuallyLinkedTotal===1?"":"s"," across ",a.manuallyLinkedRequirements.length," requirement",a.manuallyLinkedRequirements.length===1?"":"s"]}),e.jsx("div",{className:"text-xs text-gray-500 mt-0.5",children:"Linked from the Requirements tab — not auto-generated"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Array.from(S.entries()).map(([T,d])=>e.jsxs("span",{className:`text-[10px] px-1.5 py-0 rounded ${W[T]||"text-gray-500"}`,children:[T[0],":",d]},T))})]})]})}),e.jsx("td",{className:`px-2 py-2.5 text-right tabular-nums text-sm text-gray-300 transition-colors ${L}`,children:a.manuallyLinkedTotal}),e.jsx("td",{className:`px-2 py-2.5 text-right text-xs text-gray-500 transition-colors ${L}`,children:"—"}),E>0&&e.jsx("td",{colSpan:E,className:`px-1.5 py-2.5 text-center text-gray-700 text-xs transition-colors ${L}`,children:"(no taxonomy data)"})]},t),n&&e.jsx("tr",{onMouseEnter:()=>k(t),onMouseLeave:()=>k(null),className:"border-b border-white/5 bg-surface-2",children:e.jsx("td",{colSpan:3+E,className:"px-4 py-4",children:e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:a.manuallyLinkedRequirements.map(T=>e.jsxs("div",{className:"bg-surface-1 rounded-lg border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2.5 bg-white/5 border-b border-white/10",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"font-mono text-sm text-amber-300 font-semibold flex-shrink-0",children:T.externalId}),e.jsx("span",{className:"text-sm text-gray-200 truncate",title:T.title,children:T.title})]}),e.jsxs("span",{className:"text-xs text-gray-500 tabular-nums flex-shrink-0",children:[T.testCases.length," test",T.testCases.length===1?"":"s"]})]}),e.jsx("div",{className:"divide-y divide-white/5",children:T.testCases.map(d=>e.jsxs(te,{to:`/test-cases?tcId=${d.id}`,className:"flex items-center gap-2.5 px-3 py-2.5 hover:bg-surface-2/60 transition-colors",title:d.title,children:[e.jsx("span",{className:"font-mono text-xs text-gray-500 flex-shrink-0",children:d.id}),e.jsx("span",{className:"text-sm text-gray-300 hover:text-brand-300 truncate flex-1",children:d.title}),d.priority&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium flex-shrink-0 ${W[d.priority]||""}`,children:d.priority}),d.persona&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-violet-500/15 text-violet-300 flex-shrink-0",children:d.persona})]},d.id))})]},T.requirementId))})})},`${t}-expanded`)]})})()]})]})}),e.jsxs("div",{className:"flex flex-wrap gap-3 px-3 py-2 border-t border-white/5 text-[10px] text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(G,{size:10,className:"text-emerald-400"})," covered"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(se,{size:8,className:"text-gray-700"})," no tests"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Q,{size:10})," click a row to expand and see all test cases"]})]})]})]})}const et={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"},de={passed:{color:"text-emerald-400 bg-emerald-500/15",icon:G,label:"Passed"},failed:{color:"text-red-400 bg-red-500/15",icon:ye,label:"Failed"},not_run:{color:"text-gray-400 bg-gray-500/15",icon:H,label:"Not Run"}},xe={full:"text-emerald-400 bg-emerald-500/15",partial:"text-amber-400 bg-amber-500/15",none:"text-red-400 bg-red-500/15"},fe={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"},tt=[{key:"requirements",label:"Requirements",icon:D},{key:"traceability",label:"Traceability Matrix",icon:ge},{key:"coverage",label:"Coverage Dashboard",icon:be},{key:"orphans",label:"Orphan Detection",icon:ee}];function K(s){return s.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase())}function me(s){return s?new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"-"}function V({priority:s}){const u=et[s]||"bg-gray-500/20 text-gray-300";return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${u}`,children:K(s)})}function st({result:s}){const u=de[s]||de.not_run,l=u.icon;return e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${u.color}`,children:[e.jsx(l,{size:12}),u.label]})}function at({level:s}){const u={full:"Fully Covered",partial:"Partially Covered",none:"Not Covered"},l=xe[s]||xe.none;return e.jsx("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${l}`,children:u[s]||"Unknown"})}function U({label:s="Loading..."}){return e.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-gray-400",children:[e.jsx(le,{size:20,className:"animate-spin"}),e.jsx("span",{children:s})]})}function _({icon:s,title:u,subtitle:l}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-surface-2 flex items-center justify-center mb-3",children:e.jsx(s,{size:24,className:"text-gray-500"})}),e.jsx("p",{className:"text-gray-300 font-medium",children:u}),l&&e.jsx("p",{className:"text-gray-500 text-sm mt-1 max-w-sm",children:l})]})}function rt({reqId:s,onLink:u}){const{data:l,isLoading:b}=he(s),h=Oe();if(b)return e.jsx(U,{label:"Loading linked test cases..."});const i=(l==null?void 0:l.testCases)||(Array.isArray(l)?l:[]);return e.jsx("div",{className:"px-4 pb-4",children: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-3",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-300",children:["Linked Test Cases (",i.length,")"]}),e.jsxs("button",{onClick:u,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(ie,{size:12})," Link Test Cases"]})]}),i.length===0?e.jsx("p",{className:"text-gray-500 text-sm py-4 text-center",children:"No test cases linked yet."}):e.jsx("div",{className:"space-y-1.5",children:i.map(p=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 rounded-lg bg-surface-1 border border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-gray-500 font-mono",children:p.id}),e.jsx("span",{className:"text-sm text-gray-200",children:p.title}),p.priority&&e.jsx(V,{priority:p.priority})]}),e.jsx("button",{onClick:()=>h.mutate({reqId:s,testCaseIds:[p.id]}),disabled:h.isPending,className:"text-gray-500 hover:text-red-400 transition-colors p-1",title:"Unlink",children:e.jsx(ee,{size:14})})]},p.id))})]})})}function nt({initial:s,onClose:u}){const l=Ee(),b=qe(),h=!!s,[i,p]=C.useState({externalId:(s==null?void 0:s.externalId)||"",title:(s==null?void 0:s.title)||"",description:(s==null?void 0:s.description)||"",priority:(s==null?void 0:s.priority)||"medium",source:(s==null?void 0:s.source)||"",status:(s==null?void 0:s.status)||"active"}),r=l.isPending||b.isPending,v=()=>{i.title.trim()&&(h?b.mutate({id:s.id,data:i},{onSuccess:u}):l.mutate(i,{onSuccess:u}))};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:u,children:e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 w-full max-w-lg mx-4 shadow-2xl",onClick:y=>y.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/5",children:[e.jsx("h3",{className:"text-gray-200 font-semibold",children:h?"Edit Requirement":"New Requirement"}),e.jsx("button",{onClick:u,className:"text-gray-500 hover:text-gray-300 transition-colors",children:e.jsx(re,{size:18})})]}),e.jsxs("div",{className:"px-5 py-4 space-y-4 max-h-[60vh] overflow-y-auto",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"External ID"}),e.jsx("input",{value:i.externalId,onChange:y=>p(g=>({...g,externalId:y.target.value})),placeholder:"e.g. REQ-001",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:["Title ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{value:i.title,onChange:y=>p(g=>({...g,title:y.target.value})),placeholder:"Requirement title",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"Description"}),e.jsx("textarea",{value:i.description,onChange:y=>p(g=>({...g,description:y.target.value})),rows:3,placeholder:"Describe the requirement...",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50 resize-none"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"Priority"}),e.jsxs("select",{value:i.priority,onChange:y=>p(g=>({...g,priority:y.target.value})),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-brand-500/50",children:[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("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"Status"}),e.jsxs("select",{value:i.status,onChange:y=>p(g=>({...g,status:y.target.value})),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-brand-500/50",children:[e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"draft",children:"Draft"}),e.jsx("option",{value:"deprecated",children:"Deprecated"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"Source"}),e.jsx("input",{value:i.source,onChange:y=>p(g=>({...g,source:y.target.value})),placeholder:"e.g. Jira, Confluence, PRD",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:u,className:"px-4 py-2 text-sm font-medium text-gray-400 hover:text-gray-200 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:v,disabled:r||!i.title.trim(),className:"flex items-center gap-1.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg px-4 py-2 text-sm font-medium transition-colors",children:[r?e.jsx(le,{size:14,className:"animate-spin"}):e.jsx(Xe,{size:14}),h?"Update":"Create"]})]})]})})}function it({reqId:s,onClose:u}){const{data:l,isLoading:b}=De(),{data:h}=he(s),i=Be(),[p,r]=C.useState(""),[v,y]=C.useState(new Set),g=(h==null?void 0:h.testCases)||(Array.isArray(h)?h:[]),A=C.useMemo(()=>new Set(g.map(f=>f.id)),[g]),I=C.useMemo(()=>((l==null?void 0:l.testCases)||(Array.isArray(l)?l:[])).filter(m=>{var x,c;if(A.has(m.id))return!1;if(p){const o=p.toLowerCase();return((x=m.title)==null?void 0:x.toLowerCase().includes(o))||((c=m.id)==null?void 0:c.toLowerCase().includes(o))}return!0}),[l,A,p]),M=f=>{y(m=>{const x=new Set(m);return x.has(f)?x.delete(f):x.add(f),x})},$=()=>{v.size!==0&&i.mutate({reqId:s,testCaseIds:Array.from(v)},{onSuccess:u})};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:u,children:e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 w-full max-w-xl mx-4 shadow-2xl",onClick:f=>f.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/5",children:[e.jsx("h3",{className:"text-gray-200 font-semibold",children:"Link Test Cases"}),e.jsx("button",{onClick:u,className:"text-gray-500 hover:text-gray-300 transition-colors",children:e.jsx(re,{size:18})})]}),e.jsx("div",{className:"px-5 py-3 border-b border-white/5",children:e.jsxs("div",{className:"relative",children:[e.jsx(ne,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:p,onChange:f=>r(f.target.value),placeholder:"Search test cases...",className:"w-full bg-surface-2 border border-white/10 rounded-lg pl-9 pr-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50"})]})}),e.jsx("div",{className:"px-5 py-3 max-h-[40vh] overflow-y-auto",children:b?e.jsx(U,{label:"Loading test cases..."}):I.length===0?e.jsx("p",{className:"text-gray-500 text-sm text-center py-8",children:"No available test cases to link."}):e.jsx("div",{className:"space-y-1.5",children:I.map(f=>e.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-surface-2 cursor-pointer transition-colors",children:[e.jsx("input",{type:"checkbox",checked:v.has(f.id),onChange:()=>M(f.id),className:"rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500/30"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:f.title}),e.jsx("p",{className:"text-xs text-gray-500 font-mono",children:f.id})]}),f.priority&&e.jsx(V,{priority:f.priority})]},f.id))})}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-t border-white/5",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:[v.size," selected"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:u,className:"px-4 py-2 text-sm font-medium text-gray-400 hover:text-gray-200 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:$,disabled:v.size===0||i.isPending,className:"flex items-center gap-1.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg px-4 py-2 text-sm font-medium transition-colors",children:[i.isPending?e.jsx(le,{size:14,className:"animate-spin"}):e.jsx(ie,{size:14}),"Link Selected"]})]})]})]})})}function lt(){const[s,u]=C.useState(""),[l,b]=C.useState(""),[h,i]=C.useState(null),[p,r]=C.useState(null),[v,y]=C.useState(null),[g]=Re("reqId");C.useEffect(()=>{g&&(r(g),requestAnimationFrame(()=>{var c;return(c=document.getElementById(`req-${g}`))==null?void 0:c.scrollIntoView({block:"center",behavior:"smooth"})}))},[g]);const A=C.useMemo(()=>{const c={};return l&&(c.priority=l),s&&(c.search=s),Object.keys(c).length>0?c:void 0},[l,s]),{data:I,isLoading:M}=Me(A),{data:$}=$e(),f=C.useMemo(()=>{const c=Array.isArray($==null?void 0:$.sources)?$.sources:Array.isArray($)?$:[];return new Map(c.map(o=>[o.id,o.title]))},[$]),m=c=>{const o=/^source:(.+)$/.exec(c||"");return o?f.get(o[1])??"Deleted source":c||"-"};ze();const x=(I==null?void 0:I.requirements)||(Array.isArray(I)?I:[]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 gap-3 flex-wrap",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Requirements"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ne,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:s,onChange:c=>u(c.target.value),placeholder:"Search requirements...",className:"bg-surface-2 border border-white/10 rounded-lg pl-9 pr-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50 w-56"})]}),e.jsx("div",{className:"flex items-center gap-1.5 text-xs text-gray-500",children:e.jsx(Ve,{size:12})}),e.jsxs("select",{value:l,onChange:c=>b(c.target.value),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-xs text-gray-300 focus:outline-none focus:border-brand-500/50",children:[e.jsx("option",{value:"",children:"All Priorities"}),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.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:M?e.jsx(U,{}):x.length===0?e.jsx(_,{icon:D,title:"No requirements found",subtitle:"Requirements are derived from Sources via AI Test Gen. Add a source and generate test cases to populate this list."}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-left",children:[e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider w-8"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"External ID"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Title"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Priority"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Source"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider text-center",children:"Linked TCs"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:x.map(c=>{const o=p===c.id;return e.jsxs(Te.Fragment,{children:[e.jsxs("tr",{id:`req-${c.id}`,className:"group cursor-pointer hover:bg-white/5 transition-colors",onClick:()=>r(o?null:c.id),children:[e.jsx("td",{className:"px-4 py-3 w-8",children:o?e.jsx(Z,{size:14,className:"text-gray-500"}):e.jsx(Q,{size:14,className:"text-gray-500"})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx("span",{className:"text-xs font-mono text-gray-500",children:c.externalId||c.id})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-gray-200 truncate block max-w-xs",children:c.title})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx(V,{priority:c.priority||"medium"})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx("span",{className:"text-xs text-gray-400",title:c.sourceQuote||void 0,children:m(c.source)})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap text-center",children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-gray-400",children:[e.jsx(ie,{size:12})," ",c.linkedTestCaseCount??c.testCaseCount??0]})})]}),o&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"p-0",children:e.jsx(rt,{reqId:c.id,onLink:()=>y(c.id)})})})]},c.id)})})]})}),h&&e.jsx(nt,{initial:h,onClose:()=>i(null)}),v&&e.jsx(it,{reqId:v,onClose:()=>y(null)})]})}function ct({sourceTrace:s,expandedSources:u,setExpandedSources:l}){const b=(s==null?void 0:s.sources)||[];if(b.length===0)return e.jsx(_,{icon:D,title:"No source documents with test cases",subtitle:"Generate test cases from Sources in AI Test Gen to see document-level traceability here."});const h=i=>{l(p=>{const r=new Set(p);return r.has(i)?r.delete(i):r.add(i),r})};return e.jsx("div",{className:"space-y-4",children:b.map(i=>{const p=u.has(i.sourceId),r=i.coveragePercent??0,v=r>=80?"text-emerald-400":r>=50?"text-amber-400":"text-red-400",y=r>=80?"bg-emerald-500":r>=50?"bg-amber-500":"bg-red-500";return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden hover:border-white/15 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 cursor-pointer hover:bg-white/5 transition-colors",onClick:()=>h(i.sourceId),children:[e.jsx("div",{className:"flex-shrink-0",children:p?e.jsx(Z,{size:16,className:"text-gray-500"}):e.jsx(Q,{size:16,className:"text-gray-500"})}),e.jsx("div",{className:"flex-shrink-0 w-9 h-9 rounded-lg bg-brand-500/10 border border-brand-500/20 flex items-center justify-center",children:e.jsx(D,{size:16,className:"text-brand-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-200 truncate",children:i.sourceTitle}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:[i.fileName&&e.jsxs("span",{className:"mr-3",children:["📎 ",i.fileName]}),e.jsxs("span",{className:"text-emerald-400 font-medium",children:[i.totalTestCases," test case",i.totalTestCases!==1?"s":""," generated"]}),(i.manuallyLinkedCount??0)>0&&e.jsxs("span",{className:"ml-3 text-amber-400",children:["· ",i.manuallyLinkedCount," test case",i.manuallyLinkedCount!==1?"s":""," linked manually"]})]})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-shrink-0",children:[e.jsx("div",{className:"text-right",children:e.jsxs("p",{className:`text-lg font-bold ${v}`,children:[r,"%"]})}),e.jsx("div",{className:"w-16 h-2 bg-surface-2 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${y} rounded-full transition-all`,style:{width:`${r}%`}})})]})]}),p&&e.jsx("div",{className:"border-t border-white/5 px-5 py-4",children:e.jsx(Ze,{sourceId:i.sourceId})})]},i.sourceId)})})}function ot(){const{data:s,isLoading:u}=Ae(),{data:l,isLoading:b}=Ie(),[h,i]=ue("subtab",["document","list"],"document"),[p,r]=C.useState(new Set);if(u||b)return e.jsx(U,{label:"Building traceability matrix..."});const g=((l==null?void 0:l.matrix)||(Array.isArray(l)?l:[])).map(m=>{const x=m.requirement||m,c=(m.testCases||[]).map(z=>{const P=z.testCase||z,q=z.mapping||null,B=z.latestExecution||null;return{id:P.id,title:P.title||P.name,type:P.type,priority:P.priority,automationStatus:P.automationStatus||P.automation_status,scriptPath:(q==null?void 0:q.scriptPath)||(q==null?void 0:q.script_path)||null,latestResult:(B==null?void 0:B.status)||"not_run"}}),o=c.map(z=>z.latestResult),k=o.includes("failed")?"failed":o.every(z=>z==="passed")&&o.length>0?"passed":"not_run",a=c.filter(z=>z.automationStatus==="automated"||z.scriptPath).length,Y=c.length===0?"none":a===c.length?"full":"partial";return{id:x.id,externalId:x.externalId||x.external_id,title:x.title,priority:x.priority,status:x.status,testCases:c,tcCount:c.length,overallResult:k,coverageLevel:Y}}).filter(m=>m.status==="active"||m.status==="draft");if(g.length===0)return e.jsx(_,{icon:ge,title:"No traceability data",subtitle:"Create requirements and link test cases to build the matrix."});const A=new Map;g.forEach(m=>{m.testCases.forEach(x=>{A.has(x.id)||A.set(x.id,{id:x.id,title:x.title,type:x.type})})});const I=Array.from(A.values()),M=g.reduce((m,x)=>m+x.tcCount,0),$=g.filter(m=>m.tcCount>0).length,f=g.length>0?Math.round($/g.length*100):0;return e.jsxs("div",{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:"Traceability Matrix"}),e.jsx("p",{className:"text-sm text-gray-400 mt-0.5",children:"Source Document → Content Sections → Test Cases mapping"})]}),e.jsx("div",{className:"flex items-center gap-1 bg-surface-2 rounded-lg p-0.5 border border-white/5",children:[{key:"document",label:"Detailed View",icon:e.jsx(Ye,{size:12})},{key:"list",label:"List",icon:e.jsx(ae,{size:12})}].map(m=>e.jsxs("button",{onClick:()=>i(m.key),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${h===m.key?"bg-brand-600 text-white shadow-sm":"text-gray-400 hover:text-gray-200"}`,children:[m.icon," ",m.label]},m.key))})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-5",children:[e.jsxs("div",{className:"bg-surface-1 rounded-lg border border-white/5 px-4 py-3",children:[e.jsx("p",{className:"text-[10px] font-medium text-gray-500 uppercase tracking-wider",children:"Requirements"}),e.jsx("p",{className:"text-xl font-bold text-gray-200 mt-0.5",children:g.length})]}),e.jsxs("div",{className:"bg-surface-1 rounded-lg border border-white/5 px-4 py-3",children:[e.jsx("p",{className:"text-[10px] font-medium text-gray-500 uppercase tracking-wider",children:"Linked Test Cases"}),e.jsx("p",{className:"text-xl font-bold text-gray-200 mt-0.5",children:I.length})]}),e.jsxs("div",{className:"bg-surface-1 rounded-lg border border-white/5 px-4 py-3",children:[e.jsx("p",{className:"text-[10px] font-medium text-gray-500 uppercase tracking-wider",children:"Links"}),e.jsx("p",{className:"text-xl font-bold text-brand-300 mt-0.5",children:M})]}),e.jsxs("div",{className:"bg-surface-1 rounded-lg border border-white/5 px-4 py-3",children:[e.jsx("p",{className:"text-[10px] font-medium text-gray-500 uppercase tracking-wider",children:"Requirement Coverage"}),e.jsxs("p",{className:"text-xl font-bold text-gray-200 mt-0.5",children:[f,"%"]}),e.jsxs("p",{className:"text-[10px] text-gray-500 mt-0.5",children:[$,"/",g.length," covered"]})]})]}),h==="document"?e.jsx(ct,{sourceTrace:s,expandedSources:p,setExpandedSources:r}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-400",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block w-3 h-3 rounded bg-emerald-500/30 border border-emerald-500/40"})," Passed"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block w-3 h-3 rounded bg-red-500/30 border border-red-500/40"})," Failed"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block w-3 h-3 rounded bg-gray-500/20 border border-white/10"})," Not Run"]})]}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-left",children:[e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Requirement"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Linked Test Cases"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider text-center",children:"Count"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider text-center",children:"Result"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider text-center",children:"Coverage"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:g.map(m=>e.jsxs("tr",{className:m.tcCount===0?"bg-red-500/5":m.coverageLevel==="full"?"bg-emerald-500/5":"",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{priority:m.priority||"medium"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-200 text-sm font-medium",children:m.title}),e.jsx("p",{className:"text-[10px] font-mono text-gray-500",children:m.externalId||m.id})]})]})}),e.jsx("td",{className:"px-4 py-3",children:m.testCases.length===0?e.jsx("span",{className:"text-gray-500 text-xs italic",children:"No test cases linked"}):e.jsx("div",{className:"flex flex-wrap gap-1.5",children:m.testCases.map(x=>{const c=x.latestResult==="passed"?"bg-emerald-500/15 text-emerald-300 border-emerald-500/30":x.latestResult==="failed"?"bg-red-500/15 text-red-300 border-red-500/30":"bg-gray-500/15 text-gray-300 border-white/10",o=x.title.length>25?x.title.slice(0,25)+"…":x.title;return e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium border ${c}`,title:`${x.id} — ${x.title} — ${x.latestResult}`,children:[x.latestResult==="passed"?"✓":x.latestResult==="failed"?"✗":"●",e.jsx("span",{className:"font-mono opacity-80",children:x.id}),e.jsx("span",{children:o})]},x.id)})})}),e.jsx("td",{className:"px-4 py-3 text-center whitespace-nowrap",children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-gray-400",children:[e.jsx(ae,{size:12})," ",m.tcCount]})}),e.jsx("td",{className:"px-4 py-3 text-center whitespace-nowrap",children:e.jsx(st,{result:m.overallResult})}),e.jsx("td",{className:"px-4 py-3 text-center whitespace-nowrap",children:e.jsx(at,{level:m.coverageLevel})})]},m.id))})]})})]})]})}function dt(){var m,x,c;const{data:s,isLoading:u}=Pe(),{data:l}=pe();if(u)return e.jsx(U,{label:"Computing coverage metrics..."});const b=s||{},h=l||{};b.requirementCoverage??b.requirementCoveragePercent;const i=b.automationCoverage??b.automationCoveragePercent??0,p=b.sourceCoverage??0,r=((m=h.orphanTestCases)==null?void 0:m.length)??b.orphanTestCases??0,v=((x=h.orphanScripts)==null?void 0:x.length)??b.orphanScripts??0,y=((c=h.orphanSources)==null?void 0:c.length)??0,g=b.testCaseByPriority||{},A=["critical","high","medium","low"],I={critical:"bg-rose-400",high:"bg-orange-500",medium:"bg-amber-500",low:"bg-emerald-500"},M=A.map(o=>{var k,a;return{label:K(o),automated:((k=g[o])==null?void 0:k.automated)??0,total:((a=g[o])==null?void 0:a.total)??0,color:I[o]||"bg-gray-500"}}).filter(o=>o.total>0),$=b.byType||{},f=Object.entries($).map(([o,k])=>({type:o,count:(k==null?void 0:k.count)??k??0})).filter(o=>o.count>0);return e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200 mb-4",children:"Coverage Dashboard"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-400 mb-3",children:[e.jsx(Je,{size:16}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider",children:"Automation Coverage"})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsxs("span",{className:"text-3xl font-bold text-emerald-400",children:[Math.round(i),"%"]})}),e.jsx("div",{className:"mt-3 h-2 bg-surface-2 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-emerald-500 rounded-full transition-all",style:{width:`${Math.min(i,100)}%`}})})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-400 mb-3",children:[e.jsx(D,{size:16}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider",children:"Source Coverage"})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsxs("span",{className:"text-3xl font-bold text-purple-400",children:[Math.round(p),"%"]})}),e.jsx("div",{className:"mt-3 h-2 bg-surface-2 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-purple-500 rounded-full transition-all",style:{width:`${Math.min(p,100)}%`}})})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-400 mb-3",children:[e.jsx(H,{size:16}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider",children:"Orphan Test Cases"})]}),e.jsx("span",{className:`text-3xl font-bold ${r>0?"text-amber-400":"text-gray-500"}`,children:r}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Not linked to any requirement"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-400 mb-3",children:[e.jsx(ee,{size:16}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider",children:"Orphan Test Scripts"})]}),e.jsx("span",{className:`text-3xl font-bold ${v>0?"text-orange-400":"text-gray-500"}`,children:v}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Mapped script with no test case"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-400 mb-3",children:[e.jsx(D,{size:16}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider",children:"Orphan Sources"})]}),e.jsx("span",{className:`text-3xl font-bold ${y>0?"text-purple-400":"text-gray-500"}`,children:y}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Sources with no linked test cases"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-300 mb-4 flex items-center gap-2",children:[e.jsx(be,{size:14,className:"text-brand-300"})," Test Case Automation by Priority"]}),e.jsx("div",{className:"space-y-3",children:M.length===0?e.jsx("p",{className:"text-gray-500 text-sm py-4 text-center",children:"No test cases yet."}):M.map(o=>{const k=o.total>0?Math.round(o.automated/o.total*100):0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs text-gray-400",children:o.label}),e.jsxs("span",{className:"text-xs text-gray-500",children:[o.automated,"/",o.total," automated (",k,"%)"]})]}),e.jsx("div",{className:"h-2 bg-surface-2 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${o.color} rounded-full transition-all`,style:{width:`${k}%`}})})]},o.label)})})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-300 mb-4 flex items-center gap-2",children:[e.jsx(ae,{size:14,className:"text-brand-300"})," Coverage by Type"]}),f.length===0?e.jsx("p",{className:"text-gray-500 text-sm py-4 text-center",children:"No type distribution data available."}):e.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(o=>{const k=fe[o.type]||"bg-gray-500/20 text-gray-300";return e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium ${k}`,children:[K(o.type),e.jsxs("span",{className:"opacity-70",children:["(",o.count,")"]})]},o.type)})})]})]})]})}function xt(){const{data:s,isLoading:u}=pe();if(u)return e.jsx(U,{label:"Scanning for orphan items..."});const l=s||{},b=l.orphanTestCases||l.testCases||[],h=l.orphanScripts||l.scripts||[],i=l.orphanSources||[],p=l.unmappedScripts||[];return e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200 mb-4",children:"Orphan Detection"}),e.jsx("p",{className:"text-sm text-gray-400 mb-6",children:"Find unlinked items that may need attention."}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-white/5",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-300 flex items-center gap-2",children:[e.jsx(H,{size:14,className:"text-amber-400"}),"Orphan Test Cases",e.jsx("span",{className:`inline-flex items-center justify-center min-w-[20px] h-5 rounded-full text-xs font-medium px-1.5 ${b.length>0?"bg-amber-500/20 text-amber-300":"bg-gray-500/20 text-gray-400"}`,children:b.length})]}),e.jsx("span",{className:"text-xs text-gray-500",children:"Not linked to any requirement"})]}),e.jsx("div",{className:"p-0",children:b.length===0?e.jsx(_,{icon:G,title:"No orphan test cases",subtitle:"All test cases are linked to requirements."}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-left",children:[e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Title"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Type"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Priority"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Created"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:b.map(r=>e.jsxs("tr",{className:"hover:bg-surface-2/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-mono text-gray-500",children:r.id}),e.jsx("span",{className:"text-gray-200",children:r.title})]})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:r.type?e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${fe[r.type]||"bg-gray-500/20 text-gray-300"}`,children:K(r.type)}):e.jsx("span",{className:"text-gray-600",children:"-"})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:e.jsx(V,{priority:r.priority||"medium"})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap text-xs text-gray-400",children:me(r.createdAt)})]},r.id))})]})})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-white/5",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-300 flex items-center gap-2",children:[e.jsx(ee,{size:14,className:"text-orange-400"}),"Unmapped Test Scripts",e.jsx("span",{className:`inline-flex items-center justify-center min-w-[20px] h-5 rounded-full text-xs font-medium px-1.5 ${p.length>0?"bg-orange-500/20 text-orange-300":"bg-gray-500/20 text-gray-400"}`,children:p.length})]}),e.jsx("span",{className:"text-xs text-gray-500",children:"Test files in project not linked to any test case"})]}),e.jsx("div",{className:"p-0",children:p.length===0&&h.length===0?e.jsx(_,{icon:G,title:"No unmapped scripts",subtitle:"All test scripts in the project are mapped to test cases."}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-left",children:[e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Script Path"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"File Name"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Framework"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Status"})]})}),e.jsxs("tbody",{className:"divide-y divide-white/5",children:[p.map((r,v)=>e.jsxs("tr",{className:"hover:bg-surface-2/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-2.5",children:e.jsx("span",{className:"text-xs font-mono text-gray-400",children:r.path})}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsx("span",{className:"text-gray-200 text-sm",children:r.name})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-gray-500/20 text-gray-300",children:r.framework})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-amber-500/15 text-amber-300",children:[e.jsx(H,{size:10})," Not Mapped"]})})]},r.path||v)),h.map((r,v)=>e.jsxs("tr",{className:"hover:bg-surface-2/50 transition-colors bg-red-500/[0.03]",children:[e.jsx("td",{className:"px-4 py-2.5",children:e.jsx("span",{className:"text-xs font-mono text-gray-400",children:r.scriptPath||r.path})}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsx("span",{className:"text-gray-200 text-sm",children:r.testName||r.name||"-"})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-gray-500/20 text-gray-300",children:r.framework?K(r.framework):"-"})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-red-500/15 text-red-300",children:[e.jsx(ye,{size:10})," Orphaned"]})})]},`orphan-${r.id||v}`))]})]})})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-white/5",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-300 flex items-center gap-2",children:[e.jsx(D,{size:14,className:"text-purple-400"}),"Orphan Sources",e.jsx("span",{className:`inline-flex items-center justify-center min-w-[20px] h-5 rounded-full text-xs font-medium px-1.5 ${i.length>0?"bg-purple-500/20 text-purple-300":"bg-gray-500/20 text-gray-400"}`,children:i.length})]}),e.jsx("span",{className:"text-xs text-gray-500",children:"Sources with no generated or manually-linked test cases"})]}),e.jsx("div",{className:"p-0",children:i.length===0?e.jsx(_,{icon:G,title:"No orphan sources",subtitle:"All sources have been used for test generation."}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-left",children:[e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Title"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Type"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Created"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:i.map(r=>{const v={requirement:"📋 Requirement",nlp:"💬 NLP",jira:"🎫 JIRA",document:"📎 Document"};return e.jsxs("tr",{className:"hover:bg-surface-2/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-2.5",children:e.jsx("span",{className:"text-gray-200",children:r.title})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:e.jsx("span",{className:"text-xs text-gray-400",children:v[r.type]||r.type})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap text-xs text-gray-400",children:me(r.createdAt)})]},r.id)})})]})})]})]})}function jt(){const[s,u]=ue("tab",["requirements","traceability","coverage","orphans"],"requirements");return e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(Ke,{size:24,className:"text-brand-300"}),"Traceability, Coverage & Requirements"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Track requirement coverage, manage traceability, and find orphan items"})]}),e.jsx(Le,{type:"coverage-matrix",formats:["xlsx"],label:"Export Matrix"})]})})}),e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 flex gap-1",children:tt.map(l=>{const b=l.icon,h=s===l.key;return e.jsxs("button",{onClick:()=>u(l.key),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors ${h?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200 hover:border-white/10"}`,children:[e.jsx(b,{size:16}),l.label]},l.key)})})}),e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-8",children:[s==="requirements"&&e.jsx(lt,{}),s==="traceability"&&e.jsx(ot,{}),s==="coverage"&&e.jsx(dt,{}),s==="orphans"&&e.jsx(xt,{})]})]})}export{jt as CoveragePage};
|
|
1
|
+
import{r as C,j as e,L as te,R as Te}from"./vendor-react-DOVfxdUy.js";import{E as Le}from"./ExportButton-xrS_AnfS.js";import{u as ue,a as Re}from"./useTabParam-CyYAP90W.js";import{al as Me,ah as $e,am as ze,an as Ae,ao as Pe,ap as Ie,aq as pe,ar as he,as as Ee,at as Oe,au as qe,F as De,av as Be}from"./useTestManagement-ommXjx0q.js";import{f as Fe}from"./formatDate-T65-Y6Mi.js";import{u as Ge}from"./vendor-query-DkZSMtfn.js";import{ix as _e}from"./index-BlA8ntjb.js";import{j as D,a6 as Ue,X as re,w as ne,cf as Qe,U as oe,p as H,z as Z,u as Q,v as He,h as se,s as G,dg as Ke,G as ge,b as be,ci as ee,bP as Ve,f as ie,aJ as Ye,e as ae,aD as Je,aq as ye,a1 as le,b1 as Xe}from"./vendor-icons-Cm92aSc5.js";const X=["happy-path","negative","boundary","equivalence","error-handling","security","performance","accessibility","compatibility","integration","data-validation"],We={"happy-path":"HP",negative:"NEG",boundary:"BND",equivalence:"EQ","error-handling":"ERR",security:"SEC",performance:"PRF",accessibility:"A11Y",compatibility:"CMP",integration:"INT","data-validation":"DV"},W={critical:"bg-red-500/15 text-red-300",high:"bg-orange-500/15 text-orange-300",medium:"bg-amber-500/15 text-amber-300",low:"bg-gray-500/15 text-gray-400"};function Ze({sourceId:s,onClose:u}){const{data:l,isLoading:b,error:h}=Ge({queryKey:["source-coverage-matrix",s],queryFn:()=>_e(s),refetchOnWindowFocus:!1}),[i,p]=C.useState(""),[r,v]=C.useState(new Set),[y,g]=C.useState(new Set),[A,P]=C.useState(!1),[M,$]=C.useState("recent"),[f,m]=C.useState(!1),[x,c]=C.useState(new Set),[o,k]=C.useState(null),a=l,Y=C.useMemo(()=>{if(!a)return[];const t=i.trim().toLowerCase();return a.requirements.filter(n=>!(r.size>0&&!Object.values(n.testCasesByStrategy).some(j=>j.some(L=>r.has(L.priority)))||y.size>0&&!n.personas.some(j=>y.has(j))||A&&!a.strategies.some(j=>(n.byStrategy[j]||0)===0)||t&&![n.title,n.sourceQuote,n.requirementId||"",...Object.values(n.testCasesByStrategy).flat().map(j=>j.title)].join(" ").toLowerCase().includes(t)))},[a,i,r,y,A]),z=C.useMemo(()=>{const t=Y.slice();if(!a)return t;if(M==="recent")t.sort((n,w)=>w.lastGeneratedAt-n.lastGeneratedAt);else if(M==="coverage-asc"){const n=Math.max(1,a.strategies.length);t.sort((w,j)=>{const L=a.strategies.filter(S=>(w.byStrategy[S]||0)>0).length/n,E=a.strategies.filter(S=>(j.byStrategy[S]||0)>0).length/n;return L-E})}else if(M==="priority-desc"){const n={critical:0,high:1,medium:2,low:3};t.sort((w,j)=>{const L=Math.min(...Object.values(w.testCasesByStrategy).flat().map(S=>n[S.priority]??99)),E=Math.min(...Object.values(j.testCasesByStrategy).flat().map(S=>n[S.priority]??99));return L-E})}else M==="tests-desc"?t.sort((n,w)=>w.totalTests-n.totalTests):M==="tests-asc"&&t.sort((n,w)=>n.totalTests-w.totalTests);return t},[Y,M,a]),I=C.useMemo(()=>{if(!a)return{reqCount:0,testCount:0,coverage:0};const t=Math.max(1,a.strategies.length),n=a.requirements.reduce((L,E)=>L+a.strategies.filter(S=>(E.byStrategy[S]||0)>0).length,0),w=a.requirements.length*t,j=w>0?Math.round(n/w*100):0;return{reqCount:a.requirements.length,testCount:a.totalTests,coverage:j}},[a]);if(b)return e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-12 text-center text-gray-500 text-sm",children:"Loading coverage matrix…"});if(h)return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-red-500/30 p-6 text-center text-red-300",children:["Failed to load coverage matrix: ",String((h==null?void 0:h.message)||h)]});if(!a)return null;if(a.requirements.length===0&&a.manuallyLinkedTotal===0)return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-12 text-center",children:[e.jsx(D,{className:"w-10 h-10 mx-auto mb-3 text-gray-500"}),e.jsx("h3",{className:"text-base font-medium text-gray-300 mb-1",children:"No saved test cases for this source"}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:a.legacyCount>0?`${a.legacyCount} legacy test case${a.legacyCount===1?"":"s"} found, but no requirement metadata. Re-generate via AI Test Gen to populate the matrix.`:"Generate test cases via AI Test Gen to see requirement coverage here."}),e.jsx(te,{to:"/ai-test-gen",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium transition-colors",children:"Open AI Test Gen"})]});const q=(t,n,w)=>{const j=new Set(t);j.has(n)?j.delete(n):j.add(n),w(j)},B=t=>{const n=new Set(x);n.has(t)?n.delete(t):n.add(t),c(n)},ce=()=>{p(""),v(new Set),g(new Set),P(!1)},je=!!(i.trim()||r.size||y.size||A),Ne=()=>{if(!a)return;const t=N=>{const R=String(N??"");return/[",\r\n]/.test(R)?`"${R.replace(/"/g,'""')}"`:R},n=a.strategies,w=a.personas,j=["Requirement ID","Title","Source Quote","Total Tests","Last Generated",...n.map(N=>`${N} (count)`),...w.map(N=>`${N} (count)`),"Test Case IDs (by strategy)"],L=z.map(N=>{const R=N.lastGeneratedAt?new Date(N.lastGeneratedAt).toISOString():"",we=w.map(F=>Object.values(N.testCasesByStrategy).flat().filter(J=>J.persona===F).length),Ce=n.map(F=>N.byStrategy[F]||0),ke=n.map(F=>{const J=N.testCasesByStrategy[F]||[];return J.length===0?"":`${F}: ${J.map(Se=>Se.id).join(", ")}`}).filter(Boolean).join(" | ");return[N.requirementId??"",N.title,N.sourceQuote,N.totalTests,R,...Ce,...we,ke].map(t).join(",")}),E=[j.map(t).join(","),...L].join(`\r
|
|
2
|
+
`),S=new Blob([E],{type:"text/csv;charset=utf-8"}),O=URL.createObjectURL(S),T=`coverage-matrix_${a.sourceTitle.replace(/[^a-z0-9]+/gi,"-").toLowerCase()||a.sourceId}.csv`,d=document.createElement("a");d.href=O,d.download=T,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(O)},ve=(t,n,w,j="")=>{const S=(t.testCasesByStrategy[n]||[]).length;return S===0?e.jsx("td",{className:`px-1.5 py-2.5 text-center text-gray-700 transition-colors ${j}`,children:e.jsx(se,{size:10,className:"inline"})},`${n}`):e.jsx("td",{className:`px-1.5 py-2.5 text-center transition-colors ${j}`,title:`${S} test case${S===1?"":"s"} for ${n} — expand the row to see them`,children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5",children:[e.jsx(G,{size:12,className:"text-emerald-400"}),e.jsx("span",{className:"text-sm text-gray-200 tabular-nums",children:S})]})},`${n}`)};return e.jsxs("div",{className:"space-y-4 relative",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-brand-500/10 border border-brand-500/20 flex items-center justify-center",children:e.jsx(D,{size:18,className:"text-brand-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-200",children:a.sourceTitle||"Source"}),e.jsxs("p",{className:"text-sm text-gray-500",children:[I.reqCount," requirement",I.reqCount===1?"":"s"," · ",e.jsxs("span",{className:"text-gray-300",children:[I.testCount+a.manuallyLinkedTotal," Test Case",I.testCount+a.manuallyLinkedTotal===1?"":"s"]})," · ",I.testCount," generated",a.manuallyLinkedTotal>0&&e.jsxs("span",{className:"text-amber-400",children:[" · ",a.manuallyLinkedTotal," manually linked"]}),a.legacyCount>0&&e.jsxs("span",{className:"ml-2 text-amber-400",children:["(+ ",a.legacyCount," legacy uncategorized)"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:Ne,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-surface-2 hover:bg-surface-3 text-gray-300 rounded-lg border border-white/10 transition-colors",title:"Export coverage matrix as CSV",children:[e.jsx(Ue,{className:"w-4 h-4"}),"Export CSV"]}),u&&e.jsx("button",{onClick:u,className:"p-1.5 rounded text-gray-400 hover:text-gray-200 hover:bg-surface-2 transition-colors",title:"Close",children:e.jsx(re,{size:16})})]})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[e.jsxs("div",{className:"relative flex-1 min-w-[220px]",children:[e.jsx(ne,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500 pointer-events-none"}),e.jsx("input",{type:"text",value:i,onChange:t=>p(t.target.value),placeholder:"Search requirements or test case titles…",className:"w-full pl-10 pr-3 py-2 text-sm rounded-lg bg-surface-2 border border-white/5 text-gray-200 placeholder-gray-500 focus:outline-none focus:ring-1 focus:ring-brand-500"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-gray-400",children:[e.jsx(Qe,{size:14}),e.jsxs("select",{value:M,onChange:t=>$(t.target.value),className:"px-2.5 py-1.5 text-sm rounded bg-surface-2 border border-white/5 text-gray-200 focus:outline-none focus:ring-1 focus:ring-brand-500",children:[e.jsx("option",{value:"recent",children:"Recently generated"}),e.jsx("option",{value:"coverage-asc",children:"Least covered first"}),e.jsx("option",{value:"priority-desc",children:"Highest priority first"}),e.jsx("option",{value:"tests-desc",children:"Most tests first"}),e.jsx("option",{value:"tests-asc",children:"Fewest tests first"})]})]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-sm text-gray-400 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:A,onChange:t=>P(t.target.checked),className:"rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),"Uncovered only"]}),a.personas.length>0&&e.jsxs("label",{className:"flex items-center gap-1.5 text-sm text-gray-400 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:f,onChange:t=>m(t.target.checked),className:"rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),e.jsx(oe,{size:13})," Per-persona columns"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-sm text-gray-500 mr-1",children:"Priority:"}),["critical","high","medium","low"].map(t=>{const n=r.has(t);return e.jsx("button",{onClick:()=>q(r,t,v),className:`text-sm px-3 py-1 rounded-full border transition-colors ${n?"bg-amber-500/20 text-amber-200 border-amber-400/40":"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"}`,children:t},t)})]}),a.personas.length>0&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-sm text-gray-500 mr-1",children:"Persona:"}),a.personas.map(t=>{const n=y.has(t);return e.jsx("button",{onClick:()=>q(y,t,g),className:`text-sm px-3 py-1 rounded-full border transition-colors ${n?"bg-violet-500/20 text-violet-200 border-violet-400/40":"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"}`,children:t},t)})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-500",children:[e.jsxs("span",{children:["Showing ",e.jsx("span",{className:"text-gray-300",children:z.length})," of ",e.jsx("span",{className:"text-gray-300",children:a.requirements.length})," requirements"]}),je&&e.jsx("button",{onClick:ce,className:"text-brand-400 hover:text-brand-300",children:"Clear filters"})]})]}),z.length===0&&a.manuallyLinkedTotal===0?e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-12 text-center",children:[e.jsx(H,{className:"w-8 h-8 mx-auto mb-3 text-amber-400"}),e.jsx("p",{className:"text-sm text-gray-400",children:"No requirements match the current filters."}),e.jsx("button",{onClick:ce,className:"mt-3 text-sm text-brand-400 hover:text-brand-300",children:"Clear filters"})]}):e.jsxs("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:"text-xs uppercase tracking-wide text-gray-500 border-b border-white/5",children:[e.jsx("th",{className:"text-left font-medium px-3 py-2.5 sticky left-0 bg-surface-1 z-10",children:"Requirement"}),e.jsx("th",{className:"text-right font-medium px-2 py-2.5",children:"Tests"}),e.jsx("th",{className:"text-right font-medium px-2 py-2.5",children:"Last Gen"}),X.filter(t=>a.strategies.includes(t)).map(t=>e.jsx("th",{className:"text-center font-medium px-1.5 py-2.5",title:t,children:We[t]||t},t)),f&&a.personas.map(t=>e.jsx("th",{className:"text-center font-medium px-1.5 py-2.5 border-l border-white/5",title:`Persona: ${t}`,children:e.jsx("div",{className:"text-violet-300",children:t})},`persona-${t}`))]})}),e.jsxs("tbody",{children:[z.map(t=>{Math.max(1,a.strategies.length),a.strategies.filter(d=>(t.byStrategy[d]||0)>0).length;const n=Date.now()-(t.lastGeneratedAt||0),w=t.lastGeneratedAt?n<6e4?"just now":n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`:"—",j=x.has(t.bucketKey),L=new Map;for(const d of Object.values(t.testCasesByStrategy))for(const N of d)L.set(N.priority,(L.get(N.priority)||0)+1);const E=o===t.bucketKey,S=j||E,O=S?"bg-surface-2":"",T=S?"bg-surface-2":"bg-surface-1";return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onMouseEnter:()=>k(t.bucketKey),onMouseLeave:()=>k(null),className:"border-b border-white/5 transition-colors",children:[e.jsx("td",{className:`px-3 py-2.5 sticky left-0 z-10 max-w-md transition-colors ${T}`,children:e.jsxs("button",{onClick:()=>B(t.bucketKey),className:"flex items-start gap-1.5 text-left w-full",children:[j?e.jsx(Z,{size:13,className:"text-gray-400 flex-shrink-0 mt-0.5"}):e.jsx(Q,{size:13,className:"text-gray-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:t.requirementId&&e.jsx("span",{className:"font-mono text-brand-300 text-sm",children:t.requirementId})}),e.jsx("div",{className:"text-gray-300 text-sm truncate",title:t.title,children:t.title}),t.sourceQuote&&t.sourceQuote.length>t.title.length&&e.jsxs("div",{className:"text-xs text-gray-500 truncate mt-0.5",title:t.sourceQuote,children:["“",t.sourceQuote.slice(0,100),t.sourceQuote.length>100?"…":"","”"]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[Array.from(L.entries()).map(([d,N])=>e.jsxs("span",{className:`text-[10px] px-1.5 py-0 rounded ${W[d]||"text-gray-500"}`,children:[d[0],":",N]},d)),t.personas.map(d=>e.jsx("span",{className:"text-[10px] px-1.5 py-0 rounded bg-violet-500/15 text-violet-300",children:d},d))]})]})]})}),e.jsx("td",{className:`px-2 py-2.5 text-right tabular-nums text-sm text-gray-300 transition-colors ${O}`,children:t.totalTests}),e.jsxs("td",{className:`px-2 py-2.5 text-right text-xs text-gray-500 transition-colors ${O}`,title:t.lastGeneratedAt?Fe(t.lastGeneratedAt):"",children:[e.jsx(He,{size:11,className:"inline mr-0.5"}),w]}),X.filter(d=>a.strategies.includes(d)).map(d=>ve(t,d,void 0,O)),f&&a.personas.map(d=>{const N=Object.values(t.testCasesByStrategy).flat().filter(R=>R.persona===d).length;return N===0?e.jsx("td",{className:`px-1.5 py-2.5 text-center text-gray-700 border-l border-white/5 transition-colors ${O}`,children:e.jsx(se,{size:10,className:"inline"})},`persona-${d}`):e.jsx("td",{className:`px-1.5 py-2.5 text-center border-l border-white/5 transition-colors ${O}`,title:`${N} test case${N===1?"":"s"} for persona ${d} — expand the row to see them`,children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5",children:[e.jsx(oe,{size:11,className:"text-violet-400"}),e.jsx("span",{className:"text-sm text-gray-200 tabular-nums",children:N})]})},`persona-${d}`)})]},t.bucketKey),j&&e.jsx("tr",{onMouseEnter:()=>k(t.bucketKey),onMouseLeave:()=>k(null),className:"border-b border-white/5 bg-surface-2",children:e.jsx("td",{colSpan:3+X.filter(d=>a.strategies.includes(d)).length+(f?a.personas.length:0),className:"px-4 py-4",children:e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:Object.entries(t.testCasesByStrategy).map(([d,N])=>e.jsxs("div",{className:"bg-surface-1 rounded-lg border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2.5 bg-white/5 border-b border-white/10",children:[e.jsx("span",{className:"font-mono text-sm text-gray-200 font-semibold",children:d}),e.jsxs("span",{className:"text-xs text-gray-500 tabular-nums",children:[N.length," test",N.length===1?"":"s"]})]}),e.jsx("div",{className:"divide-y divide-white/5",children:N.map(R=>e.jsxs(te,{to:`/test-cases?tcId=${R.id}`,className:"flex items-center gap-2.5 px-3 py-2.5 hover:bg-surface-2/60 transition-colors",title:R.title,children:[e.jsx("span",{className:"font-mono text-xs text-gray-500 flex-shrink-0",children:R.id}),e.jsx("span",{className:"text-sm text-gray-300 hover:text-brand-300 truncate flex-1",children:R.title}),R.priority&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium flex-shrink-0 ${W[R.priority]||""}`,children:R.priority}),R.persona&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-violet-500/15 text-violet-300 flex-shrink-0",children:R.persona})]},R.id))})]},d))})})},`${t.bucketKey}-expanded`)]})}),a.manuallyLinkedTotal>0&&(()=>{const t="__manually_linked__",n=x.has(t),j=n||o===t,L=j?"bg-surface-2":"",E=j?"bg-surface-2":"bg-surface-1",S=new Map;for(const T of a.manuallyLinkedRequirements)for(const d of T.testCases)S.set(d.priority,(S.get(d.priority)||0)+1);const O=X.filter(T=>a.strategies.includes(T)).length+(f?a.personas.length:0);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onMouseEnter:()=>k(t),onMouseLeave:()=>k(null),className:"border-b border-white/5 transition-colors",children:[e.jsx("td",{className:`px-3 py-2.5 sticky left-0 z-10 max-w-md transition-colors ${E}`,children:e.jsxs("button",{onClick:()=>B(t),className:"flex items-start gap-1.5 text-left w-full",children:[n?e.jsx(Z,{size:13,className:"text-gray-400 flex-shrink-0 mt-0.5"}):e.jsx(Q,{size:13,className:"text-gray-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx("span",{className:"text-amber-300 text-xs uppercase tracking-wide font-semibold",children:"Manually Linked"})}),e.jsxs("div",{className:"text-gray-300 text-sm mt-0.5",children:[a.manuallyLinkedTotal," test case",a.manuallyLinkedTotal===1?"":"s"," across ",a.manuallyLinkedRequirements.length," requirement",a.manuallyLinkedRequirements.length===1?"":"s"]}),e.jsx("div",{className:"text-xs text-gray-500 mt-0.5",children:"Linked from the Requirements tab — not auto-generated"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Array.from(S.entries()).map(([T,d])=>e.jsxs("span",{className:`text-[10px] px-1.5 py-0 rounded ${W[T]||"text-gray-500"}`,children:[T[0],":",d]},T))})]})]})}),e.jsx("td",{className:`px-2 py-2.5 text-right tabular-nums text-sm text-gray-300 transition-colors ${L}`,children:a.manuallyLinkedTotal}),e.jsx("td",{className:`px-2 py-2.5 text-right text-xs text-gray-500 transition-colors ${L}`,children:"—"}),O>0&&e.jsx("td",{colSpan:O,className:`px-1.5 py-2.5 text-center text-gray-700 text-xs transition-colors ${L}`,children:"(no taxonomy data)"})]},t),n&&e.jsx("tr",{onMouseEnter:()=>k(t),onMouseLeave:()=>k(null),className:"border-b border-white/5 bg-surface-2",children:e.jsx("td",{colSpan:3+O,className:"px-4 py-4",children:e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:a.manuallyLinkedRequirements.map(T=>e.jsxs("div",{className:"bg-surface-1 rounded-lg border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2.5 bg-white/5 border-b border-white/10",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"font-mono text-sm text-amber-300 font-semibold flex-shrink-0",children:T.externalId}),e.jsx("span",{className:"text-sm text-gray-200 truncate",title:T.title,children:T.title})]}),e.jsxs("span",{className:"text-xs text-gray-500 tabular-nums flex-shrink-0",children:[T.testCases.length," test",T.testCases.length===1?"":"s"]})]}),e.jsx("div",{className:"divide-y divide-white/5",children:T.testCases.map(d=>e.jsxs(te,{to:`/test-cases?tcId=${d.id}`,className:"flex items-center gap-2.5 px-3 py-2.5 hover:bg-surface-2/60 transition-colors",title:d.title,children:[e.jsx("span",{className:"font-mono text-xs text-gray-500 flex-shrink-0",children:d.id}),e.jsx("span",{className:"text-sm text-gray-300 hover:text-brand-300 truncate flex-1",children:d.title}),d.priority&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium flex-shrink-0 ${W[d.priority]||""}`,children:d.priority}),d.persona&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-violet-500/15 text-violet-300 flex-shrink-0",children:d.persona})]},d.id))})]},T.requirementId))})})},`${t}-expanded`)]})})()]})]})}),e.jsxs("div",{className:"flex flex-wrap gap-3 px-3 py-2 border-t border-white/5 text-[10px] text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(G,{size:10,className:"text-emerald-400"})," covered"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(se,{size:8,className:"text-gray-700"})," no tests"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Q,{size:10})," click a row to expand and see all test cases"]})]})]})]})}const et={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"},de={passed:{color:"text-emerald-400 bg-emerald-500/15",icon:G,label:"Passed"},failed:{color:"text-red-400 bg-red-500/15",icon:ye,label:"Failed"},not_run:{color:"text-gray-400 bg-gray-500/15",icon:H,label:"Not Run"}},xe={full:"text-emerald-400 bg-emerald-500/15",partial:"text-amber-400 bg-amber-500/15",none:"text-red-400 bg-red-500/15"},fe={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"},tt=[{key:"requirements",label:"Requirements",icon:D},{key:"traceability",label:"Traceability Matrix",icon:ge},{key:"coverage",label:"Coverage Dashboard",icon:be},{key:"orphans",label:"Orphan Detection",icon:ee}];function K(s){return s.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase())}function me(s){return s?new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"-"}function V({priority:s}){const u=et[s]||"bg-gray-500/20 text-gray-300";return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${u}`,children:K(s)})}function st({result:s}){const u=de[s]||de.not_run,l=u.icon;return e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${u.color}`,children:[e.jsx(l,{size:12}),u.label]})}function at({level:s}){const u={full:"Fully Covered",partial:"Partially Covered",none:"Not Covered"},l=xe[s]||xe.none;return e.jsx("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${l}`,children:u[s]||"Unknown"})}function U({label:s="Loading..."}){return e.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-gray-400",children:[e.jsx(le,{size:20,className:"animate-spin"}),e.jsx("span",{children:s})]})}function _({icon:s,title:u,subtitle:l}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-surface-2 flex items-center justify-center mb-3",children:e.jsx(s,{size:24,className:"text-gray-500"})}),e.jsx("p",{className:"text-gray-300 font-medium",children:u}),l&&e.jsx("p",{className:"text-gray-500 text-sm mt-1 max-w-sm",children:l})]})}function rt({reqId:s,onLink:u}){const{data:l,isLoading:b}=he(s),h=Ee();if(b)return e.jsx(U,{label:"Loading linked test cases..."});const i=(l==null?void 0:l.testCases)||(Array.isArray(l)?l:[]);return e.jsx("div",{className:"px-4 pb-4",children: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-3",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-300",children:["Linked Test Cases (",i.length,")"]}),e.jsxs("button",{onClick:u,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(ie,{size:12})," Link Test Cases"]})]}),i.length===0?e.jsx("p",{className:"text-gray-500 text-sm py-4 text-center",children:"No test cases linked yet."}):e.jsx("div",{className:"space-y-1.5",children:i.map(p=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 rounded-lg bg-surface-1 border border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-gray-500 font-mono",children:p.id}),e.jsx("span",{className:"text-sm text-gray-200",children:p.title}),p.priority&&e.jsx(V,{priority:p.priority})]}),e.jsx("button",{onClick:()=>h.mutate({reqId:s,testCaseIds:[p.id]}),disabled:h.isPending,className:"text-gray-500 hover:text-red-400 transition-colors p-1",title:"Unlink",children:e.jsx(ee,{size:14})})]},p.id))})]})})}function nt({initial:s,onClose:u}){const l=Oe(),b=qe(),h=!!s,[i,p]=C.useState({externalId:(s==null?void 0:s.externalId)||"",title:(s==null?void 0:s.title)||"",description:(s==null?void 0:s.description)||"",priority:(s==null?void 0:s.priority)||"medium",source:(s==null?void 0:s.source)||"",status:(s==null?void 0:s.status)||"active"}),r=l.isPending||b.isPending,v=()=>{i.title.trim()&&(h?b.mutate({id:s.id,data:i},{onSuccess:u}):l.mutate(i,{onSuccess:u}))};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:u,children:e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 w-full max-w-lg mx-4 shadow-2xl",onClick:y=>y.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/5",children:[e.jsx("h3",{className:"text-gray-200 font-semibold",children:h?"Edit Requirement":"New Requirement"}),e.jsx("button",{onClick:u,className:"text-gray-500 hover:text-gray-300 transition-colors",children:e.jsx(re,{size:18})})]}),e.jsxs("div",{className:"px-5 py-4 space-y-4 max-h-[60vh] overflow-y-auto",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"External ID"}),e.jsx("input",{value:i.externalId,onChange:y=>p(g=>({...g,externalId:y.target.value})),placeholder:"e.g. REQ-001",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:["Title ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{value:i.title,onChange:y=>p(g=>({...g,title:y.target.value})),placeholder:"Requirement title",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"Description"}),e.jsx("textarea",{value:i.description,onChange:y=>p(g=>({...g,description:y.target.value})),rows:3,placeholder:"Describe the requirement...",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50 resize-none"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"Priority"}),e.jsxs("select",{value:i.priority,onChange:y=>p(g=>({...g,priority:y.target.value})),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-brand-500/50",children:[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("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"Status"}),e.jsxs("select",{value:i.status,onChange:y=>p(g=>({...g,status:y.target.value})),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-brand-500/50",children:[e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"draft",children:"Draft"}),e.jsx("option",{value:"deprecated",children:"Deprecated"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"Source"}),e.jsx("input",{value:i.source,onChange:y=>p(g=>({...g,source:y.target.value})),placeholder:"e.g. Jira, Confluence, PRD",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:u,className:"px-4 py-2 text-sm font-medium text-gray-400 hover:text-gray-200 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:v,disabled:r||!i.title.trim(),className:"flex items-center gap-1.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg px-4 py-2 text-sm font-medium transition-colors",children:[r?e.jsx(le,{size:14,className:"animate-spin"}):e.jsx(Xe,{size:14}),h?"Update":"Create"]})]})]})})}function it({reqId:s,onClose:u}){const{data:l,isLoading:b}=De(),{data:h}=he(s),i=Be(),[p,r]=C.useState(""),[v,y]=C.useState(new Set),g=(h==null?void 0:h.testCases)||(Array.isArray(h)?h:[]),A=C.useMemo(()=>new Set(g.map(f=>f.id)),[g]),P=C.useMemo(()=>((l==null?void 0:l.testCases)||(Array.isArray(l)?l:[])).filter(m=>{var x,c;if(A.has(m.id))return!1;if(p){const o=p.toLowerCase();return((x=m.title)==null?void 0:x.toLowerCase().includes(o))||((c=m.id)==null?void 0:c.toLowerCase().includes(o))}return!0}),[l,A,p]),M=f=>{y(m=>{const x=new Set(m);return x.has(f)?x.delete(f):x.add(f),x})},$=()=>{v.size!==0&&i.mutate({reqId:s,testCaseIds:Array.from(v)},{onSuccess:u})};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:u,children:e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 w-full max-w-xl mx-4 shadow-2xl",onClick:f=>f.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/5",children:[e.jsx("h3",{className:"text-gray-200 font-semibold",children:"Link Test Cases"}),e.jsx("button",{onClick:u,className:"text-gray-500 hover:text-gray-300 transition-colors",children:e.jsx(re,{size:18})})]}),e.jsx("div",{className:"px-5 py-3 border-b border-white/5",children:e.jsxs("div",{className:"relative",children:[e.jsx(ne,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:p,onChange:f=>r(f.target.value),placeholder:"Search test cases...",className:"w-full bg-surface-2 border border-white/10 rounded-lg pl-9 pr-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50"})]})}),e.jsx("div",{className:"px-5 py-3 max-h-[40vh] overflow-y-auto",children:b?e.jsx(U,{label:"Loading test cases..."}):P.length===0?e.jsx("p",{className:"text-gray-500 text-sm text-center py-8",children:"No available test cases to link."}):e.jsx("div",{className:"space-y-1.5",children:P.map(f=>e.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-surface-2 cursor-pointer transition-colors",children:[e.jsx("input",{type:"checkbox",checked:v.has(f.id),onChange:()=>M(f.id),className:"rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500/30"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:f.title}),e.jsx("p",{className:"text-xs text-gray-500 font-mono",children:f.id})]}),f.priority&&e.jsx(V,{priority:f.priority})]},f.id))})}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-t border-white/5",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:[v.size," selected"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:u,className:"px-4 py-2 text-sm font-medium text-gray-400 hover:text-gray-200 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:$,disabled:v.size===0||i.isPending,className:"flex items-center gap-1.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg px-4 py-2 text-sm font-medium transition-colors",children:[i.isPending?e.jsx(le,{size:14,className:"animate-spin"}):e.jsx(ie,{size:14}),"Link Selected"]})]})]})]})})}function lt(){const[s,u]=C.useState(""),[l,b]=C.useState(""),[h,i]=C.useState(null),[p,r]=C.useState(null),[v,y]=C.useState(null),[g]=Re("reqId");C.useEffect(()=>{g&&(r(g),requestAnimationFrame(()=>{var c;return(c=document.getElementById(`req-${g}`))==null?void 0:c.scrollIntoView({block:"center",behavior:"smooth"})}))},[g]);const A=C.useMemo(()=>{const c={};return l&&(c.priority=l),s&&(c.search=s),Object.keys(c).length>0?c:void 0},[l,s]),{data:P,isLoading:M}=Me(A),{data:$}=$e(),f=C.useMemo(()=>{const c=Array.isArray($==null?void 0:$.sources)?$.sources:Array.isArray($)?$:[];return new Map(c.map(o=>[o.id,o.title]))},[$]),m=c=>{const o=/^source:(.+)$/.exec(c||"");return o?f.get(o[1])??"Deleted source":c||"-"};ze();const x=(P==null?void 0:P.requirements)||(Array.isArray(P)?P:[]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 gap-3 flex-wrap",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Requirements"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ne,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:s,onChange:c=>u(c.target.value),placeholder:"Search requirements...",className:"bg-surface-2 border border-white/10 rounded-lg pl-9 pr-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50 w-56"})]}),e.jsx("div",{className:"flex items-center gap-1.5 text-xs text-gray-500",children:e.jsx(Ve,{size:12})}),e.jsxs("select",{value:l,onChange:c=>b(c.target.value),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-xs text-gray-300 focus:outline-none focus:border-brand-500/50",children:[e.jsx("option",{value:"",children:"All Priorities"}),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.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:M?e.jsx(U,{}):x.length===0?e.jsx(_,{icon:D,title:"No requirements found",subtitle:"Requirements are derived from Sources via AI Test Gen. Add a source and generate test cases to populate this list."}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-left",children:[e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider w-8"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"External ID"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Title"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Priority"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Source"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider text-center",children:"Linked TCs"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:x.map(c=>{const o=p===c.id;return e.jsxs(Te.Fragment,{children:[e.jsxs("tr",{id:`req-${c.id}`,className:"group cursor-pointer hover:bg-white/5 transition-colors",onClick:()=>r(o?null:c.id),children:[e.jsx("td",{className:"px-4 py-3 w-8",children:o?e.jsx(Z,{size:14,className:"text-gray-500"}):e.jsx(Q,{size:14,className:"text-gray-500"})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx("span",{className:"text-xs font-mono text-gray-500",children:c.externalId||c.id})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-gray-200 truncate block max-w-xs",children:c.title})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx(V,{priority:c.priority||"medium"})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx("span",{className:"text-xs text-gray-400",title:c.sourceQuote||void 0,children:m(c.source)})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap text-center",children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-gray-400",children:[e.jsx(ie,{size:12})," ",c.linkedTestCaseCount??c.testCaseCount??0]})})]}),o&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"p-0",children:e.jsx(rt,{reqId:c.id,onLink:()=>y(c.id)})})})]},c.id)})})]})}),h&&e.jsx(nt,{initial:h,onClose:()=>i(null)}),v&&e.jsx(it,{reqId:v,onClose:()=>y(null)})]})}function ct({sourceTrace:s,expandedSources:u,setExpandedSources:l}){const b=(s==null?void 0:s.sources)||[];if(b.length===0)return e.jsx(_,{icon:D,title:"No source documents with test cases",subtitle:"Generate test cases from Sources in AI Test Gen to see document-level traceability here."});const h=i=>{l(p=>{const r=new Set(p);return r.has(i)?r.delete(i):r.add(i),r})};return e.jsx("div",{className:"space-y-4",children:b.map(i=>{const p=u.has(i.sourceId),r=i.coveragePercent??0,v=r>=80?"text-emerald-400":r>=50?"text-amber-400":"text-red-400",y=r>=80?"bg-emerald-500":r>=50?"bg-amber-500":"bg-red-500";return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden hover:border-white/15 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 cursor-pointer hover:bg-white/5 transition-colors",onClick:()=>h(i.sourceId),children:[e.jsx("div",{className:"flex-shrink-0",children:p?e.jsx(Z,{size:16,className:"text-gray-500"}):e.jsx(Q,{size:16,className:"text-gray-500"})}),e.jsx("div",{className:"flex-shrink-0 w-9 h-9 rounded-lg bg-brand-500/10 border border-brand-500/20 flex items-center justify-center",children:e.jsx(D,{size:16,className:"text-brand-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-200 truncate",children:i.sourceTitle}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:[i.fileName&&e.jsxs("span",{className:"mr-3",children:["📎 ",i.fileName]}),e.jsxs("span",{className:"text-emerald-400 font-medium",children:[i.totalTestCases," test case",i.totalTestCases!==1?"s":""," generated"]}),(i.manuallyLinkedCount??0)>0&&e.jsxs("span",{className:"ml-3 text-amber-400",children:["· ",i.manuallyLinkedCount," test case",i.manuallyLinkedCount!==1?"s":""," linked manually"]})]})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-shrink-0",children:[e.jsx("div",{className:"text-right",children:e.jsxs("p",{className:`text-lg font-bold ${v}`,children:[r,"%"]})}),e.jsx("div",{className:"w-16 h-2 bg-surface-2 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${y} rounded-full transition-all`,style:{width:`${r}%`}})})]})]}),p&&e.jsx("div",{className:"border-t border-white/5 px-5 py-4",children:e.jsx(Ze,{sourceId:i.sourceId})})]},i.sourceId)})})}function ot(){const{data:s,isLoading:u}=Ae(),{data:l,isLoading:b}=Pe(),[h,i]=ue("subtab",["document","list"],"document"),[p,r]=C.useState(new Set);if(u||b)return e.jsx(U,{label:"Building traceability matrix..."});const g=((l==null?void 0:l.matrix)||(Array.isArray(l)?l:[])).map(m=>{const x=m.requirement||m,c=(m.testCases||[]).map(z=>{const I=z.testCase||z,q=z.mapping||null,B=z.latestExecution||null;return{id:I.id,title:I.title||I.name,type:I.type,priority:I.priority,automationStatus:I.automationStatus||I.automation_status,scriptPath:(q==null?void 0:q.scriptPath)||(q==null?void 0:q.script_path)||null,latestResult:(B==null?void 0:B.status)||"not_run"}}),o=c.map(z=>z.latestResult),k=o.includes("failed")?"failed":o.every(z=>z==="passed")&&o.length>0?"passed":"not_run",a=c.filter(z=>z.automationStatus==="automated"||z.scriptPath).length,Y=c.length===0?"none":a===c.length?"full":"partial";return{id:x.id,externalId:x.externalId||x.external_id,title:x.title,priority:x.priority,status:x.status,testCases:c,tcCount:c.length,overallResult:k,coverageLevel:Y}}).filter(m=>m.status==="active"||m.status==="draft");if(g.length===0)return e.jsx(_,{icon:ge,title:"No traceability data",subtitle:"Create requirements and link test cases to build the matrix."});const A=new Map;g.forEach(m=>{m.testCases.forEach(x=>{A.has(x.id)||A.set(x.id,{id:x.id,title:x.title,type:x.type})})});const P=Array.from(A.values()),M=g.reduce((m,x)=>m+x.tcCount,0),$=g.filter(m=>m.tcCount>0).length,f=g.length>0?Math.round($/g.length*100):0;return e.jsxs("div",{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:"Traceability Matrix"}),e.jsx("p",{className:"text-sm text-gray-400 mt-0.5",children:"Source Document → Content Sections → Test Cases mapping"})]}),e.jsx("div",{className:"flex items-center gap-1 bg-surface-2 rounded-lg p-0.5 border border-white/5",children:[{key:"document",label:"Detailed View",icon:e.jsx(Ye,{size:12})},{key:"list",label:"List",icon:e.jsx(ae,{size:12})}].map(m=>e.jsxs("button",{onClick:()=>i(m.key),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${h===m.key?"bg-brand-600 text-white shadow-sm":"text-gray-400 hover:text-gray-200"}`,children:[m.icon," ",m.label]},m.key))})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-5",children:[e.jsxs("div",{className:"bg-surface-1 rounded-lg border border-white/5 px-4 py-3",children:[e.jsx("p",{className:"text-[10px] font-medium text-gray-500 uppercase tracking-wider",children:"Requirements"}),e.jsx("p",{className:"text-xl font-bold text-gray-200 mt-0.5",children:g.length})]}),e.jsxs("div",{className:"bg-surface-1 rounded-lg border border-white/5 px-4 py-3",children:[e.jsx("p",{className:"text-[10px] font-medium text-gray-500 uppercase tracking-wider",children:"Linked Test Cases"}),e.jsx("p",{className:"text-xl font-bold text-gray-200 mt-0.5",children:P.length})]}),e.jsxs("div",{className:"bg-surface-1 rounded-lg border border-white/5 px-4 py-3",children:[e.jsx("p",{className:"text-[10px] font-medium text-gray-500 uppercase tracking-wider",children:"Links"}),e.jsx("p",{className:"text-xl font-bold text-brand-300 mt-0.5",children:M})]}),e.jsxs("div",{className:"bg-surface-1 rounded-lg border border-white/5 px-4 py-3",children:[e.jsx("p",{className:"text-[10px] font-medium text-gray-500 uppercase tracking-wider",children:"Requirement Coverage"}),e.jsxs("p",{className:"text-xl font-bold text-gray-200 mt-0.5",children:[f,"%"]}),e.jsxs("p",{className:"text-[10px] text-gray-500 mt-0.5",children:[$,"/",g.length," covered"]})]})]}),h==="document"?e.jsx(ct,{sourceTrace:s,expandedSources:p,setExpandedSources:r}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-400",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block w-3 h-3 rounded bg-emerald-500/30 border border-emerald-500/40"})," Passed"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block w-3 h-3 rounded bg-red-500/30 border border-red-500/40"})," Failed"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block w-3 h-3 rounded bg-gray-500/20 border border-white/10"})," Not Run"]})]}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-left",children:[e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Requirement"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Linked Test Cases"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider text-center",children:"Count"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider text-center",children:"Result"}),e.jsx("th",{className:"px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider text-center",children:"Coverage"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:g.map(m=>e.jsxs("tr",{className:m.tcCount===0?"bg-red-500/5":m.coverageLevel==="full"?"bg-emerald-500/5":"",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{priority:m.priority||"medium"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-200 text-sm font-medium",children:m.title}),e.jsx("p",{className:"text-[10px] font-mono text-gray-500",children:m.externalId||m.id})]})]})}),e.jsx("td",{className:"px-4 py-3",children:m.testCases.length===0?e.jsx("span",{className:"text-gray-500 text-xs italic",children:"No test cases linked"}):e.jsx("div",{className:"flex flex-wrap gap-1.5",children:m.testCases.map(x=>{const c=x.latestResult==="passed"?"bg-emerald-500/15 text-emerald-300 border-emerald-500/30":x.latestResult==="failed"?"bg-red-500/15 text-red-300 border-red-500/30":"bg-gray-500/15 text-gray-300 border-white/10",o=x.title.length>25?x.title.slice(0,25)+"…":x.title;return e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium border ${c}`,title:`${x.id} — ${x.title} — ${x.latestResult}`,children:[x.latestResult==="passed"?"✓":x.latestResult==="failed"?"✗":"●",e.jsx("span",{className:"font-mono opacity-80",children:x.id}),e.jsx("span",{children:o})]},x.id)})})}),e.jsx("td",{className:"px-4 py-3 text-center whitespace-nowrap",children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-gray-400",children:[e.jsx(ae,{size:12})," ",m.tcCount]})}),e.jsx("td",{className:"px-4 py-3 text-center whitespace-nowrap",children:e.jsx(st,{result:m.overallResult})}),e.jsx("td",{className:"px-4 py-3 text-center whitespace-nowrap",children:e.jsx(at,{level:m.coverageLevel})})]},m.id))})]})})]})]})}function dt(){var m,x,c;const{data:s,isLoading:u}=Ie(),{data:l}=pe();if(u)return e.jsx(U,{label:"Computing coverage metrics..."});const b=s||{},h=l||{};b.requirementCoverage??b.requirementCoveragePercent;const i=b.automationCoverage??b.automationCoveragePercent??0,p=b.sourceCoverage??0,r=((m=h.orphanTestCases)==null?void 0:m.length)??b.orphanTestCases??0,v=((x=h.orphanScripts)==null?void 0:x.length)??b.orphanScripts??0,y=((c=h.orphanSources)==null?void 0:c.length)??0,g=b.testCaseByPriority||{},A=["critical","high","medium","low"],P={critical:"bg-rose-400",high:"bg-orange-500",medium:"bg-amber-500",low:"bg-emerald-500"},M=A.map(o=>{var k,a;return{label:K(o),automated:((k=g[o])==null?void 0:k.automated)??0,total:((a=g[o])==null?void 0:a.total)??0,color:P[o]||"bg-gray-500"}}).filter(o=>o.total>0),$=b.byType||{},f=Object.entries($).map(([o,k])=>({type:o,count:(k==null?void 0:k.count)??k??0})).filter(o=>o.count>0);return e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200 mb-4",children:"Coverage Dashboard"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-400 mb-3",children:[e.jsx(Je,{size:16}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider",children:"Automation Coverage"})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsxs("span",{className:"text-3xl font-bold text-emerald-400",children:[Math.round(i),"%"]})}),e.jsx("div",{className:"mt-3 h-2 bg-surface-2 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-emerald-500 rounded-full transition-all",style:{width:`${Math.min(i,100)}%`}})})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-400 mb-3",children:[e.jsx(D,{size:16}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider",children:"Source Coverage"})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsxs("span",{className:"text-3xl font-bold text-purple-400",children:[Math.round(p),"%"]})}),e.jsx("div",{className:"mt-3 h-2 bg-surface-2 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-purple-500 rounded-full transition-all",style:{width:`${Math.min(p,100)}%`}})})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-400 mb-3",children:[e.jsx(H,{size:16}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider",children:"Orphan Test Cases"})]}),e.jsx("span",{className:`text-3xl font-bold ${r>0?"text-amber-400":"text-gray-500"}`,children:r}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Not linked to any requirement"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-400 mb-3",children:[e.jsx(ee,{size:16}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider",children:"Orphan Test Scripts"})]}),e.jsx("span",{className:`text-3xl font-bold ${v>0?"text-orange-400":"text-gray-500"}`,children:v}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Mapped script with no test case"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-400 mb-3",children:[e.jsx(D,{size:16}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider",children:"Orphan Sources"})]}),e.jsx("span",{className:`text-3xl font-bold ${y>0?"text-purple-400":"text-gray-500"}`,children:y}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Sources with no linked test cases"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-300 mb-4 flex items-center gap-2",children:[e.jsx(be,{size:14,className:"text-brand-300"})," Test Case Automation by Priority"]}),e.jsx("div",{className:"space-y-3",children:M.length===0?e.jsx("p",{className:"text-gray-500 text-sm py-4 text-center",children:"No test cases yet."}):M.map(o=>{const k=o.total>0?Math.round(o.automated/o.total*100):0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs text-gray-400",children:o.label}),e.jsxs("span",{className:"text-xs text-gray-500",children:[o.automated,"/",o.total," automated (",k,"%)"]})]}),e.jsx("div",{className:"h-2 bg-surface-2 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${o.color} rounded-full transition-all`,style:{width:`${k}%`}})})]},o.label)})})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-300 mb-4 flex items-center gap-2",children:[e.jsx(ae,{size:14,className:"text-brand-300"})," Coverage by Type"]}),f.length===0?e.jsx("p",{className:"text-gray-500 text-sm py-4 text-center",children:"No type distribution data available."}):e.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(o=>{const k=fe[o.type]||"bg-gray-500/20 text-gray-300";return e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium ${k}`,children:[K(o.type),e.jsxs("span",{className:"opacity-70",children:["(",o.count,")"]})]},o.type)})})]})]})]})}function xt(){const{data:s,isLoading:u}=pe();if(u)return e.jsx(U,{label:"Scanning for orphan items..."});const l=s||{},b=l.orphanTestCases||l.testCases||[],h=l.orphanScripts||l.scripts||[],i=l.orphanSources||[],p=l.unmappedScripts||[];return e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200 mb-4",children:"Orphan Detection"}),e.jsx("p",{className:"text-sm text-gray-400 mb-6",children:"Find unlinked items that may need attention."}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-white/5",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-300 flex items-center gap-2",children:[e.jsx(H,{size:14,className:"text-amber-400"}),"Orphan Test Cases",e.jsx("span",{className:`inline-flex items-center justify-center min-w-[20px] h-5 rounded-full text-xs font-medium px-1.5 ${b.length>0?"bg-amber-500/20 text-amber-300":"bg-gray-500/20 text-gray-400"}`,children:b.length})]}),e.jsx("span",{className:"text-xs text-gray-500",children:"Not linked to any requirement"})]}),e.jsx("div",{className:"p-0",children:b.length===0?e.jsx(_,{icon:G,title:"No orphan test cases",subtitle:"All test cases are linked to requirements."}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-left",children:[e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Title"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Type"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Priority"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Created"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:b.map(r=>e.jsxs("tr",{className:"hover:bg-surface-2/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-mono text-gray-500",children:r.id}),e.jsx("span",{className:"text-gray-200",children:r.title})]})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:r.type?e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${fe[r.type]||"bg-gray-500/20 text-gray-300"}`,children:K(r.type)}):e.jsx("span",{className:"text-gray-600",children:"-"})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:e.jsx(V,{priority:r.priority||"medium"})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap text-xs text-gray-400",children:me(r.createdAt)})]},r.id))})]})})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-white/5",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-300 flex items-center gap-2",children:[e.jsx(ee,{size:14,className:"text-orange-400"}),"Unmapped Test Scripts",e.jsx("span",{className:`inline-flex items-center justify-center min-w-[20px] h-5 rounded-full text-xs font-medium px-1.5 ${p.length>0?"bg-orange-500/20 text-orange-300":"bg-gray-500/20 text-gray-400"}`,children:p.length})]}),e.jsx("span",{className:"text-xs text-gray-500",children:"Test files in project not linked to any test case"})]}),e.jsx("div",{className:"p-0",children:p.length===0&&h.length===0?e.jsx(_,{icon:G,title:"No unmapped scripts",subtitle:"All test scripts in the project are mapped to test cases."}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-left",children:[e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Script Path"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"File Name"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Framework"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Status"})]})}),e.jsxs("tbody",{className:"divide-y divide-white/5",children:[p.map((r,v)=>e.jsxs("tr",{className:"hover:bg-surface-2/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-2.5",children:e.jsx("span",{className:"text-xs font-mono text-gray-400",children:r.path})}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsx("span",{className:"text-gray-200 text-sm",children:r.name})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-gray-500/20 text-gray-300",children:r.framework})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-amber-500/15 text-amber-300",children:[e.jsx(H,{size:10})," Not Mapped"]})})]},r.path||v)),h.map((r,v)=>e.jsxs("tr",{className:"hover:bg-surface-2/50 transition-colors bg-red-500/[0.03]",children:[e.jsx("td",{className:"px-4 py-2.5",children:e.jsx("span",{className:"text-xs font-mono text-gray-400",children:r.scriptPath||r.path})}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsx("span",{className:"text-gray-200 text-sm",children:r.testName||r.name||"-"})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-gray-500/20 text-gray-300",children:r.framework?K(r.framework):"-"})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-red-500/15 text-red-300",children:[e.jsx(ye,{size:10})," Orphaned"]})})]},`orphan-${r.id||v}`))]})]})})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-white/5",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-300 flex items-center gap-2",children:[e.jsx(D,{size:14,className:"text-purple-400"}),"Orphan Sources",e.jsx("span",{className:`inline-flex items-center justify-center min-w-[20px] h-5 rounded-full text-xs font-medium px-1.5 ${i.length>0?"bg-purple-500/20 text-purple-300":"bg-gray-500/20 text-gray-400"}`,children:i.length})]}),e.jsx("span",{className:"text-xs text-gray-500",children:"Sources with no generated or manually-linked test cases"})]}),e.jsx("div",{className:"p-0",children:i.length===0?e.jsx(_,{icon:G,title:"No orphan sources",subtitle:"All sources have been used for test generation."}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-left",children:[e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Title"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Type"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Created"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:i.map(r=>{const v={requirement:"📋 Requirement",nlp:"💬 NLP",jira:"🎫 JIRA",document:"📎 Document"};return e.jsxs("tr",{className:"hover:bg-surface-2/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-2.5",children:e.jsx("span",{className:"text-gray-200",children:r.title})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:e.jsx("span",{className:"text-xs text-gray-400",children:v[r.type]||r.type})}),e.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap text-xs text-gray-400",children:me(r.createdAt)})]},r.id)})})]})})]})]})}function jt(){const[s,u]=ue("tab",["requirements","traceability","coverage","orphans"],"requirements");return e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(Ke,{size:24,className:"text-brand-300"}),"Traceability, Coverage & Requirements"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Track requirement coverage, manage traceability, and find orphan items"})]}),e.jsx(Le,{type:"coverage-matrix",formats:["xlsx"],label:"Export Matrix"})]})})}),e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 flex gap-1",children:tt.map(l=>{const b=l.icon,h=s===l.key;return e.jsxs("button",{onClick:()=>u(l.key),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors ${h?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200 hover:border-white/10"}`,children:[e.jsx(b,{size:16}),l.label]},l.key)})})}),e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-8",children:[s==="requirements"&&e.jsx(lt,{}),s==="traceability"&&e.jsx(ot,{}),s==="coverage"&&e.jsx(dt,{}),s==="orphans"&&e.jsx(xt,{})]})]})}export{jt as CoveragePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as h,j as e}from"./vendor-react-DOVfxdUy.js";import{r as P,a as z,u as L,a3 as U}from"./vendor-icons-D_Dmmj8d.js";function A(r){if(!r||!r.trim())return!1;const l=r.trim().split(/\s+/);if(l.length!==5)return!1;const o=[{min:0,max:59},{min:0,max:23},{min:1,max:31},{min:1,max:12},{min:0,max:7}];for(let s=0;s<5;s++)if(!B(l[s],o[s].min,o[s].max))return!1;return!0}function B(r,l,o){if(r==="*")return!0;const s=r.split(",");for(const n of s){const a=n.match(/^(\*|\d+-\d+)\/(\d+)$/);if(a){const x=parseInt(a[2],10);if(isNaN(x)||x<1||a[1]!=="*"&&!H(a[1],l,o))return!1;continue}if(n.includes("-")){if(!H(n,l,o))return!1;continue}const i=parseInt(n,10);if(isNaN(i)||i<l||i>o)return!1}return!0}function H(r,l,o){const s=r.split("-");if(s.length!==2)return!1;const n=parseInt(s[0],10),a=parseInt(s[1],10);return!isNaN(n)&&!isNaN(a)&&n>=l&&a<=o&&n<=a}function V(r){if(!r)return"";const l=r.trim().split(/\s+/);if(l.length!==5)return r;const[o,s,n,a,i]=l;if(o==="*"&&s==="*"&&n==="*"&&a==="*"&&i==="*")return"Every minute";const x=o.match(/^\*\/(\d+)$/);if(x&&s==="*"&&n==="*"&&a==="*"&&i==="*")return`Every ${x[1]} minutes`;const p=s.match(/^\*\/(\d+)$/);if(p&&n==="*"&&a==="*"&&i==="*"){const m=o==="0"?"":` at :${o.padStart(2,"0")}`;return`Every ${p[1]} hours${m}`}const d=parseInt(o,10),u=parseInt(s,10);if(!isNaN(d)&&!isNaN(u)){const m=q(u,d);if(n==="*"&&a==="*"&&i==="*")return`Daily at ${m}`;if(n==="*"&&a==="*"&&X(i))return`Weekdays at ${m}`;if(n==="*"&&a==="*"&&(i==="0,6"||i==="6,0"))return`Weekends at ${m}`;if(n==="*"&&a==="*"&&i!=="*"){const f=Y(i);if(f)return`${f} at ${m}`}if(a==="*"&&i==="*"&&n!=="*")return`Monthly on day ${n} at ${m}`}return!isNaN(d)&&s==="*"&&n==="*"&&a==="*"&&i==="*"?`Hourly at :${o.padStart(2,"0")}`:r}function q(r,l){const o=r>=12?"PM":"AM";return`${r===0?12:r>12?r-12:r}:${String(l).padStart(2,"0")} ${o}`}function Y(r){const l=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],o=r.split(","),s=[];for(const n of o)if(n.includes("-")){const[a,i]=n.split("-").map(Number);if(a==null||i==null||isNaN(a)||isNaN(i))return null;for(let x=a;x<=i;x++)l[x]&&s.push(l[x])}else{const a=parseInt(n,10);!isNaN(a)&&l[a]&&s.push(l[a])}return s.length===0?null:s.join(", ")}function G(r,l=3){if(!A(r))return[];const o=r.trim().split(/\s+/),[s,n,a,i,x]=o,p=[],d=new Date,u=new Date(d);u.setSeconds(0,0),u.setMinutes(u.getMinutes()+1);const m=366*24*60;let f=0;for(;p.length<l&&f<m;)N(u.getMinutes(),s)&&N(u.getHours(),n)&&N(u.getDate(),a)&&N(u.getMonth()+1,i)&&J(u.getDay(),x)&&p.push(new Date(u)),u.setMinutes(u.getMinutes()+1),f++;return p}function N(r,l){if(l==="*")return!0;const o=l.split(",");for(const s of o){const n=s.match(/^(\*|\d+-\d+)\/(\d+)$/);if(n){const a=parseInt(n[2],10);if(n[1]==="*"){if(r%a===0)return!0}else{const[i]=n[1].split("-").map(Number);if(i!=null&&r-i>=0&&(r-i)%a===0)return!0}continue}if(s.includes("-")){const[a,i]=s.split("-").map(Number);if(a!=null&&i!=null&&r>=a&&r<=i)return!0;continue}if(parseInt(s,10)===r)return!0}return!1}function J(r,l){if(l==="*")return!0;const o=l.replace(/7/g,"0");return N(r,o)}function K(r){if(!r)return{tab:"daily",atHour:9,atMinute:0};const l=r.trim().split(/\s+/);if(l.length!==5)return{tab:"advanced"};const[o,s,n,a,i]=l,x=o.match(/^\*\/(\d+)$/);if(x&&s==="*"&&n==="*"&&a==="*"&&i==="*")return{tab:"minutes",everyMinutes:parseInt(x[1],10)};const p=s.match(/^\*\/(\d+)$/);if(p&&n==="*"&&a==="*"&&i==="*")return{tab:"hourly",everyHours:parseInt(p[1],10),atMinute:parseInt(o,10)||0};if(s==="*"&&n==="*"&&a==="*"&&i==="*"&&/^\d+$/.test(o))return{tab:"hourly",everyHours:1,atMinute:parseInt(o,10)};const d=parseInt(o,10),u=parseInt(s,10);if(!isNaN(d)&&!isNaN(u)){if(n==="*"&&a==="*"&&i!=="*"){const m=D(i);return{tab:"weekly",atHour:u,atMinute:d,daysOfWeek:m}}if(i==="*"&&a!=="*"&&n!=="*")return{tab:"monthly",atHour:u,atMinute:d,dayOfMonth:parseInt(n,10),everyMonths:parseInt(a,10)||1};if(i==="*"&&n!=="*")return{tab:"monthly",atHour:u,atMinute:d,dayOfMonth:parseInt(n,10)};if(n==="*"&&a==="*"&&i==="*")return{tab:"daily",atHour:u,atMinute:d}}return{tab:"advanced"}}const Q=/^[0-7](-[0-7])?(,[0-7](-[0-7])?)*$/;function w(r){return Q.test(r)?[...new Set(D(r).map(l=>l===7?0:l))].sort((l,o)=>l-o):null}function X(r){var l;return((l=w(r))==null?void 0:l.join(","))==="1,2,3,4,5"}function Z(r,l){if(r.trim()===l.trim())return!0;const o=r.trim().split(/\s+/),s=l.trim().split(/\s+/);if(o.length!==5||s.length!==5)return!1;for(let i=0;i<4;i++)if(o[i]!==s[i])return!1;const n=w(o[4]),a=w(s[4]);return!!n&&!!a&&n.join(",")===a.join(",")}function D(r){const l=[],o=r.split(",");for(const s of o)if(s.includes("-")){const[n,a]=s.split("-").map(Number);if(n!=null&&a!=null)for(let i=n;i<=a;i++)l.push(i)}else{const n=parseInt(s,10);isNaN(n)||l.push(n)}return l}const ee=[{key:"minutes",label:"Minutes"},{key:"hourly",label:"Hourly"},{key:"daily",label:"Daily"},{key:"weekly",label:"Weekly"},{key:"monthly",label:"Monthly"},{key:"advanced",label:"Advanced"}],te=[1,2,3,5,10,15,20,30],se=[1,2,3,4,6,8,12],re=[0,5,10,15,20,30,45],ne=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function oe({value:r,onChange:l}){const o=h.useMemo(()=>K(r),[]),[s,n]=h.useState(o.tab),[a,i]=h.useState(o.everyMinutes??5),[x,p]=h.useState(o.everyHours??1),[d,u]=h.useState(o.atMinute??0),[m,f]=h.useState(o.atHour??9),[$,O]=h.useState(o.daysOfWeek??[1,2,3,4,5]),[S,T]=h.useState(o.dayOfMonth??1),[v,I]=h.useState(r||"0 8 * * *"),k=()=>{switch(s){case"minutes":return`*/${a} * * * *`;case"hourly":return x===1?`${d} * * * *`:`${d} */${x} * * *`;case"daily":return`${d} ${m} * * *`;case"weekly":return`${d} ${m} * * ${$.sort().join(",")}`;case"monthly":return`${d} ${m} ${S} * *`;case"advanced":return v;default:return"0 8 * * *"}},g=k(),y=A(g),W=y?V(g):"Invalid expression",C=h.useMemo(()=>y?G(g,3):[],[g,y]);h.useEffect(()=>{y&&g!==r&&!Z(g,r)&&l(g)},[g,y]);const E=t=>{t==="advanced"&&I(k()),n(t)},_=t=>{O(c=>c.includes(t)?c.filter(M=>M!==t):[...c,t].sort())},j=t=>{const c=t>=12?"PM":"AM";return`${t===0?12:t>12?t-12:t} ${c}`};return e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex gap-1 p-1 bg-surface-2 rounded-xl",children:ee.map(({key:t,label:c})=>e.jsx("button",{onClick:()=>E(t),className:`flex-1 px-2 py-1.5 rounded-lg text-xs font-medium transition-colors ${s===t?"bg-brand-500/15 text-brand-300 shadow-sm":"text-gray-500 hover:text-gray-300 hover:bg-white/5"}`,children:c},t))}),e.jsxs("div",{className:"px-1 py-2",children:[s==="minutes"&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-gray-400",children:"Run every"}),e.jsx("select",{value:a,onChange:t=>i(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:te.map(t=>e.jsx("option",{value:t,children:t},t))}),e.jsx("span",{className:"text-sm text-gray-400",children:"minutes"})]}),s==="hourly"&&e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("span",{className:"text-sm text-gray-400",children:"Run every"}),e.jsx("select",{value:x,onChange:t=>p(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:se.map(t=>e.jsx("option",{value:t,children:t},t))}),e.jsx("span",{className:"text-sm text-gray-400",children:"hour(s) at minute"}),e.jsx("select",{value:d,onChange:t=>u(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:re.map(t=>e.jsxs("option",{value:t,children:[":",String(t).padStart(2,"0")]},t))})]}),s==="daily"&&e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("span",{className:"text-sm text-gray-400",children:"Run daily at"}),e.jsx("select",{value:m,onChange:t=>f(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:Array.from({length:24},(t,c)=>e.jsx("option",{value:c,children:j(c)},c))}),e.jsx("span",{className:"text-sm text-gray-400",children:":"}),e.jsx("select",{value:d,onChange:t=>u(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:Array.from({length:60},(t,c)=>e.jsx("option",{value:c,children:String(c).padStart(2,"0")},c))})]}),s==="weekly"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-gray-400 block mb-2",children:"Run on"}),e.jsx("div",{className:"flex gap-1.5",children:ne.map((t,c)=>e.jsx("button",{onClick:()=>_(c),className:`w-10 h-10 rounded-lg text-xs font-semibold transition-colors ${$.includes(c)?"bg-emerald-500/20 text-emerald-300 border-2 border-emerald-500/50 shadow-sm shadow-emerald-500/10":"bg-surface-2 text-gray-500 border border-white/5 hover:bg-white/5 hover:text-gray-300"}`,children:t},c))})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("span",{className:"text-sm text-gray-400",children:"At"}),e.jsx("select",{value:m,onChange:t=>f(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:Array.from({length:24},(t,c)=>e.jsx("option",{value:c,children:j(c)},c))}),e.jsx("span",{className:"text-sm text-gray-400",children:":"}),e.jsx("select",{value:d,onChange:t=>u(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:Array.from({length:60},(t,c)=>e.jsx("option",{value:c,children:String(c).padStart(2,"0")},c))})]})]}),s==="monthly"&&e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("span",{className:"text-sm text-gray-400",children:"Run on day"}),e.jsx("select",{value:S,onChange:t=>T(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:Array.from({length:31},(t,c)=>e.jsx("option",{value:c+1,children:c+1},c+1))}),e.jsx("span",{className:"text-sm text-gray-400",children:"at"}),e.jsx("select",{value:m,onChange:t=>f(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:Array.from({length:24},(t,c)=>e.jsx("option",{value:c,children:j(c)},c))}),e.jsx("span",{className:"text-sm text-gray-400",children:":"}),e.jsx("select",{value:d,onChange:t=>u(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:Array.from({length:60},(t,c)=>e.jsx("option",{value:c,children:String(c).padStart(2,"0")},c))})]}),s==="advanced"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"grid grid-cols-5 gap-2",children:["Minute","Hour","Day","Month","Weekday"].map((t,c)=>{const R=v.split(/\s+/)[c]||"*";return e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] text-gray-500 uppercase tracking-wider mb-1",children:t}),e.jsx("input",{value:R,onChange:F=>{const b=v.split(/\s+/);for(;b.length<5;)b.push("*");b[c]=F.target.value,I(b.join(" "))},className:"w-full bg-surface-2 border border-white/10 rounded-lg px-2 py-1.5 text-sm text-gray-200 outline-none font-mono text-center focus:border-brand-500/40"}),e.jsx("div",{className:"text-[9px] text-gray-600 text-center mt-0.5",children:["0-59","0-23","1-31","1-12","0-6"][c]})]},t)})}),e.jsxs("div",{className:"text-[10px] text-gray-600 space-y-0.5 bg-surface-2/50 rounded-lg p-2",children:[e.jsxs("div",{children:[e.jsx("code",{className:"text-gray-400",children:"*"})," = every ",e.jsx("code",{className:"text-gray-400",children:"*/5"})," = every 5th ",e.jsx("code",{className:"text-gray-400",children:"1,3,5"})," = specific ",e.jsx("code",{className:"text-gray-400",children:"1-5"})," = range"]}),e.jsxs("div",{children:["Weekday: ",e.jsx("code",{className:"text-gray-400",children:"0"}),"=Sun ",e.jsx("code",{className:"text-gray-400",children:"1"}),"=Mon ... ",e.jsx("code",{className:"text-gray-400",children:"6"}),"=Sat ",e.jsx("code",{className:"text-gray-400",children:"1-5"}),"=Weekdays"]})]})]})]}),e.jsxs("div",{className:`rounded-xl p-3 space-y-1.5 ${y?"bg-surface-2/50 border border-white/5":"bg-red-500/5 border border-red-500/20"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[y?e.jsx(P,{size:13,className:"text-emerald-400 flex-shrink-0"}):e.jsx(z,{size:13,className:"text-red-400 flex-shrink-0"}),e.jsx("span",{className:`text-sm font-medium ${y?"text-gray-200":"text-red-400"}`,children:W})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-gray-500 font-mono",children:[e.jsx(L,{size:10}),e.jsx("span",{children:g})]}),y&&C.length>0&&e.jsxs("div",{className:"pt-1",children:[e.jsx("div",{className:"text-[10px] text-gray-600 mb-1",children:"Next runs:"}),C.map((t,c)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-gray-500",children:[e.jsx(U,{size:9,className:"flex-shrink-0"}),e.jsxs("span",{children:[t.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",year:"numeric"})," at ",t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})]})]},c))]})]})]})}export{oe as C,X as i};
|
|
1
|
+
import{r as h,j as e}from"./vendor-react-DOVfxdUy.js";import{s as P,a as z,v as L,a4 as U}from"./vendor-icons-Cm92aSc5.js";function A(r){if(!r||!r.trim())return!1;const l=r.trim().split(/\s+/);if(l.length!==5)return!1;const o=[{min:0,max:59},{min:0,max:23},{min:1,max:31},{min:1,max:12},{min:0,max:7}];for(let s=0;s<5;s++)if(!B(l[s],o[s].min,o[s].max))return!1;return!0}function B(r,l,o){if(r==="*")return!0;const s=r.split(",");for(const n of s){const a=n.match(/^(\*|\d+-\d+)\/(\d+)$/);if(a){const x=parseInt(a[2],10);if(isNaN(x)||x<1||a[1]!=="*"&&!H(a[1],l,o))return!1;continue}if(n.includes("-")){if(!H(n,l,o))return!1;continue}const i=parseInt(n,10);if(isNaN(i)||i<l||i>o)return!1}return!0}function H(r,l,o){const s=r.split("-");if(s.length!==2)return!1;const n=parseInt(s[0],10),a=parseInt(s[1],10);return!isNaN(n)&&!isNaN(a)&&n>=l&&a<=o&&n<=a}function V(r){if(!r)return"";const l=r.trim().split(/\s+/);if(l.length!==5)return r;const[o,s,n,a,i]=l;if(o==="*"&&s==="*"&&n==="*"&&a==="*"&&i==="*")return"Every minute";const x=o.match(/^\*\/(\d+)$/);if(x&&s==="*"&&n==="*"&&a==="*"&&i==="*")return`Every ${x[1]} minutes`;const p=s.match(/^\*\/(\d+)$/);if(p&&n==="*"&&a==="*"&&i==="*"){const m=o==="0"?"":` at :${o.padStart(2,"0")}`;return`Every ${p[1]} hours${m}`}const d=parseInt(o,10),u=parseInt(s,10);if(!isNaN(d)&&!isNaN(u)){const m=q(u,d);if(n==="*"&&a==="*"&&i==="*")return`Daily at ${m}`;if(n==="*"&&a==="*"&&X(i))return`Weekdays at ${m}`;if(n==="*"&&a==="*"&&(i==="0,6"||i==="6,0"))return`Weekends at ${m}`;if(n==="*"&&a==="*"&&i!=="*"){const f=Y(i);if(f)return`${f} at ${m}`}if(a==="*"&&i==="*"&&n!=="*")return`Monthly on day ${n} at ${m}`}return!isNaN(d)&&s==="*"&&n==="*"&&a==="*"&&i==="*"?`Hourly at :${o.padStart(2,"0")}`:r}function q(r,l){const o=r>=12?"PM":"AM";return`${r===0?12:r>12?r-12:r}:${String(l).padStart(2,"0")} ${o}`}function Y(r){const l=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],o=r.split(","),s=[];for(const n of o)if(n.includes("-")){const[a,i]=n.split("-").map(Number);if(a==null||i==null||isNaN(a)||isNaN(i))return null;for(let x=a;x<=i;x++)l[x]&&s.push(l[x])}else{const a=parseInt(n,10);!isNaN(a)&&l[a]&&s.push(l[a])}return s.length===0?null:s.join(", ")}function G(r,l=3){if(!A(r))return[];const o=r.trim().split(/\s+/),[s,n,a,i,x]=o,p=[],d=new Date,u=new Date(d);u.setSeconds(0,0),u.setMinutes(u.getMinutes()+1);const m=366*24*60;let f=0;for(;p.length<l&&f<m;)N(u.getMinutes(),s)&&N(u.getHours(),n)&&N(u.getDate(),a)&&N(u.getMonth()+1,i)&&J(u.getDay(),x)&&p.push(new Date(u)),u.setMinutes(u.getMinutes()+1),f++;return p}function N(r,l){if(l==="*")return!0;const o=l.split(",");for(const s of o){const n=s.match(/^(\*|\d+-\d+)\/(\d+)$/);if(n){const a=parseInt(n[2],10);if(n[1]==="*"){if(r%a===0)return!0}else{const[i]=n[1].split("-").map(Number);if(i!=null&&r-i>=0&&(r-i)%a===0)return!0}continue}if(s.includes("-")){const[a,i]=s.split("-").map(Number);if(a!=null&&i!=null&&r>=a&&r<=i)return!0;continue}if(parseInt(s,10)===r)return!0}return!1}function J(r,l){if(l==="*")return!0;const o=l.replace(/7/g,"0");return N(r,o)}function K(r){if(!r)return{tab:"daily",atHour:9,atMinute:0};const l=r.trim().split(/\s+/);if(l.length!==5)return{tab:"advanced"};const[o,s,n,a,i]=l,x=o.match(/^\*\/(\d+)$/);if(x&&s==="*"&&n==="*"&&a==="*"&&i==="*")return{tab:"minutes",everyMinutes:parseInt(x[1],10)};const p=s.match(/^\*\/(\d+)$/);if(p&&n==="*"&&a==="*"&&i==="*")return{tab:"hourly",everyHours:parseInt(p[1],10),atMinute:parseInt(o,10)||0};if(s==="*"&&n==="*"&&a==="*"&&i==="*"&&/^\d+$/.test(o))return{tab:"hourly",everyHours:1,atMinute:parseInt(o,10)};const d=parseInt(o,10),u=parseInt(s,10);if(!isNaN(d)&&!isNaN(u)){if(n==="*"&&a==="*"&&i!=="*"){const m=D(i);return{tab:"weekly",atHour:u,atMinute:d,daysOfWeek:m}}if(i==="*"&&a!=="*"&&n!=="*")return{tab:"monthly",atHour:u,atMinute:d,dayOfMonth:parseInt(n,10),everyMonths:parseInt(a,10)||1};if(i==="*"&&n!=="*")return{tab:"monthly",atHour:u,atMinute:d,dayOfMonth:parseInt(n,10)};if(n==="*"&&a==="*"&&i==="*")return{tab:"daily",atHour:u,atMinute:d}}return{tab:"advanced"}}const Q=/^[0-7](-[0-7])?(,[0-7](-[0-7])?)*$/;function w(r){return Q.test(r)?[...new Set(D(r).map(l=>l===7?0:l))].sort((l,o)=>l-o):null}function X(r){var l;return((l=w(r))==null?void 0:l.join(","))==="1,2,3,4,5"}function Z(r,l){if(r.trim()===l.trim())return!0;const o=r.trim().split(/\s+/),s=l.trim().split(/\s+/);if(o.length!==5||s.length!==5)return!1;for(let i=0;i<4;i++)if(o[i]!==s[i])return!1;const n=w(o[4]),a=w(s[4]);return!!n&&!!a&&n.join(",")===a.join(",")}function D(r){const l=[],o=r.split(",");for(const s of o)if(s.includes("-")){const[n,a]=s.split("-").map(Number);if(n!=null&&a!=null)for(let i=n;i<=a;i++)l.push(i)}else{const n=parseInt(s,10);isNaN(n)||l.push(n)}return l}const ee=[{key:"minutes",label:"Minutes"},{key:"hourly",label:"Hourly"},{key:"daily",label:"Daily"},{key:"weekly",label:"Weekly"},{key:"monthly",label:"Monthly"},{key:"advanced",label:"Advanced"}],te=[1,2,3,5,10,15,20,30],se=[1,2,3,4,6,8,12],re=[0,5,10,15,20,30,45],ne=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function oe({value:r,onChange:l}){const o=h.useMemo(()=>K(r),[]),[s,n]=h.useState(o.tab),[a,i]=h.useState(o.everyMinutes??5),[x,p]=h.useState(o.everyHours??1),[d,u]=h.useState(o.atMinute??0),[m,f]=h.useState(o.atHour??9),[$,O]=h.useState(o.daysOfWeek??[1,2,3,4,5]),[S,T]=h.useState(o.dayOfMonth??1),[v,I]=h.useState(r||"0 8 * * *"),k=()=>{switch(s){case"minutes":return`*/${a} * * * *`;case"hourly":return x===1?`${d} * * * *`:`${d} */${x} * * *`;case"daily":return`${d} ${m} * * *`;case"weekly":return`${d} ${m} * * ${$.sort().join(",")}`;case"monthly":return`${d} ${m} ${S} * *`;case"advanced":return v;default:return"0 8 * * *"}},g=k(),y=A(g),W=y?V(g):"Invalid expression",C=h.useMemo(()=>y?G(g,3):[],[g,y]);h.useEffect(()=>{y&&g!==r&&!Z(g,r)&&l(g)},[g,y]);const E=t=>{t==="advanced"&&I(k()),n(t)},_=t=>{O(c=>c.includes(t)?c.filter(M=>M!==t):[...c,t].sort())},j=t=>{const c=t>=12?"PM":"AM";return`${t===0?12:t>12?t-12:t} ${c}`};return e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex gap-1 p-1 bg-surface-2 rounded-xl",children:ee.map(({key:t,label:c})=>e.jsx("button",{onClick:()=>E(t),className:`flex-1 px-2 py-1.5 rounded-lg text-xs font-medium transition-colors ${s===t?"bg-brand-500/15 text-brand-300 shadow-sm":"text-gray-500 hover:text-gray-300 hover:bg-white/5"}`,children:c},t))}),e.jsxs("div",{className:"px-1 py-2",children:[s==="minutes"&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-gray-400",children:"Run every"}),e.jsx("select",{value:a,onChange:t=>i(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:te.map(t=>e.jsx("option",{value:t,children:t},t))}),e.jsx("span",{className:"text-sm text-gray-400",children:"minutes"})]}),s==="hourly"&&e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("span",{className:"text-sm text-gray-400",children:"Run every"}),e.jsx("select",{value:x,onChange:t=>p(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:se.map(t=>e.jsx("option",{value:t,children:t},t))}),e.jsx("span",{className:"text-sm text-gray-400",children:"hour(s) at minute"}),e.jsx("select",{value:d,onChange:t=>u(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:re.map(t=>e.jsxs("option",{value:t,children:[":",String(t).padStart(2,"0")]},t))})]}),s==="daily"&&e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("span",{className:"text-sm text-gray-400",children:"Run daily at"}),e.jsx("select",{value:m,onChange:t=>f(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:Array.from({length:24},(t,c)=>e.jsx("option",{value:c,children:j(c)},c))}),e.jsx("span",{className:"text-sm text-gray-400",children:":"}),e.jsx("select",{value:d,onChange:t=>u(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:Array.from({length:60},(t,c)=>e.jsx("option",{value:c,children:String(c).padStart(2,"0")},c))})]}),s==="weekly"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-gray-400 block mb-2",children:"Run on"}),e.jsx("div",{className:"flex gap-1.5",children:ne.map((t,c)=>e.jsx("button",{onClick:()=>_(c),className:`w-10 h-10 rounded-lg text-xs font-semibold transition-colors ${$.includes(c)?"bg-emerald-500/20 text-emerald-300 border-2 border-emerald-500/50 shadow-sm shadow-emerald-500/10":"bg-surface-2 text-gray-500 border border-white/5 hover:bg-white/5 hover:text-gray-300"}`,children:t},c))})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("span",{className:"text-sm text-gray-400",children:"At"}),e.jsx("select",{value:m,onChange:t=>f(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:Array.from({length:24},(t,c)=>e.jsx("option",{value:c,children:j(c)},c))}),e.jsx("span",{className:"text-sm text-gray-400",children:":"}),e.jsx("select",{value:d,onChange:t=>u(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:Array.from({length:60},(t,c)=>e.jsx("option",{value:c,children:String(c).padStart(2,"0")},c))})]})]}),s==="monthly"&&e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("span",{className:"text-sm text-gray-400",children:"Run on day"}),e.jsx("select",{value:S,onChange:t=>T(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:Array.from({length:31},(t,c)=>e.jsx("option",{value:c+1,children:c+1},c+1))}),e.jsx("span",{className:"text-sm text-gray-400",children:"at"}),e.jsx("select",{value:m,onChange:t=>f(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:Array.from({length:24},(t,c)=>e.jsx("option",{value:c,children:j(c)},c))}),e.jsx("span",{className:"text-sm text-gray-400",children:":"}),e.jsx("select",{value:d,onChange:t=>u(parseInt(t.target.value,10)),className:"bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none cursor-pointer",children:Array.from({length:60},(t,c)=>e.jsx("option",{value:c,children:String(c).padStart(2,"0")},c))})]}),s==="advanced"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"grid grid-cols-5 gap-2",children:["Minute","Hour","Day","Month","Weekday"].map((t,c)=>{const R=v.split(/\s+/)[c]||"*";return e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] text-gray-500 uppercase tracking-wider mb-1",children:t}),e.jsx("input",{value:R,onChange:F=>{const b=v.split(/\s+/);for(;b.length<5;)b.push("*");b[c]=F.target.value,I(b.join(" "))},className:"w-full bg-surface-2 border border-white/10 rounded-lg px-2 py-1.5 text-sm text-gray-200 outline-none font-mono text-center focus:border-brand-500/40"}),e.jsx("div",{className:"text-[9px] text-gray-600 text-center mt-0.5",children:["0-59","0-23","1-31","1-12","0-6"][c]})]},t)})}),e.jsxs("div",{className:"text-[10px] text-gray-600 space-y-0.5 bg-surface-2/50 rounded-lg p-2",children:[e.jsxs("div",{children:[e.jsx("code",{className:"text-gray-400",children:"*"})," = every ",e.jsx("code",{className:"text-gray-400",children:"*/5"})," = every 5th ",e.jsx("code",{className:"text-gray-400",children:"1,3,5"})," = specific ",e.jsx("code",{className:"text-gray-400",children:"1-5"})," = range"]}),e.jsxs("div",{children:["Weekday: ",e.jsx("code",{className:"text-gray-400",children:"0"}),"=Sun ",e.jsx("code",{className:"text-gray-400",children:"1"}),"=Mon ... ",e.jsx("code",{className:"text-gray-400",children:"6"}),"=Sat ",e.jsx("code",{className:"text-gray-400",children:"1-5"}),"=Weekdays"]})]})]})]}),e.jsxs("div",{className:`rounded-xl p-3 space-y-1.5 ${y?"bg-surface-2/50 border border-white/5":"bg-red-500/5 border border-red-500/20"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[y?e.jsx(P,{size:13,className:"text-emerald-400 flex-shrink-0"}):e.jsx(z,{size:13,className:"text-red-400 flex-shrink-0"}),e.jsx("span",{className:`text-sm font-medium ${y?"text-gray-200":"text-red-400"}`,children:W})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-gray-500 font-mono",children:[e.jsx(L,{size:10}),e.jsx("span",{children:g})]}),y&&C.length>0&&e.jsxs("div",{className:"pt-1",children:[e.jsx("div",{className:"text-[10px] text-gray-600 mb-1",children:"Next runs:"}),C.map((t,c)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-gray-500",children:[e.jsx(U,{size:9,className:"flex-shrink-0"}),e.jsxs("span",{children:[t.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",year:"numeric"})," at ",t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})]})]},c))]})]})]})}export{oe as C,X as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,u as f,d as $,r as p,L as w,n as T}from"./vendor-react-DOVfxdUy.js";import{u as R}from"./useTestExplorer-CUqC18DV.js";import{T as S,C as A,ap as y,O as F,aq as D,ar as I,X as L,o as M,as as z,J as E,at as P,au as O,a0 as _,av as B,r as V,aw as q,S as K}from"./vendor-icons-D_Dmmj8d.js";import{u as U,L as g}from"./useTestLifecycle-C2S_vaX2.js";import{u as W,a as X,b as H,c as Y,d as G}from"./useTestResults-yjH1aUy-.js";import{u as J}from"./useChartTheme-CTIe6M63.js";import{R as Q,C as Z,h as ee,X as te,Y as k,T as se,A as N,L as ae}from"./vendor-charts-By5uZ93z.js";import{f as b}from"./formatTestName-BKd2Uqhs.js";import{u as re}from"./useSuites-V0AxZYex.js";import{f as le}from"./formatDate-T65-Y6Mi.js";import{R as ne}from"./RunState-CRuS_bC2.js";import"./vendor-query-DkZSMtfn.js";import"./index-D6sQYc_0.js";function ie(){const{data:a,isLoading:s}=R(),l=(a==null?void 0:a.suites)??[],r=(a==null?void 0:a.totalTests)??0;let i=0,o=0,c=0,t=0;for(const n of l)for(const m of n.tests){const x=m.lastStatus;x==="passed"?i++:x==="failed"||x==="error"?o++:x==="skipped"?c++:t++}if(s&&r===0)return e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:["Total Tests","Passing","Failing","No Run"].map(n=>e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsx("p",{className:"text-sm text-gray-500 mb-1",children:n}),e.jsx("p",{className:"text-3xl font-bold text-gray-600",children:"—"}),e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"Scanning project…"})]},n))});if(r===0)return e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:["Total Tests","Passing","Failing","No Run"].map(n=>e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsx("p",{className:"text-sm text-gray-500 mb-1",children:n}),e.jsx("p",{className:"text-3xl font-bold text-gray-600",children:"0"}),e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"No tests detected"})]},n))});const d=r>0?Math.round(i/r*100):0,h=r>0?Math.round(o/r*100):0,u=r>0?Math.round(t/r*100):0;return e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Total Tests"}),e.jsx(S,{size:16,className:"text-orange-400"})]}),e.jsx("p",{className:"text-3xl font-bold text-gray-100",children:r}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:t>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-400",children:t})," never run",c>0&&e.jsxs(e.Fragment,{children:[", ",e.jsx("span",{className:"text-gray-400",children:c})," skipped"]})]}):c>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-400",children:c})," skipped"]}):"All tests have executed"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Passing"}),e.jsx(A,{size:16,className:i>0?"text-emerald-400":"text-gray-600"})]}),e.jsx("p",{className:`text-3xl font-bold ${i>0?"text-emerald-400":"text-gray-100"}`,children:i}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[d,"% of catalog"]})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Failing"}),o>0?e.jsx(y,{size:16,className:"text-red-400"}):e.jsx(F,{size:16,className:"text-gray-600"})]}),e.jsx("p",{className:`text-3xl font-bold ${o>0?"text-red-400":"text-gray-100"}`,children:o}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:o>0?`${h}% of catalog`:"No failing tests"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"No Run"}),e.jsx(D,{size:16,className:t>0?"text-amber-400":"text-gray-600"})]}),e.jsx("p",{className:`text-3xl font-bold ${t>0?"text-amber-400":"text-gray-100"}`,children:t}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:t>0?`${u}% of catalog`:"All tests have run"})]})]})}const C=["active","in_review","draft","deprecated"],ce={active:"#10b981",in_review:"#f59e0b",draft:"#3b82f6",deprecated:"#f43f5e"};function oe(){const a=f(),{data:s}=R(),l=U(),r=(s==null?void 0:s.suites)??[],i={draft:0,active:0,in_review:0,deprecated:0};let o=0;for(const t of r)for(const d of t.tests)i[l.statusOf(t.file,d.name)]++,o++;const c=t=>o>0?Math.round(t/o*100):0;return 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",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-lg bg-brand-500/10 text-brand-400",children:e.jsx(I,{size:16})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-100",children:"Test Status"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Authoring status across ",o," test",o===1?"":"s"]})]})]}),e.jsx("button",{onClick:()=>a("/tests"),className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",children:"View in Test Explorer →"})]}),e.jsx("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-black/5 dark:bg-white/5 mb-5",children:o===0?null:C.map(t=>i[t]>0?e.jsx("div",{className:"h-full transition-all",style:{width:`${c(i[t])}%`,backgroundColor:ce[t]},title:`${g[t].label}: ${i[t]} (${c(i[t])}%)`},t):null)}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:C.map(t=>{const d=g[t].cls.split(" ").filter(h=>h.startsWith("text-")).join(" ");return e.jsxs("button",{onClick:()=>a(`/tests?lifecycle=${t}`),className:"group text-left rounded-lg border border-white/5 bg-surface-2/40 hover:bg-surface-2 hover:border-white/10 px-3.5 py-3 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${g[t].dot}`}),e.jsx("span",{className:`text-xs font-medium ${d}`,children:g[t].label})]}),e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-2xl font-bold text-gray-100",children:i[t]}),e.jsxs("span",{className:"text-xs text-gray-500",children:[c(i[t]),"%"]})]})]},t)})})]})}function de(){const{data:a}=W(20),s=J(),l=(a==null?void 0:a.trends)||[];if(l.length===0)return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200 mb-4",children:"Execution Trend"}),e.jsx("div",{className:"h-52 flex items-center justify-center text-gray-600 text-sm",children:"No test runs yet. Run tests to see trends."})]});const r=l.map((i,o)=>({run:`#${o+1}`,passed:i.passed,failed:i.failed,skipped:i.skipped,passRate:i.passRate}));return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 flex flex-col",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200 mb-4",children:"Execution Trend"}),e.jsx("div",{className:"flex-1 min-h-[13rem]",children:e.jsx(Q,{width:"100%",height:"100%",children:e.jsxs(Z,{data:r,children:[e.jsx(ee,{strokeDasharray:"3 3",stroke:s.gridStroke}),e.jsx(te,{dataKey:"run",tick:{fontSize:11,fill:s.axisFill}}),e.jsx(k,{yAxisId:"left",tick:{fontSize:11,fill:s.axisFill}}),e.jsx(k,{yAxisId:"right",orientation:"right",domain:[0,100],tick:{fontSize:11,fill:s.axisFill}}),e.jsx(se,{contentStyle:{background:s.tooltipBackground,border:s.tooltipBorder,borderRadius:8,fontSize:13},labelStyle:{color:s.tooltipLabelColor}}),e.jsx(N,{yAxisId:"left",type:"monotone",dataKey:"passed",stackId:"1",fill:"#22c55e",fillOpacity:.3,stroke:"#22c55e"}),e.jsx(N,{yAxisId:"left",type:"monotone",dataKey:"failed",stackId:"1",fill:"#ef4444",fillOpacity:.3,stroke:"#ef4444"}),e.jsx(N,{yAxisId:"left",type:"monotone",dataKey:"skipped",stackId:"1",fill:"#64748b",fillOpacity:.2,stroke:"#64748b"}),e.jsx(ae,{yAxisId:"right",type:"monotone",dataKey:"passRate",stroke:"#a78bfa",strokeWidth:2,dot:!1})]})})})]})}function v({title:a,count:s,onClose:l,children:r}){return $.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:l}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 w-[640px] max-w-[92vw] max-h-[80vh] flex flex-col shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/5 flex-shrink-0",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-200",children:[a,typeof s=="number"&&e.jsxs("span",{className:"text-gray-500 font-normal",children:[" (",s,")"]})]}),e.jsx("button",{onClick:l,className:"text-gray-500 hover:text-gray-300 transition-colors","aria-label":"Close",children:e.jsx(L,{size:18})})]}),e.jsx("div",{className:"p-3 overflow-y-auto space-y-1",children:r})]})]}),document.body)}function xe(){const{data:a}=X(50),s=(a==null?void 0:a.topFailures)||[],l=f(),[r,i]=p.useState(!1),o=t=>{if(t.file){const d=new URLSearchParams;d.set("file",t.file.replace(/\\/g,"/")),d.set("test",t.testName),l(`/tests?${d.toString()}`)}else l("/tests")},c=(t,d)=>e.jsxs("button",{onClick:()=>o(t),title:t.lastError||t.testName,className:"w-full flex items-start gap-2.5 p-2.5 rounded-lg hover:bg-surface-2 transition-colors text-left",children:[e.jsx(y,{size:16,className:"text-red-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:b(t.testName)}),e.jsx("p",{className:"text-xs text-gray-500 truncate",children:t.lastError||"No error details"})]}),e.jsxs("span",{className:"text-xs font-medium text-red-400 flex-shrink-0",children:[t.failureCount,"x"]})]},d);return 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.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Top Failures"}),s.length>5&&e.jsx("button",{onClick:()=>i(!0),className:"text-xs text-brand-400 hover:text-brand-300 whitespace-nowrap",children:"View all →"})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No failures recorded yet."}):e.jsx("div",{className:"space-y-2",children:s.slice(0,5).map(c)}),r&&e.jsx(v,{title:"Top Failures",count:s.length,onClose:()=>i(!1),children:s.map(c)})]})}function me(){const{data:a}=H(),s=(a==null?void 0:a.flaky)||[],l=f(),[r,i]=p.useState(!1),o=t=>{if(t.file){const d=new URLSearchParams;d.set("file",t.file.replace(/\\/g,"/")),d.set("test",t.testName),l(`/tests?${d.toString()}`)}else l("/tests")},c=(t,d)=>{var h;return e.jsxs("button",{onClick:()=>o(t),title:`Open ${t.testName} in Results`,className:"w-full flex items-start gap-2.5 p-2.5 rounded-lg hover:bg-surface-2 transition-colors text-left",children:[e.jsx(M,{size:16,className:"text-amber-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:b(t.testName)}),e.jsx("div",{className:"flex items-center gap-1 mt-1",children:(h=t.recentStatuses)==null?void 0:h.slice(0,10).map((u,n)=>e.jsx("span",{title:u,className:`w-2.5 h-2.5 rounded-full ${u==="passed"?"bg-emerald-400":u==="failed"?"bg-red-400":"bg-gray-600"}`},n))})]}),e.jsxs("span",{className:"text-xs font-medium text-amber-400 flex-shrink-0",children:[Math.round(t.flakinessRate*100),"%"]})]},d)};return 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.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Flaky Tests"}),s.length>5&&e.jsx("button",{onClick:()=>i(!0),className:"text-xs text-brand-400 hover:text-brand-300 whitespace-nowrap",children:"View all →"})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No flaky tests detected."}):e.jsx("div",{className:"space-y-2",children:s.slice(0,5).map(c)}),r&&e.jsx(v,{title:"Flaky Tests",count:s.length,onClose:()=>i(!1),children:s.map(c)})]})}function j(a){if(!a||a<0)return"—";if(a<1e3)return`${Math.round(a)}ms`;const s=a/1e3;return s<60?`${s.toFixed(s<10?1:0)}s`:`${Math.floor(s/60)}m ${Math.round(s%60)}s`}function he(a){if(!a)return"";const s=a.replace(/\\/g,"/");return s.slice(s.lastIndexOf("/")+1)}function ue(){const{data:a}=Y(50),s=(a==null?void 0:a.slowest)||[],l=f(),[r,i]=p.useState(!1),o=t=>{if(t.file){const d=new URLSearchParams;d.set("file",t.file.replace(/\\/g,"/")),d.set("test",t.name),l(`/tests?${d.toString()}`)}else l("/tests")},c=(t,d)=>e.jsxs("button",{onClick:()=>o(t),title:`${t.name}${t.file?` — ${t.file}`:""} · avg ${j(t.avgDuration)}, max ${j(t.maxDuration)}`,className:"w-full flex items-start gap-2.5 p-2.5 rounded-lg hover:bg-surface-2 transition-colors text-left",children:[e.jsx(z,{size:16,className:"text-sky-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:b(t.name)}),e.jsx("p",{className:"text-xs text-gray-500 truncate",children:t.file?he(t.file):`max ${j(t.maxDuration)}`})]}),e.jsx("span",{className:"text-xs font-medium text-sky-400 flex-shrink-0 tabular-nums",children:j(t.avgDuration)})]},d);return 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.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Slowest Tests"}),s.length>5&&e.jsx("button",{onClick:()=>i(!0),className:"text-xs text-brand-400 hover:text-brand-300 whitespace-nowrap",children:"View all →"})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No timing data yet. Run tests to see the slowest."}):e.jsx("div",{className:"space-y-2",children:s.slice(0,5).map(c)}),r&&e.jsx(v,{title:"Slowest Tests",count:s.length,onClose:()=>i(!1),children:s.map(c)})]})}function fe(a){if(!a)return"";const s=Date.now()-a,l=Math.floor(s/6e4);if(l<1)return"just now";if(l<60)return`${l}m ago`;const r=Math.floor(l/60);if(r<24)return`${r}h ago`;const i=Math.floor(r/24);return i<7?`${i}d ago`:new Date(a).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function pe(a){return a>=90?{fill:"bg-emerald-500",text:"text-emerald-400"}:a>=50?{fill:"bg-amber-500",text:"text-amber-400"}:{fill:"bg-red-500",text:"text-red-400"}}const ge="bg-surface-1 rounded-xl border border-white/5 p-5",je=5;function be(){const{data:a,isLoading:s}=re(),l=(a==null?void 0:a.suites)??[],[r,i]=p.useState(!1);p.useEffect(()=>{if(!s&&l.length>0){const n=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(n)}},[s,l.length]);const o=n=>{var m;return((m=n.lastRun)==null?void 0:m.status)==="completed"?n.lastRun:(n.history||[]).find(x=>x.status==="completed")},c=n=>{var m,x;return(((x=(m=o(n))==null?void 0:m.summary)==null?void 0:x.total)??0)>0},t=l.filter(c).map(n=>{const m=o(n),x=m.summary;return{id:n.id,name:n.name,run:!0,rate:x.total?Math.round(x.passed/x.total*100):0,passed:x.passed??0,failed:x.failed??0,total:x.total??0,finishedAt:m.finishedAt}}).sort((n,m)=>n.rate-m.rate),d=l.filter(n=>!c(n)).map(n=>({id:n.id,name:n.name,run:!1})),h=[...t,...d].slice(0,je),u=l.length;return e.jsxs("div",{className:ge,children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Pass rate by suite"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Latest run · lowest first"})]}),u>0&&e.jsx(w,{to:"/tests?view=suites",className:"text-xs text-brand-400 hover:text-brand-300 whitespace-nowrap",children:"View all →"})]}),s?e.jsx("div",{className:"h-44 flex items-center justify-center text-sm text-gray-500",children:"Loading suites…"}):u===0?e.jsx("div",{className:"h-44 flex items-center justify-center text-sm text-gray-500 text-center px-4",children:"No suites yet. Create suites in Test Explorer to track their pass rates here."}):e.jsx("div",{className:"space-y-1",children:h.map(n=>{const m=n.run?pe(n.rate):null;return e.jsxs(w,{to:`/tests?view=suites&suite=${n.id}`,className:"grid grid-cols-[minmax(0,150px)_1fr_84px] items-center gap-3 py-1.5 px-1 -mx-1 rounded-lg hover:bg-white/5 transition-colors",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:`text-[13px] font-medium truncate ${n.run?"text-gray-200":"text-gray-400"}`,title:n.name,children:b(n.name)}),e.jsx("div",{className:"text-[11px] text-gray-500 truncate",children:n.run?`${fe(n.finishedAt)} · ${n.total} tests`:"Never run"})]}),e.jsx("div",{className:"h-2 rounded-full bg-surface-2 overflow-hidden",children:n.run&&e.jsx("div",{className:`h-full rounded-full ${m.fill} transition-[width] duration-700 ease-out`,style:{width:r?`${n.rate}%`:"0%"}})}),e.jsx("div",{className:"text-right",children:n.run?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`text-[15px] font-semibold ${m.text}`,children:[n.rate,"%"]}),e.jsxs("div",{className:"text-[11px] text-gray-500 tabular-nums",children:[n.passed," / ",n.failed]})]}):e.jsx("div",{className:"text-[11px] text-gray-500",children:"Not run yet"})})]},n.id)})})]})}function Ne(a){const s=Date.now()-new Date(a).getTime();if(!Number.isFinite(s)||s<0)return"just now";const l=Math.floor(s/1e3);if(l<60)return`${l}s ago`;const r=Math.floor(l/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function ye(a){if(!a)return"—";const s=Math.round(a/1e3);if(s<60)return`${s}s`;const l=Math.floor(s/60),r=s%60;return r===0?`${l}m`:`${l}m ${r}s`}function ve(a){return a.status==="running"?{Icon:_,tint:"text-sky-400",bg:"bg-sky-500/15",label:"Running",spin:!0}:a.status==="cancelled"?{Icon:B,tint:"text-gray-400",bg:"bg-gray-500/15",label:"Cancelled",spin:!1}:a.status==="completed"&&(a.exitCode??0)===0?{Icon:V,tint:"text-emerald-400",bg:"bg-emerald-500/15",label:"Passed",spin:!1}:{Icon:y,tint:"text-red-400",bg:"bg-red-500/15",label:"Failed",spin:!1}}function we({runs:a}){const s=f(),l=a.slice(0,5);return 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("h3",{className:"text-base font-semibold text-gray-200",children:"Recent Executions"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["Last ",l.length," test executions with per-run breakdown"]})]}),e.jsx("button",{onClick:()=>s("/results"),className:"text-xs text-brand-400 hover:text-brand-300 transition-colors",children:"View all →"})]}),l.length===0?e.jsx("div",{className:"h-40 flex items-center justify-center text-sm text-gray-500",children:"No runs yet. Execute tests to see history."}):e.jsx("div",{className:"overflow-x-auto -mx-2",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-[11px] uppercase tracking-wide text-gray-500 border-b border-white/5",children:[e.jsx("th",{className:"text-left font-medium px-2 py-2",children:"Run"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Passed"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Failed"}),e.jsx("th",{className:"text-right font-medium px-2 py-2 hidden sm:table-cell",children:"Skipped"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Total"}),e.jsx("th",{className:"text-right font-medium px-2 py-2 hidden lg:table-cell",children:"Pass Rate"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Duration"}),e.jsx("th",{className:"text-right font-medium px-2 py-2 hidden sm:table-cell",children:"When"}),e.jsx("th",{className:"text-right font-medium px-2 py-2 hidden lg:table-cell",children:"Source"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Status"})]})}),e.jsx("tbody",{children:l.map(r=>{const i=ve(r),o=i.Icon,c=r.summary,t=c?c.passRate>=90?"text-emerald-400":c.passRate>=70?"text-amber-400":"text-red-400":"text-gray-500";return e.jsxs("tr",{onClick:()=>s(`/results?runId=${encodeURIComponent(r.runId)}`),className:"border-b border-white/5 hover:bg-surface-2 cursor-pointer transition-colors",children:[e.jsx("td",{className:"px-2 py-2.5 min-w-0 max-w-xs",children:r.label?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-gray-200 truncate",title:r.label,children:r.label}),e.jsx("p",{className:"text-[11px] text-gray-500 truncate font-mono",title:r.command,children:r.command})]}):e.jsx("p",{className:"text-gray-200 truncate font-mono text-xs",title:r.command,children:r.command})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums",children:c?e.jsx("span",{className:"text-emerald-400 font-medium",children:c.passed}):e.jsx("span",{className:"text-gray-600",children:"—"})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums",children:c?e.jsx("span",{className:c.failed>0?"text-red-400 font-medium":"text-gray-500",children:c.failed}):e.jsx("span",{className:"text-gray-600",children:"—"})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums hidden sm:table-cell",children:c?e.jsx("span",{className:"text-gray-500",children:c.skipped}):e.jsx("span",{className:"text-gray-600",children:"—"})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums",children:c?e.jsx("span",{className:"text-gray-300",children:c.total}):e.jsx("span",{className:"text-gray-600",children:"—"})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums hidden lg:table-cell",children:r.status==="running"?e.jsx("span",{className:"text-gray-600",title:"Shown when the run finishes",children:"—"}):c?e.jsxs("span",{className:`${t} font-medium`,children:[c.passRate.toFixed(1),"%"]}):e.jsx("span",{className:"text-gray-600",children:"—"})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums text-gray-400",children:ye(r.duration)}),e.jsx("td",{className:"px-2 py-2.5 text-right text-gray-500 text-xs hidden sm:table-cell",title:le(r.startTime),children:Ne(r.startTime)}),e.jsx("td",{className:"px-2 py-2.5 text-right hidden lg:table-cell",children:r.source==="cloud"&&r.cloudProvider==="local-appium"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-gray-500",title:"Local device (Appium)",children:[e.jsx(E,{size:11}),"local device"]}):r.source==="cloud"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-sky-300 px-1.5 py-0.5 bg-sky-500/10 rounded",title:r.cloudProvider,children:[e.jsx(P,{size:11}),r.cloudProvider||"cloud"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-gray-500",children:[e.jsx(O,{size:11}),"local"]})}),e.jsx("td",{className:"px-2 py-2.5 text-right",children:r.status==="running"?e.jsx(ne,{size:"sm"}):e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-md text-xs font-medium ${i.bg} ${i.tint}`,children:[e.jsx(o,{size:12}),i.label]})})]},r.runId)})})]})})]})}function Ee(){const{project:a}=T(),s=f(),{data:l}=G(10,0),r=(l==null?void 0:l.runs)??[];return e.jsxs("div",{className:"p-6 space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-100",children:"Automation Dashboard"}),e.jsxs("p",{className:"text-base text-gray-400 mt-0.5",children:[a.framework||"Auto-detect"," · ",a.stats.totalFiles," files · ",a.stats.totalModules," modules"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs("button",{onClick:()=>s("/ai-record"),className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-surface-2 hover:bg-surface-3 text-gray-300 text-sm border border-white/5 transition-colors",title:"Record a flow with AI",children:[e.jsx(q,{size:15}),"AI Record"]}),e.jsxs("button",{onClick:()=>s("/ai"),className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium transition-colors",title:"Open the AI Assistant",children:[e.jsx(K,{size:15}),"AI Assistant"]})]})]}),e.jsx(ie,{}),e.jsx(oe,{}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsx(de,{}),e.jsx(be,{})]}),e.jsx(we,{runs:r}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsx(xe,{}),e.jsx(me,{}),e.jsx(ue,{})]})]})}export{Ee as Dashboard};
|
|
1
|
+
import{j as e,u as f,d as $,r as p,L as w,n as T}from"./vendor-react-DOVfxdUy.js";import{u as R}from"./useTestExplorer-BGhkGHKy.js";import{T as S,C as A,aq as y,Q as F,ar as D,as as I,X as L,p as M,at as z,K as E,au as P,av as O,a1 as _,aw as B,s as K,ax as V,S as q}from"./vendor-icons-Cm92aSc5.js";import{u as U,L as g}from"./useTestLifecycle-DX5ES6x8.js";import{u as W,a as X,b as H,c as Y,d as G}from"./useTestResults-DWjvm8gm.js";import{u as Q}from"./useChartTheme-CTIe6M63.js";import{R as J,C as Z,h as ee,X as te,Y as k,T as se,A as N,L as ae}from"./vendor-charts-By5uZ93z.js";import{f as b}from"./formatTestName-BKd2Uqhs.js";import{u as re}from"./useSuites-GN_K2mHc.js";import{f as le}from"./formatDate-T65-Y6Mi.js";import{R as ne}from"./RunState-DDwFB4tA.js";import"./vendor-query-DkZSMtfn.js";import"./index-BlA8ntjb.js";function ie(){const{data:a,isLoading:s}=R(),l=(a==null?void 0:a.suites)??[],r=(a==null?void 0:a.totalTests)??0;let i=0,o=0,c=0,t=0;for(const n of l)for(const m of n.tests){const x=m.lastStatus;x==="passed"?i++:x==="failed"||x==="error"?o++:x==="skipped"?c++:t++}if(s&&r===0)return e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:["Total Tests","Passing","Failing","No Run"].map(n=>e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsx("p",{className:"text-sm text-gray-500 mb-1",children:n}),e.jsx("p",{className:"text-3xl font-bold text-gray-600",children:"—"}),e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"Scanning project…"})]},n))});if(r===0)return e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:["Total Tests","Passing","Failing","No Run"].map(n=>e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsx("p",{className:"text-sm text-gray-500 mb-1",children:n}),e.jsx("p",{className:"text-3xl font-bold text-gray-600",children:"0"}),e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"No tests detected"})]},n))});const d=r>0?Math.round(i/r*100):0,h=r>0?Math.round(o/r*100):0,u=r>0?Math.round(t/r*100):0;return e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Total Tests"}),e.jsx(S,{size:16,className:"text-orange-400"})]}),e.jsx("p",{className:"text-3xl font-bold text-gray-100",children:r}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:t>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-400",children:t})," never run",c>0&&e.jsxs(e.Fragment,{children:[", ",e.jsx("span",{className:"text-gray-400",children:c})," skipped"]})]}):c>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-400",children:c})," skipped"]}):"All tests have executed"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Passing"}),e.jsx(A,{size:16,className:i>0?"text-emerald-400":"text-gray-600"})]}),e.jsx("p",{className:`text-3xl font-bold ${i>0?"text-emerald-400":"text-gray-100"}`,children:i}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[d,"% of catalog"]})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Failing"}),o>0?e.jsx(y,{size:16,className:"text-red-400"}):e.jsx(F,{size:16,className:"text-gray-600"})]}),e.jsx("p",{className:`text-3xl font-bold ${o>0?"text-red-400":"text-gray-100"}`,children:o}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:o>0?`${h}% of catalog`:"No failing tests"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"No Run"}),e.jsx(D,{size:16,className:t>0?"text-amber-400":"text-gray-600"})]}),e.jsx("p",{className:`text-3xl font-bold ${t>0?"text-amber-400":"text-gray-100"}`,children:t}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:t>0?`${u}% of catalog`:"All tests have run"})]})]})}const C=["active","in_review","draft","deprecated"],ce={active:"#10b981",in_review:"#f59e0b",draft:"#3b82f6",deprecated:"#f43f5e"};function oe(){const a=f(),{data:s}=R(),l=U(),r=(s==null?void 0:s.suites)??[],i={draft:0,active:0,in_review:0,deprecated:0};let o=0;for(const t of r)for(const d of t.tests)i[l.statusOf(t.file,d.name)]++,o++;const c=t=>o>0?Math.round(t/o*100):0;return 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",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-lg bg-brand-500/10 text-brand-400",children:e.jsx(I,{size:16})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-100",children:"Test Status"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Authoring status across ",o," test",o===1?"":"s"]})]})]}),e.jsx("button",{onClick:()=>a("/tests"),className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",children:"View in Test Explorer →"})]}),e.jsx("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-black/5 dark:bg-white/5 mb-5",children:o===0?null:C.map(t=>i[t]>0?e.jsx("div",{className:"h-full transition-all",style:{width:`${c(i[t])}%`,backgroundColor:ce[t]},title:`${g[t].label}: ${i[t]} (${c(i[t])}%)`},t):null)}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:C.map(t=>{const d=g[t].cls.split(" ").filter(h=>h.startsWith("text-")).join(" ");return e.jsxs("button",{onClick:()=>a(`/tests?lifecycle=${t}`),className:"group text-left rounded-lg border border-white/5 bg-surface-2/40 hover:bg-surface-2 hover:border-white/10 px-3.5 py-3 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${g[t].dot}`}),e.jsx("span",{className:`text-xs font-medium ${d}`,children:g[t].label})]}),e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-2xl font-bold text-gray-100",children:i[t]}),e.jsxs("span",{className:"text-xs text-gray-500",children:[c(i[t]),"%"]})]})]},t)})})]})}function de(){const{data:a}=W(20),s=Q(),l=(a==null?void 0:a.trends)||[];if(l.length===0)return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200 mb-4",children:"Execution Trend"}),e.jsx("div",{className:"h-52 flex items-center justify-center text-gray-600 text-sm",children:"No test runs yet. Run tests to see trends."})]});const r=l.map((i,o)=>({run:`#${o+1}`,passed:i.passed,failed:i.failed,skipped:i.skipped,passRate:i.passRate}));return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 flex flex-col",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200 mb-4",children:"Execution Trend"}),e.jsx("div",{className:"flex-1 min-h-[13rem]",children:e.jsx(J,{width:"100%",height:"100%",children:e.jsxs(Z,{data:r,children:[e.jsx(ee,{strokeDasharray:"3 3",stroke:s.gridStroke}),e.jsx(te,{dataKey:"run",tick:{fontSize:11,fill:s.axisFill}}),e.jsx(k,{yAxisId:"left",tick:{fontSize:11,fill:s.axisFill}}),e.jsx(k,{yAxisId:"right",orientation:"right",domain:[0,100],tick:{fontSize:11,fill:s.axisFill}}),e.jsx(se,{contentStyle:{background:s.tooltipBackground,border:s.tooltipBorder,borderRadius:8,fontSize:13},labelStyle:{color:s.tooltipLabelColor}}),e.jsx(N,{yAxisId:"left",type:"monotone",dataKey:"passed",stackId:"1",fill:"#22c55e",fillOpacity:.3,stroke:"#22c55e"}),e.jsx(N,{yAxisId:"left",type:"monotone",dataKey:"failed",stackId:"1",fill:"#ef4444",fillOpacity:.3,stroke:"#ef4444"}),e.jsx(N,{yAxisId:"left",type:"monotone",dataKey:"skipped",stackId:"1",fill:"#64748b",fillOpacity:.2,stroke:"#64748b"}),e.jsx(ae,{yAxisId:"right",type:"monotone",dataKey:"passRate",stroke:"#a78bfa",strokeWidth:2,dot:!1})]})})})]})}function v({title:a,count:s,onClose:l,children:r}){return $.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:l}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 w-[640px] max-w-[92vw] max-h-[80vh] flex flex-col shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/5 flex-shrink-0",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-200",children:[a,typeof s=="number"&&e.jsxs("span",{className:"text-gray-500 font-normal",children:[" (",s,")"]})]}),e.jsx("button",{onClick:l,className:"text-gray-500 hover:text-gray-300 transition-colors","aria-label":"Close",children:e.jsx(L,{size:18})})]}),e.jsx("div",{className:"p-3 overflow-y-auto space-y-1",children:r})]})]}),document.body)}function xe(){const{data:a}=X(50),s=(a==null?void 0:a.topFailures)||[],l=f(),[r,i]=p.useState(!1),o=t=>{if(t.file){const d=new URLSearchParams;d.set("file",t.file.replace(/\\/g,"/")),d.set("test",t.testName),l(`/tests?${d.toString()}`)}else l("/tests")},c=(t,d)=>e.jsxs("button",{onClick:()=>o(t),title:t.lastError||t.testName,className:"w-full flex items-start gap-2.5 p-2.5 rounded-lg hover:bg-surface-2 transition-colors text-left",children:[e.jsx(y,{size:16,className:"text-red-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:b(t.testName)}),e.jsx("p",{className:"text-xs text-gray-500 truncate",children:t.lastError||"No error details"})]}),e.jsxs("span",{className:"text-xs font-medium text-red-400 flex-shrink-0",children:[t.failureCount,"x"]})]},d);return 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.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Top Failures"}),s.length>5&&e.jsx("button",{onClick:()=>i(!0),className:"text-xs text-brand-400 hover:text-brand-300 whitespace-nowrap",children:"View all →"})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No failures recorded yet."}):e.jsx("div",{className:"space-y-2",children:s.slice(0,5).map(c)}),r&&e.jsx(v,{title:"Top Failures",count:s.length,onClose:()=>i(!1),children:s.map(c)})]})}function me(){const{data:a}=H(),s=(a==null?void 0:a.flaky)||[],l=f(),[r,i]=p.useState(!1),o=t=>{if(t.file){const d=new URLSearchParams;d.set("file",t.file.replace(/\\/g,"/")),d.set("test",t.testName),l(`/tests?${d.toString()}`)}else l("/tests")},c=(t,d)=>{var h;return e.jsxs("button",{onClick:()=>o(t),title:`Open ${t.testName} in Results`,className:"w-full flex items-start gap-2.5 p-2.5 rounded-lg hover:bg-surface-2 transition-colors text-left",children:[e.jsx(M,{size:16,className:"text-amber-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:b(t.testName)}),e.jsx("div",{className:"flex items-center gap-1 mt-1",children:(h=t.recentStatuses)==null?void 0:h.slice(0,10).map((u,n)=>e.jsx("span",{title:u,className:`w-2.5 h-2.5 rounded-full ${u==="passed"?"bg-emerald-400":u==="failed"?"bg-red-400":"bg-gray-600"}`},n))})]}),e.jsxs("span",{className:"text-xs font-medium text-amber-400 flex-shrink-0",children:[Math.round(t.flakinessRate*100),"%"]})]},d)};return 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.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Flaky Tests"}),s.length>5&&e.jsx("button",{onClick:()=>i(!0),className:"text-xs text-brand-400 hover:text-brand-300 whitespace-nowrap",children:"View all →"})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No flaky tests detected."}):e.jsx("div",{className:"space-y-2",children:s.slice(0,5).map(c)}),r&&e.jsx(v,{title:"Flaky Tests",count:s.length,onClose:()=>i(!1),children:s.map(c)})]})}function j(a){if(!a||a<0)return"—";if(a<1e3)return`${Math.round(a)}ms`;const s=a/1e3;return s<60?`${s.toFixed(s<10?1:0)}s`:`${Math.floor(s/60)}m ${Math.round(s%60)}s`}function he(a){if(!a)return"";const s=a.replace(/\\/g,"/");return s.slice(s.lastIndexOf("/")+1)}function ue(){const{data:a}=Y(50),s=(a==null?void 0:a.slowest)||[],l=f(),[r,i]=p.useState(!1),o=t=>{if(t.file){const d=new URLSearchParams;d.set("file",t.file.replace(/\\/g,"/")),d.set("test",t.name),l(`/tests?${d.toString()}`)}else l("/tests")},c=(t,d)=>e.jsxs("button",{onClick:()=>o(t),title:`${t.name}${t.file?` — ${t.file}`:""} · avg ${j(t.avgDuration)}, max ${j(t.maxDuration)}`,className:"w-full flex items-start gap-2.5 p-2.5 rounded-lg hover:bg-surface-2 transition-colors text-left",children:[e.jsx(z,{size:16,className:"text-sky-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:b(t.name)}),e.jsx("p",{className:"text-xs text-gray-500 truncate",children:t.file?he(t.file):`max ${j(t.maxDuration)}`})]}),e.jsx("span",{className:"text-xs font-medium text-sky-400 flex-shrink-0 tabular-nums",children:j(t.avgDuration)})]},d);return 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.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Slowest Tests"}),s.length>5&&e.jsx("button",{onClick:()=>i(!0),className:"text-xs text-brand-400 hover:text-brand-300 whitespace-nowrap",children:"View all →"})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No timing data yet. Run tests to see the slowest."}):e.jsx("div",{className:"space-y-2",children:s.slice(0,5).map(c)}),r&&e.jsx(v,{title:"Slowest Tests",count:s.length,onClose:()=>i(!1),children:s.map(c)})]})}function fe(a){if(!a)return"";const s=Date.now()-a,l=Math.floor(s/6e4);if(l<1)return"just now";if(l<60)return`${l}m ago`;const r=Math.floor(l/60);if(r<24)return`${r}h ago`;const i=Math.floor(r/24);return i<7?`${i}d ago`:new Date(a).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function pe(a){return a>=90?{fill:"bg-emerald-500",text:"text-emerald-400"}:a>=50?{fill:"bg-amber-500",text:"text-amber-400"}:{fill:"bg-red-500",text:"text-red-400"}}const ge="bg-surface-1 rounded-xl border border-white/5 p-5",je=5;function be(){const{data:a,isLoading:s}=re(),l=(a==null?void 0:a.suites)??[],[r,i]=p.useState(!1);p.useEffect(()=>{if(!s&&l.length>0){const n=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(n)}},[s,l.length]);const o=n=>{var m;return((m=n.lastRun)==null?void 0:m.status)==="completed"?n.lastRun:(n.history||[]).find(x=>x.status==="completed")},c=n=>{var m,x;return(((x=(m=o(n))==null?void 0:m.summary)==null?void 0:x.total)??0)>0},t=l.filter(c).map(n=>{const m=o(n),x=m.summary;return{id:n.id,name:n.name,run:!0,rate:x.total?Math.round(x.passed/x.total*100):0,passed:x.passed??0,failed:x.failed??0,total:x.total??0,finishedAt:m.finishedAt}}).sort((n,m)=>n.rate-m.rate),d=l.filter(n=>!c(n)).map(n=>({id:n.id,name:n.name,run:!1})),h=[...t,...d].slice(0,je),u=l.length;return e.jsxs("div",{className:ge,children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Pass rate by suite"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Latest run · lowest first"})]}),u>0&&e.jsx(w,{to:"/tests?view=suites",className:"text-xs text-brand-400 hover:text-brand-300 whitespace-nowrap",children:"View all →"})]}),s?e.jsx("div",{className:"h-44 flex items-center justify-center text-sm text-gray-500",children:"Loading suites…"}):u===0?e.jsx("div",{className:"h-44 flex items-center justify-center text-sm text-gray-500 text-center px-4",children:"No suites yet. Create suites in Test Explorer to track their pass rates here."}):e.jsx("div",{className:"space-y-1",children:h.map(n=>{const m=n.run?pe(n.rate):null;return e.jsxs(w,{to:`/tests?view=suites&suite=${n.id}`,className:"grid grid-cols-[minmax(0,150px)_1fr_84px] items-center gap-3 py-1.5 px-1 -mx-1 rounded-lg hover:bg-white/5 transition-colors",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:`text-[13px] font-medium truncate ${n.run?"text-gray-200":"text-gray-400"}`,title:n.name,children:b(n.name)}),e.jsx("div",{className:"text-[11px] text-gray-500 truncate",children:n.run?`${fe(n.finishedAt)} · ${n.total} tests`:"Never run"})]}),e.jsx("div",{className:"h-2 rounded-full bg-surface-2 overflow-hidden",children:n.run&&e.jsx("div",{className:`h-full rounded-full ${m.fill} transition-[width] duration-700 ease-out`,style:{width:r?`${n.rate}%`:"0%"}})}),e.jsx("div",{className:"text-right",children:n.run?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`text-[15px] font-semibold ${m.text}`,children:[n.rate,"%"]}),e.jsxs("div",{className:"text-[11px] text-gray-500 tabular-nums",children:[n.passed," / ",n.failed]})]}):e.jsx("div",{className:"text-[11px] text-gray-500",children:"Not run yet"})})]},n.id)})})]})}function Ne(a){const s=Date.now()-new Date(a).getTime();if(!Number.isFinite(s)||s<0)return"just now";const l=Math.floor(s/1e3);if(l<60)return`${l}s ago`;const r=Math.floor(l/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function ye(a){if(!a)return"—";const s=Math.round(a/1e3);if(s<60)return`${s}s`;const l=Math.floor(s/60),r=s%60;return r===0?`${l}m`:`${l}m ${r}s`}function ve(a){return a.status==="running"?{Icon:_,tint:"text-sky-400",bg:"bg-sky-500/15",label:"Running",spin:!0}:a.status==="cancelled"?{Icon:B,tint:"text-gray-400",bg:"bg-gray-500/15",label:"Cancelled",spin:!1}:a.status==="completed"&&(a.exitCode??0)===0?{Icon:K,tint:"text-emerald-400",bg:"bg-emerald-500/15",label:"Passed",spin:!1}:{Icon:y,tint:"text-red-400",bg:"bg-red-500/15",label:"Failed",spin:!1}}function we({runs:a}){const s=f(),l=a.slice(0,5);return 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("h3",{className:"text-base font-semibold text-gray-200",children:"Recent Executions"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["Last ",l.length," test executions with per-run breakdown"]})]}),e.jsx("button",{onClick:()=>s("/results"),className:"text-xs text-brand-400 hover:text-brand-300 transition-colors",children:"View all →"})]}),l.length===0?e.jsx("div",{className:"h-40 flex items-center justify-center text-sm text-gray-500",children:"No runs yet. Execute tests to see history."}):e.jsx("div",{className:"overflow-x-auto -mx-2",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-[11px] uppercase tracking-wide text-gray-500 border-b border-white/5",children:[e.jsx("th",{className:"text-left font-medium px-2 py-2",children:"Run"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Passed"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Failed"}),e.jsx("th",{className:"text-right font-medium px-2 py-2 hidden sm:table-cell",children:"Skipped"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Total"}),e.jsx("th",{className:"text-right font-medium px-2 py-2 hidden lg:table-cell",children:"Pass Rate"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Duration"}),e.jsx("th",{className:"text-right font-medium px-2 py-2 hidden sm:table-cell",children:"When"}),e.jsx("th",{className:"text-right font-medium px-2 py-2 hidden lg:table-cell",children:"Source"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Status"})]})}),e.jsx("tbody",{children:l.map(r=>{const i=ve(r),o=i.Icon,c=r.summary,t=c?c.passRate>=90?"text-emerald-400":c.passRate>=70?"text-amber-400":"text-red-400":"text-gray-500";return e.jsxs("tr",{onClick:()=>s(`/results?runId=${encodeURIComponent(r.runId)}`),className:"border-b border-white/5 hover:bg-surface-2 cursor-pointer transition-colors",children:[e.jsx("td",{className:"px-2 py-2.5 min-w-0 max-w-xs",children:r.label?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-gray-200 truncate",title:r.label,children:r.label}),e.jsx("p",{className:"text-[11px] text-gray-500 truncate font-mono",title:r.command,children:r.command})]}):e.jsx("p",{className:"text-gray-200 truncate font-mono text-xs",title:r.command,children:r.command})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums",children:c?e.jsx("span",{className:"text-emerald-400 font-medium",children:c.passed}):e.jsx("span",{className:"text-gray-600",children:"—"})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums",children:c?e.jsx("span",{className:c.failed>0?"text-red-400 font-medium":"text-gray-500",children:c.failed}):e.jsx("span",{className:"text-gray-600",children:"—"})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums hidden sm:table-cell",children:c?e.jsx("span",{className:"text-gray-500",children:c.skipped}):e.jsx("span",{className:"text-gray-600",children:"—"})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums",children:c?e.jsx("span",{className:"text-gray-300",children:c.total}):e.jsx("span",{className:"text-gray-600",children:"—"})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums hidden lg:table-cell",children:r.status==="running"?e.jsx("span",{className:"text-gray-600",title:"Shown when the run finishes",children:"—"}):c?e.jsxs("span",{className:`${t} font-medium`,children:[c.passRate.toFixed(1),"%"]}):e.jsx("span",{className:"text-gray-600",children:"—"})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums text-gray-400",children:ye(r.duration)}),e.jsx("td",{className:"px-2 py-2.5 text-right text-gray-500 text-xs hidden sm:table-cell",title:le(r.startTime),children:Ne(r.startTime)}),e.jsx("td",{className:"px-2 py-2.5 text-right hidden lg:table-cell",children:r.source==="cloud"&&r.cloudProvider==="local-appium"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-gray-500",title:"Local device (Appium)",children:[e.jsx(E,{size:11}),"local device"]}):r.source==="cloud"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-sky-300 px-1.5 py-0.5 bg-sky-500/10 rounded",title:r.cloudProvider,children:[e.jsx(P,{size:11}),r.cloudProvider||"cloud"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-gray-500",children:[e.jsx(O,{size:11}),"local"]})}),e.jsx("td",{className:"px-2 py-2.5 text-right",children:r.status==="running"?e.jsx(ne,{size:"sm"}):e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-md text-xs font-medium ${i.bg} ${i.tint}`,children:[e.jsx(o,{size:12}),i.label]})})]},r.runId)})})]})})]})}function Ee(){const{project:a}=T(),s=f(),{data:l}=G(10,0),r=(l==null?void 0:l.runs)??[];return e.jsxs("div",{className:"p-6 space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-100",children:"Automation Dashboard"}),e.jsxs("p",{className:"text-base text-gray-400 mt-0.5",children:[a.framework||"Auto-detect"," · ",a.stats.totalFiles," files · ",a.stats.totalModules," modules"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs("button",{onClick:()=>s("/ai-record"),className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-surface-2 hover:bg-surface-3 text-gray-300 text-sm border border-white/5 transition-colors",title:"Record a flow with AI",children:[e.jsx(V,{size:15}),"AI Record"]}),e.jsxs("button",{onClick:()=>s("/ai"),className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium transition-colors",title:"Open the AI Assistant",children:[e.jsx(q,{size:15}),"AI Assistant"]})]})]}),e.jsx(ie,{}),e.jsx(oe,{}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsx(de,{}),e.jsx(be,{})]}),e.jsx(we,{runs:r}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsx(xe,{}),e.jsx(me,{}),e.jsx(ue,{})]})]})}export{Ee as Dashboard};
|