1import{p as R,aH as E,r as C,j as e,C as o,b as m,c as j,d as u,e as l,h as i,ae as P,ao as T,B as S}from"./index-DGo-vssZ.js";import{r as L}from"./vendor-Qgthw7N1.js";import{C as d}from"./circle-x--5-vDMIU.js";function B(){var g,f,y,k,v,w,b;const{user:x,isAdmin:p}=R(),{subscription:t}=E(),[a,N]=L.useState({}),{data:s}=C({queryKey:["/api/admin/impersonation-status"],enabled:!!x}),{data:c,error:r,isLoading:I}=C({queryKey:["/api/analytics/time-series?period=30d"],enabled:!!x}),A=async()=>{try{const n=await fetch("/api/subscription/create-checkout",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({priceType:"monthly",successUrl:`${window.location.origin}/?payment=success`,cancelUrl:`${window.location.origin}/?payment=cancelled`})}),h=await n.json();N(U=>({...U,checkout:{success:n.ok,status:n.status,data:h,hasCheckoutUrl:!!h.checkoutUrl,upgraded:!!h.upgraded}}))}catch(n){N(h=>({...h,checkout:{success:!1,error:n.message}}))}};return e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx("h1",{className:"text-3xl font-bold mb-8",children:"System Test Results"}),e.jsxs(o,{className:"mb-6",children:[e.jsx(m,{children:e.jsx(j,{children:"Current User Status"})}),e.jsx(u,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Email:"}),e.jsx("span",{className:"font-mono",children:(x==null?void 0:x.email)||"Not authenticated"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Is Admin:"}),e.jsx(l,{variant:p?"default":"secondary",children:p?"Yes":"No"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Subscription Status:"}),e.jsx(l,{children:(t==null?void 0:t.subscriptionStatus)||"Unknown"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Is On Trial:"}),e.jsx(l,{variant:t!=null&&t.isOnTrial?"default":"secondary",children:t!=null&&t.isOnTrial?"Yes":"No"})]})]})})]}),e.jsxs(o,{className:"mb-6",children:[e.jsx(m,{children:e.jsxs(j,{className:"flex items-center gap-2",children:["Test 1: Impersonation Status",s!=null&&s.isImpersonating?e.jsx(i,{className:"h-5 w-5 text-green-500"}):e.jsx(d,{className:"h-5 w-5 text-red-500"})]})}),e.jsx(u,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Is Impersonating:"}),e.jsx(l,{variant:s!=null&&s.isImpersonating?"default":"secondary",children:s!=null&&s.isImpersonating?"Yes":"No"})]}),(s==null?void 0:s.isImpersonating)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Original User:"}),e.jsx("span",{className:"font-mono text-sm",children:(g=s.originalUser)==null?void 0:g.email})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Target User:"}),e.jsx("span",{className:"font-mono text-sm",children:(f=s.targetUser)==null?void 0:f.email})]})]}),e.jsx("div",{className:"mt-4 p-3 bg-muted rounded-md",children:e.jsxs("p",{className:"text-sm",children:[e.jsx("strong",{children:"Expected:"})," If impersonating, should show banner and user details.",e.jsx("br",{}),e.jsx("strong",{children:"Result:"})," ",s!=null&&s.isImpersonating?"â
Impersonation detected correctly":"â Not impersonating (normal state)"]})})]})})]}),e.jsxs(o,{className:"mb-6",children:[e.jsx(m,{children:e.jsxs(j,{className:"flex items-center gap-2",children:["Test 2: Analytics Time Series Data",I?e.
1jsx(P,{className:"h-5 w-5 animate-spin"}):c&&!r?e.jsx(i,{className:"h-5 w-5 text-green-500"}):e.jsx(d,{className:"h-5 w-5 text-red-500"})]})}),e.jsx(u,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"API Status:"}),e.jsx(l,{variant:r?"destructive":"default",children:r?`Error: ${r.message}`:"Success"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Data Points:"}),e.jsx("span",{children:Array.isArray(c)?c.length:0})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Has Activity:"}),e.jsx(l,{variant:c!=null&&c.some(n=>n.hours>0)?"default":"secondary",children:c!=null&&c.some(n=>n.hours>0)?"Yes":"No"})]}),e.jsx("div",{className:"mt-4 p-3 bg-muted rounded-md",children:e.jsxs("p",{className:"text-sm",children:[e.jsx("strong",{children:"Expected:"})," Should load time series data without 401 error.",e.jsx("br",{}),e.jsx("strong",{children:"Result:"})," ",r?`â Error: ${r.message}`:"â
Data loaded successfully"]})})]})})]}),e.jsxs(o,{className:"mb-6",children:[e.jsx(m,{children:e.jsxs(j,{className:"flex items-center gap-2",children:["Test 3: Subscription Checkout",(y=a.checkout)!=null&&y.success?e.jsx(i,{className:"h-5 w-5 text-green-500"}):a.checkout?e.jsx(d,{className:"h-5 w-5 text-red-500"}):e.jsx(T,{className:"h-5 w-5 text-yellow-500"})]})}),e.jsx(u,{children:e.jsxs("div",{className:"space-y-2",children:[a.checkout?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"API Response:"}),e.jsx(l,{variant:a.checkout.success?"default":"destructive",children:a.checkout.status||"N/A"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Has Checkout URL:"}),e.jsx(l,{variant:a.checkout.hasCheckoutUrl?"default":"secondary",children:a.checkout.hasCheckoutUrl?"Yes":"No"})]}),((k=a.checkout.data)==null?void 0:k.message)&&e.jsx("div",{className:"mt-2 p-2 bg-destructive/10 rounded",children:e.jsx("p",{className:"text-sm text-destructive",children:a.checkout.data.message})})]}):e.jsx("p",{className:"text-muted-foreground",children:"Test not run yet"}),e.jsx(S,{onClick:A,className:"w-full mt-4",disabled:!!a.checkout,children:a.checkout?"Test Complete":"Run Checkout Test"}),e.jsx("div",{className:"mt-4 p-3 bg-muted rounded-md",children:e.jsxs("p",{className:"text-sm",children:[e.jsx("strong",{children:"Expected:"})," Should create checkout session and return URL.",e.jsx("br",{}),e.jsx("strong",{children:"Result:"})," ",(v=a.checkout)!=null&&v.success?"â
Checkout URL created successfully":a.checkout?"â Failed to create checkout":"â³ Test not run"]})})]})})]}),e.jsxs(o,{children:[e.jsx(m,{children:e.jsx(j,{children:"Test Summary"})}),e.jsx(u,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s!==void 0?e.jsx(i,{className:"h-5 w-5 text-green-500"}):e.jsx(d,{className:"h-5 w-5 text-red-500"}),e.jsxs("span",{children:["Impersonation API: ",s!==void 0?"Working":"Not Working"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!r&&c?e.jsx(i,{className:"h-5 w-5 text-green-500"}):e.jsx(d,{className:"h-5 w-5 text-red-500"}),e.jsxs("span",{children:["Analytics API: ",r?"Not Working":"Working"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[(w=a.checkout)!=null&&w.success?e.jsx(i,{className:"h-5 w-5 text-green-500"}):a.checkout?e.jsx(d,{className:"h-5 w-5 text-red-500"}):e.jsx(T,{className:"h-5 w-5 text-yellow-500"}),e.jsxs("span",{children:["Checkout API: ",(b=a.checkout)!=null&&b.success?"Working":a.checkout?"Not Working":"Not Tested"]})]})]})})]})]})}export{B as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.