@checksum-ai/runtime 1.1.4 → 1.1.6
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/cli.js +1 -1
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -62,7 +62,7 @@ ${k}${S}${A}${_6.default.cursorHide}`});var Xb=require("async_hooks"),Jb=K(Yb(),
|
|
|
62
62
|
`)]});var ey=K(ws(),1);var US=we((e,t)=>{let{validate:r=s(()=>!0,"validate")}=e,i=de(e.theme),[n,a]=B("pending"),[o,u]=B(),[c,l]=B(""),p=ye({isLoading:n==="loading",theme:i});De(async(w,m)=>{if(n==="pending")if(Ie(w)){let g=c;a("loading");let E=await r(g);E===!0?(l(g),a("done"),t(g)):(m.write(c),u(E||"You must provide a valid value"),a("pending"))}else l(m.line),u(void 0)});let h=i.style.message(e.message),d="",D;e.mask?d=(typeof e.mask=="string"?e.mask:"*").repeat(c.length):n!=="done"&&(D=`${i.style.help("[input is masked]")}${ey.default.cursorHide}`),n==="done"&&(d=i.style.answer(d));let b="";return o&&(b=i.style.error(o)),[[p,h,d,D].filter(Boolean).join(" "),b]});var ty=K(Fi(),1);var ry=K(ws(),1);var qS={icon:{cursor:Zr.pointer},style:{disabled:s(e=>ty.default.dim(`- ${e}`),"disabled")},helpMode:"auto"};function ta(e){return!Ee.isSeparator(e)&&!e.disabled}s(ta,"isSelectable");var We=we((e,t)=>{let{choices:r,loop:i=!0,pageSize:n=7}=e,a=Wt(!0),o=de(qS,e.theme),u=ye({theme:o}),[c,l]=B("pending"),f=Wt(),p=qn(()=>{let v=r.findIndex(ta),F=r.findLastIndex(ta);if(v<0)throw new jr("[select prompt] No selectable choices. All choices are disabled.");return{first:v,last:F}},[r]),h=qn(()=>"default"in e?r.findIndex(v=>ta(v)&&v.value===e.default):-1,[e.default,r]),[d,D]=B(h===-1?p.first:h),b=r[d];De((v,F)=>{if(clearTimeout(f.current),Ie(v))l("done"),t(b.value);else if(zr(v)||Bn(v)){if(F.clearLine(0),i||zr(v)&&d!==p.first||Bn(v)&&d!==p.last){let k=zr(v)?-1:1,C=d;do C=(C+k+r.length)%r.length;while(!ta(r[C]));D(C)}}else if(v0(v)){F.clearLine(0);let k=Number(v.name)-1,C=r[k];C!=null&&ta(C)&&D(k)}else if(m0(v))F.clearLine(0);else{let k=F.line.toLowerCase(),C=r.findIndex(S=>Ee.isSeparator(S)||!ta(S)?!1:String(S.name||S.value).toLowerCase().startsWith(k));C>=0&&D(C),f.current=setTimeout(()=>{F.clearLine(0)},700)}});let w=o.style.message(e.message),m="",g="";(o.helpMode==="always"||o.helpMode==="auto"&&a.current)&&(a.current=!1,r.length>n?g=`
|
|
63
63
|
${o.style.help("(Use arrow keys to reveal more choices)")}`:m=o.style.help("(Use arrow keys)"));let E=ys({items:r,active:d,renderItem({item:v,isActive:F}){if(Ee.isSeparator(v))return` ${v.separator}`;let k=v.name||v.value;if(v.disabled){let A=typeof v.disabled=="string"?v.disabled:"(disabled)";return o.style.disabled(`${k} ${A}`)}let C=F?o.style.highlight:A=>A,S=F?o.icon.cursor:" ";return C(`${S} ${k}`)},pageSize:n,loop:i});if(c==="done"){let v=b.name||String(b.value);return`${u} ${w} ${o.style.answer(v)}`}let y=b.description?`
|
|
64
64
|
${b.description}`:"";return`${[u,w,m].filter(Boolean).join(" ")}
|
|
65
|
-
${E}${y}${g}${ry.default.cursorHide}`});var ad=class ad{constructor(t,r,i){this.webDriver=t;this.pageInteractor=r;this.callbacks=i;this.quitWaitForUserInteractions=!1}async run(t){switch(await We({message:"What next?",choices:[{name:"Record my actions",value:"RecordManualActions"},{name:"Custom code",value:"CustomCode"},{name:"Generate assertions",value:"GenerateAssertions"},{name:"Back",value:"Back"}]})){case"RecordManualActions":await this.listenForUserInteractions(t);break;case"CustomCode":await this.getCustomCode();break;case"GenerateAssertions":await this.callbacks.generateAssertions();break;case"Back":break}}async listenForUserInteractions(t){this.quitWaitForUserInteractions=!1;let r=s(()=>{let n=ee({message:"Waiting for user interaction [press anything to stop]...",default:void 0});return n.finally(()=>{}).then(()=>{this.quitWaitForUserInteractions=!0}).catch(()=>{}),n},"startQuit"),i=r();for(;!this.quitWaitForUserInteractions;)try{let n=await this.webDriver.getTimeMachinePage().evaluate(()=>window.checksum.timeMachine.consumeInteractions());if(n.length){try{i.cancel()}catch{}for(let a of n)t&&a.timestamp<t||await this.vetManualAction(a);i=r()}await W(1e3)}catch(n){console.log("error",n)}}async vetManualAction(t){let{esraMetadata:r,nodeId:i,...n}=t;console.log("Interaction:",n);let a=await ee({message:"Thought [no thought will filter out this interaction]?",default:void 0});a&&(t.description=a,this.callbacks.onActionExecuted(t))}async getCustomCode(){let t=await ee({message:"Provide the body of the function: async (page: Page) => { /* code */ }"});if(!t)return;let r={eventCode:"custom_code",fillValue:t};await this.pageInteractor.performAction(r),await this.vetManualAction(r)}};s(ad,"ManualVisualTestGenerator");var nu=ad;var au=s(async(e,t,r={})=>{var u,c;let i=ee({message:((u=r.makePromptMessage)==null?void 0:u.call(r,t))??`Continuing in ${t} seconds [Press enter to stop]...`},{clearPromptOnDone:!0}),n=!1;i.then(async l=>{n=!0,r.onCancelMessage&&console.log(r.onCancelMessage)}).catch(()=>{});let o=s(async()=>{if(await W(1e3),n)return;i.cancel();let l=t-1;return l===0?(r.onContinueMessage&&console.log(r.onContinueMessage),e()):au(e,l,r)},"timeout")();try{let l=await Promise.race([o,i]);return n?(c=r.cancelCallback)==null?void 0:c.call(r,l):l}catch{return o}},"userInterruptibleDelayedCallback");var sd=class sd{constructor(t,r,i,n,a){this.webDriver=t;this.pageInteractor=r;this.apiBaseURL=i;this.apiKey=n;this.callbacks=a;this.previousActionFailed=!1;this.currentChecksumId="0";this.run=s(async(t=[])=>{this.clear(),this.executedActions=t,await this.startSession(),await this.iterationLoop()},"run");this.iterationLoop=s(async()=>{switch(await this.iterate()){case"continue":return this.runInterruptibleNextAIStep(this.iterationLoop);case"reset":return this.runInterruptibleNextAIStep(()=>this.run(this.callbacks.getExecutedActions()));case"stop":return}},"iterationLoop");this.runInterruptibleNextAIStep=s(async t=>au(t,5,{makePromptMessage:s(i=>`Will continue in ${i} seconds [Press enter to stop]...`,"makePromptMessage"),onContinueMessage:"Continuing with AI...",onCancelMessage:"Stopping AI"}),"runInterruptibleNextAIStep")}async init(){}setStory(t){this.story=t}clear(){this.executedActions=[],this.remoteSessionId=void 0,this.userThoughtForNextLLMStep=void 0,this.previousActionFailed=!1,this.currentChecksumId="0"}async iterate(){let t="continue",{reducedHTML:r,flashingHTML:i,elementsForNodeInterpretation:n,currentChecksumId:a}=await this.webDriver.evaluateWithChecksum(async({appRules:u,currentChecksumId:c})=>window.checksum.testGenerator.reduceHTML(u,{stopFlashingElementsDetection:!0,assignChecksumIdsToAllElements:!0,initialChecksumId:c}),{appRules:{appSpecificInteractableElementsSelectors:[]},currentChecksumId:this.currentChecksumId});this.currentChecksumId=a;let o=await this.getNextAction({reducedHTML:r,flashingHTML:i,elementsForNodeInterpretation:n});if(this.isFailureAction(o))return await this.getUserThoughtForNextLLMStep(),"continue";try{let u=await this.pageInteractor.translateActionResponseToAgentPotentialAction(o),c=await this.approveAction(u);switch(await this.webDriver.clearHighlights(),c){case"ProvideGuidance":return await this.getUserThoughtForNextLLMStep(),this.iterate();case"ChangeValue":u.fillValue=await this.getValueReplacementFromUser(),t="reset";break;case"Finish":return this.callbacks.onSuccess(),this.callbacks.stop(),"stop";case"Abort":return this.callbacks.stop(),"stop"}if(this.userThoughtForNextLLMStep=void 0,this.previousActionFailed=!1,this.isFinishAction(o))return this.callbacks.onSuccess(),this.callbacks.stop(),"stop";try{let l=new In(this.webDriver.page);l.startListening(),u.timestamp=Date.now(),await this.pageInteractor.performAction(u),await l.wait(),await W(2e3),this.callbacks.onActionExecuted(u)}catch(l){this.previousActionFailed=!0,console.error(l)}}catch(u){this.previousActionFailed=!0,console.error(u)}return t}async startSession({retriesLeft:t=3}={}){let r={type:"test-generation",storyTitle:this.story.goal,storyInstructions:this.story.instructions,testId:void 0,testSuiteId:void 0,thoughtsAndActions:{previous:this.executedActions.filter(i=>!!i.description).map(i=>({thought:i.description,action:void 0}))}};try{let i=await fetch(`${this.apiBaseURL}/ai-fallback/init`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.apiKey},body:JSON.stringify({data:r})});this.remoteSessionId=await i.text()}catch(i){if(console.error(i),await W(2e3),t>0)return this.startSession({retriesLeft:t-1});throw i}}async approveAction(t){var a;await this.webDriver.highlightElementByLocator(this.pageInteractor.makeLocator(t.selector,t.parentFramesSelectors),t.clickOffset,"10px solid rgba(255,0,0,1)");let r=`${t.description}${(a=t.fillValue)!=null&&a.length?` with "${t.fillValue}"`:""}`;return au(async()=>"Proceed",5,{makePromptMessage:s(o=>`Will approve action ${r} in ${o} seconds [Press enter to stop]...`,"makePromptMessage"),onContinueMessage:"Continuing with AI...",cancelCallback:s(async()=>await We({message:`Proceed with action: "${r}"?`,choices:[{name:"Yes",value:"Proceed"},{name:"Yes, but use a different value",value:"ChangeValue"},{name:"No, I will provide guidance",value:"ProvideGuidance"},{name:"Abort (no test code will be generated)",value:"Abort"},{name:"Finish",value:"Finish"}]}),"getApproval")})}async getUserThoughtForNextLLMStep(){this.userThoughtForNextLLMStep=await ee({message:"What should be done next?"})}async getValueReplacementFromUser(){return ee({message:"What value should be used?"})}async getNextAction({reducedHTML:t,flashingHTML:r,elementsForNodeInterpretation:i}){let n={reduction:{reducedHTML:t,flashingHTML:r,elementsForNodeInterpretation:i},currentURL:this.webDriver.page.url(),previousActionOverview:{success:!this.previousActionFailed,userCorrection:this.userThoughtForNextLLMStep}};try{return await(await fetch(`${this.apiBaseURL}/ai-fallback/iterate`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.apiKey},body:JSON.stringify({sessionId:this.remoteSessionId,iterationData:n})})).json()}catch(a){throw console.error(a),a}}isFailureAction(t){var r;return["failed","fail"].includes(t.thought)||["failed","fail"].includes((r=t.action)==null?void 0:r.type)}isFinishAction(t){var r;return t.thought==="finish"||((r=t.action)==null?void 0:r.type)==="finish"}};s(sd,"AIVisualTestGenerator");var su=sd;var zS=250,od=class od{constructor(t){this.webDriver=t;this.numberOfReceivedRrwebEventsIndex=0;this.syncTimeMachine=s(async()=>{try{let t;try{t=await this.webDriver.getRRwebEvents(this.numberOfReceivedRrwebEventsIndex)}catch{return}if(!t||t.length===0)return;try{await this.webDriver.getTimeMachinePage().evaluate(({events:r,len:i})=>window.checksum.timeMachine.handleEvents(r,i),{events:t,len:this.numberOfReceivedRrwebEventsIndex})}catch{return}this.numberOfReceivedRrwebEventsIndex+=t.length}finally{this.syncTimeout=setTimeout(this.syncTimeMachine,zS)}},"syncTimeMachine")}async start(t=!1){await this.initTimeMachine(t),this.syncTimeMachine()}async stop(){clearTimeout(this.syncTimeout)}async disableEventsHandling(){await this.setShouldHandleEvents(!1)}async enableEventsHandling(){await this.setShouldHandleEvents(!0)}async setShouldHandleEvents(t){try{await this.webDriver.getTimeMachinePage().evaluate(r=>window.checksum.timeMachine.setShouldHandleEvents(r),t)}catch{}}async initTimeMachine(t=!1){await this.webDriver.getTimeMachinePage().evaluate(({type:r,shouldHandleEvents:i})=>{window.checksum.timeMachine.init(r,i)},{type:"VisualTestGenerationConsumer",shouldHandleEvents:t})}};s(od,"TimeMachineSync");var ou=od;var He=require("fs"),uu=K(require("child_process")),Ft=require("path");var ud=class ud{constructor(t,r=!1){this.args=t;this.debugMode=r;this.checksumApiUrl="https://api.checksum.ai";this.checksumAppUrl="https://app.checksum.ai";this.printError=s(t=>{console.log("\x1B[31m%s\x1B[0m",t)},"printError")}async execCmd(t,r={}){let i={...process.env,...r},n=await uu.spawn(t,{env:i,shell:!0,stdio:"inherit"});return new Promise((o,u)=>{n.on("exit",c=>{c===0?o(!0):u(new Error(`Checksum failed execution with code: ${c} `))})})}async getCmdOutput(t){return new Promise(function(r,i){uu.exec(t,(n,a,o)=>{if(n){i(`Error executing command: ${n.message}`);return}r(a)})})}loadChecksumData(){this.locateChecksumLibs(),this.processChecksumArguments(),this.setChecksumConfig()}async patchPlaywright(t=!1){fe("Patching playwright",t);let r=`node ${(0,Ft.join)(__dirname,"scripts/patch.js")}${t?" off":""}`;try{await this.execCmd(r,{PROJECT_ROOT:this.projectRootDirectory,RUNTIME:"true"})}catch(i){console.log("Error patching playwright",i.message)}}getPlaywrightConfigFilePath(){return(0,Ft.join)(this.checksumRoot,"playwright.config.ts")}buildVolatileConfig(){if(!this.volatileChecksumConfig)return;let t=this.getVolatileConfigPath(),r=`
|
|
65
|
+
${E}${y}${g}${ry.default.cursorHide}`});var ad=class ad{constructor(t,r,i){this.webDriver=t;this.pageInteractor=r;this.callbacks=i;this.quitWaitForUserInteractions=!1}async run(t){switch(await We({message:"What next?",choices:[{name:"Record my actions",value:"RecordManualActions"},{name:"Custom code",value:"CustomCode"},{name:"Generate assertions",value:"GenerateAssertions"},{name:"Back",value:"Back"}]})){case"RecordManualActions":await this.listenForUserInteractions(t);break;case"CustomCode":await this.getCustomCode();break;case"GenerateAssertions":await this.callbacks.generateAssertions();break;case"Back":break}}async listenForUserInteractions(t){this.quitWaitForUserInteractions=!1;let r=s(()=>{let n=ee({message:"Waiting for user interaction [press anything to stop]...",default:void 0});return n.finally(()=>{}).then(()=>{this.quitWaitForUserInteractions=!0}).catch(()=>{}),n},"startQuit"),i=r();for(;!this.quitWaitForUserInteractions;)try{let n=await this.webDriver.getTimeMachinePage().evaluate(()=>window.checksum.timeMachine.consumeInteractions());if(n.length){try{i.cancel()}catch{}for(let a of n)t&&a.timestamp<t||await this.vetManualAction(a);i=r()}await W(1e3)}catch(n){console.log("error",n)}}async vetManualAction(t){let{esraMetadata:r,nodeId:i,...n}=t;console.log("Interaction:",n);let a=await ee({message:"Thought [no thought will filter out this interaction]?",default:void 0});a&&(t.description=a,this.callbacks.onActionExecuted(t))}async getCustomCode(){let t=await ee({message:"Provide the body of the function: async (page: Page) => { /* code */ }"});if(!t)return;let r={eventCode:"custom_code",fillValue:t};await this.pageInteractor.performAction(r),await this.vetManualAction(r)}};s(ad,"ManualVisualTestGenerator");var nu=ad;var au=s(async(e,t,r={})=>{var u,c;let i=ee({message:((u=r.makePromptMessage)==null?void 0:u.call(r,t))??`Continuing in ${t} seconds [Press enter to stop]...`},{clearPromptOnDone:!0}),n=!1;i.then(async l=>{n=!0,r.onCancelMessage&&console.log(r.onCancelMessage)}).catch(()=>{});let o=s(async()=>{if(await W(1e3),n)return;i.cancel();let l=t-1;return l===0?(r.onContinueMessage&&console.log(r.onContinueMessage),e()):au(e,l,r)},"timeout")();try{let l=await Promise.race([o,i]);return n?(c=r.cancelCallback)==null?void 0:c.call(r,l):l}catch{return o}},"userInterruptibleDelayedCallback");var sd=class sd{constructor(t,r,i,n,a){this.webDriver=t;this.pageInteractor=r;this.apiBaseURL=i;this.apiKey=n;this.callbacks=a;this.previousActionFailed=!1;this.currentChecksumId="0";this.run=s(async(t=[])=>{this.clear(),this.executedActions=t,await this.startSession(),await this.iterationLoop()},"run");this.iterationLoop=s(async()=>{switch(await this.iterate()){case"continue":return this.runInterruptibleNextAIStep(this.iterationLoop);case"reset":return this.runInterruptibleNextAIStep(()=>this.run(this.callbacks.getExecutedActions()));case"stop":return}},"iterationLoop");this.runInterruptibleNextAIStep=s(async t=>au(t,5,{makePromptMessage:s(i=>`Will continue in ${i} seconds [Press enter to stop]...`,"makePromptMessage"),onContinueMessage:"Continuing with AI...",onCancelMessage:"Stopping AI"}),"runInterruptibleNextAIStep")}async init(){}setStory(t){this.story=t}clear(){this.executedActions=[],this.remoteSessionId=void 0,this.userThoughtForNextLLMStep=void 0,this.previousActionFailed=!1,this.currentChecksumId="0"}async iterate(){let t="continue",{reducedHTML:r,flashingHTML:i,elementsForNodeInterpretation:n,currentChecksumId:a}=await this.webDriver.evaluateWithChecksum(async({appRules:u,currentChecksumId:c})=>window.checksum.testGenerator.reduceHTML(u,{stopFlashingElementsDetection:!0,assignChecksumIdsToAllElements:!0,initialChecksumId:c}),{appRules:{appSpecificInteractableElementsSelectors:[]},currentChecksumId:this.currentChecksumId});this.currentChecksumId=a;let o=await this.getNextAction({reducedHTML:r,flashingHTML:i,elementsForNodeInterpretation:n});if(this.isFailureAction(o))return await this.getUserThoughtForNextLLMStep(),"continue";try{let u=await this.pageInteractor.translateActionResponseToAgentPotentialAction(o),c=await this.approveAction(u);switch(await this.webDriver.clearHighlights(),c){case"ProvideGuidance":return await this.getUserThoughtForNextLLMStep(),this.iterate();case"ChangeValue":u.fillValue=await this.getValueReplacementFromUser(),t="reset";break;case"Finish":return this.callbacks.onSuccess(),this.callbacks.stop(),"stop";case"Abort":return this.callbacks.stop(),"stop"}if(this.userThoughtForNextLLMStep=void 0,this.previousActionFailed=!1,this.isFinishAction(o))return this.callbacks.onSuccess(),this.callbacks.stop(),"stop";try{let l=new In(this.webDriver.page);l.startListening(),u.timestamp=Date.now(),await this.pageInteractor.performAction(u),await l.wait(),await W(2e3),this.callbacks.onActionExecuted(u)}catch(l){this.previousActionFailed=!0,console.error(l)}}catch(u){this.previousActionFailed=!0,console.error(u)}return t}async startSession({retriesLeft:t=3}={}){let r={type:"test-generation",storyTitle:this.story.goal,storyInstructions:this.story.instructions,testId:void 0,testSuiteId:void 0,thoughtsAndActions:{previous:this.executedActions.filter(i=>!!i.description).map(i=>({thought:i.description,action:void 0}))}};try{let i=await fetch(`${this.apiBaseURL}/ai-fallback/init`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.apiKey},body:JSON.stringify({data:r})});this.remoteSessionId=await i.text()}catch(i){if(console.error(i),await W(2e3),t>0)return this.startSession({retriesLeft:t-1});throw i}}async approveAction(t){var a;await this.webDriver.highlightElementByLocator(this.pageInteractor.makeLocator(t.selector,t.parentFramesSelectors),t.clickOffset,"10px solid rgba(255,0,0,1)");let r=`${t.description}${(a=t.fillValue)!=null&&a.length?` with "${t.fillValue}"`:""}`;return au(async()=>"Proceed",5,{makePromptMessage:s(o=>`Will approve action ${r} in ${o} seconds [Press enter to stop]...`,"makePromptMessage"),onContinueMessage:"Continuing with AI...",cancelCallback:s(async()=>await We({message:`Proceed with action: "${r}"?`,choices:[{name:"Yes",value:"Proceed"},{name:"Yes, but use a different value",value:"ChangeValue"},{name:"No, I will provide guidance",value:"ProvideGuidance"},{name:"Abort (no test code will be generated)",value:"Abort"},{name:"Finish",value:"Finish"}]}),"getApproval")})}async getUserThoughtForNextLLMStep(){this.userThoughtForNextLLMStep=await ee({message:"What should be done next?"})}async getValueReplacementFromUser(){return ee({message:"What value should be used?"})}async getNextAction({reducedHTML:t,flashingHTML:r,elementsForNodeInterpretation:i}){let n={reduction:{reducedHTML:t,flashingHTML:r,elementsForNodeInterpretation:i},currentURL:this.webDriver.page.url(),previousActionOverview:{success:!this.previousActionFailed,userCorrection:this.userThoughtForNextLLMStep}};try{return await(await fetch(`${this.apiBaseURL}/ai-fallback/iterate`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.apiKey},body:JSON.stringify({sessionId:this.remoteSessionId,iterationData:n})})).json()}catch(a){throw console.error(a),a}}isFailureAction(t){var r;return["failed","fail"].includes(t.thought)||["failed","fail"].includes((r=t.action)==null?void 0:r.type)}isFinishAction(t){var r;return t.thought==="finish"||((r=t.action)==null?void 0:r.type)==="finish"}};s(sd,"AIVisualTestGenerator");var su=sd;var zS=250,od=class od{constructor(t){this.webDriver=t;this.numberOfReceivedRrwebEventsIndex=0;this.syncTimeMachine=s(async()=>{try{let t;try{t=await this.webDriver.getRRwebEvents(this.numberOfReceivedRrwebEventsIndex)}catch{return}if(!t||t.length===0)return;try{await this.webDriver.getTimeMachinePage().evaluate(({events:r,len:i})=>window.checksum.timeMachine.handleEvents(r,i),{events:t,len:this.numberOfReceivedRrwebEventsIndex})}catch{return}this.numberOfReceivedRrwebEventsIndex+=t.length}finally{this.syncTimeout=setTimeout(this.syncTimeMachine,zS)}},"syncTimeMachine")}async start(t=!1){await this.initTimeMachine(t),this.syncTimeMachine()}async stop(){clearTimeout(this.syncTimeout)}async disableEventsHandling(){await this.setShouldHandleEvents(!1)}async enableEventsHandling(){await this.setShouldHandleEvents(!0)}async setShouldHandleEvents(t){try{await this.webDriver.getTimeMachinePage().evaluate(r=>window.checksum.timeMachine.setShouldHandleEvents(r),t)}catch{}}async initTimeMachine(t=!1){await this.webDriver.getTimeMachinePage().evaluate(({type:r,shouldHandleEvents:i})=>{window.checksum.timeMachine.init(r,i)},{type:"VisualTestGenerationConsumer",shouldHandleEvents:t})}};s(od,"TimeMachineSync");var ou=od;var He=require("fs"),uu=K(require("child_process")),Ft=require("path");var ud=class ud{constructor(t,r=!1){this.args=t;this.debugMode=r;this.checksumApiUrl="https://api.checksum.ai";this.checksumAppUrl="https://app.checksum.ai";this.printError=s(t=>{console.log("\x1B[31m%s\x1B[0m",t)},"printError")}async execCmd(t,r={}){let i={...process.env,...r},n=await uu.spawn(t,{env:i,shell:!0,stdio:"inherit"});return new Promise((o,u)=>{n.on("exit",c=>{c===0?o(!0):u(new Error(`Checksum failed execution with code: ${c} `))})})}async getCmdOutput(t){return new Promise(function(r,i){uu.exec(t,(n,a,o)=>{if(n){i(`Error executing command: ${n.message}`);return}r(a)})})}loadChecksumData(){this.locateChecksumLibs(),this.processChecksumArguments(),this.setChecksumConfig()}async patchPlaywright(t=!1){fe("Patching playwright",t);let r=`node "${(0,Ft.join)(__dirname,"scripts/patch.js")}"${t?" off":""}`;try{await this.execCmd(r,{PROJECT_ROOT:this.projectRootDirectory,RUNTIME:"true"})}catch(i){console.log("Error patching playwright",i.message)}}getPlaywrightConfigFilePath(){return(0,Ft.join)(this.checksumRoot,"playwright.config.ts")}buildVolatileConfig(){if(!this.volatileChecksumConfig)return;let t=this.getVolatileConfigPath(),r=`
|
|
66
66
|
import { RunMode, getChecksumConfig } from "@checksum-ai/runtime";
|
|
67
67
|
|
|
68
68
|
export default getChecksumConfig(${JSON.stringify(this.config,null,2)});
|