@testver/testver 1.4.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +88 -69
- package/README.md +6 -2
- package/bin/testver.js +9 -1
- package/dist/index.js +52650 -35771
- 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-RWO8Cd9w.js +32 -0
- package/src/ui/static/assets/AIRecordPanel-DnreS585.js +40 -0
- package/src/ui/static/assets/AIStreamUI-C1gHJtlF.js +9 -0
- package/src/ui/static/assets/{AITestGenPage-D3t2gPAA.js → AITestGenPage-C8bWUelu.js} +5 -5
- package/src/ui/static/assets/APITestingPage-DwL67hqL.js +19 -0
- 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-64mYNK2v.js → AnalyticsPage-C5ddYfRk.js} +1 -1
- package/src/ui/static/assets/AuditLogPage-DYcUdJoj.js +1 -0
- package/src/ui/static/assets/ChangesSummary-BjNMwGIZ.js +3 -0
- package/src/ui/static/assets/{CodeMapPage-B1ezmnlE.js → CodeMapPage-BQOEtv-R.js} +3 -3
- package/src/ui/static/assets/{ConfirmDialog-t7mpeeSN.js → ConfirmDialog-D_N9188T.js} +1 -1
- package/src/ui/static/assets/{CoveragePage-YMmCbiBk.js → CoveragePage-8bDSphY1.js} +2 -2
- package/src/ui/static/assets/{CronBuilder-Nk-K-_8I.js → CronBuilder-C7_JADb7.js} +1 -1
- package/src/ui/static/assets/{Dashboard-BDVxO2V4.js → Dashboard-B22yRPyV.js} +1 -1
- package/src/ui/static/assets/{DefectsPage-l8yGeCyR.js → DefectsPage-Arv4Ac-b.js} +72 -72
- package/src/ui/static/assets/{EmptyState-D1T3JWUr.js → EmptyState-BShNSbLf.js} +1 -1
- package/src/ui/static/assets/{ExportButton-Dt5RhL-h.js → ExportButton-xrS_AnfS.js} +1 -1
- package/src/ui/static/assets/{FileViewer-CrKgh_cB.js → FileViewer-Bcr9T1jW.js} +18 -18
- package/src/ui/static/assets/{GitPage-_4nCEzkJ.js → GitPage-DXL2Sv40.js} +12 -12
- package/src/ui/static/assets/{ImportExportPage-BcR7IQi9.js → ImportExportPage-BcjzRd7T.js} +36 -36
- package/src/ui/static/assets/{JiraPushDialog-C2sP4_4h.js → JiraPushDialog-DNYU9Ce0.js} +1 -1
- package/src/ui/static/assets/{KpiTile-inmeEsy3.js → KpiTile-BKlWqjgN.js} +1 -1
- package/src/ui/static/assets/{LiveExecutionView-D5BRe9jq.js → LiveExecutionView-1LlyEDEe.js} +1 -1
- package/src/ui/static/assets/{ManagePage-B8iG6Q0B.js → ManagePage-SvRQ6L19.js} +1 -1
- package/src/ui/static/assets/{MediaModal-C5n6sHYi.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-VGcmK167.js → ModuleExplorer-BKVbxFZK.js} +1 -1
- package/src/ui/static/assets/{OutputPage-B_1nPPxE.js → OutputPage-Bi-28tJi.js} +1 -1
- package/src/ui/static/assets/PipelinesPanel-BtO3iSJ4.js +1 -0
- package/src/ui/static/assets/{ProfilePage-y7tJNNFd.js → ProfilePage-BgZ4VDC-.js} +1 -1
- package/src/ui/static/assets/{ProjectExplorer-DbfGhRq0.js → ProjectExplorer-BVGbmVP7.js} +1 -1
- package/src/ui/static/assets/{RemoteFileStrip-WuRKtx_h.js → RemoteFileStrip-dzPInzgb.js} +1 -1
- package/src/ui/static/assets/{ReportCard-G52Q6-2i.js → ReportCard-LOf1PXlb.js} +2 -2
- package/src/ui/static/assets/{ReportFullView-Bt8UFP2J.js → ReportFullView-Ce4OI8lf.js} +1 -1
- package/src/ui/static/assets/{ReportsPage-DMtDi73Q.js → ReportsPage-DFxCQ8cY.js} +48 -48
- package/src/ui/static/assets/{ResultsPage-BI9jpK2N.js → ResultsPage-DD-uj8gk.js} +115 -115
- package/src/ui/static/assets/{RunState-ifC4zi6M.js → RunState-DDwFB4tA.js} +1 -1
- package/src/ui/static/assets/{RunTargets-C7vpCbck.js → RunTargets-CkIpY3v3.js} +1 -1
- package/src/ui/static/assets/ScriptMappingPage-DQQoR6sR.js +1 -0
- package/src/ui/static/assets/{SearchableDevicePicker-BYxYJNWl.js → SearchableDevicePicker-CenIxD7b.js} +1 -1
- package/src/ui/static/assets/{SettingsPage-DSISg7r7.js → SettingsPage-DAV_0y0m.js} +83 -83
- package/src/ui/static/assets/{SharedReportView-BOqKGJmR.js → SharedReportView-CqSLFKT1.js} +1 -1
- package/src/ui/static/assets/{SourcesPage-CgqtYGBi.js → SourcesPage-BvqC9oKw.js} +14 -14
- package/src/ui/static/assets/TestExplorerPage-Bdnll77k.js +7 -0
- package/src/ui/static/assets/{TestManagementPage-wqYTKP7W.js → TestManagementPage-CCNE688A.js} +10 -10
- package/src/ui/static/assets/{TestPlansPage-DOKX9p6z.js → TestPlansPage-T6D25i6-.js} +5 -5
- package/src/ui/static/assets/{TestverCreditsDetail-cSW0SpNx.js → TestverCreditsDetail-BKpt4oLW.js} +1 -1
- package/src/ui/static/assets/{TestverCreditsRing-DpMzl3h7.js → TestverCreditsRing-CoDk5eAS.js} +1 -1
- package/src/ui/static/assets/TestverMcpPage-Dte0qSXp.js +34 -0
- package/src/ui/static/assets/{UncommittedDiffViewer-BxS0zi-p.js → UncommittedDiffViewer-BNroxCoo.js} +2 -2
- package/src/ui/static/assets/{UserManagementPage-B5d0uDU_.js → UserManagementPage-BU4MuDJZ.js} +10 -10
- package/src/ui/static/assets/{WorkflowsPage-Bk0DFnFS.js → WorkflowsPage-BP5k7AqE.js} +83 -83
- package/src/ui/static/assets/clipboard-BIEd7Ccc.js +1 -0
- package/src/ui/static/assets/{hiddenLlmProviders-CdhhNa5G.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/{index-DpQhqcHv.js → index-DLmlY2Ol.js} +1 -1
- package/src/ui/static/assets/{reportMeta-AKcU_qwq.js → reportMeta-B9ZRW6ts.js} +1 -1
- package/src/ui/static/assets/runSelected-BoPm1sz-.js +1 -0
- package/src/ui/static/assets/{useChartTheme-BFz2QcND.js → useChartTheme-CTIe6M63.js} +1 -1
- package/src/ui/static/assets/{useDebouncedValue-BsHptIvX.js → useDebouncedValue-C9odz7b2.js} +1 -1
- package/src/ui/static/assets/{useFeatureFlags-DNkIctil.js → useFeatureFlags-B4Otsv-N.js} +1 -1
- package/src/ui/static/assets/{useJiraConnector-D5ysBBvz.js → useJiraConnector--JZhbYrT.js} +1 -1
- package/src/ui/static/assets/{useOwnership-U0AfKBRo.js → useOwnership-BhPOiYzy.js} +1 -1
- package/src/ui/static/assets/useSuites-GN_K2mHc.js +1 -0
- package/src/ui/static/assets/{useTabParam-ChbOedP1.js → useTabParam-CyYAP90W.js} +1 -1
- package/src/ui/static/assets/{useTestExplorer-DT8frjCK.js → useTestExplorer-BGhkGHKy.js} +1 -1
- package/src/ui/static/assets/{useTestLifecycle-OcwQaB1s.js → useTestLifecycle-DX5ES6x8.js} +1 -1
- package/src/ui/static/assets/{useTestManagement-Xm4Bcx3u.js → useTestManagement-ommXjx0q.js} +2 -2
- package/src/ui/static/assets/useTestResults-DWjvm8gm.js +1 -0
- package/src/ui/static/assets/{vendor-charts-DWFQlmCz.js → vendor-charts-By5uZ93z.js} +1 -1
- package/src/ui/static/assets/{vendor-flow-YGpC9U9I.js → vendor-flow-B61ZV-pm.js} +1 -1
- package/src/ui/static/assets/{vendor-icons-BKPiFyYV.js → vendor-icons-Cm92aSc5.js} +1426 -1421
- package/src/ui/static/assets/vendor-query-DkZSMtfn.js +1 -0
- package/src/ui/static/assets/{vendor-quill-W-RoQfb6.js → vendor-quill-xJF2Jvjc.js} +1 -1
- package/src/ui/static/assets/{vendor-react-CTbHBddL.js → vendor-react-DOVfxdUy.js} +1 -1
- package/src/ui/static/index.html +479 -479
- package/src/ui/static/assets/AIPanel-B_R-CbrF.js +0 -32
- package/src/ui/static/assets/AIRecordPanel-BRQWIU5h.js +0 -40
- package/src/ui/static/assets/AIStreamUI-C3D989_6.js +0 -9
- package/src/ui/static/assets/APITestingPage-Cmwkiiys.js +0 -19
- package/src/ui/static/assets/AboutPage-CjEqKB-q.js +0 -1
- package/src/ui/static/assets/AdvancedPage-4kAcpE8Y.js +0 -3
- package/src/ui/static/assets/AuditLogPage-BQjOzQje.js +0 -1
- package/src/ui/static/assets/ChangesSummary-CY_Vb27i.js +0 -2
- package/src/ui/static/assets/DiffViewer-BIU09a_i.js +0 -2
- package/src/ui/static/assets/MobileRunPicker-0h-N2c6d.js +0 -1
- package/src/ui/static/assets/MobileRunTarget-Bo_xekig.js +0 -6
- package/src/ui/static/assets/PipelinesPanel-PmmPu8pj.js +0 -1
- package/src/ui/static/assets/ScriptMappingPage-7vHuvhQw.js +0 -1
- package/src/ui/static/assets/TestExplorerPage-gYLhCD4d.js +0 -7
- package/src/ui/static/assets/index-BYVxKLrT.js +0 -47
- package/src/ui/static/assets/index-C2KJt7SI.css +0 -1
- package/src/ui/static/assets/runSelected-WlgnZcSF.js +0 -1
- package/src/ui/static/assets/useSuites-DyfN9HVv.js +0 -1
- package/src/ui/static/assets/useTestResults-D5EwGIX9.js +0 -1
- package/src/ui/static/assets/vendor-query-BrzmPFT3.js +0 -1
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import{r as z,j as e,u as Ke}from"./vendor-react-
|
|
2
|
-
`).replace(/"/g,'""')}"`}function oe(n){return n.map(o=>o.map(at).join(",")).join(`\r
|
|
3
|
-
`)}function Fe(n){const o=[];let i=[],t="",s=!1;const r=n.replace(/^/,""),a=()=>{i.push(t.trim()),t=""},d=()=>{a(),i.some(l=>l!=="")&&o.push(i),i=[]};for(let l=0;l<r.length;l++){const m=r[l];s?m==='"'?r[l+1]==='"'?(t+='"',l++):s=!1:t+=m:m==='"'&&t.trim()===""?s=!0:m===","?a():m===`
|
|
4
|
-
`||m==="\r"?(m==="\r"&&r[l+1]===`
|
|
5
|
-
`&&l++,d()):t+=m}return d(),o}const
|
|
6
|
-
`),ee=n=>n.id?`${n.id}: ${n.title}`:n.title,Ee={critical:{jira:"Highest",testrail:"Critical",zephyr:"High"},high:{jira:"High",testrail:"High",zephyr:"High"},medium:{jira:"Medium",testrail:"Medium",zephyr:"Normal"},low:{jira:"Low",testrail:"Low",zephyr:"Low"}},he=(n,o)=>{var i;return((i=Ee[String(n??"medium").toLowerCase()])==null?void 0:i[o])??Ee.medium[o]},Oe=n=>n.trim().replace(/\s+/g,"_");function lt(n){const o=["Title","Priority","Type","Tags","Preconditions","Steps (Action)","Steps (Expected Result)","Steps (Test Data)","ID","Folder","Status","Review Status","Automation","Requirements","Sources","Strategy","Automatable","Automatable Reason","Grounding","Spec Drift"],i=n.map(t=>{const s=t.steps??[];return[t.title??"",t.priority??"",t.type??"",(t.tags??[]).join(", "),t.preconditions??"",s.map(r=>
|
|
7
|
-
`),d=[r,t.title,a,he(t.priority,"jira"),(t.tags??[]).map(Oe).join(" "),"Manual"],l=ie(t);if(l.length===0){i.push([...d,"","",""]);return}l.forEach((m,f)=>i.push([...f===0?d:[r,"","","","",""],m.action??"",m.testData??"",m.expectedResult??""]))}),oe([o,...i])}function pt(n){const o=["Title","Section","Type","Priority","Preconditions","Steps","Expected Result","References"],i=n.map(t=>{const s=ie(t);return[t.title,t.folder??"","Functional",he(t.priority,"testrail"),t.preconditions??"",Re(s.map(r=>r.testData?`${r.action} (data: ${
|
|
8
|
-
`),r=t.folder?`/${t.folder.split(" / ").join("/")}`:"",a=[t.title,s,t.preconditions??"",r,"Draft",he(t.priority,"zephyr"),(t.tags??[]).map(Oe).join(",")],d=ie(t);if(d.length===0){i.push([...a,"","",""]);continue}d.forEach((l,m)=>i.push([...m===0?a:["","","","","","",""],l.action??"",l.testData??"",l.expectedResult??""]))}return oe([o,...i])}const me=n=>`@${n.trim().replace(/[\s@]+/g,"-").replace(/[^\p{L}\p{N}_\-.:]/gu,"")}`,Q=n=>
|
|
9
|
-
`).replace(/\n+$/,`
|
|
10
|
-
`)}function ut(n){const o=["ID","Title","Folder","Priority","Type","Status","Review Status","Automation","Preconditions","Tags","Requirements","Sources","Strategy","Automatable","Automatable Reason","Grounding","Spec Drift","Steps"],i=n.map(s=>[s.id??"",s.title,s.folder??"",s.priority??"",s.type??"",s.status??"",s.reviewStatus??"",s.automationStatus??"",s.preconditions??"",(s.tags??[]).join(", "),(s.requirements??[]).map(ee).join(`
|
|
11
|
-
`),(s.sources??[]).map(r=>r.title).join(`
|
|
12
|
-
`),s.strategy??"",s.automatable??"",s.automatableReason??"",s.grounding??"",s.specDrift?`Requirement says: ${s.specDrift.requirementSays}
|
|
13
|
-
App does: ${s.specDrift.appDoes}`:"",(s.steps??[]).length]),t=[];for(const s of n)(s.steps??[]).forEach((r,a)=>t.push([s.id??"",s.title,r.stepNumber??a+1,r.action??"",r.expectedResult??"",r.testData??""]));return[{name:"Test cases",rows:[o,...i],widths:[10,48,24,10,12,10,14,12,36,20,36,24,14,12,36,12,36,7]},{name:"Steps",rows:[["Test case ID","Test case","Step","Action","Expected result","Test data"],...t],widths:[10,40,6,48,48,24]}]}function ue(n,o,i){switch(n){case"json":return JSON.stringify(o,null,2);case"csv":return lt(o);case"gherkin":return mt(o,i);case"xray":return ct(o);case"testrail":return pt(o);case"zephyr":return dt(o)}}function L(n){return n?n.replace(/<br\s*\/?>/gi,`
|
|
14
|
-
`).replace(/<\/li>/gi,`
|
|
15
|
-
`).replace(/<\/p>/gi,`
|
|
16
|
-
`).replace(/<\/div>/gi,`
|
|
17
|
-
`).replace(/<[^>]*>/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/ /g," ").replace(/\n{3,}/g,`
|
|
18
|
-
|
|
19
|
-
`).trim():""}function
|
|
20
|
-
`).map(r=>r.trim()).filter(Boolean);return s.length===1?[s[0].replace(/^1[.)]\s+/,"").trim()].filter(Boolean):s}function Z(n){if(!n)return"medium";const o=String(n).toLowerCase().trim();return["1","p1","critical","blocker","highest"].includes(o)?"critical":["2","p2","high","major"].includes(o)?"high":["3","p3","medium","normal","moderate"].includes(o)?"medium":["4","p4","low","minor","trivial","lowest"].includes(o)?"low":"medium"}function Y(n){if(!n)return"functional";const o=n.toLowerCase().trim();return{functional:"functional",regression:"regression",smoke:"smoke",sanity:"sanity",e2e:"e2e","end-to-end":"e2e","end to end":"e2e",integration:"integration",performance:"performance",security:"security",accessibility:"accessibility",acceptance:"functional",automated:"functional",manual:"functional",exploratory:"functional",usability:"functional"}[o]||"functional"}function ne(n){const o=Fe(n);if(o.length<2)return{headers:[],rows:[]};const i=o[0].map(s=>s.replace(/^"|"$/g,"")),t=o.slice(1).map(s=>{const r={};return i.forEach((a,d)=>{r[a]=s[d]||""}),r});return{headers:i,rows:t}}function xe(n,o,i){var t,s;if(i)return{tool:i,format:o};if(o==="xml"){const r=n;if(r.includes("<suite")||r.includes("<sections")||r.includes("<cases>"))return{tool:"testrail",format:"xml"};if(r.includes("<testcase")||r.includes("<teststep"))return{tool:"zephyr",format:"xml"}}if(o==="csv"){const a=((t=n.split(`
|
|
21
|
-
`)[0])==null?void 0:t.toLowerCase())||"";if(a.includes("section")&&a.includes("title")&&(a.includes("suite")||a.includes("references")))return{tool:"testrail",format:"csv"};if(a.includes("summary")&&(a.includes("issue type")||a.includes("test type")||a.includes("manual test")))return{tool:"xray",format:"csv"};if(a.includes("name")&&a.includes("test script (step-by-step)"))return{tool:"zephyr",format:"csv"};if(a.includes("name")&&a.includes("steps")&&a.includes("expected"))return{tool:"practitest",format:"csv"}}if(o==="json")try{const a=JSON.parse(n),d=Array.isArray(a)?a:a.issues||a.tests||[];if(d.length>0&&((s=d[0].fields)!=null&&s.summary))return{tool:"xray",format:"json"}}catch{}return null}function xt(n){const o=n.map(i=>i.toLowerCase());return o.some(i=>i.includes("module"))&&o.some(i=>i.includes("test step"))?"qtest":o.some(i=>i.includes("folder"))||o.some(i=>i.includes("label"))?"zephyr":"qtest"}function fe(n){const{headers:o,rows:i}=ne(n),t=[],s={},r=x=>o.find(S=>x.some(R=>S.toLowerCase().includes(R.toLowerCase()))),a=r(["Title","Case Title","Name"])||"Title",d=r(["Priority"])||"Priority",l=r(["Type","Test Type"])||"Type",m=r(["Section","Suite","Folder"])||"Section",f=r(["Preconditions","Precondition"])||"Preconditions",j=r(["Steps","Test Steps","Steps (Actions)"])||"Steps",b=r(["Expected Result","Expected Results","Expected"])||"Expected Result",p=r(["References","Refs"])||"References";s[a]="title",s[d]="priority",s[l]="type",s[m]="tags (section)",s[f]="preconditions",s[j]="steps",s[b]="expectedResult";const h=i.filter(x=>{var S;return(S=x[a])==null?void 0:S.trim()}).map(x=>{var T;const S=[];x[m]&&S.push(x[m]),x[p]&&S.push(...x[p].split(",").map(P=>P.trim()).filter(Boolean));const R=x[j]||"",E=x[b]||"",u=J(R),v=J(E),N=u.length>0?u.map((P,g)=>({action:P,expectedResult:v[g]||""})):E?[{action:R.trim()||"See expected result",expectedResult:E.trim()}]:[];return{title:x[a].trim(),priority:Z(x[d]),type:Y(x[l]),preconditions:((T=x[f])==null?void 0:T.trim())||"",steps:N.length>0?N:void 0,tags:S.length>0?S:void 0}});return h.length===0&&t.push("No test cases found. Check if the CSV matches TestRail export format."),{testCases:h,detectedTool:"TestRail (CSV)",warnings:t,fieldMapping:s}}function De(n){const i=new DOMParser().parseFromString(n,"text/xml"),t=[],s=i.querySelector("parsererror");if(s)return{testCases:[],detectedTool:"TestRail (XML)",warnings:["Invalid XML: "+(s.textContent||"").slice(0,200)],fieldMapping:{}};const r={title:"title",priority_id:"priority",type:"type",preconds:"preconditions","steps_separated/step":"steps","section/name":"tags"},a=[];return i.querySelectorAll("case").forEach(l=>{var R,E,u,v,N,T,P,g,C;const m=(E=(R=l.querySelector("title"))==null?void 0:R.textContent)==null?void 0:E.trim();if(!m)return;const f=(u=l.querySelector("priority_id"))==null?void 0:u.textContent,j=(v=l.querySelector("type"))==null?void 0:v.textContent,b=((T=(N=l.querySelector("custom preconds"))==null?void 0:N.textContent)==null?void 0:T.trim())||"",p=l.closest("section"),h=(g=(P=p==null?void 0:p.querySelector(":scope > name"))==null?void 0:P.textContent)==null?void 0:g.trim(),x=[],S=l.querySelectorAll("custom steps_separated step");if(S.length>0)S.forEach(y=>{var O,q;const M=L(((O=y.querySelector("content"))==null?void 0:O.textContent)||""),$=L(((q=y.querySelector("expected"))==null?void 0:q.textContent)||"");M&&x.push({action:M,expectedResult:$})});else{const y=(C=l.querySelector("custom steps"))==null?void 0:C.textContent;y&&J(y).forEach(M=>x.push({action:M}))}a.push({title:m,priority:Z(f),type:Y(j||void 0),preconditions:L(b),steps:x.length>0?x:void 0,tags:h?[h]:void 0})}),a.length===0&&t.push("No <case> elements found in XML."),{testCases:a,detectedTool:"TestRail (XML)",warnings:t,fieldMapping:r}}function re(n,o){const i=o.toLowerCase(),t=n.getElementsByTagName?n.getElementsByTagName("*"):n.querySelectorAll("*"),s=[];for(let r=0;r<t.length;r++){const a=t[r];a.tagName.toLowerCase()===i&&s.push(a)}return s}function U(n,...o){const i=o.map(t=>t.toLowerCase());for(const t of Array.from(n.children))if(i.includes(t.tagName.toLowerCase()))return t;return null}function Ae(n){const i=new DOMParser().parseFromString(n,"text/xml"),t=[];if(i.querySelector("parsererror"))return{testCases:[],detectedTool:"Zephyr (XML)",warnings:["Invalid XML"],fieldMapping:{}};const r={name:"title",priority:"priority","labels/label | folder":"tags","testScript/steps/step/description":"steps.action","testScript/steps/step/expectedResult":"steps.expectedResult","testScript/steps/step/testData":"steps.testData","objective | precondition":"preconditions"},a=[];return re(i,"testCase").forEach(l=>{var v,N,T,P,g;const m=U(l,"name"),f=((v=m==null?void 0:m.textContent)==null?void 0:v.trim())||l.getAttribute("name")||"";if(!f)return;const j=U(l,"priority"),b=((N=j==null?void 0:j.textContent)==null?void 0:N.trim())||l.getAttribute("priority")||"",p=[],h=U(l,"folder");(T=h==null?void 0:h.textContent)!=null&&T.trim()&&p.push(h.textContent.trim());const x=U(l,"labels");if(x)for(const C of Array.from(x.children)){const y=(P=C.textContent)==null?void 0:P.trim();y&&p.push(y)}const S=L(((g=U(l,"precondition","preconditions","objective"))==null?void 0:g.textContent)||""),R=[],E=U(l,"testScript");let u=[];if(E){const C=U(E,"steps");C&&(u=Array.from(C.children).filter(y=>y.tagName.toLowerCase()==="step"))}u.length===0&&(u=re(l,"step").filter(C=>{var y;return l.contains(((y=C.parentElement)==null?void 0:y.parentElement)||null),!0}),u.length===0&&(u=[...re(l,"teststep"),...re(l,"test-step")])),u.forEach(C=>{var O,q,X,V;const y=L(((O=U(C,"description","action","step"))==null?void 0:O.textContent)||((q=C.querySelector("content"))==null?void 0:q.textContent)||""),M=L(((X=U(C,"expectedResult","expected","result"))==null?void 0:X.textContent)||""),$=L(((V=U(C,"testData","test-data","data"))==null?void 0:V.textContent)||"");y&&R.push({action:y,expectedResult:M,testData:$||void 0})}),a.push({title:f,priority:Z(b),preconditions:S,steps:R.length>0?R:void 0,tags:p.length>0?p:void 0})}),a.length===0&&t.push("No <testCase> elements found in XML. Expected a Zephyr Scale / TM4J export with <project><testCases><testCase>… structure."),{testCases:a,detectedTool:"Zephyr (XML)",warnings:t,fieldMapping:r}}function Pe(n,o){var R,E;const i=[],t=u=>n.find(v=>u.some(N=>v.toLowerCase().includes(N.toLowerCase()))),s=t(["Test Case Name","Test Case","Name","Title","Summary"])||n[0]||"Name",r=t(["Priority"])||"",a=t(["Folder","Component"])||"",d=t(["Label","Tag"])||"",l=t(["Objective"])||"",m=t(["Precondition"])||"",f=t(["Step Description","Test Step Description","Test Script (Step-by-Step) - Description","Step Action","Test Step","Action","Description","Step"])||"",j=t(["Expected Result","Expected Results","Step Expected Result","Test Script (Step-by-Step) - Expected Result","Expected"])||"",b=t(["Test Data","Step Test Data","Test Script (Step-by-Step) - Test Data","Data"])||"",p={[s]:"title"};r&&(p[r]="priority"),a&&(p[a]="tags (folder)"),d&&(p[d]="tags (labels)"),l&&(p[l]="preconditions (objective)"),m&&(p[m]="preconditions"),f&&(p[f]="steps.action"),j&&(p[j]="steps.expectedResult"),b&&(p[b]="steps.testData");const h=u=>{var P,g;const v=[],N=(P=u[a])==null?void 0:P.trim();N&&v.push(N);const T=(g=u[d])==null?void 0:g.trim();return T&&T.split(/[,;|]/).map(C=>C.trim()).filter(Boolean).forEach(C=>v.push(C)),v},x=f!==""&&o.some(u=>{var v,N,T;return!((v=u[s])!=null&&v.trim())&&(((N=u[f])==null?void 0:N.trim())||((T=u[j])==null?void 0:T.trim()))}),S=[];if(x){let u=null,v=[];const N=()=>{u&&(u.steps=v.length>0?v:void 0,S.push(u)),u=null,v=[]};for(const T of o){const P=(R=T[s])==null?void 0:R.trim();if(P){N(),u={title:P,priority:Z(T[r]),preconditions:L(T[m]||T[l]||""),steps:void 0,tags:void 0};const g=h(T);g.length>0&&(u.tags=g)}if(u){const g=L(T[f]||""),C=L(T[j]||""),y=L(T[b]||"");(g||C||y)&&v.push({action:g||"(no description)",expectedResult:C||void 0,testData:y||void 0})}}N()}else for(const u of o){const v=(E=u[s])==null?void 0:E.trim();if(!v)continue;const N=L(u[f]||""),T=L(u[j]||""),P=J(N),g=J(T),C=P.length>0?P.map((M,$)=>({action:M,expectedResult:g[$]||""})):N?[{action:N,expectedResult:T||void 0}]:[],y=h(u);S.push({title:v,priority:Z(u[r]),preconditions:L(u[m]||u[l]||""),steps:C.length>0?C:void 0,tags:y.length>0?y:void 0})}return S.length===0?i.push('No test cases parsed from the spreadsheet. Verify the export matches a Zephyr Scale / TM4J template (expected a "Name" column plus optional Test Script step columns).'):f===""&&i.push('No step column was detected — only titles were imported. Add columns like "Test Script (Step-by-Step) - Description" / "Expected Result" to capture steps.'),{testCases:S,detectedTool:"Zephyr (Excel)",warnings:i,fieldMapping:p}}function Le(n){var E,u,v,N,T,P;const{headers:o,rows:i}=ne(n),t=[],s=g=>o.find(C=>g.some(y=>C.toLowerCase().includes(y.toLowerCase()))),r=s(["Summary","Title","Name"])||"Summary",a=s(["Priority"])||"Priority",d=s(["Test Type","Issue Type","Type"])||"",l=s(["Manual Test Steps","Steps","Test Steps"])||"",m=s(["Expected Result","Expected Results"])||"",f=s(["Labels","Tags","Components"])||"",j=s(["Preconditions","Precondition","Description"])||"",b={[r]:"title",[a]:"priority"};d&&(b[d]="type"),l&&(b[l]="steps"),f&&(b[f]="tags");const p=o.find(g=>["action","step","step action"].includes(g.toLowerCase()))||"",h=o.find(g=>["data","test data","step data"].includes(g.toLowerCase()))||"",x=o.find(g=>["result","expected result","expected"].includes(g.toLowerCase()))||"",S=o.find(g=>["tcid","test id","issue id","test case identifier","id"].includes(g.toLowerCase()))||"";if(p&&S){const g=new Map;for(const y of i){const M=(E=y[S])==null?void 0:E.trim();if(!M)continue;let $=g.get(M);if(!$&&((u=y[r])!=null&&u.trim())){const V=y[f]?y[f].split(/[,;\s]+/).map(_=>_.trim()).filter(Boolean):[];$={title:y[r].trim(),priority:Z(y[a]),type:Y(y[d]),preconditions:((v=y[j])==null?void 0:v.trim())||"",tags:V.length>0?V:void 0},g.set(M,$)}if(!$)continue;const O=((N=y[p])==null?void 0:N.trim())||"",q=((T=y[x])==null?void 0:T.trim())||"",X=((P=y[h])==null?void 0:P.trim())||"";(O||q||X)&&($.steps=[...$.steps??[],{action:O||"(no description)",expectedResult:q,...X?{testData:X}:{}}])}const C=[...g.values()];return C.length===0&&t.push("No test cases found. Each test needs a row with its Summary."),{testCases:C,detectedTool:"Xray (CSV)",warnings:t,fieldMapping:{...b,[S]:"test id",[p]:"steps.action",...x?{[x]:"steps.expectedResult"}:{},...h?{[h]:"steps.testData"}:{}}}}return{testCases:i.filter(g=>{var C;return(C=g[r])==null?void 0:C.trim()}).map(g=>{var X;const C=g[f]?g[f].split(/[,;]/).map(V=>V.trim()).filter(Boolean):[],y=g[l]||"",M=g[m]||"",$=J(y),O=J(M),q=$.length>0?$.map((V,_)=>({action:V,expectedResult:O[_]||""})):[];return{title:g[r].trim(),priority:Z(g[a]),type:Y(g[d]),preconditions:((X=g[j])==null?void 0:X.trim())||"",steps:q.length>0?q:void 0,tags:C.length>0?C:void 0}}),detectedTool:"Xray (CSV)",warnings:t,fieldMapping:b}}function ft(n){const o=[];let i;try{i=JSON.parse(n)}catch{return{testCases:[],detectedTool:"Xray (JSON)",warnings:["Invalid JSON format"],fieldMapping:{}}}const t=Array.isArray(i)?i:i.issues||i.tests||[],s={"fields.summary":"title","fields.priority.name":"priority","fields.labels":"tags","fields.description":"preconditions"};return{testCases:t.filter(a=>{var d;return(d=a.fields)==null?void 0:d.summary}).map(a=>{var f,j;const d=a.fields,l=[];for(const[b,p]of Object.entries(d||{}))if(b.startsWith("customfield_")&&Array.isArray(p)){const h=p;if(h.length>0&&(h[0].action||h[0].step||h[0].content)){h.forEach(x=>{const S=L(x.action||x.step||x.content||""),R=L(x.result||x.expected||x.expectedResult||""),E=L(x.data||x.testData||"");S&&l.push({action:S,expectedResult:R,testData:E||void 0})}),s[b]="steps";break}}const m=Array.isArray(d.labels)?d.labels:[];return{title:d.summary,priority:Z(((f=d.priority)==null?void 0:f.name)||d.priority),type:Y((j=d.issuetype)==null?void 0:j.name),preconditions:L(d.description||""),steps:l.length>0?l:void 0,tags:m.length>0?m:void 0}}),detectedTool:"Xray (JSON)",warnings:o,fieldMapping:s}}function ke(n){const{headers:o,rows:i}=ne(n),t=[],s=p=>o.find(h=>p.some(x=>h.toLowerCase().includes(x.toLowerCase()))),r=s(["Name","Title","Test Name"])||o[0]||"Name",a=s(["Priority"])||"",d=s(["Steps","Test Steps","Step Description"])||"",l=s(["Expected Results","Expected Result","Expected"])||"",m=s(["Preconditions","Precondition"])||"",f=s(["Tags","Labels","Custom Fields"])||"",j={[r]:"title"};return a&&(j[a]="priority"),d&&(j[d]="steps"),l&&(j[l]="expectedResult"),{testCases:i.filter(p=>{var h;return(h=p[r])==null?void 0:h.trim()}).map(p=>{var E;const h=J(p[d]||""),x=J(p[l]||""),S=h.length>0?h.map((u,v)=>({action:u,expectedResult:x[v]||""})):[],R=p[f]?p[f].split(/[,;]/).map(u=>u.trim()).filter(Boolean):[];return{title:p[r].trim(),priority:Z(p[a]),preconditions:((E=p[m])==null?void 0:E.trim())||"",steps:S.length>0?S:void 0,tags:R.length>0?R:void 0}}),detectedTool:"PractiTest (CSV)",warnings:t,fieldMapping:j}}function Ie(n,o){const i=[],t=b=>n.find(p=>b.some(h=>p.toLowerCase().includes(h.toLowerCase()))),s=t(["Name","Test Case Name","Title","Summary"])||n[0]||"Name",r=t(["Priority"])||"",a=t(["Test Steps","Steps","Step Description","Test Step Description"])||"",d=t(["Expected Result","Expected Results","Expected"])||"",l=t(["Preconditions","Precondition","Pre-Conditions"])||"",m=t(["Module","Folder","Component"])||"",f={[s]:"title"};return r&&(f[r]="priority"),a&&(f[a]="steps"),d&&(f[d]="expectedResult"),m&&(f[m]="tags (module)"),{testCases:o.filter(b=>{var p;return(p=b[s])==null?void 0:p.trim()}).map(b=>{var u;const p=L(b[a]||""),h=L(b[d]||""),x=J(p),S=J(h),R=x.length>0?x.map((v,N)=>({action:v,expectedResult:S[N]||""})):[],E=[];return(u=b[m])!=null&&u.trim()&&E.push(b[m].trim()),{title:b[s].trim(),priority:Z(b[r]),preconditions:L(b[l]||""),steps:R.length>0?R:void 0,tags:E.length>0?E:void 0}}),detectedTool:"qTest (Excel)",warnings:i,fieldMapping:f}}async function ht(n,o,i){if(i=String(i||"").toLowerCase(),i==="xlsx"||i==="xls"){const s=await Qe(n);if(s.length===0)return{testCases:[],detectedTool:"Unknown",warnings:["Empty spreadsheet or no data rows found"],fieldMapping:{}};const r=Object.keys(s[0]),a=o||xt(r);return a==="qtest"?Ie(r,s):a==="zephyr"?Pe(r,s):Ie(r,s)}const t=n;if(i==="xml"){const s=xe(t,i,o||void 0);if((s==null?void 0:s.tool)==="testrail"||o==="testrail")return De(t);if((s==null?void 0:s.tool)==="zephyr"||o==="zephyr")return Ae(t);const r=De(t),a=Ae(t);return r.testCases.length>=a.testCases.length?r:a}if(i==="json")return ft(t);if(i==="csv"||i==="txt"){const s=xe(t,"csv",o||void 0);if((s==null?void 0:s.tool)==="zephyr"||o==="zephyr"){const{headers:a,rows:d}=ne(t);return{...Pe(a,d),detectedTool:"Zephyr (CSV)"}}if((s==null?void 0:s.tool)==="testrail"||o==="testrail")return fe(t);if((s==null?void 0:s.tool)==="xray"||o==="xray")return Le(t);if((s==null?void 0:s.tool)==="practitest"||o==="practitest")return ke(t);const r=xe(t,"csv");if(r){if(r.tool==="testrail")return fe(t);if(r.tool==="xray")return Le(t);if(r.tool==="practitest")return ke(t)}return fe(t)}return{testCases:[],detectedTool:"Unknown",warnings:[`Unsupported file format: .${i}`],fieldMapping:{}}}const gt=!1;function qe(n,o=0){var t;const i=[];for(const s of n)i.push({id:s.id,name:s.name,depth:o}),(t=s.children)!=null&&t.length&&i.push(...qe(s.children,o+1));return i}function Rt({embedded:n=!1}={}){var Ce,we;const[o,i]=z.useState(null),[t,s]=z.useState("json"),[r,a]=z.useState(""),[d,l]=z.useState(""),[m,f]=z.useState(null),[j,b]=z.useState("file"),[p,h]=z.useState(!1),[x,S]=z.useState("select"),[R,E]=z.useState(null),[u,v]=z.useState(null),[N,T]=z.useState(null),[P,g]=z.useState(!1),[C,y]=z.useState(!1),[M,$]=z.useState(""),{toast:O}=rt(),[q,X]=z.useState(!1),V=et(),_=tt(),{data:W}=st(),ge=Array.isArray(W)?W:(W==null?void 0:W.folders)??(W==null?void 0:W.tree)??[],ae=z.useMemo(()=>qe(ge),[ge]),ye=((Ce=ae.find(c=>c.id===d))==null?void 0:Ce.name)||"Test cases";function be(c){O("success",c)}function Ve(c){navigator.clipboard.writeText(c),X(!0),setTimeout(()=>X(!1),2e3)}async function Xe(c){try{const w=await V.mutateAsync(c||void 0);i(w),be("Export completed")}catch{}}function Be(c){const w=Fe(c);if(w.length<2)return[];const D=w[0].map(A=>A.trim().toLowerCase());return w.slice(1).map(A=>{const k={};D.forEach((I,Ge)=>{k[I]=A[Ge]||""});const F=k.title||k.name||k["test case"]||"",je=[],ce=(k["steps (action)"]||"").split("|").map(I=>I.trim()),pe=(k["steps (expected result)"]||"").split("|").map(I=>I.trim()),Se=(k["steps (test data)"]||"").split("|").map(I=>I.trim()),He=Math.max(ce.length,pe.length,Se.length);for(let I=0;I<He;I++)(ce[I]||pe[I])&&je.push({action:ce[I]||"",expectedResult:pe[I]||"",testData:Se[I]||""});return{title:F,priority:k.priority||"medium",type:k.type||"functional",tags:(k.tags||"").split(",").map(I=>I.trim()).filter(Boolean),preconditions:k.preconditions||"",steps:je}}).filter(A=>A.title)}function Je(c,w,D){const A=new Blob([c],{type:D}),k=URL.createObjectURL(A),F=document.createElement("a");F.href=k,F.download=w,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(k)}async function Ue(){if(!o)return;const c=(o==null?void 0:o.testCases)??(Array.isArray(o)?o:[]),w=de.find(A=>A.id===t),D=`test-cases-${w.id==="json"||w.id==="csv"||w.id==="xlsx"||w.id==="gherkin"?"export":w.id}-${Date.now()}.${w.ext}`;if(w.id==="xlsx"){try{const A=await Ye(ut(c)),k=URL.createObjectURL(A),F=document.createElement("a");F.href=k,F.download=D,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(k)}catch(A){O("error",`Could not build the Excel file: ${(A==null?void 0:A.message)||A}`)}return}Je(ue(w.id,c,ye),D,w.mime)}function Ze(c){var A;const w=(A=c.target.files)==null?void 0:A[0];if(!w)return;const D=new FileReader;D.onload=()=>{a(D.result)},D.readAsText(w),c.target.value=""}async function We(){if(r.trim())try{let c;const w=r.trim();if(w.startsWith("[")||w.startsWith("{")?(c=JSON.parse(w),Array.isArray(c)||(c=[c])):c=Be(w),!c.length){f({error:"No valid test cases found in input"});return}const D=await _.mutateAsync({testCases:c,folderId:d||void 0});f(D),be(`${(D==null?void 0:D.imported)??0} test cases imported`)}catch(c){f({error:c.message||"Import failed"})}}z.useCallback(async c=>{if(R){y(!0);try{const w=c.name.lastIndexOf("."),D=w>-1?c.name.slice(w+1).toLowerCase():"",k=D==="xlsx"||D==="xls"?await c.arrayBuffer():await c.text(),F=await ht(k,R,D);v(F),S("preview")}catch(w){v({detectedTool:R,testCases:[],fieldMapping:{},warnings:[w.message||"Failed to parse file"]}),S("preview")}finally{y(!1)}}},[R]);const K=o?(o==null?void 0:o.testCases)??(Array.isArray(o)?o:[]):[],le=de.find(c=>c.id===t),H=K.length>0?t==="xlsx"?ue("csv",K):ue(t,K,ye):null,_e=H?new Blob([H]).size:0;return e.jsx("div",{className:n?"text-gray-200":"min-h-screen bg-surface-0 text-gray-200",children:e.jsx("div",{className:n?"":"max-w-[1400px] mx-auto px-6 py-6",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-100 mb-1 flex items-center gap-2",children:[e.jsx(te,{size:20,className:"text-brand-300"}),"Export Test Cases"]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Export test cases for backup, migration, or sharing"}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-end gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex-1 min-w-[180px] max-w-xs",children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Folder"}),e.jsxs("select",{value:d,onChange:c=>l(c.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-brand-500/50",children:[e.jsx("option",{value:"",children:"All Folders"}),ae.map(c=>e.jsx("option",{value:c.id,children:" ".repeat(c.depth)+c.name},c.id))]})]}),e.jsxs("div",{className:"min-w-[200px]",children:[e.jsx("label",{htmlFor:"export-format",className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Format"}),e.jsx("select",{id:"export-format",value:t,onChange:c=>s(c.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-brand-500/50",children:de.map(c=>e.jsx("option",{value:c.id,children:c.label},c.id))}),e.jsx("p",{className:"text-[11px] text-gray-500 mt-1",children:le.hint})]}),e.jsxs("button",{onClick:()=>Xe(d||void 0),disabled:V.isPending,className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm font-medium flex items-center gap-2 transition-colors disabled:opacity-50",children:[V.isPending?e.jsx(ve,{size:16,className:"animate-spin"}):e.jsx(te,{size:16}),"Export"]})]}),H&&e.jsxs("div",{className:"space-y-3 border-t border-white/5 pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-gray-400",children:[K.length," test case",K.length!==1?"s":""," • ",t==="xlsx"?"preview of the Test cases sheet":`${(_e/1024).toFixed(1)} KB`," • ",le.label]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>Ve(H),className:"flex items-center gap-1.5 text-xs text-brand-300 hover:text-brand-200 transition-colors",children:[e.jsx(it,{size:12}),q?"Copied!":"Copy"]}),e.jsxs("button",{onClick:Ue,className:"flex items-center gap-1.5 text-xs bg-emerald-600 hover:bg-emerald-500 text-white px-3 py-1.5 rounded-lg font-medium transition-colors",children:[e.jsx(te,{size:12}),"Download ",le.label]})]})]}),e.jsxs("pre",{className:"bg-surface-0 border border-white/5 rounded-lg p-3 text-xs text-gray-300 font-mono max-h-64 overflow-auto whitespace-pre-wrap",children:[H.slice(0,5e3),H.length>5e3?`
|
|
22
|
-
|
|
23
|
-
... (truncated preview)`:""]})]})]})]}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-100 mb-1 flex items-center gap-2",children:[e.jsx(se,{size:20,className:"text-brand-300"}),"Import Test Cases"]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Import test cases from JSON or CSV files"}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center bg-surface-2 border border-white/10 rounded-lg p-0.5",children:[e.jsxs("button",{onClick:()=>b("file"),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center gap-1.5 ${
|
|
24
|
-
|
|
25
|
-
JSON: [{ "title": "...", "steps": [...] }]
|
|
26
|
-
CSV: Title,Priority,Type,Steps (Action),Steps (Expected Result)`,className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder-gray-500 font-mono focus:outline-none focus:border-brand-500/50 resize-y"})]}),e.jsxs("div",{className:"flex items-end gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex-1 min-w-[180px] max-w-xs",children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Target Folder"}),e.jsxs("select",{value:d,onChange:c=>l(c.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-brand-500/50",children:[e.jsx("option",{value:"",children:"Root (No folder)"}),ae.map(c=>e.jsx("option",{value:c.id,children:" ".repeat(c.depth)+c.name},c.id))]})]}),e.jsxs("button",{onClick:We,disabled:_.isPending||!r.trim(),className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-5 py-2 text-sm font-medium flex items-center gap-2 transition-colors disabled:opacity-50",children:[_.isPending?e.jsx(ve,{size:16,className:"animate-spin"}):e.jsx(se,{size:16}),"Import Test Cases"]}),r&&e.jsx("button",{onClick:()=>{a(""),f(null)},className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",children:"Clear"})]}),m&&e.jsx("div",{className:`rounded-lg p-3 text-sm ${m.error?"bg-red-500/10 border border-red-500/20 text-red-400":"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400"}`,children:m.error?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Te,{size:16}),e.jsx("span",{children:m.error})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(G,{size:16}),e.jsxs("span",{className:"font-medium",children:[m.imported??m.count??0," test case",(m.imported??m.count??0)!==1?"s":""," imported successfully"]})]}),((
|
|
27
|
-
"title": "Verify login",
|
|
28
|
-
"priority": "high",
|
|
29
|
-
"type": "functional",
|
|
30
|
-
"steps": [
|
|
31
|
-
{ "action": "Go to login",
|
|
32
|
-
"expectedResult": "Page loads" }
|
|
33
|
-
],
|
|
34
|
-
"tags": ["auth", "smoke"]
|
|
35
|
-
}]`})]}),e.jsxs("div",{className:"border border-white/5 rounded-lg p-3 bg-surface-0",children:[e.jsxs("p",{className:"text-xs text-gray-400 mb-2 font-bold flex items-center gap-1.5",children:[e.jsx(Me,{size:12,className:"text-brand-300"})," CSV Format"]}),e.jsx("pre",{className:"text-[10px] text-gray-500 font-mono whitespace-pre-wrap leading-relaxed",children:`Title,Priority,Type,Tags,Steps (Action),Steps (Expected Result),Steps (Test Data)
|
|
36
|
-
"Verify login","high","functional","auth, smoke","Go to login | Enter creds | Click submit","Page loads | Fields shown | Dashboard"," | user@test.com | "`}),e.jsxs("p",{className:"text-[10px] text-gray-600 mt-2",children:["Separate multiple steps with ",e.jsx("span",{className:"text-gray-400 font-medium",children:"|"})," (pipe)"]})]})]})]})]}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-100 mb-1 flex items-center gap-2",children:[e.jsx(nt,{size:20,className:"text-brand-300"}),"Import from Third-Party Tools or local files"]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Import test cases exported from tools like TestRail, Zephyr, Xray, PractiTest, qTest — or from any other tool, or your own local test case files."}),e.jsx(yt,{}),gt]})]})})})}function yt(){const n=Ke(),o=()=>{ot(n,{prompt:"I want to import test cases from a third-party test management tool into Testver. I will upload an export file in the chat (CSV, XML, JSON, or Excel). Please read the file, extract every test case (title, priority, preconditions, steps, expected results, tags), normalize the values to match Testver's schema (priority: critical|high|medium|low; type: web|ui|api|mobile|database|integration|e2e|security|performance|usability|accessibility|compatibility|localization), and create them via the test-management tools. Report back with the count created and any rows that needed manual review.",mode:"api"})};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-6",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-brand-500/15 flex items-center justify-center flex-shrink-0",children:e.jsx(Ne,{size:20,className:"text-brand-300"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100 mb-1",children:["Import via AI Assistant — works with any tool",e.jsx("span",{className:"ml-2 inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wider bg-brand-500/15 text-brand-300 border border-brand-500/30 align-middle",children:"API mode"})]}),e.jsxs("p",{className:"text-sm text-gray-400 leading-relaxed",children:["The AI Assistant can read an export file from tools like ",e.jsx("em",{className:"not-italic text-gray-300",children:"TestRail, Zephyr, Xray, PractiTest, qTest"})," — or from ",e.jsx("em",{className:"not-italic text-gray-300",children:"any other tool"}),", or your own local test case files — and create the test cases in Testver for you. Clicking the button below opens the AI Assistant in ",e.jsx("em",{className:"not-italic text-gray-300",children:"API mode"})," with a pre-filled prompt. Upload your export in the chat and the AI will parse the structure, map fields, and create everything in the right folder."]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mb-5",children:[e.jsxs("div",{className:"rounded-lg border border-white/5 bg-surface-2/50 p-3.5",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider font-semibold text-gray-500 mb-2",children:"Supported export formats"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:[{ext:"CSV",icon:e.jsx(Me,{size:11})},{ext:"XML",icon:e.jsx(ze,{size:11})},{ext:"JSON",icon:e.jsx($e,{size:11})}].map(i=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-md bg-white/[0.06] border border-white/10 text-[11px] text-gray-200 font-medium",children:[i.icon,i.ext]},i.ext))})]}),e.jsxs("div",{className:"rounded-lg border border-white/5 bg-surface-2/50 p-3.5",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider font-semibold text-gray-500 mb-2",children:"What the AI does for you"}),e.jsxs("ul",{className:"text-[12px] text-gray-300 space-y-1 leading-relaxed",children:[e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(G,{size:11,className:"text-emerald-400 mt-0.5 flex-shrink-0"})," Detects the source tool's format automatically"]}),e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(G,{size:11,className:"text-emerald-400 mt-0.5 flex-shrink-0"})," Maps fields (title, priority, steps, preconditions, tags)"]}),e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(G,{size:11,className:"text-emerald-400 mt-0.5 flex-shrink-0"})," Normalizes priority and type to Testver's schema"]}),e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(G,{size:11,className:"text-emerald-400 mt-0.5 flex-shrink-0"})," Reports per-row errors so nothing is silently dropped"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("button",{onClick:o,className:"flex items-center gap-2 bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2.5 text-sm font-semibold transition-colors shadow-sm",children:[e.jsx(Ne,{size:14})," Import with AI Assistant"]}),e.jsxs("span",{className:"text-xs text-gray-500",children:["Opens the AI Assistant in ",e.jsx("span",{className:"text-brand-300 font-medium",children:"API mode"})," with a pre-filled import prompt. Upload your export file there."]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-white/5 text-[11px] text-gray-500 leading-relaxed",children:[e.jsx("strong",{className:"text-gray-400 font-medium",children:"Tip:"})," the AI works best when columns/tags are clearly named in your export (e.g. ",e.jsx("em",{className:"not-italic text-gray-400",children:"Test Case Name"}),", ",e.jsx("em",{className:"not-italic text-gray-400",children:"Priority"}),", ",e.jsx("em",{className:"not-italic text-gray-400",children:"Steps"}),"). For very large exports (1000+ test cases), split the file into chunks of ~500 per upload for the smoothest run."]})]})}export{Rt as ImportExportPage};
|
|
1
|
+
import{r as z,j as e,u as Ke}from"./vendor-react-DOVfxdUy.js";import{r as Qe,w as Ye}from"./excel-BrxuVus5.js";import{aj as et,ak as tt,J as st}from"./useTestManagement-ommXjx0q.js";import{b as rt}from"./index-BlA8ntjb.js";import{h as ot}from"./aiHandoff-vhtR29Fh.js";import{a6 as te,a1 as ve,ai as it,be as se,aJ as ze,s as G,aq as Te,cc as $e,j as Me,am as nt,S as Ne}from"./vendor-icons-Cm92aSc5.js";import"./vendor-excel-BFHGVHVC.js";import"./vendor-query-DkZSMtfn.js";const de=[{id:"json",label:"JSON",ext:"json",mime:"application/json",hint:"Everything, re-importable into Testver"},{id:"csv",label:"CSV",ext:"csv",mime:"text/csv",hint:"One row per case, re-importable into Testver"},{id:"xlsx",label:"Excel",ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",hint:"A Test cases sheet and a Steps sheet"},{id:"gherkin",label:"Gherkin",ext:"feature",mime:"text/plain",hint:"A BDD .feature file — Given / When / Then"},{id:"xray",label:"Xray CSV",ext:"csv",mime:"text/csv",hint:"Xray's Test Case Importer — one row per step"},{id:"testrail",label:"TestRail CSV",ext:"csv",mime:"text/csv",hint:"TestRail's CSV import — numbered steps"},{id:"zephyr",label:"Zephyr Scale CSV",ext:"csv",mime:"text/csv",hint:"Zephyr Scale's CSV import — one row per step"}];function at(n){return`"${String(n??"").replace(/\r\n?/g,`
|
|
2
|
+
`).replace(/"/g,'""')}"`}function oe(n){return n.map(o=>o.map(at).join(",")).join(`\r
|
|
3
|
+
`)}function Fe(n){const o=[];let i=[],t="",s=!1;const r=n.replace(/^/,""),a=()=>{i.push(t.trim()),t=""},d=()=>{a(),i.some(l=>l!=="")&&o.push(i),i=[]};for(let l=0;l<r.length;l++){const m=r[l];s?m==='"'?r[l+1]==='"'?(t+='"',l++):s=!1:t+=m:m==='"'&&t.trim()===""?s=!0:m===","?a():m===`
|
|
4
|
+
`||m==="\r"?(m==="\r"&&r[l+1]===`
|
|
5
|
+
`&&l++,d()):t+=m}return d(),o}const J=n=>String(n??"").replace(/\s*\r?\n\s*/g," ").trim(),ie=n=>(n.steps??[]).filter(o=>(o.action??"").trim()||(o.expectedResult??"").trim()),Re=n=>n.map((o,i)=>`${i+1}. ${J(o)}`).join(`
|
|
6
|
+
`),ee=n=>n.id?`${n.id}: ${n.title}`:n.title,Ee={critical:{jira:"Highest",testrail:"Critical",zephyr:"High"},high:{jira:"High",testrail:"High",zephyr:"High"},medium:{jira:"Medium",testrail:"Medium",zephyr:"Normal"},low:{jira:"Low",testrail:"Low",zephyr:"Low"}},he=(n,o)=>{var i;return((i=Ee[String(n??"medium").toLowerCase()])==null?void 0:i[o])??Ee.medium[o]},Oe=n=>n.trim().replace(/\s+/g,"_");function lt(n){const o=["Title","Priority","Type","Tags","Preconditions","Steps (Action)","Steps (Expected Result)","Steps (Test Data)","ID","Folder","Status","Review Status","Automation","Requirements","Sources","Strategy","Automatable","Automatable Reason","Grounding","Spec Drift"],i=n.map(t=>{const s=t.steps??[];return[t.title??"",t.priority??"",t.type??"",(t.tags??[]).join(", "),t.preconditions??"",s.map(r=>J(r.action)).join(" | "),s.map(r=>J(r.expectedResult)).join(" | "),s.map(r=>J(r.testData)).join(" | "),t.id??"",t.folder??"",t.status??"",t.reviewStatus??"",t.automationStatus??"",J((t.requirements??[]).map(ee).join("; ")),J((t.sources??[]).map(r=>r.title).join("; ")),t.strategy??"",t.automatable??"",J(t.automatableReason),t.grounding??"",t.specDrift?J(`Requirement says: ${t.specDrift.requirementSays} — app does: ${t.specDrift.appDoes}`):""]});return oe([o,...i])}function ct(n){const o=["Test ID","Summary","Description","Priority","Labels","Test Type","Action","Data","Expected Result"],i=[];return n.forEach((t,s)=>{const r=t.id||`T${s+1}`,a=[t.preconditions?`Preconditions: ${t.preconditions}`:"",...(t.requirements??[]).map(m=>`Verifies ${ee(m)}`)].filter(Boolean).join(`
|
|
7
|
+
`),d=[r,t.title,a,he(t.priority,"jira"),(t.tags??[]).map(Oe).join(" "),"Manual"],l=ie(t);if(l.length===0){i.push([...d,"","",""]);return}l.forEach((m,f)=>i.push([...f===0?d:[r,"","","","",""],m.action??"",m.testData??"",m.expectedResult??""]))}),oe([o,...i])}function pt(n){const o=["Title","Section","Type","Priority","Preconditions","Steps","Expected Result","References"],i=n.map(t=>{const s=ie(t);return[t.title,t.folder??"","Functional",he(t.priority,"testrail"),t.preconditions??"",Re(s.map(r=>r.testData?`${r.action} (data: ${J(r.testData)})`:r.action??"")),Re(s.map(r=>r.expectedResult??"")),(t.requirements??[]).map(r=>r.externalId||r.id||"").filter(Boolean).join(", ")]});return oe([o,...i])}function dt(n){const o=["Name","Objective","Precondition","Folder","Status","Priority","Labels","Test Script (Step-by-Step) - Step","Test Script (Step-by-Step) - Test Data","Test Script (Step-by-Step) - Expected Result"],i=[];for(const t of n){const s=(t.requirements??[]).map(l=>`Verifies ${ee(l)}`).join(`
|
|
8
|
+
`),r=t.folder?`/${t.folder.split(" / ").join("/")}`:"",a=[t.title,s,t.preconditions??"",r,"Draft",he(t.priority,"zephyr"),(t.tags??[]).map(Oe).join(",")],d=ie(t);if(d.length===0){i.push([...a,"","",""]);continue}d.forEach((l,m)=>i.push([...m===0?a:["","","","","","",""],l.action??"",l.testData??"",l.expectedResult??""]))}return oe([o,...i])}const me=n=>`@${n.trim().replace(/[\s@]+/g,"-").replace(/[^\p{L}\p{N}_\-.:]/gu,"")}`,Q=n=>J(n)||"(empty)";function mt(n,o="Test cases"){const i=[`Feature: ${Q(o)}`,""],t=new Map;for(const r of n){const a=r.folder??"";t.set(a,[...t.get(a)??[],r])}const s=t.size>1;for(const[r,a]of t){const d=s?" ":" ";s&&i.push(` Rule: ${r||"No folder"}`,"");for(const l of a){const m=[l.id?me(l.id):"",l.priority?me(`priority-${l.priority}`):"",...(l.tags??[]).map(me),l.automatable==="manual"?"@manual":""].filter(p=>p.length>1);m.length&&i.push(`${d}${[...new Set(m)].join(" ")}`),i.push(`${d}Scenario: ${Q(l.title)}`);for(const p of l.requirements??[])i.push(`${d} # Verifies ${J(ee(p))}`);let f="";const w=p=>{const h=f===p?"And":p;return f=p,h},b=String(l.preconditions??"").split(/\r?\n|;\s+/).map(p=>p.trim()).filter(Boolean);for(const p of b)i.push(`${d} ${w("Given")} ${Q(p)}`);for(const p of ie(l))(p.action??"").trim()&&(i.push(`${d} ${w("When")} ${Q(p.action)}`),(p.testData??"").trim()&&i.push(`${d} """`,...String(p.testData).split(/\r?\n/).map(h=>`${d} ${h.replace(/"""/g,'\\"\\"\\"')}`),`${d} """`)),(p.expectedResult??"").trim()&&i.push(`${d} ${w("Then")} ${Q(p.expectedResult)}`);i.push("")}}return i.join(`
|
|
9
|
+
`).replace(/\n+$/,`
|
|
10
|
+
`)}function ut(n){const o=["ID","Title","Folder","Priority","Type","Status","Review Status","Automation","Preconditions","Tags","Requirements","Sources","Strategy","Automatable","Automatable Reason","Grounding","Spec Drift","Steps"],i=n.map(s=>[s.id??"",s.title,s.folder??"",s.priority??"",s.type??"",s.status??"",s.reviewStatus??"",s.automationStatus??"",s.preconditions??"",(s.tags??[]).join(", "),(s.requirements??[]).map(ee).join(`
|
|
11
|
+
`),(s.sources??[]).map(r=>r.title).join(`
|
|
12
|
+
`),s.strategy??"",s.automatable??"",s.automatableReason??"",s.grounding??"",s.specDrift?`Requirement says: ${s.specDrift.requirementSays}
|
|
13
|
+
App does: ${s.specDrift.appDoes}`:"",(s.steps??[]).length]),t=[];for(const s of n)(s.steps??[]).forEach((r,a)=>t.push([s.id??"",s.title,r.stepNumber??a+1,r.action??"",r.expectedResult??"",r.testData??""]));return[{name:"Test cases",rows:[o,...i],widths:[10,48,24,10,12,10,14,12,36,20,36,24,14,12,36,12,36,7]},{name:"Steps",rows:[["Test case ID","Test case","Step","Action","Expected result","Test data"],...t],widths:[10,40,6,48,48,24]}]}function ue(n,o,i){switch(n){case"json":return JSON.stringify(o,null,2);case"csv":return lt(o);case"gherkin":return mt(o,i);case"xray":return ct(o);case"testrail":return pt(o);case"zephyr":return dt(o)}}function L(n){return n?n.replace(/<br\s*\/?>/gi,`
|
|
14
|
+
`).replace(/<\/li>/gi,`
|
|
15
|
+
`).replace(/<\/p>/gi,`
|
|
16
|
+
`).replace(/<\/div>/gi,`
|
|
17
|
+
`).replace(/<[^>]*>/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/ /g," ").replace(/\n{3,}/g,`
|
|
18
|
+
|
|
19
|
+
`).trim():""}function B(n){if(!n)return[];const o=L(n),i=o.split(/\n\s*(?:\d+[\.\)]\s*|Step\s+\d+[:\s])/i).map(r=>r.trim()).filter(Boolean),t=/^(?:1[.)]\s+|Step\s+1[:\s]\s*)/i;if(i.length>1)return i.map((r,a)=>a===0?r.replace(t,"").trim():r);const s=o.split(`
|
|
20
|
+
`).map(r=>r.trim()).filter(Boolean);return s.length===1?[s[0].replace(/^1[.)]\s+/,"").trim()].filter(Boolean):s}function Z(n){if(!n)return"medium";const o=String(n).toLowerCase().trim();return["1","p1","critical","blocker","highest"].includes(o)?"critical":["2","p2","high","major"].includes(o)?"high":["3","p3","medium","normal","moderate"].includes(o)?"medium":["4","p4","low","minor","trivial","lowest"].includes(o)?"low":"medium"}function Y(n){if(!n)return"functional";const o=n.toLowerCase().trim();return{functional:"functional",regression:"regression",smoke:"smoke",sanity:"sanity",e2e:"e2e","end-to-end":"e2e","end to end":"e2e",integration:"integration",performance:"performance",security:"security",accessibility:"accessibility",acceptance:"functional",automated:"functional",manual:"functional",exploratory:"functional",usability:"functional"}[o]||"functional"}function ne(n){const o=Fe(n);if(o.length<2)return{headers:[],rows:[]};const i=o[0].map(s=>s.replace(/^"|"$/g,"")),t=o.slice(1).map(s=>{const r={};return i.forEach((a,d)=>{r[a]=s[d]||""}),r});return{headers:i,rows:t}}function xe(n,o,i){var t,s;if(i)return{tool:i,format:o};if(o==="xml"){const r=n;if(r.includes("<suite")||r.includes("<sections")||r.includes("<cases>"))return{tool:"testrail",format:"xml"};if(r.includes("<testcase")||r.includes("<teststep"))return{tool:"zephyr",format:"xml"}}if(o==="csv"){const a=((t=n.split(`
|
|
21
|
+
`)[0])==null?void 0:t.toLowerCase())||"";if(a.includes("section")&&a.includes("title")&&(a.includes("suite")||a.includes("references")))return{tool:"testrail",format:"csv"};if(a.includes("summary")&&(a.includes("issue type")||a.includes("test type")||a.includes("manual test")))return{tool:"xray",format:"csv"};if(a.includes("name")&&a.includes("test script (step-by-step)"))return{tool:"zephyr",format:"csv"};if(a.includes("name")&&a.includes("steps")&&a.includes("expected"))return{tool:"practitest",format:"csv"}}if(o==="json")try{const a=JSON.parse(n),d=Array.isArray(a)?a:a.issues||a.tests||[];if(d.length>0&&((s=d[0].fields)!=null&&s.summary))return{tool:"xray",format:"json"}}catch{}return null}function xt(n){const o=n.map(i=>i.toLowerCase());return o.some(i=>i.includes("module"))&&o.some(i=>i.includes("test step"))?"qtest":o.some(i=>i.includes("folder"))||o.some(i=>i.includes("label"))?"zephyr":"qtest"}function fe(n){const{headers:o,rows:i}=ne(n),t=[],s={},r=x=>o.find(S=>x.some(R=>S.toLowerCase().includes(R.toLowerCase()))),a=r(["Title","Case Title","Name"])||"Title",d=r(["Priority"])||"Priority",l=r(["Type","Test Type"])||"Type",m=r(["Section","Suite","Folder"])||"Section",f=r(["Preconditions","Precondition"])||"Preconditions",w=r(["Steps","Test Steps","Steps (Actions)"])||"Steps",b=r(["Expected Result","Expected Results","Expected"])||"Expected Result",p=r(["References","Refs"])||"References";s[a]="title",s[d]="priority",s[l]="type",s[m]="tags (section)",s[f]="preconditions",s[w]="steps",s[b]="expectedResult";const h=i.filter(x=>{var S;return(S=x[a])==null?void 0:S.trim()}).map(x=>{var T;const S=[];x[m]&&S.push(x[m]),x[p]&&S.push(...x[p].split(",").map(P=>P.trim()).filter(Boolean));const R=x[w]||"",E=x[b]||"",u=B(R),v=B(E),N=u.length>0?u.map((P,g)=>({action:P,expectedResult:v[g]||""})):E?[{action:R.trim()||"See expected result",expectedResult:E.trim()}]:[];return{title:x[a].trim(),priority:Z(x[d]),type:Y(x[l]),preconditions:((T=x[f])==null?void 0:T.trim())||"",steps:N.length>0?N:void 0,tags:S.length>0?S:void 0}});return h.length===0&&t.push("No test cases found. Check if the CSV matches TestRail export format."),{testCases:h,detectedTool:"TestRail (CSV)",warnings:t,fieldMapping:s}}function De(n){const i=new DOMParser().parseFromString(n,"text/xml"),t=[],s=i.querySelector("parsererror");if(s)return{testCases:[],detectedTool:"TestRail (XML)",warnings:["Invalid XML: "+(s.textContent||"").slice(0,200)],fieldMapping:{}};const r={title:"title",priority_id:"priority",type:"type",preconds:"preconditions","steps_separated/step":"steps","section/name":"tags"},a=[];return i.querySelectorAll("case").forEach(l=>{var R,E,u,v,N,T,P,g,C;const m=(E=(R=l.querySelector("title"))==null?void 0:R.textContent)==null?void 0:E.trim();if(!m)return;const f=(u=l.querySelector("priority_id"))==null?void 0:u.textContent,w=(v=l.querySelector("type"))==null?void 0:v.textContent,b=((T=(N=l.querySelector("custom preconds"))==null?void 0:N.textContent)==null?void 0:T.trim())||"",p=l.closest("section"),h=(g=(P=p==null?void 0:p.querySelector(":scope > name"))==null?void 0:P.textContent)==null?void 0:g.trim(),x=[],S=l.querySelectorAll("custom steps_separated step");if(S.length>0)S.forEach(y=>{var O,q;const M=L(((O=y.querySelector("content"))==null?void 0:O.textContent)||""),$=L(((q=y.querySelector("expected"))==null?void 0:q.textContent)||"");M&&x.push({action:M,expectedResult:$})});else{const y=(C=l.querySelector("custom steps"))==null?void 0:C.textContent;y&&B(y).forEach(M=>x.push({action:M}))}a.push({title:m,priority:Z(f),type:Y(w||void 0),preconditions:L(b),steps:x.length>0?x:void 0,tags:h?[h]:void 0})}),a.length===0&&t.push("No <case> elements found in XML."),{testCases:a,detectedTool:"TestRail (XML)",warnings:t,fieldMapping:r}}function re(n,o){const i=o.toLowerCase(),t=n.getElementsByTagName?n.getElementsByTagName("*"):n.querySelectorAll("*"),s=[];for(let r=0;r<t.length;r++){const a=t[r];a.tagName.toLowerCase()===i&&s.push(a)}return s}function U(n,...o){const i=o.map(t=>t.toLowerCase());for(const t of Array.from(n.children))if(i.includes(t.tagName.toLowerCase()))return t;return null}function Ae(n){const i=new DOMParser().parseFromString(n,"text/xml"),t=[];if(i.querySelector("parsererror"))return{testCases:[],detectedTool:"Zephyr (XML)",warnings:["Invalid XML"],fieldMapping:{}};const r={name:"title",priority:"priority","labels/label | folder":"tags","testScript/steps/step/description":"steps.action","testScript/steps/step/expectedResult":"steps.expectedResult","testScript/steps/step/testData":"steps.testData","objective | precondition":"preconditions"},a=[];return re(i,"testCase").forEach(l=>{var v,N,T,P,g;const m=U(l,"name"),f=((v=m==null?void 0:m.textContent)==null?void 0:v.trim())||l.getAttribute("name")||"";if(!f)return;const w=U(l,"priority"),b=((N=w==null?void 0:w.textContent)==null?void 0:N.trim())||l.getAttribute("priority")||"",p=[],h=U(l,"folder");(T=h==null?void 0:h.textContent)!=null&&T.trim()&&p.push(h.textContent.trim());const x=U(l,"labels");if(x)for(const C of Array.from(x.children)){const y=(P=C.textContent)==null?void 0:P.trim();y&&p.push(y)}const S=L(((g=U(l,"precondition","preconditions","objective"))==null?void 0:g.textContent)||""),R=[],E=U(l,"testScript");let u=[];if(E){const C=U(E,"steps");C&&(u=Array.from(C.children).filter(y=>y.tagName.toLowerCase()==="step"))}u.length===0&&(u=re(l,"step").filter(C=>{var y;return l.contains(((y=C.parentElement)==null?void 0:y.parentElement)||null),!0}),u.length===0&&(u=[...re(l,"teststep"),...re(l,"test-step")])),u.forEach(C=>{var O,q,X,V;const y=L(((O=U(C,"description","action","step"))==null?void 0:O.textContent)||((q=C.querySelector("content"))==null?void 0:q.textContent)||""),M=L(((X=U(C,"expectedResult","expected","result"))==null?void 0:X.textContent)||""),$=L(((V=U(C,"testData","test-data","data"))==null?void 0:V.textContent)||"");y&&R.push({action:y,expectedResult:M,testData:$||void 0})}),a.push({title:f,priority:Z(b),preconditions:S,steps:R.length>0?R:void 0,tags:p.length>0?p:void 0})}),a.length===0&&t.push("No <testCase> elements found in XML. Expected a Zephyr Scale / TM4J export with <project><testCases><testCase>… structure."),{testCases:a,detectedTool:"Zephyr (XML)",warnings:t,fieldMapping:r}}function Pe(n,o){var R,E;const i=[],t=u=>n.find(v=>u.some(N=>v.toLowerCase().includes(N.toLowerCase()))),s=t(["Test Case Name","Test Case","Name","Title","Summary"])||n[0]||"Name",r=t(["Priority"])||"",a=t(["Folder","Component"])||"",d=t(["Label","Tag"])||"",l=t(["Objective"])||"",m=t(["Precondition"])||"",f=t(["Step Description","Test Step Description","Test Script (Step-by-Step) - Description","Step Action","Test Step","Action","Description","Step"])||"",w=t(["Expected Result","Expected Results","Step Expected Result","Test Script (Step-by-Step) - Expected Result","Expected"])||"",b=t(["Test Data","Step Test Data","Test Script (Step-by-Step) - Test Data","Data"])||"",p={[s]:"title"};r&&(p[r]="priority"),a&&(p[a]="tags (folder)"),d&&(p[d]="tags (labels)"),l&&(p[l]="preconditions (objective)"),m&&(p[m]="preconditions"),f&&(p[f]="steps.action"),w&&(p[w]="steps.expectedResult"),b&&(p[b]="steps.testData");const h=u=>{var P,g;const v=[],N=(P=u[a])==null?void 0:P.trim();N&&v.push(N);const T=(g=u[d])==null?void 0:g.trim();return T&&T.split(/[,;|]/).map(C=>C.trim()).filter(Boolean).forEach(C=>v.push(C)),v},x=f!==""&&o.some(u=>{var v,N,T;return!((v=u[s])!=null&&v.trim())&&(((N=u[f])==null?void 0:N.trim())||((T=u[w])==null?void 0:T.trim()))}),S=[];if(x){let u=null,v=[];const N=()=>{u&&(u.steps=v.length>0?v:void 0,S.push(u)),u=null,v=[]};for(const T of o){const P=(R=T[s])==null?void 0:R.trim();if(P){N(),u={title:P,priority:Z(T[r]),preconditions:L(T[m]||T[l]||""),steps:void 0,tags:void 0};const g=h(T);g.length>0&&(u.tags=g)}if(u){const g=L(T[f]||""),C=L(T[w]||""),y=L(T[b]||"");(g||C||y)&&v.push({action:g||"(no description)",expectedResult:C||void 0,testData:y||void 0})}}N()}else for(const u of o){const v=(E=u[s])==null?void 0:E.trim();if(!v)continue;const N=L(u[f]||""),T=L(u[w]||""),P=B(N),g=B(T),C=P.length>0?P.map((M,$)=>({action:M,expectedResult:g[$]||""})):N?[{action:N,expectedResult:T||void 0}]:[],y=h(u);S.push({title:v,priority:Z(u[r]),preconditions:L(u[m]||u[l]||""),steps:C.length>0?C:void 0,tags:y.length>0?y:void 0})}return S.length===0?i.push('No test cases parsed from the spreadsheet. Verify the export matches a Zephyr Scale / TM4J template (expected a "Name" column plus optional Test Script step columns).'):f===""&&i.push('No step column was detected — only titles were imported. Add columns like "Test Script (Step-by-Step) - Description" / "Expected Result" to capture steps.'),{testCases:S,detectedTool:"Zephyr (Excel)",warnings:i,fieldMapping:p}}function Le(n){var E,u,v,N,T,P;const{headers:o,rows:i}=ne(n),t=[],s=g=>o.find(C=>g.some(y=>C.toLowerCase().includes(y.toLowerCase()))),r=s(["Summary","Title","Name"])||"Summary",a=s(["Priority"])||"Priority",d=s(["Test Type","Issue Type","Type"])||"",l=s(["Manual Test Steps","Steps","Test Steps"])||"",m=s(["Expected Result","Expected Results"])||"",f=s(["Labels","Tags","Components"])||"",w=s(["Preconditions","Precondition","Description"])||"",b={[r]:"title",[a]:"priority"};d&&(b[d]="type"),l&&(b[l]="steps"),f&&(b[f]="tags");const p=o.find(g=>["action","step","step action"].includes(g.toLowerCase()))||"",h=o.find(g=>["data","test data","step data"].includes(g.toLowerCase()))||"",x=o.find(g=>["result","expected result","expected"].includes(g.toLowerCase()))||"",S=o.find(g=>["tcid","test id","issue id","test case identifier","id"].includes(g.toLowerCase()))||"";if(p&&S){const g=new Map;for(const y of i){const M=(E=y[S])==null?void 0:E.trim();if(!M)continue;let $=g.get(M);if(!$&&((u=y[r])!=null&&u.trim())){const V=y[f]?y[f].split(/[,;\s]+/).map(_=>_.trim()).filter(Boolean):[];$={title:y[r].trim(),priority:Z(y[a]),type:Y(y[d]),preconditions:((v=y[w])==null?void 0:v.trim())||"",tags:V.length>0?V:void 0},g.set(M,$)}if(!$)continue;const O=((N=y[p])==null?void 0:N.trim())||"",q=((T=y[x])==null?void 0:T.trim())||"",X=((P=y[h])==null?void 0:P.trim())||"";(O||q||X)&&($.steps=[...$.steps??[],{action:O||"(no description)",expectedResult:q,...X?{testData:X}:{}}])}const C=[...g.values()];return C.length===0&&t.push("No test cases found. Each test needs a row with its Summary."),{testCases:C,detectedTool:"Xray (CSV)",warnings:t,fieldMapping:{...b,[S]:"test id",[p]:"steps.action",...x?{[x]:"steps.expectedResult"}:{},...h?{[h]:"steps.testData"}:{}}}}return{testCases:i.filter(g=>{var C;return(C=g[r])==null?void 0:C.trim()}).map(g=>{var X;const C=g[f]?g[f].split(/[,;]/).map(V=>V.trim()).filter(Boolean):[],y=g[l]||"",M=g[m]||"",$=B(y),O=B(M),q=$.length>0?$.map((V,_)=>({action:V,expectedResult:O[_]||""})):[];return{title:g[r].trim(),priority:Z(g[a]),type:Y(g[d]),preconditions:((X=g[w])==null?void 0:X.trim())||"",steps:q.length>0?q:void 0,tags:C.length>0?C:void 0}}),detectedTool:"Xray (CSV)",warnings:t,fieldMapping:b}}function ft(n){const o=[];let i;try{i=JSON.parse(n)}catch{return{testCases:[],detectedTool:"Xray (JSON)",warnings:["Invalid JSON format"],fieldMapping:{}}}const t=Array.isArray(i)?i:i.issues||i.tests||[],s={"fields.summary":"title","fields.priority.name":"priority","fields.labels":"tags","fields.description":"preconditions"};return{testCases:t.filter(a=>{var d;return(d=a.fields)==null?void 0:d.summary}).map(a=>{var f,w;const d=a.fields,l=[];for(const[b,p]of Object.entries(d||{}))if(b.startsWith("customfield_")&&Array.isArray(p)){const h=p;if(h.length>0&&(h[0].action||h[0].step||h[0].content)){h.forEach(x=>{const S=L(x.action||x.step||x.content||""),R=L(x.result||x.expected||x.expectedResult||""),E=L(x.data||x.testData||"");S&&l.push({action:S,expectedResult:R,testData:E||void 0})}),s[b]="steps";break}}const m=Array.isArray(d.labels)?d.labels:[];return{title:d.summary,priority:Z(((f=d.priority)==null?void 0:f.name)||d.priority),type:Y((w=d.issuetype)==null?void 0:w.name),preconditions:L(d.description||""),steps:l.length>0?l:void 0,tags:m.length>0?m:void 0}}),detectedTool:"Xray (JSON)",warnings:o,fieldMapping:s}}function ke(n){const{headers:o,rows:i}=ne(n),t=[],s=p=>o.find(h=>p.some(x=>h.toLowerCase().includes(x.toLowerCase()))),r=s(["Name","Title","Test Name"])||o[0]||"Name",a=s(["Priority"])||"",d=s(["Steps","Test Steps","Step Description"])||"",l=s(["Expected Results","Expected Result","Expected"])||"",m=s(["Preconditions","Precondition"])||"",f=s(["Tags","Labels","Custom Fields"])||"",w={[r]:"title"};return a&&(w[a]="priority"),d&&(w[d]="steps"),l&&(w[l]="expectedResult"),{testCases:i.filter(p=>{var h;return(h=p[r])==null?void 0:h.trim()}).map(p=>{var E;const h=B(p[d]||""),x=B(p[l]||""),S=h.length>0?h.map((u,v)=>({action:u,expectedResult:x[v]||""})):[],R=p[f]?p[f].split(/[,;]/).map(u=>u.trim()).filter(Boolean):[];return{title:p[r].trim(),priority:Z(p[a]),preconditions:((E=p[m])==null?void 0:E.trim())||"",steps:S.length>0?S:void 0,tags:R.length>0?R:void 0}}),detectedTool:"PractiTest (CSV)",warnings:t,fieldMapping:w}}function Ie(n,o){const i=[],t=b=>n.find(p=>b.some(h=>p.toLowerCase().includes(h.toLowerCase()))),s=t(["Name","Test Case Name","Title","Summary"])||n[0]||"Name",r=t(["Priority"])||"",a=t(["Test Steps","Steps","Step Description","Test Step Description"])||"",d=t(["Expected Result","Expected Results","Expected"])||"",l=t(["Preconditions","Precondition","Pre-Conditions"])||"",m=t(["Module","Folder","Component"])||"",f={[s]:"title"};return r&&(f[r]="priority"),a&&(f[a]="steps"),d&&(f[d]="expectedResult"),m&&(f[m]="tags (module)"),{testCases:o.filter(b=>{var p;return(p=b[s])==null?void 0:p.trim()}).map(b=>{var u;const p=L(b[a]||""),h=L(b[d]||""),x=B(p),S=B(h),R=x.length>0?x.map((v,N)=>({action:v,expectedResult:S[N]||""})):[],E=[];return(u=b[m])!=null&&u.trim()&&E.push(b[m].trim()),{title:b[s].trim(),priority:Z(b[r]),preconditions:L(b[l]||""),steps:R.length>0?R:void 0,tags:E.length>0?E:void 0}}),detectedTool:"qTest (Excel)",warnings:i,fieldMapping:f}}async function ht(n,o,i){if(i=String(i||"").toLowerCase(),i==="xlsx"||i==="xls"){const s=await Qe(n);if(s.length===0)return{testCases:[],detectedTool:"Unknown",warnings:["Empty spreadsheet or no data rows found"],fieldMapping:{}};const r=Object.keys(s[0]),a=o||xt(r);return a==="qtest"?Ie(r,s):a==="zephyr"?Pe(r,s):Ie(r,s)}const t=n;if(i==="xml"){const s=xe(t,i,o||void 0);if((s==null?void 0:s.tool)==="testrail"||o==="testrail")return De(t);if((s==null?void 0:s.tool)==="zephyr"||o==="zephyr")return Ae(t);const r=De(t),a=Ae(t);return r.testCases.length>=a.testCases.length?r:a}if(i==="json")return ft(t);if(i==="csv"||i==="txt"){const s=xe(t,"csv",o||void 0);if((s==null?void 0:s.tool)==="zephyr"||o==="zephyr"){const{headers:a,rows:d}=ne(t);return{...Pe(a,d),detectedTool:"Zephyr (CSV)"}}if((s==null?void 0:s.tool)==="testrail"||o==="testrail")return fe(t);if((s==null?void 0:s.tool)==="xray"||o==="xray")return Le(t);if((s==null?void 0:s.tool)==="practitest"||o==="practitest")return ke(t);const r=xe(t,"csv");if(r){if(r.tool==="testrail")return fe(t);if(r.tool==="xray")return Le(t);if(r.tool==="practitest")return ke(t)}return fe(t)}return{testCases:[],detectedTool:"Unknown",warnings:[`Unsupported file format: .${i}`],fieldMapping:{}}}const gt=!1;function qe(n,o=0){var t;const i=[];for(const s of n)i.push({id:s.id,name:s.name,depth:o}),(t=s.children)!=null&&t.length&&i.push(...qe(s.children,o+1));return i}function Rt({embedded:n=!1}={}){var Ce,je;const[o,i]=z.useState(null),[t,s]=z.useState("json"),[r,a]=z.useState(""),[d,l]=z.useState(""),[m,f]=z.useState(null),[w,b]=z.useState("file"),[p,h]=z.useState(!1),[x,S]=z.useState("select"),[R,E]=z.useState(null),[u,v]=z.useState(null),[N,T]=z.useState(null),[P,g]=z.useState(!1),[C,y]=z.useState(!1),[M,$]=z.useState(""),{toast:O}=rt(),[q,X]=z.useState(!1),V=et(),_=tt(),{data:W}=st(),ge=Array.isArray(W)?W:(W==null?void 0:W.folders)??(W==null?void 0:W.tree)??[],ae=z.useMemo(()=>qe(ge),[ge]),ye=((Ce=ae.find(c=>c.id===d))==null?void 0:Ce.name)||"Test cases";function be(c){O("success",c)}function Ve(c){navigator.clipboard.writeText(c),X(!0),setTimeout(()=>X(!1),2e3)}async function Xe(c){try{const j=await V.mutateAsync(c||void 0);i(j),be("Export completed")}catch{}}function Je(c){const j=Fe(c);if(j.length<2)return[];const D=j[0].map(A=>A.trim().toLowerCase());return j.slice(1).map(A=>{const k={};D.forEach((I,Ge)=>{k[I]=A[Ge]||""});const F=k.title||k.name||k["test case"]||"",we=[],ce=(k["steps (action)"]||"").split("|").map(I=>I.trim()),pe=(k["steps (expected result)"]||"").split("|").map(I=>I.trim()),Se=(k["steps (test data)"]||"").split("|").map(I=>I.trim()),He=Math.max(ce.length,pe.length,Se.length);for(let I=0;I<He;I++)(ce[I]||pe[I])&&we.push({action:ce[I]||"",expectedResult:pe[I]||"",testData:Se[I]||""});return{title:F,priority:k.priority||"medium",type:k.type||"functional",tags:(k.tags||"").split(",").map(I=>I.trim()).filter(Boolean),preconditions:k.preconditions||"",steps:we}}).filter(A=>A.title)}function Be(c,j,D){const A=new Blob([c],{type:D}),k=URL.createObjectURL(A),F=document.createElement("a");F.href=k,F.download=j,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(k)}async function Ue(){if(!o)return;const c=(o==null?void 0:o.testCases)??(Array.isArray(o)?o:[]),j=de.find(A=>A.id===t),D=`test-cases-${j.id==="json"||j.id==="csv"||j.id==="xlsx"||j.id==="gherkin"?"export":j.id}-${Date.now()}.${j.ext}`;if(j.id==="xlsx"){try{const A=await Ye(ut(c)),k=URL.createObjectURL(A),F=document.createElement("a");F.href=k,F.download=D,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(k)}catch(A){O("error",`Could not build the Excel file: ${(A==null?void 0:A.message)||A}`)}return}Be(ue(j.id,c,ye),D,j.mime)}function Ze(c){var A;const j=(A=c.target.files)==null?void 0:A[0];if(!j)return;const D=new FileReader;D.onload=()=>{a(D.result)},D.readAsText(j),c.target.value=""}async function We(){if(r.trim())try{let c;const j=r.trim();if(j.startsWith("[")||j.startsWith("{")?(c=JSON.parse(j),Array.isArray(c)||(c=[c])):c=Je(j),!c.length){f({error:"No valid test cases found in input"});return}const D=await _.mutateAsync({testCases:c,folderId:d||void 0});f(D),be(`${(D==null?void 0:D.imported)??0} test cases imported`)}catch(c){f({error:c.message||"Import failed"})}}z.useCallback(async c=>{if(R){y(!0);try{const j=c.name.lastIndexOf("."),D=j>-1?c.name.slice(j+1).toLowerCase():"",k=D==="xlsx"||D==="xls"?await c.arrayBuffer():await c.text(),F=await ht(k,R,D);v(F),S("preview")}catch(j){v({detectedTool:R,testCases:[],fieldMapping:{},warnings:[j.message||"Failed to parse file"]}),S("preview")}finally{y(!1)}}},[R]);const K=o?(o==null?void 0:o.testCases)??(Array.isArray(o)?o:[]):[],le=de.find(c=>c.id===t),H=K.length>0?t==="xlsx"?ue("csv",K):ue(t,K,ye):null,_e=H?new Blob([H]).size:0;return e.jsx("div",{className:n?"text-gray-200":"min-h-screen bg-surface-0 text-gray-200",children:e.jsx("div",{className:n?"":"max-w-[1400px] mx-auto px-6 py-6",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-100 mb-1 flex items-center gap-2",children:[e.jsx(te,{size:20,className:"text-brand-300"}),"Export Test Cases"]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Export test cases for backup, migration, or sharing"}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-end gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex-1 min-w-[180px] max-w-xs",children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Folder"}),e.jsxs("select",{value:d,onChange:c=>l(c.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-brand-500/50",children:[e.jsx("option",{value:"",children:"All Folders"}),ae.map(c=>e.jsx("option",{value:c.id,children:" ".repeat(c.depth)+c.name},c.id))]})]}),e.jsxs("div",{className:"min-w-[200px]",children:[e.jsx("label",{htmlFor:"export-format",className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Format"}),e.jsx("select",{id:"export-format",value:t,onChange:c=>s(c.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-brand-500/50",children:de.map(c=>e.jsx("option",{value:c.id,children:c.label},c.id))}),e.jsx("p",{className:"text-[11px] text-gray-500 mt-1",children:le.hint})]}),e.jsxs("button",{onClick:()=>Xe(d||void 0),disabled:V.isPending,className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm font-medium flex items-center gap-2 transition-colors disabled:opacity-50",children:[V.isPending?e.jsx(ve,{size:16,className:"animate-spin"}):e.jsx(te,{size:16}),"Export"]})]}),H&&e.jsxs("div",{className:"space-y-3 border-t border-white/5 pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-gray-400",children:[K.length," test case",K.length!==1?"s":""," • ",t==="xlsx"?"preview of the Test cases sheet":`${(_e/1024).toFixed(1)} KB`," • ",le.label]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>Ve(H),className:"flex items-center gap-1.5 text-xs text-brand-300 hover:text-brand-200 transition-colors",children:[e.jsx(it,{size:12}),q?"Copied!":"Copy"]}),e.jsxs("button",{onClick:Ue,className:"flex items-center gap-1.5 text-xs bg-emerald-600 hover:bg-emerald-500 text-white px-3 py-1.5 rounded-lg font-medium transition-colors",children:[e.jsx(te,{size:12}),"Download ",le.label]})]})]}),e.jsxs("pre",{className:"bg-surface-0 border border-white/5 rounded-lg p-3 text-xs text-gray-300 font-mono max-h-64 overflow-auto whitespace-pre-wrap",children:[H.slice(0,5e3),H.length>5e3?`
|
|
22
|
+
|
|
23
|
+
... (truncated preview)`:""]})]})]})]}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-100 mb-1 flex items-center gap-2",children:[e.jsx(se,{size:20,className:"text-brand-300"}),"Import Test Cases"]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Import test cases from JSON or CSV files"}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center bg-surface-2 border border-white/10 rounded-lg p-0.5",children:[e.jsxs("button",{onClick:()=>b("file"),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center gap-1.5 ${w==="file"?"bg-brand-600 text-white":"text-gray-400 hover:text-gray-200"}`,children:[e.jsx(se,{size:13})," Upload File"]}),e.jsxs("button",{onClick:()=>b("paste"),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center gap-1.5 ${w==="paste"?"bg-brand-600 text-white":"text-gray-400 hover:text-gray-200"}`,children:[e.jsx(ze,{size:13})," Paste Data"]})]}),r&&e.jsxs("span",{className:"text-xs text-emerald-400 flex items-center gap-1",children:[e.jsx(G,{size:12}),r.trim().startsWith("[")||r.trim().startsWith("{")?"JSON":"CSV"," data loaded (",(new Blob([r]).size/1024).toFixed(1)," KB)"]})]}),w==="file"?e.jsx("div",{children:e.jsxs("label",{className:`flex flex-col items-center justify-center w-full h-40 border-2 border-dashed rounded-xl cursor-pointer transition-all duration-200 group ${p?"border-emerald-400 bg-emerald-500/10 scale-[1.01] shadow-lg shadow-emerald-500/10":"border-white/10 hover:border-emerald-500/40 bg-surface-2/50"}`,onDragOver:c=>{c.preventDefault(),c.stopPropagation(),h(!0)},onDragEnter:c=>{c.preventDefault(),c.stopPropagation(),h(!0)},onDragLeave:c=>{c.preventDefault(),c.stopPropagation(),h(!1)},onDrop:c=>{var A;c.preventDefault(),c.stopPropagation(),h(!1);const j=(A=c.dataTransfer.files)==null?void 0:A[0];if(!j)return;const D=new FileReader;D.onload=()=>{a(D.result)},D.readAsText(j)},children:[p?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-emerald-500/20 flex items-center justify-center mb-2 animate-pulse",children:e.jsx(te,{size:24,className:"text-emerald-300"})}),e.jsx("span",{className:"text-sm font-medium text-emerald-300",children:"Drop file here"})]}):e.jsxs(e.Fragment,{children:[e.jsx(se,{size:28,className:"text-gray-500 group-hover:text-brand-400 mb-2 transition-colors"}),e.jsxs("span",{className:"text-sm text-gray-400 group-hover:text-gray-300",children:["Click to upload ",e.jsx("span",{className:"font-medium text-brand-300",children:".json"})," or ",e.jsx("span",{className:"font-medium text-brand-300",children:".csv"})," file"]}),e.jsx("span",{className:"text-xs text-gray-600 mt-1",children:"or drag and drop"})]}),e.jsx("input",{type:"file",accept:".json,.csv,.txt",onChange:Ze,className:"hidden"})]})}):e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Paste JSON or CSV data"}),e.jsx("textarea",{value:r,onChange:c=>a(c.target.value),rows:10,placeholder:`Paste JSON array or CSV data...
|
|
24
|
+
|
|
25
|
+
JSON: [{ "title": "...", "steps": [...] }]
|
|
26
|
+
CSV: Title,Priority,Type,Steps (Action),Steps (Expected Result)`,className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder-gray-500 font-mono focus:outline-none focus:border-brand-500/50 resize-y"})]}),e.jsxs("div",{className:"flex items-end gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex-1 min-w-[180px] max-w-xs",children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Target Folder"}),e.jsxs("select",{value:d,onChange:c=>l(c.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-brand-500/50",children:[e.jsx("option",{value:"",children:"Root (No folder)"}),ae.map(c=>e.jsx("option",{value:c.id,children:" ".repeat(c.depth)+c.name},c.id))]})]}),e.jsxs("button",{onClick:We,disabled:_.isPending||!r.trim(),className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-5 py-2 text-sm font-medium flex items-center gap-2 transition-colors disabled:opacity-50",children:[_.isPending?e.jsx(ve,{size:16,className:"animate-spin"}):e.jsx(se,{size:16}),"Import Test Cases"]}),r&&e.jsx("button",{onClick:()=>{a(""),f(null)},className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",children:"Clear"})]}),m&&e.jsx("div",{className:`rounded-lg p-3 text-sm ${m.error?"bg-red-500/10 border border-red-500/20 text-red-400":"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400"}`,children:m.error?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Te,{size:16}),e.jsx("span",{children:m.error})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(G,{size:16}),e.jsxs("span",{className:"font-medium",children:[m.imported??m.count??0," test case",(m.imported??m.count??0)!==1?"s":""," imported successfully"]})]}),((je=m.errors)==null?void 0:je.length)>0&&e.jsx("ul",{className:"mt-2 space-y-1 text-xs text-red-400",children:m.errors.map((c,j)=>e.jsxs("li",{className:"flex items-start gap-1",children:[e.jsx(Te,{size:12,className:"mt-0.5 shrink-0"}),e.jsx("span",{children:typeof c=="string"?c:c.message??JSON.stringify(c)})]},j))})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"border border-white/5 rounded-lg p-3 bg-surface-0",children:[e.jsxs("p",{className:"text-xs text-gray-400 mb-2 font-bold flex items-center gap-1.5",children:[e.jsx($e,{size:12,className:"text-brand-300"})," JSON Format"]}),e.jsx("pre",{className:"text-[10px] text-gray-500 font-mono whitespace-pre-wrap leading-relaxed",children:`[{
|
|
27
|
+
"title": "Verify login",
|
|
28
|
+
"priority": "high",
|
|
29
|
+
"type": "functional",
|
|
30
|
+
"steps": [
|
|
31
|
+
{ "action": "Go to login",
|
|
32
|
+
"expectedResult": "Page loads" }
|
|
33
|
+
],
|
|
34
|
+
"tags": ["auth", "smoke"]
|
|
35
|
+
}]`})]}),e.jsxs("div",{className:"border border-white/5 rounded-lg p-3 bg-surface-0",children:[e.jsxs("p",{className:"text-xs text-gray-400 mb-2 font-bold flex items-center gap-1.5",children:[e.jsx(Me,{size:12,className:"text-brand-300"})," CSV Format"]}),e.jsx("pre",{className:"text-[10px] text-gray-500 font-mono whitespace-pre-wrap leading-relaxed",children:`Title,Priority,Type,Tags,Steps (Action),Steps (Expected Result),Steps (Test Data)
|
|
36
|
+
"Verify login","high","functional","auth, smoke","Go to login | Enter creds | Click submit","Page loads | Fields shown | Dashboard"," | user@test.com | "`}),e.jsxs("p",{className:"text-[10px] text-gray-600 mt-2",children:["Separate multiple steps with ",e.jsx("span",{className:"text-gray-400 font-medium",children:"|"})," (pipe)"]})]})]})]})]}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-100 mb-1 flex items-center gap-2",children:[e.jsx(nt,{size:20,className:"text-brand-300"}),"Import from Third-Party Tools or local files"]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Import test cases exported from tools like TestRail, Zephyr, Xray, PractiTest, qTest — or from any other tool, or your own local test case files."}),e.jsx(yt,{}),gt]})]})})})}function yt(){const n=Ke(),o=()=>{ot(n,{prompt:"I want to import test cases from a third-party test management tool into Testver. I will upload an export file in the chat (CSV, XML, JSON, or Excel). Please read the file, extract every test case (title, priority, preconditions, steps, expected results, tags), normalize the values to match Testver's schema (priority: critical|high|medium|low; type: web|ui|api|mobile|database|integration|e2e|security|performance|usability|accessibility|compatibility|localization), and create them via the test-management tools. Report back with the count created and any rows that needed manual review.",mode:"api"})};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-6",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-brand-500/15 flex items-center justify-center flex-shrink-0",children:e.jsx(Ne,{size:20,className:"text-brand-300"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100 mb-1",children:["Import via AI Assistant — works with any tool",e.jsx("span",{className:"ml-2 inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wider bg-brand-500/15 text-brand-300 border border-brand-500/30 align-middle",children:"API mode"})]}),e.jsxs("p",{className:"text-sm text-gray-400 leading-relaxed",children:["The AI Assistant can read an export file from tools like ",e.jsx("em",{className:"not-italic text-gray-300",children:"TestRail, Zephyr, Xray, PractiTest, qTest"})," — or from ",e.jsx("em",{className:"not-italic text-gray-300",children:"any other tool"}),", or your own local test case files — and create the test cases in Testver for you. Clicking the button below opens the AI Assistant in ",e.jsx("em",{className:"not-italic text-gray-300",children:"API mode"})," with a pre-filled prompt. Upload your export in the chat and the AI will parse the structure, map fields, and create everything in the right folder."]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mb-5",children:[e.jsxs("div",{className:"rounded-lg border border-white/5 bg-surface-2/50 p-3.5",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider font-semibold text-gray-500 mb-2",children:"Supported export formats"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:[{ext:"CSV",icon:e.jsx(Me,{size:11})},{ext:"XML",icon:e.jsx(ze,{size:11})},{ext:"JSON",icon:e.jsx($e,{size:11})}].map(i=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-md bg-white/[0.06] border border-white/10 text-[11px] text-gray-200 font-medium",children:[i.icon,i.ext]},i.ext))})]}),e.jsxs("div",{className:"rounded-lg border border-white/5 bg-surface-2/50 p-3.5",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider font-semibold text-gray-500 mb-2",children:"What the AI does for you"}),e.jsxs("ul",{className:"text-[12px] text-gray-300 space-y-1 leading-relaxed",children:[e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(G,{size:11,className:"text-emerald-400 mt-0.5 flex-shrink-0"})," Detects the source tool's format automatically"]}),e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(G,{size:11,className:"text-emerald-400 mt-0.5 flex-shrink-0"})," Maps fields (title, priority, steps, preconditions, tags)"]}),e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(G,{size:11,className:"text-emerald-400 mt-0.5 flex-shrink-0"})," Normalizes priority and type to Testver's schema"]}),e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(G,{size:11,className:"text-emerald-400 mt-0.5 flex-shrink-0"})," Reports per-row errors so nothing is silently dropped"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("button",{onClick:o,className:"flex items-center gap-2 bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2.5 text-sm font-semibold transition-colors shadow-sm",children:[e.jsx(Ne,{size:14})," Import with AI Assistant"]}),e.jsxs("span",{className:"text-xs text-gray-500",children:["Opens the AI Assistant in ",e.jsx("span",{className:"text-brand-300 font-medium",children:"API mode"})," with a pre-filled import prompt. Upload your export file there."]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-white/5 text-[11px] text-gray-500 leading-relaxed",children:[e.jsx("strong",{className:"text-gray-400 font-medium",children:"Tip:"})," the AI works best when columns/tags are clearly named in your export (e.g. ",e.jsx("em",{className:"not-italic text-gray-400",children:"Test Case Name"}),", ",e.jsx("em",{className:"not-italic text-gray-400",children:"Priority"}),", ",e.jsx("em",{className:"not-italic text-gray-400",children:"Steps"}),"). For very large exports (1000+ test cases), split the file into chunks of ~500 per upload for the smoothest run."]})]})}export{Rt as ImportExportPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,j as e,
|
|
1
|
+
import{r as a,j as e,d as K}from"./vendor-react-DOVfxdUy.js";import{a as q}from"./vendor-query-DkZSMtfn.js";import{u as C,d as M,e as Q}from"./useJiraConnector--JZhbYrT.js";import{gT as B}from"./index-BlA8ntjb.js";import{a7 as S,X as R,a1 as X,$ as _}from"./vendor-icons-Cm92aSc5.js";const P=100;function G({ids:l,className:n,label:x}){const{isConfigured:o}=C(),[d,i]=a.useState(!1);return!o||l.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>i(!0),title:"Create a Jira issue for each selected test case",className:n??"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-blue-300 border border-white/10 transition-colors",children:[e.jsx(S,{size:14}),x??"Push to Jira"]}),d&&e.jsx(A,{ids:l,onClose:()=>i(!1)})]})}function A({ids:l,onClose:n}){var w;const x=q(),{connectorId:o,connector:d}=C(),{data:i,isLoading:E}=M(o),{data:m}=Q(o),J=(i==null?void 0:i.projects)??[],c=a.useMemo(()=>{const s=[...new Set(((m==null?void 0:m.types)??[]).filter(u=>!u.subtask).map(u=>String(u.name)))];return s.length?s:["Task"]},[m]),[h,L]=a.useState(((w=d==null?void 0:d.config)==null?void 0:w.defaultProject)??""),[p,g]=a.useState(""),[f,T]=a.useState(!1),[b,z]=a.useState(!1),[t,j]=a.useState(!1),[y,k]=a.useState(null),[r,F]=a.useState(null);a.useEffect(()=>{f||c.length===0||g(c.find(s=>s.toLowerCase()==="test")??c.find(s=>s.toLowerCase()==="task")??c[0])},[c,f]),a.useEffect(()=>{const s=u=>{u.key==="Escape"&&!t&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[t,n]);const N=l.length>P;async function I(){j(!0),k(null);try{const s=await B({ids:l,projectKey:h,issueType:p,connectorId:o??void 0,force:b});F(s),x.invalidateQueries({queryKey:["tm-test-cases"]}),x.invalidateQueries({queryKey:["tm-test-case"]})}catch(s){k((s==null?void 0:s.message)||"Push failed")}finally{j(!1)}}const v="w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:ring-1 focus:ring-brand-500";return K.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",role:"dialog","aria-modal":"true","aria-labelledby":"jira-push-title",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>{t||n()}}),e.jsxs("div",{className:"relative w-full max-w-lg rounded-xl bg-surface-1 border border-white/10 p-5 shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("h3",{id:"jira-push-title",className:"text-base font-semibold text-gray-100",children:["Push ",l.length," test case",l.length===1?"":"s"," to Jira"]}),e.jsx("button",{onClick:n,disabled:t,"aria-label":"Close",className:"text-gray-500 hover:text-gray-300",children:e.jsx(R,{size:16})})]}),r?e.jsxs("div",{className:"mt-3 space-y-3 text-sm",role:"status",children:[e.jsxs("p",{className:"text-gray-300",children:[r.pushed.length," created",r.skipped.length>0&&e.jsxs(e.Fragment,{children:[", ",r.skipped.length," already in Jira (skipped)"]}),r.failed.length>0&&e.jsxs(e.Fragment,{children:[", ",e.jsxs("span",{className:"text-red-400",children:[r.failed.length," failed"]})]}),"."]}),e.jsxs("ul",{className:"max-h-64 overflow-auto space-y-1",children:[[...r.pushed.map(s=>({...s,note:""})),...r.skipped.map(s=>({...s,note:"already pushed"}))].map(s=>e.jsxs("li",{className:"flex items-center gap-2 text-xs",children:[e.jsxs("a",{href:s.url,target:"_blank",rel:"noreferrer",className:"text-blue-300 hover:underline inline-flex items-center gap-1 font-mono shrink-0",children:[s.key,e.jsx(_,{size:11})]}),e.jsx("span",{className:"text-gray-400 truncate",children:s.title}),s.note&&e.jsxs("span",{className:"text-gray-500 shrink-0",children:["· ",s.note]})]},s.id)),r.failed.map(s=>e.jsxs("li",{className:"text-xs text-red-400",children:[s.title||s.id,": ",s.error]},s.id))]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:n,className:"px-4 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium",children:"Done"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-gray-400 mt-2 leading-relaxed",children:"Each case becomes one issue: its title as the summary, and its preconditions, steps and requirements in the description. The issue is linked back on the case."}),N&&e.jsxs("p",{className:"text-sm text-amber-300 mt-2",children:["Push up to ",P," at a time — select fewer cases."]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-xs text-gray-500 mb-1",children:"Project"}),e.jsxs("select",{value:h,onChange:s=>L(s.target.value),className:v,disabled:t,children:[e.jsx("option",{value:"",children:E?"Loading…":"Select a project…"}),J.map(s=>e.jsxs("option",{value:s.key,children:[s.key," — ",s.name]},s.key))]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-xs text-gray-500 mb-1",children:"Issue type"}),e.jsx("select",{value:p,onChange:s=>{g(s.target.value),T(!0)},className:v,disabled:t,children:c.map(s=>e.jsx("option",{value:s,children:s},s))})]})]}),e.jsxs("label",{className:"flex items-center gap-2 mt-3 text-xs text-gray-400",children:[e.jsx("input",{type:"checkbox",checked:b,onChange:s=>z(s.target.checked),disabled:t}),"Push cases that were pushed before again (creates new issues)"]}),y&&e.jsx("p",{className:"text-sm text-red-400 mt-3",role:"alert",children:y}),e.jsxs("div",{className:"flex gap-2 justify-end mt-4",children:[e.jsx("button",{onClick:n,disabled:t,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsxs("button",{onClick:I,disabled:t||!h||!p||N,className:"flex items-center gap-1.5 px-4 py-2 text-sm rounded-lg bg-blue-600 hover:bg-blue-500 text-white font-medium disabled:opacity-50",children:[t?e.jsx(X,{size:14,className:"animate-spin"}):e.jsx(S,{size:14}),t?"Pushing…":"Create issues"]})]})]})]})]}),document.body)}export{G as J};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t}from"./vendor-react-
|
|
1
|
+
import{j as t}from"./vendor-react-DOVfxdUy.js";import{cA as N,dq as v,dr as w}from"./vendor-icons-Cm92aSc5.js";const f={good:"On target",warn:"Watch",bad:"Needs action"};function h(e){return e.toLocaleString(void 0,{maximumFractionDigits:1})}function $(e,s){return`${e>0?"+":""}${h(e)}${s??""}`}const D={good:"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300",warn:"bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300",bad:"bg-rose-50 text-rose-700 dark:bg-rose-500/15 dark:text-rose-300"},g={good:"#059669",warn:"#d97706",bad:"#dc2626"};function A(e,s,n,o=3){const a=e.filter(r=>typeof r=="number"&&Number.isFinite(r));if(a.length<2)return"";const m=Math.min(...a),i=Math.max(...a),l=i-m||1;return a.map((r,d)=>`${(d*s/(a.length-1)).toFixed(1)},${(n-o-(r-m)/l*(n-2*o)).toFixed(1)}`).join(" ")}function L({cell:e}){const{title:s,value:n,unit:o,delta:a,deltaGood:m,hint:i,status:l}=e,r=typeof a=="number"&&Number.isFinite(a),d=e.deltaDirection??(r?a>0?"up":a<0?"down":"flat":void 0),u=m??"up",c=d==="flat"||a===0,p=d==="up"&&u==="up"||d==="down"&&u==="down",k=c?"text-gray-500 dark:text-gray-400":p?"text-emerald-700 dark:text-emerald-400":"text-rose-700 dark:text-rose-400",y=c?N:d==="up"?v:w,x=l&&f[l]?l:void 0,b=Array.isArray(e.trend)?A(e.trend,200,36,4):"",j=x?g[x]:c?"#94a3b8":p?g.good:g.bad;return t.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-4 py-3.5 h-full flex flex-col","data-testid":"kpi-tile",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsx("div",{className:"text-[13px] font-medium text-gray-600 dark:text-gray-400 leading-snug",children:s}),x&&t.jsx("span",{className:`flex-shrink-0 rounded-full px-2 py-0.5 text-[11px] font-semibold ${D[x]}`,"data-testid":"kpi-status",children:f[x]})]}),t.jsxs("div",{className:"mt-1.5 flex items-baseline gap-1",children:[t.jsx("span",{className:"text-[28px] leading-tight font-bold tracking-tight text-gray-900 dark:text-gray-100 tabular-nums",children:typeof n=="number"?h(n):n}),o&&t.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 font-medium",children:o})]}),r&&t.jsxs("div",{className:`mt-1 flex items-center gap-1 text-[13px] font-semibold ${k}`,children:[t.jsx(y,{size:13,"aria-hidden":!0}),t.jsx("span",{className:"tabular-nums",children:$(a,o)}),i&&t.jsx("span",{className:"font-normal text-gray-500 dark:text-gray-400 ml-0.5 truncate",children:i})]}),!r&&i&&t.jsx("div",{className:"mt-1 text-[13px] text-gray-500 dark:text-gray-400",children:i}),b&&t.jsx("svg",{viewBox:"0 0 200 36",preserveAspectRatio:"none",className:"mt-auto pt-2 w-full h-9",role:"img","aria-label":`${s}: trend over ${e.trend.length} periods`,children:t.jsx("polyline",{points:b,fill:"none",stroke:j,strokeWidth:2,vectorEffect:"non-scaling-stroke",strokeLinejoin:"round"})})]})}export{L as K,f as T,D as a,A as s};
|
package/src/ui/static/assets/{LiveExecutionView-D5BRe9jq.js → LiveExecutionView-1LlyEDEe.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,j as e,L as M}from"./vendor-react-
|
|
1
|
+
import{r as a,j as e,L as M}from"./vendor-react-DOVfxdUy.js";import{u as V}from"./vendor-query-DkZSMtfn.js";import{gF as R,dS as z}from"./index-BlA8ntjb.js";import{a1 as j,aV as F,X as O,ab as E,ba as B,aa as q}from"./vendor-icons-Cm92aSc5.js";function D(t,s=!0){return V({queryKey:["run-live",t],queryFn:()=>R(t),enabled:!!t&&s,refetchInterval:d=>{const r=d.state.data;return r&&(r.status!=="running"||r.provider!=="testver-grid")?!1:3e3},staleTime:2e3,retry:!1})}const G=8,w=new Set,v=new Set;function $(t){return w.has(t)?!0:w.size>=G?!1:(w.add(t),v.forEach(s=>s()),!0)}function T(t){w.delete(t)&&v.forEach(s=>s())}function K(t){return v.add(t),()=>{v.delete(t)}}const A="testver.liveView";function k(){try{return localStorage.getItem(A)!=="off"}catch{return!0}}function P(t){try{localStorage.setItem(A,t?"on":"off")}catch{}v.forEach(s=>s())}const C={chromium:"bg-emerald-400",firefox:"bg-orange-400",webkit:"bg-sky-400"};function _(t){if(!t)return"";const s=Math.max(0,Math.round((Date.now()-Date.parse(t))/1e3));return s<60?`${s}s`:`${Math.floor(s/60)}m ${s%60}s`}function L({session:t,index:s,compact:d=!1,onEnlarge:r}){const n=a.useRef(null),[u,o]=a.useState(!1),[x,f]=a.useState(document.visibilityState==="visible"),[i,m]=a.useState(!1),[h,y]=a.useState(!1),[l,g]=a.useState(0);a.useEffect(()=>{const c=n.current;if(!c)return;const p=new IntersectionObserver(([S])=>o(!!(S!=null&&S.isIntersecting)),{threshold:.2});return p.observe(c),()=>p.disconnect()},[]),a.useEffect(()=>{const c=()=>f(document.visibilityState==="visible");return document.addEventListener("visibilitychange",c),()=>document.removeEventListener("visibilitychange",c)},[]);const N=u&&x&&t.liveAvailable&&!h;a.useEffect(()=>{if(!N){m(!1);return}const c=$(t.sessionId);return m(c),()=>{c&&T(t.sessionId)}},[N,t.sessionId]),a.useEffect(()=>{const c=setInterval(()=>g(p=>p+1),1e3);return()=>clearInterval(c)},[]);const b=N&&i;return e.jsxs("div",{ref:n,className:`rounded-lg border border-white/5 bg-black/40 overflow-hidden flex flex-col ${d?"":"min-h-[180px]"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-surface-2/60 border-b border-white/5 text-[11px]",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${C[t.browser]||"bg-gray-400"}`}),e.jsx("span",{className:"text-gray-200 capitalize font-medium",children:t.browser}),e.jsxs("span",{className:"text-gray-500",children:["worker ",s+1]}),e.jsxs("span",{className:"text-gray-600",children:["· ",t.provider==="hetzner"?"box":t.provider==="fly"?"Fly":""]}),t.liveAvailable?e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-emerald-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"})," LIVE ",_(t.startedAt??t.createdAt)]}):e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-amber-400",children:[e.jsx(j,{size:10,className:"animate-spin"})," starting"]}),r&&t.liveAvailable&&e.jsx("button",{onClick:()=>r(t),title:"Enlarge",className:"w-5 h-5 inline-flex items-center justify-center rounded text-gray-500 hover:text-gray-200 hover:bg-white/10",children:e.jsx(F,{size:11})})]}),e.jsx("div",{className:`relative flex-1 aspect-video bg-black ${r&&b?"cursor-zoom-in":""}`,onClick:()=>{r&&b&&r(t)},title:r&&b?"Click to enlarge":void 0,children:b?e.jsx("img",{src:z(t.sessionId),alt:`Live ${t.browser} session`,className:"absolute inset-0 w-full h-full object-contain",onError:()=>y(!0)}):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-[11px] text-gray-500 px-3 text-center",children:h?"Live view is not available for this session — no display on the machine (evidence off), or an older image.":t.liveAvailable?x?i?"Scroll into view to watch":"Stream limit reached — close another live view to watch this one":"Paused while this tab is in the background":"Browser is starting…"})})]})}function I({session:t,onClose:s}){const[d,r]=a.useState(!1);return a.useEffect(()=>{const n=$(`${t.sessionId}:modal`);return()=>{n&&T(`${t.sessionId}:modal`)}},[t.sessionId]),a.useEffect(()=>{const n=u=>{u.key==="Escape"&&s()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[s]),e.jsx("div",{className:"fixed inset-0 z-50 bg-black/80 flex items-center justify-center p-6",onClick:s,children:e.jsxs("div",{className:"w-full max-w-5xl rounded-xl border border-white/10 bg-surface-1 overflow-hidden",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-white/5 text-sm",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${C[t.browser]||"bg-gray-400"}`}),e.jsx("span",{className:"text-gray-200 capitalize font-medium",children:t.browser}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-emerald-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"})," LIVE"]}),e.jsx("button",{onClick:s,className:"ml-auto w-7 h-7 inline-flex items-center justify-center rounded text-gray-400 hover:text-gray-100 hover:bg-white/10",title:"Close",children:e.jsx(O,{size:15})})]}),e.jsx("div",{className:"bg-black aspect-video",children:d?e.jsx("div",{className:"h-full flex items-center justify-center text-sm text-gray-500",children:"The session has ended — closing."}):e.jsx("img",{src:z(t.sessionId),alt:"Live session",className:"w-full h-full object-contain",onError:()=>{r(!0),setTimeout(s,1200)}})})]})})}function W({runId:t,layout:s="inline",className:d=""}){const{data:r}=D(t),[n,u]=a.useState(k()),[o,x]=a.useState(null);if(a.useEffect(()=>K(()=>u(k())),[]),a.useEffect(()=>{o&&!(r!=null&&r.sessions.some(l=>l.sessionId===o.sessionId&&l.liveAvailable))&&x(null)},[r,o]),!t||!r||r.provider!=="testver-grid")return null;const f=r.sessions,i=f.filter(l=>l.liveAvailable),m=r.status!=="running",h=()=>{P(!n),u(!n)};if(s==="strip")return m?null:e.jsxs("div",{className:`px-4 pb-2.5 pl-11 ${d}`,children:[n?i.length===0?e.jsxs("div",{className:"text-[11px] text-amber-400/90 inline-flex items-center gap-1.5",children:[e.jsx(j,{size:11,className:"animate-spin"})," Starting a browser on Testver Grid…"]}):e.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${Math.min(i.length,3)}, minmax(0, 240px))`},children:i.slice(0,3).map((l,g)=>e.jsx(L,{session:l,index:g,compact:!0,onEnlarge:x},l.sessionId))}):e.jsxs("button",{onClick:h,className:"text-[11px] text-gray-500 hover:text-gray-300 inline-flex items-center gap-1",children:[e.jsx(E,{size:11})," Show live browser"]}),o&&e.jsx(I,{session:o,onClose:()=>x(null)})]});const y=s==="panel"?i.length>1?2:1:Math.min(Math.max(i.length,1),2);return e.jsxs("div",{className:`${s==="panel"?"h-full flex flex-col":"rounded-xl border border-white/5 bg-surface-1 mb-3 w-full max-w-[560px]"} ${d}`,children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-white/5 flex-shrink-0",children:[e.jsx(B,{size:14,className:"text-emerald-400"}),e.jsx("span",{className:"text-sm font-medium text-gray-200",children:"Testver Grid"}),r.browser&&e.jsx("span",{className:"text-xs text-gray-500 capitalize",children:r.browser}),m?e.jsx("span",{className:"text-xs text-gray-500",children:"· run finished"}):i.length>0?e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-emerald-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"})," ",i.length," live browser",i.length===1?"":"s"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-amber-400",children:[e.jsx(j,{size:12,className:"animate-spin"})," starting a browser"]}),e.jsx("button",{onClick:h,title:n?"Hide live view (remembered)":"Show live view (remembered)",className:"ml-auto inline-flex items-center gap-1 text-[11px] text-gray-500 hover:text-gray-200",children:n?e.jsxs(e.Fragment,{children:[e.jsx(q,{size:12})," Hide"]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{size:12})," Show live view"]})})]}),n&&e.jsxs("div",{className:`${s==="panel"?"flex-1 overflow-y-auto":""} p-3`,children:[m?e.jsxs("div",{className:"text-xs text-gray-500 px-1 py-2",children:["The browsers for this run have been released. "," ",e.jsx(M,{to:`/results?runId=${encodeURIComponent(t)}`,className:"text-cyan-400 hover:text-cyan-300",children:"Video and command log are in Results."})]}):i.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-white/10 aspect-video flex flex-col items-center justify-center gap-2 text-center px-6",children:[e.jsx(j,{size:18,className:"text-amber-400 animate-spin"}),e.jsx("div",{className:"text-sm text-gray-300",children:"Starting a browser on Testver Grid"}),e.jsx("div",{className:"text-[11px] text-gray-500",children:"About 5 seconds on a ready machine, up to 40 seconds when a fresh one has to boot. The stream appears here the moment the browser is up."})]}):e.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:`repeat(${y}, minmax(0, 1fr))`},children:i.map((l,g)=>e.jsx(L,{session:l,index:g,onEnlarge:x},l.sessionId))}),!m&&f.length>i.length&&e.jsxs("div",{className:"mt-2 text-[11px] text-gray-500",children:[f.length-i.length," more worker",f.length-i.length===1?"":"s"," starting…"]})]}),o&&e.jsx(I,{session:o,onClose:()=>x(null)})]})}export{W as L};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as a,j as s,l as t}from"./vendor-react-
|
|
1
|
+
import{e as a,j as s,l as t}from"./vendor-react-DOVfxdUy.js";function n(){const[r]=a(),e=r.get("tab");return e==="cicd"||e==="pipelines"?s.jsx(t,{to:"/pipelines",replace:!0}):e==="browser-sessions"?s.jsx(t,{to:"/settings?tab=browser-sessions",replace:!0}):s.jsx(t,{to:"/settings?tab=config",replace:!0})}export{n as ManagePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as x,
|
|
1
|
+
import{r as x,d as m,j as e}from"./vendor-react-DOVfxdUy.js";import{X as p}from"./vendor-icons-Cm92aSc5.js";function v({title:s,subtitle:o,icon:d,toolbar:i,footer:a,onClose:r,children:l}){return x.useEffect(()=>{const t=c=>{c.key==="Escape"&&r()};window.addEventListener("keydown",t);const n=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",t),document.body.style.overflow=n}},[r]),m.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-3 sm:p-5",onClick:r,children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":s,className:"flex h-[92vh] w-[min(96vw,1680px)] flex-col overflow-hidden rounded-xl border border-white/10 bg-surface-1 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-white/5 px-4 py-2.5",children:[d,e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-200",title:s,children:s}),o&&e.jsx("p",{className:"truncate text-[11px] text-gray-500",children:o})]}),i,e.jsx("button",{onClick:r,title:"Close (Esc)","aria-label":"Close",className:"ml-1 rounded-lg p-1.5 text-gray-500 transition-colors hover:bg-white/10 hover:text-gray-200",children:e.jsx(p,{size:18})})]}),e.jsx("div",{className:"relative min-h-0 flex-1",children:l}),a&&e.jsx("div",{className:"border-t border-white/5 px-4 py-1.5 text-[11px] text-gray-500",children:a})]})}),document.body)}export{v as M};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as o,j as t}from"./vendor-react-DOVfxdUy.js";import{y as S,z as I,A as E}from"./index-BlA8ntjb.js";import{M as C}from"./MobileRunTarget-C4M4YJJh.js";import{K as N,c4 as L,au as M}from"./vendor-icons-Cm92aSc5.js";const R={browserstack:"BrowserStack",saucelabs:"Sauce Labs",lambdatest:"LambdaTest","local-appium":"Local Devices"};function A({disabled:m,initial:e,compact:b=!1,xcode:c=!1,onChange:w}){const[l,i]=o.useState([]),[p,g]=o.useState(!1),[r,n]=o.useState((e==null?void 0:e.cloudProvider)||""),[a,k]=o.useState({deviceName:(e==null?void 0:e.deviceName)||"",platformName:(e==null?void 0:e.platformName)==="iOS"?"iOS":"Android",platformVersion:(e==null?void 0:e.platformVersion)||"",appId:(e==null?void 0:e.appId)||"",appPath:(e==null?void 0:e.appPath)||""}),[v,y]=o.useState();o.useEffect(()=>{S().then(s=>i(s.providers.filter(d=>d.enabled&&d.id!=="testver-grid"))).catch(()=>i([])),I().then(({config:s})=>g(!!s.enabled)).catch(()=>g(!1))},[]),o.useEffect(()=>{r||c||(p?n("local-appium"):l.length>0&&n(l[0].id))},[p,l,r]),o.useEffect(()=>{if(!r){y(void 0);return}let s=!1;const d=()=>{E().then(P=>{if(s)return;const u=P.ticket;y(u&&!u.claimed&&Date.now()<u.expiresAt?u.sessionId:void 0)}).catch(()=>{})};d();const j=window.setInterval(d,5e3);return()=>{s=!0,window.clearInterval(j)}},[r]);const h=!c&&l.length===0&&!p;if(o.useEffect(()=>{const s=c?!r||!!a.deviceName:!!r&&!!a.deviceName&&(!!a.appId||!!a.appPath.trim()),d=r?{cloudProvider:r,deviceName:a.deviceName,platformName:a.platformName,platformVersion:a.platformVersion,appId:a.appId,appPath:a.appPath,reuseSessionId:v}:null;w({payload:d,active:!!r,blocked:h,ready:s})},[r,a,v,h,c]),h)return t.jsxs("div",{className:"mt-3 flex items-start gap-2.5 px-3.5 py-3 rounded-xl border border-amber-500/25 bg-amber-500/10 text-sm text-amber-700 dark:text-amber-200",children:[t.jsx(N,{size:15,className:"mt-0.5 flex-shrink-0 text-amber-600 dark:text-amber-300"}),t.jsxs("span",{children:["No device target available. To run this test, connect a local device or enable a cloud device grid in ",t.jsx("span",{className:"font-semibold",children:"Connectors"}),"."]})]});const x=b?"flex items-center gap-1 px-2.5 py-1 text-xs rounded-lg border transition-colors":"flex items-center gap-1.5 px-2.5 h-8 text-xs rounded-lg border transition-colors",f=12;return t.jsxs("div",{className:b?"space-y-2":"mt-3 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:`${b?"text-xs":"text-sm"} text-gray-400`,children:"Run on:"}),t.jsxs("div",{className:"flex gap-1.5 flex-wrap",children:[c&&t.jsxs("button",{onClick:()=>n(""),disabled:m,title:"Xcode runs the tests on the simulator that is running, else the newest iPhone simulator",className:`${x} ${r?"border-white/5 bg-surface-2 text-gray-400 hover:text-gray-300 hover:border-white/10":"border-gray-300 dark:border-white/25 bg-gray-100/70 dark:bg-white/[0.08] text-gray-800 dark:text-gray-100 font-medium"} disabled:opacity-50`,children:[t.jsx(L,{size:f}),"This Mac"]}),l.map(s=>t.jsxs("button",{onClick:()=>n(s.id),disabled:m,className:`${x} ${r===s.id?"border-blue-500/50 bg-blue-500/10 text-blue-300 font-medium":"border-white/5 bg-surface-2 text-gray-400 hover:text-gray-300 hover:border-white/10"} disabled:opacity-50`,children:[t.jsx(M,{size:f}),R[s.id]||s.id]},s.id)),p&&t.jsxs("button",{onClick:()=>n("local-appium"),disabled:m,className:`${x} ${r==="local-appium"?"border-gray-300 dark:border-white/25 bg-gray-100/70 dark:bg-white/[0.08] text-gray-800 dark:text-gray-100 font-medium":"border-white/5 bg-surface-2 text-gray-400 hover:text-gray-300 hover:border-white/10"} disabled:opacity-50`,children:[t.jsx(N,{size:f}),"Local Devices"]})]})]}),r&&t.jsx(C,{providerId:r,disabled:m,value:a,onChange:k,xcode:c})]})}export{A as M};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{r as i,j as e}from"./vendor-react-DOVfxdUy.js";import{T as V,bJ as _,bK as B,U as K,S as z,X as H}from"./index-BlA8ntjb.js";import{K as D,$ as X,a1 as U,di as J,z as W,ah as Y,be as q}from"./vendor-icons-Cm92aSc5.js";import{a as $}from"./formatDate-T65-Y6Mi.js";import{S as G,L as Q}from"./SearchableDevicePicker-CenIxD7b.js";const M=1e3;function ie({testRunning:c,hideHeader:w=!1}){const[s,u]=i.useState(null),[p,y]=i.useState(null),[k,h]=i.useState(null),[j,P]=i.useState(null),[S,b]=i.useState(!1),[v,x]=i.useState(M),m=i.useRef(null),N=i.useRef(0),o=i.useRef(c);i.useEffect(()=>{o.current=c},[c]),i.useEffect(()=>{let r=!1;return V().then(f=>{r||u(f.session)}).catch(()=>{}),()=>{r=!0}},[]),i.useEffect(()=>{let r=!1;const f=async()=>{if(!r)try{const l=await _({timeoutMs:15e3,since:N.current||void 0});!r&&l.unchanged?h(null):r||(N.current=l.capturedAt||0,y(l.image),h(null),b(!!l.delayed),l.dashboardUrl&&P(l.dashboardUrl),x(o.current?500:M))}catch(l){!r&&B(l)?(h(null),x(M)):r||(h(l.message),x(Math.min(v*2,o.current?4e3:1e4)))}finally{r||(m.current=window.setTimeout(f,v))}};return f(),()=>{r=!0,m.current&&window.clearTimeout(m.current)}},[]);const g=!s;return e.jsxs("div",{className:"h-full flex flex-col bg-surface-1",children:[!w&&e.jsxs("div",{className:"px-3 py-2 border-b border-white/5 flex items-center gap-2",children:[e.jsx(D,{size:13,className:"text-indigo-300"}),e.jsx("span",{className:"text-xs font-medium text-gray-200",children:c?"Live Device — Execution view":"Live Device"}),s&&e.jsx("span",{className:"text-[10px] text-gray-500 truncate",children:s.device}),S&&p&&e.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400/80 border border-amber-500/20 flex-shrink-0",title:"Cloud preview frames are captured between test commands and are a few seconds behind the device. Use the provider link for their real-time view.",children:"~few sec behind"}),e.jsx("div",{className:"flex-1"}),((s==null?void 0:s.dashboardUrl)||j)&&e.jsxs("a",{href:(s==null?void 0:s.dashboardUrl)||j,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-indigo-300 hover:text-indigo-200",title:"Open the cloud provider's session view — their stream is real-time",children:["Live on provider ",e.jsx(X,{size:9})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden relative flex items-center justify-center bg-black/40",children:g&&!c?e.jsxs("div",{className:"text-center px-4 py-8",children:[e.jsx(D,{size:28,className:"text-gray-600 mx-auto mb-2"}),e.jsx("p",{className:"text-xs text-gray-400",children:"No active mobile session"}),e.jsx("p",{className:"text-[10px] text-gray-600 mt-1",children:"Click Run to start a test (a device session opens automatically), or connect a device in AI Assistant."}),k&&e.jsx("p",{className:"text-[10px] text-red-400 mt-2",children:k})]}):p?e.jsx("img",{src:`data:image/png;base64,${p}`,alt:"Live device",className:"max-h-full max-w-full object-contain",style:c?{filter:"saturate(0.85) brightness(0.95)"}:void 0}):e.jsxs("div",{className:"flex flex-col items-center gap-2 text-xs text-gray-500 px-4 py-8 text-center",children:[e.jsx(U,{size:14,className:"animate-spin"}),e.jsx("span",{children:"Waiting for the test's device session…"}),e.jsx("span",{className:"text-[10px] text-gray-600",children:"First frame appears within a few seconds of session creation."})]})})]})}function re({providerId:c,disabled:w,value:s,onChange:u,xcode:p=!1}){const[y,k]=i.useState([]),[h,j]=i.useState(!1),[P,S]=i.useState(null),[b,v]=i.useState([]),[x,m]=i.useState(null),[N,o]=i.useState(!1),[g,r]=i.useState(!1),[f,l]=i.useState(null),A=i.useRef(null);i.useEffect(()=>{let t=!1;return j(!0),S(null),K(c).then(a=>{t||k((a.devices||[]).filter(d=>!p||d.platform==="ios"))}).catch(a=>{t||S(a.message)}).finally(()=>{t||j(!1)}),()=>{t=!0}},[c,p]),i.useEffect(()=>{let t=!1;return z().then(a=>{t||v(a.apps||[])}).catch(a=>{t||m(a.message)}),()=>{t=!0}},[]);const L=i.useMemo(()=>{if(!s.deviceName)return"";const t=y.find(a=>(a.rawDeviceKey===s.deviceName||a.name===s.deviceName)&&a.os===s.platformVersion);return t?t.id:""},[y,s.deviceName,s.platformVersion]),n=i.useMemo(()=>b.find(t=>t.id===s.appId)??null,[b,s.appId]),C=n?n.label||n.filename:s.appPath.trim()?s.appPath.trim():"Pick app or upload…",E=(()=>{if(n){const t=(n.size/1048576).toFixed(1),a=n.kind==="ipa"?"iOS":"Android",d=n.uploadedAt?$(n.uploadedAt):"";return[n.label||n.filename,n.filename,`${a} · ${t} MB${d?` · uploaded ${d}`:""}`].join(`
|
|
2
|
+
`)}return s.appPath.trim()?s.appPath.trim():"Pick app or upload…"})(),I=t=>{u({...s,deviceName:c==="local-appium"?t.rawDeviceKey:t.name,platformName:t.platform==="ios"?"iOS":"Android",platformVersion:t.os})},R=t=>{u({...s,appId:t.id,appPath:""}),o(!1)},T=()=>{u({...s,appId:"",appPath:""}),o(!1)},F=async t=>{r(!0),m(null),l(0);try{const a=await H(t,void 0,O=>l(O)),d=await z();v(d.apps||[]),u({...s,appId:a.id,appPath:""}),o(!1)}catch(a){m(a.message)}finally{r(!1),l(null),A.current&&(A.current.value="")}};return e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap max-w-full min-w-0",children:[e.jsx("span",{title:"Mobile device target",className:"flex-shrink-0",children:e.jsx(D,{size:13,className:"text-indigo-400 dark:text-indigo-300"})}),e.jsx("div",{className:"flex-1 min-w-[13rem]",children:e.jsx(G,{devices:y,selectedId:L,onSelect:I,loading:h,disabled:w,errorText:P,placeholder:"Select a device…",emptyText:c==="local-appium"?Q:void 0,variant:"compact"})}),!p&&e.jsxs("div",{className:"relative flex-1 min-w-[13rem]",children:[e.jsxs("button",{type:"button",disabled:w||g,onClick:()=>o(!N),title:`${E?E+`
|
|
3
|
+
|
|
4
|
+
`:""}Shared app library — apps uploaded in AI Assistant / AI Record appear here. Uploads are cached by SHA-256, so repeat runs skip re-upload.`,className:"w-full h-8 flex items-center justify-between gap-1.5 px-2.5 text-xs rounded-lg bg-white dark:bg-white/[0.04] border border-gray-200 dark:border-white/10 text-gray-800 dark:text-gray-200 hover:border-gray-300 dark:hover:border-white/20 transition-colors disabled:opacity-50",children:[e.jsxs("span",{className:"flex items-center gap-1.5 truncate min-w-0",children:[e.jsx(J,{size:11,className:`flex-shrink-0 ${n?"text-indigo-500 dark:text-indigo-300":"text-gray-500"}`}),e.jsx("span",{className:`truncate ${n||s.appPath.trim()?"":"text-gray-500"}`,children:g?`Uploading… ${f!==null?Math.round(f*100)+"%":""}`:C})]}),g?e.jsx(U,{size:11,className:"animate-spin flex-shrink-0 text-gray-500"}):e.jsx(W,{size:11,className:"flex-shrink-0 text-gray-500"})]}),N&&!g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>o(!1)}),e.jsxs("div",{className:"absolute top-full left-0 mt-1 w-full max-h-72 bg-surface-1 border border-white/10 rounded-lg shadow-xl z-40 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[x&&e.jsx("div",{className:"px-3 py-2 text-xs text-red-300",children:x}),!x&&b.length===0&&e.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No apps in the library yet — upload an .apk or .ipa below."}),b.map(t=>{const a=t.id===s.appId;return e.jsxs("button",{onClick:()=>R(t),title:`${t.label||t.filename}
|
|
5
|
+
${t.filename}
|
|
6
|
+
${t.kind==="ipa"?"iOS":"Android"} · ${(t.size/1024/1024).toFixed(1)} MB${t.uploadedAt?` · uploaded ${$(t.uploadedAt)}`:""}`,className:`w-full flex items-center justify-between gap-2 px-3 py-1.5 text-xs transition-colors ${a?"bg-indigo-500/15 text-indigo-200":"text-gray-300 hover:bg-white/5"}`,children:[e.jsxs("span",{className:"flex items-center gap-1.5 truncate",children:[a&&e.jsx(Y,{size:11,className:"text-indigo-300 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:t.label||t.filename})]}),e.jsxs("span",{className:"text-[10px] text-gray-500 flex-shrink-0",children:[t.kind," · ",(t.size/1024/1024).toFixed(1)," MB"]})]},t.id)}),s.appId&&e.jsx("button",{onClick:T,className:"w-full text-left px-3 py-1.5 text-xs text-gray-500 hover:bg-white/5 border-t border-white/5",children:"Clear selection"})]}),e.jsxs("div",{className:"border-t border-white/10 px-2 py-1.5 bg-surface-1/50",children:[e.jsxs("button",{type:"button",onClick:t=>{var a;t.stopPropagation(),(a=A.current)==null||a.click()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-[11px] rounded-md bg-indigo-500/10 text-indigo-300 hover:bg-indigo-500/20 transition-colors",children:[e.jsx(q,{size:11})," ",e.jsx("span",{title:"Android: .apk or .aab · real iPhone / iPad: .ipa · iOS simulator: the .app zipped",children:"Upload app build"})]}),e.jsx("p",{className:"mt-1.5 px-1 text-[10px] text-gray-500 leading-relaxed",children:"Shared with AI Assistant + AI Record — apps uploaded there appear here. Uploads are cached by SHA-256, so repeat runs skip re-upload."})]})]})]})]}),e.jsx("input",{ref:A,type:"file",accept:".apk,.aab,.ipa,.zip,application/vnd.android.package-archive,application/zip,application/octet-stream",className:"hidden",onChange:t=>{var d;const a=(d=t.target.files)==null?void 0:d[0];a&&F(a)}})]})}export{re as M,ie as R};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,o as p,n as h,r as m}from"./vendor-react-
|
|
1
|
+
import{j as e,o as p,n as h,r as m}from"./vendor-react-DOVfxdUy.js";import{u as g}from"./vendor-query-DkZSMtfn.js";import{g as j,L as b,B as u}from"./index-BlA8ntjb.js";import{u as N,F as v,a as y}from"./FileViewer-Bcr9T1jW.js";import{ap as F,u as w,F as k}from"./vendor-icons-Cm92aSc5.js";import{E as f}from"./EmptyState-BShNSbLf.js";import"./RemoteFileStrip-dzPInzgb.js";import"./index-DLmlY2Ol.js";import"./useChartTheme-CTIe6M63.js";import"./sandboxStorage-BrzaG3ny.js";import"./simpleMarkdown-kWs-10D8.js";import"./formatDate-T65-Y6Mi.js";import"./UncommittedDiffViewer-BNroxCoo.js";function E(s){return g({queryKey:["moduleFiles",s],queryFn:()=>j(s),enabled:!!s,staleTime:15e3})}function M({path:s,onNavigate:r}){const t=s.split("/").filter(Boolean);return e.jsxs("nav",{className:"flex items-center gap-1 text-xs text-gray-400 px-1 overflow-x-auto",children:[e.jsx("button",{onClick:()=>r(""),className:"hover:text-gray-200 flex-shrink-0",children:e.jsx(F,{size:13})}),t.map((n,o)=>{const i=t.slice(0,o+1).join("/");return e.jsxs("span",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(w,{size:12,className:"text-gray-600"}),e.jsx("button",{onClick:()=>r(i),className:`hover:text-gray-200 truncate max-w-[120px] ${o===t.length-1?"text-gray-200 font-medium":""}`,children:n})]},i)})]})}function Q(){const{moduleId:s}=p(),{project:r}=h(),{data:t,isLoading:n}=E(s),{expanded:o,toggle:i}=N(),[c,x]=m.useState(null),l=r.modules.find(a=>a.id===s),d=m.useMemo(()=>t!=null&&t.files?t.files.map(a=>({name:a.name,path:a.path,type:"file",language:a.language})):[],[t]);return l?n?e.jsx(b,{text:`Loading ${l.label}...`}):e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-100",children:l.label}),e.jsx(u,{label:`${l.count} files`,color:"gray"}),e.jsx(u,{label:l.language,color:"blue"}),e.jsx("div",{className:"flex-1"}),e.jsx(M,{path:c??l.path,onNavigate:()=>x(null)})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx("div",{className:"w-64 border-r border-white/5 overflow-y-auto bg-surface-1 flex-shrink-0",children:d.length===0?e.jsx(f,{title:"No files",description:"This module has no source files",icon:e.jsx(k,{size:20})}):e.jsx("div",{className:"py-1",children:e.jsx(v,{nodes:d,expanded:o,selectedPath:c,onToggle:i,onSelect:x})})}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(y,{filePath:c})})]})]}):e.jsx(f,{title:"Module not found",description:`No module with id "${s}"`})}export{Q as ModuleExplorer};
|