@checksum-ai/runtime 1.1.25 → 1.1.26

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.
Files changed (2) hide show
  1. package/index.js +1 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -324,7 +324,7 @@ ${p}`,s(_,p))return u}return u}addESRA(t,s){if(!this.esraMetadataMap)return"";if
324
324
  \\s]*,\\s*({[\\s\\S]*?}))?[\r
325
325
  \\s]*\\)`)}}};r(dD,"CodeMirror");var EC=dD;var B4=class B4{constructor(t,s){this.config=t;this.workerInfo=s;this.hasMonitor=!1;this.monitorAgentHost="http://localhost",this.monitorAgentPort=process.env.CHECKSUM_UPLOAD_AGENT_PORT,this.monitorAgentPort?this.hasMonitor=!0:vc("CHECKSUM_UPLOAD_AGENT_PORT is not defined"),this.sendPlaywrightConfig()}addAsset(t){this.signalUpload(t,["trace","har"].includes(t.type))}addTestInfo(t,s){this.sendMessage({type:"testInfo",payload:{checksumTestId:t,pwTestId:s}})}addSingleTestStats(t,s){this.sendMessage({type:"testStats",payload:{passed:t,healed:s}})}sendPlaywrightConfig(){this.sendMessage({type:"playwrightConfig",payload:{reporter:this.workerInfo.config.reporter}})}sendMessage(t){if(this.hasMonitor)return fetch(`${this.monitorAgentHost}:${this.monitorAgentPort}`,{method:"POST",body:JSON.stringify(t)}).catch(s=>{vc("Failed to send message to test run monitor",t,s)})}signalUpload(t,s=!1){return this.sendMessage({type:"asset",payload:t,watch:s})}};r(B4,"TestRunMonitorBridge");var kC=B4;var bQ=r(()=>{let t=new Error().stack.split(`
326
326
  `).find(s=>s.includes(".checksum.spec.ts"));if(t)return{lineNumber:parseInt(t.split(":")[1]),columnNumber:parseInt(t.split(":")[2])}},"findCodeLocationFromStackTrace"),J4=class J4{constructor(){this.store={};this.activeVariablesSet=new Set;return new Proxy(this,this)}clearAll(){for(let t in this.store)this.store.hasOwnProperty(t)&&delete this.store[t];this.activeVariablesSet.clear()}getActiveVariables(){let t={};for(let s of this.activeVariablesSet)t[s]=this.store[s];return t}getActiveVariablesString(){return Object.entries(this.getActiveVariables()).map(([t,s])=>`const ${t} = "${s.value}";`).join(`
327
- `)}setVariable(t,s){this.store[t]={value:s}}set(t,s,u){if(typeof s!="string")return!1;let p=bQ();return t.store[s]={value:u,...p,line:""},!0}get(t,s){var u;if(s in t)return t[s];if(!(s in t.store))throw new Error(`Variable ${s} is not defined`);return t.activeVariablesSet.add(s),(u=t.store[s])==null?void 0:u.value}};r(J4,"VariablesStore");var AC=J4;var j4={},ZF=r((e,t,s={},u=!1)=>{let{baseURL:p,runMode:_,apiKey:S,apiURL:L}=t,w=e.extend({codeMirror:[async({},m)=>{let h=await EC.init(_,{generateAssertionCode:r(()=>"","generateAssertionCode")});await m(h)},{scope:"worker"}],monitorBridge:[async({},m,h)=>{let se=new kC(t,h);await m(se)},{scope:"worker"}],variablesStore:r(async({},m)=>{let h=new AC;await m(h)},"variablesStore"),page:r(async({page:m,codeMirror:h,monitorBridge:se,variablesStore:ae},Z,ie)=>{let oe=await yC.init(m,h,se,ae,ie,SQ(ie),w,t,u);Object.defineProperty(oe.constructor,"name",{value:"Page"}),await Z(oe),await oe.onTestComplete(ie.status==="passed")},"page")});return w.use({launchOptions:{args:["--remote-debugging-port=9222",...s!=null&&s.useMockData?["--disable-web-security"]:[]]},baseURL:p,bypassCSP:!0}),{test:w,defineChecksumTest:DQ}},"createChecksumTestExtension"),DQ=r((e,t)=>{let u=new Error().stack.split(`
327
+ `)}setVariable(t,s){this.store[t]={value:s}}set(t,s,u){if(typeof s!="string")return!1;let p=bQ();return t.store[s]={value:u,...p,line:""},!0}get(t,s){var u;if(s in t)return t[s];if(!(s in t.store))throw new Error(`Variable ${s} is not defined`);return t.activeVariablesSet.add(s),(u=t.store[s])==null?void 0:u.value}};r(J4,"VariablesStore");var AC=J4;var j4={},ZF=r((e,t,s={},u=!1)=>{let{baseURL:p,runMode:_,apiKey:S,apiURL:L}=t,w=e.extend({codeMirror:[async({},m)=>{let h=await EC.init(_,{generateAssertionCode:r(()=>"","generateAssertionCode")});await m(h)},{scope:"worker"}],monitorBridge:[async({},m,h)=>{let se=new kC(t,h);await m(se)},{scope:"worker"}],variablesStore:r(async({},m)=>{let h=new AC;await m(h)},"variablesStore"),page:r(async({page:m,codeMirror:h,monitorBridge:se,variablesStore:ae},Z,ie)=>{let oe=await yC.init(m,h,se,ae,ie,SQ(ie),w,t,u);Object.defineProperty(oe.constructor,"name",{value:"Page"}),await Z(oe),await oe.onTestComplete(ie.status==="passed")},"page")});return w.use({launchOptions:{args:[...s!=null&&s.useMockData?["--disable-web-security"]:[]]},baseURL:p,bypassCSP:!0}),{test:w,defineChecksumTest:DQ}},"createChecksumTestExtension"),DQ=r((e,t)=>{let u=new Error().stack.split(`
328
328
  `).filter(p=>p.includes(".checksum.spec.ts"))[0];if(!u)throw new Error("Could not locate test location. Make sure test is run from valid checksum test file");return j4[u]=t,e},"defineChecksumTest");function SQ(e){let{file:t,line:s}=e,u=Object.keys(j4).filter(_=>_.trim().includes(t.trim()));if(!u.length)return;let p=4;for(let _=0;_<p;_++)for(let S of u){let L;try{L=parseInt(S.split(":").reverse()[1])}catch{continue}if(L-_===parseInt(s))return j4[S]}}r(SQ,"getCurrentTestIdFromMapping");var U4=class U4{constructor(t,s,u=!1,p={}){this.page=t;this.soft=u;this.configuration=p;this.fallbackEnabled=!1;this.withChecksumAI=!1;this.withChecksumAIMatcher=r(async()=>{throw this.withChecksumAI=!0,new Error},"withChecksumAIMatcher");this.setThought(s)}setThought(t){var s,u;t&&(this.checksumAIThought=this.page.addNewThought(t,"assertion"),(u=(s=this.page.getRuntimeOptions())==null?void 0:s.useChecksumAI)!=null&&u.assertions&&(this.page.setAIFallback(t),this.fallbackEnabled=!0))}get(t,s,u){if(typeof s!="string")return t[s];if(s==="checksumAI")return p=>(this.setThought(p),u);if(s==="withChecksumAI"||typeof t[s]=="function"){let p=s==="withChecksumAI"?this.withChecksumAIMatcher:t[s];return(..._)=>this.checksumAIThought?this.executeMatcherWithinStep(p,t,..._):this.executeMatcher(p,t,..._)}else{let p=t[s];return new Proxy(p,this)}}findNestedErrors(t,s){t.error&&t.infectParentStepsWithError&&s.push(t.error);for(let u of t.steps)this.findNestedErrors(u,s)}async callMatcher(t,s,...u){this.beforeMatcherCall();let p=t.call(s,...u),_=p instanceof Promise?await p:p;if(this.step){let S=[];if(this.step.error?S.push(this.step.error):this.findNestedErrors(this.step,S),S.length)throw S[0]}return _}executeMatcherWithinStep(t,s,...u){return this.page.step(this.checksumAIThought.thought,()=>this.callMatcher(t,s,...u).catch(this.onMatcherFailure.bind(this)),!1,{obtainStep:r(p=>this.step=p,"obtainStep")}).catch(p=>{if(!this.soft&&!(this.withChecksumAI&&p.message===hh))throw p}).finally(this.afterMatcherExecute.bind(this))}async executeMatcher(t,s,...u){try{return await this.callMatcher(t,s,...u)}catch(p){await this.onMatcherFailure(p)}finally{this.afterMatcherExecute()}}beforeMatcherCall(){this.page.setExpectConfiguration(this.configuration)}afterMatcherExecute(){this.checksumAIThought=void 0,this.fallbackEnabled=!1,this.withChecksumAI=!1,this.page.resetFallbacks(),this.page.setExpectConfiguration(void 0)}async onMatcherFailure(t){if(!this.fallbackEnabled)throw vc("[onMatcherFailure] fallback disabled, continuing with error."),t;vc("[onMatcherFailure] initiating fallback sequence with thought:",this.checksumAIThought.thought);try{await this.page.initiateFallbackSequence({type:"assertion",error:t,withChecksumAI:this.withChecksumAI})}catch(s){if(this.soft)return;throw s}throw this.soft=!0,this.page.testInfo.status="failed",t}};r(U4,"ExpectCallProxyHandler");var wC=U4;var PC=class PC{constructor(t=void 0,s={}){this.page=t;this.configuration=s}get(t,s){return s==="setPage"?u=>{this.page=u}:s==="extend"?(...u)=>{let p=t.extend(...u);return new Proxy(p,this)}:s==="configure"?u=>{let p=t.configure(u);return new Proxy(p,new PC(this.page,{...this.configuration,...u}))}:s==="soft"?(...u)=>{let p=this.manipulateArgsAndExtractThought(u),_=t.soft(...u);return new Proxy(_,this.makeExpectCallProxyHandler(p,!0))}:s==="poll"?(...u)=>{let p=this.manipulateArgsAndExtractThought(u),_=t.poll(...u);return new Proxy(_,this.makeExpectCallProxyHandler(p))}:t[s]instanceof Function?t[s].bind(t):t[s]}apply(t,s,u){let p=this.manipulateArgsAndExtractThought(u),_=t.apply(s,u);return new Proxy(_,this.makeExpectCallProxyHandler(p))}makeExpectCallProxyHandler(t,s){var u;return new wC(this.page,t,s===!0?!0:(u=this.configuration)==null?void 0:u.soft,this.configuration)}manipulateArgsAndExtractThought(t){let s,u=t[1];if(typeof u=="string")s=u,t[1]=void 0;else if(typeof u=="object"){if(u.checksumAI===!1){t[1].checksumAI=void 0;return}u.checksumAI&&typeof u.checksumAI=="string"?(s=u.checksumAI,t[1].checksumAI=void 0):u.message&&(s=u.message,t[1].message=void 0)}return s}};r(PC,"ExpectProxyHandler");var NC=PC;var OC=class OC{constructor(t){this.expect=t;this.proxy=new Proxy(this.expect,new NC)}static init(t){return new OC(t).proxy}};r(OC,"ChecksumExpect");var IC=OC;var YF=require("@playwright/test");function xQ(e){let t=qI(),{baseURL:s,options:u,apiKey:p}=t;if(!s)throw new Error("A default baseURL is required - please set it in the config file");if(!p)throw new Error("apiKey is required - please set it in the config file - checksum.config.ts");let _=process.env.CHECKSUM_REPL==="true",{test:S,defineChecksumTest:L}=ZF(e??YF.test,t,u,_),w=IC.init(S.expect),m=CQ();S._checksum={expect:w,checksumAI:m},_&&(console.log("Detected REPL mode"),S.beforeEach(async()=>{S.setTimeout(0)}),S.afterEach(async()=>{for(;;)await Lp(1e3)}));let h=r(({name:se,userRole:ae})=>{let{environment:Z,user:ie}=$k(t,{environment:se,role:ae},!0),oe=VI(t,{environment:Z,user:ie});return{environment:Z,user:ie,login:oe}},"getEnvironment");return{test:S,expect:w,login:a1({config:t}),defineChecksumTest:L,getEnvironment:h,checksumAI:m}}r(xQ,"init");var CQ=r(()=>{let e=r(function(){},"func");return e.page=void 0,new Proxy(e,{apply:r(function(s,u,p){return s.page.checksumAI(p[0],p[1])},"apply"),set:r(function(s,u,p){if(u==="page")return s[u]=p},"set")})},"makeChecksumAI");0&&(module.exports={RunMode,getChecksumConfig,getLogin,init});
329
329
  /*! Bundled license information:
330
330
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checksum-ai/runtime",
3
- "version": "1.1.25",
3
+ "version": "1.1.26",
4
4
  "description": "Checksum.ai test runtime",
5
5
  "main": "index.js",
6
6
  "dependencies": {