@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 +0,0 @@
|
|
|
1
|
-
import{j as e,r as l}from"./vendor-react-DOVfxdUy.js";import{a as it,u as K}from"./vendor-query-DkZSMtfn.js";import{R as ot,Q as ct}from"./RunState-CRuS_bC2.js";import{ae as dt,cW as xt,cX as mt,cY as ht,cv as ut,cZ as pt,c_ as Ze,c$ as gt,d0 as bt,d1 as yt,d2 as ft,d3 as Qe,d4 as vt,d5 as jt,d6 as Nt,d7 as wt,d8 as kt,d9 as Ct,da as St}from"./index-D6sQYc_0.js";import{C as Te}from"./ConfirmDialog-DtotgVmI.js";import{u as It,T as Ge}from"./RunTargets-CPKBrefj.js";import{u as Tt,b as zt,a as Se}from"./useTabParam-CyYAP90W.js";import{G as Le,X as $e,a0 as Y,cm as He,as as Rt,b4 as Ye,o as Ae,aI as Ee,b6 as Et,b7 as Pt,a8 as Ue,aZ as $t,cE as ue,v as Fe,R as At,cF as Mt,_ as Je,b8 as Lt,cG as Ht,ag as Ie,ah as Oe}from"./vendor-icons-D_Dmmj8d.js";const qt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20128%20128'%3e%3cpath%20fill='%232088ff'%20d='M26.666%200C11.97%200%200%2011.97%200%2026.666c0%2012.87%209.181%2023.651%2021.334%2026.13v37.87c0%2011.77%209.68%2021.334%2021.332%2021.334h.195c1.302%209.023%209.1%2016%2018.473%2016C71.612%20128%2080%20119.612%2080%20109.334s-8.388-18.668-18.666-18.668c-9.372%200-17.17%206.977-18.473%2016h-.195c-8.737%200-16-7.152-16-16V63.779a18.514%2018.514%200%200%200%2013.24%205.555h2.955c1.303%209.023%209.1%2016%2018.473%2016%209.372%200%2017.169-6.977%2018.47-16h11.057c1.303%209.023%209.1%2016%2018.473%2016%2010.278%200%2018.666-8.39%2018.666-18.668C128%2056.388%20119.612%2048%20109.334%2048c-9.373%200-17.171%206.977-18.473%2016H79.805c-1.301-9.023-9.098-16-18.471-16s-17.171%206.977-18.473%2016h-2.955c-6.433%200-11.793-4.589-12.988-10.672%2014.58-.136%2026.416-12.05%2026.416-26.662C53.334%2011.97%2041.362%200%2026.666%200zm0%205.334A21.292%2021.292%200%200%201%2048%2026.666%2021.294%2021.294%200%200%201%2026.666%2048%2021.292%2021.292%200%200%201%205.334%2026.666%2021.29%2021.29%200%200%201%2026.666%205.334zm-5.215%207.541C18.67%2012.889%2016%2015.123%2016%2018.166v17.043c0%204.043%204.709%206.663%208.145%204.533l13.634-8.455c3.257-2.02%203.274-7.002.032-9.045l-13.635-8.59a5.024%205.024%200%200%200-2.725-.777zm-.117%205.291%2013.635%208.588-13.635%208.455V18.166zm40%2035.168a13.29%2013.29%200%200%201%2013.332%2013.332A13.293%2013.293%200%200%201%2061.334%2080%2013.294%2013.294%200%200%201%2048%2066.666a13.293%2013.293%200%200%201%2013.334-13.332zm48%200a13.29%2013.29%200%200%201%2013.332%2013.332A13.293%2013.293%200%200%201%20109.334%2080%2013.294%2013.294%200%200%201%2096%2066.666a13.293%2013.293%200%200%201%2013.334-13.332zm-42.568%206.951a2.667%202.667%200%200%200-1.887.78l-6.3%206.294-2.093-2.084a2.667%202.667%200%200%200-3.771.006%202.667%202.667%200%200%200%20.008%203.772l3.974%203.96a2.667%202.667%200%200%200%203.766-.001l8.185-8.174a2.667%202.667%200%200%200%20.002-3.772%202.667%202.667%200%200%200-1.884-.78zm48%200a2.667%202.667%200%200%200-1.887.78l-6.3%206.294-2.093-2.084a2.667%202.667%200%200%200-3.771.006%202.667%202.667%200%200%200%20.008%203.772l3.974%203.96a2.667%202.667%200%200%200%203.766-.001l8.185-8.174a2.667%202.667%200%200%200%20.002-3.772%202.667%202.667%200%200%200-1.884-.78zM61.334%2096a13.293%2013.293%200%200%201%2013.332%2013.334%2013.29%2013.29%200%200%201-13.332%2013.332A13.293%2013.293%200%200%201%2048%20109.334%2013.294%2013.294%200%200%201%2061.334%2096zM56%20105.334c-2.193%200-4%201.807-4%204%200%202.195%201.808%204%204%204s4-1.805%204-4c0-2.193-1.807-4-4-4zm10.666%200c-2.193%200-4%201.807-4%204%200%202.195%201.808%204%204%204s4-1.805%204-4c0-2.193-1.807-4-4-4zM56%20108c.75%200%201.334.585%201.334%201.334%200%20.753-.583%201.332-1.334%201.332-.75%200-1.334-.58-1.334-1.332%200-.75.585-1.334%201.334-1.334zm10.666%200c.75%200%201.334.585%201.334%201.334%200%20.753-.583%201.332-1.334%201.332-.75%200-1.332-.58-1.332-1.332%200-.75.583-1.334%201.332-1.334z'/%3e%3cpath%20fill='%2379b8ff'%20d='M109.334%2090.666c-9.383%200-17.188%206.993-18.477%2016.031a2.667%202.667%200%200%200-.265-.011l-2.7.09a2.667%202.667%200%200%200-2.578%202.751%202.667%202.667%200%200%200%202.752%202.578l2.7-.087a2.667%202.667%200%200%200%20.097-.006C92.17%20121.029%2099.965%20128%20109.334%20128c10.278%200%2018.666-8.388%2018.666-18.666s-8.388-18.668-18.666-18.668zm0%205.334a13.293%2013.293%200%200%201%2013.332%2013.334%2013.29%2013.29%200%200%201-13.332%2013.332A13.293%2013.293%200%200%201%2096%20109.334%2013.294%2013.294%200%200%201%20109.334%2096z'/%3e%3c/svg%3e",Ft="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20128%20128'%20xml:space='preserve'%3e%3cpath%20fill='%23E24329'%20d='m124.755%2051.382-.177-.452L107.47%206.282a4.459%204.459%200%200%200-1.761-2.121%204.581%204.581%200%200%200-5.236.281%204.578%204.578%200%200%200-1.518%202.304L87.404%2042.088H40.629L29.077%206.746a4.492%204.492%200%200%200-1.518-2.31%204.581%204.581%200%200%200-5.236-.281%204.502%204.502%200%200%200-1.761%202.121L3.422%2050.904l-.17.452c-5.059%2013.219-.763%2028.192%2010.537%2036.716l.059.046.157.111%2026.061%2019.516%2012.893%209.758%207.854%205.93a5.283%205.283%200%200%200%206.388%200l7.854-5.93%2012.893-9.758%2026.218-19.634.065-.052c11.273-8.526%2015.562-23.472%2010.524-36.677z'/%3e%3cpath%20fill='%23FC6D26'%20d='m124.755%2051.382-.177-.452a57.79%2057.79%200%200%200-23.005%2010.341L64%2089.682c12.795%209.68%2023.934%2018.09%2023.934%2018.09l26.218-19.634.065-.052c11.291-8.527%2015.586-23.488%2010.538-36.704z'/%3e%3cpath%20fill='%23FCA326'%20d='m40.066%20107.771%2012.893%209.758%207.854%205.93a5.283%205.283%200%200%200%206.388%200l7.854-5.93%2012.893-9.758s-11.152-8.436-23.947-18.09a18379.202%2018379.202%200%200%200-23.935%2018.09z'/%3e%3cpath%20fill='%23FC6D26'%20d='M26.42%2061.271A57.73%2057.73%200%200%200%203.422%2050.904l-.17.452c-5.059%2013.219-.763%2028.192%2010.537%2036.716l.059.046.157.111%2026.061%2019.516L64%2089.655%2026.42%2061.271z'/%3e%3c/svg%3e",Ot="/assets/jenkins-CWiA3Rta.svg",Bt="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2032%2032'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cdefs%3e%3cmask%20id='a'%20x='1.455'%20y='1.455'%20width='29.091'%20height='29.091'%20maskUnits='userSpaceOnUse'%3e%3cpath%20d='M5.7,20.974l1.464-1.565,1.819,1.819L7.5,22.707,9.293,24.5l1.479-1.479L12.6,24.852,11.151,26.3l4.242,4.242h6.667a1.212,1.212,0,0,0,1.212-1.212v-9.7l6.195-4.129a2.425,2.425,0,0,0,1.078-2.016V2.667a1.212,1.212,0,0,0-1.212-1.212H18.509a2.425,2.425,0,0,0-2.016,1.078L12.364,8.727h-9.7A1.212,1.212,0,0,0,1.455,9.94v6.666Z'%20style='fill:%23fff'/%3e%3cpath%20d='M3.636,23.273H1.455v7.273H8.727V28.364H3.636Z'%20style='fill:%23fff'/%3e%3c/mask%3e%3clinearGradient%20id='b'%20x1='0.069'%20y1='31.569'%20x2='1.069'%20y2='31.569'%20gradientTransform='matrix(0,%2029.091,%2029.091,%200,%20-902.364,%20-0.545)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23ffffff'/%3e%3cstop%20offset='1'%20stop-color='%23ffffff'%20stop-opacity='0'/%3e%3c/linearGradient%3e%3clinearGradient%20id='c'%20x1='0.069'%20y1='31.194'%20x2='1.069'%20y2='31.194'%20xlink:href='%23b'/%3e%3c/defs%3e%3ctitle%3efile_type_azurepipelines%3c/title%3e%3cg%20style='mask:url(%23a)'%3e%3cpath%20d='M1.455,23.273H3.636v5.091H8.727v2.182H1.455Z'%20style='fill:%2391b0f2'/%3e%3cpath%20d='M1.455,9.939v6.667L5.7,20.974,7.515,19.03l5.455,5.455L11.151,26.3l4.242,4.242h6.667a1.212,1.212,0,0,0,1.212-1.212v-9.7L12.364,8.727h-9.7A1.212,1.212,0,0,0,1.455,9.939Z'%20style='fill:%230f46bd'/%3e%3cpath%20d='M6,18.249,17.212,1.455H30.545V14.788L13.751,26Z'%20style='fill:%23062aa9'/%3e%3cpath%20d='M6.7,18.952a1.212,1.212,0,0,1-.151-1.53l9.94-14.889a2.424,2.424,0,0,1,2.016-1.078H29.333a1.212,1.212,0,0,1,1.212,1.212V13.492a2.424,2.424,0,0,1-1.078,2.016l-14.889,9.94a1.212,1.212,0,0,1-1.53-.151Z'%20style='fill:%232560e0'/%3e%3cpath%20d='M7.5,22.707l9.255-9.255,1.792,1.792L9.293,24.5Z'%20style='fill:%230a44c2'/%3e%3cpath%20d='M7.5,22.707l9.255-9.255,1.792,1.792L9.293,24.5Z'%20style='fill:%23729af2'/%3e%3cpath%20d='M10.772,23.02,8.98,21.228l7.776-7.775,1.792,1.792Z'%20style='fill:%234c80f0'/%3e%3cpath%20d='M23.273,12.364a3.636,3.636,0,1,0-3.636-3.636A3.636,3.636,0,0,0,23.273,12.364Z'%20style='fill:%230a44c2'/%3e%3cpath%20d='M23.273,12.364a3.636,3.636,0,1,0-3.636-3.636A3.636,3.636,0,0,0,23.273,12.364Z'%20style='fill:%2391b0f2'/%3e%3cg%20style='opacity:0.20000000298023224'%3e%3cpath%20d='M5.7,20.974l1.464-1.565,1.819,1.819L7.5,22.707,9.293,24.5l1.479-1.479L12.6,24.852,11.151,26.3l4.242,4.242h6.667a1.212,1.212,0,0,0,1.212-1.212v-9.7l6.195-4.129a2.425,2.425,0,0,0,1.078-2.016V2.667a1.212,1.212,0,0,0-1.212-1.212H18.509a2.425,2.425,0,0,0-2.016,1.078L12.364,8.727h-9.7A1.212,1.212,0,0,0,1.455,9.94v6.666Z'%20style='fill:url(%23b)'/%3e%3cpath%20d='M3.636,23.273H1.455v7.273H8.727V28.364H3.636Z'%20style='fill:url(%23c)'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",_t="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20128%20128'%3e%3cdefs%3e%3clinearGradient%20id='bitbucket-original-a'%20gradientUnits='userSpaceOnUse'%20x1='28.593'%20y1='14.226'%20x2='16.672'%20y2='23.532'%20gradientTransform='scale(4)'%3e%3cstop%20offset='.176'%20stop-color='%230052cc'/%3e%3cstop%20offset='1'%20stop-color='%232684ff'/%3e%3c/linearGradient%3e%3c/defs%3e%3cpath%20d='M19.082%2020c-1.918%200-3.355%201.758-3.039%203.516l12.95%2079.289c.32%202.078%202.077%203.515%204.155%203.515h62.66c1.442%200%202.72-1.12%203.04-2.558l13.109-80.086c.316-1.918-1.121-3.516-3.039-3.516zM74.07%2077.227H54.09l-5.278-28.293h30.215zm0%200'%20fill='%232684ff'/%3e%3cpath%20d='M107.64%2048.934H78.868L74.07%2077.227H54.09l-23.5%2027.972s1.12.961%202.719.961h62.66c1.441%200%202.719-1.12%203.039-2.558zm0%200'%20fill='url(%23bitbucket-original-a)'/%3e%3c/svg%3e",Dt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20128%20128'%3e%3cpath%20fill='%23343434'%20d='M47.809%2064c0-8.45%206.847-15.23%2015.23-15.23%208.387%200%2015.234%206.847%2015.234%2015.23S71.426%2079.23%2063.04%2079.23c-8.383%200-15.23-6.847-15.23-15.23zm15.23-64C33.152%200%208.13%2020.48%201.023%2048.129c-.062.191-.062.383-.062.64a3.07%203.07%200%20003.07%203.07h25.793c1.215%200%202.305-.702%202.75-1.792%205.313-11.52%2016.961-19.582%2030.465-19.582%2018.496%200%2033.535%2015.039%2033.535%2033.535%200%2018.496-15.039%2033.535-33.535%2033.535-13.504%200-25.152-8-30.465-19.582-.511-1.023-1.535-1.793-2.75-1.793H4.031a3.07%203.07%200%2000-3.07%203.07c0%20.196.062.387.062.641C8.063%20107.52%2033.153%20128%2063.04%20128c35.328%200%2064-28.672%2064-64s-28.672-64-64-64zm0%200'/%3e%3c/svg%3e",Gt={"github-actions":qt,"gitlab-ci":Ft,jenkins:Ot,"azure-pipelines":Bt,bitbucket:_t,circleci:Dt},Ut={circleci:!0};function Kt({platform:s,size:i=16,className:n=""}){const a=Gt[s];return a?e.jsx("img",{src:a,alt:"","aria-hidden":"true",width:i,height:i,style:{width:i,height:i},className:`flex-shrink-0 object-contain ${Ut[s]?"dark:invert":""} ${n}`}):null}async function Xe(s){var i;try{if((i=navigator.clipboard)!=null&&i.writeText)return await navigator.clipboard.writeText(s),!0}catch{}try{const n=document.createElement("textarea");n.value=s,n.setAttribute("readonly",""),n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select();const a=document.execCommand("copy");return document.body.removeChild(n),a}catch{return!1}}const Pe={queued:"bg-amber-500/10 border-amber-500/30 text-amber-300",running:"bg-blue-500/10 border-blue-500/30 text-blue-300",passed:"bg-emerald-500/10 border-emerald-500/30 text-emerald-300",failed:"bg-red-500/10 border-red-500/30 text-red-300",cancelled:"bg-white/5 border-white/10 text-gray-400",error:"bg-red-500/10 border-red-500/30 text-red-300"},et={command:"Command",suite:"Suite",cycle:"Cycle"};function V(s){if(!s)return"—";const i=Date.now()-new Date(s).getTime(),n=Math.floor(i/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const a=Math.floor(n/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function tt(s){if(!s)return"";const i=new Date(s).getTime()-Date.now();if(i<=0)return"expired";const n=i/864e5;return n>=1?`expires in ${Math.round(n)}d`:`expires in ${Math.max(1,Math.floor(i/36e5))}h`}function pe(s){if(!s||s<=0)return"—";const i=Math.round(s/1e3);if(i<60)return`${i}s`;const n=Math.floor(i/60);return n<60?`${n}m ${i%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function st(s){return s>=90?"text-emerald-400":s>=70?"text-amber-400":"text-red-400"}function at(s){let i;try{i=new URL(s)}catch{return"Enter a full address, e.g. https://testver.example.com"}return/^https?:$/.test(i.protocol)?/^(localhost|127\.|0\.0\.0\.0|\[?::1\]?)/i.test(i.hostname)?"This is a local address — CI runners in the cloud cannot reach it. Use the address your CI runners reach this server at.":i.protocol==="http:"?"Plain http — the CI token travels unencrypted. Use https when CI reaches this server over the internet.":null:"Use an http(s) address"}function Be(s){const i=l.useRef(s);i.current=s,l.useEffect(()=>{const n=a=>{a.key==="Escape"&&i.current()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[])}function Re({what:s,error:i,onRetry:n}){return e.jsxs("div",{role:"alert",className:"px-4 py-3 rounded-xl bg-red-500/10 border border-red-500/30 text-sm text-red-300 flex items-center gap-3",children:[e.jsx(Ae,{size:15,className:"flex-shrink-0"}),e.jsxs("span",{className:"flex-1",children:["Could not load ",s,": ",(i==null?void 0:i.message)||String(i)]}),e.jsxs("button",{onClick:n,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg border border-red-500/30 hover:bg-red-500/10 text-xs font-medium",children:[e.jsx(At,{size:12})," Retry"]})]})}function rt({message:s,onDismiss:i}){return s?e.jsxs("div",{role:"alert",className:"mb-4 px-3 py-2.5 rounded-xl bg-red-500/10 border border-red-500/30 text-sm text-red-300 flex items-start gap-2",children:[e.jsx(Ae,{size:15,className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"flex-1",children:s}),e.jsx("button",{onClick:i,"aria-label":"Dismiss error",className:"text-red-300 hover:text-red-200",children:e.jsx($e,{size:14})})]}):null}function ls(){var je,ie,Ne,we;const s=it(),{hasRole:i}=dt(),n=i("tester"),a=i("admin"),[o,w]=Tt("tab",["dashboard","pipelines","ci-runs","tokens","trace"],"dashboard"),x=zt(),N=K({queryKey:["ci-pipelines"],queryFn:xt}),g=K({queryKey:["ci-tokens"],queryFn:mt}),v=K({queryKey:["ci-runs"],queryFn:()=>ht(200),refetchInterval:t=>{var u;return(((u=t.state.data)==null?void 0:u.runs)||[]).some(f=>f.state==="running"||f.state==="queued")?1e4:3e4}}),{data:b}=K({queryKey:["suites"],queryFn:ut}),c=K({queryKey:["ci-analytics"],queryFn:pt,refetchInterval:3e4}),d=c.data,j=((je=N.data)==null?void 0:je.pipelines)||[],P=((ie=g.data)==null?void 0:ie.tokens)||[],F=P.filter(t=>!t.revoked),$=P.filter(t=>t.revoked),S=((Ne=v.data)==null?void 0:Ne.runs)||[],O=(b==null?void 0:b.suites)||[],h=[...new Set(j.filter(t=>t.target.type==="cycle"&&t.target.cycleId).map(t=>t.target.cycleId))],{data:R}=K({queryKey:["ci-cycle-names",h.join(",")],enabled:h.length>0,queryFn:async()=>{const t=await Promise.all(h.map(async u=>{try{const f=await Ze(u);return[u,{name:f==null?void 0:f.name,planId:f==null?void 0:f.planId}]}catch{return[u,null]}}));return Object.fromEntries(t)}}),[A]=Se("state"),[k]=Se("pipeline"),[B]=Se("branch"),[M]=Se("env"),L=S.filter(t=>(!A||t.state===A)&&(!k||t.mappingName===k)&&(!B||(t.branch||"").toLowerCase().includes(B.toLowerCase()))&&(!M||(t.environment||"").toLowerCase()===M.toLowerCase())),_=!!(A||k||B||M),ce=()=>x({state:null,pipeline:null,branch:null,env:null}),[se,I]=l.useState(0),[z,ae]=l.useState(20);l.useEffect(()=>{I(0)},[A,k,B,M]);const E=Math.max(1,Math.ceil(L.length/z)),T=Math.min(se,E-1),re=L.slice(T*z,(T+1)*z),[ne,U]=l.useState(null),[W,m]=l.useState(null),[y,J]=l.useState(null),[ge,le]=l.useState(null),[Z,de]=l.useState(null),[X,p]=l.useState(null),[be,ye]=l.useState(!1),[fe,D]=l.useState(null),[Me,ee]=l.useState(null),ve=t=>{var u;return(u=O.find(f=>f.id===t))==null?void 0:u.name},Q=()=>{s.invalidateQueries({queryKey:["ci-pipelines"]}),s.invalidateQueries({queryKey:["ci-tokens"]}),s.invalidateQueries({queryKey:["ci-runs"]}),s.invalidateQueries({queryKey:["ci-analytics"]})},ze=async t=>{try{await Qe({...t,enabled:!t.enabled}),Q()}catch(u){D((u==null?void 0:u.message)||String(u))}},q=[{id:"dashboard",label:"Dashboard",icon:e.jsx(He,{size:15})},{id:"pipelines",label:"Pipelines",icon:e.jsx(Le,{size:15})},{id:"tokens",label:"CI Tokens",icon:e.jsx(Ue,{size:15})},{id:"ci-runs",label:"CI Runs",icon:e.jsx(ue,{size:15})},{id:"trace",label:"Trace",icon:e.jsx(Fe,{size:15})}];return e.jsxs("div",{className:"h-full flex flex-col bg-surface-0 text-gray-200 animate-fade-in",children:[e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto w-full px-6 py-6",children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(Le,{size:24,className:"text-brand-300"}),"CI/CD Pipelines"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Your CI/CD pipelines trigger test runs that execute on this Testver server and gate the build on the verdict"})]})}),e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsx("div",{role:"tablist","aria-label":"CI/CD Pipelines sections",className:"max-w-[1400px] mx-auto w-full px-6 flex gap-1",children:q.map(t=>e.jsxs("button",{role:"tab","aria-selected":o===t.id,onClick:()=>w(t.id),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors ${o===t.id?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200 hover:border-white/10"}`,children:[t.icon,t.label]},t.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto w-full px-6 py-6 space-y-8",children:[fe&&e.jsxs("div",{role:"alert",className:"px-4 py-3 rounded-xl bg-red-500/10 border border-red-500/30 text-sm text-red-300 flex items-center justify-between",children:[e.jsx("span",{children:fe}),e.jsx("button",{onClick:()=>D(null),"aria-label":"Dismiss error",className:"text-red-300 hover:text-red-200",children:e.jsx($e,{size:14})})]}),o==="pipelines"&&e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-brand-500/10 border border-brand-500/25 text-sm text-gray-300",children:[e.jsx("b",{className:"text-brand-300",children:"Delegated execution:"})," CI pipelines trigger runs that execute ",e.jsx("b",{children:"on this Testver server"}),", then gate the build on the verdict. Map a pipeline to a suite, cycle, or command, create a CI token, and wire your workflow — from CI or any terminal via"," ",e.jsx("code",{className:"text-brand-300",children:"testver trigger"}),"."]}),o==="dashboard"&&c.isLoading&&e.jsxs("div",{className:"py-12 text-center text-gray-500 text-sm",children:[e.jsx(Y,{size:16,className:"animate-spin inline mr-2"}),"Loading the dashboard…"]}),o==="dashboard"&&c.isError&&e.jsx(Re,{what:"the CI dashboard",error:c.error,onRetry:()=>c.refetch()}),o==="dashboard"&&d&&d.totals.runs===0&&e.jsxs("div",{className:"py-16 text-center rounded-xl border border-dashed border-white/10",children:[e.jsx(He,{size:32,className:"mx-auto text-gray-600 mb-3"}),e.jsx("p",{className:"text-base font-medium text-gray-300 mb-1",children:"No CI runs yet"}),e.jsx("p",{className:"text-sm text-gray-500 max-w-md mx-auto mb-4",children:"Create a pipeline mapping and a CI token, then trigger a run from your pipeline or any terminal. The dashboard lights up with pass rates, trends, and insights from the first run."}),e.jsx("button",{onClick:()=>w("pipelines"),className:"px-4 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:"Set up a Pipeline →"})]}),o==="dashboard"&&d&&d.totals.runs>0&&e.jsxs("section",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2 mb-3",children:[e.jsx(He,{size:17,className:"text-emerald-300"})," Overview"]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-3",children:[e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:"CI Runs"}),e.jsx("div",{className:"text-xl font-semibold text-gray-100 mt-0.5",children:d.totals.runs})]}),e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",title:"Passed ÷ (passed + failed + errored). A run that errored — lost, timed out or ran no tests — counts against it; cancelled runs don't count.",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:"Pass Rate"}),e.jsxs("div",{className:`text-xl font-semibold mt-0.5 ${st(d.totals.passRate)}`,children:[d.totals.passRate,"%"]}),(d.totals.errored||0)>0&&e.jsxs("div",{className:"text-xs text-gray-500 mt-0.5",children:[d.totals.errored," errored"]})]}),e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsxs("div",{className:"text-xs text-gray-500 uppercase tracking-wide flex items-center gap-1",children:[e.jsx(Rt,{size:11})," Avg Duration"]}),e.jsx("div",{className:"text-xl font-semibold text-gray-100 mt-0.5",children:pe(d.totals.avgDurationMs)})]}),e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:"Active / Queued"}),e.jsx("div",{className:`text-xl font-semibold mt-0.5 ${d.totals.active>0?"text-blue-300":"text-gray-100"}`,children:d.totals.active})]})]}),d.trend.length>1&&e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide mb-2",children:"Recent verdicts (oldest → newest)"}),e.jsx("div",{className:"flex items-end gap-1 h-14",role:"list","aria-label":"Recent CI verdicts",children:d.trend.map((t,u)=>{const f=d.trend.length,xe=Math.max(...d.trend.map(H=>H.durationMs||0),1),te=30+Math.round((t.durationMs||0)/xe*70),oe=t.state==="passed"?"bg-emerald-400/70":t.state==="error"?"bg-amber-400/80":"bg-red-400/80",G=u<f/4?"left-0":u>3*f/4?"right-0":"left-1/2 -translate-x-1/2",ke=`${t.mapping||"CI run"}: ${t.state}${t.summary?`, ${t.summary.passed} of ${t.summary.total} passed`:""}, ${V(t.at)}`,Ce=`block w-full rounded-sm transition-opacity hover:opacity-80 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-400 ${oe}`;return e.jsxs("div",{role:"listitem",className:"relative flex-1 max-w-[14px] h-full flex items-end",onMouseEnter:()=>ee(u),onMouseLeave:()=>ee(H=>H===u?null:H),children:[t.runId?e.jsx("a",{href:`/results?runId=${encodeURIComponent(t.runId)}`,target:"_blank",rel:"noopener noreferrer","aria-label":`${ke} — open the report`,onFocus:()=>ee(u),onBlur:()=>ee(H=>H===u?null:H),className:Ce,style:{height:`${te}%`}}):e.jsx("span",{tabIndex:0,"aria-label":ke,onFocus:()=>ee(u),onBlur:()=>ee(H=>H===u?null:H),className:Ce,style:{height:`${te}%`}}),Me===u&&e.jsxs("div",{className:`absolute bottom-full mb-2 ${G} z-50 pointer-events-none w-64 rounded-xl bg-surface-1 border border-white/10 shadow-xl shadow-black/30 p-3.5 text-left`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2.5",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-100 truncate",children:t.mapping||"CI run"}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full border flex-shrink-0 ${Pe[t.state]||Pe.failed}`,children:t.state})]}),e.jsxs("div",{className:"space-y-1.5 text-xs",children:[t.branch&&e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"text-gray-500",children:"Branch"}),e.jsx("span",{className:"text-gray-200 truncate",children:t.branch})]}),t.summary&&e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"text-gray-500",children:"Result"}),e.jsxs("span",{className:"text-gray-200",children:[e.jsx("span",{className:"text-emerald-400",children:t.summary.passed})," / ",t.summary.total," passed",t.summary.failed>0&&e.jsxs("span",{className:"text-red-400",children:[" · ",t.summary.failed," failed"]})]})]}),t.error&&e.jsx("div",{className:"text-amber-300 line-clamp-2",children:t.error}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"text-gray-500",children:"Duration"}),e.jsx("span",{className:"text-gray-200",children:pe(t.durationMs)})]}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"text-gray-500",children:"When"}),e.jsxs("span",{className:"text-gray-200",children:[V(t.at)," · ",new Date(t.at).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]})]}),t.runId&&e.jsx("div",{className:"mt-2.5 pt-2 border-t border-white/10 text-xs text-brand-300",children:"Click the bar to open the full report →"})]})]},t.ciRunId)})})]})]}),o==="pipelines"&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(Le,{size:17,className:"text-brand-300"})," Pipeline Mappings"]}),n&&e.jsxs("button",{onClick:()=>U({enabled:!0,target:{type:"suite"}}),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:[e.jsx(Ye,{size:14})," New Mapping"]})]}),N.isError?e.jsx(Re,{what:"pipeline mappings",error:N.error,onRetry:()=>N.refetch()}):N.isLoading?e.jsxs("div",{className:"py-8 text-center text-gray-500 text-sm",children:[e.jsx(Y,{size:16,className:"animate-spin inline mr-2"}),"Loading…"]}):j.length===0?e.jsxs("div",{className:"py-10 text-center rounded-xl border border-dashed border-white/10 text-sm text-gray-500",children:["No pipeline mappings yet — ",n?"create one to let CI (or the CLI) trigger runs on this server.":"a tester or admin can create one."]}):e.jsx("div",{className:"space-y-2",children:j.map(t=>{var te,me,oe;const u=t.target.type==="suite"?ve(t.target.suiteId):void 0,f=t.target.type==="cycle"&&t.target.cycleId?R==null?void 0:R[t.target.cycleId]:void 0,xe=t.target.type==="suite"&&O.length>0&&!u||t.target.type==="cycle"&&f===null;return e.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-xl bg-surface-1 border border-white/5 ${t.enabled?"":"opacity-60"}`,children:[e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-brand-500/15 text-brand-300 border border-brand-500/25 flex-shrink-0",children:et[t.target.type]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-gray-200",children:t.name}),!t.enabled&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-white/5 text-gray-500",children:"disabled"}),t.previousNames&&t.previousNames.length>0&&e.jsxs("span",{className:"text-xs text-gray-500",title:"CI files that still use an old name keep triggering this mapping",children:["also answers to ",t.previousNames.map(G=>`"${G}"`).join(", "),n&&e.jsx("button",{onClick:async()=>{try{await gt(t.id),Q()}catch(G){D((G==null?void 0:G.message)||String(G))}},className:"ml-1.5 text-brand-300 hover:text-brand-200 underline-offset-2 hover:underline",children:"Forget old names"})]})]}),e.jsxs("div",{className:"text-sm text-gray-400 truncate",children:[t.target.type==="command"&&e.jsx("code",{children:t.target.command}),t.target.type==="suite"&&e.jsxs(e.Fragment,{children:["→ ",u||e.jsx("code",{children:t.target.suiteId})]}),t.target.type==="cycle"&&e.jsxs(e.Fragment,{children:["→ ",f!=null&&f.name?`Cycle "${f.name}"`:e.jsxs(e.Fragment,{children:["Cycle ",e.jsx("code",{children:t.target.cycleId})]})]}),xe&&e.jsxs("span",{className:"ml-2 text-amber-400",children:[e.jsx(Ae,{size:12,className:"inline -mt-0.5"})," no longer exists — triggers will fail"]}),((te=t.overrides)==null?void 0:te.environment)&&e.jsxs("span",{className:"ml-2",children:["env: ",t.overrides.environment]}),((me=t.overrides)==null?void 0:me.browser)&&e.jsxs("span",{className:"ml-2",children:["browser: ",t.overrides.browser]}),((oe=t.statusPush)==null?void 0:oe.enabled)&&e.jsxs("span",{className:"ml-2 text-brand-400/80",children:["PR status → ",t.statusPush.provider]}),e.jsxs("span",{className:"ml-2",children:["· last triggered ",V(t.lastTriggeredAt)]})]})]}),n&&e.jsx("button",{onClick:()=>void ze(t),role:"switch","aria-checked":t.enabled,"aria-label":`${t.enabled?"Disable":"Enable"} ${t.name}`,title:t.enabled?"Enabled — click to disable":"Disabled — click to enable",className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${t.enabled?"bg-brand-500":"bg-surface-3 border border-white/10"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${t.enabled?"translate-x-4":""}`})}),n&&e.jsx("button",{onClick:()=>J(t),title:"Get pipeline config + CLI snippet","aria-label":`Wire ${t.name} into CI`,className:"p-2 rounded-lg text-gray-400 hover:text-brand-300 hover:bg-white/5 transition-colors",children:e.jsx(Ee,{size:15})}),n&&e.jsx("button",{onClick:()=>U(t),title:"Edit","aria-label":`Edit ${t.name}`,className:"p-2 rounded-lg text-gray-400 hover:text-gray-200 hover:bg-white/5 transition-colors",children:e.jsx(Et,{size:15})}),n&&e.jsx("button",{onClick:()=>m(t),title:"Delete","aria-label":`Delete ${t.name}`,className:"p-2 rounded-lg text-gray-400 hover:text-red-300 hover:bg-white/5 transition-colors",children:e.jsx(Pt,{size:15})})]},t.id)})})]}),o==="tokens"&&e.jsxs("section",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2 mb-1",children:[e.jsx(Ue,{size:17,className:"text-amber-300"})," CI Tokens"]}),e.jsxs("p",{className:"text-sm text-gray-400 mb-3",children:["Machine tokens for the Gate API. Store one as ",e.jsx("code",{children:"TESTVER_CI_TOKEN"})," in your CI platform's secrets. The value is shown ",e.jsx("b",{children:"once"})," at creation. A token triggers only the pipeline mappings it is scoped to — ad-hoc suites, cycles and commands need a token that allows them."]}),a?e.jsx(Vt,{pipelines:j,onCreated:t=>{le(t),Q()}}):e.jsx("p",{className:"text-sm text-gray-500 mb-3 px-3 py-2 rounded-lg bg-surface-2 border border-white/5",children:"Only admins can create or revoke CI tokens."}),g.isError?e.jsx(Re,{what:"CI tokens",error:g.error,onRetry:()=>g.refetch()}):g.isLoading?e.jsxs("div",{className:"py-6 text-center text-gray-500 text-sm",children:[e.jsx(Y,{size:16,className:"animate-spin inline mr-2"}),"Loading…"]}):F.length===0?e.jsxs("div",{className:"py-8 text-center rounded-xl border border-dashed border-white/10 text-sm text-gray-500",children:["No active CI tokens.",a?" Create one above, then add it to your CI platform's secrets.":""]}):e.jsx("div",{className:"space-y-1.5",children:F.map(t=>e.jsx(Ke,{token:t,pipelines:j,onRevoke:a?()=>de({id:t.id,name:t.name}):void 0},t.id))}),$.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("button",{onClick:()=>ye(t=>!t),"aria-expanded":be,className:"text-sm text-gray-500 hover:text-gray-300",children:[be?"▾":"▸"," Revoked tokens (",$.length,")"]}),be&&e.jsx("div",{className:"space-y-1.5 mt-2",children:$.map(t=>e.jsx(Ke,{token:t,pipelines:j},t.id))})]})]}),o==="dashboard"&&d&&(d.perPipeline.length>0||d.perBranch.length>0)&&e.jsxs("section",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2 mb-3",children:[e.jsx($t,{size:17,className:"text-purple-300"})," Insights"]}),e.jsx("p",{className:"text-sm text-gray-500 -mt-2 mb-3",children:"Click a row to see its runs."}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-3",children:[e.jsx(qe,{title:"By Pipeline",rows:d.perPipeline,onSelect:t=>x({tab:"ci-runs",pipeline:t,branch:null,env:null,state:null})}),e.jsx(qe,{title:"By Branch",rows:d.perBranch,onSelect:t=>x({tab:"ci-runs",branch:t,pipeline:null,env:null,state:null})}),e.jsx(qe,{title:"By Environment",rows:d.perEnvironment,onSelect:t=>x({tab:"ci-runs",env:t,pipeline:null,branch:null,state:null})})]})]}),o==="trace"&&e.jsx(Yt,{}),o==="dashboard"&&d&&d.totals.runs>0&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(ue,{size:17,className:"text-blue-300"})," Recent CI Runs",e.jsx("span",{className:"text-sm text-gray-500 font-normal",children:"(last 5)"})]}),e.jsx("button",{onClick:()=>w("ci-runs"),className:"text-sm text-brand-300 hover:text-brand-200 font-medium",children:"View all runs →"})]}),e.jsx(We,{runs:S.slice(0,5),onCancel:n?p:void 0})]}),o==="ci-runs"&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 flex-wrap gap-2",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(ue,{size:17,className:"text-blue-300"})," CI Runs",e.jsxs("span",{className:"text-sm text-gray-500 font-normal",children:[_?`${L.length} of ${S.length}`:`${S.length} total`,(((we=v.data)==null?void 0:we.total)||0)>S.length&&` (latest ${S.length} of ${v.data.total})`]})]}),S.length>0&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsxs("select",{value:A||"",onChange:t=>x({state:t.target.value||null}),"aria-label":"Filter by state",className:"px-2.5 py-1.5 rounded-lg bg-surface-2 border border-white/10 text-sm text-gray-900 dark:text-gray-200 focus:outline-none",children:[e.jsx("option",{value:"",children:"All states"}),["running","queued","passed","failed","cancelled","error"].map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsxs("select",{value:k||"",onChange:t=>x({pipeline:t.target.value||null}),"aria-label":"Filter by pipeline",className:"px-2.5 py-1.5 rounded-lg bg-surface-2 border border-white/10 text-sm text-gray-900 dark:text-gray-200 focus:outline-none",children:[e.jsx("option",{value:"",children:"All pipelines"}),[...new Set(S.map(t=>t.mappingName).filter(Boolean))].map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsxs("select",{value:M||"",onChange:t=>x({env:t.target.value||null}),"aria-label":"Filter by environment",className:"px-2.5 py-1.5 rounded-lg bg-surface-2 border border-white/10 text-sm text-gray-900 dark:text-gray-200 focus:outline-none",children:[e.jsx("option",{value:"",children:"All environments"}),[...new Set(S.map(t=>t.environment).filter(Boolean))].map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx("input",{value:B||"",onChange:t=>x({branch:t.target.value||null}),placeholder:"Branch…","aria-label":"Filter by branch",className:"px-2.5 py-1.5 rounded-lg bg-surface-2 border border-white/10 text-sm text-gray-200 placeholder-gray-600 focus:outline-none w-32"}),_&&e.jsx("button",{onClick:ce,className:"text-sm text-gray-500 hover:text-gray-300 px-1.5",title:"Clear all filters",children:"✕ Clear"})]})]}),v.isError?e.jsx(Re,{what:"CI runs",error:v.error,onRetry:()=>v.refetch()}):v.isLoading?e.jsxs("div",{className:"py-8 text-center text-gray-500 text-sm",children:[e.jsx(Y,{size:16,className:"animate-spin inline mr-2"}),"Loading…"]}):S.length===0?e.jsxs("div",{className:"py-10 text-center rounded-xl border border-dashed border-white/10 text-sm text-gray-500",children:["No CI-triggered runs yet. Trigger one with ",e.jsx("code",{children:'testver trigger --mapping "…"'})," or from your pipeline."]}):e.jsxs(e.Fragment,{children:[e.jsx(We,{runs:re,emptyNote:"No runs match the filters.",onCancel:n?p:void 0}),E>1&&e.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 mt-2 rounded-xl border border-white/5 bg-surface-1 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[e.jsx("span",{children:"Rows per page:"}),e.jsx("select",{value:z,onChange:t=>{ae(Number(t.target.value)),I(0)},"aria-label":"Rows per page",className:"bg-surface-2 border border-white/10 rounded px-2 py-1 text-gray-900 dark:text-gray-200 focus:outline-none focus:border-brand-500/40",children:[10,20,50,100].map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[e.jsxs("span",{children:["Showing ",T*z+1,"–",Math.min((T+1)*z,L.length)," of ",L.length," run",L.length===1?"":"s"]}),e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsx("button",{onClick:()=>I(0),disabled:T===0,title:"First page","aria-label":"First page",className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"«"}),e.jsx("button",{onClick:()=>I(t=>Math.max(0,t-1)),disabled:T===0,title:"Previous page",className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"‹ Prev"}),e.jsxs("span",{className:"px-2 text-gray-400",children:["Page ",e.jsx("span",{className:"text-gray-900 dark:text-gray-200 font-medium",children:T+1})," of ",E]}),e.jsx("button",{onClick:()=>I(t=>Math.min(E-1,t+1)),disabled:T>=E-1,title:"Next page",className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"Next ›"}),e.jsx("button",{onClick:()=>I(E-1),disabled:T>=E-1,title:"Last page","aria-label":"Last page",className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"»"})]})]})]})]})]})]})}),ne&&e.jsx(Zt,{mapping:ne,suites:O,onClose:()=>U(null),onSaved:()=>{U(null),Q()}}),y&&e.jsx(Qt,{mapping:y,hasToken:F.length>0,onOpenTokens:()=>{J(null),w("tokens")},onClose:()=>J(null)}),ge&&e.jsx(Wt,{raw:ge.raw,token:ge.token,pipelines:j,onClose:()=>le(null)}),W&&e.jsx(Te,{open:!0,title:`Delete mapping "${W.name}"?`,description:"CI jobs and scripts triggering this mapping name will start failing with 404. This does not affect past runs.",confirmLabel:"Delete",variant:"danger",onCancel:()=>m(null),onConfirm:async()=>{try{await bt(W.id),Q()}catch(t){D((t==null?void 0:t.message)||String(t))}m(null)}}),Z&&e.jsx(Te,{open:!0,title:`Revoke token "${Z.name}"?`,description:"Every CI job or script using this token immediately loses access. This cannot be undone.",confirmLabel:"Revoke",variant:"danger",onCancel:()=>de(null),onConfirm:async()=>{try{await yt(Z.id),Q()}catch(t){D((t==null?void 0:t.message)||String(t))}de(null)}}),X&&e.jsx(Te,{open:!0,title:`Cancel this ${X.mappingName||"CI"} run?`,description:X.state==="queued"?'It leaves the queue and its CI job fails with "cancelled".':'The tests stop on the Testver server and the CI job fails with "cancelled".',confirmLabel:"Cancel run",variant:"danger",onCancel:()=>p(null),onConfirm:async()=>{try{await ft(X.id),Q()}catch(t){D((t==null?void 0:t.message)||String(t))}p(null)}})]})}function nt(s,i){const n=s==null?void 0:s.mappingIds,a=n?n.length===0?"no pipeline mappings":n.map(w=>{var x;return((x=i.find(N=>N.id===w))==null?void 0:x.name)||"a deleted mapping"}).join(", "):"all pipeline mappings",o=(s==null?void 0:s.adHoc)??"none";return o==="commands"?`${a} + ad-hoc suites, cycles and shell commands`:o==="suites"?`${a} + ad-hoc suites and cycles`:a}function Ke({token:s,pipelines:i,onRevoke:n}){var o;const a=!!s.expiresAt&&new Date(s.expiresAt).getTime()<=Date.now();return e.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 rounded-xl bg-surface-1 border border-white/5 text-sm ${s.revoked||a?"opacity-70":""}`,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium text-gray-200",children:s.name}),e.jsxs("code",{className:"text-xs text-gray-500",children:[s.prefix,"…"]}),s.revoked&&e.jsxs("span",{className:"text-xs px-1.5 py-0.5 rounded bg-white/5 text-gray-500",children:["revoked ",V(s.revokedAt),s.revokedBy?` by ${s.revokedBy}`:""]}),!s.revoked&&s.expiresAt&&e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${a?"bg-red-500/10 text-red-300":"bg-white/5 text-gray-400"}`,children:tt(s.expiresAt)}),(((o=s.scope)==null?void 0:o.adHoc)??"none")==="commands"&&!s.revoked&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-300",title:"Can run any shell command on this server",children:"runs commands"})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-0.5 truncate",children:["Triggers ",nt(s.scope,i)]})]}),e.jsxs("span",{className:"text-sm text-gray-500 whitespace-nowrap",children:["created ",V(s.createdAt),s.createdBy?` by ${s.createdBy}`:""," · last used ",V(s.lastUsedAt)]}),n&&e.jsx("button",{onClick:n,title:"Revoke","aria-label":`Revoke ${s.name}`,className:"p-1.5 rounded-lg text-red-400 hover:text-red-600 dark:hover:text-red-500 hover:bg-red-500/10 transition-colors",children:e.jsx(Mt,{size:15})})]})}function Vt({pipelines:s,onCreated:i}){const[n,a]=l.useState(""),[o,w]=l.useState(!0),[x,N]=l.useState([]),[g,v]=l.useState("none"),[b,c]=l.useState("365"),[d,j]=l.useState(!1),[P,F]=l.useState(null),$=!!n.trim()&&!d&&(o||x.length>0||g!=="none"),S=async()=>{if($){j(!0),F(null);try{const h=await kt({name:n.trim(),scope:{mappingIds:o?void 0:x,adHoc:g},expiresInDays:b?Number(b):void 0});a(""),N([]),w(!0),v("none"),i(h)}catch(h){F((h==null?void 0:h.message)||String(h))}finally{j(!1)}}};return e.jsxs("div",{className:"mb-4 p-4 rounded-xl bg-surface-1 border border-white/5 space-y-3",children:[e.jsxs("div",{className:"flex items-end gap-2 flex-wrap",children:[e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Name"}),e.jsx("input",{value:n,onChange:h=>a(h.target.value),maxLength:60,onKeyDown:h=>{h.key==="Enter"&&S()},placeholder:"e.g. github-pr-gate",className:"px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50 w-64"})]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Expires"}),e.jsxs("select",{value:b,onChange:h=>c(h.target.value),className:"px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-900 dark:text-gray-200 focus:outline-none focus:border-brand-500/50",children:[e.jsx("option",{value:"30",children:"in 30 days"}),e.jsx("option",{value:"90",children:"in 90 days"}),e.jsx("option",{value:"365",children:"in 1 year"}),e.jsx("option",{value:"",children:"never"})]})]}),e.jsxs("button",{disabled:!$,onClick:()=>void S(),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:[d?e.jsx(Y,{size:14,className:"animate-spin"}):e.jsx(Ye,{size:14})," Create Token"]})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"text-xs text-gray-500 mb-1",children:"May trigger"}),e.jsxs("div",{className:"flex flex-col gap-1.5 text-sm text-gray-300",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:"tok-scope",checked:o,onChange:()=>w(!0),className:"accent-brand-500"}),"Every pipeline mapping"]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:"tok-scope",checked:!o,onChange:()=>w(!1),className:"accent-brand-500"}),"Only these mappings:"]}),!o&&e.jsxs("div",{className:"ml-6 flex flex-wrap gap-x-4 gap-y-1",children:[s.length===0&&e.jsx("span",{className:"text-xs text-gray-500",children:"No mappings yet."}),s.map(h=>e.jsxs("label",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx("input",{type:"checkbox",checked:x.includes(h.id),className:"accent-brand-500",onChange:R=>N(A=>R.target.checked?[...A,h.id]:A.filter(k=>k!==h.id))}),h.name]},h.id))]})]})]}),e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"text-xs text-gray-500 mb-1",children:["Ad-hoc targets (CLI ",e.jsx("code",{children:"--suite"})," / ",e.jsx("code",{children:"--cycle"})," / ",e.jsx("code",{children:"--command"}),")"]}),e.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1.5 text-sm text-gray-300",children:[["none","Not allowed"],["suites","Any suite or cycle"],["commands","Suites, cycles and shell commands"]].map(([h,R])=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:"tok-adhoc",checked:g===h,onChange:()=>v(h),className:"accent-brand-500"}),R]},h))}),g==="commands"&&e.jsx("p",{className:"mt-1.5 text-xs px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/25 text-amber-300",children:"⚠ Anyone holding this token can run any shell command on this Testver server. Prefer a pipeline mapping with a fixed command, and only allow this for a trusted, private pipeline."})]}),P&&e.jsx("p",{role:"alert",className:"text-sm text-red-300",children:P})]})}function Wt({raw:s,token:i,pipelines:n,onClose:a}){const[o,w]=l.useState(null),[x,N]=l.useState(!1),g=()=>{o==="ok"?a():N(!0)};Be(g);const v=window.location.origin,b=at(v);return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",children:[e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"new-token-title",className:"w-full max-w-xl rounded-2xl bg-surface-1 border border-white/10 p-6",children:[e.jsxs("h3",{id:"new-token-title",className:"text-base font-semibold text-gray-100 mb-2",children:['CI token "',i.name,'" created']}),e.jsx("p",{className:"text-xs text-amber-300 mb-3",children:"Copy it now — this is the only time it will be shown."}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 rounded-xl bg-surface-2 border border-white/10",children:[e.jsx("code",{className:"text-xs text-gray-200 break-all flex-1 select-all",children:s}),e.jsx("button",{onClick:async()=>{w(await Xe(s)?"ok":"fail")},"aria-label":"Copy the token",className:"p-1.5 rounded-lg text-gray-400 hover:text-gray-200",children:o==="ok"?e.jsx(Ie,{size:14,className:"text-emerald-400"}):e.jsx(Oe,{size:14})})]}),o==="fail"&&e.jsx("p",{role:"alert",className:"text-xs text-red-300 mt-1.5",children:"Copying isn't available here — select the token above and copy it by hand."}),e.jsxs("div",{className:"mt-4 text-sm text-gray-400 space-y-1.5",children:[e.jsx("p",{className:"font-medium text-gray-300",children:"Next:"}),e.jsxs("ol",{className:"list-decimal ml-5 space-y-1",children:[e.jsxs("li",{children:["Add it to your CI platform's secrets as ",e.jsx("code",{children:"TESTVER_CI_TOKEN"}),"."]}),e.jsxs("li",{children:["Open a pipeline mapping's ",e.jsx(Ee,{size:12,className:"inline -mt-0.5"})," ",e.jsx("b",{children:"Wire into CI"})," to generate the pipeline file."]}),e.jsxs("li",{children:["CI reaches this server at ",b?e.jsxs("span",{className:"text-amber-300",children:["the address your CI runners can reach (this page's address, ",e.jsx("code",{children:v}),", is local)"]}):e.jsx("code",{children:v}),"."]})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["It may trigger ",nt(i.scope,n),i.expiresAt?` · ${tt(i.expiresAt)}`:" · never expires","."]})]}),e.jsx("div",{className:"mt-4 text-right",children:e.jsx("button",{onClick:g,className:"px-4 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white",children:"Done"})})]}),x&&e.jsx(Te,{open:!0,title:"Close without copying the token?",description:"It cannot be shown again — you would have to create a new token.",confirmLabel:"Close",variant:"danger",onCancel:()=>N(!1),onConfirm:a})]})}function Zt({mapping:s,suites:i,onClose:n,onSaved:a}){var Ne,we,t,u,f,xe,te,me,oe,G,ke,Ce,H,_e,De;Be(n);const[o,w]=l.useState(s.name||""),[x,N]=l.useState(((Ne=s.target)==null?void 0:Ne.type)||"suite"),[g,v]=l.useState(((we=s.target)==null?void 0:we.command)||""),[b,c]=l.useState(((t=s.target)==null?void 0:t.suiteId)||""),[d,j]=l.useState(""),[P,F]=l.useState(((u=s.target)==null?void 0:u.cycleId)||""),[$,S]=l.useState(((f=s.overrides)==null?void 0:f.environment)||""),[O,h]=l.useState(((xe=s.overrides)==null?void 0:xe.browser)||""),[R,A]=l.useState(s.autoHeal||"inherit"),[k,B]=l.useState(s.timeoutMinutes?String(s.timeoutMinutes):""),[M,L]=l.useState(!!((te=s.statusPush)!=null&&te.enabled)),[_,ce]=l.useState(((me=s.statusPush)==null?void 0:me.provider)||"github"),[se,I]=l.useState(((oe=s.statusPush)==null?void 0:oe.repo)||""),[z,ae]=l.useState(s.statusPush?"••••••••":""),[E,T]=l.useState(((G=s.statusPush)==null?void 0:G.baseUrl)||""),[re,ne]=l.useState(s.enabled!==!1),[U,W]=l.useState(!1),[m,y]=l.useState(null),J={github:"owner/repo",gitlab:"group/project (or numeric id)","azure-devops":"org/project/repo",bitbucket:"workspace/repo"},ge={github:"PAT with repo:status (classic) or Commit statuses read/write (fine-grained)",gitlab:"Access token with api scope","azure-devops":"PAT with Code (Status) scope",bitbucket:"username:app_password with Repositories:Write (or a workspace access token)"},le=s.statusPush,Z=!!le&&(le.provider!==_||(le.baseUrl||"")!==E.trim()),de=z==="••••••••";l.useEffect(()=>{Z&&de&&ae("")},[Z,de]);const{data:X}=K({queryKey:["tm-plans"],queryFn:()=>vt(),enabled:x==="cycle"});K({queryKey:["ci-cycle-plan",(ke=s.target)==null?void 0:ke.cycleId],enabled:x==="cycle"&&!!((Ce=s.target)!=null&&Ce.cycleId)&&!d,queryFn:async()=>{const r=await Ze(s.target.cycleId).catch(()=>null);return r!=null&&r.planId&&j(r.planId),(r==null?void 0:r.planId)||null}});const{data:p}=K({queryKey:["tm-cycles",d],queryFn:()=>jt(d),enabled:x==="cycle"&&!!d}),be=((p==null?void 0:p.cycles)||[]).map(r=>r.id).join(","),{data:ye}=K({queryKey:["cycle-automation-counts",d,be],enabled:x==="cycle"&&!!d&&(((H=p==null?void 0:p.cycles)==null?void 0:H.length)||0)>0,queryFn:async()=>{const r=await Promise.all(p.cycles.map(async C=>{try{const he=await Nt(C.id);return[C.id,(he.executions||[]).filter(lt=>lt.hasMappedScript).length]}catch{return[C.id,-1]}}));return Object.fromEntries(r)}}),fe=r=>ye==null?void 0:ye[r],D=((p==null?void 0:p.cycles)||[]).filter(r=>(fe(r.id)??1)!==0).length,{browserOpts:Me,envOpts:ee}=It(),ve=!!o.trim()&&!/^[A-Za-z0-9][A-Za-z0-9 ._-]*$/.test(o.trim()),Q=!!s.id&&!!s.name&&o.trim()!==s.name,ze=k.trim()!==""&&!(Number.isInteger(Number(k))&&Number(k)>=1&&Number(k)<=1440),q=[];o.trim()?ve&&q.push("a valid name"):q.push("a name"),x==="command"&&!g.trim()&&q.push("the command"),x==="suite"&&!b&&q.push("a suite"),x==="cycle"&&!P&&q.push("a cycle"),ze&&q.push("a timeout between 1 and 1440 minutes"),M&&!se.trim()&&q.push("the repository for status push"),M&&!z.trim()&&q.push(Z?"the access token for the new git host":"the status push access token");const je=q.length===0,ie="w-full px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-900 dark:text-gray-200 focus:outline-none focus:border-brand-500/50";return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"mapping-modal-title",className:"w-full max-w-2xl rounded-2xl bg-surface-1 border border-white/10 p-6 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{id:"mapping-modal-title",className:"text-base font-semibold text-gray-100",children:[s.id?"Edit":"New"," Pipeline Mapping"]}),e.jsx("button",{onClick:n,"aria-label":"Close",className:"text-gray-500 hover:text-gray-300",children:e.jsx($e,{size:16})})]}),e.jsx(rt,{message:m,onDismiss:()=>y(null)}),e.jsx("label",{htmlFor:"mapping-name",className:"block text-sm font-medium text-gray-300 mb-1",children:"Mapping name (the trigger key)"}),e.jsx("input",{id:"mapping-name",value:o,onChange:r=>w(r.target.value),placeholder:'e.g. "pr-gate-main"',maxLength:60,className:`w-full px-3 py-2 rounded-xl bg-surface-2 border text-sm text-gray-200 placeholder-gray-600 focus:outline-none mb-1 ${ve?"border-red-500/50 focus:border-red-500/70":"border-white/10 focus:border-brand-500/50"}`}),ve?e.jsx("p",{className:"text-xs text-red-400 mb-3",children:"This name can only contain letters, numbers, spaces, dots, dashes, and underscores — and must start with a letter or number. Special characters would break the generated CI config files."}):Q?e.jsxs("p",{className:"text-xs text-amber-300 mb-3",children:['CI files that use "',s.name,'" keep working — Testver remembers the old name. Update them to "',o.trim(),'" when you can, then forget the old name from the mapping list.']}):e.jsxs("p",{className:"text-xs text-gray-500 mb-3",children:["Your CI pipeline uses this exact name to trigger the run — e.g. ",e.jsxs("code",{children:['testver trigger --mapping "',o.trim()||"pr-gate-main",'"']}),". Allowed: letters, numbers, spaces, dots, dashes, underscores."]}),e.jsx("span",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Execution target"}),e.jsx("div",{className:"flex gap-1.5 mb-3",role:"group","aria-label":"Execution target",children:["suite","cycle","command"].map(r=>e.jsx("button",{onClick:()=>N(r),"aria-pressed":x===r,className:`px-3.5 py-1.5 rounded-lg text-sm font-medium transition-colors ${x===r?"bg-brand-600 text-white":"bg-surface-2 text-gray-400 hover:text-gray-200"}`,children:et[r]},r))}),x==="suite"&&e.jsxs("select",{value:b,onChange:r=>c(r.target.value),className:`${ie} mb-4`,"aria-label":"Suite",children:[e.jsx("option",{value:"",children:"Select a suite…"}),i.map(r=>{var C;return e.jsxs("option",{value:r.id,children:[r.name," (",((C=r.tests)==null?void 0:C.length)||0," tests)"]},r.id)}),b&&!i.some(r=>r.id===b)&&e.jsxs("option",{value:b,children:["(deleted suite ",b,")"]})]}),x==="cycle"&&e.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-4",children:[e.jsxs("select",{value:d,onChange:r=>{j(r.target.value),F("")},className:ie,"aria-label":"Test plan",children:[e.jsx("option",{value:"",children:"Select a plan…"}),((X==null?void 0:X.plans)||[]).map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))]}),e.jsxs("select",{value:P,onChange:r=>F(r.target.value),className:ie,disabled:!d,"aria-label":"Test cycle",children:[e.jsx("option",{value:"",children:d?"Select a cycle…":"Pick a plan first"}),((p==null?void 0:p.cycles)||[]).map(r=>{const C=fe(r.id),he=C===0;return e.jsxs("option",{value:r.id,disabled:he,children:[r.name,C===void 0||C===-1?"":he?" — no automated scripts":` (${C} automated)`]},r.id)})]}),d&&(((_e=p==null?void 0:p.cycles)==null?void 0:_e.length)||0)>0&&D>0&&e.jsxs("p",{className:"col-span-2 text-xs text-gray-500",children:["CI triggers run a cycle's ",e.jsx("b",{className:"text-gray-400",children:"mapped automation scripts"})," — cycles without any are disabled here (",D," of ",p.cycles.length," cycle",p.cycles.length!==1?"s":""," in this plan ",D===1?"has":"have"," automated scripts). Map scripts under Script Mapping to enable a cycle."]}),d&&(((De=p==null?void 0:p.cycles)==null?void 0:De.length)||0)>0&&D===0&&e.jsx("p",{className:"col-span-2 text-xs px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/25 text-amber-300",children:"⚠ None of this plan's cycles have mapped automation scripts — a CI trigger would fail. Pick a different plan or map automation scripts first (Script Mapping screen)."})]}),x==="command"&&e.jsx("textarea",{value:g,onChange:r=>v(r.target.value),rows:2,"aria-label":"Command",placeholder:"npx playwright test --grep @smoke",className:"w-full px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 font-mono placeholder-gray-600 focus:outline-none focus:border-brand-500/50 mb-4"}),e.jsxs("span",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:["Overrides ",e.jsxs("span",{className:"text-gray-600",children:["(optional — ",x==="command"?"the browser / environment entries from Settings → Run Commands":`defaults come from the ${x}'s saved settings`,")"]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs text-gray-500 mb-1",children:"Environment"}),e.jsx(Ge,{isEnv:!0,value:$,onChange:S,options:ee})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs text-gray-500 mb-1",children:"Browser"}),e.jsx(Ge,{isEnv:!1,value:O,onChange:h,options:Me})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-xs text-gray-500 mb-1",children:"Time limit (minutes)"}),e.jsx("input",{value:k,onChange:r=>B(r.target.value.replace(/[^0-9]/g,"")),inputMode:"numeric",placeholder:"240",className:`w-full px-3 py-2 rounded-xl bg-surface-2 border text-sm text-gray-200 placeholder-gray-600 focus:outline-none ${ze?"border-red-500/50":"border-white/10 focus:border-brand-500/50"}`})]})]}),e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-sm text-gray-300 mb-1",children:"Auto-Heal on this pipeline"}),e.jsx("div",{className:"inline-flex rounded-lg border border-white/10 bg-surface-2 overflow-hidden",role:"group","aria-label":"Auto-Heal on this pipeline",children:[["inherit","Inherit"],["off","Off"],["heal","Heal only"],["heal-regate","Heal + re-gate"]].map(([r,C],he)=>e.jsx("button",{type:"button",onClick:()=>A(r),className:`px-3 py-1.5 text-xs font-medium transition-colors ${he>0?"border-l border-white/10":""} ${R===r?"bg-purple-500/15 text-purple-600 dark:text-purple-300":"text-gray-500 hover:text-gray-300 hover:bg-white/5"}`,"aria-pressed":R===r,children:C},r))}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[e.jsx("b",{children:"Heal only"})," keeps the build result and heals in the workspace's mode (Suggest when the workspace is Off). ",e.jsx("b",{children:"Heal + re-gate"})," always keeps verified fixes (Auto) and holds the gate until healing finishes, so a fully-healed run turns the build green, labeled as auto-healed."," ",e.jsx("b",{children:"Inherit"})," follows Settings → General."]})]}),e.jsxs("label",{className:"flex items-start gap-2 text-sm text-gray-300 mb-2",children:[e.jsx("input",{type:"checkbox",checked:M,onChange:r=>L(r.target.checked),className:"accent-brand-500 mt-0.5"}),e.jsxs("span",{children:["Push commit statuses to the git host (PR decoration)",e.jsx("span",{className:"block text-xs text-gray-500",children:"Testver posts queued → running → success/failure statuses on the triggering commit, so PRs show the verdict — this is what enables the fire-and-forget CI job mode."})]})]}),M&&e.jsxs("div",{className:"ml-6 mb-3 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("select",{value:_,onChange:r=>ce(r.target.value),className:ie,"aria-label":"Git host",children:[e.jsx("option",{value:"github",children:"GitHub"}),e.jsx("option",{value:"gitlab",children:"GitLab"}),e.jsx("option",{value:"azure-devops",children:"Azure DevOps"}),e.jsx("option",{value:"bitbucket",children:"Bitbucket"})]}),e.jsx("input",{value:se,onChange:r=>I(r.target.value),placeholder:J[_],"aria-label":"Repository",className:"px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 font-mono placeholder-gray-600 focus:outline-none"})]}),e.jsx("input",{value:z,onChange:r=>ae(r.target.value),type:"password",autoComplete:"new-password","aria-label":"Access token",placeholder:le&&!Z?"Token saved — type to replace":"Access token",className:"w-full px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 placeholder-gray-600 focus:outline-none"}),Z&&e.jsx("p",{className:"text-xs text-amber-300",children:"The git host changed — enter the access token for it. The saved token is not sent to a different host."}),e.jsxs("p",{className:"text-xs text-gray-600 -mt-1",children:[ge[_],". Stored encrypted on this server, never returned to the browser."]}),e.jsx("input",{value:E,onChange:r=>T(r.target.value),"aria-label":"Self-hosted base URL",placeholder:"Self-hosted base URL (optional — GHE / self-managed GitLab / Azure Server)",className:"w-full px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 placeholder-gray-600 focus:outline-none"})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-300 mb-5",children:[e.jsx("input",{type:"checkbox",checked:re,onChange:r=>ne(r.target.checked),className:"accent-brand-500"}),"Enabled (triggers are rejected while disabled)"]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[!je&&e.jsxs("span",{className:"text-xs text-gray-500 mr-auto",children:["Still needed: ",q.join(", ")]}),e.jsx("button",{onClick:n,className:"px-4 py-2 rounded-xl text-sm text-gray-400 hover:text-gray-200",children:"Cancel"}),e.jsxs("button",{disabled:!je||U,onClick:async()=>{var r;W(!0),y(null);try{await Qe({id:s.id,name:o.trim(),target:{type:x,command:x==="command"?g.trim():void 0,suiteId:x==="suite"?b:void 0,cycleId:x==="cycle"?P||((r=s.target)==null?void 0:r.cycleId):void 0},overrides:$||O?{environment:$||void 0,browser:O||void 0}:void 0,autoHeal:R,timeoutMinutes:k.trim()?Number(k):void 0,statusPush:M?{enabled:!0,provider:_,repo:se.trim(),token:z.trim(),baseUrl:E.trim()||void 0}:void 0,enabled:re}),a()}catch(C){y((C==null?void 0:C.message)||String(C)),W(!1)}},className:"flex items-center gap-1.5 px-4 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-50",children:[U&&e.jsx(Y,{size:13,className:"animate-spin"}),s.id?"Save Changes":"Create Mapping"]})]})]})})}const Ve=[{id:"github-actions",label:"GitHub Actions",note:"Add TESTVER_CI_TOKEN as a repository secret (Settings → Secrets and variables → Actions). Pull requests report on their own commit."},{id:"gitlab-ci",label:"GitLab CI",note:"Add TESTVER_CI_TOKEN as a masked CI/CD variable. This file is the repo's .gitlab-ci.yml — saving replaces any existing pipeline. Merge requests are gated once (no duplicate branch pipeline)."},{id:"jenkins",label:"Jenkins",note:`Add a Secret Text credential with id "testver-ci-token", then set the job's Script Path to Jenkinsfile.testver-gate. The agent needs curl + jq.`,branchNote:"Jenkins decides which branches build in the job settings — the branch list is not used."},{id:"azure-pipelines",label:"Azure Pipelines",note:`Create a pipeline from azure-testver-gate.yml (Pipelines → New → Existing Azure Pipelines YAML file), then add TESTVER_CI_TOKEN as a secret variable ("Keep this value secret"). PR builds report on the PR's own commit.`},{id:"bitbucket",label:"Bitbucket",note:"Add TESTVER_CI_TOKEN as a SECURED repository variable (Repository settings → Repository variables). This is the repo's bitbucket-pipelines.yml — saving replaces any existing pipeline."},{id:"circleci",label:"CircleCI",note:"Add TESTVER_CI_TOKEN as a project environment variable (Project Settings → Environment Variables). This is the repo's .circleci/config.yml — saving replaces any existing config.",branchNote:'CircleCI filters by the pushed branch: listing branches means only those are gated — pull request branches too need "*" to be gated.'}];function Qt({mapping:s,hasToken:i,onOpenTokens:n,onClose:a}){var W;Be(a);const[o,w]=l.useState(window.location.origin),[x,N]=l.useState("github-actions"),[g,v]=l.useState(!1),[b,c]=l.useState("main"),[d,j]=l.useState(null),[P,F]=l.useState(".github/workflows/testver-gate.yml"),[$,S]=l.useState(!1),[O,h]=l.useState(!1),[R,A]=l.useState(!1),[k,B]=l.useState(!1),[M,L]=l.useState(!1),[_,ce]=l.useState(null),[se,I]=l.useState(null),z=l.useMemo(()=>at(o),[o]),ae=b.split(",").map(m=>m.trim()).filter(Boolean),E=Ve.find(m=>m.id===x),T=()=>{j(null),B(!1),I(null)},re=`npx -y testver trigger --server ${o} --mapping "${s.name}"`,ne=async(m,y)=>{await Xe(y)?(ce(m),setTimeout(()=>ce(J=>J===m?null:J),1500)):I("Copying isn't available here — select the text and copy it by hand.")},U=async m=>{if(d){A(!0),I(null);try{await St({filePath:P,content:d,overwrite:m}),B(!0)}catch(y){(y==null?void 0:y.status)===409?L(!0):I((y==null?void 0:y.message)||String(y))}finally{A(!1)}}};return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",children:[e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wire-modal-title",className:"w-full max-w-5xl rounded-2xl bg-surface-1 border border-white/10 p-6 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{id:"wire-modal-title",className:"text-base font-semibold text-gray-100",children:['Wire "',s.name,'" into CI']}),e.jsx("button",{onClick:a,"aria-label":"Close",className:"text-gray-500 hover:text-gray-300",children:e.jsx($e,{size:16})})]}),e.jsx(rt,{message:se,onDismiss:()=>I(null)}),!i&&e.jsxs("div",{className:"mb-4 px-3 py-2.5 rounded-xl bg-amber-500/10 border border-amber-500/25 text-sm text-amber-300 flex items-center gap-3",children:[e.jsx(Ae,{size:15,className:"flex-shrink-0"}),e.jsxs("span",{className:"flex-1",children:["There is no active CI token yet — the pipeline needs one in its secrets as ",e.jsx("code",{children:"TESTVER_CI_TOKEN"}),"."]}),e.jsx("button",{onClick:n,className:"px-2.5 py-1 rounded-lg border border-amber-500/30 hover:bg-amber-500/10 text-xs font-medium whitespace-nowrap",children:"Go to CI Tokens"})]}),e.jsxs("label",{htmlFor:"wire-server-url",className:"block text-sm font-medium text-gray-300 mb-1",children:["Testver server URL ",e.jsx("span",{className:"text-gray-600",children:"(must be reachable from CI runners)"})]}),e.jsx("input",{id:"wire-server-url",value:o,onChange:m=>{w(m.target.value.trim()),T()},className:`w-full px-3 py-2 rounded-xl bg-surface-2 border text-sm text-gray-200 focus:outline-none mb-1 ${z?"border-amber-500/40":"border-white/10 focus:border-brand-500/50"}`}),z?e.jsxs("p",{className:"text-xs text-amber-300 mb-4",children:["⚠ ",z]}):e.jsx("div",{className:"mb-4"}),e.jsxs("span",{className:"block text-sm font-medium text-gray-300 mb-1 flex items-center gap-1.5",children:[e.jsx(Ht,{size:13})," From any terminal / script (exit 0 passed · 1 failed · 2 no verdict)"]}),e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2.5 rounded-xl bg-surface-2 border border-white/10 mb-1",children:[e.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-all flex-1 m-0",children:re}),e.jsx("button",{onClick:()=>void ne("cli",re),"aria-label":"Copy the CLI command",className:"p-1.5 rounded-lg text-gray-400 hover:text-gray-200",children:_==="cli"?e.jsx(Ie,{size:14,className:"text-emerald-400"}):e.jsx(Oe,{size:14})})]}),e.jsxs("p",{className:"text-xs text-gray-600 mb-4",children:["Needs Node.js (npx fetches the ",e.jsx("code",{children:"testver"})," CLI). Auth: set ",e.jsx("code",{children:"TESTVER_CI_TOKEN"})," (or pass ",e.jsx("code",{children:"--token"}),")."," ","Add ",e.jsx("code",{children:"--sha <commit> --branch <name>"})," to record the commit on the run (Trace, PR status)."," ","Add ",e.jsx("code",{children:"--no-wait"})," to return right away and let the commit status carry the verdict."]}),e.jsxs("span",{className:"block text-sm font-medium text-gray-300 mb-1.5 flex items-center gap-1.5",children:[e.jsx(Ee,{size:14})," Pipeline config",e.jsx("span",{className:"font-normal text-gray-500",children:"— the CI job triggers Testver and gates on the verdict; nothing is installed on the runner"})]}),e.jsx("span",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-1.5",children:"Platform"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2 mb-4",children:Ve.map(m=>{const y=x===m.id;return e.jsxs("button",{onClick:()=>{N(m.id),T()},"aria-pressed":y,className:`relative flex items-center gap-2.5 px-3 py-2.5 rounded-xl border text-sm font-medium transition-colors text-left ${y?"bg-brand-500/10 border-brand-500 text-gray-900 dark:text-gray-100":"bg-surface-1 border-white/10 text-gray-600 dark:text-gray-300 hover:border-white/25 hover:bg-surface-2"}`,children:[e.jsx(Kt,{platform:m.id,size:18}),e.jsx("span",{className:"truncate",children:m.label}),y&&e.jsx(Ie,{size:14,className:"ml-auto text-brand-500 flex-shrink-0"})]},m.id)})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-1.5",children:"Gate mode"}),e.jsx("div",{className:"inline-flex p-1 rounded-xl bg-surface-2 border border-white/10",children:[{id:!1,label:"Wait & gate",hint:"exit code"},{id:!0,label:"Fire-and-forget",hint:"status push-back"}].map(m=>{const y=g===m.id;return e.jsxs("button",{onClick:()=>{v(m.id),T()},"aria-pressed":y,className:`px-3.5 py-2 rounded-lg text-sm font-medium transition-colors ${y?"bg-brand-600 text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"}`,children:[m.label,e.jsxs("span",{className:`ml-1.5 text-xs ${y?"text-white/70":"text-gray-500"}`,children:["(",m.hint,")"]})]},String(m.id))})})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-1.5",children:"Branches"}),e.jsx("input",{value:b,onChange:m=>{c(m.target.value),T()},placeholder:"main, release/* ( * = every branch)",className:"w-full px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 font-mono placeholder-gray-600 focus:outline-none focus:border-brand-500/50"}),e.jsx("span",{className:"block text-xs text-gray-500 mt-1",children:E.branchNote||"Pushes to these branches, and pull requests targeting them, run the gate. Comma-separated; * = every branch."})]})]}),g&&e.jsxs("p",{className:"text-xs mb-2 px-3 py-2 rounded-lg border bg-amber-500/10 border-amber-500/25 text-amber-300",children:["The job triggers and exits immediately — the PR verdict comes from the commit status Testver pushes.",(W=s.statusPush)!=null&&W.enabled?" Status push-back is configured on this mapping. ✓":' ⚠ Enable "Push commit statuses" on this mapping first, or the PR will never get a verdict.']}),e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-3",children:[e.jsxs("p",{className:"flex-1 text-sm text-gray-500 dark:text-gray-400 leading-relaxed px-3 py-2 rounded-lg bg-surface-2 border border-white/5",children:[e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:"Setup: "}),E.note]}),e.jsxs("button",{disabled:O||ae.length===0,onClick:async()=>{h(!0),B(!1),I(null);try{const m=await wt({platform:x,options:{branches:ae,delegate:{mapping:s.name,serverUrl:o,noWait:g}}});j(m.content),F(m.filePath),S(!!m.exists)}catch(m){I((m==null?void 0:m.message)||String(m))}finally{h(!1)}},className:"flex items-center gap-1.5 px-4 py-2.5 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-50 flex-shrink-0 transition-colors",children:[O?e.jsx(Y,{size:14,className:"animate-spin"}):e.jsx(Ee,{size:14}),d?"Regenerate":"Generate Config"]})]}),d&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"px-3 py-2.5 rounded-xl bg-surface-2 border border-white/10 text-xs text-gray-300 overflow-auto max-h-80 whitespace-pre",children:d}),e.jsx("button",{onClick:()=>void ne("yaml",d),"aria-label":"Copy the pipeline config",className:"absolute top-2 right-2 p-1.5 rounded-lg bg-surface-1 text-gray-400 hover:text-gray-200",children:_==="yaml"?e.jsx(Ie,{size:14,className:"text-emerald-400"}):e.jsx(Oe,{size:14})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 mt-3",children:[e.jsxs("span",{className:"text-xs text-gray-600",children:["Saves to ",e.jsx("code",{children:P})," in this project — commit & push it (token setup: see the note above).",$&&e.jsx("span",{className:"text-amber-300",children:" That file already exists — saving replaces it."})]}),e.jsxs("button",{disabled:R||k,onClick:()=>$?L(!0):void U(!1),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-sm font-medium bg-emerald-600 hover:bg-emerald-500 text-white disabled:opacity-60 flex-shrink-0",children:[R?e.jsx(Y,{size:13,className:"animate-spin"}):k?e.jsx(Ie,{size:13}):null,k?"Saved to project":"Save to project"]})]})]})]}),M&&e.jsx(Te,{open:!0,title:`Replace ${P}?`,description:"This file already exists in the project. Saving replaces its whole content with the Testver gate — anything else in it is lost (git still has the previous version).",confirmLabel:"Replace file",variant:"danger",onCancel:()=>L(!1),onConfirm:()=>{L(!1),U(!0)}})]})}function qe({title:s,rows:i,onSelect:n}){return e.jsxs("div",{className:"rounded-xl bg-surface-1 border border-white/5 overflow-hidden",children:[e.jsx("div",{className:"px-4 py-2.5 text-xs font-semibold text-gray-400 uppercase tracking-wide border-b border-white/5",children:s}),i.length===0?e.jsx("div",{className:"px-4 py-5 text-center text-xs text-gray-600",children:"No data yet"}):e.jsx("table",{className:"w-full text-sm",children:e.jsx("tbody",{children:i.slice(0,6).map(a=>e.jsxs("tr",{onClick:n?()=>n(a.key):void 0,className:`border-t border-white/5 first:border-t-0 ${n?"cursor-pointer hover:bg-white/[0.04] transition-colors":""}`,children:[e.jsx("td",{className:"px-4 py-2 text-gray-200 truncate max-w-[120px]",title:a.key,children:n?e.jsx("button",{onClick:o=>{o.stopPropagation(),n(a.key)},"aria-label":`Show runs for ${a.key}`,className:"text-left truncate max-w-full hover:text-brand-300 focus:outline-none focus-visible:underline",children:a.key}):a.key}),e.jsxs("td",{className:"px-2 py-2 text-gray-500 whitespace-nowrap",children:[a.runs," run",a.runs!==1?"s":""]}),e.jsxs("td",{className:`px-2 py-2 font-medium whitespace-nowrap ${st(a.passRate)}`,title:(a.errored||0)>0?`${a.errored} errored run(s) count against the pass rate`:void 0,children:[a.passRate,"%"]}),e.jsx("td",{className:"px-2 py-2 text-gray-500 whitespace-nowrap",children:pe(a.avgDurationMs)}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${a.lastState==="passed"?"bg-emerald-400":a.lastState==="failed"||a.lastState==="error"?"bg-red-400":a.lastState==="running"?"bg-sky-400 animate-pulse":a.lastState==="queued"?"border border-dashed border-gray-400 bg-transparent":"bg-gray-500"}`,title:`last: ${a.lastState} · ${V(a.lastAt)}`,"aria-label":`last run ${a.lastState}`})})]},a.key))})})]})}function Yt(){const[s,i]=Se("q"),[n,a]=l.useState(s||""),[o,w]=l.useState(null),[x,N]=l.useState(!1),[g,v]=l.useState(null),b=async(c=n)=>{const d=c.trim();if(d.length<2){v("Enter at least 2 characters — a commit sha (6 or more) or a branch name");return}N(!0),v(null),d!==s&&i(d);try{w(await Ct(d))}catch(j){v((j==null?void 0:j.message)||String(j)),w(null)}finally{N(!1)}};return l.useEffect(()=>{s&&!o&&b(s)},[]),e.jsxs("section",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2 mb-1",children:[e.jsx(Fe,{size:17,className:"text-amber-300"})," Trace a Deploy"]}),e.jsx("p",{className:"text-sm text-gray-400 mb-3",children:"Paste a commit sha (6 or more characters) or a branch name from a deploy to see every run that gated it — the CI verdicts plus any manual verification runs on the same commit."}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("input",{value:n,onChange:c=>a(c.target.value),onKeyDown:c=>{c.key==="Enter"&&b()},placeholder:"e.g. 2f812c2 or release/2.4","aria-label":"Commit sha or branch",className:"px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 font-mono placeholder-gray-600 focus:outline-none focus:border-brand-500/50 w-80"}),e.jsxs("button",{onClick:()=>void b(),disabled:x,className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:[x?e.jsx(Y,{size:14,className:"animate-spin"}):e.jsx(Fe,{size:14})," Trace"]})]}),g&&e.jsx("div",{role:"alert",className:"px-3 py-2 rounded-lg bg-red-500/10 border border-red-500/30 text-xs text-red-300 mb-3",children:g}),o&&e.jsxs("div",{className:"space-y-1.5",children:[o.ciRuns.length===0&&o.otherRuns.length===0&&e.jsxs("div",{className:"px-4 py-4 rounded-xl border border-dashed border-white/10 text-sm text-gray-500 text-center",children:["No runs found for ",e.jsx("code",{children:o.query}),".",o.hint?` ${o.hint}.`:""]}),o.ciRuns.map(c=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 rounded-xl bg-surface-1 border border-white/5 text-sm",children:[e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full border flex-shrink-0 ${Pe[c.state]}`,children:c.state}),e.jsx("span",{className:"text-gray-200 font-medium",children:c.mappingName}),c.buildNumber&&e.jsxs("span",{className:"text-gray-500 text-xs",children:["#",c.buildNumber]}),e.jsxs("span",{className:"text-sm text-gray-400",children:[c.branch,c.sha?` · ${c.sha.slice(0,7)}`:""]}),c.summary&&e.jsxs("span",{className:"text-sm text-gray-300",children:[e.jsx("span",{className:"text-emerald-400",children:c.summary.passed}),"/",c.summary.total," passed"]}),c.error&&e.jsx("span",{className:"text-xs text-red-300 truncate max-w-[280px]",title:c.error,children:c.error}),e.jsxs("span",{className:"text-sm text-gray-500 ml-auto",children:[V(c.createdAt)," · ",pe(c.durationMs)]}),c.buildUrl&&e.jsx("a",{href:c.buildUrl,target:"_blank",rel:"noopener noreferrer",title:"CI build","aria-label":"Open the CI build",className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5",children:e.jsx(Je,{size:13})}),c.runId&&e.jsx("a",{href:`/results?runId=${encodeURIComponent(c.runId)}`,target:"_blank",rel:"noopener noreferrer",title:"Testver report","aria-label":"Open the Testver report",className:"p-1.5 rounded-lg text-brand-400 hover:text-brand-300 hover:bg-white/5",children:e.jsx(ue,{size:13})})]},c.id)),o.otherRuns.map(c=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 rounded-xl bg-surface-1 border border-white/5 text-sm opacity-90",children:[e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full border bg-white/5 border-white/10 text-gray-400 flex-shrink-0",children:c.origin||"run"}),e.jsx("span",{className:"text-xs text-gray-400 flex-shrink-0",children:c.status}),e.jsx("span",{className:"text-gray-200",children:c.label||c.runId}),e.jsxs("span",{className:"text-sm text-gray-400",children:[c.gitBranch,c.gitCommitSha?` · ${c.gitCommitSha.slice(0,7)}`:""]}),c.summary&&e.jsxs("span",{className:"text-sm text-gray-300",children:[e.jsx("span",{className:"text-emerald-400",children:c.summary.passed}),"/",c.summary.total," passed"]}),e.jsxs("span",{className:"text-sm text-gray-500 ml-auto",children:[V(c.startTime)," · ",pe(c.duration)]}),e.jsx("a",{href:`/results?runId=${encodeURIComponent(c.runId)}`,target:"_blank",rel:"noopener noreferrer",title:"Testver report","aria-label":"Open the Testver report",className:"p-1.5 rounded-lg text-brand-400 hover:text-brand-300 hover:bg-white/5",children:e.jsx(ue,{size:13})})]},c.runId)),o.searched&&e.jsxs("p",{className:"text-xs text-gray-600 pt-1",children:["Searched the latest ",o.searched.ciRuns," CI runs and ",o.searched.otherRuns," other runs."]})]})]})}function We({runs:s,emptyNote:i,onCancel:n}){return e.jsx("div",{className:"rounded-xl border border-white/5 overflow-hidden bg-surface-1",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs text-gray-500 uppercase tracking-wide border-b border-white/5",children:[e.jsx("th",{className:"px-4 py-2.5",children:"State"}),e.jsx("th",{className:"px-4 py-2.5",children:"Pipeline"}),e.jsx("th",{className:"px-4 py-2.5",children:"Branch / Commit"}),e.jsx("th",{className:"px-4 py-2.5",children:"Result"}),e.jsx("th",{className:"px-4 py-2.5",children:"Duration"}),e.jsx("th",{className:"px-4 py-2.5",children:"Triggered"}),e.jsx("th",{className:"px-4 py-2.5 text-right",children:"Links"})]})}),e.jsxs("tbody",{children:[s.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-6 text-center text-sm text-gray-500",children:i||"No runs."})}),s.map(a=>e.jsxs("tr",{className:"border-t border-white/5 align-top",children:[e.jsx("td",{className:"px-4 py-2.5",children:a.state==="running"?e.jsx(ot,{size:"sm"}):a.state==="queued"?e.jsx(ct,{size:"sm",position:a.queuePosition||void 0}):e.jsx("span",{className:`inline-flex items-center gap-1.5 text-xs px-2 py-0.5 rounded-full border capitalize ${Pe[a.state]}`,children:a.state})}),e.jsxs("td",{className:"px-4 py-2.5 text-gray-200",children:[a.mappingName||"—",a.buildNumber&&e.jsxs("span",{className:"text-gray-500 ml-1.5",children:["#",a.buildNumber]})]}),e.jsxs("td",{className:"px-4 py-2.5 text-gray-300 text-sm",children:[a.branch||"—",a.sha&&e.jsx("code",{className:"ml-1.5 text-gray-500",children:a.sha.slice(0,7)})]}),e.jsxs("td",{className:"px-4 py-2.5 text-sm text-gray-300 max-w-[320px]",children:[a.summary&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-emerald-400",children:a.summary.passed})," / ",a.summary.total," passed",a.summary.failed>0&&e.jsxs("span",{className:"text-red-400 ml-1",children:["(",a.summary.failed," failed)"]})]}),a.error&&e.jsx("span",{className:"block text-xs text-red-300 mt-0.5 line-clamp-2",title:a.error,children:a.error}),!a.summary&&!a.error&&"—",a.pushWarning&&e.jsxs("span",{className:"block text-xs text-amber-400/80 mt-0.5 line-clamp-2",title:a.pushWarning,children:["PR status not posted: ",a.pushWarning]}),a.autoHeal&&e.jsxs("span",{className:"block text-[11px] mt-0.5 space-x-2",children:[a.autoHeal.healed>0&&e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-300",title:"Locator repaired, verified by re-run, and kept — the summary above counts the original failure",children:["✦ ",a.autoHeal.healed," healed & verified"]}),a.autoHeal.suggested>0&&e.jsxs("span",{className:"text-purple-600 dark:text-purple-300",title:"A verified fix is waiting — open the run in Results and click Apply fix",children:[a.autoHeal.suggested," fix",a.autoHeal.suggested>1?"es":""," ready"]}),a.autoHeal.reverted>0&&e.jsxs("span",{className:"text-amber-600 dark:text-amber-300",title:"A repair was tried but failed verification — files were restored",children:[a.autoHeal.reverted," reverted"]})]})]}),e.jsx("td",{className:"px-4 py-2.5 text-sm text-gray-400",title:"Time on the Testver server (queue wait not included)",children:pe(a.durationMs)}),e.jsxs("td",{className:"px-4 py-2.5 text-sm text-gray-400",children:[V(a.createdAt)," by ",a.triggeredBy]}),e.jsxs("td",{className:"px-4 py-2.5 text-right whitespace-nowrap",children:[n&&(a.state==="queued"||a.state==="running")&&e.jsx("button",{onClick:()=>n(a),title:"Cancel this run","aria-label":`Cancel the ${a.mappingName||"CI"} run`,className:"inline-flex p-1.5 rounded-lg text-red-400 hover:text-red-500 hover:bg-red-500/10",children:e.jsx(Lt,{size:13})}),a.buildUrl&&e.jsx("a",{href:a.buildUrl,target:"_blank",rel:"noopener noreferrer",title:"Open CI build","aria-label":"Open the CI build",className:"inline-flex p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5",children:e.jsx(Je,{size:13})}),a.runId&&e.jsx("a",{href:`/results?runId=${encodeURIComponent(a.runId)}`,target:"_blank",rel:"noopener noreferrer",title:"Open Testver report","aria-label":"Open the Testver report",className:"inline-flex p-1.5 rounded-lg text-brand-400 hover:text-brand-300 hover:bg-white/5",children:e.jsx(ue,{size:13})})]})]},a.id))]})]})})}export{ls as PipelinesPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as z,j as e}from"./vendor-react-DOVfxdUy.js";import{u as Ue}from"./useTabParam-CyYAP90W.js";import{b as Ae,D as Pe}from"./index-D6sQYc_0.js";import{C as Ee}from"./ConfirmDialog-DtotgVmI.js";import{aa as Fe,ab as Ie,ac as Be,F as Oe,ad as He,ae as qe,af as Ve,ag as Ge}from"./useTestManagement-DW6AW2mt.js";import{u as Ye}from"./vendor-query-DkZSMtfn.js";import{f as D}from"./formatTestName-BKd2Uqhs.js";import{cv as q,b as De,f as I,a0 as F,T as Z,cf as J,aC as Je,cm as Ke,r as H,o as me,ap as pe,I as Qe,al as Xe,aI as he,Z as Ze,R as ge,v as ue,X as be,bO as We,y as fe,ag as X,_ as es,dj as oe,t as ss,aJ as ts,b1 as as}from"./vendor-icons-D_Dmmj8d.js";const rs={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"},ns={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"},xe={playwright:"bg-green-500/20 text-green-300",jest:"bg-red-500/20 text-red-300",cypress:"bg-teal-500/20 text-teal-300",mocha:"bg-amber-500/20 text-amber-300",vitest:"bg-yellow-500/20 text-yellow-300",cucumber:"bg-emerald-500/20 text-emerald-300",pytest:"bg-blue-500/20 text-blue-300",junit:"bg-orange-500/20 text-orange-300",testng:"bg-violet-500/20 text-violet-300",nunit:"bg-purple-500/20 text-purple-300",xunit:"bg-indigo-500/20 text-indigo-300",mstest:"bg-sky-500/20 text-sky-300",rspec:"bg-rose-500/20 text-rose-300",robot:"bg-cyan-500/20 text-cyan-300",unknown:"bg-gray-500/20 text-gray-300"},Y={synced:"bg-emerald-500",script_updated:"bg-amber-500",script_missing:"bg-red-500",case_updated:"bg-blue-500"};function is(t){if(!t)return"Never";const i=Date.now()-t,o=Math.floor(i/6e4);if(o<1)return"Just now";if(o<60)return`${o}m ago`;const j=Math.floor(o/60);return j<24?`${j}h ago`:`${Math.floor(j/24)}d ago`}function ye(t){return t.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())}function je(t,i=40){if(t.length<=i)return t;const o=t.split("/");return o.length<=2?"..."+t.slice(-i):o[0]+"/.../"+o.slice(-2).join("/")}const ee=t=>{var i;return((i=t==null?void 0:t.mapping)==null?void 0:i.syncStatus)||(t==null?void 0:t.syncStatus)||"synced"};function ls({status:t}){const i={synced:{icon:H,label:"Synced",color:"text-emerald-400 bg-emerald-500/15"},script_updated:{icon:me,label:"Script Updated",color:"text-amber-400 bg-amber-500/15"},script_missing:{icon:pe,label:"Script Missing",color:"text-red-400 bg-red-500/15"},case_updated:{icon:q,label:"Case Updated",color:"text-blue-400 bg-blue-500/15"},not_mapped:{icon:as,label:"Not Mapped",color:"text-gray-400 bg-gray-500/15"}},o=i[t]||i.not_mapped,j=o.icon;return e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${o.color}`,children:[e.jsx(j,{size:12}),o.label]})}function se({priority:t}){const i=rs[t]||"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 ${i}`,children:ye(t)})}function cs({type:t}){const i=ns[t]||"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 ${i}`,children:ye(t)})}function W({framework:t}){const i=xe[t]||xe.unknown;return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${i}`,children:t})}function js(){var le;const[t,i]=Ue("tab",["dashboard","mapped","map"],"dashboard"),[o,j]=z.useState(""),[b,S]=z.useState(""),[u,C]=z.useState(""),[M,R]=z.useState(null),[T,N]=z.useState(new Set),[E,$]=z.useState(new Set),{toast:A}=Ae(),[m,n]=z.useState(null),{data:w,isLoading:v}=Fe(),{data:p,isLoading:c}=Ie(),{data:g,isLoading:s}=Be(),{data:r}=Oe(),{data:l,isLoading:f}=Ye({queryKey:["test-explorer"],queryFn:Pe}),y=He(),h=qe(),_=Ve(),L=Ge(),k=w||{},P=Array.isArray(p)?p:(p==null?void 0:p.testCases)||(p==null?void 0:p.mappings)||[],B=Array.isArray(g)?g:(g==null?void 0:g.testCases)||[],V=k.totalTestCases??((le=r==null?void 0:r.testCases)==null?void 0:le.length)??(r==null?void 0:r.length)??0,K=k.syncedCount??0,te=k.scriptUpdatedCount??0,ae=k.scriptMissingCount??0,re=k.caseUpdatedCount??0,G=k.mappedCount??P.length??0,Ne=k.unmappedCount??Math.max(0,V-G),ne=k.totalMappings??K+te+ae+re,ve=k.syncHealthPercentage??(ne>0?Math.round(K/ne*100):0),we=k.mappingPercentage??(V>0?Math.round(G/V*100):0),Q=z.useMemo(()=>{let a=[...P];if(o){const d=o.toLowerCase();a=a.filter(x=>{var O,ce,de;return(x.title||((O=x.testCase)==null?void 0:O.title)||"").toLowerCase().includes(d)||(x.scriptPath||((ce=x.mapping)==null?void 0:ce.scriptPath)||"").toLowerCase().includes(d)||(x.testName||((de=x.mapping)==null?void 0:de.testName)||"").toLowerCase().includes(d)})}return u&&(a=a.filter(d=>ee(d)===u)),a},[P,o,u]),ke=z.useMemo(()=>{if(!b)return B;const a=b.toLowerCase();return B.filter(d=>(d.title||"").toLowerCase().includes(a)||(d.id||"").toLowerCase().includes(a))},[B,b]);function U(a){A("success",a)}function Se(a){$(d=>{const x=new Set(d);return x.has(a)?x.delete(a):x.add(a),x})}function Ce(a){N(d=>{const x=new Set(d);return x.has(a)?x.delete(a):x.add(a),x})}function Me(){T.size===Q.length?N(new Set):N(new Set(Q.map(a=>a.testCaseId||a.id)))}function ie(a){a.length>0&&n(a)}async function Te(a){n(null);try{await h.mutateAsync(a),N(new Set),U(`Unlinked ${a.length} mapping(s)`)}catch(d){A("error",d.message||"Failed to unlink")}}async function $e(a){const d=a.testCaseId||a.id;try{await L.mutateAsync({testCaseId:d,syncStatus:"synced"}),U("Marked as synced")}catch(x){U(`Error: ${x.message||"Failed to sync"}`)}}async function Le(a,d,x){try{await y.mutateAsync([{testCaseId:a,scriptPath:d.file,testName:x.name,suite:x.suite||d.name,framework:x.framework||d.framework}]),R(null),U(`Mapped successfully to "${x.name}"`)}catch(O){U(`Error: ${O.message||"Failed to map"}`)}}async function ze(){try{await _.mutateAsync(),U("Sync check completed")}catch(a){U(`Error: ${a.message||"Sync check failed"}`)}}async function _e(){const a=Array.from(T);try{for(const d of a)await L.mutateAsync({testCaseId:d,syncStatus:"synced"});N(new Set),U(`Marked ${a.length} as synced`)}catch(d){U(`Error: ${d.message||"Failed to mark synced"}`)}}const Re=[{id:"dashboard",label:"Dashboard",icon:De},{id:"mapped",label:"Mapped Test Cases",icon:I},{id:"map",label:"Map Test Cases",icon:q}];return e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[m&&e.jsx(Ee,{open:!0,title:"Remove mapping?",description:`Remove the script mapping for ${m.length} test case${m.length===1?"":"s"}? This unlinks the script — it doesn't delete the test case or the script.`,confirmLabel:"Remove",onConfirm:()=>Te(m),onCancel:()=>n(null)}),e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(q,{size:24,className:"text-brand-300"}),"Script Mapping & Sync"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Link test cases to automation scripts and monitor sync health"})]})}),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:Re.map(a=>{const d=a.icon,x=t===a.id;return e.jsxs("button",{onClick:()=>i(a.id),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors ${x?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200 hover:border-white/10"}`,children:[e.jsx(d,{size:14}),a.label]},a.id)})})}),e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-8",children:[t==="dashboard"&&e.jsx(ds,{totalTestCases:V,totalMapped:G,totalUnmapped:Ne,mappingPercentage:we,syncHealth:ve,syncedCount:K,scriptUpdatedCount:te,scriptMissingCount:ae,caseUpdatedCount:re,isLoading:v,onCheckSync:ze,checkSyncPending:_.isPending,onGoToMap:()=>i("mapped"),onGoToUnmapped:()=>i("map"),mappedItems:P}),t==="mapped"&&e.jsx(os,{items:Q,isLoading:c,searchMapped:o,setSearchMapped:j,syncStatusFilter:u,setSyncStatusFilter:C,selectedMappedIds:T,toggleMappedSelection:Ce,selectAllMapped:Me,totalMapped:G,onUnlink:a=>ie([a.testCaseId||a.id]),onResync:$e,onBulkUnlink:()=>ie(Array.from(T)),onBulkMarkSynced:_e,onViewScript:(a,d)=>{const x=a.replace(/\\/g,"/"),O=`/tests?file=${encodeURIComponent(x)}&test=${encodeURIComponent(d)}`;window.open(O,"_blank","noopener")}}),t==="map"&&e.jsx(xs,{unmapped:ke,unmappedLoading:s,searchUnmapped:b,setSearchUnmapped:S,selectedTestCaseId:M,setSelectedTestCaseId:R,explorerData:l,explorerLoading:f,expandedSuites:E,toggleSuiteExpand:Se,onMap:Le,mappingPending:y.isPending,mappedScripts:P})]})]})}function ds({totalTestCases:t,totalMapped:i,totalUnmapped:o,mappingPercentage:j,syncHealth:b,syncedCount:S,scriptUpdatedCount:u,scriptMissingCount:C,caseUpdatedCount:M,isLoading:R,onCheckSync:T,checkSyncPending:N,onGoToMap:E,onGoToUnmapped:$,mappedItems:A}){const[m,n]=z.useState(null),w=j??(t>0?Math.round(i/t*100):0),v=S+u+C+M,p={synced:[],script_updated:[],script_missing:[],case_updated:[]};for(const c of A){const g=ee(c);p[g]&&p[g].push(c)}return R?e.jsxs("div",{className:"flex items-center justify-center py-20",children:[e.jsx(F,{className:"w-6 h-6 text-brand-400 animate-spin"}),e.jsx("span",{className:"ml-2 text-gray-400",children:"Loading dashboard..."})]}):e.jsxs("div",{className:"space-y-6 max-w-6xl",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/15 flex items-center justify-center",children:e.jsx(Z,{className:"w-5 h-5 text-blue-400"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-gray-100",children:t}),e.jsx("div",{className:"text-xs text-gray-400",children:"Total Test Cases"})]})]})}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-emerald-500/15 flex items-center justify-center",children:e.jsx(I,{className:"w-5 h-5 text-emerald-400"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-2xl font-bold text-gray-100",children:[i,e.jsxs("span",{className:"text-sm font-normal text-emerald-400 ml-1.5",children:[w,"%"]})]}),e.jsx("div",{className:"text-xs text-gray-400",children:"Mapped"})]})]})}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-amber-500/15 flex items-center justify-center",children:e.jsx(J,{className:"w-5 h-5 text-amber-400"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-gray-100",children:o}),e.jsx("div",{className:"text-xs text-gray-400",children:"Unmapped"})]})]})}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-cyan-500/15 flex items-center justify-center",children:e.jsx(Je,{className:"w-5 h-5 text-cyan-400"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-2xl font-bold text-gray-100",children:[b,e.jsx("span",{className:"text-sm font-normal text-cyan-400 ml-0.5",children:"%"})]}),e.jsx("div",{className:"text-xs text-gray-400",children:"Sync Health"})]})]})})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("h3",{className:"text-sm font-medium text-gray-200 mb-4 flex items-center gap-2",children:[e.jsx(Ke,{className:"w-4 h-4 text-brand-400"}),"Sync Status Breakdown"]}),v>0?e.jsxs("div",{className:"w-full h-3 rounded-full bg-surface-2 overflow-hidden flex mb-4",children:[S>0&&e.jsx("div",{className:`${Y.synced} h-full transition-all`,style:{width:`${S/v*100}%`},title:`Synced: ${S}`}),u>0&&e.jsx("div",{className:`${Y.script_updated} h-full transition-all`,style:{width:`${u/v*100}%`},title:`Script Updated: ${u}`}),C>0&&e.jsx("div",{className:`${Y.script_missing} h-full transition-all`,style:{width:`${C/v*100}%`},title:`Script Missing: ${C}`}),M>0&&e.jsx("div",{className:`${Y.case_updated} h-full transition-all`,style:{width:`${M/v*100}%`},title:`Case Updated: ${M}`})]}):e.jsx("div",{className:"w-full h-3 rounded-full bg-surface-2 mb-4"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{key:"synced",label:"Synced",count:S,icon:H,color:"text-emerald-400",desc:"Test case and script file are in sync. No action needed."},{key:"script_updated",label:"Script Updated",count:u,icon:me,color:"text-amber-400",desc:"The automation script file was modified on disk after mapping. Review the test case to ensure it still matches the script."},{key:"script_missing",label:"Script Missing",count:C,icon:pe,color:"text-red-400",desc:"The mapped script file was deleted or moved. Re-map the test case to a valid script file."},{key:"case_updated",label:"Case Updated",count:M,icon:q,color:"text-blue-400",desc:"The test case was edited after mapping. The automation script may need to be updated to reflect the changes."}].map(c=>{const g=c.icon,s=m===c.key;return e.jsx("div",{className:"relative group/card",children:e.jsxs("button",{onClick:()=>n(s?null:c.key),className:`w-full bg-surface-2 rounded-lg border p-3 flex items-center gap-2 text-left transition-colors ${s?"border-brand-500/40 ring-1 ring-brand-500/20":"border-white/5 hover:border-white/10"}`,children:[e.jsx(g,{size:16,className:`${c.color} shrink-0`}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-lg font-semibold text-gray-100",children:c.count}),e.jsx("div",{className:"text-xs text-gray-400",children:c.label})]}),e.jsxs("span",{className:"relative group/info shrink-0",children:[e.jsx(Qe,{size:12,className:"text-gray-600 hover:text-gray-300 transition-colors cursor-help"}),e.jsxs("span",{className:"absolute z-20 bottom-full right-0 mb-2 w-56 px-3 py-2.5 rounded-lg bg-gray-900 border border-white/10 shadow-xl text-[11px] text-gray-300 leading-relaxed opacity-0 invisible group-hover/info:opacity-100 group-hover/info:visible transition-all pointer-events-none",children:[e.jsxs("span",{className:"font-medium text-gray-100 mb-1 flex items-center gap-1.5",children:[e.jsx(g,{size:11,className:c.color})," ",c.label]}),c.desc,e.jsx("span",{className:"absolute top-full right-4 -mt-px w-2 h-2 bg-gray-900 border-r border-b border-white/10 rotate-45"})]})]})]})},c.key)})}),m&&p[m]&&e.jsxs("div",{className:"mt-4 bg-surface-2 rounded-lg border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2.5 border-b border-white/5 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider",children:m==="synced"?"Synced Mappings":m==="script_updated"?"Scripts Changed on Disk":m==="script_missing"?"Missing Script Files":"Test Cases Updated After Mapping"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[p[m].length," item",p[m].length!==1?"s":""]})]}),p[m].length===0?e.jsx("div",{className:"px-4 py-6 text-center text-sm text-gray-500",children:"No items in this category"}):e.jsx("div",{className:"divide-y divide-white/5 max-h-[300px] overflow-y-auto",children:p[m].map((c,g)=>{const s=c,r=c.mapping||{},l=r.scriptPath||c.scriptPath||"",f=r.testName||c.testName||"",y=s.title||s.name||"Untitled",h=r.lastSynced||r.last_synced;return e.jsx("div",{className:"px-4 py-3 hover:bg-white/[0.02] transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Z,{size:12,className:"text-brand-400 shrink-0"}),e.jsx("span",{className:"text-sm text-gray-200 font-medium truncate",children:y}),s.priority&&e.jsx(se,{priority:s.priority})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-5",children:[e.jsx(Xe,{size:10,className:"text-gray-600 shrink-0"}),e.jsx(he,{size:11,className:"text-gray-500 shrink-0"}),e.jsx("span",{className:"text-xs font-mono text-gray-400 truncate",children:l||"No script path"}),f&&e.jsx("span",{className:"text-[10px] text-gray-500 bg-surface-1 px-1.5 py-0.5 rounded shrink-0",title:f,children:D(f)})]})]}),e.jsxs("div",{className:"text-right shrink-0",children:[m==="case_updated"&&e.jsx("span",{className:"text-[10px] text-blue-400",children:"Test case was modified after last sync"}),m==="script_updated"&&e.jsx("span",{className:"text-[10px] text-amber-400",children:"Script file changed on disk"}),m==="script_missing"&&e.jsxs("span",{className:"text-[10px] text-red-400",children:["File not found: ",l.split("/").pop()]}),h&&e.jsxs("div",{className:"text-[10px] text-gray-500 mt-0.5",children:["Last synced: ",new Date(h).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})]})]})]})},c.id||g)})})]})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("h3",{className:"text-sm font-medium text-gray-200 mb-3 flex items-center gap-2",children:[e.jsx(Ze,{className:"w-4 h-4 text-brand-400"}),"Quick Actions"]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("button",{onClick:T,disabled:N,className:"inline-flex items-center gap-2 bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm font-medium transition-colors disabled:opacity-50",children:[N?e.jsx(F,{size:16,className:"animate-spin"}):e.jsx(ge,{size:16}),"Check Sync Status"]}),e.jsxs("button",{onClick:E,className:"inline-flex items-center gap-2 bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-4 py-2 text-sm font-medium transition-colors border border-white/5",children:[e.jsx(I,{size:16}),"View Mapped Test Cases"]}),e.jsxs("button",{onClick:$,className:"inline-flex items-center gap-2 bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-4 py-2 text-sm font-medium transition-colors border border-white/5",children:[e.jsx(J,{size:16}),"View Unmapped Test Cases"]})]})]})]})}function os({items:t,isLoading:i,searchMapped:o,setSearchMapped:j,syncStatusFilter:b,setSyncStatusFilter:S,selectedMappedIds:u,toggleMappedSelection:C,selectAllMapped:M,totalMapped:R,onUnlink:T,onResync:N,onBulkUnlink:E,onBulkMarkSynced:$,onViewScript:A}){const m=t.length>0&&u.size===t.length;return e.jsxs("div",{className:"space-y-4 max-w-full",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{className:"w-4 h-4 text-emerald-400"}),e.jsxs("span",{className:"text-sm font-medium text-gray-200",children:[R," mapped test case",R!==1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ue,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",value:o,onChange:n=>j(n.target.value),placeholder:"Search mapped cases...",className:"bg-surface-2 border border-white/10 rounded-lg pl-8 pr-3 py-1.5 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50 w-56"}),o&&e.jsx("button",{onClick:()=>j(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-200",children:e.jsx(be,{size:12})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(We,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{value:b,onChange:n=>S(n.target.value),className:"appearance-none bg-surface-2 border border-white/10 rounded-lg pl-8 pr-8 py-1.5 text-sm text-gray-200 focus:outline-none focus:border-brand-500/50 cursor-pointer",children:[e.jsx("option",{value:"",children:"All Statuses"}),e.jsx("option",{value:"synced",children:"Synced"}),e.jsx("option",{value:"script_updated",children:"Script Updated"}),e.jsx("option",{value:"script_missing",children:"Script Missing"}),e.jsx("option",{value:"case_updated",children:"Case Updated"})]}),e.jsx(fe,{size:14,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"})]})]})]}),u.size>0&&e.jsxs("div",{className:"bg-brand-500/10 border border-brand-500/20 rounded-lg px-4 py-2.5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm text-brand-300 font-medium",children:[u.size," selected"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:E,className:"inline-flex items-center gap-1.5 bg-red-500/15 hover:bg-red-500/25 text-red-300 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors",children:[e.jsx(J,{size:12}),"Unlink Selected"]}),e.jsxs("button",{onClick:$,className:"inline-flex items-center gap-1.5 bg-emerald-500/15 hover:bg-emerald-500/25 text-emerald-300 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors",children:[e.jsx(X,{size:12}),"Mark Synced"]})]})]}),i?e.jsxs("div",{className:"flex items-center justify-center py-16",children:[e.jsx(F,{className:"w-5 h-5 text-brand-400 animate-spin"}),e.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"Loading mapped cases..."})]}):t.length===0?e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-12 text-center",children:[e.jsx(I,{className:"w-8 h-8 text-gray-500 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-400",children:o||b?"No mapped test cases match your filters.":'No mapped test cases yet. Go to "Map Test Cases" to create mappings.'})]}):e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-gray-400 text-xs uppercase tracking-wider",children:[e.jsx("th",{className:"px-3 py-3 text-left w-10",children:e.jsx("button",{onClick:M,className:"w-4 h-4 rounded border border-white/20 flex items-center justify-center hover:border-brand-400 transition-colors",children:m&&e.jsx(X,{size:10,className:"text-brand-400"})})}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Test Case"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Priority"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Script Path"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Test Name"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Framework"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Sync Status"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Last Synced"}),e.jsx("th",{className:"px-3 py-3 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:t.map(n=>{var y,h,_,L,k,P;const w=n.testCaseId||n.id,v=u.has(w),p=n.title||((y=n.testCase)==null?void 0:y.title)||"Untitled",c=n.priority||((h=n.testCase)==null?void 0:h.priority)||"medium",g=n.scriptPath||((_=n.mapping)==null?void 0:_.scriptPath)||"",s=n.testName||((L=n.mapping)==null?void 0:L.testName)||"",r=n.framework||((k=n.mapping)==null?void 0:k.framework)||"",l=ee(n),f=n.lastSynced||((P=n.mapping)==null?void 0:P.lastSynced)||null;return e.jsxs("tr",{className:`hover:bg-surface-2/50 transition-colors ${v?"bg-brand-500/5":""}`,children:[e.jsx("td",{className:"px-3 py-3",children:e.jsx("button",{onClick:()=>C(w),className:`w-4 h-4 rounded border flex items-center justify-center transition-colors ${v?"bg-brand-600 border-brand-500":"border-white/20 hover:border-brand-400"}`,children:v&&e.jsx(X,{size:10,className:"text-white"})})}),e.jsx("td",{className:"px-3 py-3 align-top",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-xs font-mono text-brand-300 shrink-0 mt-0.5",children:w}),e.jsx("span",{className:"text-gray-200 font-medium break-words",children:p})]})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(se,{priority:c})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("span",{className:"text-gray-300 text-xs font-mono cursor-help",title:g,children:je(g)})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("span",{className:"text-gray-300 text-xs",title:s,children:D(s)})}),e.jsx("td",{className:"px-3 py-3",children:r&&e.jsx(W,{framework:r})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(ls,{status:l})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("span",{className:"text-gray-400 text-xs",children:is(f)})}),e.jsx("td",{className:"px-3 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{onClick:()=>N(n),className:"p-1.5 rounded-md hover:bg-surface-2 text-gray-400 hover:text-blue-400 transition-colors",title:"Re-sync",children:e.jsx(ge,{size:14})}),e.jsx("button",{onClick:()=>T(n),className:"p-1.5 rounded-md hover:bg-surface-2 text-gray-400 hover:text-red-400 transition-colors",title:"Unlink",children:e.jsx(J,{size:14})}),g&&e.jsx("button",{onClick:()=>{var B;return A(g,((B=n.mapping)==null?void 0:B.testName)||n.testName||"")},className:"p-1.5 rounded-md hover:bg-surface-2 text-gray-400 hover:text-brand-400 transition-colors",title:"View Script (new tab)",children:e.jsx(es,{size:14})})]})})]},w)})})]})})})]})}function xs({unmapped:t,unmappedLoading:i,searchUnmapped:o,setSearchUnmapped:j,selectedTestCaseId:b,setSelectedTestCaseId:S,explorerData:u,explorerLoading:C,expandedSuites:M,toggleSuiteExpand:R,onMap:T,mappingPending:N,mappedScripts:E}){const[$,A]=z.useState(!1),m=new Set,n=new Set,w=new Map;E.forEach(s=>{var f,y;const r=((f=s.mapping)==null?void 0:f.scriptPath)||s.scriptPath||"",l=((y=s.mapping)==null?void 0:y.testName)||s.testName||"";r&&(m.add(`${r}::${l}`.toLowerCase()),n.add(r.toLowerCase()),w.has(r.toLowerCase())||w.set(r.toLowerCase(),new Set),w.get(r.toLowerCase()).add(l.toLowerCase()))});const v=(u==null?void 0:u.suites)||[],p=(s,r)=>{if(m.has(`${s}::${r}`.toLowerCase()))return!0;const l=w.get(s.toLowerCase());if(!l)return!1;const f=v.find(h=>{var _;return((_=h.file)==null?void 0:_.toLowerCase())===s.toLowerCase()}),y=new Set(((f==null?void 0:f.tests)||[]).map(h=>(h.name||"").toLowerCase()));for(const h of l)if(h&&!y.has(h))return!0;return!1},c=v.map(s=>{const r=(s.tests||[]).filter(l=>$||!p(s.file,l.name));return{...s,tests:r,testCount:r.length}}).filter(s=>s.tests.length>0),g=v.reduce((s,r)=>s+(r.tests||[]).filter(l=>p(r.file,l.name)).length,0);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:e.jsx(q,{className:"w-4 h-4 text-brand-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-200",children:"Map Test Cases to Scripts"}),e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:'Select a test case on the left, then click "Map" on a script on the right to create the mapping.'})]}),e.jsx("span",{className:`text-xs px-2.5 py-1 rounded-full border ${t.length>0?"bg-amber-500/10 text-amber-300 border-amber-500/20":"bg-emerald-500/10 text-emerald-300 border-emerald-500/20"}`,children:t.length>0?`${t.length} unmapped`:"All mapped ✓"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",style:{minHeight:"60vh"},children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 border-b border-white/5 flex items-center justify-between shrink-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"w-4 h-4 text-amber-400"}),e.jsx("span",{className:"text-sm font-medium text-gray-200",children:"Unmapped Test Cases"}),e.jsx("span",{className:"text-xs text-gray-500 bg-surface-2 px-2 py-0.5 rounded-full",children:t.length})]})}),e.jsx("div",{className:"px-4 py-2 border-b border-white/5 shrink-0",children:e.jsxs("div",{className:"relative",children:[e.jsx(ue,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",value:o,onChange:s=>j(s.target.value),placeholder:"Search test cases...",className:"w-full bg-surface-2 border border-white/10 rounded-lg pl-8 pr-3 py-1.5 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50"}),o&&e.jsx("button",{onClick:()=>j(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-200",children:e.jsx(be,{size:12})})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:i?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(F,{className:"w-5 h-5 text-brand-400 animate-spin"}),e.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"Loading..."})]}):t.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[e.jsx(H,{className:"w-8 h-8 text-emerald-400 mb-2"}),e.jsx("p",{className:"text-sm text-gray-400 text-center",children:o?"No unmapped test cases match your search.":"All test cases are mapped!"})]}):e.jsx("div",{className:"divide-y divide-white/5",children:t.map(s=>{const r=s.id||s.testCaseId,l=b===r;return e.jsx("button",{onClick:()=>S(l?null:r),className:`w-full text-left px-4 py-3 transition-colors ${l?"bg-brand-500/10 border-l-2 border-l-brand-500":"hover:bg-surface-2/50 border-l-2 border-l-transparent"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xs font-mono text-brand-300 shrink-0",children:r}),e.jsx("span",{className:"text-sm font-medium text-gray-200 truncate",title:s.title||"Untitled",children:s.title||"Untitled"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx(se,{priority:s.priority||"medium"}),s.type&&e.jsx(cs,{type:s.type})]})]}),e.jsx("div",{className:`w-4 h-4 rounded-full border-2 mt-0.5 shrink-0 transition-colors ${l?"border-brand-500 bg-brand-500":"border-white/20"}`,children:l&&e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-white"})})})]})},r)})})})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-white/5 flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{className:"w-4 h-4 text-brand-400"}),e.jsx("span",{className:"text-sm font-medium text-gray-200",children:"Available Scripts"}),c.length>0&&e.jsxs("span",{className:"text-xs text-gray-500 bg-surface-2 px-2 py-0.5 rounded-full",children:[c.reduce((s,r)=>{var l;return s+(((l=r.tests)==null?void 0:l.length)||0)},0)," available"]})]}),g>0&&e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[e.jsx("span",{className:"text-[10px] text-gray-500",children:"Show mapped"}),e.jsx("button",{role:"switch","aria-checked":$,onClick:()=>A(!$),className:`relative inline-flex h-4 w-7 items-center rounded-full transition-colors ${$?"bg-brand-500":"bg-gray-600"}`,children:e.jsx("span",{className:`inline-block h-2.5 w-2.5 rounded-full bg-white transition-transform ${$?"translate-x-3.5":"translate-x-0.5"}`})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:C?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(F,{className:"w-5 h-5 text-brand-400 animate-spin"}),e.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"Loading scripts..."})]}):c.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[e.jsx(oe,{className:"w-8 h-8 text-gray-500 mb-2"}),e.jsx("p",{className:"text-sm text-gray-400 text-center",children:"No test scripts discovered yet."}),e.jsx("p",{className:"text-xs text-gray-500 text-center mt-1",children:"Run your test framework first so Testver can discover test suites, or use the Test Explorer to scan."})]}):e.jsx("div",{className:"divide-y divide-white/5",children:c.map((s,r)=>{const l=s.file||`suite-${r}`,f=M.has(l),y=s.tests||[];return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>R(l),className:"w-full text-left px-4 py-3 hover:bg-surface-2/50 transition-colors flex items-center gap-2",children:[f?e.jsx(fe,{size:14,className:"text-gray-400 shrink-0"}):e.jsx(ss,{size:14,className:"text-gray-400 shrink-0"}),e.jsx(oe,{size:14,className:"text-gray-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-200 truncate",title:s.name||s.file,children:s.name?D(s.name):s.file}),e.jsx("div",{className:"text-xs text-gray-500 font-mono truncate mt-0.5",children:s.file})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(W,{framework:s.framework||"unknown"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[s.testCount||y.length," test",(s.testCount||y.length)!==1?"s":""]})]})]}),f&&y.length>0&&e.jsx("div",{className:"bg-surface-0/50",children:y.map((h,_)=>{const L=p(s.file,h.name);return e.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 pl-10 border-t border-white/5 transition-colors ${L?"bg-emerald-500/[0.03] opacity-60":"hover:bg-surface-2/30"}`,children:[e.jsx(ts,{size:12,className:L?"text-emerald-500 shrink-0":"text-gray-500 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-sm truncate ${L?"text-gray-400":"text-gray-300"}`,title:h.name,children:D(h.name)}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(W,{framework:h.framework||s.framework||"unknown"}),e.jsx("span",{className:"text-xs text-gray-500 font-mono truncate",children:je(s.file,30)})]})]}),L&&!b?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[10px] font-medium bg-emerald-500/15 text-emerald-400 border border-emerald-500/20 shrink-0",children:[e.jsx(H,{size:10})," Mapped"]}):L&&b?e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium bg-emerald-500/15 text-emerald-400 border border-emerald-500/20",children:[e.jsx(H,{size:9})," Mapped"]}),e.jsxs("button",{onClick:()=>T(b,s,h),disabled:N,className:"inline-flex items-center gap-1 bg-amber-600 hover:bg-amber-500 text-white rounded-lg px-2.5 py-1 text-[10px] font-medium transition-colors disabled:opacity-50",children:[N?e.jsx(F,{size:10,className:"animate-spin"}):e.jsx(I,{size:10}),"Map Also"]})]}):b?e.jsxs("button",{onClick:()=>T(b,s,h),disabled:N,className:"inline-flex items-center gap-1.5 bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-3 py-1.5 text-xs font-medium transition-colors shrink-0 disabled:opacity-50",children:[N?e.jsx(F,{size:12,className:"animate-spin"}):e.jsx(I,{size:12}),"Map"]}):e.jsx("span",{className:"text-xs text-gray-500 italic shrink-0",children:"Select a test case first"})]},`${l}-${_}`)})})]},l)})})})]})]})]})}export{js as ScriptMappingPage};
|