@pan-stack/test 0.0.10 → 0.0.12

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.
@@ -4027,7 +4027,11 @@ function coversPicker(initial) {
4027
4027
  }));
4028
4028
  const addCode = (code) => { code = code.trim(); if (code && !cur.includes(code)) cur.push(code); draw(); };
4029
4029
  input.addEventListener('keydown', (e) => {
4030
- if (e.key === 'Enter' || e.key === ',') { e.preventDefault(); input.value.split(',').forEach(addCode); input.value = ''; }
4030
+ if (e.key === 'Enter' || e.key === ',') {
4031
+ e.preventDefault(); input.value.split(',').forEach(addCode); input.value = '';
4032
+ // \u0111\xF3ng b\u1EA3ng g\u1EE3i \xFD (n\xF3 che n\xFAt \xABT\u1EA1o\xBB c\u1EE7a h\u1ED9p tho\u1EA1i \u2014 tr\u01B0\u1EDBc \u0111\xE2y ph\u1EA3i b\u1EA5m ra ngo\xE0i m\u1EDBi b\u1EA5m \u0111\u01B0\u1EE3c)
4033
+ input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }));
4034
+ }
4031
4035
  });
4032
4036
  input.addEventListener('blur', () => { if (input.value.trim()) { input.value.split(',').forEach(addCode); input.value = ''; } });
