@checksum-ai/runtime 1.4.4 → 1.4.5
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/.env +1 -1
- package/cli.js +1 -1
- package/package.json +1 -1
- package/test-run-monitor.js +1 -1
package/.env
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
CHECKSUM_RUNTIME_BUILD_TIME=2025-11-
|
|
1
|
+
CHECKSUM_RUNTIME_BUILD_TIME=2025-11-10T06:39:13.931Z
|
package/cli.js
CHANGED
|
@@ -1696,7 +1696,7 @@ ${a.map(s=>[s.type,s.nestedLevel,this.getText(s.body)]).join(`,
|
|
|
1696
1696
|
${Qun}
|
|
1697
1697
|
${g}
|
|
1698
1698
|
${qun}
|
|
1699
|
-
${(await s.getFormattedTestFileCode()).code}`)}loadVtgTestFileMirror(r){if(!r||!r.startsWith("/"))throw new Error("Currently vtg mode can only run with absolute path to file");let a=new swe(r);return a.loadTestFromFile(),a}createActionJsonFileForExistingChecksumSpec(r,a){let s=r.testMirrors[0].translateStatementsToActions({mergeCustomCodeSteps:this.vtgSettingsService.getSettings().mergeCustomCodeSteps}),l=this.getActionJsonFilePath(a);(0,Qz.writeFileSync)(l,JSON.stringify(s,null,2))}createFolderIfNotExists(r){return(0,Qz.existsSync)(r)||(0,Qz.mkdirSync)(r,{recursive:!0}),r}getSavePathForNewChecksumSpec(){return(0,mfe.join)(this.draftsFolderPath,"test.checksum.spec.ts")}getActionJsonFilePath(r){let a=this.getFileName(r).replace(".spec.ts",".json");return(0,mfe.join)(this.draftsFolderPath,a)}getEvalFilePath(r){let a=this.internalE2ETest?".eval.e2e.checksum.spec.ts":".eval.checksum.spec.ts";return(0,mfe.join)(this.draftsFolderPath,a)}getFileName(r){return r.split("/").pop()}};e(jDr,"VtgTestRunner");var _kt=jDr;var gLe=require("fs");var UDr=e(i=>isNaN(i)?0:i,"getStat"),$vn=e(i=>{let r=[];if(i.specs&&r.push(...i.specs),i.suites)for(let a of i.suites)r.push(...$vn(a));return r},"extractSpecsFromSuite"),vLi=e(i=>{let r=[];for(let a of i.suites)r.push(...$vn(a));return r},"extractFlatSpecsMap");var xLi=e((i,r,a)=>{let{expected:s,unexpected:l,flaky:d}=i.stats,g=[];vLi(i).forEach(S=>{let F=ALi(S.id,r);F&&(S.recovered=!0);let O=S.tests[0],N=S.tags.includes("bug")||O.annotations.some(Q=>Q.type==="bug"),q=O.annotations&&O.annotations.length>0?O.annotations.map(Q=>({type:Q.type,description:Q.description||""})):[];g.push({checksumTestId:a[S.id],playwrightTestId:S.id,success:!!S.ok,recovered:F,bug:N,annotations:q,outcome:O.status})});let E={passed:UDr(d)+UDr(s),failed:UDr(l),bug:g.filter(S=>S.bug).length,recovered:g.filter(S=>S.recovered).length,tests:g};return g.forEach(S=>{S.bug&&(S.outcome==="expected"||S.outcome==="flaky"?E.passed--:S.outcome==="unexpected"&&E.failed--)}),E},"modifyStatsPerTestFile"),ALi=e((i,r)=>Object.values(r[i]||{}).some(a=>{var s,l;return(l=(s=a.autoRecoveryMetadata)==null?void 0:s.data)==null?void 0:l.autoRecovered}),"isAutoRecovered"),Vvn=e((i,r,a)=>{(0,gLe.cpSync)(i,i+".backup");try{let s=JSON.parse((0,gLe.readFileSync)(i,"utf-8")),l=xLi(s,r,a);return s.checksumMetadata=l,(0,gLe.writeFileSync)(i,JSON.stringify(s,null,2)),s}catch(s){return console.log("Error processing JSON report",s.message),null}},"processJSONReport");var qDr=class qDr extends kP{constructor(a,s=!1,l=!1){super(a,s);this.vtgMode=l;this.MAX_COMPLETION_WAIT=2*3600*1e3;this.didFail=!1;this.isolationMode=!1;this.trmMessagesBuffer="";this.completeIndicators={upload:!1,tests:!1,report:!1};this.uploadProgress=0;this.playwrightIdToReportMetadata={};this.pwTestIdToChecksumTestId={};this.logFilter={"upload-progress":{logEveryMS:1e3*30,lastLogTimestamp:0,logOnValueChange:!0,value:""}}}get replMode(){return this.getChecksumArg("repl")??!1}async run(){if(this.loadTracer(),this.validateAuthExists(),this.buildVolatileChecksumConfig(),this.vtgMode&&(this.config.options.hostReports=!1),!await this.getSession())return;this.testSuiteAnalytics=zwt.getInstance(this.testSuiteRunInfo,this.isolationMode),this.testSuiteAnalytics.genericEvent(`Project root found at ${this.projectRootDirectory}`,{message:`Checksum root found at ${this.checksumRoot}`});let a={CHECKSUM_ROOT_FOLDER:this.checksumRoot,CHECKSUM_TEST_SUITE_INFO:JSON.stringify(this.testSuiteRunInfo)},s;try{s=await E8(this.startTestRunMonitor(this.testSuiteRunId),1e4,"test run monitor timeout"),a.CHECKSUM_UPLOAD_AGENT_PORT=s}catch{let b="Error starting test run monitor. Test results will not be available on checksum.";this.testSuiteAnalytics.testRunMonitorError({error:b}),this.log(b)}a.PW_TEST_HTML_REPORT_OPEN="never",this.isolationMode&&(a.CHECKSUM_ISOLATED_MODE="true"),this.testSuiteRunId&&(a.CHECKSUM_TEST_SUITE_ID=this.testSuiteRunId),this.replMode&&(a.CHECKSUM_REPL="true"),this.getChecksumArg("tm")&&(a.CHECKSUM_SHOW_TIME_MACHINE="true");let l=this.getNonChecksumArgs();this.vtgMode&&(await new _kt(this.getChecksumArg("id")||void 0,this.getChecksumArg("edit")||void 0,this.getChecksumArg("legacy")||!1,eg.vtg.isE2ETestMode,this.getChecksumArg("restore")||!1,this.checksumRoot,this.getInternalFilesDirPath()).initAndUpdateEnvAndPlaywrightArgs(a,l),eg.promptKillActivePlaywrightProcesses&&await this.promptKillActivePlaywrightProcesses()),this.replMode&&l.push("--debug");let d=`npx playwright test --config "${this.getPlaywrightConfigFilePath()}" ${l.map(g=>`"${g}"`).join(" ")}`;await this.patchPlaywright();try{console.log(`Tests running with @checksum-ai/runtime version ${this.checksumRuntimeVersion}`),this.replMode?(console.log("Running in REPL mode"),this.execCmd(d,a),await this.execCmd(`node ${__dirname}/repl.js`,a)):(this.testSuiteAnalytics.testSuiteStart(),await this.execCmd(d,a)),console.log(`Tests execution finished. Checksum is finalizing${this.isolationMode?"":" and uploading"} the report, please wait...`)}catch{this.didFail=!0,console.log("Error during test execution: Failed passing test"),this.testSuiteAnalytics.testsFailed()}finally{this.isolationMode||console.log("Waiting for test files to upload to Checksum..."),this.sendReportUploadRequest(),await this.patchPlaywright(!0),this.completeIndicators.tests=!0,await this.handleCompleteMessage()}}loadPlaywrightConfigOptions(){var S,F;let a=e(O=>(lS("Using report folder",O),(0,PK.join)(O,"index.html")),"makeFilePath"),s=e(O=>(lS("Using JSON report folder",O),(0,PK.join)(O,"report.json")),"makeJsonFilePath"),l,d,g=!1,b="never";process.env.PLAYWRIGHT_HTML_OUTPUT_DIR&&(l=a(process.env.PLAYWRIGHT_HTML_OUTPUT_DIR));let E=(S=this.playwrightConfig)==null?void 0:S.reporter;if(E instanceof Array){let O=E.filter(Q=>Q instanceof Array&&Q[0]==="html"),N=E.filter(Q=>Q instanceof Array&&Q[0]==="json");if(!process.env.PLAYWRIGHT_HTML_OUTPUT_DIR){let Q=O.find(z=>{var oe;return(oe=z[1])==null?void 0:oe.outputFolder});Q&&(l=a((0,PK.join)(this.checksumRoot,Q[1].outputFolder)))}let q=N.find(Q=>{var z;return(z=Q[1])==null?void 0:z.outputFile});q&&(g=!0,d=(0,PK.join)(this.checksumRoot,q[1].outputFile));for(let Q of O){let z=(F=Q[1])==null?void 0:F.open;if(z==="always"||z==="on-failure"){b=z;break}}}l||(eg.isRepoMode?l=a((0,PK.join)(eg.runtimeRoot,"playwright-report")):l=a((0,PK.join)(this.projectRootDirectory,"playwright-report"))),d||(eg.isRepoMode?d=s((0,PK.join)(eg.runtimeRoot,"playwright-report")):d=s((0,PK.join)(this.projectRootDirectory,"playwright-report"))),this.playwrightConfigOptions={openReportCriteria:b,reportPath:l,jsonReportPath:d,hasJsonReporter:g}}sendReportUploadRequest(){let a=e(F=>{this.testSuiteAnalytics.testSuiteError({error:F}),this.log(F),this.completeIndicators.report=!0,this.testRunMonitorProcess.stdin.write("cli:report=false")},"makeError");if(!this.playwrightConfigOptions)return a("No playwright config options");let{reportPath:s,openReportCriteria:l,jsonReportPath:d,hasJsonReporter:g}=this.playwrightConfigOptions;if(g&&((0,Grt.existsSync)(d)?Vvn(d,this.playwrightIdToReportMetadata,this.pwTestIdToChecksumTestId):console.warn(`Could not find JSON report file at ${d}`)),!(0,Grt.existsSync)(s))return a(`Could not find report file at ${s}`);lS("Sending report upload request",s);let b=this.saveMetadataToFile((0,PK.dirname)(s)),E={reportPath:s,pathToChecksumMetadata:b,openReportCriteria:l,didFail:this.didFail},S=Buffer.from(JSON.stringify(E)).toString("base64");this.testRunMonitorProcess.stdin.write(`cli:report=${S}`)}saveMetadataToFile(a){try{let s=(0,PK.join)(a,`checksum-metadata-${(0,QDr.randomUUID)()}.json`);return(0,Grt.writeFileSync)(s,JSON.stringify(this.playwrightIdToReportMetadata,null,2)),s}catch(s){let l=`Error saving metadata to file - ${s.message}`;this.testSuiteAnalytics.testSuiteError({error:l}),this.log(l);return}}startTestMonitorProcess(a){let l=[JSON.stringify({sessionId:a,apiURL:this.config.apiURL,apiKey:this.config.apiKey}),...this.isolationMode?["isolated"]:[]],d={command:"node",args:[(0,PK.join)(__dirname,"test-run-monitor.js"),...l]};return eg.isRepoMode&&(d.command="yarn",d.args=["test-run-monitor",...l]),Jvn.spawn(d.command,d.args)}startTestRunMonitor(a){return new Promise(s=>{console.log("Starting test run monitor"),this.testRunMonitorProcess=this.startTestMonitorProcess(a),this.testRunMonitorProcess.stdout.on("data",l=>{let d=this.parseTRMMessages(l.toString().trim());if(d.length)for(let g of d){if(g.startsWith("trace")){this.logTRMMessage(g),this.handleTestRunMonitorTrace(g.substring("trace".length+1));continue}if(!g.startsWith("monitor")){this.logTRMMessage(g);continue}let b=e(()=>{let O=g.substring("monitor".length+1),N=O.indexOf("=");if(N===-1)return{key:O,value:""};let[q,Q]=[O.substring(0,N),O.substring(N+1)];return{key:q,value:Q}},"getKeyAndValue"),{key:E,value:S}=b();if(!Object.values(Nor).includes(E)){this.logTRMMessage(`Received unknown monitor message: "${g}"`);continue}let F=E;this.logInterProcessEventMessage(F,S),E==="port"?s(S):this.handleTestRunMonitorMessage(F,S)}}),this.testRunMonitorProcess.on("exit",(l,d)=>{let g=`test run monitor process exited with code ${l} and signal ${d}`;this.testSuiteAnalytics.testRunMonitorError({error:g}),this.log(g)}),this.testRunMonitorProcess.stderr.on("data",l=>{let d=`TRM Error: ${l.toString().substring(0,300)}`;this.testSuiteAnalytics.testRunMonitorError({error:d}),this.log(d)}),this.testRunMonitorProcess.on("error",l=>{let d=`Error starting test run monitor: ${l.message}`;this.testSuiteAnalytics.testRunMonitorError({error:d}),this.log(d)})})}logInterProcessEventMessage(a,s){e(()=>{if(!this.logFilter[a])return!0;if(this.logFilter[a].logOnValueChange&&this.logFilter[a].value!==s)return this.logFilter[a].value=s,!0;if(this.logFilter[a].logEveryMS){let d=Date.now();if(d-this.logFilter[a].lastLogTimestamp>=this.logFilter[a].logEveryMS)return this.logFilter[a].lastLogTimestamp=d,!0}return!1},"shouldLog")()&&this.logTRMMessage(`Received monitor message: "${a}${s?`=${s}`:""}"`)}parseTRMMessages(a){let s=this.trmMessagesBuffer+a,l,d,g=e(()=>{l=s.indexOf("{trm}"),d=s.indexOf("{/trm}")},"findIndexes");g();let b=[];for(;l!==-1&&d!==-1&&d>l;){if(b.push(s.substring(l+"{trm}".length,d)),s=s.slice(d+"{/trm}".length).trim(),s.length&&!s.startsWith("{trm}"))return console.warn("Buffered data does not start with start delimiter",s),this.trmMessagesBuffer="",b;this.trmMessagesBuffer=s,g()}return b}setChecksumTestMetadata(a){let{retry:s,type:l,pwTestId:d,checksumTestId:g}=a;this.playwrightIdToReportMetadata[d]||(this.playwrightIdToReportMetadata[d]={}),this.playwrightIdToReportMetadata[d][s]||(this.playwrightIdToReportMetadata[d][s]={}),this.playwrightIdToReportMetadata[d][s][l]=a,this.pwTestIdToChecksumTestId[d]=g}async handleTestRunMonitorTrace(a){let s=a.indexOf("="),[l,d]=s>-1?[a.substring(0,s),a.substring(s+1)]:[a,""];if(!Object.values(Jwt).includes(l)){lS("Unknown trace event",l);return}try{let g=d?JSON.parse(d):{};switch(l){case"Upload Start":this.testSuiteAnalytics.uploadStart({filename:g.filename});break;case"Upload Complete":this.testSuiteAnalytics.uploadComplete({filename:g.filename});break;case"Upload Failed":this.testSuiteAnalytics.uploadFailed({filename:g.filename,error:g.error});break;case"Trace Processing Error":this.testSuiteAnalytics.traceProcessingError({error:g.error});break}}catch(g){lS(`Error parsing trace payload, ${g.message}`)}}async handleTestRunMonitorMessage(a,s){var l;switch(a){case"uploads-complete-with-errors":console.log("Error uploading test files to Checksum");try{let g=JSON.parse(s);this.testSuiteAnalytics.uploadsCompleteWithErrors(g)}catch{}this.sendProcessingError().then(()=>{this.completeIndicators.upload=!0});break;case"checksumTestMetadata":try{let g=JSON.parse(s);this.setChecksumTestMetadata(g)}catch(g){let b=`Error parsing test metadata event - ${g.message}`;this.testSuiteAnalytics.testSuiteError({error:b}),this.log(b)}break;case"uploads-complete":this.isolationMode||console.log("Test files uploaded successfully"),this.testSuiteAnalytics.allUploadsComplete(),this.sendUploadsComplete().then(()=>{this.completeIndicators.upload=!0});break;case"report-complete":{if(this.isolationMode){this.completeIndicators.report=!0;break}let g=s.slice(0,s.indexOf(":"))==="true",b=s.slice(s.indexOf(":")+1),E=this.handleStats(b);if(this.testSuiteAnalytics.testSuiteEnd({passed:E.passed,failed:E.failed,bug:E.bug,total:((l=E.tests)==null?void 0:l.length)||0}),await this.sendTestRunEnd(E),this.completeIndicators.report=!0,g){let S=`${this.checksumAppUrl}/#/test-runs/${this.testSuiteRunId}`,F=`Checksum report URL: ${S}`,O="*".repeat(F.length);console.log(`${O}
|
|
1699
|
+
${(await s.getFormattedTestFileCode()).code}`)}loadVtgTestFileMirror(r){if(!r||!r.startsWith("/"))throw new Error("Currently vtg mode can only run with absolute path to file");let a=new swe(r);return a.loadTestFromFile(),a}createActionJsonFileForExistingChecksumSpec(r,a){let s=r.testMirrors[0].translateStatementsToActions({mergeCustomCodeSteps:this.vtgSettingsService.getSettings().mergeCustomCodeSteps}),l=this.getActionJsonFilePath(a);(0,Qz.writeFileSync)(l,JSON.stringify(s,null,2))}createFolderIfNotExists(r){return(0,Qz.existsSync)(r)||(0,Qz.mkdirSync)(r,{recursive:!0}),r}getSavePathForNewChecksumSpec(){return(0,mfe.join)(this.draftsFolderPath,"test.checksum.spec.ts")}getActionJsonFilePath(r){let a=this.getFileName(r).replace(".spec.ts",".json");return(0,mfe.join)(this.draftsFolderPath,a)}getEvalFilePath(r){let a=this.internalE2ETest?".eval.e2e.checksum.spec.ts":".eval.checksum.spec.ts";return(0,mfe.join)(this.draftsFolderPath,a)}getFileName(r){return r.split("/").pop()}};e(jDr,"VtgTestRunner");var _kt=jDr;var gLe=require("fs");var UDr=e(i=>isNaN(i)?0:i,"getStat"),$vn=e(i=>{let r=[];if(i.specs&&r.push(...i.specs),i.suites)for(let a of i.suites)r.push(...$vn(a));return r},"extractSpecsFromSuite"),vLi=e(i=>{let r=[];for(let a of i.suites)r.push(...$vn(a));return r},"extractFlatSpecsMap");var xLi=e((i,r,a)=>{let{expected:s,unexpected:l,flaky:d}=i.stats,g=[];vLi(i).forEach(S=>{let F=ALi(S.id,r);F&&(S.recovered=!0);let O=S.tests[0],N=S.tags.includes("bug")||O.annotations.some(Q=>Q.type==="bug"),q=O.annotations&&O.annotations.length>0?O.annotations.map(Q=>({type:Q.type,description:Q.description||""})):[];g.push({checksumTestId:a[S.id],playwrightTestId:S.id,success:!!S.ok,recovered:F,bug:N,annotations:q,outcome:O.status,filePath:S.file})});let E={passed:UDr(d)+UDr(s),failed:UDr(l),bug:g.filter(S=>S.bug).length,recovered:g.filter(S=>S.recovered).length,tests:g};return g.forEach(S=>{S.bug&&(S.outcome==="expected"||S.outcome==="flaky"?E.passed--:S.outcome==="unexpected"&&E.failed--)}),E},"modifyStatsPerTestFile"),ALi=e((i,r)=>Object.values(r[i]||{}).some(a=>{var s,l;return(l=(s=a.autoRecoveryMetadata)==null?void 0:s.data)==null?void 0:l.autoRecovered}),"isAutoRecovered"),Vvn=e((i,r,a)=>{(0,gLe.cpSync)(i,i+".backup");try{let s=JSON.parse((0,gLe.readFileSync)(i,"utf-8")),l=xLi(s,r,a);return s.checksumMetadata=l,(0,gLe.writeFileSync)(i,JSON.stringify(s,null,2)),s}catch(s){return console.log("Error processing JSON report",s.message),null}},"processJSONReport");var qDr=class qDr extends kP{constructor(a,s=!1,l=!1){super(a,s);this.vtgMode=l;this.MAX_COMPLETION_WAIT=2*3600*1e3;this.didFail=!1;this.isolationMode=!1;this.trmMessagesBuffer="";this.completeIndicators={upload:!1,tests:!1,report:!1};this.uploadProgress=0;this.playwrightIdToReportMetadata={};this.pwTestIdToChecksumTestId={};this.logFilter={"upload-progress":{logEveryMS:1e3*30,lastLogTimestamp:0,logOnValueChange:!0,value:""}}}get replMode(){return this.getChecksumArg("repl")??!1}async run(){if(this.loadTracer(),this.validateAuthExists(),this.buildVolatileChecksumConfig(),this.vtgMode&&(this.config.options.hostReports=!1),!await this.getSession())return;this.testSuiteAnalytics=zwt.getInstance(this.testSuiteRunInfo,this.isolationMode),this.testSuiteAnalytics.genericEvent(`Project root found at ${this.projectRootDirectory}`,{message:`Checksum root found at ${this.checksumRoot}`});let a={CHECKSUM_ROOT_FOLDER:this.checksumRoot,CHECKSUM_TEST_SUITE_INFO:JSON.stringify(this.testSuiteRunInfo)},s;try{s=await E8(this.startTestRunMonitor(this.testSuiteRunId),1e4,"test run monitor timeout"),a.CHECKSUM_UPLOAD_AGENT_PORT=s}catch{let b="Error starting test run monitor. Test results will not be available on checksum.";this.testSuiteAnalytics.testRunMonitorError({error:b}),this.log(b)}a.PW_TEST_HTML_REPORT_OPEN="never",this.isolationMode&&(a.CHECKSUM_ISOLATED_MODE="true"),this.testSuiteRunId&&(a.CHECKSUM_TEST_SUITE_ID=this.testSuiteRunId),this.replMode&&(a.CHECKSUM_REPL="true"),this.getChecksumArg("tm")&&(a.CHECKSUM_SHOW_TIME_MACHINE="true");let l=this.getNonChecksumArgs();this.vtgMode&&(await new _kt(this.getChecksumArg("id")||void 0,this.getChecksumArg("edit")||void 0,this.getChecksumArg("legacy")||!1,eg.vtg.isE2ETestMode,this.getChecksumArg("restore")||!1,this.checksumRoot,this.getInternalFilesDirPath()).initAndUpdateEnvAndPlaywrightArgs(a,l),eg.promptKillActivePlaywrightProcesses&&await this.promptKillActivePlaywrightProcesses()),this.replMode&&l.push("--debug");let d=`npx playwright test --config "${this.getPlaywrightConfigFilePath()}" ${l.map(g=>`"${g}"`).join(" ")}`;await this.patchPlaywright();try{console.log(`Tests running with @checksum-ai/runtime version ${this.checksumRuntimeVersion}`),this.replMode?(console.log("Running in REPL mode"),this.execCmd(d,a),await this.execCmd(`node ${__dirname}/repl.js`,a)):(this.testSuiteAnalytics.testSuiteStart(),await this.execCmd(d,a)),console.log(`Tests execution finished. Checksum is finalizing${this.isolationMode?"":" and uploading"} the report, please wait...`)}catch{this.didFail=!0,console.log("Error during test execution: Failed passing test"),this.testSuiteAnalytics.testsFailed()}finally{this.isolationMode||console.log("Waiting for test files to upload to Checksum..."),this.sendReportUploadRequest(),await this.patchPlaywright(!0),this.completeIndicators.tests=!0,await this.handleCompleteMessage()}}loadPlaywrightConfigOptions(){var S,F;let a=e(O=>(lS("Using report folder",O),(0,PK.join)(O,"index.html")),"makeFilePath"),s=e(O=>(lS("Using JSON report folder",O),(0,PK.join)(O,"report.json")),"makeJsonFilePath"),l,d,g=!1,b="never";process.env.PLAYWRIGHT_HTML_OUTPUT_DIR&&(l=a(process.env.PLAYWRIGHT_HTML_OUTPUT_DIR));let E=(S=this.playwrightConfig)==null?void 0:S.reporter;if(E instanceof Array){let O=E.filter(Q=>Q instanceof Array&&Q[0]==="html"),N=E.filter(Q=>Q instanceof Array&&Q[0]==="json");if(!process.env.PLAYWRIGHT_HTML_OUTPUT_DIR){let Q=O.find(z=>{var oe;return(oe=z[1])==null?void 0:oe.outputFolder});Q&&(l=a((0,PK.join)(this.checksumRoot,Q[1].outputFolder)))}let q=N.find(Q=>{var z;return(z=Q[1])==null?void 0:z.outputFile});q&&(g=!0,d=(0,PK.join)(this.checksumRoot,q[1].outputFile));for(let Q of O){let z=(F=Q[1])==null?void 0:F.open;if(z==="always"||z==="on-failure"){b=z;break}}}l||(eg.isRepoMode?l=a((0,PK.join)(eg.runtimeRoot,"playwright-report")):l=a((0,PK.join)(this.projectRootDirectory,"playwright-report"))),d||(eg.isRepoMode?d=s((0,PK.join)(eg.runtimeRoot,"playwright-report")):d=s((0,PK.join)(this.projectRootDirectory,"playwright-report"))),this.playwrightConfigOptions={openReportCriteria:b,reportPath:l,jsonReportPath:d,hasJsonReporter:g}}sendReportUploadRequest(){let a=e(F=>{this.testSuiteAnalytics.testSuiteError({error:F}),this.log(F),this.completeIndicators.report=!0,this.testRunMonitorProcess.stdin.write("cli:report=false")},"makeError");if(!this.playwrightConfigOptions)return a("No playwright config options");let{reportPath:s,openReportCriteria:l,jsonReportPath:d,hasJsonReporter:g}=this.playwrightConfigOptions;if(g&&((0,Grt.existsSync)(d)?Vvn(d,this.playwrightIdToReportMetadata,this.pwTestIdToChecksumTestId):console.warn(`Could not find JSON report file at ${d}`)),!(0,Grt.existsSync)(s))return a(`Could not find report file at ${s}`);lS("Sending report upload request",s);let b=this.saveMetadataToFile((0,PK.dirname)(s)),E={reportPath:s,pathToChecksumMetadata:b,openReportCriteria:l,didFail:this.didFail},S=Buffer.from(JSON.stringify(E)).toString("base64");this.testRunMonitorProcess.stdin.write(`cli:report=${S}`)}saveMetadataToFile(a){try{let s=(0,PK.join)(a,`checksum-metadata-${(0,QDr.randomUUID)()}.json`);return(0,Grt.writeFileSync)(s,JSON.stringify(this.playwrightIdToReportMetadata,null,2)),s}catch(s){let l=`Error saving metadata to file - ${s.message}`;this.testSuiteAnalytics.testSuiteError({error:l}),this.log(l);return}}startTestMonitorProcess(a){let l=[JSON.stringify({sessionId:a,apiURL:this.config.apiURL,apiKey:this.config.apiKey}),...this.isolationMode?["isolated"]:[]],d={command:"node",args:[(0,PK.join)(__dirname,"test-run-monitor.js"),...l]};return eg.isRepoMode&&(d.command="yarn",d.args=["test-run-monitor",...l]),Jvn.spawn(d.command,d.args)}startTestRunMonitor(a){return new Promise(s=>{console.log("Starting test run monitor"),this.testRunMonitorProcess=this.startTestMonitorProcess(a),this.testRunMonitorProcess.stdout.on("data",l=>{let d=this.parseTRMMessages(l.toString().trim());if(d.length)for(let g of d){if(g.startsWith("trace")){this.logTRMMessage(g),this.handleTestRunMonitorTrace(g.substring("trace".length+1));continue}if(!g.startsWith("monitor")){this.logTRMMessage(g);continue}let b=e(()=>{let O=g.substring("monitor".length+1),N=O.indexOf("=");if(N===-1)return{key:O,value:""};let[q,Q]=[O.substring(0,N),O.substring(N+1)];return{key:q,value:Q}},"getKeyAndValue"),{key:E,value:S}=b();if(!Object.values(Nor).includes(E)){this.logTRMMessage(`Received unknown monitor message: "${g}"`);continue}let F=E;this.logInterProcessEventMessage(F,S),E==="port"?s(S):this.handleTestRunMonitorMessage(F,S)}}),this.testRunMonitorProcess.on("exit",(l,d)=>{let g=`test run monitor process exited with code ${l} and signal ${d}`;this.testSuiteAnalytics.testRunMonitorError({error:g}),this.log(g)}),this.testRunMonitorProcess.stderr.on("data",l=>{let d=`TRM Error: ${l.toString().substring(0,300)}`;this.testSuiteAnalytics.testRunMonitorError({error:d}),this.log(d)}),this.testRunMonitorProcess.on("error",l=>{let d=`Error starting test run monitor: ${l.message}`;this.testSuiteAnalytics.testRunMonitorError({error:d}),this.log(d)})})}logInterProcessEventMessage(a,s){e(()=>{if(!this.logFilter[a])return!0;if(this.logFilter[a].logOnValueChange&&this.logFilter[a].value!==s)return this.logFilter[a].value=s,!0;if(this.logFilter[a].logEveryMS){let d=Date.now();if(d-this.logFilter[a].lastLogTimestamp>=this.logFilter[a].logEveryMS)return this.logFilter[a].lastLogTimestamp=d,!0}return!1},"shouldLog")()&&this.logTRMMessage(`Received monitor message: "${a}${s?`=${s}`:""}"`)}parseTRMMessages(a){let s=this.trmMessagesBuffer+a,l,d,g=e(()=>{l=s.indexOf("{trm}"),d=s.indexOf("{/trm}")},"findIndexes");g();let b=[];for(;l!==-1&&d!==-1&&d>l;){if(b.push(s.substring(l+"{trm}".length,d)),s=s.slice(d+"{/trm}".length).trim(),s.length&&!s.startsWith("{trm}"))return console.warn("Buffered data does not start with start delimiter",s),this.trmMessagesBuffer="",b;this.trmMessagesBuffer=s,g()}return b}setChecksumTestMetadata(a){let{retry:s,type:l,pwTestId:d,checksumTestId:g}=a;this.playwrightIdToReportMetadata[d]||(this.playwrightIdToReportMetadata[d]={}),this.playwrightIdToReportMetadata[d][s]||(this.playwrightIdToReportMetadata[d][s]={}),this.playwrightIdToReportMetadata[d][s][l]=a,this.pwTestIdToChecksumTestId[d]=g}async handleTestRunMonitorTrace(a){let s=a.indexOf("="),[l,d]=s>-1?[a.substring(0,s),a.substring(s+1)]:[a,""];if(!Object.values(Jwt).includes(l)){lS("Unknown trace event",l);return}try{let g=d?JSON.parse(d):{};switch(l){case"Upload Start":this.testSuiteAnalytics.uploadStart({filename:g.filename});break;case"Upload Complete":this.testSuiteAnalytics.uploadComplete({filename:g.filename});break;case"Upload Failed":this.testSuiteAnalytics.uploadFailed({filename:g.filename,error:g.error});break;case"Trace Processing Error":this.testSuiteAnalytics.traceProcessingError({error:g.error});break}}catch(g){lS(`Error parsing trace payload, ${g.message}`)}}async handleTestRunMonitorMessage(a,s){var l;switch(a){case"uploads-complete-with-errors":console.log("Error uploading test files to Checksum");try{let g=JSON.parse(s);this.testSuiteAnalytics.uploadsCompleteWithErrors(g)}catch{}this.sendProcessingError().then(()=>{this.completeIndicators.upload=!0});break;case"checksumTestMetadata":try{let g=JSON.parse(s);this.setChecksumTestMetadata(g)}catch(g){let b=`Error parsing test metadata event - ${g.message}`;this.testSuiteAnalytics.testSuiteError({error:b}),this.log(b)}break;case"uploads-complete":this.isolationMode||console.log("Test files uploaded successfully"),this.testSuiteAnalytics.allUploadsComplete(),this.sendUploadsComplete().then(()=>{this.completeIndicators.upload=!0});break;case"report-complete":{if(this.isolationMode){this.completeIndicators.report=!0;break}let g=s.slice(0,s.indexOf(":"))==="true",b=s.slice(s.indexOf(":")+1),E=this.handleStats(b);if(this.testSuiteAnalytics.testSuiteEnd({passed:E.passed,failed:E.failed,bug:E.bug,total:((l=E.tests)==null?void 0:l.length)||0}),await this.sendTestRunEnd(E),this.completeIndicators.report=!0,g){let S=`${this.checksumAppUrl}/#/test-runs/${this.testSuiteRunId}`,F=`Checksum report URL: ${S}`,O="*".repeat(F.length);console.log(`${O}
|
|
1700
1700
|
${F}
|
|
1701
1701
|
${O}`),this.testSuiteAnalytics.reportComplete({stats:E,reportUrl:S})}else this.testSuiteAnalytics.testSuiteError({error:"An error occurred while uploading the test report to Checksum"}),this.testSuiteAnalytics.reportUploadError(),console.log("An error occurred while uploading the test report to Checksum");break}case"upload-progress":{if(this.isolationMode)break;let g=parseInt(s);(g<this.uploadProgress||g>=this.uploadProgress+10||g===100&&this.uploadProgress!==100)&&(this.uploadProgress=g,console.log(`[ Uploads progress: ${this.uploadProgress}% ]`))}break;case"log":console.log(s);break;case"trace":let d=s;if(!Object.values(Jwt).includes(d))return;this.testSuiteAnalytics.genericEvent(d);break;case"playwrightConfig":try{this.playwrightConfig||(this.playwrightConfig=JSON.parse(s),this.testSuiteAnalytics.playwrightConfig({config:this.playwrightConfig}),this.loadPlaywrightConfigOptions())}catch(g){let b=`Error parsing playwright config - ${g.message}`;this.testSuiteAnalytics.playwrightConfigError({error:b}),this.log(b)}break;default:this.testSuiteAnalytics.testRunMonitorError({error:`Unhandled test run monitor message: ${a}=${s}`}),this.log(`Unhandled test run monitor message: ${a}=${s}`)}}handleStats(a){let s={};try{a&&a.length>0?(s=JSON.parse(a),s.tests=s.tests.map(l=>{let d=this.playwrightIdToReportMetadata[l.playwrightTestId];if(!d)return l;let g=Object.keys(d??{}),b=!1,E=!1,S=[];g.forEach(O=>{var N;if(d[O]){let q=d[O].autoRecoverySummaries;(N=q==null?void 0:q.data)!=null&&N.length&&S.push(...q.data)}});let F=g[g.length-1];if(F&&d[F]){let O=d[F].autoRecoveryMetadata;b=(O==null?void 0:O.data.autoRecoveryTriggered)??!1,E=(O==null?void 0:O.data.autoRecovered)??!1}return{...l,recovered:E,autoRecoveryTriggered:b,autoRecoverySummaries:S}})):(this.testSuiteAnalytics.testSuiteError({error:"No stats received from test run monitor"}),lS("No stats received from test run monitor"))}catch(l){this.testSuiteAnalytics.testSuiteError({error:`Error parsing stats - ${l.message}`}),this.log(`Error parsing stats - ${l.message}`)}return s}async handleCompleteMessage(){let a=Date.now(),s=12;for(;;){if(Date.now()-a>this.MAX_COMPLETION_WAIT){console.log("Warning: Checksum wasn't able to upload all test assets or expected a file the couldn't be found. This might cause issues when viewing the report/trace."),this.testSuiteAnalytics.runtimeTimeout(),this.shutdown(1);return}if(Object.keys(this.completeIndicators).find(l=>!this.completeIndicators[l]))lS(this.completeIndicators),--s===0&&(this.testSuiteAnalytics.completionStatus({stats:this.completeIndicators}),s=12),await IT(5e3);else{this.testSuiteAnalytics.runtimeComplete(),console.log("Checksum test suite run has completed"),await this.shutdown(this.didFail?1:0);return}}}async shutdown(a=0){await this.cleanup(),process.exit(a)}async cleanup(){await super.cleanup(),this.testRunMonitorProcess&&(this.testRunMonitorProcess.stdin.write("cli:shutdown"),this.testRunMonitorProcess.kill())}async getSession(){let a,s;try{if(!this.config.options.hostReports)return this.setIsolatedMode(),!0;if(s=this.config.apiKey,!s||s==="<API key>"){let S="No API key found in checksum config - please set it in the config file - checksum.config.ts";return this.runtimeTrace(S,"Checksum Config Error"),this.log(S,!0),this.shutdown(1),!1}let l=await this.getEnvInfo(),d=JSON.stringify({...l,isHidden:!!this.config.options.hideReports}),g=await fetch(`${this.config.apiURL}/client-api/test-runs`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",ChecksumAppCode:s},body:d}),{uuid:b,appName:E}=await g.json();return this.testSuiteRunId=b,l.commit=l.name,l.name=E,this.testSuiteRunInfo={appName:E,commitHash:l.commitHash,envName:l.name,branch:l.branch,testSuiteRunId:b,checksumRuntimeVersion:this.checksumRuntimeVersion},!0}catch(l){let d=`Error connecting to Checksum, the report will not be hosted - ${l.message}`;return this.runtimeTrace(d,"Test Suite Init Error"),this.log(d),this.setIsolatedMode(),!0}}setIsolatedMode(){this.testSuiteRunId=process.env.CHECKSUM_TEST_SUITE_ID||(0,QDr.randomUUID)(),this.isolationMode=!0,this.completeIndicators.upload=!0,eg.testRun.monitoring.debugAnalytics?this.testSuiteRunInfo=Lun(this.checksumRuntimeVersion,this.testSuiteRunId):this.testSuiteRunInfo=Run(this.checksumRuntimeVersion,this.testSuiteRunId)}async sendTestRunEnd(a){if(!this.isolationMode)try{let s="{}";try{s=JSON.stringify({...a,endedAt:Date.now()})}catch(l){this.testSuiteAnalytics.testSuiteError({error:`Error stringifying stats ${l.message}`}),this.log(`Error stringifying stats ${l.message}`,!0)}await this.updateTestRun(`${this.config.apiURL}/client-api/test-runs/${this.testSuiteRunId}`,"PATCH",s)}catch(s){return this.testSuiteAnalytics.testSuiteError({error:`Error sending test run end ${s.message}`}),this.log(`Error sending test run end ${s.message}`,!0),null}}async sendUploadsComplete(){if(!this.isolationMode)try{await this.updateTestRun(`${this.config.apiURL}/client-api/test-runs/${this.testSuiteRunId}/uploads-completed`,"PATCH")}catch(a){this.testSuiteAnalytics.testSuiteError({error:`Error sending test run uploads complete - ${a.message}`}),this.log(`Error sending test run uploads complete - ${a.message}`,!0)}}async sendProcessingError(){if(!this.isolationMode)try{await this.updateTestRun(`${this.config.apiURL}/client-api/test-runs/${this.testSuiteRunId}/process-error`,"PATCH")}catch(a){this.testSuiteAnalytics.testSuiteError({error:`Error sending test run processing error - ${a.message}`}),this.log(`Error sending test run processing error - ${a.message}`,!0)}}async updateTestRun(a,s,l=void 0){let d=await fetch(a,{method:s,headers:{Accept:"application/json","Content-Type":"application/json",ChecksumAppCode:this.config.apiKey},body:l});return lS("Received update test run response from url:",a),await this.logApiResponse(d),d}async logApiResponse(a){try{if(!a.ok){let{status:l,statusText:d}=a,g=await a.text();this.testSuiteAnalytics.testSuiteError({status:l,statusText:d,error:g});return}a.headers.get("Content-Type").includes("application/json")?a.json().then(l=>{lS("API Response:",l)}):a.text().then(l=>{lS("API Response:",l)})}catch(s){this.testSuiteAnalytics.testSuiteError({error:`Error logging API response - ${s.message}`})}}logTRMMessage(a){(Array.isArray(a)?a:[a]).forEach(s=>{lS("[trm]",s)})}};e(qDr,"TestsRunner");var Krt=qDr;var $Dr=class $Dr extends kP{constructor(r,a=!1){super(r,a)}async run(r){switch(r){default:console.log(`
|
|
1702
1702
|
Checksum CLI
|
package/package.json
CHANGED
package/test-run-monitor.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
`).join(`
|
|
7
7
|
`+o),e.push(r+"m+"+pn.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=ES()+t+" "+e[0]}n(wS,"formatArgs");function ES(){return oe.inspectOpts.hideDate?"":new Date().toISOString()+" "}n(ES,"getDate");function SS(...e){return process.stderr.write(ln.formatWithOptions(oe.inspectOpts,...e)+`
|
|
8
8
|
`)}n(SS,"log");function kS(e){e?process.env.DEBUG=e:delete process.env.DEBUG}n(kS,"save");function TS(){return process.env.DEBUG}n(TS,"load");function RS(e){e.inspectOpts={};let t=Object.keys(oe.inspectOpts);for(let i=0;i<t.length;i++)e.inspectOpts[t[i]]=oe.inspectOpts[t[i]]}n(RS,"init");pn.exports=nc()(oe);var{formatters:ov}=pn.exports;ov.o=function(e){return this.inspectOpts.colors=this.useColors,ln.inspect(e,this.inspectOpts).split(`
|
|
9
|
-
`).map(t=>t.trim()).join(" ")};ov.O=function(e){return this.inspectOpts.colors=this.useColors,ln.inspect(e,this.inspectOpts)}});var cv=g((bO,cc)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?cc.exports=ev():cc.exports=sv()});var pv=g((yO,lv)=>{var Pa;lv.exports=function(){if(!Pa){try{Pa=cv()("follow-redirects")}catch{}typeof Pa!="function"&&(Pa=n(function(){},"debug"))}Pa.apply(null,arguments)}});var hv=g((wO,yc)=>{var Ba=require("url"),ja=Ba.URL,AS=require("http"),CS=require("https"),fc=require("stream").Writable,mc=require("assert"),uv=pv();n(function(){var t=typeof process<"u",i=typeof window<"u"&&typeof document<"u",a=Jt(Error.captureStackTrace);!t&&(i||!a)&&console.warn("The follow-redirects package should be excluded from browser builds.")},"detectUnsupportedEnvironment")();var hc=!1;try{mc(new ja(""))}catch(e){hc=e.code==="ERR_INVALID_URL"}var OS=["auth","host","hostname","href","path","pathname","port","protocol","query","search","hash"],vc=["abort","aborted","connect","error","socket","timeout"],xc=Object.create(null);vc.forEach(function(e){xc[e]=function(t,i,a){this._redirectable.emit(e,t,i,a)}});var pc=qa("ERR_INVALID_URL","Invalid URL",TypeError),uc=qa("ERR_FR_REDIRECTION_FAILURE","Redirected request failed"),IS=qa("ERR_FR_TOO_MANY_REDIRECTS","Maximum number of redirects exceeded",uc),FS=qa("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit"),US=qa("ERR_STREAM_WRITE_AFTER_END","write after end"),NS=fc.prototype.destroy||fv;function Se(e,t){fc.call(this),this._sanitizeOptions(e),this._options=e,this._ended=!1,this._ending=!1,this._redirectCount=0,this._redirects=[],this._requestBodyLength=0,this._requestBodyBuffers=[],t&&this.on("response",t);var i=this;this._onNativeResponse=function(a){try{i._processResponse(a)}catch(r){i.emit("error",r instanceof uc?r:new uc({cause:r}))}},this._performRequest()}n(Se,"RedirectableRequest");Se.prototype=Object.create(fc.prototype);Se.prototype.abort=function(){bc(this._currentRequest),this._currentRequest.abort(),this.emit("abort")};Se.prototype.destroy=function(e){return bc(this._currentRequest,e),NS.call(this,e),this};Se.prototype.write=function(e,t,i){if(this._ending)throw new US;if(!Zt(e)&&!MS(e))throw new TypeError("data should be a string, Buffer or Uint8Array");if(Jt(t)&&(i=t,t=null),e.length===0){i&&i();return}this._requestBodyLength+e.length<=this._options.maxBodyLength?(this._requestBodyLength+=e.length,this._requestBodyBuffers.push({data:e,encoding:t}),this._currentRequest.write(e,t,i)):(this.emit("error",new FS),this.abort())};Se.prototype.end=function(e,t,i){if(Jt(e)?(i=e,e=t=null):Jt(t)&&(i=t,t=null),!e)this._ended=this._ending=!0,this._currentRequest.end(null,null,i);else{var a=this,r=this._currentRequest;this.write(e,t,function(){a._ended=!0,r.end(null,null,i)}),this._ending=!0}};Se.prototype.setHeader=function(e,t){this._options.headers[e]=t,this._currentRequest.setHeader(e,t)};Se.prototype.removeHeader=function(e){delete this._options.headers[e],this._currentRequest.removeHeader(e)};Se.prototype.setTimeout=function(e,t){var i=this;function a(s){s.setTimeout(e),s.removeListener("timeout",s.destroy),s.addListener("timeout",s.destroy)}n(a,"destroyOnTimeout");function r(s){i._timeout&&clearTimeout(i._timeout),i._timeout=setTimeout(function(){i.emit("timeout"),o()},e),a(s)}n(r,"startTimer");function o(){i._timeout&&(clearTimeout(i._timeout),i._timeout=null),i.removeListener("abort",o),i.removeListener("error",o),i.removeListener("response",o),i.removeListener("close",o),t&&i.removeListener("timeout",t),i.socket||i._currentRequest.removeListener("socket",r)}return n(o,"clearTimer"),t&&this.on("timeout",t),this.socket?r(this.socket):this._currentRequest.once("socket",r),this.on("socket",a),this.on("abort",o),this.on("error",o),this.on("response",o),this.on("close",o),this};["flushHeaders","getHeader","setNoDelay","setSocketKeepAlive"].forEach(function(e){Se.prototype[e]=function(t,i){return this._currentRequest[e](t,i)}});["aborted","connection","socket"].forEach(function(e){Object.defineProperty(Se.prototype,e,{get:n(function(){return this._currentRequest[e]},"get")})});Se.prototype._sanitizeOptions=function(e){if(e.headers||(e.headers={}),e.host&&(e.hostname||(e.hostname=e.host),delete e.host),!e.pathname&&e.path){var t=e.path.indexOf("?");t<0?e.pathname=e.path:(e.pathname=e.path.substring(0,t),e.search=e.path.substring(t))}};Se.prototype._performRequest=function(){var e=this._options.protocol,t=this._options.nativeProtocols[e];if(!t)throw new TypeError("Unsupported protocol "+e);if(this._options.agents){var i=e.slice(0,-1);this._options.agent=this._options.agents[i]}var a=this._currentRequest=t.request(this._options,this._onNativeResponse);a._redirectable=this;for(var r of vc)a.on(r,xc[r]);if(this._currentUrl=/^\//.test(this._options.path)?Ba.format(this._options):this._options.path,this._isRedirect){var o=0,s=this,c=this._requestBodyBuffers;n(function u(l){if(a===s._currentRequest)if(l)s.emit("error",l);else if(o<c.length){var p=c[o++];a.finished||a.write(p.data,p.encoding,u)}else s._ended&&a.end()},"writeNext")()}};Se.prototype._processResponse=function(e){var t=e.statusCode;this._options.trackRedirects&&this._redirects.push({url:this._currentUrl,headers:e.headers,statusCode:t});var i=e.headers.location;if(!i||this._options.followRedirects===!1||t<300||t>=400){e.responseUrl=this._currentUrl,e.redirects=this._redirects,this.emit("response",e),this._requestBodyBuffers=[];return}if(bc(this._currentRequest),e.destroy(),++this._redirectCount>this._options.maxRedirects)throw new IS;var a,r=this._options.beforeRedirect;r&&(a=Object.assign({Host:e.req.getHeader("host")},this._options.headers));var o=this._options.method;((t===301||t===302)&&this._options.method==="POST"||t===303&&!/^(?:GET|HEAD)$/.test(this._options.method))&&(this._options.method="GET",this._requestBodyBuffers=[],lc(/^content-/i,this._options.headers));var s=lc(/^host$/i,this._options.headers),c=gc(this._currentUrl),u=s||c.host,l=/^\w+:/.test(i)?this._currentUrl:Ba.format(Object.assign(c,{host:u})),p=DS(i,l);if(uv("redirecting to",p.href),this._isRedirect=!0,dc(p,this._options),(p.protocol!==c.protocol&&p.protocol!=="https:"||p.host!==u&&!LS(p.host,u))&&lc(/^(?:(?:proxy-)?authorization|cookie)$/i,this._options.headers),Jt(r)){var h={headers:e.headers,statusCode:t},m={url:l,method:o,headers:a};r(this._options,h,m),this._sanitizeOptions(this._options)}this._performRequest()};function dv(e){var t={maxRedirects:21,maxBodyLength:10485760},i={};return Object.keys(e).forEach(function(a){var r=a+":",o=i[r]=e[a],s=t[a]=Object.create(o);function c(l,p,h){return PS(l)?l=dc(l):Zt(l)?l=dc(gc(l)):(h=p,p=mv(l),l={protocol:r}),Jt(p)&&(h=p,p=null),p=Object.assign({maxRedirects:t.maxRedirects,maxBodyLength:t.maxBodyLength},l,p),p.nativeProtocols=i,!Zt(p.host)&&!Zt(p.hostname)&&(p.hostname="::1"),mc.equal(p.protocol,r,"protocol mismatch"),uv("options",p),new Se(p,h)}n(c,"request");function u(l,p,h){var m=s.request(l,p,h);return m.end(),m}n(u,"get"),Object.defineProperties(s,{request:{value:c,configurable:!0,enumerable:!0,writable:!0},get:{value:u,configurable:!0,enumerable:!0,writable:!0}})}),t}n(dv,"wrap");function fv(){}n(fv,"noop");function gc(e){var t;if(hc)t=new ja(e);else if(t=mv(Ba.parse(e)),!Zt(t.protocol))throw new pc({input:e});return t}n(gc,"parseUrl");function DS(e,t){return hc?new ja(e,t):gc(Ba.resolve(t,e))}n(DS,"resolveUrl");function mv(e){if(/^\[/.test(e.hostname)&&!/^\[[:0-9a-f]+\]$/i.test(e.hostname))throw new pc({input:e.href||e});if(/^\[/.test(e.host)&&!/^\[[:0-9a-f]+\](:\d+)?$/i.test(e.host))throw new pc({input:e.href||e});return e}n(mv,"validateUrl");function dc(e,t){var i=t||{};for(var a of OS)i[a]=e[a];return i.hostname.startsWith("[")&&(i.hostname=i.hostname.slice(1,-1)),i.port!==""&&(i.port=Number(i.port)),i.path=i.search?i.pathname+i.search:i.pathname,i}n(dc,"spreadUrlObject");function lc(e,t){var i;for(var a in t)e.test(a)&&(i=t[a],delete t[a]);return i===null||typeof i>"u"?void 0:String(i).trim()}n(lc,"removeMatchingHeaders");function qa(e,t,i){function a(r){Jt(Error.captureStackTrace)&&Error.captureStackTrace(this,this.constructor),Object.assign(this,r||{}),this.code=e,this.message=this.cause?t+": "+this.cause.message:t}return n(a,"CustomError"),a.prototype=new(i||Error),Object.defineProperties(a.prototype,{constructor:{value:a,enumerable:!1},name:{value:"Error ["+e+"]",enumerable:!1}}),a}n(qa,"createErrorType");function bc(e,t){for(var i of vc)e.removeListener(i,xc[i]);e.on("error",fv),e.destroy(t)}n(bc,"destroyRequest");function LS(e,t){mc(Zt(e)&&Zt(t));var i=e.length-t.length-1;return i>0&&e[i]==="."&&e.endsWith(t)}n(LS,"isSubdomain");function Zt(e){return typeof e=="string"||e instanceof String}n(Zt,"isString");function Jt(e){return typeof e=="function"}n(Jt,"isFunction");function MS(e){return typeof e=="object"&&"length"in e}n(MS,"isBuffer");function PS(e){return ja&&e instanceof ja}n(PS,"isURL");yc.exports=dv({http:AS,https:CS});yc.exports.wrap=dv});var fk={};Kc(fk,{TestRunMonitor:()=>_n});module.exports=lx(fk);var Sn=n(e=>new Promise(t=>setTimeout(t,e)),"awaitSleep");var ex=require("child_process"),wn=require("crypto"),J=require("fs"),tx=require("http"),ix=ce(require("net")),Ne=require("path");var xf=ce(nf()),dt=require("fs"),gf=require("path");var Ye=ce(require("path")),_s=require("fs");var hs=require("path"),Mr=require("fs");function W_(e,t,i=10){let a=e;for(let r=0;r<i;r++){let o=(0,hs.join)(a,"package.json");if((0,Mr.existsSync)(o))try{if(JSON.parse((0,Mr.readFileSync)(o,"utf8")).name===t)return a}catch{}a=(0,hs.join)(a,"..")}}n(W_,"findRepositoryRoot");function of(e,t=10){return W_(e,"checksum-customer-engineering-workspace",t)}n(of,"findCustomerEngineeringRoot");var ws=ce(uf());var P=n((e,t)=>{if(e==null||e==="")return(t==null?void 0:t.default)??!1;let i=e.toLowerCase().trim();return i==="true"?!0:i==="false"?!1:(t==null?void 0:t.default)??!1},"parseBoolean");var o0=__dirname,df=Ye.join(__dirname,".."),hf=(0,_s.existsSync)(df)?df:o0;(0,ws.config)({path:Ye.resolve(hf,".env")});var bs=P(process.env.CHECKSUM_RUNTIME_DEV_MODE);function s0(){let e=__dirname;for(;!(0,_s.existsSync)(Ye.join(e,"package.json"));)e=Ye.join(e,"..");return e}n(s0,"findRoot");var Ri=s0(),c0=of(Ri,10);(0,ws.config)({path:[hf,c0].filter(Boolean).map(e=>Ye.resolve(e,".env")),override:!1});var jr=P(process.env.CHECKSUM_VTG_E2E_TEST_MODE),ff=Ye.join(Ri,"vtg-build","index.html"),ys=jr?!0:P(process.env.CHECKSUM_RUNTIME_REPO_MODE),mf=P(process.env.CHECKSUM_VTG_SEPARATE_PROCESS),l0=ys?Ye.join(Ri,"package","pw-report-template.html"):Ye.join(Ri,"pw-report-template.html"),p0=P(process.env.CHECKSUM_DEBUG_ANALYTICS),u0=P(process.env.CHECKSUM_LOG_ANALYTICS_TO_CONSOLE),Br={isDevMode:bs,isRepoMode:ys,CI:!!process.env.CI,checksumRootFolderBypass:jr?"packages/runtime/test/e2e/checksum":ys&&process.env.CHECKSUM_RUNTIME_ROOT_FOLDER_BYPASS_FOR_REPO_MODE?process.env.CHECKSUM_RUNTIME_ROOT_FOLDER_BYPASS_FOR_REPO_MODE:process.env.CHECKSUM_RUNTIME_ROOT_FOLDER_BYPASS,logLevel:process.env.CHECKSUM_RUNTIME_LOG_LEVEL??"warnings",checksumScript:{source:process.env.CHECKSUM_RUNTIME_SCRIPT_SOURCE??(bs?"url":"file"),url:process.env.CHECKSUM_RUNTIME_SCRIPT_URL,path:Ri+"/checksumlib.js"},runtimeRoot:Ri,playwrightReporter:{htmlReportTemplatePath:l0},bypassProxyForLocalhost:P(process.env.CHECKSUM_RUNTIME_BYPASS_PROXY_FOR_LOCALHOST),promptKillActivePlaywrightProcesses:P(process.env.CHECKSUM_RUNTIME_PROMPT_KILL_ACTIVE_PLAYWRIGHT_PROCESSES,{default:!0}),useCLIDebug:P(process.env.CHECKSUM_RUNTIME_USE_CLI_DEBUG),useRemoteDebugging:{enabled:P(process.env.CHECKSUM_RUNTIME_USE_REMOTE_DEBUGGING),port:parseInt(process.env.CHECKSUM_AGENT_RUNTIME_REMOTE_DEBUGGING_PORT??"9500")},testRun:{timeMachine:{active:!0,headless:!P(process.env.CHECKSUM_RUNTIME_SHOW_RUNTIME_TIME_MACHINE),recordRRwebEventsToFile:P(process.env.CHECKSUM_RUNTIME_RECORD_RRWEB_EVENTS_TO_FILE,{default:!0})},monitoring:{defaultProvider:process.env.CHECKSUM_RUNTIME_MONITORING_DEFAULT_PROVIDER??"newrelic",debugAnalytics:p0,logToConsole:u0,newrelic:{appName:process.env.CHECKSUM_RUNTIME_MONITORING_NEWRELIC_APP_NAME??"checksum-runtime",licenseKey:"b4f3f644f40df19fe3d385c75428a450FFFFNRAL",logging:P(process.env.NEW_RELIC_LOG_ENABLED,{default:!1})},segment:{writeKey:process.env.CHECKSUM_RUNTIME_MONITORING_SEGMENT_WRITE_KEY??"TMuP8uorDj4QzJfNs0gEHDO7kHozVBOo",devWriteKey:process.env.CHECKSUM_RUNTIME_MONITORING_SEGMENT_DEV_WRITE_KEY??"gofHHwvdNHJNmb7KqACUmypZclVHEQ2l"}},autoRecovery:{verboseConsoleLog:P(process.env.CHECKSUM_RUNTIME_AUTO_RECOVERY_CONSOLE_LOG,{default:!1}),sessionTimeout:18e4},disableAutoRecovery:P(process.env.CHECKSUM_RUNTIME_DISABLE_AUTO_RECOVERY),disableHostReports:P(process.env.CHECKSUM_RUNTIME_DISABLE_HOST_REPORTS),request:{userEmail:process.env.CHECKSUM_RUNTIME_REQUEST_USER_EMAIL,reason:process.env.CHECKSUM_RUNTIME_REQUEST_REASON},platform:{name:process.env.CHECKSUM_RUNTIME_PLATFORM_NAME},runType:process.env.CHECKSUM_RUNTIME_RUN_TYPE},vtg:{isSeparateProcess:mf,isE2ETestMode:jr,writeLogFile:P(process.env.CHECKSUM_VTG_WRITE_LOG_FILE,{default:!0}),appSource:process.env.CHECKSUM_VTG_APP_SOURCE??(bs?"served-app":"served-build-file"),localUrl:`file://${ff}`,localBuildPath:ff,appURL:process.env.CHECKSUM_VTG_APP_URL,writeRrwebEventsToFile:P(process.env.CHECKSUM_VTG_RECORD_EVENTS_TO_FILE),useFakeStory:P(process.env.CHECKSUM_VTG_USE_FAKE_STORY)||jr,logAPIServer:{interval:P(process.env.CHECKSUM_VTG_LOG_API_SERVER_INTERVAL),httpTransactions:P(process.env.CHECKSUM_VTG_LOG_API_SERVER_HTTP_TRANSACTIONS,{default:!0})},customerEngRepoInternalUtilsRelativePath:process.env.CHECKSUM_VTG_CUSTOMER_ENG_REPO_INTERNAL_UTILS_RELATIVE_PATH??"tools/internal-utils.ts",fakeStory:{goal:process.env.CHECKSUM_VTG_FAKE_STORY_GOAL??"Send email via outreach list",instructions:process.env.CHECKSUM_VTG_FAKE_STORY_INSTRUCTIONS??"Make sure to select a user from the list first"},fakeTestGeneration:{internalTestId:process.env.CHECKSUM_VTG_FAKE_STORY_INTERNAL_TEST_ID??`tempID${Date.now().toString().slice(-5)}`,generationBatchId:process.env.CHECKSUM_VTG_FAKE_GENERATION_BATCH_ID??`tempID${Date.now().toString().slice(-5)}`},remoteDebugging:mf?!0:P(process.env.CHECKSUM_VTG_REMOTE_DEBUGGING),appRemoteDebuggingPort:parseInt(process.env.CHECKSUM_VTG_REMOTE_DEBUGGING_PORT??"9230"),vtgRemoteDebuggingPort:parseInt(process.env.CHECKSUM_VTG_REMOTE_DEBUGGING_PORT??"9231"),taskTimeMachine:{showTaskTimeMachine:P(process.env.CHECKSUM_VTG_SHOW_TASK_TIME_MACHINE),taskTimeout:parseInt(process.env.CHECKSUM_VTG_TASK_TIME_MACHINE_TIMEOUT??"240000"),debugPort:parseInt(process.env.CHECKSUM_VTG_TASK_TIME_MACHINE_DEBUG_PORT??"9232"),logPerformance:P(process.env.CHECKSUM_VTG_TASK_TIME_MACHINE_LOG_PERFORMANCE,{default:!0})},aiAssertions:{disabled:P(process.env.CHECKSUM_VTG_AI_ASSERTIONS_DISABLED),allowRefactoring:P(process.env.CHECKSUM_VTG_ALLOW_AI_ASSERTIONS_REFACTORING),allowFiltering:P(process.env.CHECKSUM_VTG_ALLOW_AI_ASSERTIONS_FILTERING),logPerformance:P(process.env.CHECKSUM_VTG_AI_ASSERTIONS_LOG_PERFORMANCE,{default:!1})},aiLocators:{disabled:P(process.env.CHECKSUM_VTG_AI_LOCATORS_DISABLED),useFakeAILocators:P(process.env.CHECKSUM_VTG_USE_FAKE_AI_LOCATORS)}},benchmark:P(process.env.BENCHMARK_MODE),buildTime:process.env.CHECKSUM_RUNTIME_BUILD_TIME??"unknown",llm:{models:{openai:{key:process.env.CHECKSUM_RUNTIME_OPENAI_API_KEY},anthropic:{key:process.env.CHECKSUM_RUNTIME_ANTHROPIC_API_KEY},gemini:{model:process.env.CHECKSUM_RUNTIME_GEMINI_MODEL},groq:{apiKey:process.env.CHECKSUM_RUNTIME_GROQ_API_KEY}}},gcp:{credentialsFile:process.env.CHECKSUM_RUNTIME_GCP_CREDENTIALS_FILE}};var qr=n(e=>isNaN(e)?0:e,"getStat");var vf=n((e,t)=>Object.values(t[e]||{}).some(i=>{var a,r;return(r=(a=i.autoRecoveryMetadata)==null?void 0:a.data)==null?void 0:r.autoRecovered}),"isAutoRecovered");var Es=class Es{constructor(t,i,a,r={},o={},s){this.reportHTMLFilePath=t;this.testRunUUID=i;this.pwTestIdToChecksumTestId=a;this.playwrightIdToMetadata=r;this.channel=s;this.supportVideo=!1;this.config={hosted:!0,assetsBaseURL:"https://api.checksum.ai/api/test-runs"};this.config={...this.config,...o}}async process(){this.channel.debug("Extracting report...");let t=this.extractReportBase64();this.channel.debug("Preparing new report...");let i=await this.editZipFile(t);this.channel.debug("Writing report to file..."),this.writeFile(i)}testHasTrace(t,i){try{if(!this.report)return!0;let a=Object.keys(this.pwTestIdToChecksumTestId??{}).find(o=>this.pwTestIdToChecksumTestId[o]===t);if(!a)return!0;let r=n(o=>o.some(s=>{var c;return(c=s.attachments)==null?void 0:c.some(u=>u.name==="trace")}),"hasTrace");for(let o of this.report.files)for(let s of o.tests)if(s.testId===a&&s.projectName===i&&r(s.results))return!0;return!1}catch(a){return this.channel.debug("Failed to check if test has trace, assuming trace exists",a),!0}}getStatPerFile(){let t=[];return this.report.files.forEach(i=>{i.tests.forEach(a=>{t.push({checksumTestId:this.pwTestIdToChecksumTestId[a.testId],playwrightTestId:a.testId,success:!!a.ok,recovered:vf(a.testId,this.playwrightIdToMetadata),bug:a.tags.includes("bug")||a.annotations.some(r=>r.type==="bug")||a.title.includes("@bug"),annotations:a.annotations&&a.annotations.length>0?a.annotations.filter(r=>!!(r!=null&&r.type)).map(r=>({type:r.type,description:r.description||""})):[],outcome:a.outcome})})}),t}getProcessedFilePath(){return this.reportHTMLFilePath}extractReportBase64(){var a;try{let r=(a=(0,dt.statSync)(this.reportHTMLFilePath))==null?void 0:a.size;this.channel.debug(`Report HTML file size approximately ${r} bytes`)}catch(r){this.channel.debug(`Failed to retrieve file size for ${this.reportHTMLFilePath}`,r)}let i=(0,dt.readFileSync)(this.reportHTMLFilePath,"utf-8").match(/window\.playwrightReportBase64 = "(.*)";/);if(i&&i[1])return i[1];{let r="Could not extract playwrightReportBase64 from HTML file";throw this.channel.debug(r),new Error(r)}}writeFile(t){let i=(0,dt.readFileSync)(Br.playwrightReporter.htmlReportTemplatePath,"utf-8");i=i+`<script>
|
|
9
|
+
`).map(t=>t.trim()).join(" ")};ov.O=function(e){return this.inspectOpts.colors=this.useColors,ln.inspect(e,this.inspectOpts)}});var cv=g((bO,cc)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?cc.exports=ev():cc.exports=sv()});var pv=g((yO,lv)=>{var Pa;lv.exports=function(){if(!Pa){try{Pa=cv()("follow-redirects")}catch{}typeof Pa!="function"&&(Pa=n(function(){},"debug"))}Pa.apply(null,arguments)}});var hv=g((wO,yc)=>{var Ba=require("url"),ja=Ba.URL,AS=require("http"),CS=require("https"),fc=require("stream").Writable,mc=require("assert"),uv=pv();n(function(){var t=typeof process<"u",i=typeof window<"u"&&typeof document<"u",a=Jt(Error.captureStackTrace);!t&&(i||!a)&&console.warn("The follow-redirects package should be excluded from browser builds.")},"detectUnsupportedEnvironment")();var hc=!1;try{mc(new ja(""))}catch(e){hc=e.code==="ERR_INVALID_URL"}var OS=["auth","host","hostname","href","path","pathname","port","protocol","query","search","hash"],vc=["abort","aborted","connect","error","socket","timeout"],xc=Object.create(null);vc.forEach(function(e){xc[e]=function(t,i,a){this._redirectable.emit(e,t,i,a)}});var pc=qa("ERR_INVALID_URL","Invalid URL",TypeError),uc=qa("ERR_FR_REDIRECTION_FAILURE","Redirected request failed"),IS=qa("ERR_FR_TOO_MANY_REDIRECTS","Maximum number of redirects exceeded",uc),FS=qa("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit"),US=qa("ERR_STREAM_WRITE_AFTER_END","write after end"),NS=fc.prototype.destroy||fv;function Se(e,t){fc.call(this),this._sanitizeOptions(e),this._options=e,this._ended=!1,this._ending=!1,this._redirectCount=0,this._redirects=[],this._requestBodyLength=0,this._requestBodyBuffers=[],t&&this.on("response",t);var i=this;this._onNativeResponse=function(a){try{i._processResponse(a)}catch(r){i.emit("error",r instanceof uc?r:new uc({cause:r}))}},this._performRequest()}n(Se,"RedirectableRequest");Se.prototype=Object.create(fc.prototype);Se.prototype.abort=function(){bc(this._currentRequest),this._currentRequest.abort(),this.emit("abort")};Se.prototype.destroy=function(e){return bc(this._currentRequest,e),NS.call(this,e),this};Se.prototype.write=function(e,t,i){if(this._ending)throw new US;if(!Zt(e)&&!MS(e))throw new TypeError("data should be a string, Buffer or Uint8Array");if(Jt(t)&&(i=t,t=null),e.length===0){i&&i();return}this._requestBodyLength+e.length<=this._options.maxBodyLength?(this._requestBodyLength+=e.length,this._requestBodyBuffers.push({data:e,encoding:t}),this._currentRequest.write(e,t,i)):(this.emit("error",new FS),this.abort())};Se.prototype.end=function(e,t,i){if(Jt(e)?(i=e,e=t=null):Jt(t)&&(i=t,t=null),!e)this._ended=this._ending=!0,this._currentRequest.end(null,null,i);else{var a=this,r=this._currentRequest;this.write(e,t,function(){a._ended=!0,r.end(null,null,i)}),this._ending=!0}};Se.prototype.setHeader=function(e,t){this._options.headers[e]=t,this._currentRequest.setHeader(e,t)};Se.prototype.removeHeader=function(e){delete this._options.headers[e],this._currentRequest.removeHeader(e)};Se.prototype.setTimeout=function(e,t){var i=this;function a(s){s.setTimeout(e),s.removeListener("timeout",s.destroy),s.addListener("timeout",s.destroy)}n(a,"destroyOnTimeout");function r(s){i._timeout&&clearTimeout(i._timeout),i._timeout=setTimeout(function(){i.emit("timeout"),o()},e),a(s)}n(r,"startTimer");function o(){i._timeout&&(clearTimeout(i._timeout),i._timeout=null),i.removeListener("abort",o),i.removeListener("error",o),i.removeListener("response",o),i.removeListener("close",o),t&&i.removeListener("timeout",t),i.socket||i._currentRequest.removeListener("socket",r)}return n(o,"clearTimer"),t&&this.on("timeout",t),this.socket?r(this.socket):this._currentRequest.once("socket",r),this.on("socket",a),this.on("abort",o),this.on("error",o),this.on("response",o),this.on("close",o),this};["flushHeaders","getHeader","setNoDelay","setSocketKeepAlive"].forEach(function(e){Se.prototype[e]=function(t,i){return this._currentRequest[e](t,i)}});["aborted","connection","socket"].forEach(function(e){Object.defineProperty(Se.prototype,e,{get:n(function(){return this._currentRequest[e]},"get")})});Se.prototype._sanitizeOptions=function(e){if(e.headers||(e.headers={}),e.host&&(e.hostname||(e.hostname=e.host),delete e.host),!e.pathname&&e.path){var t=e.path.indexOf("?");t<0?e.pathname=e.path:(e.pathname=e.path.substring(0,t),e.search=e.path.substring(t))}};Se.prototype._performRequest=function(){var e=this._options.protocol,t=this._options.nativeProtocols[e];if(!t)throw new TypeError("Unsupported protocol "+e);if(this._options.agents){var i=e.slice(0,-1);this._options.agent=this._options.agents[i]}var a=this._currentRequest=t.request(this._options,this._onNativeResponse);a._redirectable=this;for(var r of vc)a.on(r,xc[r]);if(this._currentUrl=/^\//.test(this._options.path)?Ba.format(this._options):this._options.path,this._isRedirect){var o=0,s=this,c=this._requestBodyBuffers;n(function u(l){if(a===s._currentRequest)if(l)s.emit("error",l);else if(o<c.length){var p=c[o++];a.finished||a.write(p.data,p.encoding,u)}else s._ended&&a.end()},"writeNext")()}};Se.prototype._processResponse=function(e){var t=e.statusCode;this._options.trackRedirects&&this._redirects.push({url:this._currentUrl,headers:e.headers,statusCode:t});var i=e.headers.location;if(!i||this._options.followRedirects===!1||t<300||t>=400){e.responseUrl=this._currentUrl,e.redirects=this._redirects,this.emit("response",e),this._requestBodyBuffers=[];return}if(bc(this._currentRequest),e.destroy(),++this._redirectCount>this._options.maxRedirects)throw new IS;var a,r=this._options.beforeRedirect;r&&(a=Object.assign({Host:e.req.getHeader("host")},this._options.headers));var o=this._options.method;((t===301||t===302)&&this._options.method==="POST"||t===303&&!/^(?:GET|HEAD)$/.test(this._options.method))&&(this._options.method="GET",this._requestBodyBuffers=[],lc(/^content-/i,this._options.headers));var s=lc(/^host$/i,this._options.headers),c=gc(this._currentUrl),u=s||c.host,l=/^\w+:/.test(i)?this._currentUrl:Ba.format(Object.assign(c,{host:u})),p=DS(i,l);if(uv("redirecting to",p.href),this._isRedirect=!0,dc(p,this._options),(p.protocol!==c.protocol&&p.protocol!=="https:"||p.host!==u&&!LS(p.host,u))&&lc(/^(?:(?:proxy-)?authorization|cookie)$/i,this._options.headers),Jt(r)){var h={headers:e.headers,statusCode:t},m={url:l,method:o,headers:a};r(this._options,h,m),this._sanitizeOptions(this._options)}this._performRequest()};function dv(e){var t={maxRedirects:21,maxBodyLength:10485760},i={};return Object.keys(e).forEach(function(a){var r=a+":",o=i[r]=e[a],s=t[a]=Object.create(o);function c(l,p,h){return PS(l)?l=dc(l):Zt(l)?l=dc(gc(l)):(h=p,p=mv(l),l={protocol:r}),Jt(p)&&(h=p,p=null),p=Object.assign({maxRedirects:t.maxRedirects,maxBodyLength:t.maxBodyLength},l,p),p.nativeProtocols=i,!Zt(p.host)&&!Zt(p.hostname)&&(p.hostname="::1"),mc.equal(p.protocol,r,"protocol mismatch"),uv("options",p),new Se(p,h)}n(c,"request");function u(l,p,h){var m=s.request(l,p,h);return m.end(),m}n(u,"get"),Object.defineProperties(s,{request:{value:c,configurable:!0,enumerable:!0,writable:!0},get:{value:u,configurable:!0,enumerable:!0,writable:!0}})}),t}n(dv,"wrap");function fv(){}n(fv,"noop");function gc(e){var t;if(hc)t=new ja(e);else if(t=mv(Ba.parse(e)),!Zt(t.protocol))throw new pc({input:e});return t}n(gc,"parseUrl");function DS(e,t){return hc?new ja(e,t):gc(Ba.resolve(t,e))}n(DS,"resolveUrl");function mv(e){if(/^\[/.test(e.hostname)&&!/^\[[:0-9a-f]+\]$/i.test(e.hostname))throw new pc({input:e.href||e});if(/^\[/.test(e.host)&&!/^\[[:0-9a-f]+\](:\d+)?$/i.test(e.host))throw new pc({input:e.href||e});return e}n(mv,"validateUrl");function dc(e,t){var i=t||{};for(var a of OS)i[a]=e[a];return i.hostname.startsWith("[")&&(i.hostname=i.hostname.slice(1,-1)),i.port!==""&&(i.port=Number(i.port)),i.path=i.search?i.pathname+i.search:i.pathname,i}n(dc,"spreadUrlObject");function lc(e,t){var i;for(var a in t)e.test(a)&&(i=t[a],delete t[a]);return i===null||typeof i>"u"?void 0:String(i).trim()}n(lc,"removeMatchingHeaders");function qa(e,t,i){function a(r){Jt(Error.captureStackTrace)&&Error.captureStackTrace(this,this.constructor),Object.assign(this,r||{}),this.code=e,this.message=this.cause?t+": "+this.cause.message:t}return n(a,"CustomError"),a.prototype=new(i||Error),Object.defineProperties(a.prototype,{constructor:{value:a,enumerable:!1},name:{value:"Error ["+e+"]",enumerable:!1}}),a}n(qa,"createErrorType");function bc(e,t){for(var i of vc)e.removeListener(i,xc[i]);e.on("error",fv),e.destroy(t)}n(bc,"destroyRequest");function LS(e,t){mc(Zt(e)&&Zt(t));var i=e.length-t.length-1;return i>0&&e[i]==="."&&e.endsWith(t)}n(LS,"isSubdomain");function Zt(e){return typeof e=="string"||e instanceof String}n(Zt,"isString");function Jt(e){return typeof e=="function"}n(Jt,"isFunction");function MS(e){return typeof e=="object"&&"length"in e}n(MS,"isBuffer");function PS(e){return ja&&e instanceof ja}n(PS,"isURL");yc.exports=dv({http:AS,https:CS});yc.exports.wrap=dv});var fk={};Kc(fk,{TestRunMonitor:()=>_n});module.exports=lx(fk);var Sn=n(e=>new Promise(t=>setTimeout(t,e)),"awaitSleep");var ex=require("child_process"),wn=require("crypto"),J=require("fs"),tx=require("http"),ix=ce(require("net")),Ne=require("path");var xf=ce(nf()),dt=require("fs"),gf=require("path");var Ye=ce(require("path")),_s=require("fs");var hs=require("path"),Mr=require("fs");function W_(e,t,i=10){let a=e;for(let r=0;r<i;r++){let o=(0,hs.join)(a,"package.json");if((0,Mr.existsSync)(o))try{if(JSON.parse((0,Mr.readFileSync)(o,"utf8")).name===t)return a}catch{}a=(0,hs.join)(a,"..")}}n(W_,"findRepositoryRoot");function of(e,t=10){return W_(e,"checksum-customer-engineering-workspace",t)}n(of,"findCustomerEngineeringRoot");var ws=ce(uf());var P=n((e,t)=>{if(e==null||e==="")return(t==null?void 0:t.default)??!1;let i=e.toLowerCase().trim();return i==="true"?!0:i==="false"?!1:(t==null?void 0:t.default)??!1},"parseBoolean");var o0=__dirname,df=Ye.join(__dirname,".."),hf=(0,_s.existsSync)(df)?df:o0;(0,ws.config)({path:Ye.resolve(hf,".env")});var bs=P(process.env.CHECKSUM_RUNTIME_DEV_MODE);function s0(){let e=__dirname;for(;!(0,_s.existsSync)(Ye.join(e,"package.json"));)e=Ye.join(e,"..");return e}n(s0,"findRoot");var Ri=s0(),c0=of(Ri,10);(0,ws.config)({path:[hf,c0].filter(Boolean).map(e=>Ye.resolve(e,".env")),override:!1});var jr=P(process.env.CHECKSUM_VTG_E2E_TEST_MODE),ff=Ye.join(Ri,"vtg-build","index.html"),ys=jr?!0:P(process.env.CHECKSUM_RUNTIME_REPO_MODE),mf=P(process.env.CHECKSUM_VTG_SEPARATE_PROCESS),l0=ys?Ye.join(Ri,"package","pw-report-template.html"):Ye.join(Ri,"pw-report-template.html"),p0=P(process.env.CHECKSUM_DEBUG_ANALYTICS),u0=P(process.env.CHECKSUM_LOG_ANALYTICS_TO_CONSOLE),Br={isDevMode:bs,isRepoMode:ys,CI:!!process.env.CI,checksumRootFolderBypass:jr?"packages/runtime/test/e2e/checksum":ys&&process.env.CHECKSUM_RUNTIME_ROOT_FOLDER_BYPASS_FOR_REPO_MODE?process.env.CHECKSUM_RUNTIME_ROOT_FOLDER_BYPASS_FOR_REPO_MODE:process.env.CHECKSUM_RUNTIME_ROOT_FOLDER_BYPASS,logLevel:process.env.CHECKSUM_RUNTIME_LOG_LEVEL??"warnings",checksumScript:{source:process.env.CHECKSUM_RUNTIME_SCRIPT_SOURCE??(bs?"url":"file"),url:process.env.CHECKSUM_RUNTIME_SCRIPT_URL,path:Ri+"/checksumlib.js"},runtimeRoot:Ri,playwrightReporter:{htmlReportTemplatePath:l0},bypassProxyForLocalhost:P(process.env.CHECKSUM_RUNTIME_BYPASS_PROXY_FOR_LOCALHOST),promptKillActivePlaywrightProcesses:P(process.env.CHECKSUM_RUNTIME_PROMPT_KILL_ACTIVE_PLAYWRIGHT_PROCESSES,{default:!0}),useCLIDebug:P(process.env.CHECKSUM_RUNTIME_USE_CLI_DEBUG),useRemoteDebugging:{enabled:P(process.env.CHECKSUM_RUNTIME_USE_REMOTE_DEBUGGING),port:parseInt(process.env.CHECKSUM_AGENT_RUNTIME_REMOTE_DEBUGGING_PORT??"9500")},testRun:{timeMachine:{active:!0,headless:!P(process.env.CHECKSUM_RUNTIME_SHOW_RUNTIME_TIME_MACHINE),recordRRwebEventsToFile:P(process.env.CHECKSUM_RUNTIME_RECORD_RRWEB_EVENTS_TO_FILE,{default:!0})},monitoring:{defaultProvider:process.env.CHECKSUM_RUNTIME_MONITORING_DEFAULT_PROVIDER??"newrelic",debugAnalytics:p0,logToConsole:u0,newrelic:{appName:process.env.CHECKSUM_RUNTIME_MONITORING_NEWRELIC_APP_NAME??"checksum-runtime",licenseKey:"b4f3f644f40df19fe3d385c75428a450FFFFNRAL",logging:P(process.env.NEW_RELIC_LOG_ENABLED,{default:!1})},segment:{writeKey:process.env.CHECKSUM_RUNTIME_MONITORING_SEGMENT_WRITE_KEY??"TMuP8uorDj4QzJfNs0gEHDO7kHozVBOo",devWriteKey:process.env.CHECKSUM_RUNTIME_MONITORING_SEGMENT_DEV_WRITE_KEY??"gofHHwvdNHJNmb7KqACUmypZclVHEQ2l"}},autoRecovery:{verboseConsoleLog:P(process.env.CHECKSUM_RUNTIME_AUTO_RECOVERY_CONSOLE_LOG,{default:!1}),sessionTimeout:18e4},disableAutoRecovery:P(process.env.CHECKSUM_RUNTIME_DISABLE_AUTO_RECOVERY),disableHostReports:P(process.env.CHECKSUM_RUNTIME_DISABLE_HOST_REPORTS),request:{userEmail:process.env.CHECKSUM_RUNTIME_REQUEST_USER_EMAIL,reason:process.env.CHECKSUM_RUNTIME_REQUEST_REASON},platform:{name:process.env.CHECKSUM_RUNTIME_PLATFORM_NAME},runType:process.env.CHECKSUM_RUNTIME_RUN_TYPE},vtg:{isSeparateProcess:mf,isE2ETestMode:jr,writeLogFile:P(process.env.CHECKSUM_VTG_WRITE_LOG_FILE,{default:!0}),appSource:process.env.CHECKSUM_VTG_APP_SOURCE??(bs?"served-app":"served-build-file"),localUrl:`file://${ff}`,localBuildPath:ff,appURL:process.env.CHECKSUM_VTG_APP_URL,writeRrwebEventsToFile:P(process.env.CHECKSUM_VTG_RECORD_EVENTS_TO_FILE),useFakeStory:P(process.env.CHECKSUM_VTG_USE_FAKE_STORY)||jr,logAPIServer:{interval:P(process.env.CHECKSUM_VTG_LOG_API_SERVER_INTERVAL),httpTransactions:P(process.env.CHECKSUM_VTG_LOG_API_SERVER_HTTP_TRANSACTIONS,{default:!0})},customerEngRepoInternalUtilsRelativePath:process.env.CHECKSUM_VTG_CUSTOMER_ENG_REPO_INTERNAL_UTILS_RELATIVE_PATH??"tools/internal-utils.ts",fakeStory:{goal:process.env.CHECKSUM_VTG_FAKE_STORY_GOAL??"Send email via outreach list",instructions:process.env.CHECKSUM_VTG_FAKE_STORY_INSTRUCTIONS??"Make sure to select a user from the list first"},fakeTestGeneration:{internalTestId:process.env.CHECKSUM_VTG_FAKE_STORY_INTERNAL_TEST_ID??`tempID${Date.now().toString().slice(-5)}`,generationBatchId:process.env.CHECKSUM_VTG_FAKE_GENERATION_BATCH_ID??`tempID${Date.now().toString().slice(-5)}`},remoteDebugging:mf?!0:P(process.env.CHECKSUM_VTG_REMOTE_DEBUGGING),appRemoteDebuggingPort:parseInt(process.env.CHECKSUM_VTG_REMOTE_DEBUGGING_PORT??"9230"),vtgRemoteDebuggingPort:parseInt(process.env.CHECKSUM_VTG_REMOTE_DEBUGGING_PORT??"9231"),taskTimeMachine:{showTaskTimeMachine:P(process.env.CHECKSUM_VTG_SHOW_TASK_TIME_MACHINE),taskTimeout:parseInt(process.env.CHECKSUM_VTG_TASK_TIME_MACHINE_TIMEOUT??"240000"),debugPort:parseInt(process.env.CHECKSUM_VTG_TASK_TIME_MACHINE_DEBUG_PORT??"9232"),logPerformance:P(process.env.CHECKSUM_VTG_TASK_TIME_MACHINE_LOG_PERFORMANCE,{default:!0})},aiAssertions:{disabled:P(process.env.CHECKSUM_VTG_AI_ASSERTIONS_DISABLED),allowRefactoring:P(process.env.CHECKSUM_VTG_ALLOW_AI_ASSERTIONS_REFACTORING),allowFiltering:P(process.env.CHECKSUM_VTG_ALLOW_AI_ASSERTIONS_FILTERING),logPerformance:P(process.env.CHECKSUM_VTG_AI_ASSERTIONS_LOG_PERFORMANCE,{default:!1})},aiLocators:{disabled:P(process.env.CHECKSUM_VTG_AI_LOCATORS_DISABLED),useFakeAILocators:P(process.env.CHECKSUM_VTG_USE_FAKE_AI_LOCATORS)}},benchmark:P(process.env.BENCHMARK_MODE),buildTime:process.env.CHECKSUM_RUNTIME_BUILD_TIME??"unknown",llm:{models:{openai:{key:process.env.CHECKSUM_RUNTIME_OPENAI_API_KEY},anthropic:{key:process.env.CHECKSUM_RUNTIME_ANTHROPIC_API_KEY},gemini:{model:process.env.CHECKSUM_RUNTIME_GEMINI_MODEL},groq:{apiKey:process.env.CHECKSUM_RUNTIME_GROQ_API_KEY}}},gcp:{credentialsFile:process.env.CHECKSUM_RUNTIME_GCP_CREDENTIALS_FILE}};var qr=n(e=>isNaN(e)?0:e,"getStat");var vf=n((e,t)=>Object.values(t[e]||{}).some(i=>{var a,r;return(r=(a=i.autoRecoveryMetadata)==null?void 0:a.data)==null?void 0:r.autoRecovered}),"isAutoRecovered");var Es=class Es{constructor(t,i,a,r={},o={},s){this.reportHTMLFilePath=t;this.testRunUUID=i;this.pwTestIdToChecksumTestId=a;this.playwrightIdToMetadata=r;this.channel=s;this.supportVideo=!1;this.config={hosted:!0,assetsBaseURL:"https://api.checksum.ai/api/test-runs"};this.config={...this.config,...o}}async process(){this.channel.debug("Extracting report...");let t=this.extractReportBase64();this.channel.debug("Preparing new report...");let i=await this.editZipFile(t);this.channel.debug("Writing report to file..."),this.writeFile(i)}testHasTrace(t,i){try{if(!this.report)return!0;let a=Object.keys(this.pwTestIdToChecksumTestId??{}).find(o=>this.pwTestIdToChecksumTestId[o]===t);if(!a)return!0;let r=n(o=>o.some(s=>{var c;return(c=s.attachments)==null?void 0:c.some(u=>u.name==="trace")}),"hasTrace");for(let o of this.report.files)for(let s of o.tests)if(s.testId===a&&s.projectName===i&&r(s.results))return!0;return!1}catch(a){return this.channel.debug("Failed to check if test has trace, assuming trace exists",a),!0}}getStatPerFile(){let t=[];return this.report.files.forEach(i=>{i.tests.forEach(a=>{var r;t.push({checksumTestId:this.pwTestIdToChecksumTestId[a.testId],playwrightTestId:a.testId,success:!!a.ok,recovered:vf(a.testId,this.playwrightIdToMetadata),bug:a.tags.includes("bug")||a.annotations.some(o=>o.type==="bug")||a.title.includes("@bug"),annotations:a.annotations&&a.annotations.length>0?a.annotations.filter(o=>!!(o!=null&&o.type)).map(o=>({type:o.type,description:o.description||""})):[],outcome:a.outcome,filePath:(r=a.location)==null?void 0:r.file})})}),t}getProcessedFilePath(){return this.reportHTMLFilePath}extractReportBase64(){var a;try{let r=(a=(0,dt.statSync)(this.reportHTMLFilePath))==null?void 0:a.size;this.channel.debug(`Report HTML file size approximately ${r} bytes`)}catch(r){this.channel.debug(`Failed to retrieve file size for ${this.reportHTMLFilePath}`,r)}let i=(0,dt.readFileSync)(this.reportHTMLFilePath,"utf-8").match(/window\.playwrightReportBase64 = "(.*)";/);if(i&&i[1])return i[1];{let r="Could not extract playwrightReportBase64 from HTML file";throw this.channel.debug(r),new Error(r)}}writeFile(t){let i=(0,dt.readFileSync)(Br.playwrightReporter.htmlReportTemplatePath,"utf-8");i=i+`<script>
|
|
10
10
|
window.playwrightReportBase64 = "${t}";
|
|
11
11
|
</script>`;let a=this.getProcessedFilePath().replace(".html",".backup.html");(0,dt.writeFileSync)(a,(0,dt.readFileSync)(this.getProcessedFilePath())),(0,dt.writeFileSync)(this.getProcessedFilePath(),i)}getReportsStats(){return this.stats}async editZipFile(t){let i=t.replace("data:application/zip;base64,",""),a=await(0,xf.loadAsync)(i,{base64:!0});for(let o of Object.keys(a.files)){let s=a.file(o);if(s){let c=await s.async("string"),u=JSON.parse(c);o.startsWith("report")?(this.handleReportJSON(u),this.report=u,this.extractStats(u)):this.handleFileReportJSON(u),a.file(o,JSON.stringify(u))}}return`data:application/zip;base64,${await a.generateAsync({type:"base64",compression:"DEFLATE"})}`}extractStats(t){if(!t.stats)return;let{expected:i,unexpected:a,flaky:r}=t.stats,o=this.getStatPerFile(),s={passed:qr(r)+qr(i),failed:qr(a),bug:o.filter(c=>c.bug).length,recovered:o.filter(c=>c.recovered).length,tests:o};o.forEach(c=>{c.bug&&(c.outcome==="expected"||c.outcome==="flaky"?s.passed--:c.outcome==="unexpected"&&s.failed--)}),this.stats=s}makeAttachmentPath(t){return this.config.hosted?`${this.config.assetsBaseURL}/${this.testRunUUID}/report-data-file-url?fileName=${(0,gf.basename)(t)}`:t}handleReportJSON(t){let i={},a=n(r=>{let o=r.testId,s=this.playwrightIdToMetadata[o];s&&(i[o]=s),r.results.forEach(c=>{this.processAttachments(c.attachments,r.testId)})},"getChecksumMetadataForPWTestId");t.files.forEach(r=>{r.tests.forEach(a)}),t.checksumMetadata=i}handleFileReportJSON(t){var i;(i=t.tests)==null||i.forEach(a=>{var r;(r=a.results)==null||r.forEach(o=>{this.processAttachments(o.attachments,a.testId)})})}processAttachments(t,i){if(t.forEach(a=>this.updateAttachment(a,i)),!this.supportVideo){let a=t.findIndex(r=>r.name==="video");a!==-1&&t.splice(a,1)}}updateAttachment(t,i){t.path&&(t.path=this.makeAttachmentPath(t.path))}};n(Es,"PlaywrightReportProcessor");var zr=Es;var bf={trace:"application/zip","trace-backup-file":"application/zip",har:"application/zip",report:"text/html","rrweb-recording":"application/json"},f0={click:"click",fill:"input",click_and_type:"click_and_type",clear_and_type:"clear_and_type",double_click:"double_click",drag_and_drop:"drag_and_drop",hover:"hover",navigate:"navigation",keystroke:"keystroke",selectoption:"selectoption",upload_files:"upload_files",wait:"wait",get_more_items:"get_more_items",reset:void 0,save:void 0,fail:void 0,finish:void 0,dismiss_modal:void 0,vision_help:void 0,switch_tab:"switch_tab",expand_interactable_elements:void 0,approve_release:void 0,logout_and_login:"logout_and_login",canvas_click:"canvas_click",native_accept:"native_accept",native_dismiss:"native_dismiss",hard_assertion:void 0,soft_assertion:void 0,recovery:void 0,scroll:void 0},p1=Object.fromEntries(Object.entries(f0).map(e=>e.reverse())),m0={goto:"navigation",click:"click",dblclick:"double_click",dragTo:"drag_and_drop",check:"check",uncheck:"uncheck",fill:"input",hover:"hover",selectOption:"selectoption",waitForTimeout:"wait","keyboard.press":"keystroke",setInputFiles:"upload_files",getPage:"switch_tab",reauthenticate:"logout_and_login",canvasClick:"canvas_click"},u1=Object.fromEntries(Object.entries(m0).map(e=>e.reverse()));var d1={input:[1,2],selectoption:[1,2],keystroke:[1,2],wait:[1,2],navigation:[1,2],click:[0,1],double_click:[0,1],drag_and_drop:[1,2],upload_files:[1,2],canvas_click:[1,2],logout_and_login:[1],login:[1,2],click_and_type:[1,2],clear_and_type:[1,2],check:[0,1],uncheck:[0,1],hover:[0,1]},f1={input:1,selectoption:1,keystroke:1,wait:-1,navigation:1,click:0,double_click:0,drag_and_drop:1,upload_files:1,canvas_click:-1,logout_and_login:-1,login:1,click_and_type:0,clear_and_type:0,check:0,uncheck:0,hover:0,native_accept:-1,native_dismiss:-1};function Ra(e,t){return n(function(){return e.apply(t,arguments)},"wrap")}n(Ra,"bind");var{toString:h0}=Object.prototype,{getPrototypeOf:ks}=Object,{iterator:Wr,toStringTag:_f}=Symbol,Kr=(e=>t=>{let i=h0.call(t);return e[i]||(e[i]=i.slice(8,-1).toLowerCase())})(Object.create(null)),Be=n(e=>(e=e.toLowerCase(),t=>Kr(t)===e),"kindOfTest"),Gr=n(e=>t=>typeof t===e,"typeOfTest"),{isArray:Ci}=Array,Ai=Gr("undefined");function Aa(e){return e!==null&&!Ai(e)&&e.constructor!==null&&!Ai(e.constructor)&&_e(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}n(Aa,"isBuffer");var wf=Be("ArrayBuffer");function v0(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&wf(e.buffer),t}n(v0,"isArrayBufferView");var x0=Gr("string"),_e=Gr("function"),Ef=Gr("number"),Ca=n(e=>e!==null&&typeof e=="object","isObject"),g0=n(e=>e===!0||e===!1,"isBoolean"),Hr=n(e=>{if(Kr(e)!=="object")return!1;let t=ks(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(_f in e)&&!(Wr in e)},"isPlainObject"),b0=n(e=>{if(!Ca(e)||Aa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},"isEmptyObject"),y0=Be("Date"),_0=Be("File"),w0=Be("Blob"),E0=Be("FileList"),S0=n(e=>Ca(e)&&_e(e.pipe),"isStream"),k0=n(e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||_e(e.append)&&((t=Kr(e))==="formdata"||t==="object"&&_e(e.toString)&&e.toString()==="[object FormData]"))},"isFormData"),T0=Be("URLSearchParams"),[R0,A0,C0,O0]=["ReadableStream","Request","Response","Headers"].map(Be),I0=n(e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),"trim");function Oa(e,t,{allOwnKeys:i=!1}={}){if(e===null||typeof e>"u")return;let a,r;if(typeof e!="object"&&(e=[e]),Ci(e))for(a=0,r=e.length;a<r;a++)t.call(null,e[a],a,e);else{if(Aa(e))return;let o=i?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length,c;for(a=0;a<s;a++)c=o[a],t.call(null,e[c],c,e)}}n(Oa,"forEach");function Sf(e,t){if(Aa(e))return null;t=t.toLowerCase();let i=Object.keys(e),a=i.length,r;for(;a-- >0;)if(r=i[a],t===r.toLowerCase())return r;return null}n(Sf,"findKey");var Wt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,kf=n(e=>!Ai(e)&&e!==Wt,"isContextDefined");function Ss(){let{caseless:e,skipUndefined:t}=kf(this)&&this||{},i={},a=n((r,o)=>{let s=e&&Sf(i,o)||o;Hr(i[s])&&Hr(r)?i[s]=Ss(i[s],r):Hr(r)?i[s]=Ss({},r):Ci(r)?i[s]=r.slice():(!t||!Ai(r))&&(i[s]=r)},"assignValue");for(let r=0,o=arguments.length;r<o;r++)arguments[r]&&Oa(arguments[r],a);return i}n(Ss,"merge");var F0=n((e,t,i,{allOwnKeys:a}={})=>(Oa(t,(r,o)=>{i&&_e(r)?e[o]=Ra(r,i):e[o]=r},{allOwnKeys:a}),e),"extend"),U0=n(e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),"stripBOM"),N0=n((e,t,i,a)=>{e.prototype=Object.create(t.prototype,a),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),i&&Object.assign(e.prototype,i)},"inherits"),D0=n((e,t,i,a)=>{let r,o,s,c={};if(t=t||{},e==null)return t;do{for(r=Object.getOwnPropertyNames(e),o=r.length;o-- >0;)s=r[o],(!a||a(s,e,t))&&!c[s]&&(t[s]=e[s],c[s]=!0);e=i!==!1&&ks(e)}while(e&&(!i||i(e,t))&&e!==Object.prototype);return t},"toFlatObject"),L0=n((e,t,i)=>{e=String(e),(i===void 0||i>e.length)&&(i=e.length),i-=t.length;let a=e.indexOf(t,i);return a!==-1&&a===i},"endsWith"),M0=n(e=>{if(!e)return null;if(Ci(e))return e;let t=e.length;if(!Ef(t))return null;let i=new Array(t);for(;t-- >0;)i[t]=e[t];return i},"toArray"),P0=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ks(Uint8Array)),j0=n((e,t)=>{let a=(e&&e[Wr]).call(e),r;for(;(r=a.next())&&!r.done;){let o=r.value;t.call(e,o[0],o[1])}},"forEachEntry"),B0=n((e,t)=>{let i,a=[];for(;(i=e.exec(t))!==null;)a.push(i);return a},"matchAll"),q0=Be("HTMLFormElement"),z0=n(e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,n(function(i,a,r){return a.toUpperCase()+r},"replacer")),"toCamelCase"),yf=(({hasOwnProperty:e})=>(t,i)=>e.call(t,i))(Object.prototype),H0=Be("RegExp"),Tf=n((e,t)=>{let i=Object.getOwnPropertyDescriptors(e),a={};Oa(i,(r,o)=>{let s;(s=t(r,o,e))!==!1&&(a[o]=s||r)}),Object.defineProperties(e,a)},"reduceDescriptors"),W0=n(e=>{Tf(e,(t,i)=>{if(_e(e)&&["arguments","caller","callee"].indexOf(i)!==-1)return!1;let a=e[i];if(_e(a)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+i+"'")})}})},"freezeMethods"),K0=n((e,t)=>{let i={},a=n(r=>{r.forEach(o=>{i[o]=!0})},"define");return Ci(e)?a(e):a(String(e).split(t)),i},"toObjectSet"),G0=n(()=>{},"noop"),V0=n((e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,"toFiniteNumber");function $0(e){return!!(e&&_e(e.append)&&e[_f]==="FormData"&&e[Wr])}n($0,"isSpecCompliantForm");var Z0=n(e=>{let t=new Array(10),i=n((a,r)=>{if(Ca(a)){if(t.indexOf(a)>=0)return;if(Aa(a))return a;if(!("toJSON"in a)){t[r]=a;let o=Ci(a)?[]:{};return Oa(a,(s,c)=>{let u=i(s,r+1);!Ai(u)&&(o[c]=u)}),t[r]=void 0,o}}return a},"visit");return i(e,0)},"toJSONObject"),J0=Be("AsyncFunction"),Y0=n(e=>e&&(Ca(e)||_e(e))&&_e(e.then)&&_e(e.catch),"isThenable"),Rf=((e,t)=>e?setImmediate:t?((i,a)=>(Wt.addEventListener("message",({source:r,data:o})=>{r===Wt&&o===i&&a.length&&a.shift()()},!1),r=>{a.push(r),Wt.postMessage(i,"*")}))(`axios@${Math.random()}`,[]):i=>setTimeout(i))(typeof setImmediate=="function",_e(Wt.postMessage)),X0=typeof queueMicrotask<"u"?queueMicrotask.bind(Wt):typeof process<"u"&&process.nextTick||Rf,Q0=n(e=>e!=null&&_e(e[Wr]),"isIterable"),d={isArray:Ci,isArrayBuffer:wf,isBuffer:Aa,isFormData:k0,isArrayBufferView:v0,isString:x0,isNumber:Ef,isBoolean:g0,isObject:Ca,isPlainObject:Hr,isEmptyObject:b0,isReadableStream:R0,isRequest:A0,isResponse:C0,isHeaders:O0,isUndefined:Ai,isDate:y0,isFile:_0,isBlob:w0,isRegExp:H0,isFunction:_e,isStream:S0,isURLSearchParams:T0,isTypedArray:P0,isFileList:E0,forEach:Oa,merge:Ss,extend:F0,trim:I0,stripBOM:U0,inherits:N0,toFlatObject:D0,kindOf:Kr,kindOfTest:Be,endsWith:L0,toArray:M0,forEachEntry:j0,matchAll:B0,isHTMLForm:q0,hasOwnProperty:yf,hasOwnProp:yf,reduceDescriptors:Tf,freezeMethods:W0,toObjectSet:K0,toCamelCase:z0,noop:G0,toFiniteNumber:V0,findKey:Sf,global:Wt,isContextDefined:kf,isSpecCompliantForm:$0,toJSONObject:Z0,isAsyncFn:J0,isThenable:Y0,setImmediate:Rf,asap:X0,isIterable:Q0};function Oi(e,t,i,a,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),i&&(this.config=i),a&&(this.request=a),r&&(this.response=r,this.status=r.status?r.status:null)}n(Oi,"AxiosError");d.inherits(Oi,Error,{toJSON:n(function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:d.toJSONObject(this.config),code:this.code,status:this.status}},"toJSON")});var Af=Oi.prototype,Cf={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Cf[e]={value:e}});Object.defineProperties(Oi,Cf);Object.defineProperty(Af,"isAxiosError",{value:!0});Oi.from=(e,t,i,a,r,o)=>{let s=Object.create(Af);d.toFlatObject(e,s,n(function(p){return p!==Error.prototype},"filter"),l=>l!=="isAxiosError");let c=e&&e.message?e.message:"Error",u=t==null&&e?e.code:t;return Oi.call(s,c,u,i,a,r),e&&s.cause==null&&Object.defineProperty(s,"cause",{value:e,configurable:!0}),s.name=e&&e.name||"Error",o&&Object.assign(s,o),s};var k=Oi;var Uh=ce(Fh(),1),rn=Uh.default;function Ks(e){return d.isPlainObject(e)||d.isArray(e)}n(Ks,"isVisitable");function Dh(e){return d.endsWith(e,"[]")?e.slice(0,-2):e}n(Dh,"removeBrackets");function Nh(e,t,i){return e?e.concat(t).map(n(function(r,o){return r=Dh(r),!i&&o?"["+r+"]":r},"each")).join(i?".":""):t}n(Nh,"renderKey");function PE(e){return d.isArray(e)&&!e.some(Ks)}n(PE,"isFlatArray");var jE=d.toFlatObject(d,{},null,n(function(t){return/^is[A-Z]/.test(t)},"filter"));function BE(e,t,i){if(!d.isObject(e))throw new TypeError("target must be an object");t=t||new(rn||FormData),i=d.toFlatObject(i,{metaTokens:!0,dots:!1,indexes:!1},!1,n(function(x,b){return!d.isUndefined(b[x])},"defined"));let a=i.metaTokens,r=i.visitor||p,o=i.dots,s=i.indexes,u=(i.Blob||typeof Blob<"u"&&Blob)&&d.isSpecCompliantForm(t);if(!d.isFunction(r))throw new TypeError("visitor must be a function");function l(f){if(f===null)return"";if(d.isDate(f))return f.toISOString();if(d.isBoolean(f))return f.toString();if(!u&&d.isBlob(f))throw new k("Blob is not supported. Use a Buffer instead.");return d.isArrayBuffer(f)||d.isTypedArray(f)?u&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}n(l,"convertValue");function p(f,x,b){let y=f;if(f&&!b&&typeof f=="object"){if(d.endsWith(x,"{}"))x=a?x:x.slice(0,-2),f=JSON.stringify(f);else if(d.isArray(f)&&PE(f)||(d.isFileList(f)||d.endsWith(x,"[]"))&&(y=d.toArray(f)))return x=Dh(x),y.forEach(n(function(E,w){!(d.isUndefined(E)||E===null)&&t.append(s===!0?Nh([x],w,o):s===null?x:x+"[]",l(E))},"each")),!1}return Ks(f)?!0:(t.append(Nh(b,x,o),l(f)),!1)}n(p,"defaultVisitor");let h=[],m=Object.assign(jE,{defaultVisitor:p,convertValue:l,isVisitable:Ks});function v(f,x){if(!d.isUndefined(f)){if(h.indexOf(f)!==-1)throw Error("Circular reference detected in "+x.join("."));h.push(f),d.forEach(f,n(function(y,_){(!(d.isUndefined(y)||y===null)&&r.call(t,y,d.isString(_)?_.trim():_,x,m))===!0&&v(y,x?x.concat(_):[_])},"each")),h.pop()}}if(n(v,"build"),!d.isObject(e))throw new TypeError("data must be an object");return v(e),t}n(BE,"toFormData");var Rt=BE;function Lh(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,n(function(a){return t[a]},"replacer"))}n(Lh,"encode");function Mh(e,t){this._pairs=[],e&&Rt(e,this,t)}n(Mh,"AxiosURLSearchParams");var Ph=Mh.prototype;Ph.append=n(function(t,i){this._pairs.push([t,i])},"append");Ph.toString=n(function(t){let i=t?function(a){return t.call(this,a,Lh)}:Lh;return this._pairs.map(n(function(r){return i(r[0])+"="+i(r[1])},"each"),"").join("&")},"toString");var jh=Mh;function qE(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}n(qE,"encode");function Gt(e,t,i){if(!t)return e;let a=i&&i.encode||qE;d.isFunction(i)&&(i={serialize:i});let r=i&&i.serialize,o;if(r?o=r(t,i):o=d.isURLSearchParams(t)?t.toString():new jh(t,i).toString(a),o){let s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}n(Gt,"buildURL");var $s=class $s{constructor(){this.handlers=[]}use(t,i,a){return this.handlers.push({fulfilled:t,rejected:i,synchronous:a?a.synchronous:!1,runWhen:a?a.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){d.forEach(this.handlers,n(function(a){a!==null&&t(a)},"forEachHandler"))}};n($s,"InterceptorManager");var Gs=$s,Vs=Gs;var Di={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var Hh=ce(require("crypto"),1);var Bh=ce(require("url"),1),qh=Bh.default.URLSearchParams;var Zs="abcdefghijklmnopqrstuvwxyz",zh="0123456789",Wh={DIGIT:zh,ALPHA:Zs,ALPHA_DIGIT:Zs+Zs.toUpperCase()+zh},zE=n((e=16,t=Wh.ALPHA_DIGIT)=>{let i="",{length:a}=t,r=new Uint32Array(e);Hh.default.randomFillSync(r);for(let o=0;o<e;o++)i+=t[r[o]%a];return i},"generateString"),Kh={isNode:!0,classes:{URLSearchParams:qh,FormData:rn,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:Wh,generateString:zE,protocols:["http","https","file","data"]};var Xs={};Kc(Xs,{hasBrowserEnv:()=>Ys,hasStandardBrowserEnv:()=>HE,hasStandardBrowserWebWorkerEnv:()=>WE,navigator:()=>Js,origin:()=>KE});var Ys=typeof window<"u"&&typeof document<"u",Js=typeof navigator=="object"&&navigator||void 0,HE=Ys&&(!Js||["ReactNative","NativeScript","NS"].indexOf(Js.product)<0),WE=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",KE=Ys&&window.location.href||"http://localhost";var j={...Xs,...Kh};function Qs(e,t){return Rt(e,new j.classes.URLSearchParams,{visitor:n(function(i,a,r,o){return j.isNode&&d.isBuffer(i)?(this.append(a,i.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},"visitor"),...t})}n(Qs,"toURLEncodedForm");function GE(e){return d.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}n(GE,"parsePropPath");function VE(e){let t={},i=Object.keys(e),a,r=i.length,o;for(a=0;a<r;a++)o=i[a],t[o]=e[o];return t}n(VE,"arrayToObject");function $E(e){function t(i,a,r,o){let s=i[o++];if(s==="__proto__")return!0;let c=Number.isFinite(+s),u=o>=i.length;return s=!s&&d.isArray(r)?r.length:s,u?(d.hasOwnProp(r,s)?r[s]=[r[s],a]:r[s]=a,!c):((!r[s]||!d.isObject(r[s]))&&(r[s]=[]),t(i,a,r[s],o)&&d.isArray(r[s])&&(r[s]=VE(r[s])),!c)}if(n(t,"buildPath"),d.isFormData(e)&&d.isFunction(e.entries)){let i={};return d.forEachEntry(e,(a,r)=>{t(GE(a),r,i,0)}),i}return null}n($E,"formDataToJSON");var nn=$E;function ZE(e,t,i){if(d.isString(e))try{return(t||JSON.parse)(e),d.trim(e)}catch(a){if(a.name!=="SyntaxError")throw a}return(i||JSON.stringify)(e)}n(ZE,"stringifySafely");var ec={transitional:Di,adapter:["xhr","http","fetch"],transformRequest:[n(function(t,i){let a=i.getContentType()||"",r=a.indexOf("application/json")>-1,o=d.isObject(t);if(o&&d.isHTMLForm(t)&&(t=new FormData(t)),d.isFormData(t))return r?JSON.stringify(nn(t)):t;if(d.isArrayBuffer(t)||d.isBuffer(t)||d.isStream(t)||d.isFile(t)||d.isBlob(t)||d.isReadableStream(t))return t;if(d.isArrayBufferView(t))return t.buffer;if(d.isURLSearchParams(t))return i.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(a.indexOf("application/x-www-form-urlencoded")>-1)return Qs(t,this.formSerializer).toString();if((c=d.isFileList(t))||a.indexOf("multipart/form-data")>-1){let u=this.env&&this.env.FormData;return Rt(c?{"files[]":t}:t,u&&new u,this.formSerializer)}}return o||r?(i.setContentType("application/json",!1),ZE(t)):t},"transformRequest")],transformResponse:[n(function(t){let i=this.transitional||ec.transitional,a=i&&i.forcedJSONParsing,r=this.responseType==="json";if(d.isResponse(t)||d.isReadableStream(t))return t;if(t&&d.isString(t)&&(a&&!this.responseType||r)){let s=!(i&&i.silentJSONParsing)&&r;try{return JSON.parse(t,this.parseReviver)}catch(c){if(s)throw c.name==="SyntaxError"?k.from(c,k.ERR_BAD_RESPONSE,this,null,this.response):c}}return t},"transformResponse")],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:j.classes.FormData,Blob:j.classes.Blob},validateStatus:n(function(t){return t>=200&&t<300},"validateStatus"),headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};d.forEach(["delete","get","head","post","put","patch"],e=>{ec.headers[e]={}});var Li=ec;var JE=d.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Gh=n(e=>{let t={},i,a,r;return e&&e.split(`
|
|
12
12
|
`).forEach(n(function(s){r=s.indexOf(":"),i=s.substring(0,r).trim().toLowerCase(),a=s.substring(r+1).trim(),!(!i||t[i]&&JE[i])&&(i==="set-cookie"?t[i]?t[i].push(a):t[i]=[a]:t[i]=t[i]?t[i]+", "+a:a)},"parser")),t},"default");var Vh=Symbol("internals");function Da(e){return e&&String(e).trim().toLowerCase()}n(Da,"normalizeHeader");function on(e){return e===!1||e==null?e:d.isArray(e)?e.map(on):String(e)}n(on,"normalizeValue");function YE(e){let t=Object.create(null),i=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,a;for(;a=i.exec(e);)t[a[1]]=a[2];return t}n(YE,"parseTokens");var XE=n(e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()),"isValidHeaderName");function tc(e,t,i,a,r){if(d.isFunction(a))return a.call(this,t,i);if(r&&(t=i),!!d.isString(t)){if(d.isString(a))return t.indexOf(a)!==-1;if(d.isRegExp(a))return a.test(t)}}n(tc,"matchHeaderValue");function QE(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,i,a)=>i.toUpperCase()+a)}n(QE,"formatHeader");function eS(e,t){let i=d.toCamelCase(" "+t);["get","set","has"].forEach(a=>{Object.defineProperty(e,a+i,{value:n(function(r,o,s){return this[a].call(this,t,r,o,s)},"value"),configurable:!0})})}n(eS,"buildAccessors");var ic=class ic{constructor(t){t&&this.set(t)}set(t,i,a){let r=this;function o(c,u,l){let p=Da(u);if(!p)throw new Error("header name must be a non-empty string");let h=d.findKey(r,p);(!h||r[h]===void 0||l===!0||l===void 0&&r[h]!==!1)&&(r[h||u]=on(c))}n(o,"setHeader");let s=n((c,u)=>d.forEach(c,(l,p)=>o(l,p,u)),"setHeaders");if(d.isPlainObject(t)||t instanceof this.constructor)s(t,i);else if(d.isString(t)&&(t=t.trim())&&!XE(t))s(Gh(t),i);else if(d.isObject(t)&&d.isIterable(t)){let c={},u,l;for(let p of t){if(!d.isArray(p))throw TypeError("Object iterator must return a key-value pair");c[l=p[0]]=(u=c[l])?d.isArray(u)?[...u,p[1]]:[u,p[1]]:p[1]}s(c,i)}else t!=null&&o(i,t,a);return this}get(t,i){if(t=Da(t),t){let a=d.findKey(this,t);if(a){let r=this[a];if(!i)return r;if(i===!0)return YE(r);if(d.isFunction(i))return i.call(this,r,a);if(d.isRegExp(i))return i.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,i){if(t=Da(t),t){let a=d.findKey(this,t);return!!(a&&this[a]!==void 0&&(!i||tc(this,this[a],a,i)))}return!1}delete(t,i){let a=this,r=!1;function o(s){if(s=Da(s),s){let c=d.findKey(a,s);c&&(!i||tc(a,a[c],c,i))&&(delete a[c],r=!0)}}return n(o,"deleteHeader"),d.isArray(t)?t.forEach(o):o(t),r}clear(t){let i=Object.keys(this),a=i.length,r=!1;for(;a--;){let o=i[a];(!t||tc(this,this[o],o,t,!0))&&(delete this[o],r=!0)}return r}normalize(t){let i=this,a={};return d.forEach(this,(r,o)=>{let s=d.findKey(a,o);if(s){i[s]=on(r),delete i[o];return}let c=t?QE(o):String(o).trim();c!==o&&delete i[o],i[c]=on(r),a[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let i=Object.create(null);return d.forEach(this,(a,r)=>{a!=null&&a!==!1&&(i[r]=t&&d.isArray(a)?a.join(", "):a)}),i}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,i])=>t+": "+i).join(`
|