twd-js 1.3.2 → 1.3.3
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/bundled.es.js +1 -1
- package/dist/bundled.umd.js +1 -1
- package/dist/index.cjs.js +28 -28
- package/dist/index.d.ts +31 -0
- package/dist/index.es.js +1910 -1906
- package/dist/mock-sw.js +1 -1
- package/dist/vite-plugin.cjs.js +1 -1
- package/dist/vite-plugin.d.ts +46 -0
- package/dist/vite-plugin.es.js +21 -5
- package/package.json +1 -1
package/dist/bundled.es.js
CHANGED
|
@@ -757,7 +757,7 @@ class Pe {
|
|
|
757
757
|
}
|
|
758
758
|
}
|
|
759
759
|
window.__testRunner = Pe;
|
|
760
|
-
const mt = "1.3.
|
|
760
|
+
const mt = "1.3.3", yt = () => typeof window < "u" ? (window.__TWD_MOCK_STATE__ || (window.__TWD_MOCK_STATE__ = {
|
|
761
761
|
rules: []
|
|
762
762
|
}), window.__TWD_MOCK_STATE__) : {
|
|
763
763
|
rules: []
|
package/dist/bundled.umd.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
0% { transform: rotate(0deg); }
|
|
4
4
|
100% { transform: rotate(360deg); }
|
|
5
5
|
}
|
|
6
|
-
`,document.head.appendChild(O));const q=({className:t,children:e,dataTestId:n})=>c("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#000",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`lucide ${t}`,"data-testid":n,children:e}),it=()=>c(q,{className:"lucide-play-icon lucide-play",dataTestId:"play-icon",children:c("path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"})}),Le=({id:t,name:e,skip:n,only:r})=>c(L,{children:[e," ",r&&c("span",{style:{color:"#2563eb"},"data-testid":`only-indicator-${t}`,children:[" ","(only)"]}),n&&c("span",{style:{color:"#6b7280"},"data-testid":`skip-indicator-${t}`,children:[" ","(skipped)"]})]}),st=t=>{switch(t.status){case"pass":return{item:{background:"#dcfce7"},container:{borderLeft:"3px solid #00c951"}};case"fail":return{item:{background:"#fee2e2"},container:{borderLeft:"3px solid #fb2c36"}};case"skip":return{item:{background:"#f3f4f6"}};case"running":return{item:{background:"#fef9c3"}};default:return{item:{background:"transparent"}}}},_t=t=>t.startsWith("Assertion passed")||t.startsWith("Event fired")?{color:"#0d542b",fontWeight:"700"}:t.startsWith("Test failed")?{color:"#fb2c36",fontWeight:"700"}:{},lt=({node:t,depth:e,id:n,runTest:r})=>{const s=st(t);return c("li",{style:{marginBottom:"4px",marginLeft:e*6,...s.container},"data-testid":`test-list-item-${n}`,children:[c("div",{style:{display:"flex",alignItems:"left",justifyContent:"space-between",padding:"4px 6px",borderRadius:"4px",...s.item},children:[c("span",{style:{fontWeight:"500",color:"#374151",maxWidth:"220px"},children:c(Le,{id:n,name:t.name,skip:t.skip,only:t.only})}),c("button",{onClick:()=>r(n),"aria-label":`Run ${t.name} test`,style:{background:"transparent",border:"1px solid #d1d5db",borderRadius:"4px",padding:"0",cursor:"pointer",verticalAlign:"middle",fontSize:"12px",width:"24px",height:"24px",display:"flex",alignItems:"center",justifyContent:"center"},disabled:t.status==="running","data-testid":`run-test-button-${n}`,children:t.status==="running"?c(ot,{}):c(it,{})})]}),t.logs&&t.logs.length>0&&c("ul",{style:{borderRadius:"4px",maxHeight:"260px",overflowY:"auto",padding:0,background:"#f3f4f6",listStyle:"none",marginTop:"4px",textAlign:"left"},children:t.logs.map((i,_)=>c("li",{style:{fontSize:"12px",padding:"4px 6px",borderBottom:"1px solid #d1d5db",color:"#374151",..._t(i)},children:i},_))})]},t.name)},at=()=>c(q,{className:"lucide-chevron-down-icon lucide-chevron-down",dataTestId:"chevron-down-icon",children:c("path",{d:"m6 9 6 6 6-6"})}),ct=()=>c(q,{className:"lucide-chevron-right-icon lucide-chevron-right",dataTestId:"chevron-right-icon",children:c("path",{d:"m9 18 6-6-6-6"})}),ut=({tests:t,runTest:e})=>{const[n,r]=re({}),s=l=>r(u=>({...u,[l]:!u[l]})),i=(l,u=0)=>{if(l.type==="test")return c(lt,{node:l,depth:u,id:l.id,runTest:()=>e(l.id)},l.id);const a=n[l.id];return c("li",{style:{marginLeft:u*12},children:[c("span",{style:{fontWeight:"bold",cursor:"pointer",color:"#374151",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px",gap:"6px"},"data-testid":`test-group-${l.name}`,tabIndex:0,role:"button","aria-expanded":!a,onClick:()=>s(l.id),children:[c(Le,{id:l.id,name:l.name,skip:l.skip,only:l.only}),a?c(ct,{}):c(at,{})]}),!a&&l.childrenNodes&&l.childrenNodes.length>0&&c("ul",{style:{listStyle:"none",padding:0,margin:0},children:l.childrenNodes.map(p=>i(p,u+1))})]},l.id)},_=nt(t);return c("ul",{style:{listStyle:"none",padding:0,margin:0},children:_.map(l=>i(l))})},dt={left:{left:0,borderTopRightRadius:"6px",borderBottomRightRadius:"6px",borderTopLeftRadius:"0",borderBottomLeftRadius:"0"},right:{right:0,borderTopLeftRadius:"6px",borderBottomLeftRadius:"6px",borderTopRightRadius:"0",borderBottomRightRadius:"0"}},ft=({setOpen:t,position:e})=>c("button",{"aria-label":"Open TWD sidebar",style:{position:"fixed",top:"50%",transform:"translateY(-50%)",background:"#1A6EF4",color:"white",padding:"6px 10px",cursor:"pointer",fontSize:"12px",...dt[e]},onClick:()=>t(!0),children:"TWD"}),pt=({isOpen:t,position:e})=>{Qe(()=>{const n=document.documentElement;return t?e==="left"?n.style.marginLeft="280px":n.style.marginRight="280px":(n.style.marginRight="0",n.style.marginLeft="0"),()=>{n.style.marginRight="0",n.style.marginLeft="0"}},[t,e])},ie=typeof window<"u"?(window.__TWD_STATE__||(window.__TWD_STATE__={handlers:new Map,beforeEachHooks:new Map,afterEachHooks:new Map,stack:[]}),window.__TWD_STATE__):{handlers:new Map,beforeEachHooks:new Map,afterEachHooks:new Map,stack:[]},w=ie.handlers,Ne=ie.beforeEachHooks,Ie=ie.afterEachHooks,ht=t=>{const e=[],n=[];let r=t;for(;r;)Ne.has(r)&&e.unshift(...Ne.get(r)),Ie.has(r)&&n.push(...Ie.get(r)),r=w.get(r)?.parent;return{before:e,after:n}},se=t=>{const e=w.get(t);return e?e.only?!0:e.children?e.children.some(n=>se(n)):!1:!1},gt=t=>{let e=w.get(t);for(;e?.parent;){const n=w.get(e.parent);if(n?.only)return!0;e=n}return!1},De=t=>{let e=w.get(t);for(;e;){if(e.skip)return!0;if(!e.parent)break;e=w.get(e.parent)}return!1};class Pe{events;constructor(e){this.events=e}async runAll(){const e=Array.from(w.values()).filter(r=>!r.parent&&r.type==="suite"),n=Array.from(w.values()).some(r=>r.only);for(const r of e)await this.runSuite(r,n);return w}async runSingle(e){const n=w.get(e);if(!n||n.type!=="test")return;await this.runTest(n,!1)}async runSuite(e,n){if(De(e.id)&&!se(e.id)){this.events.onSkip?.(e);return}if(n&&!se(e.id))return;this.events.onSuiteStart?.(e);const s=(e.children||[]).map(i=>w.get(i));for(const i of s)i.type==="suite"?await this.runSuite(i,n):i.type==="test"&&await this.runTest(i,n);this.events.onSuiteEnd?.(e)}async runTest(e,n){if((De(e.id)||e.skip)&&!e.only){this.events.onSkip(e);return}const s=gt(e.id);if(n&&!e.only&&!s){this.events.onSkip(e);return}this.events.onStart?.(e);const i=ht(e.parent);try{for(const _ of i.before)await _();e.logs=[],await e.handler(),this.events.onPass(e)}catch(_){this.events.onFail(e,_)}finally{for(const _ of i.after)await _()}}}window.__testRunner=Pe;const mt="1.3.2",Be=(typeof window<"u"?(window.__TWD_MOCK_STATE__||(window.__TWD_MOCK_STATE__={rules:[]}),window.__TWD_MOCK_STATE__):{rules:[]}).rules,yt=async t=>{if("serviceWorker"in navigator){const e=t??"/mock-sw.js";await navigator.serviceWorker.register(`${e}?v=${mt}`),navigator.serviceWorker.controller||await new Promise(n=>{navigator.serviceWorker.addEventListener("controllerchange",n,{once:!0})}),navigator.serviceWorker.addEventListener("message",n=>{if(n.data?.type==="EXECUTED"){const{alias:r,request:s}=n.data,i=Be.find(_=>_.alias===r);i&&(i.executed=!0,i.request=s)}})}},vt=()=>Be,bt=()=>c(q,{className:"lucide-wifi-pen-icon lucide-wifi-pen",dataTestId:"wifi-pen-icon",children:[c("path",{d:"M2 8.82a15 15 0 0 1 20 0"}),c("path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z"}),c("path",{d:"M5 12.859a10 10 0 0 1 10.5-2.222"}),c("path",{d:"M8.5 16.429a5 5 0 0 1 3-1.406"})]}),kt=()=>{const t=vt(),e=t.filter(r=>r.executed);return c("button",{onClick:()=>{console.group("🌐 TWD Mock Rules"),console.log("Total rules:",t.length),console.log("Triggered rules:",e.length),console.log("Rules details:"),console.log(t),console.groupEnd()},"aria-label":"View mock rules details in console",style:{background:"#f8fafc",border:"1px solid #cbd5e1",borderRadius:"6px",padding:"8px 12px",cursor:"pointer",fontSize:"12px",color:"#475569",display:"flex",alignItems:"center",gap:"8px",marginBottom:"10px",width:"100%",textAlign:"left",transition:"all 0.2s ease",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)"},children:[c(bt,{}),c("span",{style:{flex:1},children:["Rules: ",e.length,"/",t.length," triggered"]}),c("span",{style:{fontSize:"10px",color:"#1E293B",fontWeight:"500"},children:"View rules in console"})]})},wt={left:{left:0,borderRight:"1px solid #e5e7eb"},right:{right:0,borderLeft:"1px solid #e5e7eb"}},xt='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',St=({open:t,position:e="left"})=>{const[n,r]=re(0),[s,i]=re(t);pt({isOpen:s,position:e});const _=new Pe({onStart:o=>{o.status="running",r(f=>f+1)},onPass:o=>{o.status="pass",r(f=>f+1)},onFail:(o,f)=>{o.status="fail",console.error("Test failed:",o.name,f),o.logs.push(`Test failed: ${f.message}`),r(d=>d+1)},onSkip:o=>{o.status="skip",r(f=>f+1)}}),l=async()=>{await _.runAll()},u=async o=>{const f=Array.from(w.values()).filter(d=>d.type==="test").find(d=>d.id===o);f&&await _.runSingle(f.id)},a=Array.from(w.values());if(!s)return c(ft,{position:e,setOpen:i});const p=a.filter(o=>o.type==="test").length;return c("div",{style:{fontFamily:xt,position:"fixed",top:0,bottom:0,width:"280px",background:"#f9fafb",fontSize:"14px",overflowY:"auto",boxShadow:"2px 0 6px rgba(0,0,0,0.1)",textAlign:"left",zIndex:1e3,...wt[e]},"data-testid":"twd-sidebar",children:[c("div",{style:{padding:"8px",background:"#f9fafb",position:"sticky",top:0,zIndex:1e3,borderBottom:"1px solid #e5e7eb"},children:[c("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"14px"},children:[c("button",{onClick:l,style:{background:"#1A6EF4",color:"white",padding:"4px 8px",borderRadius:"4px",border:"none",cursor:"pointer"},children:"Run All"}),c("button",{"aria-label":"Close sidebar",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:"14px",paddingRight:"0",paddingLeft:"0"},onClick:()=>i(!1),children:"✖"})]}),c("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:"14px",color:"#6b7280",marginBottom:"10px"},children:[c("span",{style:{color:"#374151"},children:["Total: ",p]}),c("div",{style:{display:"flex",gap:"4px"},children:[c("span",{style:{color:"#00c951"},children:["✓ ",a.filter(o=>o.status==="pass").length]}),c("span",{style:{color:"#fb2c36"},children:["✗ ",a.filter(o=>o.status==="fail").length]})]})]}),c(kt,{})]}),c("div",{style:{padding:"8px"},children:c(ut,{tests:a.map(o=>({name:o.name,depth:o.depth,status:o.status,logs:o.logs,id:o.id,parent:o.parent,type:o.type,only:o.only,skip:o.skip})),runTest:u})})]})},Tt=t=>({render:e=>{Ke(e,t)}}),Et=(t,e)=>{const{open:n=!0,position:r="left",serviceWorker:s=!0,serviceWorkerUrl:i="/mock-sw.js"}=e||{};Xe(t,c(St,{open:n,position:r}),Tt),s&&yt(i).then(()=>{console.log("Request mocking initialized")}).catch(_=>{console.error("Error initializing request mocking:",_)})};W.initTWD=Et,Object.defineProperty(W,Symbol.toStringTag,{value:"Module"})}));
|
|
6
|
+
`,document.head.appendChild(O));const q=({className:t,children:e,dataTestId:n})=>c("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#000",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`lucide ${t}`,"data-testid":n,children:e}),it=()=>c(q,{className:"lucide-play-icon lucide-play",dataTestId:"play-icon",children:c("path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"})}),Le=({id:t,name:e,skip:n,only:r})=>c(L,{children:[e," ",r&&c("span",{style:{color:"#2563eb"},"data-testid":`only-indicator-${t}`,children:[" ","(only)"]}),n&&c("span",{style:{color:"#6b7280"},"data-testid":`skip-indicator-${t}`,children:[" ","(skipped)"]})]}),st=t=>{switch(t.status){case"pass":return{item:{background:"#dcfce7"},container:{borderLeft:"3px solid #00c951"}};case"fail":return{item:{background:"#fee2e2"},container:{borderLeft:"3px solid #fb2c36"}};case"skip":return{item:{background:"#f3f4f6"}};case"running":return{item:{background:"#fef9c3"}};default:return{item:{background:"transparent"}}}},_t=t=>t.startsWith("Assertion passed")||t.startsWith("Event fired")?{color:"#0d542b",fontWeight:"700"}:t.startsWith("Test failed")?{color:"#fb2c36",fontWeight:"700"}:{},lt=({node:t,depth:e,id:n,runTest:r})=>{const s=st(t);return c("li",{style:{marginBottom:"4px",marginLeft:e*6,...s.container},"data-testid":`test-list-item-${n}`,children:[c("div",{style:{display:"flex",alignItems:"left",justifyContent:"space-between",padding:"4px 6px",borderRadius:"4px",...s.item},children:[c("span",{style:{fontWeight:"500",color:"#374151",maxWidth:"220px"},children:c(Le,{id:n,name:t.name,skip:t.skip,only:t.only})}),c("button",{onClick:()=>r(n),"aria-label":`Run ${t.name} test`,style:{background:"transparent",border:"1px solid #d1d5db",borderRadius:"4px",padding:"0",cursor:"pointer",verticalAlign:"middle",fontSize:"12px",width:"24px",height:"24px",display:"flex",alignItems:"center",justifyContent:"center"},disabled:t.status==="running","data-testid":`run-test-button-${n}`,children:t.status==="running"?c(ot,{}):c(it,{})})]}),t.logs&&t.logs.length>0&&c("ul",{style:{borderRadius:"4px",maxHeight:"260px",overflowY:"auto",padding:0,background:"#f3f4f6",listStyle:"none",marginTop:"4px",textAlign:"left"},children:t.logs.map((i,_)=>c("li",{style:{fontSize:"12px",padding:"4px 6px",borderBottom:"1px solid #d1d5db",color:"#374151",..._t(i)},children:i},_))})]},t.name)},at=()=>c(q,{className:"lucide-chevron-down-icon lucide-chevron-down",dataTestId:"chevron-down-icon",children:c("path",{d:"m6 9 6 6 6-6"})}),ct=()=>c(q,{className:"lucide-chevron-right-icon lucide-chevron-right",dataTestId:"chevron-right-icon",children:c("path",{d:"m9 18 6-6-6-6"})}),ut=({tests:t,runTest:e})=>{const[n,r]=re({}),s=l=>r(u=>({...u,[l]:!u[l]})),i=(l,u=0)=>{if(l.type==="test")return c(lt,{node:l,depth:u,id:l.id,runTest:()=>e(l.id)},l.id);const a=n[l.id];return c("li",{style:{marginLeft:u*12},children:[c("span",{style:{fontWeight:"bold",cursor:"pointer",color:"#374151",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px",gap:"6px"},"data-testid":`test-group-${l.name}`,tabIndex:0,role:"button","aria-expanded":!a,onClick:()=>s(l.id),children:[c(Le,{id:l.id,name:l.name,skip:l.skip,only:l.only}),a?c(ct,{}):c(at,{})]}),!a&&l.childrenNodes&&l.childrenNodes.length>0&&c("ul",{style:{listStyle:"none",padding:0,margin:0},children:l.childrenNodes.map(p=>i(p,u+1))})]},l.id)},_=nt(t);return c("ul",{style:{listStyle:"none",padding:0,margin:0},children:_.map(l=>i(l))})},dt={left:{left:0,borderTopRightRadius:"6px",borderBottomRightRadius:"6px",borderTopLeftRadius:"0",borderBottomLeftRadius:"0"},right:{right:0,borderTopLeftRadius:"6px",borderBottomLeftRadius:"6px",borderTopRightRadius:"0",borderBottomRightRadius:"0"}},ft=({setOpen:t,position:e})=>c("button",{"aria-label":"Open TWD sidebar",style:{position:"fixed",top:"50%",transform:"translateY(-50%)",background:"#1A6EF4",color:"white",padding:"6px 10px",cursor:"pointer",fontSize:"12px",...dt[e]},onClick:()=>t(!0),children:"TWD"}),pt=({isOpen:t,position:e})=>{Qe(()=>{const n=document.documentElement;return t?e==="left"?n.style.marginLeft="280px":n.style.marginRight="280px":(n.style.marginRight="0",n.style.marginLeft="0"),()=>{n.style.marginRight="0",n.style.marginLeft="0"}},[t,e])},ie=typeof window<"u"?(window.__TWD_STATE__||(window.__TWD_STATE__={handlers:new Map,beforeEachHooks:new Map,afterEachHooks:new Map,stack:[]}),window.__TWD_STATE__):{handlers:new Map,beforeEachHooks:new Map,afterEachHooks:new Map,stack:[]},w=ie.handlers,Ne=ie.beforeEachHooks,Ie=ie.afterEachHooks,ht=t=>{const e=[],n=[];let r=t;for(;r;)Ne.has(r)&&e.unshift(...Ne.get(r)),Ie.has(r)&&n.push(...Ie.get(r)),r=w.get(r)?.parent;return{before:e,after:n}},se=t=>{const e=w.get(t);return e?e.only?!0:e.children?e.children.some(n=>se(n)):!1:!1},gt=t=>{let e=w.get(t);for(;e?.parent;){const n=w.get(e.parent);if(n?.only)return!0;e=n}return!1},De=t=>{let e=w.get(t);for(;e;){if(e.skip)return!0;if(!e.parent)break;e=w.get(e.parent)}return!1};class Pe{events;constructor(e){this.events=e}async runAll(){const e=Array.from(w.values()).filter(r=>!r.parent&&r.type==="suite"),n=Array.from(w.values()).some(r=>r.only);for(const r of e)await this.runSuite(r,n);return w}async runSingle(e){const n=w.get(e);if(!n||n.type!=="test")return;await this.runTest(n,!1)}async runSuite(e,n){if(De(e.id)&&!se(e.id)){this.events.onSkip?.(e);return}if(n&&!se(e.id))return;this.events.onSuiteStart?.(e);const s=(e.children||[]).map(i=>w.get(i));for(const i of s)i.type==="suite"?await this.runSuite(i,n):i.type==="test"&&await this.runTest(i,n);this.events.onSuiteEnd?.(e)}async runTest(e,n){if((De(e.id)||e.skip)&&!e.only){this.events.onSkip(e);return}const s=gt(e.id);if(n&&!e.only&&!s){this.events.onSkip(e);return}this.events.onStart?.(e);const i=ht(e.parent);try{for(const _ of i.before)await _();e.logs=[],await e.handler(),this.events.onPass(e)}catch(_){this.events.onFail(e,_)}finally{for(const _ of i.after)await _()}}}window.__testRunner=Pe;const mt="1.3.3",Be=(typeof window<"u"?(window.__TWD_MOCK_STATE__||(window.__TWD_MOCK_STATE__={rules:[]}),window.__TWD_MOCK_STATE__):{rules:[]}).rules,yt=async t=>{if("serviceWorker"in navigator){const e=t??"/mock-sw.js";await navigator.serviceWorker.register(`${e}?v=${mt}`),navigator.serviceWorker.controller||await new Promise(n=>{navigator.serviceWorker.addEventListener("controllerchange",n,{once:!0})}),navigator.serviceWorker.addEventListener("message",n=>{if(n.data?.type==="EXECUTED"){const{alias:r,request:s}=n.data,i=Be.find(_=>_.alias===r);i&&(i.executed=!0,i.request=s)}})}},vt=()=>Be,bt=()=>c(q,{className:"lucide-wifi-pen-icon lucide-wifi-pen",dataTestId:"wifi-pen-icon",children:[c("path",{d:"M2 8.82a15 15 0 0 1 20 0"}),c("path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z"}),c("path",{d:"M5 12.859a10 10 0 0 1 10.5-2.222"}),c("path",{d:"M8.5 16.429a5 5 0 0 1 3-1.406"})]}),kt=()=>{const t=vt(),e=t.filter(r=>r.executed);return c("button",{onClick:()=>{console.group("🌐 TWD Mock Rules"),console.log("Total rules:",t.length),console.log("Triggered rules:",e.length),console.log("Rules details:"),console.log(t),console.groupEnd()},"aria-label":"View mock rules details in console",style:{background:"#f8fafc",border:"1px solid #cbd5e1",borderRadius:"6px",padding:"8px 12px",cursor:"pointer",fontSize:"12px",color:"#475569",display:"flex",alignItems:"center",gap:"8px",marginBottom:"10px",width:"100%",textAlign:"left",transition:"all 0.2s ease",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)"},children:[c(bt,{}),c("span",{style:{flex:1},children:["Rules: ",e.length,"/",t.length," triggered"]}),c("span",{style:{fontSize:"10px",color:"#1E293B",fontWeight:"500"},children:"View rules in console"})]})},wt={left:{left:0,borderRight:"1px solid #e5e7eb"},right:{right:0,borderLeft:"1px solid #e5e7eb"}},xt='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',St=({open:t,position:e="left"})=>{const[n,r]=re(0),[s,i]=re(t);pt({isOpen:s,position:e});const _=new Pe({onStart:o=>{o.status="running",r(f=>f+1)},onPass:o=>{o.status="pass",r(f=>f+1)},onFail:(o,f)=>{o.status="fail",console.error("Test failed:",o.name,f),o.logs.push(`Test failed: ${f.message}`),r(d=>d+1)},onSkip:o=>{o.status="skip",r(f=>f+1)}}),l=async()=>{await _.runAll()},u=async o=>{const f=Array.from(w.values()).filter(d=>d.type==="test").find(d=>d.id===o);f&&await _.runSingle(f.id)},a=Array.from(w.values());if(!s)return c(ft,{position:e,setOpen:i});const p=a.filter(o=>o.type==="test").length;return c("div",{style:{fontFamily:xt,position:"fixed",top:0,bottom:0,width:"280px",background:"#f9fafb",fontSize:"14px",overflowY:"auto",boxShadow:"2px 0 6px rgba(0,0,0,0.1)",textAlign:"left",zIndex:1e3,...wt[e]},"data-testid":"twd-sidebar",children:[c("div",{style:{padding:"8px",background:"#f9fafb",position:"sticky",top:0,zIndex:1e3,borderBottom:"1px solid #e5e7eb"},children:[c("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"14px"},children:[c("button",{onClick:l,style:{background:"#1A6EF4",color:"white",padding:"4px 8px",borderRadius:"4px",border:"none",cursor:"pointer"},children:"Run All"}),c("button",{"aria-label":"Close sidebar",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:"14px",paddingRight:"0",paddingLeft:"0"},onClick:()=>i(!1),children:"✖"})]}),c("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:"14px",color:"#6b7280",marginBottom:"10px"},children:[c("span",{style:{color:"#374151"},children:["Total: ",p]}),c("div",{style:{display:"flex",gap:"4px"},children:[c("span",{style:{color:"#00c951"},children:["✓ ",a.filter(o=>o.status==="pass").length]}),c("span",{style:{color:"#fb2c36"},children:["✗ ",a.filter(o=>o.status==="fail").length]})]})]}),c(kt,{})]}),c("div",{style:{padding:"8px"},children:c(ut,{tests:a.map(o=>({name:o.name,depth:o.depth,status:o.status,logs:o.logs,id:o.id,parent:o.parent,type:o.type,only:o.only,skip:o.skip})),runTest:u})})]})},Tt=t=>({render:e=>{Ke(e,t)}}),Et=(t,e)=>{const{open:n=!0,position:r="left",serviceWorker:s=!0,serviceWorkerUrl:i="/mock-sw.js"}=e||{};Xe(t,c(St,{open:n,position:r}),Tt),s&&yt(i).then(()=>{console.log("Request mocking initialized")}).catch(_=>{console.error("Error initializing request mocking:",_)})};W.initTWD=Et,Object.defineProperty(W,Symbol.toStringTag,{value:"Module"})}));
|