@skyramp/testbot-core 0.13.0-v3.307 → 0.13.0-v3.308

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/VERSION.json CHANGED
@@ -1 +1 @@
1
- {"version":"0.13.0-v3.307","commit":"1b67dc575048b82c3040e05ae3fa07c63addf2e9"}
1
+ {"version":"0.13.0-v3.308","commit":"d311b77c3d58f542d8901668a45a64874980c1e3"}
package/dist/main.js CHANGED
@@ -301,7 +301,7 @@ ${g.message}`),E(127)}),c.on("exit",()=>l("SIGKILL")),c.on("close",(g,w)=>E(g??(
301
301
  `))}))}function uMt(e,t=!1){let r=[];if(t){let n=e.split(`
302
302
  `),s=[];n.reduce((i,o)=>(s.push(i),i+o.length+1),0);for(let i of e.matchAll(aMt)){let o=i[1].length,a=e.slice(0,i.index).split(`
303
303
  `).length-1,c=a+1;for(;c<n.length&&(!n[c].trim()||n[c].length-n[c].trimStart().length>o);)c++;let l=n.slice(Math.max(0,a-3),a).join(`
304
- `);r.push({title:i[2],start:s[a],end:c<n.length?s[c]:e.length,skipped:/@pytest\.mark\.skip/.test(l)})}return r}for(let n of e.matchAll(oMt)){let s=iMt(e,n.index+n[0].length);s!==void 0&&r.push({title:n[3],start:n.index,end:sMt(e,s),skipped:n[1]==="skip"||n[1]==="fixme"})}return r.filter(n=>!r.some(s=>s!==n&&s.start<=n.start&&n.end<=s.end))}var OC=e=>e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim();function dMt(e,t){let r=OC(t);if(r)return e.find(n=>OC(n.title)===r)??e.find(n=>OC(n.title)&&(r.includes(OC(n.title))||OC(n.title).includes(r)))}var iFe=/@playwright\/test|from\s+playwright|sync_playwright|async_playwright|\bpage\.goto\s*\(|\bcy\.visit\s*\(|\bcypress\b|selenium|webdriver|newSkyrampPlaywrightPage|\bbrowser\.url\s*\(|ApplicationSystemTestCase|\bCapybara\b|\bdriven_by\b|type:\s*:(?:system|feature)\b/i,pMt=[{re:/\.(?:fulfill|abort)\s*\(/,what:"route.fulfill / route.abort"},{re:/\broute_?from_?har\s*\(/i,what:"a HAR replay (routeFromHAR)"},{re:/from\s+['"]msw(?:\/[^'"]*)?['"]|require\(\s*['"]msw|\bsetup(?:Server|Worker)\s*\(/,what:"msw handlers"}];function fMt(e){for(let t of e.matchAll(/\bcy\.intercept\s*\(/g)){let r=0,n=t.index+t[0].length-1,s=n;for(;n<e.length;n++)if(e[n]==="(")r++;else if(e[n]===")"&&--r===0)break;if(/\b(statusCode|fixture|body|forceNetworkError)\s*:|\.(reply|destroy)\s*\(/.test(e.slice(s,n)))return!0}return!1}function hMt(e){let t=pMt.filter(r=>r.re.test(e)).map(r=>r.what);return fMt(e)&&t.push("cy.intercept with a response"),t}var oFe=/(?:\.goto|\bcy\.visit|\bdriver\.get|\bbrowser\.url|\.navigate\(\)\.to)\s*\(\s*(?:f?(['"`])((?:\\.|(?!\1)[^\\])*)\1)?/g,aFe=/(?<![.\w])visit[ \t]*\(?[ \t]*(?:(['"])((?:\\.|(?!\1)[^\\])*)\1)?/g,mMt=/\.(click|dblclick|fill|type|press|pressSequentially|press_sequentially|check|uncheck|selectOption|select_option|setInputFiles|set_input_files|tap|dragTo|drag_to|submit|clear|hover|reload)\s*\(/g,gMt=/(?<![\w$])(?:expect|assert|verify|should)\w*\s*\(|\bexpect\.|\bassert\b/gi,AMt=/\b(?:click_on|click_button|click_link|fill_in|select|check|uncheck|choose|attach_file)\b|\.(?:click|set|select_option)\b/g,yMt=/\b(?:assert\w*|refute\w*|expect)\b/g;function jMe(e,t=!1,r){let n=[...e.matchAll(t?aFe:oFe)].map(i=>({at:i.index,route:i[1]!==void 0?i[2]:void 0})),s=r?.navigators.size?[...e.matchAll(new RegExp(`(?<![\\w$.])(${[...r.navigators].map(i=>i.replace(/[$]/g,"\\$")).join("|")})\\s*\\(`,"g"))].map(i=>({at:i.index,route:void 0})):[];return[...n,...s].sort((i,o)=>i.at-o.at)}var EMt=/(?:from\s+|require\(\s*|import\s+)(['"])(\.{1,2}\/[^'"]+)\1/g,wMt=/require_relative\s+(['"])([^'"]+)\1/g,bMt=/^\s*from\s+(\.+)?([\w.]*)\s+import\b/gm,SMt=/(?:export\s+)?(?:async\s+)?function\s+(\w+)|(?:export\s+)?(?:const|let)\s+(\w+)\s*=\s*(?:async\s*)?(?:\([^)]*\)|\w+)\s*=>|^[ \t]*(?:async\s+)?def\s+(\w+)|^[ \t]*(\w+)\s*\([^)]*\)\s*\{/gm;function f5(e,t,r){let n=ws.resolve(ws.dirname(e),t);for(let s of[n,...r.map(i=>n+i),...r.map(i=>ws.join(n,`index${i}`))])try{if(Ka.statSync(s).isFile())return s}catch{}}function CMt(e,t){let r={navigators:new Set,browser:!1,fixtureNavigates:!1},n=/\.rb$/i.test(e),s=/\.py$/i.test(e),i=new Set([ws.resolve(e)]),o=(l,u)=>n?[...u.matchAll(wMt)].map(d=>f5(l,d[2],[".rb"])).filter(d=>!!d):s?[...u.matchAll(bMt)].map(d=>f5(l,(d[1]&&d[1].length>1?"../".repeat(d[1].length-1):"./")+d[2].replace(/\./g,"/"),[".py"])).filter(d=>!!d):[...u.matchAll(EMt)].map(d=>f5(l,d[2],[".ts",".tsx",".js",".mjs",".cjs",".jsx"])).filter(d=>!!d),a=!n&&!s&&/import\s*\{[^}]*\btest\b[^}]*\}\s*from\s*['"]\.{1,2}\//.test(t),c=o(e,t);for(let l=0;l<2&&c.length;l++){let u=[];for(let d of c){if(i.has(d))continue;i.add(d);let p;try{p=sFe(Ka.readFileSync(d,"utf-8"))}catch{continue}iFe.test(p)&&(r.browser=!0);let f=n?aFe:oFe,m=[...p.matchAll(SMt)].map(A=>({name:A[1]??A[2]??A[3]??A[4],at:A.index}));m.forEach((A,E)=>{let g=p.slice(A.at,E+1<m.length?m[E+1].at:p.length);f.lastIndex=0,A.name&&f.test(g)&&r.navigators.add(A.name)}),f.lastIndex=0,a&&/\.extend\s*[<(]/.test(p)&&f.test(p)&&(r.fixtureNavigates=!0),u.push(...o(d,p))}c=u}return r}function HMe(e){let t=e.trim().replace(/^\$\{[^}]*\}/,"").replace(/^https?:\/\/[^/]+/i,"").replace(/^\{[^}]*\}/,"");return t=t.split("?")[0],!t.startsWith("/")&&!t.startsWith("#")&&(t=`/${t}`),t.length>1?t.replace(/\/+$/,""):t}var zMe=/^(:\w+|\[[^\]]+\]|\{[^}]+\}|<[^>]+>|\$\{[^}]*\}|\*)$/;function h5(e,t){let r=HMe(e).split("/"),n=HMe(t).split("/");return r.length===n.length&&r.every((s,i)=>s===n[i]||zMe.test(s)||zMe.test(n[i]))}function vMt(e,t,r,n=!1,s={}){let{ruby:i=!1,helpers:o}=s,a=t.kind!=="in-process";if(a&&!iFe.test(e)&&!o?.browser)return["is not a browser test (no Playwright, Cypress, Capybara or WebDriver page in it, nor in a helper it imports)"];let c=sFe(e),l=i?lMt(c):uMt(c,n),u=r?.trim()?dMt(l,r):l.length===1?l[0]:void 0;if(!u)return[r?.trim()?`has no test titled "${r}"`:`holds ${l.length} tests; say which one walks the journey ("test" in "journeys")`];let d=[];if(u.skipped&&d.push(`its test "${u.title}" is skipped`),!a)return[...d,...VMe(c.slice(u.start,u.end),t,i)];let p="",f=0;for(let g of l)p+=c.slice(f,g.start),f=g.end;p+=c.slice(f);let m=c.slice(u.start,u.end),A=hMt(`${p}
304
+ `);r.push({title:i[2],start:s[a],end:c<n.length?s[c]:e.length,skipped:/@pytest\.mark\.skip/.test(l)})}return r}for(let n of e.matchAll(oMt)){let s=iMt(e,n.index+n[0].length);s!==void 0&&r.push({title:n[3],start:n.index,end:sMt(e,s),skipped:n[1]==="skip"||n[1]==="fixme"})}return r.filter(n=>!r.some(s=>s!==n&&s.start<=n.start&&n.end<=s.end))}var OC=e=>e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim();function dMt(e,t){let r=OC(t);if(r)return e.find(n=>OC(n.title)===r)??e.find(n=>OC(n.title)&&(r.includes(OC(n.title))||OC(n.title).includes(r)))}var iFe=/@playwright\/test|from\s+playwright|sync_playwright|async_playwright|\bpage\.goto\s*\(|\bcy\.visit\s*\(|\bcypress\b|selenium|webdriver|newSkyrampPlaywrightPage|\bbrowser\.url\s*\(|ApplicationSystemTestCase|\bCapybara\b|\bdriven_by\b|type:\s*:(?:system|feature)\b/i,pMt=[{re:/\.(?:fulfill|abort)\s*\(/,what:"route.fulfill / route.abort"},{re:/\broute_?from_?har\s*\(/i,what:"a HAR replay (routeFromHAR)"},{re:/from\s+['"]msw(?:\/[^'"]*)?['"]|require\(\s*['"]msw|\bsetup(?:Server|Worker)\s*\(/,what:"msw handlers"}];function fMt(e){for(let t of e.matchAll(/\bcy\.intercept\s*\(/g)){let r=0,n=t.index+t[0].length-1,s=n;for(;n<e.length;n++)if(e[n]==="(")r++;else if(e[n]===")"&&--r===0)break;if(/\b(statusCode|fixture|body|forceNetworkError)\s*:|\.(reply|destroy)\s*\(/.test(e.slice(s,n)))return!0}return!1}function hMt(e){let t=pMt.filter(r=>r.re.test(e)).map(r=>r.what);return fMt(e)&&t.push("cy.intercept with a response"),t}var oFe=/(?:\.goto|\bcy\.visit|\bdriver\.get|\bbrowser\.url|\.navigate\(\)\.to)\s*\(\s*(?:f?(['"`])((?:\\.|(?!\1)[^\\])*)\1)?/g,aFe=/(?<![.\w])visit[ \t]*\(?[ \t]*(?:(['"])((?:\\.|(?!\1)[^\\])*)\1)?/g,mMt=/\.(click|dblclick|fill|type|press|pressSequentially|press_sequentially|check|uncheck|selectOption|select_option|setInputFiles|set_input_files|tap|dragTo|drag_to|submit|clear|hover|reload)\s*\(/g,gMt=/(?<![\w$])(?:expect|assert|verify|should)\w*\s*\(|\bexpect\.|\bassert\b/gi,AMt=/\b(?:click_on|click_button|click_link|fill_in|select|check|uncheck|choose|attach_file)\b|\.(?:click|set|select_option)\b/g,yMt=/\b(?:assert\w*|refute\w*|expect)\b/g;function jMe(e,t=!1,r){let n=[...e.matchAll(t?aFe:oFe)].map(i=>({at:i.index,route:i[1]!==void 0?i[2]:void 0})),s=r?.navigators.size?[...e.matchAll(new RegExp(`(?<![\\w$.])(${[...r.navigators].map(i=>i.replace(/[$]/g,"\\$")).join("|")})\\s*\\(`,"g"))].map(i=>({at:i.index,route:void 0})):[];return[...n,...s].sort((i,o)=>i.at-o.at)}var EMt=/(?:from\s+|require\(\s*|import\s+)(['"])(\.{1,2}\/[^'"]+)\1/g,wMt=/require_relative\s+(['"])([^'"]+)\1/g,bMt=/^\s*from\s+(\.+)?([\w.]*)\s+import\b/gm,SMt=/(?:export\s+)?(?:async\s+)?function\s+(\w+)|(?:export\s+)?(?:const|let)\s+(\w+)\s*=\s*(?:async\s*)?(?:\([^)]*\)|\w+)\s*=>|^[ \t]*(?:async\s+)?def\s+(\w+)|^[ \t]*(\w+)\s*\([^)]*\)\s*\{/gm;function f5(e,t,r){let n=ws.resolve(ws.dirname(e),t);for(let s of[n,...r.map(i=>n+i),...r.map(i=>ws.join(n,`index${i}`))])try{if(Ka.statSync(s).isFile())return s}catch{}}function CMt(e,t){let r={navigators:new Set,browser:!1,fixtureNavigates:!1},n=/\.rb$/i.test(e),s=/\.py$/i.test(e),i=new Set([ws.resolve(e)]),o=(l,u)=>n?[...u.matchAll(wMt)].map(d=>f5(l,d[2],[".rb"])).filter(d=>!!d):s?[...u.matchAll(bMt)].map(d=>f5(l,(d[1]&&d[1].length>1?"../".repeat(d[1].length-1):"./")+d[2].replace(/\./g,"/"),[".py"])).filter(d=>!!d):[...u.matchAll(EMt)].map(d=>f5(l,d[2],[".ts",".tsx",".js",".mjs",".cjs",".jsx"])).filter(d=>!!d),a=!n&&!s&&/import\s*\{[^}]*\btest\b[^}]*\}\s*from\s*['"]\.{1,2}\//.test(t),c=o(e,t);for(let l=0;l<2&&c.length;l++){let u=[];for(let d of c){if(i.has(d))continue;i.add(d);let p;try{p=sFe(Ka.readFileSync(d,"utf-8"))}catch{continue}iFe.test(p)&&(r.browser=!0);let f=n?aFe:oFe,m=[...p.matchAll(SMt)].map(A=>({name:A[1]??A[2]??A[3]??A[4],at:A.index}));m.forEach((A,E)=>{let g=p.slice(A.at,E+1<m.length?m[E+1].at:p.length);f.lastIndex=0,A.name&&f.test(g)&&r.navigators.add(A.name)}),f.lastIndex=0,a&&/\.extend\s*[<(]/.test(p)&&f.test(p)&&(r.fixtureNavigates=!0),u.push(...o(d,p))}c=u}return r}function HMe(e){let t=e.trim().replace(/^\$\{[^}]*\}/,"").replace(/^https?:\/\/[^/]+/i,"").replace(/^\{[^}]*\}/,"");return t=t.split(/[?\s]/)[0],!t.startsWith("/")&&!t.startsWith("#")&&(t=`/${t}`),t.length>1?t.replace(/\/+$/,""):t}var zMe=/^(:\w+|\[[^\]]+\]|\{[^}]+\}|<[^>]+>|\$\{[^}]*\}|\*)$/;function h5(e,t){let r=HMe(e).split("/"),n=HMe(t).split("/");return r.length===n.length&&r.every((s,i)=>s===n[i]||zMe.test(s)||zMe.test(n[i]))}function vMt(e,t,r,n=!1,s={}){let{ruby:i=!1,helpers:o}=s,a=t.kind!=="in-process";if(a&&!iFe.test(e)&&!o?.browser)return["is not a browser test (no Playwright, Cypress, Capybara or WebDriver page in it, nor in a helper it imports)"];let c=sFe(e),l=i?lMt(c):uMt(c,n),u=r?.trim()?dMt(l,r):l.length===1?l[0]:void 0;if(!u)return[r?.trim()?`has no test titled "${r}"`:`holds ${l.length} tests; say which one walks the journey ("test" in "journeys")`];let d=[];if(u.skipped&&d.push(`its test "${u.title}" is skipped`),!a)return[...d,...VMe(c.slice(u.start,u.end),t,i)];let p="",f=0;for(let g of l)p+=c.slice(f,g.start),f=g.end;p+=c.slice(f);let m=c.slice(u.start,u.end),A=hMt(`${p}
305
305
  ${m}`);A.length&&d.push(`stubs the app's network (${A.join(", ")}); a journey test runs against the real app, so remove the stub from it`);let E=[...o?.fixtureNavigates?[{at:-1,route:void 0}]:[],...jMe(p,i,o),...jMe(m,i,o).map(g=>({...g,at:g.at+p.length+1}))];if(!E.length)d.push(`never opens a page; start it with a navigation to the entry route ${t.entry}`);else{let g=E.findIndex(w=>w.route===void 0||h5(w.route,t.entry));if(g<0)d.push(`does not open the journey's entry route ${t.entry} (it opens ${E.map(w=>w.route).join(", ")}); start there`);else{let w=t.steps.slice(1).filter(S=>S.route.trim()&&!h5(S.route,t.entry));for(let S of E.slice(g+1)){let x=S.route!==void 0?w.find(R=>h5(S.route,R.route)):void 0;x&&d.push(`jumps by URL to ${S.route} (step ${t.steps.indexOf(x)+1}) instead of getting there through the UI; use page.reload() where the outcome must persist`)}}}if(d.push(...VMe(m,t,i)),!n&&!i&&/@playwright\/test/.test(e)){let g=(m.match(/\btest\.step\s*\(/g)??[]).length;g<t.steps.length&&d.push(`marks ${g} of its ${t.steps.length} steps; wrap each in test.step, named for the step, so a failure names it`)}return d}function VMe(e,t,r){let n=Math.max(-1,...[...e.matchAll(r?AMt:mMt)].map(i=>i.index),...[...e.matchAll(xMt)].map(i=>i.index)),s=[...e.matchAll(r?yMt:gMt)].map(i=>i.index);return s.length?Math.max(...s)<n?[`ends with a user action and no assertion after it; assert the journey's outcome after the last step: ${t.outcome}`]:s.length<t.steps.length?[`has ${s.length} assertion(s) for ${t.steps.length} steps; after each step, assert what the user then sees`]:[]:[`asserts nothing; end it by asserting the journey's outcome: ${t.outcome}`]}var xMt=/\b(?:userEvent|user|fireEvent)\.\w+\s*\(|\.(?:trigger|setValue)\s*\(/g,IMt=/^\s*pass(?:es|ed|ing)\b\s*(?:$|[:;,.(—–-])|\bcould[- ]break\s+(?:check|test|rule|case)s?\b|\b(?:removed|dropped|deleted)\b[^.;]{0,60}\b(?:because|as|since|for)\b[^.;]{0,40}\bpass(?:es|ed|ing)?\b|\bpass(?:es|ed)\b[^.;]{0,40}\b(?:and|so)\b[^.;]{0,20}\b(?:removed|dropped|deleted)\b/i;function N0(e,t,r){return e.map(n=>{let s=t.notWritten?.find(u=>u.case.trim()===n.id)?.reason.trim(),i=t.tests.some(u=>u.covers.includes(n.id));if(s&&!i&&IMt.test(s))return{journey:n,uncovered:s,problems:["its test was removed because it passes; a journey's test stays whether it passes or fails: restore it"]};if(s&&!i)return{journey:n,uncovered:s,problems:[]};let o=t.journeys?.find(u=>u.journey.trim()===n.id),a=o?.file?.trim()||t.tests.find(u=>u.covers.includes(n.id))?.file||n.testFile,c=a?r(a):void 0;if(!c)return{journey:n,file:a,test:o?.test,problems:[`has no test: ${a||"no file"} is not on disk`]};let l;try{l=Ka.readFileSync(c,"utf-8")}catch{return{journey:n,file:a,test:o?.test,problems:[`has no test: ${a} cannot be read`]}}return{journey:n,file:a,test:o?.test,problems:vMt(l,n,o?.test,/\.py$/i.test(c),{ruby:/\.rb$/i.test(c),helpers:CMt(c,l)})}})}function $c(e,t=[]){let r=[e,...t.map(n=>n.path)].map(n=>ws.resolve(n));return n=>{let s=n.replace(/^\.\//,""),i=s.split("/")[0];return[ws.resolve(e,s),...t.filter(a=>ws.basename(ws.resolve(a.path))===i).map(a=>ws.resolve(a.path,s.slice(i.length+1)))].find(a=>r.some(c=>a.startsWith(c+ws.sep))&&Ka.existsSync(a)&&Ka.statSync(a).isFile())}}function XF(e){return e.filter(t=>t.problems.length).map(t=>`journey ${t.journey.id} (${t.journey.name})${t.file?` in ${t.file}`:""}: ${t.problems.join("; ")}`)}var ZF=(e,t)=>e===t||e.endsWith(`/${t}`)||t.endsWith(`/${e}`);function cFe(e,t,r){if(!r||!t.journeys?.find(s=>s.journey.trim()===e.id)?.brokeAt)return!1;let n=new Set([e.id,...e.steps.flatMap(s=>s.clauses??[])].map(s=>s.trim()));return t.tests.some(s=>ZF(s.file,r)&&s.covers.some(i=>n.has(i.trim()))&&typeof s.result.exit=="number"&&s.result.exit!==0)}function lFe(e,t,r){return(t?N0(e,t,r):e.map(s=>({journey:s,problems:["has no test"]}))).map(({journey:s,file:i,test:o,problems:a,uncovered:c})=>{if(c)return{id:s.id,name:s.name,entry:s.entry,steps:s.steps.length,source:s.source??"inferred",status:"Not written",problems:a,uncovered:c};let l=(t?.tests??[]).filter(E=>i&&ZF(E.file,i)),u=l.find(E=>E.covers.includes(s.id))??l[0],d=!!(i&&r(i)),p=u?.result.cases.find(E=>E.case===s.id)?.status,f=!p&&u&&!u.result.cases.length&&u.covers.every(E=>E===s.id)?u.result.exit:null,m=!p&&t!==void 0&&cFe(s,t,i),A=d?p==="pass"||f===0?"Pass":p==="fail"||f!==null&&f!==0||m?"Fail":"Not run":"Not written";return{id:s.id,name:s.name,entry:s.entry,steps:s.steps.length,source:s.source??"inferred",...d?{fileName:i}:{},...o?{test:o}:{},status:A,problems:d?a:[]}})}function uFe(e,t){if(!t)return[];let r=[];for(let n of e){let s=t.journeys?.find(p=>p.journey.trim()===n.id),i=s?.brokeAt,o=t.tests.flatMap(p=>p.result.cases.filter(f=>f.case===n.id).map(f=>f.status)),a=o.includes("fail")||!o.length&&cFe(n,t,s?.file?.trim());if(!i||!a)continue;let c=n.steps[i.step-1],l=c?` (${c.route.trim()?`${c.route.trim()} \u2014 `:""}${c.action.trim()})`:"",u=i.notReached??[],d=u.length===1?` Step ${u[0]} was not reached.`:u.length?` Steps ${u.join(", ")} were not reached.`:"";r.push({description:`User journey "${n.name.trim()}" breaks at step ${i.step}${l}: expected ${i.expected.trim()}, got ${i.actual.trim()}.${d}`,severity:"medium",category:"bug",...s?.file?{test:s.file}:{},...c?.clauses?.length?{clauses:[...c.clauses]}:{}})}return r}var RMt=["stale_test","open_question"],WMe=["low","medium","high","critical"],TMt=(e,t)=>WMe.indexOf(t)>WMe.indexOf(e??"")?t:e??t;function dFe(e,t,r=[]){let n=new Map(r.flatMap(a=>[[a.id,a.id],...a.clauses.map(c=>[c.id,a.id])])),s=(a,c)=>a===c||(n.get(a)??a)===(n.get(c)??c),i=[...e],o=[...e];for(let{test:a,clauses:c=[],...l}of t){let u=a?o.flatMap((f,m)=>!RMt.includes(f.category??"")&&vM(f.description,a)?[m]:[]):[],d=f=>c.some(m=>(o[f].requirementIds??[]).some(A=>s(A,m))),p=u.find(d)??(u.length===1&&!o[u[0]].requirementIds?.length?u[0]:void 0);if(p===void 0){i.push({...l,description:a?`${l.description} (shown by ${a})`:l.description});continue}o[p]={...o[p],description:`${o[p].description} ${l.description}`,severity:TMt(o[p].severity,l.severity)},i[p]=o[p]}return i}function pFe(e,t){if(!e)return;let r=t?.results??[];return{journeys:e.journeys,notWritten:(e.journeysNotWritten??[]).map(n=>({case:n.journey,reason:n.missing})),tests:e.tests.map(n=>{let s=r.filter(c=>n.covers.some(l=>c.behaviorIds.includes(l))),i=s.some(c=>c.status==="Fail"),o=s.some(c=>c.status==="Pass"),a=i?"fail":o?"pass":void 0;return{file:n.file,covers:n.covers,result:{exit:a?i?1:0:null,cases:a?n.covers.map(c=>({case:c,status:a})):[]}}})}}var qC=X(require("fs")),Ns=X(require("path"));function Do(e){return e.replace(/[“”„«»]/g,'"').replace(/[‘’]/g,"'").replace(/^[ \t]*(?:[-*+]|\d+[.)]|>+|#{1,6})[ \t]+/gm,"").replace(/`+([^`]*?)`+/g,"$1").replace(/(^|[^\w*])(\*\*|\*|__|_)(?=\S)([^\n]*?\S)\2(?![\w*])/g,"$1$3").replace(/\s+/g," ").trim().toLowerCase()}function kMt(e){let t=e.trim(),r=t.match(/^(["'“”‘’])([\s\S]*)(["'“”‘’])$/);return r?r[2].trim():t}function _0(e,t){let r=Do(kMt(t));return r.length>0&&Do(e).includes(r)}function g5(e,t){return e.some(r=>_0(r.body,t))}function A5(e,t){let r=t.match(/^\s*([\w.-]+\/[\w.-]+#\d+)\s*[:—–-]?\s*([\s\S]+)$/),n=r&&e.find(s=>s.pullRequest?.toLowerCase()===r[1].toLowerCase());return r&&n?{quote:r[2],scope:[n],unknownPrefix:!1}:{quote:t,scope:e,unknownPrefix:!!r}}var P0=(r=>(r.Skyramp="skyramp",r.Llm="llm",r))(P0||{}),Kp=y.string().trim().min(1),BMt=y.object({case:Kp.describe("recommend id this assertion enforces"),evidence:Kp.describe("the exact assertion line from the file that checks that case's observable")}),y5=y.object({kind:y.nativeEnum(EM).describe("seed: data the test creates in the app; runtime_mock: a mock on a Skyramp worker, which other tests reach too; env_override: an env value the app runs with. A stub inside the test's own process, such as a browser page's route, is none of these"),target:Kp.describe("the dependency, endpoint or data it affects"),mechanism:y.nativeEnum(wM).describe("test_code: the test applies and undoes it; skyramp_mocker: a mock the test applies on a Skyramp worker; recipe_override: the mocker cannot reach the dependency (its URL is fixed in the build)"),detail:Kp.describe("what it sets up"),worker:Kp.optional().describe("skyramp_mocker: host:port of the worker the test applies the mock to (default localhost:35142)"),cleanup:Kp.optional().describe("seed: a command that removes the data when the test does not, run as written and without a shell: give real values, not a placeholder such as <id>, single-quote an argument that holds shell syntax, or put the logic in a script in the repository and run that")}),NMt=y.object({file:Kp.describe("staged path under .skyramp/staged/"),source:y.nativeEnum(P0),language:Kp,covers:y.array(y.string()).min(1,"must be a non-empty array of recommend ids").describe("recommend ids this test covers"),assertions:y.array(BMt).min(1,"must be a non-empty array").describe("one per case covered, citing the real line"),context:y.array(y5).optional().describe("what the test sets up against the running app, in order: data it seeds, Skyramp mocks it applies, env overrides; omit when none")}),E5=y.object({schemaVersion:y.literal(1),tests:y.array(NMt),deferredUi:y.array(y.string()).describe("recommend ui ids left for the UI stage (generate) \u2014 [] for generate-ui"),summary:Kp.describe("one paragraph")});var Xp=y.string().trim().min(1),td=72,_Mt=y.object({repository:Xp.optional().describe("owner/repo of the checkout this lint ran in, when the run has several; omit for the working checkout"),tool:y.string(),command:y.string().describe("the exact command you ran, scoped to the changed files"),clean:y.boolean(),fixed:y.array(y.string()).optional().describe("files you fixed"),uncovered:y.array(y.string()).describe("changed/new files this linter's own config does not match (wrong extension, wrong directory) \u2014 so `clean` never examined them, even though CI may still execute them. Empty array, not omitted, when every changed/new file IS covered.")}),Mqr=y.object({schemaVersion:y.literal(1),lint:y.array(_Mt).min(1).describe("one entry per checkout this run wrote tests in, each run from that checkout"),fileConventions:y.object({ok:y.boolean(),notes:y.string().optional()}),ciReadiness:y.object({covered:y.boolean().describe("will the repo's CI run these tests?"),notes:y.string().optional()}),dependencies:y.object({added:y.array(y.object({package:y.string(),manifest:y.string(),repository:Xp.optional().describe("owner/repo of the manifest's checkout; omit for the working checkout"),reason:Xp.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).describe("every package added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own")}),support:y.array(y.object({file:Xp,repository:Xp.optional().describe("owner/repo of the file's checkout; omit for the working checkout")})).optional().describe("the files the tests need besides themselves (helper modules, page objects, fixtures, snapshots), delivered with them"),commit:y.object({message:Xp.refine(e=>e.split(`
306
306
  `)[0].length<=td,{message:`subject line must be <= ${td} chars`})}),pr:y.object({title:Xp.max(td,`must be <= ${td} chars`),body:Xp}),ready:y.boolean().describe("a statement of fact: true only if the tests are fit to commit as they stand"),blockers:y.array(y.string()).describe("what blocks the commit \u2014 required non-empty when ready is false"),summary:Xp.describe("one paragraph")});var ef=X(require("fs")),Uy=X(require("path")),wFe=require("child_process");var hFe=X(require("fs")),MC=X(require("path"));var si="{junit}",eL=(n=>(n.Junit="junit",n.Trx="trx",n.GoTestJson="go-test-json",n))(eL||{}),w5=(t=>(t.Minitest="minitest",t))(w5||{}),fFe=y.string().trim().min(1),FC=y.object({cwd:fFe.describe('repo-relative directory the command starts in ("." for the root)'),argv:y.array(fFe).min(1).describe(`the command as separate arguments, run without a shell; for a junit or trx report an argument or env value holds ${si}, where the report is written (not for Maven or Gradle, whose build writes its own)`),env:y.record(y.string(),y.string()).optional().describe("plain test or reporter settings beyond the repository's CI test job (RAILS_ENV=test, PLAYWRIGHT_JUNIT_OUTPUT_FILE={junit}); never a credential, PATH, or a tool's install path"),report:y.object({format:y.nativeEnum(eL).describe(`junit (JUnit XML to ${si}), trx (to ${si}), or go-test-json (go test -json on the command's output)`),reporter:y.nativeEnum(w5).optional().describe("a reporter Testbot loads for a runner that writes no report: minitest")}).optional().describe("the report the command writes; junit when omitted")}),D0=e=>e.report?.format??"junit",b5=/(?:^|\/)(?:mvnw?|gradlew?)(?:\.cmd)?$/,PMt=e=>D0(e)==="go-test-json"||D0(e)==="junit"&&b5.test(e.argv[0]??""),DMt=new Set(["sh","bash","zsh","dash","ksh","fish","csh","tcsh","env","sudo","doas","eval","exec","xargs","nohup","nice","timeout","time","watch","cmd","cmd.exe","powershell","pwsh"]),OMt=/^(PATH|LD_\w+|DYLD_\w+|NODE_OPTIONS|NODE_PATH|RUBYOPT|RUBYLIB|GEM_HOME|GEM_PATH|PERL5OPT|PERL5LIB|PYTHONSTARTUP|PYTHONPATH|PYTHONHOME|CLASSPATH|JAVA_HOME|JAVA_TOOL_OPTIONS|_JAVA_OPTIONS|JDK_JAVA_OPTIONS|MAVEN_OPTS|GRADLE_OPTS|DOTNET_STARTUP_HOOKS|DOTNET_ROOT|GOROOT|GOFLAGS|BASH_ENV|ENV|GH_TOKEN|(AWS|ANTHROPIC|CLAUDE_CODE|GITHUB|ACTIONS|RUNNER)_\w+)$/i,QMt=4;function S5(e,t,r=[]){let n=[];MC.isAbsolute(t.cwd)?n.push(`starts in ${t.cwd}, which is not repo-relative`):Ks(e,t.cwd)?hFe.statSync(MC.resolve(e,t.cwd),{throwIfNoEntry:!1})?.isDirectory()||n.push(`starts in ${t.cwd}, which is not a directory of the repository`):n.push(`starts in ${t.cwd}, outside the repository`);let s=MC.basename(t.argv[0]??"");DMt.has(s)&&n.push(`runs through ${s} \u2014 give the test runner's own command, without a shell or wrapper (a setting it needs goes in "env")`);for(let[i,o]of Object.entries(t.env??{}))/^[A-Za-z_][A-Za-z0-9_]*$/.test(i)?OMt.test(i)?n.push(`sets ${i} in env \u2014 env holds the tests' own settings, never a search path, a tool's install or Testbot's own configuration`):r.some(a=>a.length>=QMt&&o.includes(a))&&n.push(`sets ${i} to a secret of this run \u2014 a credential is never written into a run`):n.push(`sets env "${i}", which is not a variable name`);return n}function Zp(e,t,r=[]){let n=S5(e,t,r),s=D0(t),i=[...t.argv,...Object.values(t.env??{})].some(o=>o.includes(si));return!i&&!t.report?.reporter&&!PMt(t)&&n.push(`never writes its report to ${si} \u2014 name it in the argument or env setting the runner's ${s==="trx"?"TRX logger":"JUnit reporter"} writes to, or give report.reporter when the runner has none`),s==="go-test-json"&&i&&n.push(`reports go-test-json on its output, so it names no ${si}`),t.report?.reporter&&s!=="junit"&&n.push(`names reporter ${t.report.reporter}, which writes junit, but its format is ${s}`),n}function mFe(e,t){return e.argv.map(r=>r.split(si).join(t))}function gFe(e,t){return Object.fromEntries(Object.entries(e.env??{}).map(([r,n])=>[r,n.split(si).join(t)]))}var LC="a framework other than pytest, jest, vitest and node --test (go test, rails test, mvn, dotnet test), or one the repository's test script runs through another command (ng test, nx test)",UC=`pytest, Jest, Vitest and node --test tests run as the run already knows them, unless the repository's test script runs them through another command (ng test, nx test), which may be the only one that compiles them. A test in any other framework, or one run that way, also gives "run": the repository's own command for only those tests, from the directory the repository runs it in, as separate arguments without a shell. Its "report" says what the runner writes: junit (JUnit XML to ${si} in the reporter's argument or env setting), trx (a TRX file to ${si}, which every dotnet test writes with its built-in logger), or go-test-json (go test -json, read from the command's output). A Maven or Gradle command names no ${si}: its build writes JUnit XML to its own report directory, which the run reads. Use a reporter the repository already has, or one of those; a reporter or converter the command fetches is the version the repository pins, or else its latest release (an older one may not build with the repository's toolchain). For minitest, which writes none, give report.reporter "minitest" and the run fills ${si} itself. A setting the tests or reporter read goes in "env" (RAILS_ENV=test, or PLAYWRIGHT_JUNIT_OUTPUT_FILE=${si} with playwright test --reporter=junit): the run sets it, so never wrap the command in a shell to set one. The run replaces ${si} in argv and env with its report path, executes the command, and reads that report.`;var rd=(s=>(s.ExistingEvidenceSufficient="existing_evidence_sufficient",s.TargetedUnit="targeted_unit",s.RuntimeRequired="runtime_required",s.BlockedPreflight="blocked_preflight",s))(rd||{}),qc=(i=>(i.ExistingEvidence="existing_evidence",i.Unaffected="unaffected",i.ExistingUnit="existing_unit",i.NewUnit="new_unit",i.Runtime="runtime",i))(qc||{}),O0=(r=>(r.Repository="repository",r.Testbot="testbot",r))(O0||{}),C5=(n=>(n.Identified="identified",n.Passed="passed",n.Failed="failed",n))(C5||{}),da=y.string().trim().min(1),MMt=y.string().regex(/^[a-z0-9][a-z0-9-]*$/,"must be a short lowercase slug").describe("short-slug"),AFe="When no native unit tests exercise the change, write no repository evidence. Absence of tests is not evidence: say in the rationale that no tests exist.",FMt=y.object({id:MMt,source:y.nativeEnum(O0),kind:y.nativeEnum(Xh),outcome:y.nativeEnum(C5),summary:da.max(400).describe("one line: what it shows"),tests:y.array(da).optional().describe("source repository: the existing tests, as repo-relative paths, optionally path::test-name"),repository:da.optional().describe("source repository: owner/repo the tests live in, when the run has several checkouts; omit for the working checkout"),command:da.optional().describe("source testbot: the exact command you ran, as you ran it"),run:FC.optional().describe(`source repository, for tests in ${LC}: how the run executes only these tests, all of them in one command, with the repository's own runner writing JUnit XML to {junit}. Name each test (path::test-name): a test is credited to a file only by its name or by a report that names the file`)}),LMt=y.object({behaviorId:da.describe("an id from analyze's behaviors"),mechanism:y.nativeEnum(qc),evidenceIds:y.array(da).default([]).describe("existing_evidence: the ci-<n> or evidence ids that establish it; existing_unit: the evidence id naming the tests to run"),covers:y.string().trim().optional().describe('new_unit / runtime: the missing evidence this obtains, e.g. "the boundary the change moved"; unaffected: why the change cannot reach it, citing path:line')}),v5=(n=>(n.Browser="browser",n.RunningApp="running-app",n.Outside="outside",n))(v5||{}),UMt=y.object({behaviorId:y.string().trim().optional().describe("an id from analyze's behaviors, when it is about one"),missing:da.max(600).describe("the evidence that is required and cannot be obtained in this run"),needs:y.nativeEnum(v5).optional().describe("what that evidence needs: browser (only a real browser shows it), running-app (only the running app or its server shows it: its real requests, sign-in and permissions, what it saves), or outside (something the running app here could not give either: a third-party service it calls, hardware)")}),$Mt=y.object({file:da.describe("the changed file the failure is in"),repository:da.optional().describe("owner/repo the file is in, when the run has several checkouts; omit for the working checkout"),reason:da.max(300).describe("what prerequisite the change fails"),evidence:da.max(400).describe("the error line, quoted")}),qMt=y.object({behaviorId:da.describe("an id from analyze's behaviors"),reason:da.max(600).describe("\u2264600 characters: why this change leaves the behavior's result as it was, citing the unchanged line that decides it (path:line)")}),Q0=y.object({schemaVersion:y.literal(1),decision:y.nativeEnum(rd),evidence:y.array(FMt).describe("evidence this session found or produced; CI results are the ci-<n> items and are not restated here"),plan:y.array(LMt).describe("how each changed behavior's evidence is obtained"),gaps:y.array(UMt),outOfScope:y.array(qMt).optional().describe("behaviors analyze found that this change neither changes nor states"),blocked:$Mt.optional().describe("only for blocked_preflight"),rationale:da.max(1200).describe("\u22641200 characters: why this evidence is enough, or what it still lacks \u2014 the scope you chose and why")}),x5=new Set(["runtime"]),yFe=new Set(["existing_unit","new_unit"]);function Mi(e){let t=fe(e,"recommend.json");if(!t||!Array.isArray(t.generate)||!Array.isArray(t.maintenance))return;let r=t;return{...r,maintenance:r.maintenance.map(({repository:n,...s})=>({...s,test:s.test.trim().replace(/^\.\//,""),...n?.trim()?{repository:n.trim()}:{}}))}}var R5=".skyramp/staged";function jMt(e){return ss(E5,e).errors}function HMt(e,t=[]){let{value:r,error:n}=xn(e,t);if(n)return{errors:[n]};let s=jMt(r);return s.length>0?{errors:s}:{generate:r,errors:[]}}function tL(e,t=[]){return HMt(e.stdout,t)}function zMt(e){return e.generate.filter(t=>t.type!=="ui").map(t=>t.id)}function T5(e){return e.generate.filter(t=>t.type==="ui").map(t=>t.id)}var rL={backend:{stage:"generate",cases:zMt,noRecommendCoverage:"recommend.json missing or malformed \u2014 cannot check coverage",noRecommendIntent:"recommend.json missing or malformed \u2014 cannot check intent",uncovered:e=>`recommend case "${e}" is not covered by any generated test`,unknownCovered:e=>`test covers unknown recommend id "${e}"`,unasserted:e=>`case "${e}" has no verified assertion enforcing its expected_observable`,usedCodegen:MMe,codegenHint:"These tests were hand-written. Skyramp codegen (skyramp_contract_test_generation / skyramp_integration_test_generation) was available but not used \u2014 it computes valid sample data and response correlations. Prefer scaffolding with it and then refining, especially for the failures above."},ui:{stage:"generate-ui",cases:T5,noRecommendCoverage:"recommend.json not found \u2014 cannot check UI coverage",noRecommendIntent:"recommend.json not found \u2014 cannot check UI intent",uncovered:e=>`UI case "${e}" is not covered by any generated UI test`,unknownCovered:e=>`test covers "${e}" which is not a recommend UI case`,unasserted:e=>`UI case "${e}" has no verified assertion enforcing its expected_observable`,usedCodegen:FMe,codegenHint:"This UI test was hand-authored. Skyramp UI codegen (skyramp_ui_test_generation) was available but not used. Prefer scaffolding with it and then refining, especially for the failures above."}},AGr=oo("generate-schema",(e,t)=>tL(t,e.secretValues));function VMt(e){let t=rL[e];return{name:`${t.stage}-coverage`,verify(r,n){let{generate:s,errors:i}=tL(n,r.secretValues);if(!s)return dr(this.name,i);let o=Mi(r);if(!o)return dr(this.name,[t.noRecommendCoverage]);let a=new Set(s.tests.flatMap(d=>d.covers)),c=[],l=t.cases(o);for(let d of l)a.has(d)||c.push(t.uncovered(d));let u=new Set(e==="ui"?l:o.generate.map(d=>d.id));for(let d of a)u.has(d)||c.push(t.unknownCovered(d));if(e==="backend"){let d=new Set(s.deferredUi),p=new Set(T5(o));for(let f of p)!d.has(f)&&!a.has(f)&&c.push(`UI case "${f}" is neither covered nor deferred to the UI stage`);for(let f of d)p.has(f)||c.push(`deferredUi lists "${f}" which is not a UI case`)}return c.length===0?{name:this.name,passed:!0}:dr(this.name,c)}}}function WMt(e){let t=rL[e];return{name:`${t.stage}-intent`,verify(r,n){let{generate:s,errors:i}=tL(n,r.secretValues);if(!s)return dr(this.name,i);let o=Mi(r);if(!o)return dr(this.name,[t.noRecommendIntent]);let{asserted:a,errors:c,badFiles:l}=nFt(s,r.inputs.repositoryPath),u=c.length;for(let p of t.cases(o))a.has(p)||c.push(t.unasserted(p));if(c.length===0)return{name:this.name,passed:!0};let d=dr(this.name,c);return u>0&&u===c.length&&l.size>0?{...d,droppable:[...l]}:d}}}function JMt(e){let t=rL[e];return r=>{if(!r.inputs.skyrampMcp?.command||e==="backend"&&!K6(r))return;let n=Uy.join(r.outputsDir,`${t.stage}-stream.ndjson`);if(!(!ef.existsSync(n)||t.usedCodegen(n)))return LMe(n)?t.codegenHint:"Skyramp codegen tools were configured but the MCP server did not connect this session, so they were not available. Hand-authoring was the only option; this is an environment problem, not yours."}}var yGr=VMt("backend"),EGr=WMt("backend"),wGr=JMt("backend");var EFe=e=>e.replace(/\s+/g,"");function YMt(e){let t=['"""',"'''"],r="",n=0,s=e.length;for(;n<s;){let i=e.slice(n,n+3),o=t.find(l=>l===i);if(o){let l=e.indexOf(o,n+3);n=l===-1?s:l+3;continue}let a=e.slice(n,n+2);if(a==="//"||a==="/*"){let l=a==="//"?e.indexOf(`
307
307
  `,n):e.indexOf("*/",n);n=l===-1?s:a==="//"?l:l+2;continue}let c=e[n];if(c==="#"){let l=e.indexOf(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyramp/testbot-core",
3
- "version": "0.13.0-v3.307",
3
+ "version": "0.13.0-v3.308",
4
4
  "description": "Skyramp Testbot engine: AI-powered deterministic test generation, execution and maintenance",
5
5
  "main": "dist/main.js",
6
6
  "//files": "An explicit allowlist, never a glob. `dist/` is gitignored, so without this key npm's .gitignore fallback would publish a package with no engine in it; with a glob it would publish the sourcemaps, whose sourcesContent embeds every src/*.ts verbatim. dist/VERSION.json exists only in a release-engine.yml build.",