4033
4037
  if (D.ba.linked && P.suggest) {
@@ -5359,7 +5363,7 @@ th,td{border:1px solid #555;padding:4px 6px;vertical-align:top;text-align:left;o
5359
5363
  `:`Ng\u1EEF c\u1EA3nh:
5360
5364
  `)+o].join(`
5361
5365
  `),addDirs:r?[kA.resolve(r)]:[]}}async function Bc(e,t,n,r,i,s){let a=await SA(e,t),o=s===void 0?void 0:Buffer.from(JSON.stringify(s));await new Promise((c,l)=>{let u=xA.request({host:a.url.hostname,port:a.url.port,path:i,method:s===void 0?"GET":"POST",headers:{"x-pan-ai-token":a.token,...o?{"content-type":"application/json","content-length":String(o.length)}:{}}},d=>{r.writeHead(d.statusCode??502,{"Content-Type":String(d.headers["content-type"]||"application/json; charset=utf-8"),"Cache-Control":"no-store","X-Content-Type-Options":"nosniff"}),d.pipe(r),d.on("end",c)});u.on("error",l),n.on("close",()=>u.destroy()),u.end(o)})}var pn,TA,Bg=Se(()=>{"use strict";S();Nn();pn=new Map;TA=(e,t)=>Rg(["ai-host","--dir",e,"--lang",t,"--lifeline"])});var Wg={};ii(Wg,{CSP:()=>qc,VIEW_CSP:()=>Fc,createDocServer:()=>PA,embedSources:()=>Ug});import{randomBytes as CA,timingSafeEqual as EA}from"node:crypto";import $c from"node:fs";import AA from"node:http";import ut from"node:path";import{fileURLToPath as _A}from"node:url";function Fg(e){if(typeof R<"u"&&R[e]!==void 0)return R[e];for(let t of[ut.join($g,"ui"),ut.join($g,"..","..","src","doc","ui")]){let n=ut.join(t,ca[e].file);if($c.existsSync(n))return $c.readFileSync(n,"utf8")}throw new Error(`Thi\u1EBFu t\u1EC7p giao di\u1EC7n ${e}`)}function jg(e){let t=Ve(e.root,e.config.ba);return t?bt(t):null}function NA(e){let t=jg(e);return{root:e.root,me:vt(e.root),config:e.config,modules:e.modules,suites:e.suites,readErrors:e.readErrors,ba:t?{linked:!0,items:[...t.values()].filter(n=>!n.deleted&&(n.type==="function"||n.type==="screen")).map(n=>({code:n.code,title:n.title,type:n.type}))}:{linked:!1,path:e.config.ba??null,items:[]},summary:Pn(e,t)}}function Hg(e){let t={};for(let n of["case","steps","expected","requirement","tag"])ee(e[n])!==void 0&&(t[n]=ee(e[n]));return ee(e.priority)!==void 0&&(t.priority=ee(e.priority)),t}function PA(e){let t=ls(e.start);if(!t)throw new K(U(`Kh\xF4ng th\u1EA5y repo t\xE0i li\u1EC7u ki\u1EC3m th\u1EED (.pantest.yaml) t\u1EEB ${ut.resolve(e.start)}. T\u1EA1o b\u1EB1ng: pan-test doc init`,`No test document repo (.pantest.yaml) found from ${ut.resolve(e.start)}. Create one with: pan-test doc init`));let n=e.token??CA(24).toString("hex"),r=Ug(e.embed),i=r.length?qc.replace("frame-ancestors 'none'",`frame-ancestors ${r.join(" ")}`):qc,s=d=>({status:200,body:d}),a=r.length?Fc.replace("frame-ancestors 'self'",`frame-ancestors 'self' ${r.join(" ")}`):Fc,o={"/api/export":async(d,p)=>{let h=(Array.isArray(d.formats)?d.formats:["docx"]).map(String).filter(m=>Nc.includes(m)),f=await Pc(p,{formats:h.length?h:["docx"],results:d.results===!0,codes:d.codes===!0});return s({ok:!0,dir:ut.join(p.root,Qr),files:f.map(m=>ut.relative(p.root,m).split(ut.sep).join("/"))})},"/api/open":async(d,p)=>{let h=ut.join(p.root,Qr);$c.mkdirSync(h,{recursive:!0});let{spawn:f}=await import("node:child_process"),m=process.platform==="darwin"?"open":process.platform==="win32"?"explorer":"xdg-open";try{f(m,[h],{stdio:"ignore",detached:!0,windowsHide:!0}).unref()}catch{}return s({ok:!0,dir:h})}},c={"/api/module/new":(d,p)=>s(hs(p,String(d.code??"").trim().toUpperCase(),String(d.title??"").trim())),"/api/module":(d,p)=>s(vr(p,String(d.code),{...ee(d.title)!==void 0?{title:ee(d.title)}:{},...ee(d.commonSteps)!==void 0?{commonSteps:ee(d.commonSteps)}:{}})),"/api/suite/new":(d,p)=>s(fs(p,{module:String(d.module),title:String(d.title??""),...d.kind==="non-functional"?{kind:"non-functional"}:{},...Fn(d.covers)?{covers:Fn(d.covers)}:{},...ee(d.after)?{after:ee(d.after)}:{},avoid:Ft(p.root)})),"/api/suite":(d,p)=>{let h={};for(let f of["title","preconditions","description","owner"])ee(d[f])!==void 0&&(h[f]=ee(d[f]));return(d.kind==="functional"||d.kind==="non-functional")&&(h.kind=d.kind),(d.status==="drafting"||d.status==="done"||d.status==="deleted")&&(h.status=d.status),ee(d.priority)!==void 0&&(h.priority=ee(d.priority)),Fn(d.covers)&&(h.covers=Fn(d.covers)),Fn(d.useCases)&&(h.useCases=Fn(d.useCases)),s(zu(p,String(d.code),h))},"/api/case/new":(d,p)=>s(gs(p,String(d.suite),{case:"",...Hg(d)},{...ee(d.after)?{after:ee(d.after)}:{},avoid:Ft(p.root)})),"/api/case":(d,p)=>s(vs(p,String(d.code),Hg(d))),"/api/import/feature":(d,p)=>{let h=Array.isArray(d.files)?d.files:[];if(!h.length)throw new K(U("Ch\u01B0a ch\u1ECDn t\u1EC7p .feature n\xE0o.","No .feature file selected."));let f=Ft(p.root);return s({ok:!0,reports:h.map(m=>({name:String(m.name??""),...Lc(p,String(m.content??""),{file:String(m.name??"feature.feature"),module:String(d.module),avoid:f})}))})},"/api/results":(d,p)=>s({ok:!0,...Mc(p,la(String(d.content??"")),{...ee(d.env)?{env:ee(d.env)}:{}})}),"/api/case/move":(d,p)=>s(Vu(p,String(d.code),d.dir===-1?-1:1)),"/api/case/delete":(d,p)=>s(ws(p,String(d.code),ee(d.reason)??"")),"/api/result":(d,p)=>s(ys(p,String(d.code),{status:String(d.status),...ee(d.actual)!==void 0?{actual:ee(d.actual)}:{},...ee(d.env)!==void 0?{env:ee(d.env)}:{},...ee(d.bug)!==void 0?{bug:ee(d.bug)}:{}}))},l=()=>({status:404,body:{}}),u=AA.createServer((d,p)=>{let h=(b,C,_)=>{p.writeHead(b,{"Content-Type":_,"X-Content-Type-Options":"nosniff","Referrer-Policy":"no-referrer","Cache-Control":"no-store","Content-Security-Policy":i}),p.end(d.method==="HEAD"?void 0:C)},f=(b,C)=>h(b,JSON.stringify(C),"application/json; charset=utf-8"),m=b=>f(b instanceof K?400:500,{ok:!1,error:b.message}),g=b=>{if(p.headersSent){p.end();return}let C=U("C\u1EA7n Pan CLI (@pan-stack/cli \u2265 0.3.90) \u0111\u1EC3 d\xF9ng Tr\u1EE3 l\xFD AI: ","Pan CLI (@pan-stack/cli \u2265 0.3.90) is needed for the AI assistant: ")+b.message;T==="/api/ai"?f(200,{engines:[],max:0,runs:[],error:C}):f(503,{ok:!1,error:C})},y=b=>{Lg(["test",b,"--dir",t,"--json"],t).then(C=>{if(C.json)return f(C.json.ok===!1?400:200,C.json);let _=U("C\u1EA7n Pan CLI (@pan-stack/cli \u2265 0.3.91) \u0111\u1EC3 ph\xE1t h\xE0nh l\xEAn Pan Studio: ","Pan CLI (@pan-stack/cli \u2265 0.3.91) is needed to publish to Pan Studio: ")+(C.stderr.trim().slice(-300)||`exit ${C.code}`);return b==="studio"?f(200,{ok:!0,login:!1,cli:!1,error:_}):f(503,{ok:!1,error:_})}).catch(m)},T=(()=>{try{return new URL(d.url||"/","http://x").pathname}catch{return""}})();try{let b=u.address()?.port,C=String(d.headers.host||""),_=[`127.0.0.1:${b}`,`localhost:${b}`];if(!_.includes(C))return f(403,{error:"Host kh\xF4ng h\u1EE3p l\u1EC7"});let w=new URL(d.url||"/",`http://${C}`),x=w.pathname,v=x==="/api/ai"||x.startsWith("/api/ai/");if(d.method==="POST"){let N=c[x]??o[x]??(v||x.startsWith("/api/studio/")?l:void 0);if(!N)return f(404,{error:"Kh\xF4ng c\xF3"});let M=String(d.headers.origin||"");if(M&&!_.some(V=>M===`http://${V}`))return f(403,{error:"Origin kh\xF4ng h\u1EE3p l\u1EC7"});let O=Buffer.from(String(d.headers["x-pan-test-token"]||"")),F=Buffer.from(n);if(O.length!==F.length||!EA(O,F))return f(403,{error:"Thi\u1EBFu token phi\xEAn"});if(!String(d.headers["content-type"]||"").startsWith("application/json"))return f(415,{error:"C\u1EA7n application/json"});let Q=[],Z=0;d.on("data",V=>{Z+=V.length,Z>qg?(f(413,{error:"Qu\xE1 l\u1EDBn"}),d.destroy()):Q.push(V)}),d.on("end",()=>{if(Z>qg)return;let V;try{V=JSON.parse(Buffer.concat(Q).toString("utf8")||"{}")}catch{return f(400,{error:"JSON sai"})}if(x==="/api/studio/publish"||x==="/api/studio/remove"){y(x==="/api/studio/publish"?"publish":"unpublish");return}if(N===l){let G=Ge(t),de=x==="/api/ai/run"?{...V,...Dg(G,ee(V.item))}:V;Bc(t,G.config.language,d,p,x,de).catch(g);return}Promise.resolve().then(()=>{let G=Ge(t);return un(G.config.language),N(V,G)}).then(G=>f(G.status,G.body)).catch(m)});return}if(d.method!=="GET"&&d.method!=="HEAD")return f(405,{error:"Ch\u1EC9 cho GET/POST"});if(x==="/api/studio"){y("studio");return}if(v){let N=Ge(t);Bc(t,N.config.language,d,p,x+w.search).catch(g);return}if(x==="/"||x==="/index.html"){let N=w.searchParams.get("lang")||e.lang||Ge(t).config.language,M=Fg("index.html").replace(/<head[^>]*>/,O=>`${O}<meta name="pantest-token" content="${n}"><meta name="panba-lang" content="${N==="en"?"en":"vi"}">`);return h(200,M,ca["index.html"].type)}let A=/^\/ui\/([a-z0-9.]+)$/.exec(x);if(A&&ca[A[1]])return h(200,Fg(A[1]),ca[A[1]].type);if(x==="/favicon.ico")return h(204,"","image/x-icon");if(x==="/api/index")return f(200,NA(Ge(t)));if(x==="/view/doc"){let N=oa(aa(Ge(t),{results:w.searchParams.get("results")==="1",codes:w.searchParams.get("codes")==="1"}));return p.writeHead(200,{"Content-Type":"text/html; charset=utf-8","X-Content-Type-Options":"nosniff","Referrer-Policy":"no-referrer","Cache-Control":"no-store","Content-Security-Policy":a}),p.end(d.method==="HEAD"?void 0:N)}if(x==="/api/check"){let N=Ge(t);return f(200,{findings:xs(N,jg(N))})}return f(404,{error:"Kh\xF4ng c\xF3"})}catch(b){return m(b)}});return u.on("close",()=>Mg()),Object.assign(u,{token:n,root:t})}var $g,ca,Fc,qc,qg,Ug,ee,Fn,Kg=Se(()=>{"use strict";S();qn();Nn();xr();wr();ti();Zr();_n();Bg();$g=ut.dirname(_A(import.meta.url)),ca={"index.html":{file:"index.html",type:"text/html; charset=utf-8"},"tokens.css":{file:"tokens.css",type:"text/css; charset=utf-8"},"shell.js":{file:"shell.browser.js",type:"text/javascript; charset=utf-8"},"i18n.js":{file:"i18n.browser.js",type:"text/javascript; charset=utf-8"},"app.js":{file:"app.browser.js",type:"text/javascript; charset=utf-8"},"assist.js":{file:"assist.browser.js",type:"text/javascript; charset=utf-8"},"edit.js":{file:"edit.browser.js",type:"text/javascript; charset=utf-8"}};Fc="default-src 'none'; style-src 'unsafe-inline'; img-src 'self' data:; base-uri 'none'; form-action 'none'; frame-ancestors 'self'",qc="default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; connect-src 'self'; font-src 'self'; frame-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'",qg=24*1024*1024,Ug=e=>(e??[]).filter(t=>/^[a-z][a-z0-9+.-]*:$/.test(t)||/^https?:\/\/[A-Za-z0-9.-]+(:\d+)?$/.test(t)),ee=e=>typeof e=="string"?e:void 0,Fn=e=>Array.isArray(e)?e.map(String).map(t=>t.trim()).filter(Boolean):void 0});var Vg={};ii(Vg,{buildBundle:()=>RA});function OA(e,t,n){let r=Jr[n],i=yr(e,tn()),s=[`# ${e.code} \xB7 ${e.title}`,""],a=[e.covers.length?`- ${r.functions}${e.covers.join(", ")}`:"",e.useCases.length?`- ${r.useCase}${e.useCases.join(", ")}`:"",e.preconditions?`- ${r.pre}${e.preconditions.replace(/\n+/g," ")}`:"",`- ${r.sumHead[2]}: ${i.passed}/${i.total} \xB7 ${r.sumHead[3]}: ${i.failed} \xB7 ${r.sumHead[6]}: ${i["not-run"]}`].filter(Boolean);s.push(...a,""),e.description.trim()&&s.push(e.description.trim(),"");let o=t.modules.find(l=>l.code===e.module);o?.commonSteps.trim()&&s.push(`**${r.commonSteps}**`,"",o.commonSteps.trim(),"");let c=sa(e,{results:!0,codes:!0},r,n);if(!c.rows.length)s.push(r.noCases,"");else{s.push("| "+c.head.join(" | ")+" |","|"+c.head.map(()=>" --- |").join(""));for(let l of c.rows)s.push("| "+l.map(IA).join(" | ")+" |");s.push("")}return s.join(`
5362
- `)}function RA(e){let t=e.config.language==="en"?"en":"vi",n=Jr[t],r=Ve(e.root,e.config.ba),i=Pn(e,r?bt(r):null),s={},a=[`# ${t==="en"?"Generated by \xABpan test publish\xBB \u2014 do not edit; the test document repo is the source.":"Sinh b\u1EDFi \xABpan test publish\xBB \u2014 \u0111\u1EEBng s\u1EEDa tay; ngu\u1ED3n l\xE0 repo t\xE0i li\u1EC7u ki\u1EC3m th\u1EED."}`,`title: ${Me(e.config.title)}`,`locale: ${t}`,"theme: classic","sections:"],o=n.sumHead,c=i.modules.map(h=>[`${h.code} \xB7 ${h.title}`,h.count.total,h.count.passed,h.count.failed,h.count.blocked,h.count.skipped,h.count["not-run"],zg(h.count.passed,h.count.total)]);c.push([`**${n.total}**`,i.all.total,i.all.passed,i.all.failed,i.all.blocked,i.all.skipped,i.all["not-run"],zg(i.all.passed,i.all.total)]),s["content/tong-hop/tong-hop.md"]=[`# ${n.sumTitle}`,"","| "+o.join(" | ")+" |","|"+o.map(()=>" --- |").join(""),...c.map(h=>"| "+h.join(" | ")+" |"),"",...i.coverage?[`${t==="en"?"BA function coverage":"\u0110\u1ED9 ph\u1EE7 ch\u1EE9c n\u0103ng t\xE0i li\u1EC7u BA"}: ${i.coverage.covered}/${i.coverage.functions}`,""]:[]].join(`
5366
+ `)}function RA(e){let t=e.config.language==="en"?"en":"vi",n=Jr[t],r=Ve(e.root,e.config.ba),i=Pn(e,r?bt(r):null),s={},a=[`# ${t==="en"?"Generated by \xABpan test publish\xBB \u2014 do not edit; the test document repo is the source.":"Sinh b\u1EDFi \xABpan test publish\xBB \u2014 \u0111\u1EEBng s\u1EEDa tay; ngu\u1ED3n l\xE0 repo t\xE0i li\u1EC7u ki\u1EC3m th\u1EED."}`,`title: ${Me(e.config.title)}`,`locale: ${t}`,"theme: classic","layout: document","sections:"],o=n.sumHead,c=i.modules.map(h=>[`${h.code} \xB7 ${h.title}`,h.count.total,h.count.passed,h.count.failed,h.count.blocked,h.count.skipped,h.count["not-run"],zg(h.count.passed,h.count.total)]);c.push([`**${n.total}**`,i.all.total,i.all.passed,i.all.failed,i.all.blocked,i.all.skipped,i.all["not-run"],zg(i.all.passed,i.all.total)]),s["content/tong-hop/tong-hop.md"]=[`# ${n.sumTitle}`,"","| "+o.join(" | ")+" |","|"+o.map(()=>" --- |").join(""),...c.map(h=>"| "+h.join(" | ")+" |"),"",...i.coverage?[`${t==="en"?"BA function coverage":"\u0110\u1ED9 ph\u1EE7 ch\u1EE9c n\u0103ng t\xE0i li\u1EC7u BA"}: ${i.coverage.covered}/${i.coverage.functions}`,""]:[]].join(`
5363
5367
  `),a.push(` - id: ${Me("tong-hop")}`,` title: ${Me(n.sumTitle)}`," lessons:",` - id: ${Me("tong-hop")}`,` title: ${Me(n.sumTitle)}`," type: article",` src: ${Me("content/tong-hop/tong-hop.md")}`);let l=1,u=new Set(["tong-hop"]),d=h=>{let f=h;for(let m=2;u.has(f);m++)f=`${h}-${m}`;return u.add(f),f};return[...e.modules].sort((h,f)=>h.order-f.order).forEach((h,f)=>{let m=e.suites.filter(y=>y.module===h.code&&y.status!=="deleted").sort((y,T)=>(h.suites.indexOf(y.code)+1||1e9)-(h.suites.indexOf(T.code)+1||1e9)||y.code.localeCompare(T.code));if(!m.length)return;let g=d(Gg(h.code));a.push(` - id: ${Me(g)}`,` title: ${Me(`${f+1}. ${h.title}`)}`," lessons:");for(let y of m){let T=d(Gg(y.code)),b=`content/${g}/${T}.md`;s[b]=OA(y,e,t),a.push(` - id: ${Me(T)}`,` title: ${Me(`${y.code} \xB7 ${y.title}`)}`," type: article",` src: ${Me(b)}`,` code: ${Me(y.code)}`,` module: ${Me(h.code)}`),l++}}),s["handover.yaml"]=a.join(`
5364
5368
  `)+`
5365
5369
  `,{title:e.config.title,language:t,ba:r,lessons:l,files:s}}var Me,Gg,IA,zg,Xg=Se(()=>{"use strict";S();Nn();xr();Zr();Me=e=>JSON.stringify(e),Gg=e=>e.normalize("NFD").replace(/[̀-ͯ]/g,"").replace(/đ/g,"d").replace(/Đ/g,"D").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"muc",IA=e=>e.map(t=>t.replace(/\|/g,"\\|")).join("<br>")||" ",zg=(e,t)=>t?`${Math.round(e/t*100)}%`:"\u2014"});S();S();qn();import da from"node:fs";import At from"node:path";S();si();fn();_n();Nn();wr();xr();Zr();ti();var LA=`pan-test doc \u2014 t\xE0i li\u1EC7u k\u1ECBch b\u1EA3n ki\u1EC3m th\u1EED