@botbuddy/react 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');function O(n,p){let[f,R]=react.useState({x:n,y:p}),y=react.useRef(false),x=react.useRef({x:0,y:0}),S=react.useRef(false),D=react.useCallback(c=>{y.current=true,S.current=false,x.current={x:c.clientX-f.x,y:c.clientY-f.y},c.target.setPointerCapture(c.pointerId);},[f]),T=react.useCallback(c=>{y.current&&(S.current=true,R({x:c.clientX-x.current.x,y:c.clientY-x.current.y}));},[]),a=react.useCallback(()=>{y.current=false;},[]);return {pos:f,onPointerDown:D,onPointerMove:T,onPointerUp:a,didDrag:S}}function A(n){let[p,f]=react.useState(null),[R,y]=react.useState("loading"),x=react.useCallback(async()=>{try{let a=new URLSearchParams;n.testRunId&&a.set("test_run_id",n.testRunId),n.targetUrl&&a.set("target_url",n.targetUrl),a.set("app_slug",n.appSlug),a.set("environment",n.environment),n.version&&a.set("version",n.version),n.commitSha&&a.set("commit_sha",n.commitSha),n.branchName&&a.set("branch_name",n.branchName);let c=await fetch(`${n.config.serverUrl}/widget/test-run?${a.toString()}`,{headers:{Authorization:`Bearer ${n.config.anonKey}`,apikey:n.config.anonKey}});if(c.status===404){y("no-match"),f(null);return}if(!c.ok){y("error");return}let v=await c.json();f(v),y(v.status==="completed"?"completed":"ready");}catch{y("error");}},[n.config.serverUrl,n.config.anonKey,n.appSlug,n.environment,n.testRunId,n.targetUrl,n.version,n.commitSha,n.branchName]);return react.useEffect(()=>{x();},[x]),{run:p,widgetState:R,fetchRun:x,setVerdict:async(a,c,v,L="human")=>(f(m=>{if(!m)return null;let h=m.test_cases.map(u=>u.id===a?{...u,verdict:c,fail_reason:c==="fail"&&v||null,verdict_by_display_name:L,verdict_at:new Date().toISOString()}:u),b={total:h.length,pending:0,pass:0,fail:0,skip:0};return h.forEach(u=>{u.verdict in b&&b[u.verdict]++;}),{...m,test_cases:h,summary:b}}),(await fetch(`${n.config.serverUrl}/widget/test-cases/${a}/verdict`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.config.anonKey}`,apikey:n.config.anonKey},body:JSON.stringify({verdict:c,fail_reason:v,display_name:L})})).ok),markComplete:async()=>{if(!p)return false;let a=await fetch(`${n.config.serverUrl}/widget/test-runs/${p.id}/complete`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.config.anonKey}`,apikey:n.config.anonKey}});return a.ok&&x(),a.ok},resetRun:async()=>{if(!p)return false;let a=await fetch(`${n.config.serverUrl}/widget/test-runs/${p.id}/reset`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.config.anonKey}`,apikey:n.config.anonKey}});return a.ok&&x(),a.ok},setRun:f}}var g=({d:n,className:p})=>jsxRuntime.jsx("svg",{className:p,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:n})}),d={clipboard:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2",check:"M22 11.08V12a10 10 0 1 1-5.93-9.14M22 4 12 14.01l-3-3",x:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20M15 9l-6 6M9 9l6 6",circle:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20",skip:"M5 4l10 8-10 8V4M19 5v14",grip:"M9 5h.01M15 5h.01M9 12h.01M15 12h.01M9 19h.01M15 19h.01",minus:"M5 12h14",chevronUp:"M18 15l-6-6-6 6",chevronDown:"M6 9l6 6 6-6",externalLink:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14L21 3",pr:"M6 3v18M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6M18 9a9 9 0 0 1-9 9",ticket:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",loader:"M21 12a9 9 0 1 1-6.219-8.56",checkAll:"M18 6L7 17l-5-5M22 10l-7.5 7.5L13 16",alert:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0M12 9v4M12 17h.01"};var be={pending:d.circle,pass:d.check,fail:d.x,skip:d.skip},te={local:{bg:"rgba(59,130,246,0.15)",text:"#60a5fa",border:"rgba(59,130,246,0.3)"},preview:{bg:"rgba(168,85,247,0.15)",text:"#c084fc",border:"rgba(168,85,247,0.3)"},staging:{bg:"rgba(245,158,11,0.15)",text:"#fbbf24",border:"rgba(245,158,11,0.3)"},production:{bg:"rgba(239,68,68,0.15)",text:"#f87171",border:"rgba(239,68,68,0.3)"},custom:{bg:"rgba(128,128,128,0.15)",text:"#888",border:"rgba(128,128,128,0.3)"}},i={root:{position:"fixed",zIndex:9999,userSelect:"none",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},pill:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 8px",borderRadius:"9999px",background:"rgb(30,30,30)",border:"1px solid rgba(255,255,255,0.15)",boxShadow:"0 4px 12px rgba(0,0,0,0.3)",cursor:"pointer",fontSize:"9px",color:"#e5e5e5"},card:n=>({width:`${n}px`,borderRadius:"8px",background:"rgb(30,30,30)",border:"1px solid rgba(255,255,255,0.15)",boxShadow:"0 8px 24px rgba(0,0,0,0.4)",overflow:"hidden",display:"flex",flexDirection:"column"}),handle:{padding:"8px 12px",display:"flex",alignItems:"center",gap:"8px",cursor:"grab",borderBottom:"1px solid rgba(255,255,255,0.06)"},title:{fontSize:"10px",fontWeight:600,color:"#e5e5e5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},sub:{fontSize:"9px",color:"rgba(255,255,255,0.4)",display:"flex",alignItems:"center",gap:"6px"},btn:{padding:"2px",borderRadius:"4px",background:"transparent",border:"none",cursor:"pointer",color:"#888",display:"flex",flexShrink:0},stats:{padding:"4px 12px",display:"flex",alignItems:"center",gap:"8px",fontSize:"9px",borderBottom:"1px solid rgba(255,255,255,0.06)"},badge:n=>{let p=te[n]||te.custom;return {fontSize:"8px",padding:"0 4px",borderRadius:"4px",background:p.bg,color:p.text,border:`1px solid ${p.border}`,lineHeight:"14px"}},progress:{height:"2px",background:"rgba(255,255,255,0.06)",flexShrink:0},progressBar:n=>({height:"100%",width:`${n}%`,background:"linear-gradient(to right, #34d399, #3b82f6)",transition:"width 0.5s"}),link:n=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"9px",padding:"2px 6px",borderRadius:"4px",background:`${n}15`,color:n,textDecoration:"none",border:"none",cursor:"pointer"}),caseRow:{padding:"6px 12px",borderBottom:"1px solid rgba(255,255,255,0.06)",transition:"background 0.15s"},verdictBtn:(n,p)=>({fontSize:"8px",padding:"2px 6px",borderRadius:"4px",border:"none",cursor:"pointer",background:n?`${p}33`:"transparent",color:n?p:"#888",transition:"all 0.15s"}),input:{flex:1,fontSize:"9px",background:"rgba(0,0,0,0.3)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"4px",padding:"2px 6px",color:"#e5e5e5",outline:"none"}},ne="botbuddy-widget-state";function ve({config:n,appSlug:p,environment:f,testRunId:R,targetUrl:y,version:x,commitSha:S,branchName:D,onNavigate:T,displayName:a="human",defaultMode:c="expanded",defaultPosition:v}){let N=(()=>{try{let e=typeof window<"u"?localStorage.getItem(ne):null;if(e)return JSON.parse(e)}catch{}return null})(),[m,h]=react.useState(N?.mode||c),[b,u]=react.useState(""),[re,k]=react.useState(null),[Y,j]=react.useState(null),oe=N?.x??v?.x??16,ie=N?.y??v?.y??(typeof window<"u"?window.innerHeight-56:600),{pos:w,onPointerDown:E,onPointerMove:U,onPointerUp:$,didDrag:V}=O(oe,ie);react.useEffect(()=>{try{localStorage.setItem(ne,JSON.stringify({mode:m,x:w.x,y:w.y}));}catch{}},[m,w.x,w.y]);let F="botbuddy-widget-max-size",ae=()=>{try{let e=localStorage.getItem(F);if(e)return JSON.parse(e)}catch{}return {w:340,h:500}},[z,J]=react.useState(ae),P=react.useRef(false),C=react.useRef({x:0,y:0,w:0,h:0}),se=react.useCallback(e=>{e.stopPropagation(),P.current=true,C.current={x:e.clientX,y:e.clientY,w:z.w,h:z.h},e.target.setPointerCapture(e.pointerId);},[z]),le=react.useCallback(e=>{if(!P.current)return;let l=Math.max(280,Math.min(600,C.current.w+(e.clientX-C.current.x))),M=Math.max(300,Math.min(window.innerHeight*.9,C.current.h+(e.clientY-C.current.y)));J({w:l,h:M});},[]),de=react.useCallback(()=>{P.current&&(P.current=false,J(e=>(localStorage.setItem(F,JSON.stringify(e)),e)));},[]),{run:o,widgetState:_,fetchRun:pe,setVerdict:X,markComplete:ce,resetRun:ge}=A({config:n,appSlug:p,environment:f,testRunId:R,targetUrl:y,version:x,commitSha:S,branchName:D}),I=react.useCallback(async(e,l,M)=>{j(e);try{await X(e,l,M,a);}finally{j(null),k(null),u("");}},[X,a]),s=o?.summary||{total:0,pending:0,pass:0,fail:0,skip:0},ue=s.total>0&&s.pending===0,Z=s.total>0?(s.pass+s.fail)/s.total*100:0;if(_==="no-match"||_==="loading")return null;let G=()=>{V.current||h(e=>e==="mini"||e==="expanded"?"max":"mini");},q=({icon:e,onClick:l})=>jsxRuntime.jsx("button",{style:i.btn,onClick:M=>{M.stopPropagation(),l(M);},children:jsxRuntime.jsx(g,{d:e,className:""})});return jsxRuntime.jsxs("div",{style:{...i.root,left:w.x,top:w.y},children:[m==="mini"&&jsxRuntime.jsxs("div",{style:i.pill,onPointerDown:E,onPointerMove:U,onPointerUp:()=>{$(),V.current||G();},children:[jsxRuntime.jsx(g,{d:d.clipboard,className:""}),jsxRuntime.jsxs("span",{children:[s.pass,"/",s.total]}),s.fail>0&&jsxRuntime.jsxs("span",{style:{color:"#f87171"},children:[s.fail,"\u2717"]}),s.skip>0&&jsxRuntime.jsxs("span",{style:{color:"#f59e0b"},children:[s.skip,"\u23ED"]}),o?.pr_url&&jsxRuntime.jsxs("span",{style:{...i.link("#60a5fa"),pointerEvents:"none",textDecoration:"none"},children:[jsxRuntime.jsx(g,{d:d.pr,className:""}),o.pr_id||"PR"]}),o?.ticket_url&&jsxRuntime.jsxs("span",{style:{...i.link("#fbbf24"),pointerEvents:"none",textDecoration:"none"},children:[jsxRuntime.jsx(g,{d:d.ticket,className:""}),o.ticket_id||"TKT"]})]}),m==="expanded"&&jsxRuntime.jsxs("div",{style:i.card(300),children:[jsxRuntime.jsxs("div",{style:i.handle,onPointerDown:E,onPointerMove:U,onPointerUp:$,onClick:G,children:[jsxRuntime.jsx(g,{d:d.grip,className:""}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:i.title,children:o?.title}),o?.branch_name&&jsxRuntime.jsxs("div",{style:i.sub,children:["\u2387 ",o.branch_name]})]}),jsxRuntime.jsx(g,{d:d.chevronUp,className:""}),jsxRuntime.jsx(q,{icon:d.minus,onClick:()=>h("mini")})]}),jsxRuntime.jsxs("div",{style:i.stats,children:[jsxRuntime.jsxs("span",{style:{color:"#34d399"},children:[s.pass,"\u2713"]}),jsxRuntime.jsxs("span",{style:{color:"#f87171"},children:[s.fail,"\u2717"]}),jsxRuntime.jsxs("span",{style:{color:"#f59e0b"},children:[s.skip,"\u23ED"]}),jsxRuntime.jsxs("span",{style:{color:"#888"},children:[s.pending,"\u25CC"]}),jsxRuntime.jsx("span",{style:{color:"#555",marginLeft:"auto"},children:s.total})]}),o?.description&&jsxRuntime.jsx("div",{style:{padding:"6px 12px",fontSize:"10px",color:"#888",borderBottom:"1px solid rgba(255,255,255,0.06)",flexShrink:0},children:o.description}),jsxRuntime.jsxs("div",{style:{padding:"6px 12px",display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center",borderTop:"1px solid rgba(255,255,255,0.06)"},children:[o?.pr_url&&jsxRuntime.jsxs("a",{href:o.pr_url,target:"_blank",rel:"noopener noreferrer",style:{...i.link("#60a5fa"),textDecoration:"none"},children:[jsxRuntime.jsx(g,{d:d.pr,className:""}),o.pr_id||"PR"]}),o?.ticket_url&&jsxRuntime.jsxs("a",{href:o.ticket_url,target:"_blank",rel:"noopener noreferrer",style:{...i.link("#fbbf24"),textDecoration:"none"},children:[jsxRuntime.jsx(g,{d:d.ticket,className:""}),o.ticket_id||"Ticket"]}),jsxRuntime.jsx("span",{style:{...i.badge(o?.environment||"custom"),marginLeft:"auto"},children:o?.environment}),jsxRuntime.jsx("span",{style:{fontSize:"7px",color:"rgba(255,255,255,0.2)",letterSpacing:"0.05em"},children:"BotBuddy"})]}),jsxRuntime.jsx("div",{style:i.progress,children:jsxRuntime.jsx("div",{style:i.progressBar(Z)})})]}),m==="max"&&jsxRuntime.jsxs("div",{style:{...i.card(z.w),height:z.h,position:"relative"},children:[jsxRuntime.jsxs("div",{style:i.handle,onPointerDown:E,onPointerMove:U,onPointerUp:$,onClick:()=>{V.current||h("expanded");},children:[jsxRuntime.jsx(g,{d:d.grip,className:""}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:i.title,children:o?.title}),o?.branch_name&&jsxRuntime.jsxs("div",{style:i.sub,children:["\u2387 ",o.branch_name]})]}),jsxRuntime.jsx(g,{d:d.chevronDown,className:""}),jsxRuntime.jsx(q,{icon:d.minus,onClick:()=>h("mini")})]}),jsxRuntime.jsxs("div",{style:i.stats,children:[jsxRuntime.jsxs("span",{style:{color:"#34d399"},children:[s.pass,"\u2713"]}),jsxRuntime.jsxs("span",{style:{color:"#f87171"},children:[s.fail,"\u2717"]}),jsxRuntime.jsxs("span",{style:{color:"#f59e0b"},children:[s.skip,"\u23ED"]}),jsxRuntime.jsxs("span",{style:{color:"#888"},children:[s.pending,"\u25CC"]}),jsxRuntime.jsx("span",{style:{color:"#555",marginLeft:"auto"},children:s.total})]}),_==="error"&&jsxRuntime.jsxs("div",{style:{padding:"12px",textAlign:"center"},children:[jsxRuntime.jsx(g,{d:d.alert,className:""}),jsxRuntime.jsx("div",{style:{fontSize:"10px",color:"#f87171"},children:"Failed to load"}),jsxRuntime.jsx("button",{onClick:pe,style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",marginTop:"4px"},children:"Retry"})]}),_==="completed"&&jsxRuntime.jsxs("div",{style:{padding:"12px",textAlign:"center",borderBottom:"1px solid rgba(255,255,255,0.06)"},children:[jsxRuntime.jsx(g,{d:d.checkAll,className:""}),jsxRuntime.jsx("div",{style:{fontSize:"10px",color:"#34d399"},children:"Run completed"}),jsxRuntime.jsx("button",{onClick:ge,style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",marginTop:"4px"},children:"Reset & re-test"})]}),o?.intro_notes&&jsxRuntime.jsx("div",{style:{padding:"6px 12px",borderBottom:"1px solid rgba(255,255,255,0.06)",fontSize:"10px",color:"rgba(255,255,255,0.4)",fontStyle:"italic",flexShrink:0},children:o.intro_notes}),_!=="error"&&jsxRuntime.jsx("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:(o?.test_cases||[]).length===0?jsxRuntime.jsx("div",{style:{padding:"16px 12px",textAlign:"center",fontSize:"10px",color:"#888"},children:"No test cases"}):(o?.test_cases||[]).map(e=>jsxRuntime.jsxs("div",{style:i.caseRow,children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px"},children:[jsxRuntime.jsx("div",{style:{marginTop:"2px",flexShrink:0},children:Y===e.id?jsxRuntime.jsx(g,{d:d.loader,className:""}):jsxRuntime.jsx(g,{d:be[e.verdict],className:""})}),jsxRuntime.jsxs("div",{style:{minWidth:0,flex:1},children:[jsxRuntime.jsx("div",{style:{fontSize:"10px",color:"#e5e5e5",lineHeight:1.3},children:e.title}),e.description&&jsxRuntime.jsx("div",{style:{fontSize:"9px",color:"#888",marginTop:"2px"},children:e.description}),e.url_path&&jsxRuntime.jsxs("a",{href:e.url_path,target:"_blank",rel:"noopener noreferrer",onClick:l=>{l.stopPropagation(),T&&(l.preventDefault(),T(e.url_path));},style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",padding:"2px 0",marginTop:"2px",display:"inline-flex",alignItems:"center",gap:"2px",textDecoration:"none",position:"relative",zIndex:1,pointerEvents:"auto"},children:[jsxRuntime.jsx(g,{d:d.externalLink,className:""}),e.url_path]}),e.verdict==="fail"&&e.fail_reason&&jsxRuntime.jsxs("div",{style:{fontSize:"9px",color:"#f87171",marginTop:"2px"},children:["\u2717 ",e.fail_reason]})]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginTop:"4px",marginLeft:"22px"},children:[["pass","fail","skip"].map(l=>jsxRuntime.jsx("button",{onClick:()=>{if(e.verdict===l){I(e.id,"pending"),k(null);return}if(l==="fail"){I(e.id,"fail"),k(e.id),u("");return}k(null),I(e.id,l);},disabled:Y!==null,style:i.verdictBtn(e.verdict===l,l==="pass"?"#34d399":l==="fail"?"#f87171":"#f59e0b"),children:l.toUpperCase()},l)),e.verdict_by_display_name&&jsxRuntime.jsx("span",{style:{fontSize:"8px",color:"#555",marginLeft:"auto"},children:e.verdict_by_display_name})]}),re===e.id&&e.verdict==="fail"&&jsxRuntime.jsxs("div",{style:{marginLeft:"22px",marginTop:"4px",display:"flex",gap:"4px"},children:[jsxRuntime.jsx("input",{autoFocus:true,value:b,onChange:l=>u(l.target.value),onKeyDown:l=>{l.key==="Enter"&&b.trim()&&(I(e.id,"fail",b),k(null),u("")),l.key==="Escape"&&(k(null),u(""));},placeholder:"Reason (optional)...",style:i.input}),jsxRuntime.jsx("button",{onClick:()=>{b.trim()&&I(e.id,"fail",b),k(null),u("");},style:i.verdictBtn(true,"#f87171"),children:"\u2713"})]})]},e.id))}),ue&&_!=="completed"&&jsxRuntime.jsxs("div",{style:{padding:"6px 12px",borderTop:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[jsxRuntime.jsx("span",{style:{fontSize:"9px",color:"#34d399"},children:"All resolved"}),jsxRuntime.jsx("button",{onClick:ce,style:{fontSize:"8px",padding:"2px 8px",borderRadius:"4px",background:"rgba(59,130,246,0.15)",color:"#60a5fa",border:"none",cursor:"pointer"},children:"COMPLETE"})]}),jsxRuntime.jsxs("div",{style:{padding:"6px 12px",display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center",borderTop:"1px solid rgba(255,255,255,0.06)",flexShrink:0},children:[o?.pr_url&&jsxRuntime.jsxs("a",{href:o.pr_url,target:"_blank",rel:"noopener noreferrer",style:{...i.link("#60a5fa"),textDecoration:"none"},children:[jsxRuntime.jsx(g,{d:d.pr,className:""}),o.pr_id||"PR"]}),o?.ticket_url&&jsxRuntime.jsxs("a",{href:o.ticket_url,target:"_blank",rel:"noopener noreferrer",style:{...i.link("#fbbf24"),textDecoration:"none"},children:[jsxRuntime.jsx(g,{d:d.ticket,className:""}),o.ticket_id||"Ticket"]}),o?.created_by_agent_name&&jsxRuntime.jsxs("span",{style:{fontSize:"9px",color:"#888"},children:["by ",o.created_by_agent_name]}),jsxRuntime.jsx("span",{style:{...i.badge(o?.environment||"custom"),marginLeft:"auto"},children:o?.environment}),jsxRuntime.jsxs("button",{onClick:()=>{navigator.clipboard.writeText("0.1.9");},style:{fontSize:"7px",color:"rgba(255,255,255,0.7)",letterSpacing:"0.05em",background:"none",border:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"2px",padding:0},title:"Copy version",children:["BotBuddy v0.1.9",jsxRuntime.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),jsxRuntime.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})]})]}),jsxRuntime.jsx("div",{style:i.progress,children:jsxRuntime.jsx("div",{style:i.progressBar(Z)})}),jsxRuntime.jsx("div",{style:{position:"absolute",bottom:0,right:0,width:16,height:16,cursor:"se-resize",zIndex:10,display:"flex",alignItems:"flex-end",justifyContent:"flex-end",padding:"2px",opacity:.3},onPointerDown:se,onPointerMove:le,onPointerUp:de,onPointerEnter:e=>e.currentTarget.style.opacity="0.7",onPointerLeave:e=>{P.current||(e.currentTarget.style.opacity="0.3");},children:jsxRuntime.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",children:jsxRuntime.jsx("path",{d:"M7 1v6H1",fill:"none",stroke:"#888",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}exports.TestRunWidget=ve;exports.useDraggable=O;exports.useTestRun=A;
|
|
1
|
+
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');function A(n,p){let[f,R]=react.useState({x:n,y:p}),y=react.useRef(false),x=react.useRef({x:0,y:0}),w=react.useRef(false),N=react.useCallback(g=>{y.current=true,w.current=false,x.current={x:g.clientX-f.x,y:g.clientY-f.y},g.target.setPointerCapture(g.pointerId);},[f]),T=react.useCallback(g=>{y.current&&(w.current=true,R({x:g.clientX-x.current.x,y:g.clientY-x.current.y}));},[]),a=react.useCallback(()=>{y.current=false;},[]);return {pos:f,onPointerDown:N,onPointerMove:T,onPointerUp:a,didDrag:w}}function Y(n){let[p,f]=react.useState(null),[R,y]=react.useState("loading"),x=react.useCallback(async()=>{try{let a=new URLSearchParams;n.testRunId&&a.set("test_run_id",n.testRunId),n.targetUrl&&a.set("target_url",n.targetUrl),a.set("app_slug",n.appSlug),a.set("environment",n.environment),n.version&&a.set("version",n.version),n.commitSha&&a.set("commit_sha",n.commitSha),n.branchName&&a.set("branch_name",n.branchName);let g=await fetch(`${n.config.serverUrl}/widget/test-run?${a.toString()}`,{headers:{Authorization:`Bearer ${n.config.anonKey}`,apikey:n.config.anonKey}});if(g.status===404){y("no-match"),f(null);return}if(!g.ok){y("error");return}let v=await g.json();f(v),y(v.status==="completed"?"completed":"ready");}catch{y("error");}},[n.config.serverUrl,n.config.anonKey,n.appSlug,n.environment,n.testRunId,n.targetUrl,n.version,n.commitSha,n.branchName]);return react.useEffect(()=>{x();},[x]),{run:p,widgetState:R,fetchRun:x,setVerdict:async(a,g,v,E="human")=>(f(b=>{if(!b)return null;let h=b.test_cases.map(u=>u.id===a?{...u,verdict:g,fail_reason:g==="fail"&&v||null,verdict_by_display_name:E,verdict_at:new Date().toISOString()}:u),m={total:h.length,pending:0,pass:0,fail:0,skip:0};return h.forEach(u=>{u.verdict in m&&m[u.verdict]++;}),{...b,test_cases:h,summary:m}}),(await fetch(`${n.config.serverUrl}/widget/test-cases/${a}/verdict`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.config.anonKey}`,apikey:n.config.anonKey},body:JSON.stringify({verdict:g,fail_reason:v,display_name:E})})).ok),markComplete:async()=>{if(!p)return false;let a=await fetch(`${n.config.serverUrl}/widget/test-runs/${p.id}/complete`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.config.anonKey}`,apikey:n.config.anonKey}});return a.ok&&x(),a.ok},resetRun:async()=>{if(!p)return false;let a=await fetch(`${n.config.serverUrl}/widget/test-runs/${p.id}/reset`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.config.anonKey}`,apikey:n.config.anonKey}});return a.ok&&x(),a.ok},setRun:f}}var c=({d:n,className:p})=>jsxRuntime.jsx("svg",{className:p,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:n})}),d={clipboard:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2",check:"M22 11.08V12a10 10 0 1 1-5.93-9.14M22 4 12 14.01l-3-3",x:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20M15 9l-6 6M9 9l6 6",circle:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20",skip:"M5 4l10 8-10 8V4M19 5v14",grip:"M9 5h.01M15 5h.01M9 12h.01M15 12h.01M9 19h.01M15 19h.01",minus:"M5 12h14",chevronUp:"M18 15l-6-6-6 6",chevronDown:"M6 9l6 6 6-6",externalLink:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14L21 3",pr:"M6 3v18M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6M18 9a9 9 0 0 1-9 9",ticket:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",loader:"M21 12a9 9 0 1 1-6.219-8.56",checkAll:"M18 6L7 17l-5-5M22 10l-7.5 7.5L13 16",alert:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0M12 9v4M12 17h.01"};var ve={pending:d.circle,pass:d.check,fail:d.x,skip:d.skip},ne={local:{bg:"rgba(59,130,246,0.15)",text:"#60a5fa",border:"rgba(59,130,246,0.3)"},preview:{bg:"rgba(168,85,247,0.15)",text:"#c084fc",border:"rgba(168,85,247,0.3)"},staging:{bg:"rgba(245,158,11,0.15)",text:"#fbbf24",border:"rgba(245,158,11,0.3)"},production:{bg:"rgba(239,68,68,0.15)",text:"#f87171",border:"rgba(239,68,68,0.3)"},custom:{bg:"rgba(128,128,128,0.15)",text:"#888",border:"rgba(128,128,128,0.3)"}},i={root:{position:"fixed",zIndex:9999,userSelect:"none",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},pill:n=>({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 8px",borderRadius:"9999px",background:"rgb(30,30,30)",border:n?"1px solid rgba(52,211,153,0.6)":"1px solid rgba(255,255,255,0.15)",boxShadow:n?"0 4px 12px rgba(0,0,0,0.3), 0 0 0 1px rgba(52,211,153,0.2)":"0 4px 12px rgba(0,0,0,0.3)",cursor:"pointer",fontSize:"9px",color:"#e5e5e5"}),card:(n,p)=>({width:`${n}px`,borderRadius:"8px",background:"rgb(30,30,30)",border:p?"1px solid rgba(52,211,153,0.6)":"1px solid rgba(255,255,255,0.15)",boxShadow:p?"0 8px 24px rgba(0,0,0,0.4), 0 0 0 1px rgba(52,211,153,0.2)":"0 8px 24px rgba(0,0,0,0.4)",overflow:"hidden",display:"flex",flexDirection:"column"}),handle:{padding:"8px 12px",display:"flex",alignItems:"center",gap:"8px",cursor:"grab",borderBottom:"1px solid rgba(255,255,255,0.06)"},title:{fontSize:"10px",fontWeight:600,color:"#e5e5e5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},sub:{fontSize:"9px",color:"rgba(255,255,255,0.4)",display:"flex",alignItems:"center",gap:"6px"},btn:{padding:"2px",borderRadius:"4px",background:"transparent",border:"none",cursor:"pointer",color:"#888",display:"flex",flexShrink:0},stats:{padding:"4px 12px",display:"flex",alignItems:"center",gap:"8px",fontSize:"9px",borderBottom:"1px solid rgba(255,255,255,0.06)"},badge:n=>{let p=ne[n]||ne.custom;return {fontSize:"8px",padding:"0 4px",borderRadius:"4px",background:p.bg,color:p.text,border:`1px solid ${p.border}`,lineHeight:"14px"}},progress:{height:"2px",background:"rgba(255,255,255,0.06)",flexShrink:0},progressBar:n=>({height:"100%",width:`${n}%`,background:"linear-gradient(to right, #34d399, #3b82f6)",transition:"width 0.5s"}),link:n=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"9px",padding:"2px 6px",borderRadius:"4px",background:`${n}15`,color:n,textDecoration:"none",border:"none",cursor:"pointer"}),caseRow:{padding:"6px 12px",borderBottom:"1px solid rgba(255,255,255,0.06)",transition:"background 0.15s"},verdictBtn:(n,p)=>({fontSize:"8px",padding:"2px 6px",borderRadius:"4px",border:"none",cursor:"pointer",background:n?`${p}33`:"transparent",color:n?p:"#888",transition:"all 0.15s"}),input:{flex:1,fontSize:"9px",background:"rgba(0,0,0,0.3)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"4px",padding:"2px 6px",color:"#e5e5e5",outline:"none"}},re="botbuddy-widget-state";function he({config:n,appSlug:p,environment:f,testRunId:R,targetUrl:y,version:x,commitSha:w,branchName:N,onNavigate:T,displayName:a="human",defaultMode:g="expanded",defaultPosition:v}){let W=(()=>{try{let t=typeof window<"u"?localStorage.getItem(re):null;if(t)return JSON.parse(t)}catch{}return null})(),[b,h]=react.useState(W?.mode||g),[m,u]=react.useState(""),[oe,k]=react.useState(null),[j,F]=react.useState(null),ie=W?.x??v?.x??16,ae=W?.y??v?.y??(typeof window<"u"?window.innerHeight-56:600),{pos:_,onPointerDown:U,onPointerMove:$,onPointerUp:V,didDrag:H}=A(ie,ae);react.useEffect(()=>{try{localStorage.setItem(re,JSON.stringify({mode:b,x:_.x,y:_.y}));}catch{}},[b,_.x,_.y]);let J="botbuddy-widget-max-size",se=()=>{try{let t=localStorage.getItem(J);if(t)return JSON.parse(t)}catch{}return {w:340,h:500}},[z,X]=react.useState(se),C=react.useRef(false),P=react.useRef({x:0,y:0,w:0,h:0}),le=react.useCallback(t=>{t.stopPropagation(),C.current=true,P.current={x:t.clientX,y:t.clientY,w:z.w,h:z.h},t.target.setPointerCapture(t.pointerId);},[z]),de=react.useCallback(t=>{if(!C.current)return;let l=Math.max(280,Math.min(600,P.current.w+(t.clientX-P.current.x))),M=Math.max(300,Math.min(window.innerHeight*.9,P.current.h+(t.clientY-P.current.y)));X({w:l,h:M});},[]),pe=react.useCallback(()=>{C.current&&(C.current=false,X(t=>(localStorage.setItem(J,JSON.stringify(t)),t)));},[]),{run:o,widgetState:I,fetchRun:ce,setVerdict:Z,markComplete:ge,resetRun:ue}=Y({config:n,appSlug:p,environment:f,testRunId:R,targetUrl:y,version:x,commitSha:w,branchName:N}),B=react.useCallback(async(t,l,M)=>{F(t);try{await Z(t,l,M,a);}finally{F(null),k(null),u("");}},[Z,a]),s=o?.summary||{total:0,pending:0,pass:0,fail:0,skip:0},fe=s.total>0&&s.pending===0,S=I==="completed",G=s.total>0?(s.pass+s.fail)/s.total*100:0;if(I==="no-match"||I==="loading")return null;let q=()=>{H.current||h(t=>t==="mini"||t==="expanded"?"max":"mini");},Q=({icon:t,onClick:l})=>jsxRuntime.jsx("button",{style:i.btn,onClick:M=>{M.stopPropagation(),l(M);},children:jsxRuntime.jsx(c,{d:t,className:""})});return jsxRuntime.jsxs("div",{style:{...i.root,left:_.x,top:_.y},children:[b==="mini"&&jsxRuntime.jsxs("div",{style:i.pill(S),onPointerDown:U,onPointerMove:$,onPointerUp:()=>{V(),H.current||q();},children:[S?jsxRuntime.jsx(c,{d:d.checkAll,className:""}):jsxRuntime.jsx(c,{d:d.clipboard,className:""}),jsxRuntime.jsxs("span",{style:S?{color:"#34d399"}:void 0,children:[s.pass,"/",s.total]}),s.fail>0&&jsxRuntime.jsxs("span",{style:{color:"#f87171"},children:[s.fail,"\u2717"]}),s.skip>0&&jsxRuntime.jsxs("span",{style:{color:"#f59e0b"},children:[s.skip,"\u23ED"]}),o?.pr_url&&jsxRuntime.jsxs("span",{style:{...i.link("#60a5fa"),pointerEvents:"none",textDecoration:"none"},children:[jsxRuntime.jsx(c,{d:d.pr,className:""}),o.pr_id||"PR"]}),o?.ticket_url&&jsxRuntime.jsxs("span",{style:{...i.link("#fbbf24"),pointerEvents:"none",textDecoration:"none"},children:[jsxRuntime.jsx(c,{d:d.ticket,className:""}),o.ticket_id||"TKT"]})]}),b==="expanded"&&jsxRuntime.jsxs("div",{style:i.card(300,S),children:[jsxRuntime.jsxs("div",{style:i.handle,onPointerDown:U,onPointerMove:$,onPointerUp:V,onClick:q,children:[jsxRuntime.jsx(c,{d:d.grip,className:""}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:i.title,children:o?.title}),o?.branch_name&&jsxRuntime.jsxs("div",{style:i.sub,children:["\u2387 ",o.branch_name]})]}),jsxRuntime.jsx(c,{d:d.chevronUp,className:""}),jsxRuntime.jsx(Q,{icon:d.minus,onClick:()=>h("mini")})]}),jsxRuntime.jsxs("div",{style:i.stats,children:[jsxRuntime.jsxs("span",{style:{color:"#34d399"},children:[s.pass,"\u2713"]}),jsxRuntime.jsxs("span",{style:{color:"#f87171"},children:[s.fail,"\u2717"]}),jsxRuntime.jsxs("span",{style:{color:"#f59e0b"},children:[s.skip,"\u23ED"]}),jsxRuntime.jsxs("span",{style:{color:"#888"},children:[s.pending,"\u25CC"]}),jsxRuntime.jsx("span",{style:{color:"#555",marginLeft:"auto"},children:s.total})]}),o?.description&&jsxRuntime.jsx("div",{style:{padding:"6px 12px",fontSize:"10px",color:"#888",borderBottom:"1px solid rgba(255,255,255,0.06)",flexShrink:0},children:o.description}),jsxRuntime.jsxs("div",{style:{padding:"6px 12px",display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center",borderTop:"1px solid rgba(255,255,255,0.06)"},children:[o?.pr_url&&jsxRuntime.jsxs("a",{href:o.pr_url,target:"_blank",rel:"noopener noreferrer",style:{...i.link("#60a5fa"),textDecoration:"none"},children:[jsxRuntime.jsx(c,{d:d.pr,className:""}),o.pr_id||"PR"]}),o?.ticket_url&&jsxRuntime.jsxs("a",{href:o.ticket_url,target:"_blank",rel:"noopener noreferrer",style:{...i.link("#fbbf24"),textDecoration:"none"},children:[jsxRuntime.jsx(c,{d:d.ticket,className:""}),o.ticket_id||"Ticket"]}),jsxRuntime.jsx("span",{style:{...i.badge(o?.environment||"custom"),marginLeft:"auto"},children:o?.environment}),jsxRuntime.jsx("span",{style:{fontSize:"7px",color:"rgba(255,255,255,0.2)",letterSpacing:"0.05em"},children:"BotBuddy"})]}),jsxRuntime.jsx("div",{style:i.progress,children:jsxRuntime.jsx("div",{style:i.progressBar(G)})})]}),b==="max"&&jsxRuntime.jsxs("div",{style:{...i.card(z.w,S),height:z.h,position:"relative"},children:[jsxRuntime.jsxs("div",{style:i.handle,onPointerDown:U,onPointerMove:$,onPointerUp:V,onClick:()=>{H.current||h("expanded");},children:[jsxRuntime.jsx(c,{d:d.grip,className:""}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:i.title,children:o?.title}),o?.branch_name&&jsxRuntime.jsxs("div",{style:i.sub,children:["\u2387 ",o.branch_name]})]}),jsxRuntime.jsx(c,{d:d.chevronDown,className:""}),jsxRuntime.jsx(Q,{icon:d.minus,onClick:()=>h("mini")})]}),jsxRuntime.jsxs("div",{style:i.stats,children:[jsxRuntime.jsxs("span",{style:{color:"#34d399"},children:[s.pass,"\u2713"]}),jsxRuntime.jsxs("span",{style:{color:"#f87171"},children:[s.fail,"\u2717"]}),jsxRuntime.jsxs("span",{style:{color:"#f59e0b"},children:[s.skip,"\u23ED"]}),jsxRuntime.jsxs("span",{style:{color:"#888"},children:[s.pending,"\u25CC"]}),jsxRuntime.jsx("span",{style:{color:"#555",marginLeft:"auto"},children:s.total})]}),I==="error"&&jsxRuntime.jsxs("div",{style:{padding:"12px",textAlign:"center"},children:[jsxRuntime.jsx(c,{d:d.alert,className:""}),jsxRuntime.jsx("div",{style:{fontSize:"10px",color:"#f87171"},children:"Failed to load"}),jsxRuntime.jsx("button",{onClick:ce,style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",marginTop:"4px"},children:"Retry"})]}),S&&jsxRuntime.jsxs("div",{style:{padding:"6px 12px",display:"flex",alignItems:"center",gap:"8px",borderBottom:"1px solid rgba(52,211,153,0.2)",background:"rgba(52,211,153,0.05)"},children:[jsxRuntime.jsx(c,{d:d.checkAll,className:""}),jsxRuntime.jsx("span",{style:{fontSize:"10px",color:"#34d399",flex:1},children:"Run completed"}),jsxRuntime.jsx("button",{onClick:ue,style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer"},children:"Reset"})]}),o?.intro_notes&&jsxRuntime.jsx("div",{style:{padding:"6px 12px",borderBottom:"1px solid rgba(255,255,255,0.06)",fontSize:"10px",color:"rgba(255,255,255,0.4)",fontStyle:"italic",flexShrink:0},children:o.intro_notes}),I!=="error"&&jsxRuntime.jsx("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:(o?.test_cases||[]).length===0?jsxRuntime.jsx("div",{style:{padding:"16px 12px",textAlign:"center",fontSize:"10px",color:"#888"},children:"No test cases"}):(o?.test_cases||[]).map(t=>jsxRuntime.jsxs("div",{style:i.caseRow,children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px"},children:[jsxRuntime.jsx("div",{style:{marginTop:"2px",flexShrink:0},children:j===t.id?jsxRuntime.jsx(c,{d:d.loader,className:""}):jsxRuntime.jsx(c,{d:ve[t.verdict],className:""})}),jsxRuntime.jsxs("div",{style:{minWidth:0,flex:1},children:[jsxRuntime.jsx("div",{style:{fontSize:"10px",color:"#e5e5e5",lineHeight:1.3},children:t.title}),t.description&&jsxRuntime.jsx("div",{style:{fontSize:"9px",color:"#888",marginTop:"2px"},children:t.description}),t.url_path&&jsxRuntime.jsxs("a",{href:t.url_path,target:"_blank",rel:"noopener noreferrer",onClick:l=>{l.stopPropagation(),T&&(l.preventDefault(),T(t.url_path));},style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",padding:"2px 0",marginTop:"2px",display:"inline-flex",alignItems:"center",gap:"2px",textDecoration:"none",position:"relative",zIndex:1,pointerEvents:"auto"},children:[jsxRuntime.jsx(c,{d:d.externalLink,className:""}),t.url_path]}),t.verdict==="fail"&&t.fail_reason&&jsxRuntime.jsxs("div",{style:{fontSize:"9px",color:"#f87171",marginTop:"2px"},children:["\u2717 ",t.fail_reason]})]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginTop:"4px",marginLeft:"22px"},children:[["pass","fail","skip"].map(l=>jsxRuntime.jsx("button",{onClick:()=>{if(t.verdict===l){B(t.id,"pending"),k(null);return}if(l==="fail"){B(t.id,"fail"),k(t.id),u("");return}k(null),B(t.id,l);},disabled:j!==null,style:i.verdictBtn(t.verdict===l,l==="pass"?"#34d399":l==="fail"?"#f87171":"#f59e0b"),children:l.toUpperCase()},l)),t.verdict_by_display_name&&jsxRuntime.jsx("span",{style:{fontSize:"8px",color:"#555",marginLeft:"auto"},children:t.verdict_by_display_name})]}),oe===t.id&&t.verdict==="fail"&&jsxRuntime.jsxs("div",{style:{marginLeft:"22px",marginTop:"4px",display:"flex",gap:"4px"},children:[jsxRuntime.jsx("input",{autoFocus:true,value:m,onChange:l=>u(l.target.value),onKeyDown:l=>{l.key==="Enter"&&m.trim()&&(B(t.id,"fail",m),k(null),u("")),l.key==="Escape"&&(k(null),u(""));},placeholder:"Reason (optional)...",style:i.input}),jsxRuntime.jsx("button",{onClick:()=>{m.trim()&&B(t.id,"fail",m),k(null),u("");},style:i.verdictBtn(true,"#f87171"),children:"\u2713"})]})]},t.id))}),fe&&!S&&jsxRuntime.jsxs("div",{style:{padding:"6px 12px",borderTop:"1px solid rgba(52,211,153,0.2)",background:"rgba(52,211,153,0.05)",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[jsxRuntime.jsx("span",{style:{fontSize:"9px",color:"#34d399"},children:"All resolved"}),jsxRuntime.jsx("button",{onClick:ge,style:{fontSize:"8px",padding:"2px 8px",borderRadius:"4px",background:"rgba(52,211,153,0.15)",color:"#34d399",border:"1px solid rgba(52,211,153,0.3)",cursor:"pointer"},children:"COMPLETE"})]}),jsxRuntime.jsxs("div",{style:{padding:"6px 12px",display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center",borderTop:"1px solid rgba(255,255,255,0.06)",flexShrink:0},children:[o?.pr_url&&jsxRuntime.jsxs("a",{href:o.pr_url,target:"_blank",rel:"noopener noreferrer",style:{...i.link("#60a5fa"),textDecoration:"none"},children:[jsxRuntime.jsx(c,{d:d.pr,className:""}),o.pr_id||"PR"]}),o?.ticket_url&&jsxRuntime.jsxs("a",{href:o.ticket_url,target:"_blank",rel:"noopener noreferrer",style:{...i.link("#fbbf24"),textDecoration:"none"},children:[jsxRuntime.jsx(c,{d:d.ticket,className:""}),o.ticket_id||"Ticket"]}),o?.created_by_agent_name&&jsxRuntime.jsxs("span",{style:{fontSize:"9px",color:"#888"},children:["by ",o.created_by_agent_name]}),jsxRuntime.jsx("span",{style:{...i.badge(o?.environment||"custom"),marginLeft:"auto"},children:o?.environment}),jsxRuntime.jsxs("button",{onClick:()=>{navigator.clipboard.writeText("0.1.9");},style:{fontSize:"7px",color:"rgba(255,255,255,0.7)",letterSpacing:"0.05em",background:"none",border:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"2px",padding:0},title:"Copy version",children:["BotBuddy v0.1.9",jsxRuntime.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),jsxRuntime.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})]})]}),jsxRuntime.jsx("div",{style:i.progress,children:jsxRuntime.jsx("div",{style:i.progressBar(G)})}),jsxRuntime.jsx("div",{style:{position:"absolute",bottom:0,right:0,width:16,height:16,cursor:"se-resize",zIndex:10,display:"flex",alignItems:"flex-end",justifyContent:"flex-end",padding:"2px",opacity:.3},onPointerDown:le,onPointerMove:de,onPointerUp:pe,onPointerEnter:t=>t.currentTarget.style.opacity="0.7",onPointerLeave:t=>{C.current||(t.currentTarget.style.opacity="0.3");},children:jsxRuntime.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",children:jsxRuntime.jsx("path",{d:"M7 1v6H1",fill:"none",stroke:"#888",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}exports.TestRunWidget=he;exports.useDraggable=A;exports.useTestRun=Y;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {useState,useRef,useCallback,useEffect}from'react';import {jsxs,jsx}from'react/jsx-runtime';function O(n,p){let[f,R]=useState({x:n,y:p}),y=useRef(false),x=useRef({x:0,y:0}),S=useRef(false),D=useCallback(c=>{y.current=true,S.current=false,x.current={x:c.clientX-f.x,y:c.clientY-f.y},c.target.setPointerCapture(c.pointerId);},[f]),T=useCallback(c=>{y.current&&(S.current=true,R({x:c.clientX-x.current.x,y:c.clientY-x.current.y}));},[]),a=useCallback(()=>{y.current=false;},[]);return {pos:f,onPointerDown:D,onPointerMove:T,onPointerUp:a,didDrag:S}}function A(n){let[p,f]=useState(null),[R,y]=useState("loading"),x=useCallback(async()=>{try{let a=new URLSearchParams;n.testRunId&&a.set("test_run_id",n.testRunId),n.targetUrl&&a.set("target_url",n.targetUrl),a.set("app_slug",n.appSlug),a.set("environment",n.environment),n.version&&a.set("version",n.version),n.commitSha&&a.set("commit_sha",n.commitSha),n.branchName&&a.set("branch_name",n.branchName);let c=await fetch(`${n.config.serverUrl}/widget/test-run?${a.toString()}`,{headers:{Authorization:`Bearer ${n.config.anonKey}`,apikey:n.config.anonKey}});if(c.status===404){y("no-match"),f(null);return}if(!c.ok){y("error");return}let v=await c.json();f(v),y(v.status==="completed"?"completed":"ready");}catch{y("error");}},[n.config.serverUrl,n.config.anonKey,n.appSlug,n.environment,n.testRunId,n.targetUrl,n.version,n.commitSha,n.branchName]);return useEffect(()=>{x();},[x]),{run:p,widgetState:R,fetchRun:x,setVerdict:async(a,c,v,L="human")=>(f(m=>{if(!m)return null;let h=m.test_cases.map(u=>u.id===a?{...u,verdict:c,fail_reason:c==="fail"&&v||null,verdict_by_display_name:L,verdict_at:new Date().toISOString()}:u),b={total:h.length,pending:0,pass:0,fail:0,skip:0};return h.forEach(u=>{u.verdict in b&&b[u.verdict]++;}),{...m,test_cases:h,summary:b}}),(await fetch(`${n.config.serverUrl}/widget/test-cases/${a}/verdict`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.config.anonKey}`,apikey:n.config.anonKey},body:JSON.stringify({verdict:c,fail_reason:v,display_name:L})})).ok),markComplete:async()=>{if(!p)return false;let a=await fetch(`${n.config.serverUrl}/widget/test-runs/${p.id}/complete`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.config.anonKey}`,apikey:n.config.anonKey}});return a.ok&&x(),a.ok},resetRun:async()=>{if(!p)return false;let a=await fetch(`${n.config.serverUrl}/widget/test-runs/${p.id}/reset`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.config.anonKey}`,apikey:n.config.anonKey}});return a.ok&&x(),a.ok},setRun:f}}var g=({d:n,className:p})=>jsx("svg",{className:p,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:n})}),d={clipboard:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2",check:"M22 11.08V12a10 10 0 1 1-5.93-9.14M22 4 12 14.01l-3-3",x:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20M15 9l-6 6M9 9l6 6",circle:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20",skip:"M5 4l10 8-10 8V4M19 5v14",grip:"M9 5h.01M15 5h.01M9 12h.01M15 12h.01M9 19h.01M15 19h.01",minus:"M5 12h14",chevronUp:"M18 15l-6-6-6 6",chevronDown:"M6 9l6 6 6-6",externalLink:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14L21 3",pr:"M6 3v18M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6M18 9a9 9 0 0 1-9 9",ticket:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",loader:"M21 12a9 9 0 1 1-6.219-8.56",checkAll:"M18 6L7 17l-5-5M22 10l-7.5 7.5L13 16",alert:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0M12 9v4M12 17h.01"};var be={pending:d.circle,pass:d.check,fail:d.x,skip:d.skip},te={local:{bg:"rgba(59,130,246,0.15)",text:"#60a5fa",border:"rgba(59,130,246,0.3)"},preview:{bg:"rgba(168,85,247,0.15)",text:"#c084fc",border:"rgba(168,85,247,0.3)"},staging:{bg:"rgba(245,158,11,0.15)",text:"#fbbf24",border:"rgba(245,158,11,0.3)"},production:{bg:"rgba(239,68,68,0.15)",text:"#f87171",border:"rgba(239,68,68,0.3)"},custom:{bg:"rgba(128,128,128,0.15)",text:"#888",border:"rgba(128,128,128,0.3)"}},i={root:{position:"fixed",zIndex:9999,userSelect:"none",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},pill:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 8px",borderRadius:"9999px",background:"rgb(30,30,30)",border:"1px solid rgba(255,255,255,0.15)",boxShadow:"0 4px 12px rgba(0,0,0,0.3)",cursor:"pointer",fontSize:"9px",color:"#e5e5e5"},card:n=>({width:`${n}px`,borderRadius:"8px",background:"rgb(30,30,30)",border:"1px solid rgba(255,255,255,0.15)",boxShadow:"0 8px 24px rgba(0,0,0,0.4)",overflow:"hidden",display:"flex",flexDirection:"column"}),handle:{padding:"8px 12px",display:"flex",alignItems:"center",gap:"8px",cursor:"grab",borderBottom:"1px solid rgba(255,255,255,0.06)"},title:{fontSize:"10px",fontWeight:600,color:"#e5e5e5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},sub:{fontSize:"9px",color:"rgba(255,255,255,0.4)",display:"flex",alignItems:"center",gap:"6px"},btn:{padding:"2px",borderRadius:"4px",background:"transparent",border:"none",cursor:"pointer",color:"#888",display:"flex",flexShrink:0},stats:{padding:"4px 12px",display:"flex",alignItems:"center",gap:"8px",fontSize:"9px",borderBottom:"1px solid rgba(255,255,255,0.06)"},badge:n=>{let p=te[n]||te.custom;return {fontSize:"8px",padding:"0 4px",borderRadius:"4px",background:p.bg,color:p.text,border:`1px solid ${p.border}`,lineHeight:"14px"}},progress:{height:"2px",background:"rgba(255,255,255,0.06)",flexShrink:0},progressBar:n=>({height:"100%",width:`${n}%`,background:"linear-gradient(to right, #34d399, #3b82f6)",transition:"width 0.5s"}),link:n=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"9px",padding:"2px 6px",borderRadius:"4px",background:`${n}15`,color:n,textDecoration:"none",border:"none",cursor:"pointer"}),caseRow:{padding:"6px 12px",borderBottom:"1px solid rgba(255,255,255,0.06)",transition:"background 0.15s"},verdictBtn:(n,p)=>({fontSize:"8px",padding:"2px 6px",borderRadius:"4px",border:"none",cursor:"pointer",background:n?`${p}33`:"transparent",color:n?p:"#888",transition:"all 0.15s"}),input:{flex:1,fontSize:"9px",background:"rgba(0,0,0,0.3)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"4px",padding:"2px 6px",color:"#e5e5e5",outline:"none"}},ne="botbuddy-widget-state";function ve({config:n,appSlug:p,environment:f,testRunId:R,targetUrl:y,version:x,commitSha:S,branchName:D,onNavigate:T,displayName:a="human",defaultMode:c="expanded",defaultPosition:v}){let N=(()=>{try{let e=typeof window<"u"?localStorage.getItem(ne):null;if(e)return JSON.parse(e)}catch{}return null})(),[m,h]=useState(N?.mode||c),[b,u]=useState(""),[re,k]=useState(null),[Y,j]=useState(null),oe=N?.x??v?.x??16,ie=N?.y??v?.y??(typeof window<"u"?window.innerHeight-56:600),{pos:w,onPointerDown:E,onPointerMove:U,onPointerUp:$,didDrag:V}=O(oe,ie);useEffect(()=>{try{localStorage.setItem(ne,JSON.stringify({mode:m,x:w.x,y:w.y}));}catch{}},[m,w.x,w.y]);let F="botbuddy-widget-max-size",ae=()=>{try{let e=localStorage.getItem(F);if(e)return JSON.parse(e)}catch{}return {w:340,h:500}},[z,J]=useState(ae),P=useRef(false),C=useRef({x:0,y:0,w:0,h:0}),se=useCallback(e=>{e.stopPropagation(),P.current=true,C.current={x:e.clientX,y:e.clientY,w:z.w,h:z.h},e.target.setPointerCapture(e.pointerId);},[z]),le=useCallback(e=>{if(!P.current)return;let l=Math.max(280,Math.min(600,C.current.w+(e.clientX-C.current.x))),M=Math.max(300,Math.min(window.innerHeight*.9,C.current.h+(e.clientY-C.current.y)));J({w:l,h:M});},[]),de=useCallback(()=>{P.current&&(P.current=false,J(e=>(localStorage.setItem(F,JSON.stringify(e)),e)));},[]),{run:o,widgetState:_,fetchRun:pe,setVerdict:X,markComplete:ce,resetRun:ge}=A({config:n,appSlug:p,environment:f,testRunId:R,targetUrl:y,version:x,commitSha:S,branchName:D}),I=useCallback(async(e,l,M)=>{j(e);try{await X(e,l,M,a);}finally{j(null),k(null),u("");}},[X,a]),s=o?.summary||{total:0,pending:0,pass:0,fail:0,skip:0},ue=s.total>0&&s.pending===0,Z=s.total>0?(s.pass+s.fail)/s.total*100:0;if(_==="no-match"||_==="loading")return null;let G=()=>{V.current||h(e=>e==="mini"||e==="expanded"?"max":"mini");},q=({icon:e,onClick:l})=>jsx("button",{style:i.btn,onClick:M=>{M.stopPropagation(),l(M);},children:jsx(g,{d:e,className:""})});return jsxs("div",{style:{...i.root,left:w.x,top:w.y},children:[m==="mini"&&jsxs("div",{style:i.pill,onPointerDown:E,onPointerMove:U,onPointerUp:()=>{$(),V.current||G();},children:[jsx(g,{d:d.clipboard,className:""}),jsxs("span",{children:[s.pass,"/",s.total]}),s.fail>0&&jsxs("span",{style:{color:"#f87171"},children:[s.fail,"\u2717"]}),s.skip>0&&jsxs("span",{style:{color:"#f59e0b"},children:[s.skip,"\u23ED"]}),o?.pr_url&&jsxs("span",{style:{...i.link("#60a5fa"),pointerEvents:"none",textDecoration:"none"},children:[jsx(g,{d:d.pr,className:""}),o.pr_id||"PR"]}),o?.ticket_url&&jsxs("span",{style:{...i.link("#fbbf24"),pointerEvents:"none",textDecoration:"none"},children:[jsx(g,{d:d.ticket,className:""}),o.ticket_id||"TKT"]})]}),m==="expanded"&&jsxs("div",{style:i.card(300),children:[jsxs("div",{style:i.handle,onPointerDown:E,onPointerMove:U,onPointerUp:$,onClick:G,children:[jsx(g,{d:d.grip,className:""}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:i.title,children:o?.title}),o?.branch_name&&jsxs("div",{style:i.sub,children:["\u2387 ",o.branch_name]})]}),jsx(g,{d:d.chevronUp,className:""}),jsx(q,{icon:d.minus,onClick:()=>h("mini")})]}),jsxs("div",{style:i.stats,children:[jsxs("span",{style:{color:"#34d399"},children:[s.pass,"\u2713"]}),jsxs("span",{style:{color:"#f87171"},children:[s.fail,"\u2717"]}),jsxs("span",{style:{color:"#f59e0b"},children:[s.skip,"\u23ED"]}),jsxs("span",{style:{color:"#888"},children:[s.pending,"\u25CC"]}),jsx("span",{style:{color:"#555",marginLeft:"auto"},children:s.total})]}),o?.description&&jsx("div",{style:{padding:"6px 12px",fontSize:"10px",color:"#888",borderBottom:"1px solid rgba(255,255,255,0.06)",flexShrink:0},children:o.description}),jsxs("div",{style:{padding:"6px 12px",display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center",borderTop:"1px solid rgba(255,255,255,0.06)"},children:[o?.pr_url&&jsxs("a",{href:o.pr_url,target:"_blank",rel:"noopener noreferrer",style:{...i.link("#60a5fa"),textDecoration:"none"},children:[jsx(g,{d:d.pr,className:""}),o.pr_id||"PR"]}),o?.ticket_url&&jsxs("a",{href:o.ticket_url,target:"_blank",rel:"noopener noreferrer",style:{...i.link("#fbbf24"),textDecoration:"none"},children:[jsx(g,{d:d.ticket,className:""}),o.ticket_id||"Ticket"]}),jsx("span",{style:{...i.badge(o?.environment||"custom"),marginLeft:"auto"},children:o?.environment}),jsx("span",{style:{fontSize:"7px",color:"rgba(255,255,255,0.2)",letterSpacing:"0.05em"},children:"BotBuddy"})]}),jsx("div",{style:i.progress,children:jsx("div",{style:i.progressBar(Z)})})]}),m==="max"&&jsxs("div",{style:{...i.card(z.w),height:z.h,position:"relative"},children:[jsxs("div",{style:i.handle,onPointerDown:E,onPointerMove:U,onPointerUp:$,onClick:()=>{V.current||h("expanded");},children:[jsx(g,{d:d.grip,className:""}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:i.title,children:o?.title}),o?.branch_name&&jsxs("div",{style:i.sub,children:["\u2387 ",o.branch_name]})]}),jsx(g,{d:d.chevronDown,className:""}),jsx(q,{icon:d.minus,onClick:()=>h("mini")})]}),jsxs("div",{style:i.stats,children:[jsxs("span",{style:{color:"#34d399"},children:[s.pass,"\u2713"]}),jsxs("span",{style:{color:"#f87171"},children:[s.fail,"\u2717"]}),jsxs("span",{style:{color:"#f59e0b"},children:[s.skip,"\u23ED"]}),jsxs("span",{style:{color:"#888"},children:[s.pending,"\u25CC"]}),jsx("span",{style:{color:"#555",marginLeft:"auto"},children:s.total})]}),_==="error"&&jsxs("div",{style:{padding:"12px",textAlign:"center"},children:[jsx(g,{d:d.alert,className:""}),jsx("div",{style:{fontSize:"10px",color:"#f87171"},children:"Failed to load"}),jsx("button",{onClick:pe,style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",marginTop:"4px"},children:"Retry"})]}),_==="completed"&&jsxs("div",{style:{padding:"12px",textAlign:"center",borderBottom:"1px solid rgba(255,255,255,0.06)"},children:[jsx(g,{d:d.checkAll,className:""}),jsx("div",{style:{fontSize:"10px",color:"#34d399"},children:"Run completed"}),jsx("button",{onClick:ge,style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",marginTop:"4px"},children:"Reset & re-test"})]}),o?.intro_notes&&jsx("div",{style:{padding:"6px 12px",borderBottom:"1px solid rgba(255,255,255,0.06)",fontSize:"10px",color:"rgba(255,255,255,0.4)",fontStyle:"italic",flexShrink:0},children:o.intro_notes}),_!=="error"&&jsx("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:(o?.test_cases||[]).length===0?jsx("div",{style:{padding:"16px 12px",textAlign:"center",fontSize:"10px",color:"#888"},children:"No test cases"}):(o?.test_cases||[]).map(e=>jsxs("div",{style:i.caseRow,children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px"},children:[jsx("div",{style:{marginTop:"2px",flexShrink:0},children:Y===e.id?jsx(g,{d:d.loader,className:""}):jsx(g,{d:be[e.verdict],className:""})}),jsxs("div",{style:{minWidth:0,flex:1},children:[jsx("div",{style:{fontSize:"10px",color:"#e5e5e5",lineHeight:1.3},children:e.title}),e.description&&jsx("div",{style:{fontSize:"9px",color:"#888",marginTop:"2px"},children:e.description}),e.url_path&&jsxs("a",{href:e.url_path,target:"_blank",rel:"noopener noreferrer",onClick:l=>{l.stopPropagation(),T&&(l.preventDefault(),T(e.url_path));},style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",padding:"2px 0",marginTop:"2px",display:"inline-flex",alignItems:"center",gap:"2px",textDecoration:"none",position:"relative",zIndex:1,pointerEvents:"auto"},children:[jsx(g,{d:d.externalLink,className:""}),e.url_path]}),e.verdict==="fail"&&e.fail_reason&&jsxs("div",{style:{fontSize:"9px",color:"#f87171",marginTop:"2px"},children:["\u2717 ",e.fail_reason]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginTop:"4px",marginLeft:"22px"},children:[["pass","fail","skip"].map(l=>jsx("button",{onClick:()=>{if(e.verdict===l){I(e.id,"pending"),k(null);return}if(l==="fail"){I(e.id,"fail"),k(e.id),u("");return}k(null),I(e.id,l);},disabled:Y!==null,style:i.verdictBtn(e.verdict===l,l==="pass"?"#34d399":l==="fail"?"#f87171":"#f59e0b"),children:l.toUpperCase()},l)),e.verdict_by_display_name&&jsx("span",{style:{fontSize:"8px",color:"#555",marginLeft:"auto"},children:e.verdict_by_display_name})]}),re===e.id&&e.verdict==="fail"&&jsxs("div",{style:{marginLeft:"22px",marginTop:"4px",display:"flex",gap:"4px"},children:[jsx("input",{autoFocus:true,value:b,onChange:l=>u(l.target.value),onKeyDown:l=>{l.key==="Enter"&&b.trim()&&(I(e.id,"fail",b),k(null),u("")),l.key==="Escape"&&(k(null),u(""));},placeholder:"Reason (optional)...",style:i.input}),jsx("button",{onClick:()=>{b.trim()&&I(e.id,"fail",b),k(null),u("");},style:i.verdictBtn(true,"#f87171"),children:"\u2713"})]})]},e.id))}),ue&&_!=="completed"&&jsxs("div",{style:{padding:"6px 12px",borderTop:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[jsx("span",{style:{fontSize:"9px",color:"#34d399"},children:"All resolved"}),jsx("button",{onClick:ce,style:{fontSize:"8px",padding:"2px 8px",borderRadius:"4px",background:"rgba(59,130,246,0.15)",color:"#60a5fa",border:"none",cursor:"pointer"},children:"COMPLETE"})]}),jsxs("div",{style:{padding:"6px 12px",display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center",borderTop:"1px solid rgba(255,255,255,0.06)",flexShrink:0},children:[o?.pr_url&&jsxs("a",{href:o.pr_url,target:"_blank",rel:"noopener noreferrer",style:{...i.link("#60a5fa"),textDecoration:"none"},children:[jsx(g,{d:d.pr,className:""}),o.pr_id||"PR"]}),o?.ticket_url&&jsxs("a",{href:o.ticket_url,target:"_blank",rel:"noopener noreferrer",style:{...i.link("#fbbf24"),textDecoration:"none"},children:[jsx(g,{d:d.ticket,className:""}),o.ticket_id||"Ticket"]}),o?.created_by_agent_name&&jsxs("span",{style:{fontSize:"9px",color:"#888"},children:["by ",o.created_by_agent_name]}),jsx("span",{style:{...i.badge(o?.environment||"custom"),marginLeft:"auto"},children:o?.environment}),jsxs("button",{onClick:()=>{navigator.clipboard.writeText("0.1.9");},style:{fontSize:"7px",color:"rgba(255,255,255,0.7)",letterSpacing:"0.05em",background:"none",border:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"2px",padding:0},title:"Copy version",children:["BotBuddy v0.1.9",jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})]})]}),jsx("div",{style:i.progress,children:jsx("div",{style:i.progressBar(Z)})}),jsx("div",{style:{position:"absolute",bottom:0,right:0,width:16,height:16,cursor:"se-resize",zIndex:10,display:"flex",alignItems:"flex-end",justifyContent:"flex-end",padding:"2px",opacity:.3},onPointerDown:se,onPointerMove:le,onPointerUp:de,onPointerEnter:e=>e.currentTarget.style.opacity="0.7",onPointerLeave:e=>{P.current||(e.currentTarget.style.opacity="0.3");},children:jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",children:jsx("path",{d:"M7 1v6H1",fill:"none",stroke:"#888",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}export{ve as TestRunWidget,O as useDraggable,A as useTestRun};
|
|
1
|
+
import {useState,useRef,useCallback,useEffect}from'react';import {jsxs,jsx}from'react/jsx-runtime';function A(n,p){let[f,R]=useState({x:n,y:p}),y=useRef(false),x=useRef({x:0,y:0}),w=useRef(false),N=useCallback(g=>{y.current=true,w.current=false,x.current={x:g.clientX-f.x,y:g.clientY-f.y},g.target.setPointerCapture(g.pointerId);},[f]),T=useCallback(g=>{y.current&&(w.current=true,R({x:g.clientX-x.current.x,y:g.clientY-x.current.y}));},[]),a=useCallback(()=>{y.current=false;},[]);return {pos:f,onPointerDown:N,onPointerMove:T,onPointerUp:a,didDrag:w}}function Y(n){let[p,f]=useState(null),[R,y]=useState("loading"),x=useCallback(async()=>{try{let a=new URLSearchParams;n.testRunId&&a.set("test_run_id",n.testRunId),n.targetUrl&&a.set("target_url",n.targetUrl),a.set("app_slug",n.appSlug),a.set("environment",n.environment),n.version&&a.set("version",n.version),n.commitSha&&a.set("commit_sha",n.commitSha),n.branchName&&a.set("branch_name",n.branchName);let g=await fetch(`${n.config.serverUrl}/widget/test-run?${a.toString()}`,{headers:{Authorization:`Bearer ${n.config.anonKey}`,apikey:n.config.anonKey}});if(g.status===404){y("no-match"),f(null);return}if(!g.ok){y("error");return}let v=await g.json();f(v),y(v.status==="completed"?"completed":"ready");}catch{y("error");}},[n.config.serverUrl,n.config.anonKey,n.appSlug,n.environment,n.testRunId,n.targetUrl,n.version,n.commitSha,n.branchName]);return useEffect(()=>{x();},[x]),{run:p,widgetState:R,fetchRun:x,setVerdict:async(a,g,v,E="human")=>(f(b=>{if(!b)return null;let h=b.test_cases.map(u=>u.id===a?{...u,verdict:g,fail_reason:g==="fail"&&v||null,verdict_by_display_name:E,verdict_at:new Date().toISOString()}:u),m={total:h.length,pending:0,pass:0,fail:0,skip:0};return h.forEach(u=>{u.verdict in m&&m[u.verdict]++;}),{...b,test_cases:h,summary:m}}),(await fetch(`${n.config.serverUrl}/widget/test-cases/${a}/verdict`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.config.anonKey}`,apikey:n.config.anonKey},body:JSON.stringify({verdict:g,fail_reason:v,display_name:E})})).ok),markComplete:async()=>{if(!p)return false;let a=await fetch(`${n.config.serverUrl}/widget/test-runs/${p.id}/complete`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.config.anonKey}`,apikey:n.config.anonKey}});return a.ok&&x(),a.ok},resetRun:async()=>{if(!p)return false;let a=await fetch(`${n.config.serverUrl}/widget/test-runs/${p.id}/reset`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.config.anonKey}`,apikey:n.config.anonKey}});return a.ok&&x(),a.ok},setRun:f}}var c=({d:n,className:p})=>jsx("svg",{className:p,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:n})}),d={clipboard:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2",check:"M22 11.08V12a10 10 0 1 1-5.93-9.14M22 4 12 14.01l-3-3",x:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20M15 9l-6 6M9 9l6 6",circle:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20",skip:"M5 4l10 8-10 8V4M19 5v14",grip:"M9 5h.01M15 5h.01M9 12h.01M15 12h.01M9 19h.01M15 19h.01",minus:"M5 12h14",chevronUp:"M18 15l-6-6-6 6",chevronDown:"M6 9l6 6 6-6",externalLink:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14L21 3",pr:"M6 3v18M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6M18 9a9 9 0 0 1-9 9",ticket:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",loader:"M21 12a9 9 0 1 1-6.219-8.56",checkAll:"M18 6L7 17l-5-5M22 10l-7.5 7.5L13 16",alert:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0M12 9v4M12 17h.01"};var ve={pending:d.circle,pass:d.check,fail:d.x,skip:d.skip},ne={local:{bg:"rgba(59,130,246,0.15)",text:"#60a5fa",border:"rgba(59,130,246,0.3)"},preview:{bg:"rgba(168,85,247,0.15)",text:"#c084fc",border:"rgba(168,85,247,0.3)"},staging:{bg:"rgba(245,158,11,0.15)",text:"#fbbf24",border:"rgba(245,158,11,0.3)"},production:{bg:"rgba(239,68,68,0.15)",text:"#f87171",border:"rgba(239,68,68,0.3)"},custom:{bg:"rgba(128,128,128,0.15)",text:"#888",border:"rgba(128,128,128,0.3)"}},i={root:{position:"fixed",zIndex:9999,userSelect:"none",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},pill:n=>({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 8px",borderRadius:"9999px",background:"rgb(30,30,30)",border:n?"1px solid rgba(52,211,153,0.6)":"1px solid rgba(255,255,255,0.15)",boxShadow:n?"0 4px 12px rgba(0,0,0,0.3), 0 0 0 1px rgba(52,211,153,0.2)":"0 4px 12px rgba(0,0,0,0.3)",cursor:"pointer",fontSize:"9px",color:"#e5e5e5"}),card:(n,p)=>({width:`${n}px`,borderRadius:"8px",background:"rgb(30,30,30)",border:p?"1px solid rgba(52,211,153,0.6)":"1px solid rgba(255,255,255,0.15)",boxShadow:p?"0 8px 24px rgba(0,0,0,0.4), 0 0 0 1px rgba(52,211,153,0.2)":"0 8px 24px rgba(0,0,0,0.4)",overflow:"hidden",display:"flex",flexDirection:"column"}),handle:{padding:"8px 12px",display:"flex",alignItems:"center",gap:"8px",cursor:"grab",borderBottom:"1px solid rgba(255,255,255,0.06)"},title:{fontSize:"10px",fontWeight:600,color:"#e5e5e5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},sub:{fontSize:"9px",color:"rgba(255,255,255,0.4)",display:"flex",alignItems:"center",gap:"6px"},btn:{padding:"2px",borderRadius:"4px",background:"transparent",border:"none",cursor:"pointer",color:"#888",display:"flex",flexShrink:0},stats:{padding:"4px 12px",display:"flex",alignItems:"center",gap:"8px",fontSize:"9px",borderBottom:"1px solid rgba(255,255,255,0.06)"},badge:n=>{let p=ne[n]||ne.custom;return {fontSize:"8px",padding:"0 4px",borderRadius:"4px",background:p.bg,color:p.text,border:`1px solid ${p.border}`,lineHeight:"14px"}},progress:{height:"2px",background:"rgba(255,255,255,0.06)",flexShrink:0},progressBar:n=>({height:"100%",width:`${n}%`,background:"linear-gradient(to right, #34d399, #3b82f6)",transition:"width 0.5s"}),link:n=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"9px",padding:"2px 6px",borderRadius:"4px",background:`${n}15`,color:n,textDecoration:"none",border:"none",cursor:"pointer"}),caseRow:{padding:"6px 12px",borderBottom:"1px solid rgba(255,255,255,0.06)",transition:"background 0.15s"},verdictBtn:(n,p)=>({fontSize:"8px",padding:"2px 6px",borderRadius:"4px",border:"none",cursor:"pointer",background:n?`${p}33`:"transparent",color:n?p:"#888",transition:"all 0.15s"}),input:{flex:1,fontSize:"9px",background:"rgba(0,0,0,0.3)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"4px",padding:"2px 6px",color:"#e5e5e5",outline:"none"}},re="botbuddy-widget-state";function he({config:n,appSlug:p,environment:f,testRunId:R,targetUrl:y,version:x,commitSha:w,branchName:N,onNavigate:T,displayName:a="human",defaultMode:g="expanded",defaultPosition:v}){let W=(()=>{try{let t=typeof window<"u"?localStorage.getItem(re):null;if(t)return JSON.parse(t)}catch{}return null})(),[b,h]=useState(W?.mode||g),[m,u]=useState(""),[oe,k]=useState(null),[j,F]=useState(null),ie=W?.x??v?.x??16,ae=W?.y??v?.y??(typeof window<"u"?window.innerHeight-56:600),{pos:_,onPointerDown:U,onPointerMove:$,onPointerUp:V,didDrag:H}=A(ie,ae);useEffect(()=>{try{localStorage.setItem(re,JSON.stringify({mode:b,x:_.x,y:_.y}));}catch{}},[b,_.x,_.y]);let J="botbuddy-widget-max-size",se=()=>{try{let t=localStorage.getItem(J);if(t)return JSON.parse(t)}catch{}return {w:340,h:500}},[z,X]=useState(se),C=useRef(false),P=useRef({x:0,y:0,w:0,h:0}),le=useCallback(t=>{t.stopPropagation(),C.current=true,P.current={x:t.clientX,y:t.clientY,w:z.w,h:z.h},t.target.setPointerCapture(t.pointerId);},[z]),de=useCallback(t=>{if(!C.current)return;let l=Math.max(280,Math.min(600,P.current.w+(t.clientX-P.current.x))),M=Math.max(300,Math.min(window.innerHeight*.9,P.current.h+(t.clientY-P.current.y)));X({w:l,h:M});},[]),pe=useCallback(()=>{C.current&&(C.current=false,X(t=>(localStorage.setItem(J,JSON.stringify(t)),t)));},[]),{run:o,widgetState:I,fetchRun:ce,setVerdict:Z,markComplete:ge,resetRun:ue}=Y({config:n,appSlug:p,environment:f,testRunId:R,targetUrl:y,version:x,commitSha:w,branchName:N}),B=useCallback(async(t,l,M)=>{F(t);try{await Z(t,l,M,a);}finally{F(null),k(null),u("");}},[Z,a]),s=o?.summary||{total:0,pending:0,pass:0,fail:0,skip:0},fe=s.total>0&&s.pending===0,S=I==="completed",G=s.total>0?(s.pass+s.fail)/s.total*100:0;if(I==="no-match"||I==="loading")return null;let q=()=>{H.current||h(t=>t==="mini"||t==="expanded"?"max":"mini");},Q=({icon:t,onClick:l})=>jsx("button",{style:i.btn,onClick:M=>{M.stopPropagation(),l(M);},children:jsx(c,{d:t,className:""})});return jsxs("div",{style:{...i.root,left:_.x,top:_.y},children:[b==="mini"&&jsxs("div",{style:i.pill(S),onPointerDown:U,onPointerMove:$,onPointerUp:()=>{V(),H.current||q();},children:[S?jsx(c,{d:d.checkAll,className:""}):jsx(c,{d:d.clipboard,className:""}),jsxs("span",{style:S?{color:"#34d399"}:void 0,children:[s.pass,"/",s.total]}),s.fail>0&&jsxs("span",{style:{color:"#f87171"},children:[s.fail,"\u2717"]}),s.skip>0&&jsxs("span",{style:{color:"#f59e0b"},children:[s.skip,"\u23ED"]}),o?.pr_url&&jsxs("span",{style:{...i.link("#60a5fa"),pointerEvents:"none",textDecoration:"none"},children:[jsx(c,{d:d.pr,className:""}),o.pr_id||"PR"]}),o?.ticket_url&&jsxs("span",{style:{...i.link("#fbbf24"),pointerEvents:"none",textDecoration:"none"},children:[jsx(c,{d:d.ticket,className:""}),o.ticket_id||"TKT"]})]}),b==="expanded"&&jsxs("div",{style:i.card(300,S),children:[jsxs("div",{style:i.handle,onPointerDown:U,onPointerMove:$,onPointerUp:V,onClick:q,children:[jsx(c,{d:d.grip,className:""}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:i.title,children:o?.title}),o?.branch_name&&jsxs("div",{style:i.sub,children:["\u2387 ",o.branch_name]})]}),jsx(c,{d:d.chevronUp,className:""}),jsx(Q,{icon:d.minus,onClick:()=>h("mini")})]}),jsxs("div",{style:i.stats,children:[jsxs("span",{style:{color:"#34d399"},children:[s.pass,"\u2713"]}),jsxs("span",{style:{color:"#f87171"},children:[s.fail,"\u2717"]}),jsxs("span",{style:{color:"#f59e0b"},children:[s.skip,"\u23ED"]}),jsxs("span",{style:{color:"#888"},children:[s.pending,"\u25CC"]}),jsx("span",{style:{color:"#555",marginLeft:"auto"},children:s.total})]}),o?.description&&jsx("div",{style:{padding:"6px 12px",fontSize:"10px",color:"#888",borderBottom:"1px solid rgba(255,255,255,0.06)",flexShrink:0},children:o.description}),jsxs("div",{style:{padding:"6px 12px",display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center",borderTop:"1px solid rgba(255,255,255,0.06)"},children:[o?.pr_url&&jsxs("a",{href:o.pr_url,target:"_blank",rel:"noopener noreferrer",style:{...i.link("#60a5fa"),textDecoration:"none"},children:[jsx(c,{d:d.pr,className:""}),o.pr_id||"PR"]}),o?.ticket_url&&jsxs("a",{href:o.ticket_url,target:"_blank",rel:"noopener noreferrer",style:{...i.link("#fbbf24"),textDecoration:"none"},children:[jsx(c,{d:d.ticket,className:""}),o.ticket_id||"Ticket"]}),jsx("span",{style:{...i.badge(o?.environment||"custom"),marginLeft:"auto"},children:o?.environment}),jsx("span",{style:{fontSize:"7px",color:"rgba(255,255,255,0.2)",letterSpacing:"0.05em"},children:"BotBuddy"})]}),jsx("div",{style:i.progress,children:jsx("div",{style:i.progressBar(G)})})]}),b==="max"&&jsxs("div",{style:{...i.card(z.w,S),height:z.h,position:"relative"},children:[jsxs("div",{style:i.handle,onPointerDown:U,onPointerMove:$,onPointerUp:V,onClick:()=>{H.current||h("expanded");},children:[jsx(c,{d:d.grip,className:""}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:i.title,children:o?.title}),o?.branch_name&&jsxs("div",{style:i.sub,children:["\u2387 ",o.branch_name]})]}),jsx(c,{d:d.chevronDown,className:""}),jsx(Q,{icon:d.minus,onClick:()=>h("mini")})]}),jsxs("div",{style:i.stats,children:[jsxs("span",{style:{color:"#34d399"},children:[s.pass,"\u2713"]}),jsxs("span",{style:{color:"#f87171"},children:[s.fail,"\u2717"]}),jsxs("span",{style:{color:"#f59e0b"},children:[s.skip,"\u23ED"]}),jsxs("span",{style:{color:"#888"},children:[s.pending,"\u25CC"]}),jsx("span",{style:{color:"#555",marginLeft:"auto"},children:s.total})]}),I==="error"&&jsxs("div",{style:{padding:"12px",textAlign:"center"},children:[jsx(c,{d:d.alert,className:""}),jsx("div",{style:{fontSize:"10px",color:"#f87171"},children:"Failed to load"}),jsx("button",{onClick:ce,style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",marginTop:"4px"},children:"Retry"})]}),S&&jsxs("div",{style:{padding:"6px 12px",display:"flex",alignItems:"center",gap:"8px",borderBottom:"1px solid rgba(52,211,153,0.2)",background:"rgba(52,211,153,0.05)"},children:[jsx(c,{d:d.checkAll,className:""}),jsx("span",{style:{fontSize:"10px",color:"#34d399",flex:1},children:"Run completed"}),jsx("button",{onClick:ue,style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer"},children:"Reset"})]}),o?.intro_notes&&jsx("div",{style:{padding:"6px 12px",borderBottom:"1px solid rgba(255,255,255,0.06)",fontSize:"10px",color:"rgba(255,255,255,0.4)",fontStyle:"italic",flexShrink:0},children:o.intro_notes}),I!=="error"&&jsx("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:(o?.test_cases||[]).length===0?jsx("div",{style:{padding:"16px 12px",textAlign:"center",fontSize:"10px",color:"#888"},children:"No test cases"}):(o?.test_cases||[]).map(t=>jsxs("div",{style:i.caseRow,children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px"},children:[jsx("div",{style:{marginTop:"2px",flexShrink:0},children:j===t.id?jsx(c,{d:d.loader,className:""}):jsx(c,{d:ve[t.verdict],className:""})}),jsxs("div",{style:{minWidth:0,flex:1},children:[jsx("div",{style:{fontSize:"10px",color:"#e5e5e5",lineHeight:1.3},children:t.title}),t.description&&jsx("div",{style:{fontSize:"9px",color:"#888",marginTop:"2px"},children:t.description}),t.url_path&&jsxs("a",{href:t.url_path,target:"_blank",rel:"noopener noreferrer",onClick:l=>{l.stopPropagation(),T&&(l.preventDefault(),T(t.url_path));},style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",padding:"2px 0",marginTop:"2px",display:"inline-flex",alignItems:"center",gap:"2px",textDecoration:"none",position:"relative",zIndex:1,pointerEvents:"auto"},children:[jsx(c,{d:d.externalLink,className:""}),t.url_path]}),t.verdict==="fail"&&t.fail_reason&&jsxs("div",{style:{fontSize:"9px",color:"#f87171",marginTop:"2px"},children:["\u2717 ",t.fail_reason]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginTop:"4px",marginLeft:"22px"},children:[["pass","fail","skip"].map(l=>jsx("button",{onClick:()=>{if(t.verdict===l){B(t.id,"pending"),k(null);return}if(l==="fail"){B(t.id,"fail"),k(t.id),u("");return}k(null),B(t.id,l);},disabled:j!==null,style:i.verdictBtn(t.verdict===l,l==="pass"?"#34d399":l==="fail"?"#f87171":"#f59e0b"),children:l.toUpperCase()},l)),t.verdict_by_display_name&&jsx("span",{style:{fontSize:"8px",color:"#555",marginLeft:"auto"},children:t.verdict_by_display_name})]}),oe===t.id&&t.verdict==="fail"&&jsxs("div",{style:{marginLeft:"22px",marginTop:"4px",display:"flex",gap:"4px"},children:[jsx("input",{autoFocus:true,value:m,onChange:l=>u(l.target.value),onKeyDown:l=>{l.key==="Enter"&&m.trim()&&(B(t.id,"fail",m),k(null),u("")),l.key==="Escape"&&(k(null),u(""));},placeholder:"Reason (optional)...",style:i.input}),jsx("button",{onClick:()=>{m.trim()&&B(t.id,"fail",m),k(null),u("");},style:i.verdictBtn(true,"#f87171"),children:"\u2713"})]})]},t.id))}),fe&&!S&&jsxs("div",{style:{padding:"6px 12px",borderTop:"1px solid rgba(52,211,153,0.2)",background:"rgba(52,211,153,0.05)",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[jsx("span",{style:{fontSize:"9px",color:"#34d399"},children:"All resolved"}),jsx("button",{onClick:ge,style:{fontSize:"8px",padding:"2px 8px",borderRadius:"4px",background:"rgba(52,211,153,0.15)",color:"#34d399",border:"1px solid rgba(52,211,153,0.3)",cursor:"pointer"},children:"COMPLETE"})]}),jsxs("div",{style:{padding:"6px 12px",display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center",borderTop:"1px solid rgba(255,255,255,0.06)",flexShrink:0},children:[o?.pr_url&&jsxs("a",{href:o.pr_url,target:"_blank",rel:"noopener noreferrer",style:{...i.link("#60a5fa"),textDecoration:"none"},children:[jsx(c,{d:d.pr,className:""}),o.pr_id||"PR"]}),o?.ticket_url&&jsxs("a",{href:o.ticket_url,target:"_blank",rel:"noopener noreferrer",style:{...i.link("#fbbf24"),textDecoration:"none"},children:[jsx(c,{d:d.ticket,className:""}),o.ticket_id||"Ticket"]}),o?.created_by_agent_name&&jsxs("span",{style:{fontSize:"9px",color:"#888"},children:["by ",o.created_by_agent_name]}),jsx("span",{style:{...i.badge(o?.environment||"custom"),marginLeft:"auto"},children:o?.environment}),jsxs("button",{onClick:()=>{navigator.clipboard.writeText("0.1.9");},style:{fontSize:"7px",color:"rgba(255,255,255,0.7)",letterSpacing:"0.05em",background:"none",border:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"2px",padding:0},title:"Copy version",children:["BotBuddy v0.1.9",jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})]})]}),jsx("div",{style:i.progress,children:jsx("div",{style:i.progressBar(G)})}),jsx("div",{style:{position:"absolute",bottom:0,right:0,width:16,height:16,cursor:"se-resize",zIndex:10,display:"flex",alignItems:"flex-end",justifyContent:"flex-end",padding:"2px",opacity:.3},onPointerDown:le,onPointerMove:de,onPointerUp:pe,onPointerEnter:t=>t.currentTarget.style.opacity="0.7",onPointerLeave:t=>{C.current||(t.currentTarget.style.opacity="0.3");},children:jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",children:jsx("path",{d:"M7 1v6H1",fill:"none",stroke:"#888",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}export{he as TestRunWidget,A as useDraggable,Y as useTestRun};
|
package/package.json
CHANGED