@testim/testim-cli 4.29.0 → 4.30.0
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/cli.js.map +2 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -404,7 +404,7 @@ Please make sure the CLI has stable access to the internet. ${Ga()?"(Internal: n
|
|
|
404
404
|
`;return this.driver.executeJS(n,t.locatedElement)}async safariPreUploadActions(t){let r={width:"150px",height:"150px",left:"10px",top:"10px"};try{return await this.forceInputToBeVisible(t,r)}catch(n){throw Gi.error("failed to set input file in Safari recovery",{err:n}),n}}async uploadFilesAndForceVisibility(t,r){try{this.driver.isSafari()&&await this.safariPreUploadActions(r),await this.uploadFiles(t,r)}catch(n){let o="The element is not editable",i="The element is not focusable",a="An element command could not be completed because the element is not visible on the page.",c="element not interactable",l="element is not pointer- or keyboard interactable",d="invalid element state: Element is not currently interactable and may not be manipulated",m="Element must not be hidden, disabled or read-only",p="is not reachable by keyboard",g=n?n.message:"";if(g===d||g.startsWith(m)||g.startsWith(o)||g.startsWith(i)||g.startsWith(a)||g.includes(p)||g.includes(c)||g.includes(l)){await this.forceInputToBeVisible(r),await this.uploadFiles(t,r);return}throw Gi.error("failed to set input file",{err:n}),n}}async uploadFiles(t,r){for(let n of t)await this.driver.elementIdValue(Oe(r.seleniumElement),n)}async performAction(){let t=this.getTarget(),r=U.flags.overrideAzureStorageUrl.isEnabled(),n=U.flags.useJsInputCodeInSafari.isEnabled(),o=U.flags.useJsInputCodeInFirefox.isEnabled(),i=U.flags.downloadToBase64.isEnabled(),{sessionPlayerInit:a,context:c,step:l,stepActionUtils:d,driver:m}=this,p=await a.utils.addTokenToFileUrl(c.project.id,l.fileUrls,d.testimServicesApi,r,Gi),g=m.isSafari()&&(n||p.length>1),f=m.isFirefox()&&(o||p.length>1);if(i&&(p=await Promise.all(p.map(async({name:y,url:v})=>{let S=await _t(v);return{name:y,url:`data:${S.type};base64,${Buffer.from(S.body).toString("base64")}`}}))),g||f){await this.driver.executeJS(`
|
|
405
405
|
const getLocatedElement = ${this.sessionPlayerInit.codeSnippets.getLocatedElementCode};
|
|
406
406
|
const downloadAndUploadFile = ${tS()};
|
|
407
|
-
return downloadAndUploadFile.apply(null, arguments);`,t.locatedElement,p);return}let h=await Jh(p,this.uploadFile);await this.uploadFilesAndForceVisibility(h,t)}}});var Hi,qi,Qh=T(()=>{"use strict";Hi=require("url");ue();qi=class extends W{async updateBaseUrl(e){let t=new Hi.URL(e),r=new Hi.URL(this.context.recordedBaseUrl),n=new Hi.URL(this.context.baseUrl);return t.host===r.host&&r.host!==n.host&&(t.host=n.host),t.href}async performAction(){let e=this.context.data.testimNavigationStepDestination||this.context.data.url;if(this.step.openInNewTab){await this.driver.client.newWindow(e);return}let t=await this.updateBaseUrl(e);await this.driver.url(t)}}});var zi,Zh=T(()=>{"use strict";ue();j();zi=class extends W{async performAction(){await oe(this.step.durationMS||0)}}});var Ki,ey=T(()=>{"use strict";ue();Ki=class extends W{async execute(){try{return await this.driver.reloadTab(),{success:!0}}catch(e){return{success:!1,reason:e.message}}}}});var An,ty=T(()=>{"use strict";ue();An=class extends W{async runApiInAut(e){var n;e.withCredentials=!0;let t=this.context.data.timeToPlayStep+3e3,{apiCall:r}=this.sessionPlayerInit;try{let o=await this.driver.executeCodeAsync(r,t,e);return(o==null?void 0:o.value)||{}}catch(o){throw(n=o==null?void 0:o.message)!=null&&n.includes("Javascript execution context no longer exists")?new Error('The page refreshed or changed while executing this step. Please consider unchecking "Send via web page" if this is expected.'):o}}runApiInBg(e){let{apiCall:t,apiCallAsync:r}=this.sessionPlayerInit;return typeof r=="function"&&r.length===2?r(t,e):new Promise(n=>{t(e,n)})}async performAction(){let{sessionPlayerInit:{commonConstants:e},step:t,context:r}=this,n={id:t.id,url:r.apiUrl,method:t.method,headers:r.apiHeaders,body:r.apiBody,timeout:r.data.maxTotalStepTime,omitCookies:t.omitCookies,formData:t.formData,fileUrls:r.fileUrls},o=t.sendViaWebApp?await this.runApiInAut(n):await this.runApiInBg(n),i=o.result||{},a={method:t.method,status:i.status,url:t.url};return o.success?i.status===0?{result:i,resultInfo:a,shouldRetry:!1,success:!1,reason:"Connection problem",errorType:e.stepResult.API_REQUEST_NETWORK_ERROR}:{result:i,resultInfo:a,shouldRetry:!1,success:!0}:{result:i,resultInfo:a,shouldRetry:!1,success:!1,reason:i.error||e.error.REQUEST_TIMED_OUT,errorType:i.error?e.stepResult.API_FAILURE:e.stepResult.API_REQUEST_NETWORK_ERROR}}}});var Ji,ry=T(()=>{"use strict";ue();Ji=class extends W{async performAction(){let e=this.step.extractTextParamName,t=await this.stepActionUtils.extractTargetText(this.getTarget());return this.context.data.exports||={},this.context.data.exports[e]=t,{success:!0,data:this.context.data}}}});var sy,Lu,Du,ny=T(()=>{"use strict";sy=E(require("@applitools/spec-driver-webdriverio"));Gn();be();Lu=class{constructor(){let{EyeSdkBuilder:e}=ee(),t=fp["@applitools/eyes-sdk-core"]||"N/A",{makeSDK:r}=require("@applitools/eyes-sdk-core");this.sdk=r({name:"Testim.io",version:`4.0.1/eyes-sdk-core/${t}`,spec:sy.default}),this.handleApplitoolsSdkResult=e.handleApplitoolsSdkResult}async getManager(e,t,r,n){let{EyeSdkBuilder:o}=ee(),i=await this.sdk.makeManager({type:e?"ufg":"classic",concurrency:t});return o.rememberCreatedBatch(r,n),i}},Du=new Lu});var iy,oy,Pn,ay=T(()=>{"use strict";iy=E(require("lodash"));ue();B();ny();oy=x("pixel-validation-step-action"),Pn=class extends W{async performAction(){var m,p;let{shouldUseVisualGrid:t,applitoolsSdkConfig:r,applitoolsSdkLogger:n,testResultId:o}=this.context;this.runContext=this.context.getRunContext(void 0);let i=((m=this.runContext.incomingParams)==null?void 0:m.final)||{},a=((p=r.batch)==null?void 0:p.id)||o,c=await Du.getManager(t,this.context.config.applitoolsConcurrency||5,a,this.runContext.applitoolsIntegrationData),l=this.getTarget()||{},d;try{let g=await c.openEyes({driver:this.driver.client,config:r,logger:n}),h={region:this.step.action==="element"&&l.seleniumElement||void 0,fully:this.step.action==="stitched"};iy.isPlainObject(i.applitoolsStepSettings)&&(Object.assign(h,i.applitoolsStepSettings),oy.info("Applitools SDK step executed with applitoolsStepSettings parameter",{applitoolsStepSettings:i.applitoolsStepSettings})),await g.check({settings:h}),d={isApplitoolsSdkResult:!0,success:!0,eyesResults:await g.close()}}catch(g){oy.error("Applitools SDK step failed",{err:g,info:g.info}),d={isApplitoolsSdkResult:!0,success:!1,err:g}}return await Du.handleApplitoolsSdkResult(this.context,d,this.step)}}});var ys,Mu=T(()=>{"use strict";Rr();z();Ni();ys=class extends or{async executeCliCode(){var f,h,y;let{step:e,context:t}=this,r=this.stepActionUtils.driver.isMobile;if(!((y=(h=(f=t.company)==null?void 0:f.activePlan)==null?void 0:h.premiumFeatures)==null?void 0:y.cliAction)&&!r)return{success:"skipped",reason:"CLI action is not enabled in your current plan"};let{code:o="",id:i=""}=e,{incomingParams:a,testResultId:c,retryIndex:l,stepResultId:d}=t,m={config:t.config,data:t.data},p=t.data.timeToPlayStep,g=await cs(o,i,a,m,c,l,d,p);return this.checkCodeResponse(g)}async performAction(){try{return await this.executeCliCode()}catch(e){let{stepResult:t}=this.sessionPlayerInit.commonConstants;return e instanceof re?{success:!1,errorType:t.ACTION_TIMEOUT}:{success:!1,reason:e.message,exception:e}}}}});var ir,cy=T(()=>{"use strict";Mu();ir=class extends ys{isFailedResult(e){return e===!1}}});var Yi,ly=T(()=>{"use strict";Mu();Yi=class extends ys{isFailedResult(e){return!e}}});var Xi,uy=T(()=>{"use strict";Rr();ue();z();Xi=class extends W{async performAction(){let{stepId:e,packageData:t,resultId:r,retryIndex:n,stepResultId:o,timeToPlayBeforeExec:i}=this.context;try{return{data:await as(e,r,n,t,o,i),success:!0}}catch(a){return a instanceof wt?{success:!1,code:"invalid-node-package",message:a.message}:a instanceof re?{success:!1,code:"timeout"}:{success:!1,reason:a.message,exception:a}}}}});var bs,py=T(()=>{"use strict";ue();bs=class extends W{async performAction(){return{success:"skipped",reason:"This step can run only on Chrome"}}}});var ve,dy=T(()=>{"use strict";ue();ve=class extends W{async performAction(){var r,n;let{sfdc:e}=this.sessionPlayerInit,t=e.sfdcNewSePage(this.driver,this.context.sfdcLogHandler||((o,i)=>this.context.playback.sfdcAddLog(o,i)));t.log.info(`BEGIN STEP '${(n=(r=this.step).getStepPreview)==null?void 0:n.call(r)}'`);try{let o=this.context.sfdcTestActions;if(o===void 0)throw new Error("No test actions were compiled");return{success:!0,reason:await e.sfdcExecute(t,o,this.context)}}catch(o){return{success:!1,reason:o.reason||o.message,exception:o,shouldRetry:!1}}finally{t.releaseObjects()}}}});var Qi,my=T(()=>{"use strict";ue();Qi=class extends W{async performAction(){var r,n;let{sfdc:e}=this.sessionPlayerInit,t=e.sfdcNewSePage(this.driver,this.context.sfdcLogHandler||((o,i)=>this.context.playback.sfdcAddLog(o,i)));t.log.info(`BEGIN STEP '${(n=(r=this.step).getStepPreview)==null?void 0:n.call(r)}'`);try{return{success:!0,reason:await e.sfdcExecuteRecordedStep(t,this.step.recordedData,this.context)}}catch(o){return{success:!1,reason:o.reason||o.message,exception:o,shouldRetry:!1}}finally{t.releaseObjects()}}}});var Zi,fy=T(()=>{"use strict";ue();Zi=class extends W{async performAction(){let{sfdc:e}=this.sessionPlayerInit,t=e.sfdcNewSePage(this.driver,this.context.sfdcLogHandler);try{return await e.sfdcExecuteJavascript(t,this.step.code||"",this.context),{success:!0}}catch(r){return{success:!1,reason:r.reason||r.message,exception:r,shouldRetry:!1}}finally{t.releaseObjects()}}}});function rS(s,e){Object.keys(s).forEach(t=>{e.registerStepAction(t,s[t])})}function ea(s,e){rS(sS,e),e.registerLocateStepActionUtils(Rn.getUtils(s))}var sS,Nu=T(()=>{"use strict";ph();fh();Sh();Rh();xh();Ch();_h();Lh();Dh();Uh();Fh();Bh();Wh();Hh();Xh();Qh();Zh();ey();ty();ry();ay();cy();ly();uy();py();dy();my();fy();sS={locate:Rn,scroll:Oi,mouse:_i,submit:Bi,text:Di,"special-key":Ui,"user-code":jt,"validation-code-step":jt,"wait-for-code-step":jt,"action-code-step":jt,"condition-step":hs,"skip-code-step":hs,"element-code-step":hs,"evaluate-expression":Li,"text-validation":xn,"wait-for-text-validation":xn,"select-option":Fi,"drop-file":Wi,"input-file":Vi,hover:ji,navigation:qi,wheel:$i,sleep:zi,refresh:Ki,"api-validation":An,"api-action":An,"api-code-step":jt,"extract-text":Ji,"simple-ui-verification":Pn,"wait-for-simple-ui-verification":Pn,"cli-validation-download-file":bs,"cli-wait-for-download-file":bs,"network-validation-step":bs,"cli-validation-code-step":ir,"cli-wait-for-code-step":ir,"cli-action-code-step":ir,"cli-api-code-step":ir,"cli-condition-step":Yi,"node-package":Xi,"email-code-step":jt,"cli-email-code-step":ir,"sfdc-internal-test-step":Zi,"sfdc-recorded-step":Qi,"sfdc-step-login":ve,"sfdc-step-loginas":ve,"sfdc-step-logout":ve,"sfdc-step-sobjectcreate":ve,"sfdc-step-sobjectdelete":ve,"sfdc-step-findrecord":ve,"sfdc-step-quickaction":ve,"sfdc-step-sobjectedit":ve,"sfdc-step-sobjectvalidate":ve,"sfdc-step-launchapp":ve,"sfdc-step-wait-for-page-load":ve,"sfdc-step-closeconsoletabs":ve,"sfdc-step-relatedlistaction":ve,"sfdc-step-permission-validation":ve,"sfdc-step-convert-lead-to-opportunity":ve,"sfdc-step-quotelineeditor":ve}});var gy,nS,Ts,Uu=T(()=>{"use strict";gy=["simple-ui-verification","wait-for-simple-ui-verification"],nS=[...gy,"custom-validation","sfdc-internal-test-step","sfdc-recorded-step","sfdc-step-login","sfdc-step-loginas","sfdc-step-logout","sfdc-step-sobjectcreate","sfdc-step-sobjectdelete","sfdc-step-findrecord","sfdc-step-quickaction","sfdc-step-sobjectvalidate","sfdc-step-launchapp","sfdc-step-wait-for-page-load","sfdc-step-closeconsoletabs","sfdc-step-sobjectedit","sfdc-step-relatedlistaction","sfdc-step-permission-validation","sfdc-step-convert-lead-to-opportunity","sfdc-step-quotelineeditor"],Ts=class{constructor(e){this.isDebuggerConnected=e;this.totalStepTime=0;this.currentRetryStart=0;this.totalStepTimesReport=[];this.currentRetryTimes=[];this.currentRetryTimesReport={};this.resetStepVariables(),this.resetRetryVariables()}resetStepVariables(e,t){this.currentRetryTimes=t||[],this.totalStepTime=e||0,this.totalStepTimesReport=[],this.currentRetryTimesReport={};let r=Date.now();this.currentRetryStart=r,this.lastUpdateTime=r}resetRetryVariables(){let e=Date.now();this.currentRetryStart=e,this.lastUpdateTime=e,this.totalStepTimesReport.push(this.currentRetryTimesReport),this.currentRetryTimesReport={}}initStepRun(e){let t=o=>{let i=this.getTotalStepTimeLeftToPlay(e,o),a=5e3;return i<=a?[a]:[Math.max(a,i/3)]};e.setStartTimestamp();let r=this.getTotalStepRunTime(e),n=nS.includes(e.stepType)?[r]:t(r);this.resetStepVariables(r,n),e.context.data.maxTotalStepTime=r}initRetryTime(){this.resetRetryVariables()}getTotalStepRunTime(e){let r=e.context.config.stepTimeout;return gy.includes(e.stepType)&&(r=e.context.config.applitoolsStepTimeout||18e5),e.step.type.startsWith("sfdc-")&&(r=e.step.defaultTimeout),e.step.useStepTimeout&&e.step.stepTimeout?e.step.stepTimeout:r}getTotalStepTimeLeftToPlay(e,t=this.totalStepTime){let r=Date.now()-e.startTimestamp;return t-r}getCurrentRetryTime(e){return e.retryIndex<this.currentRetryTimes.length?this.currentRetryTimes[e.retryIndex]:this.getTotalStepTimeLeftToPlay(e)}getTotalCurrentRetryTimeLeft(e){let t=Date.now()-this.currentRetryStart;return this.getCurrentRetryTime(e)-t+1e3}getTabTimeout(e){return this.getTotalCurrentRetryTimeLeft(e)}getDynamicParentTimeout(e){return this.getTotalCurrentRetryTimeLeft(e)}getFrameTimeout(e){return this.getTotalCurrentRetryTimeLeft(e)}getLocateTimeout(e){return this.getTotalCurrentRetryTimeLeft(e)}getActionTimeout(e){if(this.isDebuggerConnected)return 6e5;let t=5e3,r=e.step.type,n=3e4;return r==="sleep"?e.step.durationMS+t:Math.max(this.getTotalStepTimeLeftToPlay(e),n)}}});var yy={};G(yy,{SeleniumTestPlayer:()=>Cn});var hy,Cn,Fu=T(()=>{"use strict";j();hy=require("@applitools/eyes-sdk-core");bn();z();Iu();ih();Cu();ku();lh();Ou();be();Nu();Uu();Cn=class{constructor(e,t,r,n,o=void 0,i=void 0){this.id=e;this.playbackTimeoutCalculator=new Ts(ki());let{SessionPlayer:a,commonConstants:c,StepActionFactory:l}=ee();this.driver=n??new Sr;let d=new gs(this.driver);this.stepActionFactory=new l(d),ea(this.driver,this.stepActionFactory),this.tabService=this.driver.tabService||new Pi(this.driver),this.driver.tabService=this.tabService,this.tabService.createSesion(e);let m=ch(this.driver);this.sessionPlayer=new a(e,{tabService:this.tabService,cookieUtils:new ms(this.driver),FrameLocator:m,portSelector:Ci,LocateElementPlayer:null,stepActionUtils:d,stepActionFactory:this.stepActionFactory,playbackTimeoutCalculator:this.playbackTimeoutCalculator,makeSDK:hy.makeSDK}),this.sessionPlayer.setShouldMonitorPerformance(Boolean(r)),this.tabService.setAddFrameHandlerCallBack(this.sessionPlayer.addPlaybackFrameHandler.bind(this.sessionPlayer)),this.sessionPlayer.playbackManager.isRemoteSession=!0,this.sessionPlayer.playbackManager.isLocalRun=!1,this.sessionPlayer.playbackManager.testRetryCount=o,this.sessionPlayer.playbackManager.previousTestResultId=i,this.sessionPlayer.playbackManager.userParamsData=t||{},this.onStepCompleted=this.onStepCompleted.bind(this),this.sessionPlayer.playbackManager.on(c.playback.RESULT,this.onStepCompleted)}onStepCompleted(e,t,r,n){n!=null&&n.isTabOpener&&this.tabService.addNewPopup(this.id,n.id).catch(()=>null)}async onDone(){var r,n;let{commonConstants:e}=ee(),t=1e3*60*2;try{await ae((r=this.driver)==null?void 0:r.end(),t)}catch(o){o instanceof re&&await((n=this.driver)==null?void 0:n.forceEnd().catch(()=>null))}this.sessionPlayer.playbackManager.off(e.playback.RESULT,this.onStepCompleted),Object.assign(this,{sessionPlayer:null,tabService:null,stepActionFactory:null,driver:null})}clearSessionTabs(){this.tabService.clearAllTabs(this.id)}async addTab(e,t={loadInfo:!0}){let n=(await this.driver.getTabIds()).at(-1);return await this.tabService.addNewTab(this.id,n,e,t),this.sessionPlayer.addPlaybackFrameHandler(n,void 0,{emptyPage:!0})}async addAllTabs(e,t={loadInfo:!0,checkForMainTab:!0,takeScreenshots:!0},r=[]){let n=await this.driver.getTabIds(),o=["app.testim.io"].concat(r);for(let i of n.reverse()){await this.tabService.addNewTab(this.id,i,e,{...t,forceSwitch:!0});let a=this.tabService.getTabInfo(this.id,i);if(o.some(c=>a.url.includes(c))){await this.tabService.removeTabInfo(this.id,i);continue}await this.sessionPlayer.addPlaybackFrameHandler(i,void 0,{emptyPage:!0})}if(this.tabService.tabCount(this.id)===1){let i=this.tabService.getMainTabInfo(this.id),a=this.tabService.getTabUtils(this.id,i);await this.tabService.switchTab(a.tabId,this.id,{forceSwitch:!0})}this.tabService.fixMissingMainTab(this.id)}getSessionId(){return this.driver.getSessionId()}}});var by={};G(by,{WorkerSelenium:()=>Bu});function iS(s){let{playback:e}=ee().commonConstants;for(let t of Object.values(e))s.playbackManager.on(t,()=>L(`Got event ${t}`))}var ta,oS,Bu,Ty=T(()=>{"use strict";j();Fe();Sn();B();At();Mo();ce();Su();z();Fu();be();ta=x("worker-selenium"),oS=1e9,Bu=class extends tt{initPlayer(t){return new Cn(this.id,t.runParams,this.options.shouldMonitorPerformance,void 0,t.retryCount,t.previousTestResultId)}async getBrowserOnce(t,r,n,o){L("in WorkerSelenium getBrowserOnce"),X.onGetSession(this.id,this.testName,t.runMode);let{driver:i}=n;this.windowUtils=new ds(this.id,i),n.clearSessionTabs();let{browserValue:a}=this.testRunConfig,c=t.baseUrl;try{let l=this.options.useLocalChromeDriver;await i.init(this.options,this.testName,this.testRunConfig,o,r,this.executionId,this.testResultId,t.seleniumPerfStats,l,this.lambdatestService),L("in WorkerSelenium after driver.init"),await n.addTab(void 0,{skipLoadInfo:l}),L("in WorkerSelenium after addTab"),l||await this.windowUtils.navigate(c,oS),await this.windowUtils.validatePageIsAvailable(),L("in WorkerSelenium after navigate")}catch(l){let d=l.message&&(l.message.startsWith("Malformed URL")||l.message.includes("Reached error page: about:neterror"))&&a==="firefox",m=l.message&&l.message==="invalid argument";throw l instanceof bt||d||m?new bt(`Page '${c}' is not available`):(ta.error("failed to navigate to page",{baseUrl:c,err:l}),l)}}async runTestOnce(t,r){var m;let{manifestVersion:n,localAssetService:o}=ee(),{driver:i,sessionPlayer:a}=r,c=n||"runner";X.onWaitToTestComplete(this.id),iS(a),a.playbackManager.executionId=t.executionId,a.playbackManager.executionName=t.executionName,a.setLightweightMode(this.options.lightweightMode),t.sfdcCredential&&a.setSfdcCredential(t.sfdcCredential),o.initialize({serverUrl:this.options.localRCASaver});let l=null;(m=this.options.lightweightMode)!=null&&m.preloadTests&&(l=(await nn(this.options))[this.testId]);let d=async()=>ae(new Promise((p,g)=>{a.playByTestId({testId:this.testId,executionId:this.executionId,resultId:this.testResultId,baseUrl:this.baseUrl,userData:this.userData,version:c,resolve:p,isLocalRun:!1,overrideTestConfigId:this.overrideTestConfigId,branch:this.branch,incognito:!1,remoteRunId:t.remoteRunId,preloadedTest:l}).catch(g)}),this.testRunTimeout,$e.TEST_COMPLETE_TIMEOUT_MSG).catch(p=>{var g;throw p instanceof re&&((g=a.stopPlayingOnTestTimeout)==null||g.call(a)),p}).then(async p=>{await o.drain(),p.stepsResults=null,p.resultId=this.testResultId,i.isAlive()||(ta.warn(`possible grid unresponsive for test ${this.testId}, result ${this.testResultId} (execution: ${this.executionId})`),p.gridIssues="could not validate grid is alive");let g=i.maxKeepAliveGap();g>=3e4&&(ta.warn(`possible browser keep alive issue ${this.testId}, result ${this.testResultId} (execution: ${this.executionId})`),p.keepAliveIssue=g);let h={...p,...t.seleniumPerfStats.getStats()};return this.lambdatestService.isLambdatestRun()&&await i.executeJS(`lambda-status=${h.success?"passed":"failed"}`).catch(()=>{}),h});i.start(),L("right before super.runTestOnce in workerSelenium");try{await super.runTestOnce(t,r),L("right after super.runTestOnce in workerSelenium");let p=await d();return L("right after runSeleniumTest"),p}catch(p){throw ta.error("failed to run test once",{err:p}),p}}}});var ra,wy=T(()=>{"use strict";ra=class{constructor(){this.sessionTabs={}}on(){}tabCount(){}getAllOpenTabIds(){return[]}isSessionTab(){return!1}getAllTabInfos(){return{}}async addNewTab(){}addOpenerStepId(){}addOpenerStep(){}getTabUtilsByTabIdAndSessionId(){}getTabUtilsByTabId(){return{}}getTabInfo(){return{}}getTabUtils(){return{}}getMainTabInfo(){}getMainTabUtils(){return{}}getMainTabId(){return null}async isMainTabExists(){return!1}clearAllTabs(){}async switchTab(){}async getTabDetails(){}async isMainTabIncognito(){return!1}async getTabIdByTabInfo(){return NaN}}});var ju,sa,vy=T(()=>{"use strict";B();ju=x("mobile-frame-locator-mock"),sa=class{foundFrameCallback(){return ju.info("foundFrameCallback-mock invoked"),{}}locate(){return ju.info("locate-mock invoked"),{}}async findFrame(){return ju.info("findFrame-mock invoked"),{}}}});var aS,Sy,Ey,ws,$u=T(()=>{"use strict";aS=E(require("webdriverio")),Sy=require("@applitools/eyes-sdk-core");wy();Cu();B();ku();Ou();be();Nu();vy();Uu();Ey=x("appium-test-player"),ws=class{constructor(e,t,r,n=aS,o=void 0,i=void 0){this.id=e;this.driver=n;let{SessionPlayer:a,commonConstants:c,StepActionFactory:l,MobileLocateElementPlayer:d}=ee(),m=new gs(this.driver);this.stepActionFactory=new l(m),ea(this.driver,this.stepActionFactory),this.playbackTimeoutCalculator=new Ts(ki()),this.sessionPlayer=new a(e,{tabService:new ra,cookieUtils:void 0,FrameLocator:sa,portSelector:Ci,LocateElementPlayer:d,stepActionUtils:m,stepActionFactory:this.stepActionFactory,playbackTimeoutCalculator:this.playbackTimeoutCalculator,makeSDK:Sy.makeSDK}),this.sessionPlayer.setShouldMonitorPerformance(Boolean(r)),this.sessionPlayer.playbackManager.isRemoteSession=!0,this.sessionPlayer.playbackManager.isLocalRun=!1,this.sessionPlayer.playbackManager.testRetryCount=o,this.sessionPlayer.playbackManager.previousTestResultId=i,this.sessionPlayer.playbackManager.userParamsData=t||{},this.onStepCompleted=this.onStepCompleted.bind(this),this.sessionPlayer.playbackManager.on(c.playback.RESULT,this.onStepCompleted)}onStepCompleted(e,t,r,n){}async onDone(){let{playbackManager:e}=this.sessionPlayer,{executionId:t,testResult:{resultId:r},appiumApi:n}=e,o={executionId:t,testResultId:r,sessionId:n==null?void 0:n.sessionId};try{await(n==null?void 0:n.endSession()),Ey.info("appium session deleted",o)}catch(i){Ey.error("error while deleting appium session",{...o,error:i})}finally{let{commonConstants:i}=ee();e.off(i.playback.RESULT),this.sessionPlayer=null,this.stepActionFactory=null,this.driver=null}}getSessionId(){var e;return(e=this.sessionPlayer.playbackManager.appiumApi)==null?void 0:e.sessionId}}});async function cS(s){return await Ne(`${s}/api/status`)}async function Ry(s,e){return await Ne(`${s}/api/devices/${e}/status`)}async function Iy(s){let e="";try{(await cS(s)).fsmState!=="Ready"&&(e="TMA is not ready")}catch{e="It seems that the TMA agent is offline."}if(e)throw new Error(e)}var xy=T(()=>{"use strict";Ve()});var Py={};G(Py,{WorkerLocalTma:()=>Hu});var Ay,kn,na,Wu,Gu,Vu,Hu,Cy=T(()=>{"use strict";Ay=E(require("jsdom"));Ve();kn=E(require("semver"));gn();Sn();j();B();At();$u();be();xy();ui();na=x("worker-appium"),Wu=class extends Error{},Gu=class extends Error{},Vu=class extends Error{},Hu=class extends tt{constructor(){super(...arguments);this.baseDevicePath=(t,r)=>`${t}/api/devices/${r}`}initPlayer(t){return new ws(this.id,t.runParams,this.options.shouldMonitorPerformance,void 0,t.retryCount,t.previousTestResultId)}initAndGetAppiumAPI(t){if(t.sessionPlayer.playbackManager.appiumApi)return t.sessionPlayer.playbackManager.appiumApi;let{AppiumApi:r}=ee(),n=new Ay.JSDOM("").window.DOMParser,o=new r(this.sessionData.serverAddress,this.sessionData.sessionId,n);return t.sessionPlayer.playbackManager.appiumApi=o,o}checkIfUpgradeIsNeeded(t,r,n){if(n)return!1;let[o,i]=[kn.coerce(t),kn.coerce(r)];return!o||!i?!1:kn.cmp(o,"!==",i)}async getBrowserOnce(t,r,n,o){var C;if(X.onGetSession(this.id,this.testName,t.runMode),!this.options.localTmaUrl||!this.options.deviceUdid)throw new Error("Missing localTmaUrl or deviceUdid");let{localTmaUrl:i,deviceUdid:a,projectData:c}=this.options;await Iy(i);let{project:l,authData:{token:d=""}={}}=this.options,{driver:m}=n,p=c.type,g=!1,f=this.options.appId;if(f){let{executionId:k,testResultId:R}=t,{mobileApp:M}=await pt.getMobileAppDataByAppId({appId:f,projectId:l,token:d,executionId:k,testResultId:R});t.nativeApp=M}let h=p==="android"?t.androidActivityWait:null,y=t.nativeAppMetadata,v=t.downloadableAppPublicLink,S=t.appPackageNameOrBundleId;if(!y)throw new Error("Application not specified. Please provide the required application for execution and try again.");if(!S)throw new Error("The application appears to be corrupted. Please ensure the application is in a valid state before running the test.");let[{appInstalled:b,version:w},I]=await Promise.all([this.getAppStateFromDevice(i,a,S),Ry(i,a)]).catch(k=>{throw this.handleDeviceNotFoundError(k),k});if(!b&&t.isAppFromDevice&&!f)throw new Error("The application is not installed on the target device. Please ensure the application is installed and try again.");!b&&v&&await this.installApp(i,a,v),b&&(!t.isAppFromDevice||f)&&(g=this.checkIfUpgradeIsNeeded(w,y.version,I.isVirtual));try{let k={testName:this.testName,executionId:this.executionId,testResultId:this.testResultId,project:`${(C=this.options.projectData)==null?void 0:C.name}-${this.options.project}`},R=rg({projectType:p,nativeAppMetadata:y,appPath:v,androidActivityWait:h,sessionTags:k,gridInfo:o,options:this.options,testRunConfig:this.testRunConfig}),M={capabilities:{udid:a,...R}},O=await this.requestNewAppiumSessionFromTma(i,M,y);if(this.sessionData=O,g){let $=this.initAndGetAppiumAPI(n);await $.removeApp(S),await this.installApp(i,a,v),await $.activateApp({[p==="ios"?"appId":"bundleId"]:S})}let D=await m.attach({sessionId:O.sessionId,capabilities:R});this.device=await pt.updateTmaDeviceDetails(a,this.options,t),na.info(`init new appium session with local TMA testName: ${this.testName}`,{sessionId:D.sessionId,testResultId:this.testResultId,nativeAppMetadata:y,sessionCaps:D.capabilities})}catch(k){throw na.error("failed to start application",{err:k}),k}}async requestNewAppiumSessionFromTma(t,r,n){var o,i;try{let a=await je({url:`${t}/api/session`,headers:{"Content-Type":"application/json"},body:r,timeout:6e4}),c={name:n.name,version:n.version};return{...a,appInfo:c,env:"local"}}catch(a){this.handleDeviceNotFoundError(a);let c=(i=(o=a.response)==null?void 0:o.body)==null?void 0:i.message;throw a.status===500&&typeof c=="string"&&c.startsWith("Failed to create driver session")?new Vu(c):a}}async getAppStateFromDevice(t,r,n){let o=this.options.projectData.type==="ios"?"bundles":"apps",i=`${this.baseDevicePath(t,r)}/${o}`,c=(await Ne(i)).find(l=>"id"in l?l.id===n:l.packageName===n);return c?{appInstalled:!0,version:c.version}:{appInstalled:!1,version:""}}async installApp(t,r,n){var o,i;try{let a=await _t(n);await Ls(`${this.baseDevicePath(t,r)}/apps`,{},{file:{buffer:a.body,fileName:"app"}})}catch(a){this.handleDeviceNotFoundError(a);let c=(i=(o=a.response)==null?void 0:o.body)==null?void 0:i.message,l="Failed to install app";throw c&&(l=`${l}: ${c}`),new Gu(l,{cause:a})}}handleDeviceNotFoundError(t){var n,o;let r=(o=(n=t.response)==null?void 0:n.body)==null?void 0:o.message;if(t.status===404&&typeof r=="string"&&(r!=null&&r.startsWith("Ensure that the requested device")))throw new Wu(`Device Unavailable: Please ensure that the specified device ${this.options.deviceUdid} is currently connected`)}async runTestOnce(t,r){let{manifestVersion:n,localAssetService:o}=ee(),{sessionPlayer:i}=r,a=n||"runner";X.onWaitToTestComplete(this.id),i.playbackManager.executionId=t.executionId,i.playbackManager.executionName=t.executionName,i.playbackManager.appiumSessionData={...this.sessionData,device:this.device},this.initAndGetAppiumAPI(r),o.initialize({serverUrl:this.options.localRCASaver});let c=async()=>{try{let l=await new Promise((m,p)=>{i.playByTestId({testId:this.testId,executionId:this.executionId,resultId:this.testResultId,baseUrl:this.baseUrl,userData:this.userData,version:a,resolve:m,isLocalRun:!1,overrideTestConfigId:this.overrideTestConfigId,branch:this.branch,remoteRunId:t.remoteRunId}).catch(p)});return await o.drain(),l.stepsResults=null,l.resultId=this.testResultId,{...l,...t.seleniumPerfStats.getStats()}}catch(l){throw na.error("error while running appium tests",{err:l}),l}};try{return await super.runTestOnce(t,r),await c()}catch(l){throw na.error("failed to run test once",{err:l}),l}}}});var Oy={};G(Oy,{WorkerAppium:()=>qu});var ky,On,qu,_y=T(()=>{"use strict";gn();ky=require("linkedom");Sn();B();At();$u();be();ui();ce();On=x("worker-appium"),qu=class extends tt{initPlayer(t){return new ws(this.id,t.runParams,this.options.shouldMonitorPerformance,void 0,t.retryCount,t.previousTestResultId)}async getBrowserOnce(t,r,n,o){X.onGetSession(this.id,this.testName,t.runMode);let{driver:i}=n,a=this.options.projectData.type,{appPath:c,isTdcAppIdExists:l,isHSAppIdExists:d}=await pt.getAppInfoForRemoteRun({testRunHandler:t,options:this.options}),m=a==="android"?t.androidActivityWait:null,p=t.nativeAppMetadata;if(!p)throw new Error("Application not specified. Please provide the required application for execution and try again.");try{let g={testName:this.testName,executionId:this.executionId,testResultId:this.testResultId,project:`${this.options.projectData.name}-${this.options.project}`,...this.options.customTag&&{customTag:this.options.customTag}},f={projectType:a,nativeAppMetadata:p,appPath:c,androidActivityWait:m,sessionTags:g,gridInfo:o,options:this.options,testRunConfig:this.testRunConfig,isHSAppIdExists:d,isTdcAppIdExists:l},h;this.options.skipLoadBalancer&&this.options.deviceUdid?(this.options.lockDevice&&await pt.lockDevice(o,this.options.deviceUdid),h=await ng(f)):h=sg(f),On.info("starting appium session",{testResultId:this.testResultId,executionId:this.executionId,sessionTags:g,nativeAppMetadata:p,capabilities:og(h)}),this.activeSession=await i.remote(h),this.device=await pt.updateDeviceOnRemoteTestResult(t,this.activeSession,this.options),On.info("appium session started successfully",{sessionId:this.activeSession.sessionId,testResultId:this.testResultId,executionId:this.executionId,sessionCaps:this.activeSession.capabilities})}catch(g){throw On.error("failed to start application",{testResultId:this.testResultId,executionId:this.executionId,err:g}),g}}getServerAddressFromGrid(){let{host:t,port:r,accessToken:n,type:o}=this.options.gridData;return o===N.TESTIM_HEADSPIN||o===N.TESTIM_TDC?`https://${t}:${r}/v0/${n}/wd/hub`:`https://${t}:${r}/wd/hub`}getDirectAddressConnection(t){let{directConnectProtocol:r,directConnectHost:n,directConnectPort:o,directConnectPath:i}=t;if(r&&n&&o&&i)return`${r}://${n}:${o}${i}`}async runTestOnce(t,r){var p,g;let{manifestVersion:n,AppiumApi:o,localAssetService:i}=ee(),{sessionPlayer:a}=r,c=n||"runner";X.onWaitToTestComplete(this.id),a.playbackManager.executionId=t.executionId,a.playbackManager.executionName=t.executionName;let l;if(this.options.skipLoadBalancer){let f=this.options.deviceUdid||((p=this.testRunConfig.mobile)==null?void 0:p.staticAllocation.deviceUdid),{protocol:h,hostname:y,port:v,path:S}=await pt.getHeadSpinDeviceConnection(this.options.gridData,f);l=`${h}://${y}:${v}${S}`}else l=this.getDirectAddressConnection(this.activeSession.capabilities)||this.getServerAddressFromGrid();let d=this.activeSession.capabilities;a.playbackManager.appiumSessionData={env:"remote",capabilities:d,sessionId:this.activeSession.sessionId,sessionToken:this.options.gridData.accessToken,gridType:this.options.gridData.type,projectType:this.options.projectData.type,gridId:this.options.gridData.gridId,companyId:(g=this.options.company)==null?void 0:g.companyId,device:this.device},a.playbackManager.appiumApi=new o(l,this.activeSession.sessionId,ky.DOMParser),i.initialize({serverUrl:this.options.localRCASaver});let m=async()=>{try{let f=await new Promise((y,v)=>{a.playByTestId({testId:this.testId,executionId:this.executionId,resultId:this.testResultId,baseUrl:this.baseUrl,userData:this.userData,version:c,resolve:y,isLocalRun:!1,overrideTestConfigId:this.overrideTestConfigId,branch:this.branch,remoteRunId:t.remoteRunId}).catch(v)});return await i.drain(),f.stepsResults=null,f.resultId=this.testResultId,{...f,...t.seleniumPerfStats.getStats()}}catch(f){throw On.error("error while running appium tests",{testResultId:this.testResultId,executionId:this.executionId,err:f}),f}};try{return await super.runTestOnce(t,r),await m()}catch(f){throw On.error("failed to run test once",{err:f}),f}}}});var oa,Ly=T(()=>{"use strict";j();bn();z();oa=class{constructor(e){this.id=e;this.driver=new Sr}async onDone(){try{await ae(this.driver.end(),12e4)}catch(t){t instanceof re&&await this.driver.forceEnd().catch(()=>null)}this.driver=null}getSessionId(){return this.driver.getSessionId()}}});var Dy,ia,My=T(()=>{"use strict";Dy=E(require("ws"));j();ia=class{constructor(){this._cdpWs=null;this._cdpUrl=null;this._cdpCallbacks=new Map}async initSession(e,t=500){await this.stopSession(),this._cdpUrl=e,await this.initCDPWebsocket(t)}async initCDPWebsocket(e=500){if(this._cdpWs)return this._cdpWs;let t=new Dy.default(this._cdpUrl,{timeout:e}),r=Vt(o=>{t.once("open",o)}),n=Vt(o=>{t.once("error",o)}).catch(()=>{t.close(),t.removeAllListeners()});return t.on("message",o=>this.onCDPMessage(o)),this._cdpWs=Promise.race([r,n]).then(()=>t),this._cdpWs}onCDPMessage(e){var n;let t=JSON.parse(e),r=this._cdpCallbacks.get(t.id);r&&(this._cdpCallbacks.delete(t.id),t.error?r.reject(new Error(t.error)):(n=t.result.exceptionDetails)!=null&&n.exception?r.reject(new Error(t.result.exceptionDetails.exception.description)):r.resolve(t.result))}async stopSession(){let e=this._cdpWs;if(this._cdpUrl=null,this._cdpWs=null,this._cdpCallbacks.clear(),e)try{return(await e).close()}catch{return}}async cdpCommand(e,t,r){let n=await this.initCDPWebsocket();this._lastWsId||=0;let o=this._lastWsId++,i=new Promise((c,l)=>{this._cdpCallbacks.set(o,{resolve:c,reject:l})}),a={method:e,params:t,id:o};return r&&Object.assign(a,{sessionId:r}),n.send(JSON.stringify(a)),i}}});var ca,zu,aa,Ny=T(()=>{"use strict";j();ca=E(require("chrome-launcher"));gn();My();en();zu=class{constructor(e){this.sessionId=e;this._isAlive=!1;this.cdpTestRunner=new ia}async init(e,t,r,n,o,i,a,c,l,d){var f,h,y,v;let m=di(e,t,r,n,o,i,a),p=[...((f=m.desiredCapabilities)==null?void 0:f.chromeOptions.args)??[],...((v=(y=(h=m.capabilities)==null?void 0:h.alwaysMatch)==null?void 0:y["goog:chromeOptions"])==null?void 0:v.args)??[],...ca.Launcher.defaultFlags().filter(S=>S!=="--disable-extensions")];this.chrome=await ca.launch({chromeFlags:p,startingUrl:void 0,ignoreDefaultFlags:!0}),this.chrome.process.once("exit",()=>{this._isAlive=!1}),this.chrome.process.once("close",()=>{this._isAlive=!1}),this._isAlive=!0;let g=await mr(`localhost:${this.chrome.port}`);await this.cdpTestRunner.initSession(g),Yr(()=>this.chrome.kill())}isAlive(){return this._isAlive}start(){}async stop(){await this.cdpTestRunner.stopSession(),this.chrome&&await this.chrome.kill(),this._isAlive=!1}getSessionId(){return this.sessionId}},aa=class{constructor(e){this.id=e;this.sessionId=te();this.driver=new zu(this.sessionId)}async onDone(){return this.driver.stop()}getSessionId(){return this.sessionId}}});var Fy={};G(Fy,{WorkerExtension:()=>_n});function lS(s){return s instanceof Error&&"type"in s&&typeof s.type=="string"}function Uy(s){return lS(s)?s:new Error(s)}var rt,_n,Ku=T(()=>{"use strict";Fe();z();Sn();j();B();At();ce();Ly();Ny();rt=x("worker-ext"),_n=class extends tt{initPlayer(){return this.options.useChromeLauncher?new aa(this.id):new oa(this.id)}async _getBrowserOnce(e,t,r,n){var i;let{driver:o}=r;try{return await o.init(this.options,this.testName,this.testRunConfig,n,t,this.executionId,this.testResultId,e.seleniumPerfStats,(i=this.options.lightweightMode)==null?void 0:i.general,this.lambdatestService)}catch(a){throw rt.error("failed to get browser",{err:a,gridInfo:n,testId:e.testId,resultId:e.testResultId}),a}}async getBrowserOnce(e,t,r,n){return X.onGetSession(this.id,this.testName,e.runMode),this._getBrowserOnce(e,t,r,n)}isUsingChromeLauncher(e){return Boolean(this.options.useChromeLauncher)}async updateTestStatusOnGrid(e,t,r){var o;let n=t?"passed":"failed";if(this.lambdatestService.isLambdatestRun()&&await e.executeJS(`lambda-status=${n}`),"browserstack"in this.options&&((o=this.options.browserstack)!=null&&o["browserstack.user"])){let i={action:"setSessionStatus",arguments:{status:n,reason:r}};await e.execute(`browserstack_executor: ${JSON.stringify(i)}`)}}async runTestOnce(e,t){let{testResultId:r,executionId:n,testId:o}=this;L("WorkerExtension runTestOnce");let i=async d=>{let m=this.options.timeoutWasGiven?Math.max(1e4,this.options.timeout):this.options.testStartTimeout;try{return await ae(e.runTestUsingCDP(d.cdpTestRunner),m,$e.TEST_START_TIMEOUT_MSG)}catch(p){if(!(p instanceof re))throw p;return rt.warn("timeout while running test using CDP. Running checkViaRestAPIIfTestStarted",{testResultId:r}),await e.checkViaRestAPIIfTestStarted()}},a=async(d,m,p)=>{try{let g=await d.url(m);return p.driverUrlFinished=!0,g}catch(g){throw rt.error("error from driver.url",{err:g,testResultId:r,executionId:n,testId:o,url:m,urlLength:m.length}),g}},c=async d=>{let m=await e.onStarted(this.options.testStartTimeout);return d.testRunHandlerOnStartedHadFinished=!0,m},l=async()=>{var g;if(L("WorkerExtension runExtTest"),((g=this.options.lightweightMode)==null?void 0:g.disableRemoteStep)||this.options.disableSockets||e.listenToRemoteStep(t.driver),this.isUsingChromeLauncher(t)){X.onWaitToTestStart(this.id),X.onWaitToTestComplete(this.id);try{return{...await i(t.driver),...e.seleniumPerfStats.getStats()}}catch(f){throw rt.warn("failed to run test via CDP",{err:f}),f}}let{driver:m}=t,p={driverUrlFinished:!1,testRunHandlerOnStartedHadFinished:!1};try{let f=await e.getRunTestUrl();X.onWaitToTestStart(this.id);try{await ae(Promise.all([a(t.driver,f,p),c(p)]),this.options.testStartTimeout,$e.TEST_START_TIMEOUT_MSG)}catch(v){if(!(v instanceof re))throw v;rt.warn("timeout occurred (see log's payload). Running checkViaRestAPIIfTestStarted",{testResultId:r,executionId:n,testId:o,...p}),await e.checkViaRestAPIIfTestStarted()}X.onWaitToTestComplete(this.id);let h=new AbortController,y=v=>{e.onCompletedCleanup(),rt.warn("on browser closed error detected",{err:v,testResultId:r,executionId:n,testId:o}),m.unregisterToClosedBrowser(y),v.type=Ms.BROWSER_CLOSED,h.abort(v)};m.registerToClosedBrowser(y);try{let v=ae(e.onCompleted(),this.testRunTimeout,$e.TEST_COMPLETE_TIMEOUT_MSG),S=await Ma(v,h.signal);m.unregisterToClosedBrowser(y);try{await this.updateTestStatusOnGrid(m,Boolean(S.success),S.reason)}catch(I){rt.error("Could not update the grid about the test status",{err:I})}m.isAlive()||(rt.warn(`possible grid unresponsive for test ${this.testId}, result ${this.testResultId} (execution: ${this.executionId})`),S.gridIssues="could not validate grid is alive");let b=m.maxKeepAliveGap();return b>=3e4&&(rt.warn(`possible browser keep alive issue ${this.testId}, result ${this.testResultId} (execution: ${this.executionId})`),S.keepAliveIssue=b),{...S,...e.seleniumPerfStats.getStats()}}catch(v){throw rt.warn("timeout wait until test completed",{err:v,testResultId:r,executionId:n,testId:o}),Uy(v)}finally{m.unregisterToClosedBrowser(y)}}catch(f){throw rt.warn("failed to start url",{err:f}),Uy(f)}};t.driver.start();try{return await super.runTestOnce(e,t),L("WorkerExtension super.runTestOnce"),await l()}catch(d){throw rt.error("failed to run test",{err:d,testId:e.testId,resultId:e.testResultId}),d}}}});var By={};G(By,{WorkerExtensionSingleBrowser:()=>Ju});var uS,pS,Ju,jy=T(()=>{"use strict";Fe();j();B();Tu();At();Ku();uS=x("base-worker"),pS=500,Ju=class extends _n{async _releasePlayer(){if(!this.testPlayer)return;let{projectId:t}=this.userData||{};await vn(this.id,this.releaseSlotOnTestFinished,t,this.testPlayer),this.testPlayer=null}onQueueCompleted(){return this._releasePlayer()}async getBrowserOnce(t,r,n,o){return X.onGetSession(this.id,`worker ${this.id}`,t.runMode),this._getBrowserOnce(t,r,n,o)}async getTestPlayer(t,r){return this.testPlayer&&!this.testPlayer.driver.isAlive()&&(uS.warn("WorkerExtensionSingleBrowser is releasing a dead player",{workerId:this.id}),await this._releasePlayer()),this.testPlayer||(this.testPlayer=await super.getTestPlayer(t,r)),this.testPlayer}async runTest(t,r,n){let o=this.handleQuarantine(t);if(o)return o;L("before runTest onTestStarted single browser");let i=await this.onTestStarted(this.id,t.testId,t.testResultId,n,t.retryKey);t.baseUrl=i.config.baseUrl;let a=await this.getTestPlayer(t,r);return t.markClearBrowser(),await this.runTestOnce(t,a)}async runTestCleanup(){var t;if(!this.executionQueue.hasMoreTests()){await this.onQueueCompleted();return}(t=this.options.lightweightMode)!=null&&t.general&&await oe(pS)}}});function dS(s,e){e===0?s():setTimeout(s,e*Rp)}var Yu,la,$y=T(()=>{"use strict";bn();le();Fe();Hl();Rt();cu();z();B();ce();qg();Yu=x("parallel-worker-manager"),la=class{constructor(e){this.customExtensionLocalLocation=e}getWorkerType(e){switch(e.mode){case Y.SELENIUM:return(Ty(),fe(by)).WorkerSelenium;case Y.APPIUM:return e.localTmaUrl?(Cy(),fe(Py)).WorkerLocalTma:(_y(),fe(Oy)).WorkerAppium;default:return gi.isFeatureAvailableForProject("useSameBrowserForMultiTests")?(jy(),fe(By)).WorkerExtensionSingleBrowser:(Ku(),fe(Fy)).WorkerExtension}}createWorkers(e,t,...r){let n=r[0],o=this.getWorkerType(n),i=()=>{try{return L("before new Worker",n.mode),new o(t,...r)}finally{L("after new Worker",n.mode)}};return Array.from(new Array(e),i)}async runTests(e,t,r,n,o,i,a,c,l){if(e&&e.length===0)return;let d=!1,m=0,p=g=>new Promise(f=>{var ht,Pr,A,_,F,H,st,ga;let h=o.project,y=new Ei(r,n,e,o,i,t),v={},S=e.length,b=((ht=o.company)==null?void 0:ht.ucid)||"",w=(Pr=o.company)==null?void 0:Pr.companyId,I=(A=o.company)==null?void 0:A.name,C=o.source||"cli",k=o.user,R=(_=o.company)==null?void 0:_.planType,M=(F=o.company)==null?void 0:F.isStartUp,O=(H=o.projectData)==null?void 0:H.name,D=(st=o.projectData)==null?void 0:st.type,$=o.lightweightMode,V=(ga=o.gridData)==null?void 0:ga.type,J=(kt,nt,he,ha,Dn,ya)=>(m++,Tf({executionId:r,projectId:h,testId:nt,resultId:he,ucid:b,companyId:w,companyName:I,projectName:O,companyPlan:R,source:C,user:k,lightweightMode:$,isStartUp:M,projectType:D,appSource:ya,gridType:V}),t.testStartAndReport(kt,r,he,ha,Dn)),Q=async(kt,nt,he,ha,Dn,ya)=>{var ap,cp,lp;m--;let Xe={...($==null?void 0:$.onlyTestIdsNoSuite)&&{show:!0},...he.seleniumStats&&{seleniumStats:he.seleniumStats},...he.gridIssues&&{gridIssues:he.gridIssues},...he.keepAliveIssue&&{keepAliveIssue:he.keepAliveIssue},...o.host&&{gridHost:o.host}};if(he.seleniumPerfMarks&&(t.concatSeleniumPerfMarks(he.seleniumPerfMarks),delete he.seleniumPerfMarks),o.grid||o.gridId?(Xe.gridName=o.grid||((ap=o.gridData)==null?void 0:ap.name),Xe.gridType=(cp=o.gridData)==null?void 0:cp.type,Xe.gridProvider=(lp=o.gridData)==null?void 0:lp.provider):o.localTmaUrl?(Xe.gridName="local-tma-from-options",Xe.gridType="local-tma"):o.useLocalChromeDriver?(Xe.gridName="local-chrome-driver-from-options",Xe.gridType="local-chrome"):o.useChromeLauncher?(Xe.gridName="chrome-launcher-from-options",Xe.gridType="local-chrome"):o.browserstack?Xe.gridName="browserstack-from-options":o.saucelabs&&(Xe.gridName="saucelabs-from-options"),await t.testEndAndReport(kt,he,r,ha,Dn,Xe).catch(Db=>Yu.error("testEndAndReport threw an error",{err:Db})),Dn)return;v[he.resultId]=he,wf({executionId:r,projectId:h,testId:nt,resultId:he.resultId,result:he,ucid:b,companyId:w,companyName:I,projectName:O,companyPlan:R,source:C,user:k,lightweightMode:$,logger:Yu,isStartUp:M,projectType:D,appSource:ya}),l&&!he.success&&(y.stop(),d=!0),(Object.keys(v).length===S||d&&m===0)&&f(v)},de=(kt,nt)=>{v[nt.resultId]=nt,t.onTestIgnored(kt,nt.resultId),m--,(Object.keys(v).length===S||d&&m===0)&&f(v)},$t=(kt,nt)=>t.onGridSlot(kt,nt);o.userData={loginData:Object.assign({},Mt(),{refreshToken:wo(),authData:Mt(),token:g}),projectId:o.project,company:o.company,servicesUrl:me},L("in localStrategy before createWorker"),this.createWorkers(c,y,o,this.customExtensionLocalLocation,r,J,Q,$t,de).forEach((kt,nt)=>{L("before schedule worker.run after createWorkers"),dS(()=>{L("right before worker.run"),kt.run()},nt)})});try{let g=await Kt(),f=await p(g);if(d)throw new Gt;return f}catch(g){throw Yu.error("failed running parallel workers",{executionId:r,err:g}),g}}}});async function Gy(s,e){var t;return(t=s.lightweightMode)!=null&&t.onlyTestIdsNoSuite&&s.testId?{tests:[s.testId.map(n=>({testId:n,testConfig:{},resultId:te()}))]}:await Cc({projectId:s.project,labels:s.label,testIds:s.testId,testNames:s.name,testConfigNames:s.testConfigNames,suiteNames:s.suites,suiteIds:s.suiteIds,branch:e,rerunFailedByRunId:s.rerunFailedByRunId,testConfigIds:s.testConfigIds,intersections:s.intersections})}function Xu(s){let e=Object.keys(s).length,t=Object.keys(s).reduce((r,n)=>r+(s[n].success===!0?1:0),0);return e===t}async function Qu(s,e){let t=s.mode==="extension"?["edge-chromium","chrome"]:["firefox","chrome","edge-chromium","safari","safari technology preview","browser","android","ios","iphone","ipad"],r=Wy.difference(Ns(s,e),t);if(r.length>0)throw lt("invalid-config-run",{browser:r.join(", "),mode:"runner"}),new P(`browser type <${r}> is not supported in ${s.mode} mode.`);return e}var Wy,Vy=T(()=>{"use strict";Wy=E(require("lodash"));j();Xr();ye();z()});var Ln,b_,Zu,ep,ua,Hy=T(()=>{"use strict";Ln=E(require("lodash"));j();B();le();ce();Fe();ts();Cl();Hl();ye();Rt();At();$f();z();$y();Vy();({testRunStatus:b_,CLI_MODE:Zu}=Lt),ep=x("test-plan-runner"),ua=class{constructor(e){this.startTime=Date.now();this.workerManager=new la(e)}async runTestAllPhases(e,t,r,n,o,i,a,c){let l={},d=Mt(),m=async()=>{let h=o.beforeParallel||1,y=!0,v=await this.workerManager.runTests(e,c,i,a,o,n,d,h,y);Object.assign(l,v)},p=async()=>{let h=zn||o.parallel,y=!1;L("right before this.workerManager.runTests");let v=await this.workerManager.runTests(t,c,i,a,o,n,d,h,y);L("right after this.workerManager.runTests"),Object.assign(l,v)},g=async()=>{let h=o.afterParallel||1,y=!1,v=await this.workerManager.runTests(r,c,i,a,o,n,d,h,y);Object.assign(l,v)};vf({executionId:i,projectId:o.project}),L("right before runBeforeTests");try{return await m(),L("right before runTestPlanTests"),await p(),L("right after runTestPlanTests"),await g(),l}catch(h){if(ep.error("error running test plan",{err:h}),h instanceof Gt)return c.markAllQueuedTests(i,pe.ABORTED,"aborted",!1);throw h}finally{await f()}async function f(){var y,v,S,b;if((y=o.lightweightMode)!=null&&y.disablePixelValidation)return;if(o.mode===Zu.SELENIUM){let[{getSessionPlayer:w},{makeSDK:I}]=await Promise.all([Promise.resolve().then(()=>(be(),Yt)),import("@applitools/eyes-sdk-core")]),{EyeSdkBuilder:C}=w();await C.closeBatch(i,I);return}let h;try{if(!((b=(S=(v=o.company)==null?void 0:v.activePlan)==null?void 0:S.premiumFeatures)!=null&&b.applitools)||(h=await qc(o.project),Ln.default.isEmpty(h)||!i))return;let{runKey:w,url:I}=h;await require("@applitools/eyes-sdk-core").makeSDK({name:"Testim.io",version:"4.0.0",spec:{}}).closeBatches({settings:{batchIds:[i],serverUrl:I,apiKey:w}})}catch{}}}async runTestPlan(e,t,r,n,o,i,a,c){var b,w,I;let l=te(),d=n.project;ka(l),e.forEach(C=>Object.assign(C,{isBeforeTestPlan:!0})),r.forEach(C=>Object.assign(C,{isAfterTestPlan:!0}));let m=[...e,...t,...r],p=new li(m,n,i,a),g=Ln.default.chain(m).map(C=>{var k;return((k=C.overrideTestConfig)==null?void 0:k.name)||""}).uniq().compact().value(),f=(g==null?void 0:g.length)===1?g[0]:null,h=(b=n.lightweightMode)!=null&&b.onlyTestIdsNoSuite?[]:m.map(C=>C.name),y=(w=n.lightweightMode)!=null&&w.onlyTestIdsNoSuite?{beforeTests:e,tests:t,afterTests:r}:p.executionStart(l,d,this.startTime,o,h);L("before testListInfoPromise");let v=await y;(I=n.lightweightMode)!=null&&I.onlyTestIdsNoSuite||X.onTestPlanStarted(v.beforeTests,v.tests,v.afterTests,o,l,c,f),L("before runTestAllPhases");let S=await this.runTestAllPhases(v.beforeTests,v.tests,v.afterTests,a,n,l,o||"All Tests",p);return L("before executionEnd"),await p.executionEnd(l),L("after executionEnd"),{results:S,executionId:l,testPlanName:o,configName:f}}async runTestPlans(e,t){ep.info("start to run test plan",{options:Object.assign({},e,{token:void 0,userParamsData:void 0}),branchToUse:t});function r(d){return Ln.default.flattenDeep(Object.values(d)).reduce((m,p)=>m.concat(p.beforeTests,p.tests,p.afterTests),[])}let n={},o={},i=e.project,a=await Pc(i,e.testPlan,e.testPlanIds,t,e.intersections),c=a.testPlans,l=a.testPlansData;if(!c||c.length===0)throw new P(`no test plan to run ${e.testPlan}`);if(!l||Object.keys(l).length===0){if(e.passZeroTests)return[];throw new P(`no test to run in test plan ${e.testPlan}`)}return e.mode!==Zu.APPIUM&&await Qu(e,r(l)),await ie(c,async d=>{var f;let m=d.testPlanId;n[m]={};let p=Object.assign({},e);p.baseUrl||=d.startUrl,p.appId||=((f=d.mobileApp)==null?void 0:f.appId)||void 0,p.gridId||=d.gridId,e.grid&&delete p.gridId,p.gridData=await ef(e,d);let g=p.overrideExecutionName||d.name;return await ie(l[m],async h=>{let y=await this.runTestPlan(h.beforeTests,h.tests,h.afterTests,p,g,m,t);X.onTestPlanFinished(y.results,d.name,this.startTime,y.executionId,!1),n[m][y.executionId]=y.results;let v=Object.keys(n[m]).map(I=>({executionId:I,status:Xu(n[m][I])})),S=Object.keys(n[m]).map(I=>n[m][I]).reduce((I,C)=>Object.assign(I,C),{}),b=Xu(S);Object.assign(o,S);let w=b?v[0].executionId:v.find(I=>!I.status).executionId;return await Ic(i,m,{success:b,executions:v,executionId:w}),y})})}async runAnonymousTestPlan(e,t){var a;ep.info("start to run anonymous",{options:Object.assign({},e,{token:void 0}),branchToUse:t}),L("before getSuite");let r=await Gy(e,t);if(L("after getSuite"),!((a=r==null?void 0:r.tests[0])!=null&&a.length)){if(e.rerunFailedByRunId)throw new P("No failed tests found in the provided run");if(e.passZeroTests)return[];throw new P("No tests to run")}t="branch"in r&&r.branch||t;let n=r;if(e.rerunFailedByRunId&&!n.runName){if(!n.runExists)throw new P("Invalid run ID - no such run.");n.runName===""&&(n.runName=`rerun-${e.rerunFailedByRunId}`)}let o=e.overrideExecutionName||n.runName||[].concat(e.label,e.name,e.suites).join(" "),i=!0;return L("Right before validateConfig + runAnonymousTestPlan tests map"),await ie(r.tests,async c=>{if(e.resultId){let d=c[0];d.resultId=e.resultId,c=[d]}e.mode!==Zu.APPIUM&&await Qu(e,c),L("right before runTestPlan");let l=await this.runTestPlan([],c,[],e,o,null,t,i);return L("right after runTestPlan"),await X.onTestPlanFinished(l.results,o,this.startTime,l.executionId,i),l})}async run(e){let t=ln(),r=[];Us(e)?r=await this.runTestPlans(e,t):r=await this.runAnonymousTestPlan(e,t);let n=Ln.default.flattenDeep(r);return L("right before onAllTestPlansFinished"),await X.onAllTestPlansFinished(n),L("right after onAllTestPlansFinished"),n.map(o=>o.results).reduce((o,i)=>Object.assign(o,i),{})}}});var Jy={};G(Jy,{init:()=>OS,run:()=>CS});async function fS(s){let e=s.project,t=await Oc(e);if(t!=null&&t.isExecutionBlocked)throw console.error("You have reached the limit of runs for the billing month, please upgrade your plan at https://www.testim.io/upgrade-contact-us?source=cli"),tn(s.authData.uid,"execution-quota-surpassed",{projectId:e}),new Ps}function gS(s,e){var i,a,c,l,d,m;let t=ro(e.activePlan),r=s.parallel;if(t==="free"&&r>zy)throw new P(`The free plan allows only ${zy} parallel runs, please upgrade your plan at https://www.testim.io/upgrade-contact-us?source=cli. Run aborted`);if(e.followL2CPlan){let p=(a=(i=e.activePlan)==null?void 0:i.premiumFeatures)==null?void 0:a.tunnel;if(s.tunnel&&!p)throw new P("Tunnel is not allowed for your current plan, please upgrade your plan at https://www.testim.io/upgrade-contact-us?source=cli. Run aborted");let g=(l=(c=e.activePlan)==null?void 0:c.premiumFeatures)==null?void 0:l.runInTurboMode;s.lightweightMode&&!g&&(console.warn(`
|
|
407
|
+
return downloadAndUploadFile.apply(null, arguments);`,t.locatedElement,p);return}let h=await Jh(p,this.uploadFile);await this.uploadFilesAndForceVisibility(h,t)}}});var Hi,qi,Qh=T(()=>{"use strict";Hi=require("url");ue();qi=class extends W{async updateBaseUrl(e){let t=new Hi.URL(e),r=new Hi.URL(this.context.recordedBaseUrl),n=new Hi.URL(this.context.baseUrl);return t.host===r.host&&r.host!==n.host&&(t.host=n.host),t.href}async performAction(){let e=this.context.data.testimNavigationStepDestination||this.context.data.url;if(this.step.openInNewTab){await this.driver.client.newWindow(e);return}let t=await this.updateBaseUrl(e);await this.driver.url(t)}}});var zi,Zh=T(()=>{"use strict";ue();j();zi=class extends W{async performAction(){await oe(this.step.durationMS||0)}}});var Ki,ey=T(()=>{"use strict";ue();Ki=class extends W{async execute(){try{return await this.driver.reloadTab(),{success:!0}}catch(e){return{success:!1,reason:e.message}}}}});var An,ty=T(()=>{"use strict";ue();An=class extends W{async runApiInAut(e){var n;e.withCredentials=!0;let t=this.context.data.timeToPlayStep+3e3,{apiCall:r}=this.sessionPlayerInit;try{let o=await this.driver.executeCodeAsync(r,t,e);return(o==null?void 0:o.value)||{}}catch(o){throw(n=o==null?void 0:o.message)!=null&&n.includes("Javascript execution context no longer exists")?new Error('The page refreshed or changed while executing this step. Please consider unchecking "Send via web page" if this is expected.'):o}}runApiInBg(e){let{apiCall:t,apiCallAsync:r}=this.sessionPlayerInit;return typeof r=="function"&&r.length===2?r(t,e):new Promise(n=>{t(e,n)})}async performAction(){let{sessionPlayerInit:{commonConstants:e},step:t,context:r}=this,n={id:t.id,url:r.apiUrl,method:t.method,headers:r.apiHeaders,body:r.apiBody,timeout:r.data.maxTotalStepTime,omitCookies:t.omitCookies,formData:t.formData,fileUrls:r.fileUrls},o=t.sendViaWebApp?await this.runApiInAut(n):await this.runApiInBg(n),i=o.result||{},a={method:t.method,status:i.status,url:t.url};return o.success?i.status===0?{result:i,resultInfo:a,shouldRetry:!1,success:!1,reason:"Connection problem",errorType:e.stepResult.API_REQUEST_NETWORK_ERROR}:{result:i,resultInfo:a,shouldRetry:!1,success:!0}:{result:i,resultInfo:a,shouldRetry:!1,success:!1,reason:i.error||e.error.REQUEST_TIMED_OUT,errorType:i.error?e.stepResult.API_FAILURE:e.stepResult.API_REQUEST_NETWORK_ERROR}}}});var Ji,ry=T(()=>{"use strict";ue();Ji=class extends W{async performAction(){let e=this.step.extractTextParamName,t=await this.stepActionUtils.extractTargetText(this.getTarget());return this.context.data.exports||={},this.context.data.exports[e]=t,{success:!0,data:this.context.data}}}});var sy,Lu,Du,ny=T(()=>{"use strict";sy=E(require("@applitools/spec-driver-webdriverio"));Gn();be();Lu=class{constructor(){let{EyeSdkBuilder:e}=ee(),t=fp["@applitools/eyes-sdk-core"]||"N/A",{makeSDK:r}=require("@applitools/eyes-sdk-core");this.sdk=r({name:"Testim.io",version:`4.0.1/eyes-sdk-core/${t}`,spec:sy.default}),this.handleApplitoolsSdkResult=e.handleApplitoolsSdkResult}async getManager(e,t,r,n){let{EyeSdkBuilder:o}=ee(),i=await this.sdk.makeManager({type:e?"ufg":"classic",concurrency:t});return o.rememberCreatedBatch(r,n),i}},Du=new Lu});var iy,oy,Pn,ay=T(()=>{"use strict";iy=E(require("lodash"));ue();B();ny();oy=x("pixel-validation-step-action"),Pn=class extends W{async performAction(){var m,p;let{shouldUseVisualGrid:t,applitoolsSdkConfig:r,applitoolsSdkLogger:n,testResultId:o}=this.context;this.runContext=this.context.getRunContext(void 0);let i=((m=this.runContext.incomingParams)==null?void 0:m.final)||{},a=((p=r.batch)==null?void 0:p.id)||o,c=await Du.getManager(t,this.context.config.applitoolsConcurrency||5,a,this.runContext.applitoolsIntegrationData),l=this.getTarget()||{},d;try{let g=await c.openEyes({driver:this.driver.client,config:r,logger:n}),h={region:this.step.action==="element"&&l.seleniumElement||void 0,fully:this.step.action==="stitched"};iy.isPlainObject(i.applitoolsStepSettings)&&(Object.assign(h,i.applitoolsStepSettings),oy.info("Applitools SDK step executed with applitoolsStepSettings parameter",{applitoolsStepSettings:i.applitoolsStepSettings})),await g.check({settings:h}),d={isApplitoolsSdkResult:!0,success:!0,eyesResults:await g.close()}}catch(g){oy.error("Applitools SDK step failed",{err:g,info:g.info}),d={isApplitoolsSdkResult:!0,success:!1,err:g}}return await Du.handleApplitoolsSdkResult(this.context,d,this.step)}}});var ys,Mu=T(()=>{"use strict";Rr();z();Ni();ys=class extends or{async executeCliCode(){var f,h,y;let{step:e,context:t}=this,r=this.stepActionUtils.driver.isMobile;if(!((y=(h=(f=t.company)==null?void 0:f.activePlan)==null?void 0:h.premiumFeatures)==null?void 0:y.cliAction)&&!r)return{success:"skipped",reason:"CLI action is not enabled in your current plan"};let{code:o="",id:i=""}=e,{incomingParams:a,testResultId:c,retryIndex:l,stepResultId:d}=t,m={config:t.config,data:t.data},p=t.data.timeToPlayStep,g=await cs(o,i,a,m,c,l,d,p);return this.checkCodeResponse(g)}async performAction(){try{return await this.executeCliCode()}catch(e){let{stepResult:t}=this.sessionPlayerInit.commonConstants;return e instanceof re?{success:!1,errorType:t.ACTION_TIMEOUT}:{success:!1,reason:e.message,exception:e}}}}});var ir,cy=T(()=>{"use strict";Mu();ir=class extends ys{isFailedResult(e){return e===!1}}});var Yi,ly=T(()=>{"use strict";Mu();Yi=class extends ys{isFailedResult(e){return!e}}});var Xi,uy=T(()=>{"use strict";Rr();ue();z();Xi=class extends W{async performAction(){let{stepId:e,packageData:t,resultId:r,retryIndex:n,stepResultId:o,timeToPlayBeforeExec:i}=this.context;try{return{data:await as(e,r,n,t,o,i),success:!0}}catch(a){return a instanceof wt?{success:!1,code:"invalid-node-package",message:a.message}:a instanceof re?{success:!1,code:"timeout"}:{success:!1,reason:a.message,exception:a}}}}});var bs,py=T(()=>{"use strict";ue();bs=class extends W{async performAction(){return{success:"skipped",reason:"This step can run only on Chrome"}}}});var ve,dy=T(()=>{"use strict";ue();ve=class extends W{async performAction(){var r,n;let{sfdc:e}=this.sessionPlayerInit,t=e.sfdcNewSePage(this.driver,this.context.sfdcLogHandler||((o,i)=>this.context.playback.sfdcAddLog(o,i)));t.log.info(`BEGIN STEP '${(n=(r=this.step).getStepPreview)==null?void 0:n.call(r)}'`);try{let o=this.context.sfdcTestActions;if(o===void 0)throw new Error("No test actions were compiled");return{success:!0,reason:await e.sfdcExecute(t,o,this.context)}}catch(o){return{success:!1,reason:o.reason||o.message,exception:o,shouldRetry:!1}}finally{t.releaseObjects()}}}});var Qi,my=T(()=>{"use strict";ue();Qi=class extends W{async performAction(){var r,n;let{sfdc:e}=this.sessionPlayerInit,t=e.sfdcNewSePage(this.driver,this.context.sfdcLogHandler||((o,i)=>this.context.playback.sfdcAddLog(o,i)));t.log.info(`BEGIN STEP '${(n=(r=this.step).getStepPreview)==null?void 0:n.call(r)}'`);try{return{success:!0,reason:await e.sfdcExecuteRecordedStep(t,this.step.recordedData,this.context)}}catch(o){return{success:!1,reason:o.reason||o.message,exception:o,shouldRetry:!1}}finally{t.releaseObjects()}}}});var Zi,fy=T(()=>{"use strict";ue();Zi=class extends W{async performAction(){let{sfdc:e}=this.sessionPlayerInit,t=e.sfdcNewSePage(this.driver,this.context.sfdcLogHandler);try{return await e.sfdcExecuteJavascript(t,this.step.code||"",this.context),{success:!0}}catch(r){return{success:!1,reason:r.reason||r.message,exception:r,shouldRetry:!1}}finally{t.releaseObjects()}}}});function rS(s,e){Object.keys(s).forEach(t=>{e.registerStepAction(t,s[t])})}function ea(s,e){rS(sS,e),e.registerLocateStepActionUtils(Rn.getUtils(s))}var sS,Nu=T(()=>{"use strict";ph();fh();Sh();Rh();xh();Ch();_h();Lh();Dh();Uh();Fh();Bh();Wh();Hh();Xh();Qh();Zh();ey();ty();ry();ay();cy();ly();uy();py();dy();my();fy();sS={locate:Rn,scroll:Oi,mouse:_i,submit:Bi,text:Di,"special-key":Ui,"user-code":jt,"validation-code-step":jt,"wait-for-code-step":jt,"action-code-step":jt,"condition-step":hs,"skip-code-step":hs,"element-code-step":hs,"evaluate-expression":Li,"text-validation":xn,"wait-for-text-validation":xn,"select-option":Fi,"drop-file":Wi,"input-file":Vi,hover:ji,navigation:qi,wheel:$i,sleep:zi,refresh:Ki,"api-validation":An,"api-action":An,"api-code-step":jt,"extract-text":Ji,"simple-ui-verification":Pn,"wait-for-simple-ui-verification":Pn,"cli-validation-download-file":bs,"cli-wait-for-download-file":bs,"network-validation-step":bs,"cli-validation-code-step":ir,"cli-wait-for-code-step":ir,"cli-action-code-step":ir,"cli-api-code-step":ir,"cli-condition-step":Yi,"node-package":Xi,"email-code-step":jt,"cli-email-code-step":ir,"sfdc-internal-test-step":Zi,"sfdc-recorded-step":Qi,"sfdc-step-login":ve,"sfdc-step-loginas":ve,"sfdc-step-logout":ve,"sfdc-step-sobjectcreate":ve,"sfdc-step-sobjectdelete":ve,"sfdc-step-findrecord":ve,"sfdc-step-quickaction":ve,"sfdc-step-sobjectedit":ve,"sfdc-step-sobjectvalidate":ve,"sfdc-step-launchapp":ve,"sfdc-step-wait-for-page-load":ve,"sfdc-step-closeconsoletabs":ve,"sfdc-step-relatedlistaction":ve,"sfdc-step-permission-validation":ve,"sfdc-step-convert-lead-to-opportunity":ve,"sfdc-step-quotelineeditor":ve}});var gy,nS,Ts,Uu=T(()=>{"use strict";gy=["simple-ui-verification","wait-for-simple-ui-verification"],nS=[...gy,"custom-validation","sfdc-internal-test-step","sfdc-recorded-step","sfdc-step-login","sfdc-step-loginas","sfdc-step-logout","sfdc-step-sobjectcreate","sfdc-step-sobjectdelete","sfdc-step-findrecord","sfdc-step-quickaction","sfdc-step-sobjectvalidate","sfdc-step-launchapp","sfdc-step-wait-for-page-load","sfdc-step-closeconsoletabs","sfdc-step-sobjectedit","sfdc-step-relatedlistaction","sfdc-step-permission-validation","sfdc-step-convert-lead-to-opportunity","sfdc-step-quotelineeditor"],Ts=class{constructor(e){this.isDebuggerConnected=e;this.totalStepTime=0;this.currentRetryStart=0;this.totalStepTimesReport=[];this.currentRetryTimes=[];this.currentRetryTimesReport={};this.resetStepVariables(),this.resetRetryVariables()}resetStepVariables(e,t){this.currentRetryTimes=t||[],this.totalStepTime=e||0,this.totalStepTimesReport=[],this.currentRetryTimesReport={};let r=Date.now();this.currentRetryStart=r,this.lastUpdateTime=r}resetRetryVariables(){let e=Date.now();this.currentRetryStart=e,this.lastUpdateTime=e,this.totalStepTimesReport.push(this.currentRetryTimesReport),this.currentRetryTimesReport={}}initStepRun(e){let t=o=>{let i=this.getTotalStepTimeLeftToPlay(e,o),a=5e3;return i<=a?[a]:[Math.max(a,i/3)]};e.setStartTimestamp();let r=this.getTotalStepRunTime(e),n=nS.includes(e.stepType)?[r]:t(r);this.resetStepVariables(r,n),e.context.data.maxTotalStepTime=r}initRetryTime(){this.resetRetryVariables()}getTotalStepRunTime(e){let r=e.context.config.stepTimeout;return gy.includes(e.stepType)&&(r=e.context.config.applitoolsStepTimeout||18e5),e.step.type.startsWith("sfdc-")&&(r=e.step.defaultTimeout),e.step.useStepTimeout&&e.step.stepTimeout?e.step.stepTimeout:r}getTotalStepTimeLeftToPlay(e,t=this.totalStepTime){let r=Date.now()-e.startTimestamp;return t-r}getCurrentRetryTime(e){return e.retryIndex<this.currentRetryTimes.length?this.currentRetryTimes[e.retryIndex]:this.getTotalStepTimeLeftToPlay(e)}getTotalCurrentRetryTimeLeft(e){let t=Date.now()-this.currentRetryStart;return this.getCurrentRetryTime(e)-t+1e3}getTabTimeout(e){return this.getTotalCurrentRetryTimeLeft(e)}getDynamicParentTimeout(e){return this.getTotalCurrentRetryTimeLeft(e)}getFrameTimeout(e){return this.getTotalCurrentRetryTimeLeft(e)}getLocateTimeout(e){return this.getTotalCurrentRetryTimeLeft(e)}getActionTimeout(e){if(this.isDebuggerConnected)return 6e5;let t=5e3,r=e.step.type,n=3e4;return r==="sleep"?e.step.durationMS+t:Math.max(this.getTotalStepTimeLeftToPlay(e),n)}}});var yy={};G(yy,{SeleniumTestPlayer:()=>Cn});var hy,Cn,Fu=T(()=>{"use strict";j();hy=require("@applitools/eyes-sdk-core");bn();z();Iu();ih();Cu();ku();lh();Ou();be();Nu();Uu();Cn=class{constructor(e,t,r,n,o=void 0,i=void 0){this.id=e;this.playbackTimeoutCalculator=new Ts(ki());let{SessionPlayer:a,commonConstants:c,StepActionFactory:l}=ee();this.driver=n??new Sr;let d=new gs(this.driver);this.stepActionFactory=new l(d),ea(this.driver,this.stepActionFactory),this.tabService=this.driver.tabService||new Pi(this.driver),this.driver.tabService=this.tabService,this.tabService.createSesion(e);let m=ch(this.driver);this.sessionPlayer=new a(e,{tabService:this.tabService,cookieUtils:new ms(this.driver),FrameLocator:m,portSelector:Ci,LocateElementPlayer:null,stepActionUtils:d,stepActionFactory:this.stepActionFactory,playbackTimeoutCalculator:this.playbackTimeoutCalculator,makeSDK:hy.makeSDK}),this.sessionPlayer.setShouldMonitorPerformance(Boolean(r)),this.tabService.setAddFrameHandlerCallBack(this.sessionPlayer.addPlaybackFrameHandler.bind(this.sessionPlayer)),this.sessionPlayer.playbackManager.isRemoteSession=!0,this.sessionPlayer.playbackManager.isLocalRun=!1,this.sessionPlayer.playbackManager.testRetryCount=o,this.sessionPlayer.playbackManager.previousTestResultId=i,this.sessionPlayer.playbackManager.userParamsData=t||{},this.onStepCompleted=this.onStepCompleted.bind(this),this.sessionPlayer.playbackManager.on(c.playback.RESULT,this.onStepCompleted)}onStepCompleted(e,t,r,n){n!=null&&n.isTabOpener&&this.tabService.addNewPopup(this.id,n.id).catch(()=>null)}async onDone(){var r,n;let{commonConstants:e}=ee(),t=1e3*60*2;try{await ae((r=this.driver)==null?void 0:r.end(),t)}catch(o){o instanceof re&&await((n=this.driver)==null?void 0:n.forceEnd().catch(()=>null))}this.sessionPlayer.playbackManager.off(e.playback.RESULT,this.onStepCompleted),Object.assign(this,{sessionPlayer:null,tabService:null,stepActionFactory:null,driver:null})}clearSessionTabs(){this.tabService.clearAllTabs(this.id)}async addTab(e,t={loadInfo:!0}){let n=(await this.driver.getTabIds()).at(-1);return await this.tabService.addNewTab(this.id,n,e,t),this.sessionPlayer.addPlaybackFrameHandler(n,void 0,{emptyPage:!0})}async addAllTabs(e,t={loadInfo:!0,checkForMainTab:!0,takeScreenshots:!0},r=[]){let n=await this.driver.getTabIds(),o=["app.testim.io"].concat(r);for(let i of n.reverse()){await this.tabService.addNewTab(this.id,i,e,{...t,forceSwitch:!0});let a=this.tabService.getTabInfo(this.id,i);if(o.some(c=>a.url.includes(c))){await this.tabService.removeTabInfo(this.id,i);continue}await this.sessionPlayer.addPlaybackFrameHandler(i,void 0,{emptyPage:!0})}if(this.tabService.tabCount(this.id)===1){let i=this.tabService.getMainTabInfo(this.id),a=this.tabService.getTabUtils(this.id,i);await this.tabService.switchTab(a.tabId,this.id,{forceSwitch:!0})}this.tabService.fixMissingMainTab(this.id)}getSessionId(){return this.driver.getSessionId()}}});var by={};G(by,{WorkerSelenium:()=>Bu});function iS(s){let{playback:e}=ee().commonConstants;for(let t of Object.values(e))s.playbackManager.on(t,()=>L(`Got event ${t}`))}var ta,oS,Bu,Ty=T(()=>{"use strict";j();Fe();Sn();B();At();Mo();ce();Su();z();Fu();be();ta=x("worker-selenium"),oS=1e9,Bu=class extends tt{initPlayer(t){return new Cn(this.id,t.runParams,this.options.shouldMonitorPerformance,void 0,t.retryCount,t.previousTestResultId)}async getBrowserOnce(t,r,n,o){L("in WorkerSelenium getBrowserOnce"),X.onGetSession(this.id,this.testName,t.runMode);let{driver:i}=n;this.windowUtils=new ds(this.id,i),n.clearSessionTabs();let{browserValue:a}=this.testRunConfig,c=t.baseUrl;try{let l=this.options.useLocalChromeDriver;await i.init(this.options,this.testName,this.testRunConfig,o,r,this.executionId,this.testResultId,t.seleniumPerfStats,l,this.lambdatestService),L("in WorkerSelenium after driver.init"),await n.addTab(void 0,{skipLoadInfo:l}),L("in WorkerSelenium after addTab"),l||await this.windowUtils.navigate(c,oS),await this.windowUtils.validatePageIsAvailable(),L("in WorkerSelenium after navigate")}catch(l){let d=l.message&&(l.message.startsWith("Malformed URL")||l.message.includes("Reached error page: about:neterror"))&&a==="firefox",m=l.message&&l.message==="invalid argument";throw l instanceof bt||d||m?new bt(`Page '${c}' is not available`):(ta.error("failed to navigate to page",{baseUrl:c,err:l}),l)}}async runTestOnce(t,r){var m;let{manifestVersion:n,localAssetService:o}=ee(),{driver:i,sessionPlayer:a}=r,c=n||"runner";X.onWaitToTestComplete(this.id),iS(a),a.playbackManager.executionId=t.executionId,a.playbackManager.executionName=t.executionName,a.setLightweightMode(this.options.lightweightMode),t.sfdcCredential&&a.setSfdcCredential(t.sfdcCredential),o.initialize({serverUrl:this.options.localRCASaver});let l=null;(m=this.options.lightweightMode)!=null&&m.preloadTests&&(l=(await nn(this.options))[this.testId]);let d=async()=>ae(new Promise((p,g)=>{a.playByTestId({testId:this.testId,executionId:this.executionId,resultId:this.testResultId,baseUrl:this.baseUrl,userData:this.userData,version:c,resolve:p,isLocalRun:!1,overrideTestConfigId:this.overrideTestConfigId,branch:this.branch,incognito:!1,remoteRunId:t.remoteRunId,preloadedTest:l}).catch(g)}),this.testRunTimeout,$e.TEST_COMPLETE_TIMEOUT_MSG).catch(p=>{var g;throw p instanceof re&&((g=a.stopPlayingOnTestTimeout)==null||g.call(a)),p}).then(async p=>{await o.drain(),p.stepsResults=null,p.resultId=this.testResultId,i.isAlive()||(ta.warn(`possible grid unresponsive for test ${this.testId}, result ${this.testResultId} (execution: ${this.executionId})`),p.gridIssues="could not validate grid is alive");let g=i.maxKeepAliveGap();g>=3e4&&(ta.warn(`possible browser keep alive issue ${this.testId}, result ${this.testResultId} (execution: ${this.executionId})`),p.keepAliveIssue=g);let h={...p,...t.seleniumPerfStats.getStats()};return this.lambdatestService.isLambdatestRun()&&await i.executeJS(`lambda-status=${h.success?"passed":"failed"}`).catch(()=>{}),h});i.start(),L("right before super.runTestOnce in workerSelenium");try{await super.runTestOnce(t,r),L("right after super.runTestOnce in workerSelenium");let p=await d();return L("right after runSeleniumTest"),p}catch(p){throw ta.error("failed to run test once",{err:p}),p}}}});var ra,wy=T(()=>{"use strict";ra=class{constructor(){this.sessionTabs={}}on(){}tabCount(){}getAllOpenTabIds(){return[]}isSessionTab(){return!1}getAllTabInfos(){return{}}async addNewTab(){}addOpenerStepId(){}addOpenerStep(){}getTabUtilsByTabIdAndSessionId(){}getTabUtilsByTabId(){return{}}getTabInfo(){return{}}getTabUtils(){return{}}getMainTabInfo(){}getMainTabUtils(){return{}}getMainTabId(){return null}async isMainTabExists(){return!1}clearAllTabs(){}async switchTab(){}async getTabDetails(){}async isMainTabIncognito(){return!1}async getTabIdByTabInfo(){return NaN}}});var ju,sa,vy=T(()=>{"use strict";B();ju=x("mobile-frame-locator-mock"),sa=class{foundFrameCallback(){return ju.info("foundFrameCallback-mock invoked"),{}}locate(){return ju.info("locate-mock invoked"),{}}async findFrame(){return ju.info("findFrame-mock invoked"),{}}}});var aS,Sy,Ey,ws,$u=T(()=>{"use strict";aS=E(require("webdriverio")),Sy=require("@applitools/eyes-sdk-core");wy();Cu();B();ku();Ou();be();Nu();vy();Uu();Ey=x("appium-test-player"),ws=class{constructor(e,t,r,n=aS,o=void 0,i=void 0){this.id=e;this.driver=n;let{SessionPlayer:a,commonConstants:c,StepActionFactory:l,MobileLocateElementPlayer:d}=ee(),m=new gs(this.driver);this.stepActionFactory=new l(m),ea(this.driver,this.stepActionFactory),this.playbackTimeoutCalculator=new Ts(ki()),this.sessionPlayer=new a(e,{tabService:new ra,cookieUtils:void 0,FrameLocator:sa,portSelector:Ci,LocateElementPlayer:d,stepActionUtils:m,stepActionFactory:this.stepActionFactory,playbackTimeoutCalculator:this.playbackTimeoutCalculator,makeSDK:Sy.makeSDK}),this.sessionPlayer.setShouldMonitorPerformance(Boolean(r)),this.sessionPlayer.playbackManager.isRemoteSession=!0,this.sessionPlayer.playbackManager.isLocalRun=!1,this.sessionPlayer.playbackManager.testRetryCount=o,this.sessionPlayer.playbackManager.previousTestResultId=i,this.sessionPlayer.playbackManager.userParamsData=t||{},this.onStepCompleted=this.onStepCompleted.bind(this),this.sessionPlayer.playbackManager.on(c.playback.RESULT,this.onStepCompleted)}onStepCompleted(e,t,r,n){}async onDone(){let{playbackManager:e}=this.sessionPlayer,{executionId:t,testResult:{resultId:r}={},appiumApi:n}=e,o={executionId:t,testResultId:r,sessionId:n==null?void 0:n.sessionId};try{await(n==null?void 0:n.endSession()),Ey.info("appium session deleted",o)}catch(i){Ey.error("error while deleting appium session",{...o,error:i})}finally{let{commonConstants:i}=ee();e.off(i.playback.RESULT),this.sessionPlayer=null,this.stepActionFactory=null,this.driver=null}}getSessionId(){var e;return(e=this.sessionPlayer.playbackManager.appiumApi)==null?void 0:e.sessionId}}});async function cS(s){return await Ne(`${s}/api/status`)}async function Ry(s,e){return await Ne(`${s}/api/devices/${e}/status`)}async function Iy(s){let e="";try{(await cS(s)).fsmState!=="Ready"&&(e="TMA is not ready")}catch{e="It seems that the TMA agent is offline."}if(e)throw new Error(e)}var xy=T(()=>{"use strict";Ve()});var Py={};G(Py,{WorkerLocalTma:()=>Hu});var Ay,kn,na,Wu,Gu,Vu,Hu,Cy=T(()=>{"use strict";Ay=E(require("jsdom"));Ve();kn=E(require("semver"));gn();Sn();j();B();At();$u();be();xy();ui();na=x("worker-appium"),Wu=class extends Error{},Gu=class extends Error{},Vu=class extends Error{},Hu=class extends tt{constructor(){super(...arguments);this.baseDevicePath=(t,r)=>`${t}/api/devices/${r}`}initPlayer(t){return new ws(this.id,t.runParams,this.options.shouldMonitorPerformance,void 0,t.retryCount,t.previousTestResultId)}initAndGetAppiumAPI(t){if(t.sessionPlayer.playbackManager.appiumApi)return t.sessionPlayer.playbackManager.appiumApi;let{AppiumApi:r}=ee(),n=new Ay.JSDOM("").window.DOMParser,o=new r(this.sessionData.serverAddress,this.sessionData.sessionId,n);return t.sessionPlayer.playbackManager.appiumApi=o,o}checkIfUpgradeIsNeeded(t,r,n){if(n)return!1;let[o,i]=[kn.coerce(t),kn.coerce(r)];return!o||!i?!1:kn.cmp(o,"!==",i)}async getBrowserOnce(t,r,n,o){var C;if(X.onGetSession(this.id,this.testName,t.runMode),!this.options.localTmaUrl||!this.options.deviceUdid)throw new Error("Missing localTmaUrl or deviceUdid");let{localTmaUrl:i,deviceUdid:a,projectData:c}=this.options;await Iy(i);let{project:l,authData:{token:d=""}={}}=this.options,{driver:m}=n,p=c.type,g=!1,f=this.options.appId;if(f){let{executionId:k,testResultId:R}=t,{mobileApp:M}=await pt.getMobileAppDataByAppId({appId:f,projectId:l,token:d,executionId:k,testResultId:R});t.nativeApp=M}let h=p==="android"?t.androidActivityWait:null,y=t.nativeAppMetadata,v=t.downloadableAppPublicLink,S=t.appPackageNameOrBundleId;if(!y)throw new Error("Application not specified. Please provide the required application for execution and try again.");if(!S)throw new Error("The application appears to be corrupted. Please ensure the application is in a valid state before running the test.");let[{appInstalled:b,version:w},I]=await Promise.all([this.getAppStateFromDevice(i,a,S),Ry(i,a)]).catch(k=>{throw this.handleDeviceNotFoundError(k),k});if(!b&&t.isAppFromDevice&&!f)throw new Error("The application is not installed on the target device. Please ensure the application is installed and try again.");!b&&v&&await this.installApp(i,a,v),b&&(!t.isAppFromDevice||f)&&(g=this.checkIfUpgradeIsNeeded(w,y.version,I.isVirtual));try{let k={testName:this.testName,executionId:this.executionId,testResultId:this.testResultId,project:`${(C=this.options.projectData)==null?void 0:C.name}-${this.options.project}`},R=rg({projectType:p,nativeAppMetadata:y,appPath:v,androidActivityWait:h,sessionTags:k,gridInfo:o,options:this.options,testRunConfig:this.testRunConfig}),M={capabilities:{udid:a,...R}},O=await this.requestNewAppiumSessionFromTma(i,M,y);if(this.sessionData=O,g){let $=this.initAndGetAppiumAPI(n);await $.removeApp(S),await this.installApp(i,a,v),await $.activateApp({[p==="ios"?"appId":"bundleId"]:S})}let D=await m.attach({sessionId:O.sessionId,capabilities:R});this.device=await pt.updateTmaDeviceDetails(a,this.options,t),na.info(`init new appium session with local TMA testName: ${this.testName}`,{sessionId:D.sessionId,testResultId:this.testResultId,nativeAppMetadata:y,sessionCaps:D.capabilities})}catch(k){throw na.error("failed to start application",{err:k}),k}}async requestNewAppiumSessionFromTma(t,r,n){var o,i;try{let a=await je({url:`${t}/api/session`,headers:{"Content-Type":"application/json"},body:r,timeout:6e4}),c={name:n.name,version:n.version};return{...a,appInfo:c,env:"local"}}catch(a){this.handleDeviceNotFoundError(a);let c=(i=(o=a.response)==null?void 0:o.body)==null?void 0:i.message;throw a.status===500&&typeof c=="string"&&c.startsWith("Failed to create driver session")?new Vu(c):a}}async getAppStateFromDevice(t,r,n){let o=this.options.projectData.type==="ios"?"bundles":"apps",i=`${this.baseDevicePath(t,r)}/${o}`,c=(await Ne(i)).find(l=>"id"in l?l.id===n:l.packageName===n);return c?{appInstalled:!0,version:c.version}:{appInstalled:!1,version:""}}async installApp(t,r,n){var o,i;try{let a=await _t(n);await Ls(`${this.baseDevicePath(t,r)}/apps`,{},{file:{buffer:a.body,fileName:"app"}})}catch(a){this.handleDeviceNotFoundError(a);let c=(i=(o=a.response)==null?void 0:o.body)==null?void 0:i.message,l="Failed to install app";throw c&&(l=`${l}: ${c}`),new Gu(l,{cause:a})}}handleDeviceNotFoundError(t){var n,o;let r=(o=(n=t.response)==null?void 0:n.body)==null?void 0:o.message;if(t.status===404&&typeof r=="string"&&(r!=null&&r.startsWith("Ensure that the requested device")))throw new Wu(`Device Unavailable: Please ensure that the specified device ${this.options.deviceUdid} is currently connected`)}async runTestOnce(t,r){let{manifestVersion:n,localAssetService:o}=ee(),{sessionPlayer:i}=r,a=n||"runner";X.onWaitToTestComplete(this.id),i.playbackManager.executionId=t.executionId,i.playbackManager.executionName=t.executionName,i.playbackManager.appiumSessionData={...this.sessionData,device:this.device},this.initAndGetAppiumAPI(r),o.initialize({serverUrl:this.options.localRCASaver});let c=async()=>{try{let l=await new Promise((m,p)=>{i.playByTestId({testId:this.testId,executionId:this.executionId,resultId:this.testResultId,baseUrl:this.baseUrl,userData:this.userData,version:a,resolve:m,isLocalRun:!1,overrideTestConfigId:this.overrideTestConfigId,branch:this.branch,remoteRunId:t.remoteRunId}).catch(p)});return await o.drain(),l.stepsResults=null,l.resultId=this.testResultId,{...l,...t.seleniumPerfStats.getStats()}}catch(l){throw na.error("error while running appium tests",{err:l}),l}};try{return await super.runTestOnce(t,r),await c()}catch(l){throw na.error("failed to run test once",{err:l}),l}}}});var Oy={};G(Oy,{WorkerAppium:()=>qu});var ky,On,qu,_y=T(()=>{"use strict";gn();ky=require("linkedom");Sn();B();At();$u();be();ui();ce();On=x("worker-appium"),qu=class extends tt{initPlayer(t){return new ws(this.id,t.runParams,this.options.shouldMonitorPerformance,void 0,t.retryCount,t.previousTestResultId)}async getBrowserOnce(t,r,n,o){X.onGetSession(this.id,this.testName,t.runMode);let{driver:i}=n,a=this.options.projectData.type,{appPath:c,isTdcAppIdExists:l,isHSAppIdExists:d}=await pt.getAppInfoForRemoteRun({testRunHandler:t,options:this.options}),m=a==="android"?t.androidActivityWait:null,p=t.nativeAppMetadata;if(!p)throw new Error("Application not specified. Please provide the required application for execution and try again.");try{let g={testName:this.testName,executionId:this.executionId,testResultId:this.testResultId,project:`${this.options.projectData.name}-${this.options.project}`,...this.options.customTag&&{customTag:this.options.customTag}},f={projectType:a,nativeAppMetadata:p,appPath:c,androidActivityWait:m,sessionTags:g,gridInfo:o,options:this.options,testRunConfig:this.testRunConfig,isHSAppIdExists:d,isTdcAppIdExists:l},h;this.options.skipLoadBalancer&&this.options.deviceUdid?(this.options.lockDevice&&await pt.lockDevice(o,this.options.deviceUdid),h=await ng(f)):h=sg(f),On.info("starting appium session",{testResultId:this.testResultId,executionId:this.executionId,sessionTags:g,nativeAppMetadata:p,capabilities:og(h)}),this.activeSession=await i.remote(h),this.device=await pt.updateDeviceOnRemoteTestResult(t,this.activeSession,this.options),On.info("appium session started successfully",{sessionId:this.activeSession.sessionId,testResultId:this.testResultId,executionId:this.executionId,sessionCaps:this.activeSession.capabilities})}catch(g){throw On.error("failed to start application",{testResultId:this.testResultId,executionId:this.executionId,err:g}),g}}getServerAddressFromGrid(){let{host:t,port:r,accessToken:n,type:o}=this.options.gridData;return o===N.TESTIM_HEADSPIN||o===N.TESTIM_TDC?`https://${t}:${r}/v0/${n}/wd/hub`:`https://${t}:${r}/wd/hub`}getDirectAddressConnection(t){let{directConnectProtocol:r,directConnectHost:n,directConnectPort:o,directConnectPath:i}=t;if(r&&n&&o&&i)return`${r}://${n}:${o}${i}`}async runTestOnce(t,r){var p,g;let{manifestVersion:n,AppiumApi:o,localAssetService:i}=ee(),{sessionPlayer:a}=r,c=n||"runner";X.onWaitToTestComplete(this.id),a.playbackManager.executionId=t.executionId,a.playbackManager.executionName=t.executionName;let l;if(this.options.skipLoadBalancer){let f=this.options.deviceUdid||((p=this.testRunConfig.mobile)==null?void 0:p.staticAllocation.deviceUdid),{protocol:h,hostname:y,port:v,path:S}=await pt.getHeadSpinDeviceConnection(this.options.gridData,f);l=`${h}://${y}:${v}${S}`}else l=this.getDirectAddressConnection(this.activeSession.capabilities)||this.getServerAddressFromGrid();let d=this.activeSession.capabilities;a.playbackManager.appiumSessionData={env:"remote",capabilities:d,sessionId:this.activeSession.sessionId,sessionToken:this.options.gridData.accessToken,gridType:this.options.gridData.type,projectType:this.options.projectData.type,gridId:this.options.gridData.gridId,companyId:(g=this.options.company)==null?void 0:g.companyId,device:this.device},a.playbackManager.appiumApi=new o(l,this.activeSession.sessionId,ky.DOMParser),i.initialize({serverUrl:this.options.localRCASaver});let m=async()=>{try{let f=await new Promise((y,v)=>{a.playByTestId({testId:this.testId,executionId:this.executionId,resultId:this.testResultId,baseUrl:this.baseUrl,userData:this.userData,version:c,resolve:y,isLocalRun:!1,overrideTestConfigId:this.overrideTestConfigId,branch:this.branch,remoteRunId:t.remoteRunId}).catch(v)});return await i.drain(),f.stepsResults=null,f.resultId=this.testResultId,{...f,...t.seleniumPerfStats.getStats()}}catch(f){throw On.error("error while running appium tests",{testResultId:this.testResultId,executionId:this.executionId,err:f}),f}};try{return await super.runTestOnce(t,r),await m()}catch(f){throw On.error("failed to run test once",{err:f}),f}}}});var oa,Ly=T(()=>{"use strict";j();bn();z();oa=class{constructor(e){this.id=e;this.driver=new Sr}async onDone(){try{await ae(this.driver.end(),12e4)}catch(t){t instanceof re&&await this.driver.forceEnd().catch(()=>null)}this.driver=null}getSessionId(){return this.driver.getSessionId()}}});var Dy,ia,My=T(()=>{"use strict";Dy=E(require("ws"));j();ia=class{constructor(){this._cdpWs=null;this._cdpUrl=null;this._cdpCallbacks=new Map}async initSession(e,t=500){await this.stopSession(),this._cdpUrl=e,await this.initCDPWebsocket(t)}async initCDPWebsocket(e=500){if(this._cdpWs)return this._cdpWs;let t=new Dy.default(this._cdpUrl,{timeout:e}),r=Vt(o=>{t.once("open",o)}),n=Vt(o=>{t.once("error",o)}).catch(()=>{t.close(),t.removeAllListeners()});return t.on("message",o=>this.onCDPMessage(o)),this._cdpWs=Promise.race([r,n]).then(()=>t),this._cdpWs}onCDPMessage(e){var n;let t=JSON.parse(e),r=this._cdpCallbacks.get(t.id);r&&(this._cdpCallbacks.delete(t.id),t.error?r.reject(new Error(t.error)):(n=t.result.exceptionDetails)!=null&&n.exception?r.reject(new Error(t.result.exceptionDetails.exception.description)):r.resolve(t.result))}async stopSession(){let e=this._cdpWs;if(this._cdpUrl=null,this._cdpWs=null,this._cdpCallbacks.clear(),e)try{return(await e).close()}catch{return}}async cdpCommand(e,t,r){let n=await this.initCDPWebsocket();this._lastWsId||=0;let o=this._lastWsId++,i=new Promise((c,l)=>{this._cdpCallbacks.set(o,{resolve:c,reject:l})}),a={method:e,params:t,id:o};return r&&Object.assign(a,{sessionId:r}),n.send(JSON.stringify(a)),i}}});var ca,zu,aa,Ny=T(()=>{"use strict";j();ca=E(require("chrome-launcher"));gn();My();en();zu=class{constructor(e){this.sessionId=e;this._isAlive=!1;this.cdpTestRunner=new ia}async init(e,t,r,n,o,i,a,c,l,d){var f,h,y,v;let m=di(e,t,r,n,o,i,a),p=[...((f=m.desiredCapabilities)==null?void 0:f.chromeOptions.args)??[],...((v=(y=(h=m.capabilities)==null?void 0:h.alwaysMatch)==null?void 0:y["goog:chromeOptions"])==null?void 0:v.args)??[],...ca.Launcher.defaultFlags().filter(S=>S!=="--disable-extensions")];this.chrome=await ca.launch({chromeFlags:p,startingUrl:void 0,ignoreDefaultFlags:!0}),this.chrome.process.once("exit",()=>{this._isAlive=!1}),this.chrome.process.once("close",()=>{this._isAlive=!1}),this._isAlive=!0;let g=await mr(`localhost:${this.chrome.port}`);await this.cdpTestRunner.initSession(g),Yr(()=>this.chrome.kill())}isAlive(){return this._isAlive}start(){}async stop(){await this.cdpTestRunner.stopSession(),this.chrome&&await this.chrome.kill(),this._isAlive=!1}getSessionId(){return this.sessionId}},aa=class{constructor(e){this.id=e;this.sessionId=te();this.driver=new zu(this.sessionId)}async onDone(){return this.driver.stop()}getSessionId(){return this.sessionId}}});var Fy={};G(Fy,{WorkerExtension:()=>_n});function lS(s){return s instanceof Error&&"type"in s&&typeof s.type=="string"}function Uy(s){return lS(s)?s:new Error(s)}var rt,_n,Ku=T(()=>{"use strict";Fe();z();Sn();j();B();At();ce();Ly();Ny();rt=x("worker-ext"),_n=class extends tt{initPlayer(){return this.options.useChromeLauncher?new aa(this.id):new oa(this.id)}async _getBrowserOnce(e,t,r,n){var i;let{driver:o}=r;try{return await o.init(this.options,this.testName,this.testRunConfig,n,t,this.executionId,this.testResultId,e.seleniumPerfStats,(i=this.options.lightweightMode)==null?void 0:i.general,this.lambdatestService)}catch(a){throw rt.error("failed to get browser",{err:a,gridInfo:n,testId:e.testId,resultId:e.testResultId}),a}}async getBrowserOnce(e,t,r,n){return X.onGetSession(this.id,this.testName,e.runMode),this._getBrowserOnce(e,t,r,n)}isUsingChromeLauncher(e){return Boolean(this.options.useChromeLauncher)}async updateTestStatusOnGrid(e,t,r){var o;let n=t?"passed":"failed";if(this.lambdatestService.isLambdatestRun()&&await e.executeJS(`lambda-status=${n}`),"browserstack"in this.options&&((o=this.options.browserstack)!=null&&o["browserstack.user"])){let i={action:"setSessionStatus",arguments:{status:n,reason:r}};await e.execute(`browserstack_executor: ${JSON.stringify(i)}`)}}async runTestOnce(e,t){let{testResultId:r,executionId:n,testId:o}=this;L("WorkerExtension runTestOnce");let i=async d=>{let m=this.options.timeoutWasGiven?Math.max(1e4,this.options.timeout):this.options.testStartTimeout;try{return await ae(e.runTestUsingCDP(d.cdpTestRunner),m,$e.TEST_START_TIMEOUT_MSG)}catch(p){if(!(p instanceof re))throw p;return rt.warn("timeout while running test using CDP. Running checkViaRestAPIIfTestStarted",{testResultId:r}),await e.checkViaRestAPIIfTestStarted()}},a=async(d,m,p)=>{try{let g=await d.url(m);return p.driverUrlFinished=!0,g}catch(g){throw rt.error("error from driver.url",{err:g,testResultId:r,executionId:n,testId:o,url:m,urlLength:m.length}),g}},c=async d=>{let m=await e.onStarted(this.options.testStartTimeout);return d.testRunHandlerOnStartedHadFinished=!0,m},l=async()=>{var g;if(L("WorkerExtension runExtTest"),((g=this.options.lightweightMode)==null?void 0:g.disableRemoteStep)||this.options.disableSockets||e.listenToRemoteStep(t.driver),this.isUsingChromeLauncher(t)){X.onWaitToTestStart(this.id),X.onWaitToTestComplete(this.id);try{return{...await i(t.driver),...e.seleniumPerfStats.getStats()}}catch(f){throw rt.warn("failed to run test via CDP",{err:f}),f}}let{driver:m}=t,p={driverUrlFinished:!1,testRunHandlerOnStartedHadFinished:!1};try{let f=await e.getRunTestUrl();X.onWaitToTestStart(this.id);try{await ae(Promise.all([a(t.driver,f,p),c(p)]),this.options.testStartTimeout,$e.TEST_START_TIMEOUT_MSG)}catch(v){if(!(v instanceof re))throw v;rt.warn("timeout occurred (see log's payload). Running checkViaRestAPIIfTestStarted",{testResultId:r,executionId:n,testId:o,...p}),await e.checkViaRestAPIIfTestStarted()}X.onWaitToTestComplete(this.id);let h=new AbortController,y=v=>{e.onCompletedCleanup(),rt.warn("on browser closed error detected",{err:v,testResultId:r,executionId:n,testId:o}),m.unregisterToClosedBrowser(y),v.type=Ms.BROWSER_CLOSED,h.abort(v)};m.registerToClosedBrowser(y);try{let v=ae(e.onCompleted(),this.testRunTimeout,$e.TEST_COMPLETE_TIMEOUT_MSG),S=await Ma(v,h.signal);m.unregisterToClosedBrowser(y);try{await this.updateTestStatusOnGrid(m,Boolean(S.success),S.reason)}catch(I){rt.error("Could not update the grid about the test status",{err:I})}m.isAlive()||(rt.warn(`possible grid unresponsive for test ${this.testId}, result ${this.testResultId} (execution: ${this.executionId})`),S.gridIssues="could not validate grid is alive");let b=m.maxKeepAliveGap();return b>=3e4&&(rt.warn(`possible browser keep alive issue ${this.testId}, result ${this.testResultId} (execution: ${this.executionId})`),S.keepAliveIssue=b),{...S,...e.seleniumPerfStats.getStats()}}catch(v){throw rt.warn("timeout wait until test completed",{err:v,testResultId:r,executionId:n,testId:o}),Uy(v)}finally{m.unregisterToClosedBrowser(y)}}catch(f){throw rt.warn("failed to start url",{err:f}),Uy(f)}};t.driver.start();try{return await super.runTestOnce(e,t),L("WorkerExtension super.runTestOnce"),await l()}catch(d){throw rt.error("failed to run test",{err:d,testId:e.testId,resultId:e.testResultId}),d}}}});var By={};G(By,{WorkerExtensionSingleBrowser:()=>Ju});var uS,pS,Ju,jy=T(()=>{"use strict";Fe();j();B();Tu();At();Ku();uS=x("base-worker"),pS=500,Ju=class extends _n{async _releasePlayer(){if(!this.testPlayer)return;let{projectId:t}=this.userData||{};await vn(this.id,this.releaseSlotOnTestFinished,t,this.testPlayer),this.testPlayer=null}onQueueCompleted(){return this._releasePlayer()}async getBrowserOnce(t,r,n,o){return X.onGetSession(this.id,`worker ${this.id}`,t.runMode),this._getBrowserOnce(t,r,n,o)}async getTestPlayer(t,r){return this.testPlayer&&!this.testPlayer.driver.isAlive()&&(uS.warn("WorkerExtensionSingleBrowser is releasing a dead player",{workerId:this.id}),await this._releasePlayer()),this.testPlayer||(this.testPlayer=await super.getTestPlayer(t,r)),this.testPlayer}async runTest(t,r,n){let o=this.handleQuarantine(t);if(o)return o;L("before runTest onTestStarted single browser");let i=await this.onTestStarted(this.id,t.testId,t.testResultId,n,t.retryKey);t.baseUrl=i.config.baseUrl;let a=await this.getTestPlayer(t,r);return t.markClearBrowser(),await this.runTestOnce(t,a)}async runTestCleanup(){var t;if(!this.executionQueue.hasMoreTests()){await this.onQueueCompleted();return}(t=this.options.lightweightMode)!=null&&t.general&&await oe(pS)}}});function dS(s,e){e===0?s():setTimeout(s,e*Rp)}var Yu,la,$y=T(()=>{"use strict";bn();le();Fe();Hl();Rt();cu();z();B();ce();qg();Yu=x("parallel-worker-manager"),la=class{constructor(e){this.customExtensionLocalLocation=e}getWorkerType(e){switch(e.mode){case Y.SELENIUM:return(Ty(),fe(by)).WorkerSelenium;case Y.APPIUM:return e.localTmaUrl?(Cy(),fe(Py)).WorkerLocalTma:(_y(),fe(Oy)).WorkerAppium;default:return gi.isFeatureAvailableForProject("useSameBrowserForMultiTests")?(jy(),fe(By)).WorkerExtensionSingleBrowser:(Ku(),fe(Fy)).WorkerExtension}}createWorkers(e,t,...r){let n=r[0],o=this.getWorkerType(n),i=()=>{try{return L("before new Worker",n.mode),new o(t,...r)}finally{L("after new Worker",n.mode)}};return Array.from(new Array(e),i)}async runTests(e,t,r,n,o,i,a,c,l){if(e&&e.length===0)return;let d=!1,m=0,p=g=>new Promise(f=>{var ht,Pr,A,_,F,H,st,ga;let h=o.project,y=new Ei(r,n,e,o,i,t),v={},S=e.length,b=((ht=o.company)==null?void 0:ht.ucid)||"",w=(Pr=o.company)==null?void 0:Pr.companyId,I=(A=o.company)==null?void 0:A.name,C=o.source||"cli",k=o.user,R=(_=o.company)==null?void 0:_.planType,M=(F=o.company)==null?void 0:F.isStartUp,O=(H=o.projectData)==null?void 0:H.name,D=(st=o.projectData)==null?void 0:st.type,$=o.lightweightMode,V=(ga=o.gridData)==null?void 0:ga.type,J=(kt,nt,he,ha,Dn,ya)=>(m++,Tf({executionId:r,projectId:h,testId:nt,resultId:he,ucid:b,companyId:w,companyName:I,projectName:O,companyPlan:R,source:C,user:k,lightweightMode:$,isStartUp:M,projectType:D,appSource:ya,gridType:V}),t.testStartAndReport(kt,r,he,ha,Dn)),Q=async(kt,nt,he,ha,Dn,ya)=>{var ap,cp,lp;m--;let Xe={...($==null?void 0:$.onlyTestIdsNoSuite)&&{show:!0},...he.seleniumStats&&{seleniumStats:he.seleniumStats},...he.gridIssues&&{gridIssues:he.gridIssues},...he.keepAliveIssue&&{keepAliveIssue:he.keepAliveIssue},...o.host&&{gridHost:o.host}};if(he.seleniumPerfMarks&&(t.concatSeleniumPerfMarks(he.seleniumPerfMarks),delete he.seleniumPerfMarks),o.grid||o.gridId?(Xe.gridName=o.grid||((ap=o.gridData)==null?void 0:ap.name),Xe.gridType=(cp=o.gridData)==null?void 0:cp.type,Xe.gridProvider=(lp=o.gridData)==null?void 0:lp.provider):o.localTmaUrl?(Xe.gridName="local-tma-from-options",Xe.gridType="local-tma"):o.useLocalChromeDriver?(Xe.gridName="local-chrome-driver-from-options",Xe.gridType="local-chrome"):o.useChromeLauncher?(Xe.gridName="chrome-launcher-from-options",Xe.gridType="local-chrome"):o.browserstack?Xe.gridName="browserstack-from-options":o.saucelabs&&(Xe.gridName="saucelabs-from-options"),await t.testEndAndReport(kt,he,r,ha,Dn,Xe).catch(Db=>Yu.error("testEndAndReport threw an error",{err:Db})),Dn)return;v[he.resultId]=he,wf({executionId:r,projectId:h,testId:nt,resultId:he.resultId,result:he,ucid:b,companyId:w,companyName:I,projectName:O,companyPlan:R,source:C,user:k,lightweightMode:$,logger:Yu,isStartUp:M,projectType:D,appSource:ya}),l&&!he.success&&(y.stop(),d=!0),(Object.keys(v).length===S||d&&m===0)&&f(v)},de=(kt,nt)=>{v[nt.resultId]=nt,t.onTestIgnored(kt,nt.resultId),m--,(Object.keys(v).length===S||d&&m===0)&&f(v)},$t=(kt,nt)=>t.onGridSlot(kt,nt);o.userData={loginData:Object.assign({},Mt(),{refreshToken:wo(),authData:Mt(),token:g}),projectId:o.project,company:o.company,servicesUrl:me},L("in localStrategy before createWorker"),this.createWorkers(c,y,o,this.customExtensionLocalLocation,r,J,Q,$t,de).forEach((kt,nt)=>{L("before schedule worker.run after createWorkers"),dS(()=>{L("right before worker.run"),kt.run()},nt)})});try{let g=await Kt(),f=await p(g);if(d)throw new Gt;return f}catch(g){throw Yu.error("failed running parallel workers",{executionId:r,err:g}),g}}}});async function Gy(s,e){var t;return(t=s.lightweightMode)!=null&&t.onlyTestIdsNoSuite&&s.testId?{tests:[s.testId.map(n=>({testId:n,testConfig:{},resultId:te()}))]}:await Cc({projectId:s.project,labels:s.label,testIds:s.testId,testNames:s.name,testConfigNames:s.testConfigNames,suiteNames:s.suites,suiteIds:s.suiteIds,branch:e,rerunFailedByRunId:s.rerunFailedByRunId,testConfigIds:s.testConfigIds,intersections:s.intersections})}function Xu(s){let e=Object.keys(s).length,t=Object.keys(s).reduce((r,n)=>r+(s[n].success===!0?1:0),0);return e===t}async function Qu(s,e){let t=s.mode==="extension"?["edge-chromium","chrome"]:["firefox","chrome","edge-chromium","safari","safari technology preview","browser","android","ios","iphone","ipad"],r=Wy.difference(Ns(s,e),t);if(r.length>0)throw lt("invalid-config-run",{browser:r.join(", "),mode:"runner"}),new P(`browser type <${r}> is not supported in ${s.mode} mode.`);return e}var Wy,Vy=T(()=>{"use strict";Wy=E(require("lodash"));j();Xr();ye();z()});var Ln,b_,Zu,ep,ua,Hy=T(()=>{"use strict";Ln=E(require("lodash"));j();B();le();ce();Fe();ts();Cl();Hl();ye();Rt();At();$f();z();$y();Vy();({testRunStatus:b_,CLI_MODE:Zu}=Lt),ep=x("test-plan-runner"),ua=class{constructor(e){this.startTime=Date.now();this.workerManager=new la(e)}async runTestAllPhases(e,t,r,n,o,i,a,c){let l={},d=Mt(),m=async()=>{let h=o.beforeParallel||1,y=!0,v=await this.workerManager.runTests(e,c,i,a,o,n,d,h,y);Object.assign(l,v)},p=async()=>{let h=zn||o.parallel,y=!1;L("right before this.workerManager.runTests");let v=await this.workerManager.runTests(t,c,i,a,o,n,d,h,y);L("right after this.workerManager.runTests"),Object.assign(l,v)},g=async()=>{let h=o.afterParallel||1,y=!1,v=await this.workerManager.runTests(r,c,i,a,o,n,d,h,y);Object.assign(l,v)};vf({executionId:i,projectId:o.project}),L("right before runBeforeTests");try{return await m(),L("right before runTestPlanTests"),await p(),L("right after runTestPlanTests"),await g(),l}catch(h){if(ep.error("error running test plan",{err:h}),h instanceof Gt)return c.markAllQueuedTests(i,pe.ABORTED,"aborted",!1);throw h}finally{await f()}async function f(){var y,v,S,b;if((y=o.lightweightMode)!=null&&y.disablePixelValidation)return;if(o.mode===Zu.SELENIUM){let[{getSessionPlayer:w},{makeSDK:I}]=await Promise.all([Promise.resolve().then(()=>(be(),Yt)),import("@applitools/eyes-sdk-core")]),{EyeSdkBuilder:C}=w();await C.closeBatch(i,I);return}let h;try{if(!((b=(S=(v=o.company)==null?void 0:v.activePlan)==null?void 0:S.premiumFeatures)!=null&&b.applitools)||(h=await qc(o.project),Ln.default.isEmpty(h)||!i))return;let{runKey:w,url:I}=h;await require("@applitools/eyes-sdk-core").makeSDK({name:"Testim.io",version:"4.0.0",spec:{}}).closeBatches({settings:{batchIds:[i],serverUrl:I,apiKey:w}})}catch{}}}async runTestPlan(e,t,r,n,o,i,a,c){var b,w,I;let l=te(),d=n.project;ka(l),e.forEach(C=>Object.assign(C,{isBeforeTestPlan:!0})),r.forEach(C=>Object.assign(C,{isAfterTestPlan:!0}));let m=[...e,...t,...r],p=new li(m,n,i,a),g=Ln.default.chain(m).map(C=>{var k;return((k=C.overrideTestConfig)==null?void 0:k.name)||""}).uniq().compact().value(),f=(g==null?void 0:g.length)===1?g[0]:null,h=(b=n.lightweightMode)!=null&&b.onlyTestIdsNoSuite?[]:m.map(C=>C.name),y=(w=n.lightweightMode)!=null&&w.onlyTestIdsNoSuite?{beforeTests:e,tests:t,afterTests:r}:p.executionStart(l,d,this.startTime,o,h);L("before testListInfoPromise");let v=await y;(I=n.lightweightMode)!=null&&I.onlyTestIdsNoSuite||X.onTestPlanStarted(v.beforeTests,v.tests,v.afterTests,o,l,c,f),L("before runTestAllPhases");let S=await this.runTestAllPhases(v.beforeTests,v.tests,v.afterTests,a,n,l,o||"All Tests",p);return L("before executionEnd"),await p.executionEnd(l),L("after executionEnd"),{results:S,executionId:l,testPlanName:o,configName:f}}async runTestPlans(e,t){ep.info("start to run test plan",{options:Object.assign({},e,{token:void 0,userParamsData:void 0}),branchToUse:t});function r(d){return Ln.default.flattenDeep(Object.values(d)).reduce((m,p)=>m.concat(p.beforeTests,p.tests,p.afterTests),[])}let n={},o={},i=e.project,a=await Pc(i,e.testPlan,e.testPlanIds,t,e.intersections),c=a.testPlans,l=a.testPlansData;if(!c||c.length===0)throw new P(`no test plan to run ${e.testPlan}`);if(!l||Object.keys(l).length===0){if(e.passZeroTests)return[];throw new P(`no test to run in test plan ${e.testPlan}`)}return e.mode!==Zu.APPIUM&&await Qu(e,r(l)),await ie(c,async d=>{var f;let m=d.testPlanId;n[m]={};let p=Object.assign({},e);p.baseUrl||=d.startUrl,p.appId||=((f=d.mobileApp)==null?void 0:f.appId)||void 0,p.gridId||=d.gridId,e.grid&&delete p.gridId,p.gridData=await ef(e,d);let g=p.overrideExecutionName||d.name;return await ie(l[m],async h=>{let y=await this.runTestPlan(h.beforeTests,h.tests,h.afterTests,p,g,m,t);X.onTestPlanFinished(y.results,d.name,this.startTime,y.executionId,!1),n[m][y.executionId]=y.results;let v=Object.keys(n[m]).map(I=>({executionId:I,status:Xu(n[m][I])})),S=Object.keys(n[m]).map(I=>n[m][I]).reduce((I,C)=>Object.assign(I,C),{}),b=Xu(S);Object.assign(o,S);let w=b?v[0].executionId:v.find(I=>!I.status).executionId;return await Ic(i,m,{success:b,executions:v,executionId:w}),y})})}async runAnonymousTestPlan(e,t){var a;ep.info("start to run anonymous",{options:Object.assign({},e,{token:void 0}),branchToUse:t}),L("before getSuite");let r=await Gy(e,t);if(L("after getSuite"),!((a=r==null?void 0:r.tests[0])!=null&&a.length)){if(e.rerunFailedByRunId)throw new P("No failed tests found in the provided run");if(e.passZeroTests)return[];throw new P("No tests to run")}t="branch"in r&&r.branch||t;let n=r;if(e.rerunFailedByRunId&&!n.runName){if(!n.runExists)throw new P("Invalid run ID - no such run.");n.runName===""&&(n.runName=`rerun-${e.rerunFailedByRunId}`)}let o=e.overrideExecutionName||n.runName||[].concat(e.label,e.name,e.suites).join(" "),i=!0;return L("Right before validateConfig + runAnonymousTestPlan tests map"),await ie(r.tests,async c=>{if(e.resultId){let d=c[0];d.resultId=e.resultId,c=[d]}e.mode!==Zu.APPIUM&&await Qu(e,c),L("right before runTestPlan");let l=await this.runTestPlan([],c,[],e,o,null,t,i);return L("right after runTestPlan"),await X.onTestPlanFinished(l.results,o,this.startTime,l.executionId,i),l})}async run(e){let t=ln(),r=[];Us(e)?r=await this.runTestPlans(e,t):r=await this.runAnonymousTestPlan(e,t);let n=Ln.default.flattenDeep(r);return L("right before onAllTestPlansFinished"),await X.onAllTestPlansFinished(n),L("right after onAllTestPlansFinished"),n.map(o=>o.results).reduce((o,i)=>Object.assign(o,i),{})}}});var Jy={};G(Jy,{init:()=>OS,run:()=>CS});async function fS(s){let e=s.project,t=await Oc(e);if(t!=null&&t.isExecutionBlocked)throw console.error("You have reached the limit of runs for the billing month, please upgrade your plan at https://www.testim.io/upgrade-contact-us?source=cli"),tn(s.authData.uid,"execution-quota-surpassed",{projectId:e}),new Ps}function gS(s,e){var i,a,c,l,d,m;let t=ro(e.activePlan),r=s.parallel;if(t==="free"&&r>zy)throw new P(`The free plan allows only ${zy} parallel runs, please upgrade your plan at https://www.testim.io/upgrade-contact-us?source=cli. Run aborted`);if(e.followL2CPlan){let p=(a=(i=e.activePlan)==null?void 0:i.premiumFeatures)==null?void 0:a.tunnel;if(s.tunnel&&!p)throw new P("Tunnel is not allowed for your current plan, please upgrade your plan at https://www.testim.io/upgrade-contact-us?source=cli. Run aborted");let g=(l=(c=e.activePlan)==null?void 0:c.premiumFeatures)==null?void 0:l.runInTurboMode;s.lightweightMode&&!g&&(console.warn(`
|
|
408
408
|
Turbo mode is not allowed for your current plan, please upgrade your plan at https://www.testim.io/upgrade-contact-us?source=cli. Turbo mode disabled for this run.`),s.lightweightMode=void 0)}let n=s.retentionDays;if(!n)return;let o=(m=(d=e.activePlan)==null?void 0:d.premiumFeatures)==null?void 0:m.resultRetention;if(n>o)throw new P(`Retention days (${n}) cannot be greater than the company's retention days (${o}). Run aborted`)}async function hS(s){var e;if(!((e=s.lightweightMode)!=null&&e.disableQuotaBlocking))try{await fS(s)}catch(t){if([P,Ps].some(r=>t instanceof r))throw t;mS.error("could not validate cli account",{err:t})}}function yS(s){let e=Mt();return cm({userId:e.uid,name:e.uid,traits:{projectId:s,company:{id:s,lastCIRun:Math.floor(Date.now()/1e3)}}})}async function bS(s,{disableResults:e=!1,disableRemoteStep:t=!1}){if(U.flags.useNewWSCLI.isEnabled()&&!e&&!t)return ft.connect(s);if(!t){let{remoteStepService:r}=await Promise.resolve().then(()=>(Ti(),Ng));await r.init(s)}if(!e){let{testResultService:r}=await Promise.resolve().then(()=>(wi(),Bg));r.init(s)}}function TS(s,e){let{branch:t,autoDetect:r}=s;if(nf(e,r),!e&&!r)throw new P(`branch ${t} does not exist, run aborted.`)}async function wS(s){let{project:e}=s,t=ln();Ky.get(s,"company.activePlan.premiumFeatures.ttaForSalesforce")&&(s.sfdcCredential=await Sc({projectId:e,branch:t}))}function vS(s,e){let{onprem:t,id:r,storageBaseUrl:n,storageType:o,name:i,activePlan:a={}}=e;if(t){let{mode:m,extensionPath:p,ext:g,playerPath:f}=s;if([Y.SELENIUM].includes(m)&&!f)throw new P("in selenium on prem mode --player-path must be provided");if(m==="extension"&&!p&&!g)throw new P("In extension on prem mode --ext or --extension-path must be provided")}let c=Boolean(a.isPoc),l=Boolean(a.isStartUp),d=ro(a);d==="free"&&(s.newBrowserWaitTimeout=s.newBrowserWaitTimeout<qy?qy:s.newBrowserWaitTimeout),U.setCompanyId(r),U.setIsPOC(c),U.setIsStartUp(l),U.setPlanType(d),xt.setPlanType(d),s.company={ucid:"",companyId:r,onprem:t,storageBaseUrl:n,storageType:o,name:i,planType:d,isPOC:c,isStartUp:l,activePlan:a}}function ES(s,e){if(kr){s.editorUrl=kr;return}s.editorUrl=e.editorUrl}function SS(s,e){s.allGrids=e}function RS(s,e){s.authData=e}function IS(s,e){let{id:t,name:r,type:n,defaults:o}=e;U.setProjectId(t),U.setProjectType(n),s.projectData={projectId:t,type:n,name:r,defaults:o}}async function xS(s){s.gridData=await tf(s)}async function AS(s){let{project:e}=s,t={projectId:e};s.overrideMappingFile&&(lt("user-override-file",t),s.mockNetworkRules=await Yd(s.overrideMappingFile))}async function PS(s,e){L("in runner.js runRunner");let{project:t,remoteRunId:r,useLocalChromeDriver:n,useChromeLauncher:o}=s;r||(s.source=n||o?"cli-local":"cli"),await km(),L("in runner.js after checkNpmVersion"),await hS(s),L("in runRunner before tunnel.connect"),await Go(s),L("in runRunner after tunnel.connect");let a=await new ua(e).run(s);return L("before tunnel.disconnect"),await Vo(s),await an.end(t),L("after tunnel.disconnect and gridService.keepAlive.end"),a}function kS(s){var e;xt.shouldShowFreeGridRunWarning((e=s.gridData)==null?void 0:e.type)&&console.log(`
|
|
409
409
|
\x1B[4m\x1B[36mOur Free grid offers basic service performance.
|
|
410
410
|
If you need faster results, contact us to upgrade your plan and dramatically improve your tests\u2019 run times.\x1B[0m
|