@testrelic/maestro-analytics 1.0.1 → 1.1.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/dist/cli.cjs +68 -18
- package/dist/index.cjs +44 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +44 -44
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -408,6 +408,17 @@ interface TestResultForUpload {
|
|
|
408
408
|
readonly os?: string;
|
|
409
409
|
/** Device name / serial, e.g. "emulator-5554", "iPhone 15 Pro" */
|
|
410
410
|
readonly deviceName?: string;
|
|
411
|
+
/**
|
|
412
|
+
* Per-flow console / device log entries. For Maestro this is the slice of
|
|
413
|
+
* `maestro.log` that falls inside the flow's start/end window — the platform
|
|
414
|
+
* surfaces them in the Maestro Session Workspace "Logs" tab.
|
|
415
|
+
*/
|
|
416
|
+
readonly consoleLogs?: ReadonlyArray<{
|
|
417
|
+
readonly level: string;
|
|
418
|
+
readonly message: string;
|
|
419
|
+
readonly timestamp: string;
|
|
420
|
+
readonly source?: string | null;
|
|
421
|
+
}>;
|
|
411
422
|
}
|
|
412
423
|
interface RunUploadPayload {
|
|
413
424
|
readonly runId: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -408,6 +408,17 @@ interface TestResultForUpload {
|
|
|
408
408
|
readonly os?: string;
|
|
409
409
|
/** Device name / serial, e.g. "emulator-5554", "iPhone 15 Pro" */
|
|
410
410
|
readonly deviceName?: string;
|
|
411
|
+
/**
|
|
412
|
+
* Per-flow console / device log entries. For Maestro this is the slice of
|
|
413
|
+
* `maestro.log` that falls inside the flow's start/end window — the platform
|
|
414
|
+
* surfaces them in the Maestro Session Workspace "Logs" tab.
|
|
415
|
+
*/
|
|
416
|
+
readonly consoleLogs?: ReadonlyArray<{
|
|
417
|
+
readonly level: string;
|
|
418
|
+
readonly message: string;
|
|
419
|
+
readonly timestamp: string;
|
|
420
|
+
readonly source?: string | null;
|
|
421
|
+
}>;
|
|
411
422
|
}
|
|
412
423
|
interface RunUploadPayload {
|
|
413
424
|
readonly runId: string;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {isValidEndpointUrl,isValidCloudConfig,createError,ErrorCode,isValidQueueEntry}from'@testrelic/core';import {existsSync,statSync,readFileSync,readdirSync,mkdirSync,writeFileSync,renameSync,unlinkSync,createReadStream}from'fs';import {resolve,join,dirname,basename,extname}from'path';import {XMLParser}from'fast-xml-parser';import {parseDocument}from'yaml';import {exec,spawn,execSync}from'child_process';import {tmpdir}from'os';import {createHash,randomUUID,randomBytes}from'crypto';import {gzipSync}from'zlib';import {Readable}from'stream';var
|
|
2
|
-
`),n}catch{}let s=dirname(t);if(s===t)break;t=s;}return null}function ce(e){try{let t=readFileSync(e,"utf-8"),r=JSON.parse(t);return typeof r!="object"||r===null||Array.isArray(r)||!Ye(r)?null:r}catch{return null}}function Ye(e){for(let t of Object.keys(e)){if(Wt.has(t))return false;let r=e[t];if(typeof r=="object"&&r!==null&&!Array.isArray(r)&&!Ye(r))return false}return true}function B(e){let t=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/.exec(e);if(t)return process.env[t[1]]??null;let r=/^\$([A-Za-z_][A-Za-z0-9_]*)$/.exec(e);return r?process.env[r[1]]??null:e}function H(e){let t=Object.create(null);for(let r of Object.keys(e)){let o=e[r];typeof o=="string"&&o.startsWith("$")?t[r]=B(o):typeof o=="object"&&o!==null&&!Array.isArray(o)?t[r]=H(o):t[r]=o;}return t}function ie(e){let t=/^(\d+)\s*([smhd])$/.exec(e.trim());if(!t)return null;let r=parseInt(t[1],10),o=t[2],n=Xt[o];return !n||r<=0?null:r*n}function de(e,t){let r=Object.create(null);if(Object.assign(r,ae),e){let l=e.cloud;l&&typeof l=="object"&&(typeof l.endpoint=="string"&&(r.endpoint=l.endpoint),typeof l.upload=="string"&&(r.uploadStrategy=l.upload),typeof l.timeout=="number"&&(r.timeout=l.timeout),typeof l.apiKey=="string"&&l.apiKey.length>0&&(r.apiKey=l.apiKey));let d=e["testrelic-repo"]??e.project;d&&typeof d=="object"&&typeof d.name=="string"&&(r.projectName=d.name);let c=e.queue;if(c&&typeof c=="object"){if(typeof c.maxAge=="string"){let p=ie(c.maxAge);p!==null&&(r.queueMaxAge=p);}typeof c.directory=="string"&&(r.queueDirectory=c.directory);}}if(t){if(typeof t.apiKey=="string"&&t.apiKey.length>0){let l=t.apiKey.startsWith("$")?B(t.apiKey):t.apiKey;l&&(r.apiKey=l);}if(typeof t.endpoint=="string"){let l=t.endpoint.startsWith("$")?B(t.endpoint):t.endpoint;l&&(r.endpoint=l);}if(typeof t.upload=="string"&&(r.uploadStrategy=t.upload),typeof t.timeout=="number"&&(r.timeout=t.timeout),typeof t.projectName=="string"&&(r.projectName=t.projectName),typeof t.queueMaxAge=="string"){let l=ie(t.queueMaxAge);l!==null&&(r.queueMaxAge=l);}typeof t.queueDirectory=="string"&&(r.queueDirectory=t.queueDirectory),typeof t.uploadArtifacts=="boolean"&&(r.uploadArtifacts=t.uploadArtifacts),typeof t.artifactMaxSizeMb=="number"&&(r.artifactMaxSizeMb=t.artifactMaxSizeMb);}let o=process.env.TESTRELIC_API_KEY;o&&o.length>0&&(r.apiKey=o);let n=process.env.TESTRELIC_CLOUD_ENDPOINT;n&&isValidEndpointUrl(n)&&(r.endpoint=n);let s=process.env.TESTRELIC_UPLOAD_STRATEGY;s&&["batch","realtime","both"].includes(s)&&(r.uploadStrategy=s);let a=process.env.TESTRELIC_CLOUD_TIMEOUT;if(a){let l=parseInt(a,10);!isNaN(l)&&l>=1e3&&l<=12e4&&(r.timeout=l);}let i=Object.freeze(r);return isValidCloudConfig(i)?i:ae}var Zt=new Set(["__proto__","constructor","prototype"]);function Qe(e){if(typeof e!="object"||e===null)return false;for(let t of Object.keys(e))if(Zt.has(t))return true;return false}function er(e){if(typeof e!="object"||e===null||Qe(e))return false;let t=e;return !(t.outputPath!==void 0&&typeof t.outputPath!="string"||t.htmlReportPath!==void 0&&typeof t.htmlReportPath!="string"||t.openReport!==void 0&&typeof t.openReport!="boolean"||t.includeScreenshots!==void 0&&typeof t.includeScreenshots!="boolean"||t.includeVideo!==void 0&&typeof t.includeVideo!="boolean"||t.includeAiAnalysis!==void 0&&typeof t.includeAiAnalysis!="boolean"||t.includeLogs!==void 0&&typeof t.includeLogs!="boolean"||t.includeFlowMetadata!==void 0&&typeof t.includeFlowMetadata!="boolean"||t.quiet!==void 0&&typeof t.quiet!="boolean"||t.metadata!==void 0&&t.metadata!==null&&(typeof t.metadata!="object"||Qe(t.metadata)))}function tr(e){if(e!==void 0&&!er(e))throw createError(ErrorCode.CONFIG_INVALID,"Invalid Maestro reporter configuration");let t=Object.create(null),r=e?.outputPath??"./test-results/testrelic-maestro.json";return t.outputPath=r,t.htmlReportPath=e?.htmlReportPath??r.replace(/\.json$/,".html"),t.openReport=e?.openReport??true,t.includeScreenshots=e?.includeScreenshots??true,t.includeVideo=e?.includeVideo??true,t.includeAiAnalysis=e?.includeAiAnalysis??true,t.includeLogs=e?.includeLogs??true,t.includeFlowMetadata=e?.includeFlowMetadata??true,t.flowsDir=e?.flowsDir??null,t.testRunId=e?.testRunId??null,t.metadata=e?.metadata??null,t.quiet=e?.quiet??false,t.reportMode=e?.reportMode??"batch",t.cloud=rr(e?.cloud??null),Object.freeze(t)}function rr(e){let t=le(process.cwd()),r=t?ce(t):null,o=r?H(r):null,n=de(o,e??void 0);return n.apiKey?n:null}var nr=new XMLParser({ignoreAttributes:false,attributeNamePrefix:"@_",allowBooleanAttributes:true,parseAttributeValue:true,trimValues:true});function G(e){return e==null?[]:Array.isArray(e)?e:[e]}function et(e){return !e||typeof e!="object"?[]:G(e.property).map(o=>({name:String(o["@_name"]??""),value:String(o["@_value"]??"")}))}function ar(e){let t=String(e["@_name"]??"unnamed"),r=String(e["@_classname"]??t),o=Number(e["@_time"]??0),n=e["@_id"]!=null?String(e["@_id"]):null,s=String(e["@_status"]??"").toUpperCase(),a=e.failure,i=e.error,l=e.skipped!==void 0,d="SUCCESS";return a?d="FAILURE":i?d="ERROR":l?d="SKIPPED":s==="FAILURE"||s==="FAILED"?d="FAILURE":s==="ERROR"?d="ERROR":s==="SKIPPED"&&(d="SKIPPED"),{id:n,name:t,classname:r,time:o,status:d,failureMessage:a?String(a["@_message"]??a["#text"]??""):null,failureType:a?String(a["@_type"]??""):null,errorMessage:i?String(i["@_message"]??i["#text"]??""):null,errorType:i?String(i["@_type"]??""):null,properties:et(e.properties)}}function Ze(e){let t=String(e["@_name"]??"Test Suite"),r=e["@_device"]!=null?String(e["@_device"]):null,o=Number(e["@_tests"]??0),n=Number(e["@_failures"]??0),s=Number(e["@_errors"]??0),a=Number(e["@_skipped"]??0),i=Number(e["@_time"]??0),d=G(e.testcase).map(ar);return {name:t,device:r,tests:o,failures:n,errors:s,skipped:a,time:i,testCases:d,properties:et(e.properties)}}function tt(e){let t=nr.parse(e),r=[];if(t.testsuites){let l=t.testsuites;r=G(l.testsuite).map(Ze);}else t.testsuite&&(r=G(t.testsuite).map(Ze));let o=0,n=0,s=0,a=0,i=0;for(let l of r)o+=l.tests,n+=l.failures,s+=l.errors,a+=l.skipped,i+=l.time;return {testSuites:r,totalTests:o,totalFailures:n,totalErrors:s,totalSkipped:a,totalTime:i}}function pe(e){let t=readFileSync(e,"utf-8");return tt(t)}var ur=new Set(["tapOn","doubleTapOn","longPressOn","inputText","eraseText","pasteText","swipe","scroll","scrollUntilVisible","hideKeyboard","pressKey","setClipboard","copyTextFrom"]),fr=new Set(["assertVisible","assertNotVisible","assertTrue","assertScreenshot","assertNoDefectsWithAI","assertWithAI","assertCondition"]),gr=new Set(["launchApp","killApp","stopApp","clearState","openLink","back","clearKeychain"]),mr=new Set(["setAirplaneMode","toggleAirplaneMode","setLocation","setOrientation","setPermissions","addMedia","travel"]),hr=new Set(["takeScreenshot","startRecording","stopRecording"]),br=new Set(["runScript","evalScript"]),yr=new Set(["runFlow","repeat","retry","waitForAnimationToEnd","extendedWaitUntil"]),xr=new Set(["assertWithAI","assertNoDefectsWithAI","extractTextWithAI"]);function ot(e){return xr.has(e)?"ai":fr.has(e)?"assertion":ur.has(e)?"interaction":gr.has(e)?"navigation":mr.has(e)?"device":hr.has(e)?"media":br.has(e)?"script":yr.has(e)?"flow_control":"other"}var vr={tapOnElement:"tapOn",assertCondition:"assertVisible",backPress:"back",applyConfiguration:"applyConfiguration",defineVariables:"defineVariables"};function wr(e){let t=e.replace(/Command$/,"");return vr[t]??t}function kr(e){if(e.selector&&typeof e.selector=="object"){let t=e.selector;if(typeof t.textRegex=="string")return t.textRegex;if(typeof t.text=="string")return t.text;if(typeof t.id=="string")return `#${t.id}`}if(e.condition&&typeof e.condition=="object"){let t=e.condition,r=t.visible??t.notVisible;if(r){if(typeof r.textRegex=="string")return r.textRegex;if(typeof r.text=="string")return r.text}}if(typeof e.path=="string")return e.path}function rt(e,t,r){let o,n;if(typeof e.command=="object"&&e.command!==null&&!Array.isArray(e.command)){let c=e.command,p=Object.keys(c)[0]??`step-${t}`;o=wr(p);let f=c[p]??{};n=kr(f);}else o=e.command??e.commandName??e.name??`step-${t}`,n=e.selector??void 0;let s=e.metadata??{},a=Cr(s.status??e.status),i=s.duration??e.duration??e.durationMs??0,l;typeof s.timestamp=="number"?l=new Date(s.timestamp).toISOString():l=e.timestamp??e.time??r;let d=e.error??e.errorMessage??void 0;return {command:o,category:ot(o),status:a,duration:i,timestamp:l,...n?{selector:n}:{},...d?{error:d}:{}}}function Cr(e){if(!e)return "completed";let t=e.toLowerCase();return t==="failed"||t==="error"?"failed":t==="skipped"?"skipped":"completed"}function st(e,t){let r=t??new Date().toISOString();try{let o=JSON.parse(e);if(Array.isArray(o))return o.map((n,s)=>rt(n,s,r));if(typeof o=="object"&&o!==null){let n=o,s=n.commands??n.steps??n.data;if(Array.isArray(s))return s.map((a,i)=>rt(a,i,r))}return []}catch{return []}}function ue(e,t){try{let r=readFileSync(e,"utf-8");return st(r,t)}catch{return []}}function fe(e){if(!existsSync(e))return [];try{return readdirSync(e,{recursive:!0}).map(String).filter(t=>basename(t).startsWith("commands")&&t.endsWith(".json")).map(t=>join(e,t))}catch{return []}}function Mr(e){let t=[];for(let r of e)if(typeof r=="object"&&r!==null){let o=r;if(typeof o.runFlow=="string")t.push(o.runFlow);else if(typeof o.runFlow=="object"&&o.runFlow!==null){let n=o.runFlow;typeof n.file=="string"&&t.push(n.file);}}return t}function at(e){if(!e)return [];let t=[],r=Array.isArray(e)?e:[e];for(let o of r)if(typeof o=="string")t.push(o);else if(typeof o=="object"&&o!==null){let n=o;if(typeof n.runFlow=="string")t.push(n.runFlow);else if(typeof n.runFlow=="object"&&n.runFlow!==null){let s=n.runFlow;typeof s.file=="string"&&t.push(s.file);}typeof n.runScript=="string"&&t.push(n.runScript);}return t}function it(e,t){let r=e.split(/^---\s*$/m,2),o=r[0]??"",n=r[1]??"",s={};try{let g=parseDocument(o).toJS();typeof g=="object"&&g!==null&&!Array.isArray(g)&&(s=g);}catch{}let a=[];if(n.trim())try{let g=parseDocument(n).toJS();Array.isArray(g)&&(a=g);}catch{}let i=typeof s.appId=="string"?s.appId:null,l=typeof s.name=="string"?s.name:null,d=[];if(Array.isArray(s.tags))for(let m of s.tags)typeof m=="string"&&d.push(m);let c={};if(typeof s.env=="object"&&s.env!==null&&!Array.isArray(s.env))for(let[m,g]of Object.entries(s.env))c[m]=String(g);let p={};if(typeof s.properties=="object"&&s.properties!==null&&!Array.isArray(s.properties))for(let[m,g]of Object.entries(s.properties))p[m]=String(g);let f=at(s.onFlowStart),x=at(s.onFlowComplete),v=Mr(a);return {appId:i,name:l,tags:d,env:c,properties:p,onFlowStart:f,onFlowComplete:x,subflowRefs:v,filePath:t}}function ge(e){let t=readFileSync(e,"utf-8");return it(t,e)}function me(e){if(!existsSync(e))return [];let t=[];function r(o){try{let n=readdirSync(o,{withFileTypes:!0});for(let s of n){let a=join(o,s.name);if(s.isDirectory())r(a);else if(s.isFile()){let i=extname(s.name).toLowerCase();(i===".yaml"||i===".yml")&&t.push(a);}}}catch{}}return r(e),t}var Dr=/^(\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?)\s+(\w+)\s+(.+)$/,Nr=/^\[?(\d{2}:\d{2}:\d{2}(?:\.\d+)?)\]?\s+(\w+)\s+(.+)$/;function lt(e){let t=e.toUpperCase();return t==="DEBUG"||t==="TRACE"||t==="VERBOSE"?"DEBUG":t==="INFO"?"INFO":t==="WARN"||t==="WARNING"?"WARN":t==="ERROR"||t==="FATAL"||t==="SEVERE"?"ERROR":"INFO"}function ct(e){let t=[],r=e.split(`
|
|
3
|
-
`),o=new Date().toISOString().split("T")[0];for(let
|
|
4
|
-
`+
|
|
1
|
+
import {isValidEndpointUrl,isValidCloudConfig,createError,ErrorCode,isValidQueueEntry}from'@testrelic/core';import {existsSync,statSync,readFileSync,readdirSync,mkdirSync,writeFileSync,renameSync,unlinkSync,createReadStream}from'fs';import {resolve,join,dirname,basename,extname}from'path';import {XMLParser}from'fast-xml-parser';import {parseDocument}from'yaml';import {exec,spawn,execSync}from'child_process';import {tmpdir}from'os';import {createHash,randomUUID,randomBytes}from'crypto';import {gzipSync}from'zlib';import {Readable}from'stream';var tt=".testrelic",Zt="testrelic-config.json",er=".testrelic",tr=5,rr=new Set(["__proto__","constructor","prototype"]),ce=Object.freeze({apiKey:null,endpoint:"https://platform.testrelic.ai/api/v1",uploadStrategy:"batch",timeout:3e4,projectName:null,queueMaxAge:6048e5,queueDirectory:`${tt}/queue`,uploadArtifacts:true,artifactMaxSizeMb:50}),or={s:1e3,m:60*1e3,h:3600*1e3,d:1440*60*1e3};function ue(e){let t=resolve(e);for(let r=0;r<=tr;r++){let o=join(t,tt,Zt);if(existsSync(o))try{if(statSync(o).isFile())return o}catch{}let s=join(t,er);if(existsSync(s))try{if(statSync(s).isFile())return process.stderr.write(`[testrelic] Deprecation: config file ".testrelic" has moved to ".testrelic/testrelic-config.json". Please migrate your config file to the new location.
|
|
2
|
+
`),s}catch{}let n=dirname(t);if(n===t)break;t=n;}return null}function pe(e){try{let t=readFileSync(e,"utf-8"),r=JSON.parse(t);return typeof r!="object"||r===null||Array.isArray(r)||!rt(r)?null:r}catch{return null}}function rt(e){for(let t of Object.keys(e)){if(rr.has(t))return false;let r=e[t];if(typeof r=="object"&&r!==null&&!Array.isArray(r)&&!rt(r))return false}return true}function G(e){let t=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/.exec(e);if(t)return process.env[t[1]]??null;let r=/^\$([A-Za-z_][A-Za-z0-9_]*)$/.exec(e);return r?process.env[r[1]]??null:e}function V(e){let t=Object.create(null);for(let r of Object.keys(e)){let o=e[r];typeof o=="string"&&o.startsWith("$")?t[r]=G(o):typeof o=="object"&&o!==null&&!Array.isArray(o)?t[r]=V(o):t[r]=o;}return t}function de(e){let t=/^(\d+)\s*([smhd])$/.exec(e.trim());if(!t)return null;let r=parseInt(t[1],10),o=t[2],s=or[o];return !s||r<=0?null:r*s}function fe(e,t){let r=Object.create(null);if(Object.assign(r,ce),e){let l=e.cloud;l&&typeof l=="object"&&(typeof l.endpoint=="string"&&(r.endpoint=l.endpoint),typeof l.upload=="string"&&(r.uploadStrategy=l.upload),typeof l.timeout=="number"&&(r.timeout=l.timeout),typeof l.apiKey=="string"&&l.apiKey.length>0&&(r.apiKey=l.apiKey));let d=e["testrelic-repo"]??e.project;d&&typeof d=="object"&&typeof d.name=="string"&&(r.projectName=d.name);let c=e.queue;if(c&&typeof c=="object"){if(typeof c.maxAge=="string"){let u=de(c.maxAge);u!==null&&(r.queueMaxAge=u);}typeof c.directory=="string"&&(r.queueDirectory=c.directory);}}if(t){if(typeof t.apiKey=="string"&&t.apiKey.length>0){let l=t.apiKey.startsWith("$")?G(t.apiKey):t.apiKey;l&&(r.apiKey=l);}if(typeof t.endpoint=="string"){let l=t.endpoint.startsWith("$")?G(t.endpoint):t.endpoint;l&&(r.endpoint=l);}if(typeof t.upload=="string"&&(r.uploadStrategy=t.upload),typeof t.timeout=="number"&&(r.timeout=t.timeout),typeof t.projectName=="string"&&(r.projectName=t.projectName),typeof t.queueMaxAge=="string"){let l=de(t.queueMaxAge);l!==null&&(r.queueMaxAge=l);}typeof t.queueDirectory=="string"&&(r.queueDirectory=t.queueDirectory),typeof t.uploadArtifacts=="boolean"&&(r.uploadArtifacts=t.uploadArtifacts),typeof t.artifactMaxSizeMb=="number"&&(r.artifactMaxSizeMb=t.artifactMaxSizeMb);}let o=process.env.TESTRELIC_API_KEY;o&&o.length>0&&(r.apiKey=o);let s=process.env.TESTRELIC_CLOUD_ENDPOINT;s&&isValidEndpointUrl(s)&&(r.endpoint=s);let n=process.env.TESTRELIC_UPLOAD_STRATEGY;n&&["batch","realtime","both"].includes(n)&&(r.uploadStrategy=n);let a=process.env.TESTRELIC_CLOUD_TIMEOUT;if(a){let l=parseInt(a,10);!isNaN(l)&&l>=1e3&&l<=12e4&&(r.timeout=l);}let i=Object.freeze(r);return isValidCloudConfig(i)?i:ce}var ar=new Set(["__proto__","constructor","prototype"]);function ot(e){if(typeof e!="object"||e===null)return false;for(let t of Object.keys(e))if(ar.has(t))return true;return false}function ir(e){if(typeof e!="object"||e===null||ot(e))return false;let t=e;return !(t.outputPath!==void 0&&typeof t.outputPath!="string"||t.htmlReportPath!==void 0&&typeof t.htmlReportPath!="string"||t.openReport!==void 0&&typeof t.openReport!="boolean"||t.includeScreenshots!==void 0&&typeof t.includeScreenshots!="boolean"||t.includeVideo!==void 0&&typeof t.includeVideo!="boolean"||t.includeAiAnalysis!==void 0&&typeof t.includeAiAnalysis!="boolean"||t.includeLogs!==void 0&&typeof t.includeLogs!="boolean"||t.includeFlowMetadata!==void 0&&typeof t.includeFlowMetadata!="boolean"||t.quiet!==void 0&&typeof t.quiet!="boolean"||t.metadata!==void 0&&t.metadata!==null&&(typeof t.metadata!="object"||ot(t.metadata)))}function lr(e){if(e!==void 0&&!ir(e))throw createError(ErrorCode.CONFIG_INVALID,"Invalid Maestro reporter configuration");let t=Object.create(null),r=e?.outputPath??"./test-results/testrelic-maestro.json";return t.outputPath=r,t.htmlReportPath=e?.htmlReportPath??r.replace(/\.json$/,".html"),t.openReport=e?.openReport??true,t.includeScreenshots=e?.includeScreenshots??true,t.includeVideo=e?.includeVideo??true,t.includeAiAnalysis=e?.includeAiAnalysis??true,t.includeLogs=e?.includeLogs??true,t.includeFlowMetadata=e?.includeFlowMetadata??true,t.flowsDir=e?.flowsDir??null,t.testRunId=e?.testRunId??null,t.metadata=e?.metadata??null,t.quiet=e?.quiet??false,t.reportMode=e?.reportMode??"batch",t.cloud=cr(e?.cloud??null),Object.freeze(t)}function cr(e){let t=ue(process.cwd()),r=t?pe(t):null,o=r?V(r):null,s=fe(o,e??void 0);return s.apiKey?s:null}var pr=new XMLParser({ignoreAttributes:false,attributeNamePrefix:"@_",allowBooleanAttributes:true,parseAttributeValue:true,trimValues:true});function q(e){return e==null?[]:Array.isArray(e)?e:[e]}function nt(e){return !e||typeof e!="object"?[]:q(e.property).map(o=>({name:String(o["@_name"]??""),value:String(o["@_value"]??"")}))}function fr(e){let t=String(e["@_name"]??"unnamed"),r=String(e["@_classname"]??t),o=Number(e["@_time"]??0),s=e["@_id"]!=null?String(e["@_id"]):null,n=String(e["@_status"]??"").toUpperCase(),a=e.failure,i=e.error,l=e.skipped!==void 0,d="SUCCESS";return a?d="FAILURE":i?d="ERROR":l?d="SKIPPED":n==="FAILURE"||n==="FAILED"?d="FAILURE":n==="ERROR"?d="ERROR":n==="SKIPPED"&&(d="SKIPPED"),{id:s,name:t,classname:r,time:o,status:d,failureMessage:a?String(a["@_message"]??a["#text"]??""):null,failureType:a?String(a["@_type"]??""):null,errorMessage:i?String(i["@_message"]??i["#text"]??""):null,errorType:i?String(i["@_type"]??""):null,properties:nt(e.properties)}}function st(e){let t=String(e["@_name"]??"Test Suite"),r=e["@_device"]!=null?String(e["@_device"]):null,o=Number(e["@_tests"]??0),s=Number(e["@_failures"]??0),n=Number(e["@_errors"]??0),a=Number(e["@_skipped"]??0),i=Number(e["@_time"]??0),d=q(e.testcase).map(fr);return {name:t,device:r,tests:o,failures:s,errors:n,skipped:a,time:i,testCases:d,properties:nt(e.properties)}}function at(e){let t=pr.parse(e),r=[];if(t.testsuites){let l=t.testsuites;r=q(l.testsuite).map(st);}else t.testsuite&&(r=q(t.testsuite).map(st));let o=0,s=0,n=0,a=0,i=0;for(let l of r)o+=l.tests,s+=l.failures,n+=l.errors,a+=l.skipped,i+=l.time;return {testSuites:r,totalTests:o,totalFailures:s,totalErrors:n,totalSkipped:a,totalTime:i}}function ge(e){let t=readFileSync(e,"utf-8");return at(t)}var xr=new Set(["tapOn","doubleTapOn","longPressOn","inputText","eraseText","pasteText","swipe","scroll","scrollUntilVisible","hideKeyboard","pressKey","setClipboard","copyTextFrom"]),vr=new Set(["assertVisible","assertNotVisible","assertTrue","assertScreenshot","assertNoDefectsWithAI","assertWithAI","assertCondition"]),wr=new Set(["launchApp","killApp","stopApp","clearState","openLink","back","clearKeychain"]),kr=new Set(["setAirplaneMode","toggleAirplaneMode","setLocation","setOrientation","setPermissions","addMedia","travel"]),Cr=new Set(["takeScreenshot","startRecording","stopRecording"]),Rr=new Set(["runScript","evalScript"]),Sr=new Set(["runFlow","repeat","retry","waitForAnimationToEnd","extendedWaitUntil"]),Tr=new Set(["assertWithAI","assertNoDefectsWithAI","extractTextWithAI"]);function lt(e){return Tr.has(e)?"ai":vr.has(e)?"assertion":xr.has(e)?"interaction":wr.has(e)?"navigation":kr.has(e)?"device":Cr.has(e)?"media":Rr.has(e)?"script":Sr.has(e)?"flow_control":"other"}var Ar={tapOnElement:"tapOn",assertCondition:"assertVisible",backPress:"back",applyConfiguration:"applyConfiguration",defineVariables:"defineVariables"};function Ir(e){let t=e.replace(/Command$/,"");return Ar[t]??t}function Mr(e){if(e.selector&&typeof e.selector=="object"){let t=e.selector;if(typeof t.textRegex=="string")return t.textRegex;if(typeof t.text=="string")return t.text;if(typeof t.id=="string")return `#${t.id}`}if(e.condition&&typeof e.condition=="object"){let t=e.condition,r=t.visible??t.notVisible;if(r){if(typeof r.textRegex=="string")return r.textRegex;if(typeof r.text=="string")return r.text}}if(typeof e.path=="string")return e.path}function it(e,t,r){let o,s;if(typeof e.command=="object"&&e.command!==null&&!Array.isArray(e.command)){let c=e.command,u=Object.keys(c)[0]??`step-${t}`;o=Ir(u);let p=c[u]??{};s=Mr(p);}else o=e.command??e.commandName??e.name??`step-${t}`,s=e.selector??void 0;let n=e.metadata??{},a=Er(n.status??e.status),i=n.duration??e.duration??e.durationMs??0,l;typeof n.timestamp=="number"?l=new Date(n.timestamp).toISOString():l=e.timestamp??e.time??r;let d=e.error??e.errorMessage??void 0;return {command:o,category:lt(o),status:a,duration:i,timestamp:l,...s?{selector:s}:{},...d?{error:d}:{}}}function Er(e){if(!e)return "completed";let t=e.toLowerCase();return t==="failed"||t==="error"?"failed":t==="skipped"?"skipped":"completed"}function ct(e,t){let r=t??new Date().toISOString();try{let o=JSON.parse(e);if(Array.isArray(o))return o.map((s,n)=>it(s,n,r));if(typeof o=="object"&&o!==null){let s=o,n=s.commands??s.steps??s.data;if(Array.isArray(n))return n.map((a,i)=>it(a,i,r))}return []}catch{return []}}function me(e,t){try{let r=readFileSync(e,"utf-8");return ct(r,t)}catch{return []}}function he(e){if(!existsSync(e))return [];try{return readdirSync(e,{recursive:!0}).map(String).filter(t=>basename(t).startsWith("commands")&&t.endsWith(".json")).map(t=>join(e,t))}catch{return []}}function Nr(e){let t=[];for(let r of e)if(typeof r=="object"&&r!==null){let o=r;if(typeof o.runFlow=="string")t.push(o.runFlow);else if(typeof o.runFlow=="object"&&o.runFlow!==null){let s=o.runFlow;typeof s.file=="string"&&t.push(s.file);}}return t}function ut(e){if(!e)return [];let t=[],r=Array.isArray(e)?e:[e];for(let o of r)if(typeof o=="string")t.push(o);else if(typeof o=="object"&&o!==null){let s=o;if(typeof s.runFlow=="string")t.push(s.runFlow);else if(typeof s.runFlow=="object"&&s.runFlow!==null){let n=s.runFlow;typeof n.file=="string"&&t.push(n.file);}typeof s.runScript=="string"&&t.push(s.runScript);}return t}function pt(e,t){let r=e.split(/^---\s*$/m,2),o=r[0]??"",s=r[1]??"",n={};try{let m=parseDocument(o).toJS();typeof m=="object"&&m!==null&&!Array.isArray(m)&&(n=m);}catch{}let a=[];if(s.trim())try{let m=parseDocument(s).toJS();Array.isArray(m)&&(a=m);}catch{}let i=typeof n.appId=="string"?n.appId:null,l=typeof n.name=="string"?n.name:null,d=[];if(Array.isArray(n.tags))for(let g of n.tags)typeof g=="string"&&d.push(g);let c={};if(typeof n.env=="object"&&n.env!==null&&!Array.isArray(n.env))for(let[g,m]of Object.entries(n.env))c[g]=String(m);let u={};if(typeof n.properties=="object"&&n.properties!==null&&!Array.isArray(n.properties))for(let[g,m]of Object.entries(n.properties))u[g]=String(m);let p=ut(n.onFlowStart),R=ut(n.onFlowComplete),x=Nr(a);return {appId:i,name:l,tags:d,env:c,properties:u,onFlowStart:p,onFlowComplete:R,subflowRefs:x,filePath:t}}function be(e){let t=readFileSync(e,"utf-8");return pt(t,e)}function ye(e){if(!existsSync(e))return [];let t=[];function r(o){try{let s=readdirSync(o,{withFileTypes:!0});for(let n of s){let a=join(o,n.name);if(n.isDirectory())r(a);else if(n.isFile()){let i=extname(n.name).toLowerCase();(i===".yaml"||i===".yml")&&t.push(a);}}}catch{}}return r(e),t}var Br=/^(\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?)\s+(\w+)\s+(.+)$/,Hr=/^\[?(\d{2}:\d{2}:\d{2}(?:\.\d+)?)\]?\s+(\w+)\s+(.+)$/;function ft(e){let t=e.toUpperCase();return t==="DEBUG"||t==="TRACE"||t==="VERBOSE"?"DEBUG":t==="INFO"?"INFO":t==="WARN"||t==="WARNING"?"WARN":t==="ERROR"||t==="FATAL"||t==="SEVERE"?"ERROR":"INFO"}function gt(e){let t=[],r=e.split(`
|
|
3
|
+
`),o=new Date().toISOString().split("T")[0];for(let s of r){let n=s.trim();if(!n)continue;let a=Br.exec(n);if(a){t.push({timestamp:a[1],level:ft(a[2]),message:a[3],source:null});continue}if(a=Hr.exec(n),a){t.push({timestamp:`${o}T${a[1]}`,level:ft(a[2]),message:a[3],source:null});continue}if(t.length>0){let i=t[t.length-1];t[t.length-1]={...i,message:i.message+`
|
|
4
|
+
`+n};}}return t}function xe(e){try{let t=readFileSync(e,"utf-8");return gt(t)}catch{return []}}function ve(e){for(let t of e){let r=t.message.toLowerCase();if(r.includes("android")||r.includes("adb")||r.includes("uiautomator")||r.includes("emulator"))return "android";if(r.includes("ios")||r.includes("xcuitest")||r.includes("simulator")||r.includes("xctest"))return "ios";if(r.includes("web driver")||r.includes("chrome")||r.includes("chromium"))return "web"}return "unknown"}function we(e){if(!existsSync(e))return [];try{return readdirSync(e,{recursive:!0}).map(String).filter(t=>basename(t)==="maestro.log"||t.endsWith(".log")).map(t=>join(e,t))}catch{return []}}var Xr=/(?:defect|issue|bug|error|warning|problem)/i,Yr=/(?:critical|severe|major|blocker)/i,Qr=/(?:warning|moderate|minor)/i,ke=/(?:cut[\s-]?off|overlap|truncat|misalign|overflow|clip|obscur|hidden\s+text|broken\s+layout)/i,J=/(?:spelling|typo|misspell|grammar)/i,K=/(?:i18n|internationali[sz]ation|locali[sz]ation|untranslated|missing\s+translation)/i,Te=/(?:layout|spacing|padding|margin|alignment|centering|position)/i,Ae=/(?:accessib|a11y|contrast|screen\s*reader|alt\s*text|aria)/i;function Ce(e){return J.test(e)?"spelling":K.test(e)?"i18n":Ae.test(e)?"accessibility":Te.test(e)?"layout":"ui"}function Re(e){return Yr.test(e)?"critical":Qr.test(e)?"warning":"info"}function Se(e){return e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim()}function Zr(e){let t=[],r=Se(e),o=/<li[^>]*>([\s\S]*?)<\/li>/gi,s;for(;(s=o.exec(e))!==null;){let n=s[1],a=Se(n);!a||a.length<5||(Xr.test(a)||ke.test(a)||J.test(a)||K.test(a))&&t.push({type:Ce(a),severity:Re(a),description:a,location:null,screenshot:null});}if(t.length===0){let n=/<p[^>]*>([\s\S]*?)<\/p>/gi;for(;(s=n.exec(e))!==null;){let a=Se(s[1]);!a||a.length<10||(ke.test(a)||J.test(a)||K.test(a)||Te.test(a)||Ae.test(a))&&t.push({type:Ce(a),severity:Re(a),description:a,location:null,screenshot:null});}}if(t.length===0&&r.length>20){let n=r.split(/[.!?]+/).filter(a=>a.trim().length>10);for(let a of n){let i=a.trim();(ke.test(i)||J.test(i)||K.test(i)||Te.test(i)||Ae.test(i))&&t.push({type:Ce(i),severity:Re(i),description:i,location:null,screenshot:null});}}return t}function mt(e){let t=Zr(e);return {defects:t,totalDefects:t.length,hasIssues:t.length>0,rawHtml:e}}function Ie(e){try{let t=readFileSync(e,"utf-8");return mt(t)}catch{return {defects:[],totalDefects:0,hasIssues:false,rawHtml:null}}}function Me(e){if(!existsSync(e))return [];try{return readdirSync(e,{recursive:!0}).map(String).filter(t=>{let r=basename(t).toLowerCase();return extname(t).toLowerCase()===".html"&&(r.includes("insight")||r.includes("ai")||r.includes("analysis"))}).map(t=>join(e,t))}catch{return []}}var no=new Set([".png",".jpg",".jpeg",".webp"]),ao=new Set([".mp4",".webm",".mov"]);function ht(e){let t=[];if(!existsSync(e))return t;function r(o){try{let s=readdirSync(o,{withFileTypes:!0});for(let n of s){let a=join(o,n.name);n.isDirectory()?r(a):n.isFile()&&t.push(a);}}catch{}}return r(e),t}function Ee(e,t){let r=[],o=[],s=[],n=[],a=[],i=null,l=[];e&&l.push(...ht(e)),t&&l.push(...ht(t));let d=new Set;for(let c of l){if(d.has(c))continue;d.add(c);let u=basename(c).toLowerCase(),p=extname(c).toLowerCase();if(no.has(p)){r.push(c);continue}if(ao.has(p)){o.push(c);continue}if(u==="maestro.log"||p===".log"&&u.includes("maestro")){s.push(c);continue}if(u.startsWith("commands")&&p===".json"){n.push(c);continue}if(p===".html"&&(u.includes("insight")||u.includes("ai")||u.includes("analysis"))){a.push(c);continue}if(p===".xml"&&(u.includes("report")||u.includes("junit"))){i||(i=c);continue}}return {screenshotPaths:r,videoPaths:o,logPaths:s,commandJsonPaths:n,aiReportPaths:a,junitReportPath:i}}function io(e){return {screenshots:e.screenshotPaths.length,videos:e.videoPaths.length,logs:e.logPaths.length,commandFiles:e.commandJsonPaths.length,aiReports:e.aiReportPaths.length,junitReport:e.junitReportPath?1:0}}function lo(e){switch(e){case "interaction":return "ui_action";case "assertion":return "assertion";case "ai":return "assertion";case "navigation":return "navigation";case "device":return "custom_step";case "media":return "custom_step";case "script":return "custom_step";case "flow_control":return "custom_step";case "recording":return "custom_step";default:return "custom_step"}}function bt(e){return {title:e.selector?`${e.command} \u2192 ${e.selector}`:e.command,category:lo(e.category),status:e.status==="failed"?"failed":"passed",duration:e.duration,timestamp:e.timestamp,videoOffset:null,error:e.error??null,children:[]}}function co(e){let t=[...e.commands.map(bt),...e.assertions.map(bt)];t.sort((s,n)=>new Date(s.timestamp).getTime()-new Date(n.timestamp).getTime());let r=e.screenshotPaths.length>0||e.videoPath?{screenshot:e.screenshotPaths[0]??void 0,video:e.videoPath??void 0}:null,o=[...e.tags];return e.platform!=="unknown"&&!o.includes(e.platform)&&o.push(e.platform),{title:e.flowName,status:e.status,duration:e.duration,startedAt:e.startedAt,completedAt:e.completedAt,retryCount:0,tags:o,failure:e.failureMessage?{message:e.failureMessage,line:null,code:null,stack:null}:null,testId:`${e.flowFile}::${e.flowName}`,filePath:e.flowFile,suiteName:e.appId??"maestro-suite",testType:"mobile",isFlaky:false,retryStatus:null,expectedStatus:"passed",actualStatus:e.status,artifacts:r,networkRequests:null,apiCalls:null,apiAssertions:null,actions:t.length>0?t:null,consoleLogs:null}}function yt(e){let t=co(e);return {url:e.appId??"maestro-flow",navigationType:"page_load",visitedAt:e.startedAt,duration:e.duration,specFile:e.flowFile,domContentLoadedAt:null,networkIdleAt:null,networkStats:null,tests:[t]}}function Fe(e){return e.map(yt)}var uo={"2xx":0,"3xx":0,"4xx":0,"5xx":0,error:0};function B(e){let t=0,r=0,o=0,s=0,n=0,a=0,i=0,l=0,d=0,c=e.length,u=0,p={},R=new Set;for(let x of e){R.add(x.url);for(let g of x.tests){switch(t++,g.status){case "passed":r++;break;case "failed":o++;break;case "flaky":s++;break;case "skipped":n++;break;case "timedout":a++;break}if(g.actions)for(let m of g.actions)if(u++,m.category==="assertion")i++,m.status==="passed"?l++:d++;else {let v=m.category;p[v]=(p[v]??0)+1;}}}return {total:t,passed:r,failed:o,flaky:s,skipped:n,timedout:a,totalApiCalls:0,uniqueApiUrls:0,apiCallsByMethod:{},apiCallsByStatusRange:uo,apiResponseTime:null,totalAssertions:i,passedAssertions:l,failedAssertions:d,totalNavigations:c,uniqueNavigationUrls:R.size,totalTimelineSteps:e.length,totalActionSteps:u,actionStepsByCategory:p}}var xt=`
|
|
5
5
|
/* \u2500\u2500 Theme Variables (verbatim from Appium) \u2500\u2500 */
|
|
6
6
|
:root,[data-theme="dark"]{
|
|
7
7
|
--bg:#0f1117;--bg-1:#161b22;--bg-2:#1c2128;--bg-3:#21262d;--bg-code:#13111c;
|
|
@@ -365,15 +365,15 @@ body{font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Rob
|
|
|
365
365
|
.test-row-arrow{display:none}
|
|
366
366
|
.summary-chip,.filter-chip,.status-indicator,.detail-status-badge,.dm-badge,.trb,.cmd-badge,.ai-severity{print-color-adjust:exact;-webkit-print-color-adjust:exact}
|
|
367
367
|
}
|
|
368
|
-
`;var
|
|
368
|
+
`;var vt=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 196 247" fill="none">
|
|
369
369
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.75 1.08009C2.034 2.66209 -0.130999 7.63009 0.610001 10.5821C0.969001 12.0121 3.021 15.2131 5.17 17.6971C14.375 28.3321 18 39.7791 18 58.2101V71.0001H12.434C1.16501 71.0001 0 73.4641 0 97.3051C0 106.858 0.298003 128.922 0.662003 146.337L1.323 178H33.606C65.786 178 65.897 178.007 68.544 180.284C72.228 183.453 72.244 189.21 68.579 192.877L65.957 195.5L33.479 195.801L1 196.103V204.551V213H24.577H48.154L51.077 215.923C55.007 219.853 55.007 224.147 51.077 228.077L48.154 231H26.469H4.783L5.41901 233.534C5.76901 234.927 7.143 238.527 8.472 241.534L10.89 247H40.945H71L71.006 241.75C71.017 230.748 76.027 221.606 84.697 216.767C97.854 209.424 114.086 213.895 121.323 226.857C123.659 231.041 124.418 233.833 124.789 239.607L125.263 247H155.187H185.11L187.528 241.534C188.857 238.527 190.231 234.927 190.581 233.534L191.217 231H169.531H147.846L144.923 228.077C142.928 226.082 142 224.152 142 222C142 219.848 142.928 217.918 144.923 215.923L147.846 213H171.423H195V204.551V196.103L162.521 195.801L130.043 195.5L127.421 192.877C123.991 189.445 123.835 183.869 127.074 180.421L129.349 178H162.013H194.677L195.338 146.337C195.702 128.922 196 106.858 196 97.3051C196 73.4641 194.835 71.0001 183.566 71.0001H178V58.2101C178 39.6501 181.397 28.7731 190.538 18.0651C195.631 12.0971 196.572 9.00809 194.511 5.02109C192.672 1.46509 190.197 9.12233e-05 186.028 9.12233e-05C179.761 9.12233e-05 168.713 14.8831 163.388 30.5001C160.975 37.5771 160.608 40.3751 160.213 54.7501L159.765 71.0001H150.732H141.7L142.286 53.2501C142.904 34.5511 144.727 24.3761 148.938 16.1211C151.823 10.4671 151.628 5.90109 148.364 2.63609C145 -0.726907 140.105 -0.887909 136.596 2.25009C133.481 5.03609 128.686 17.0811 126.507 27.5921C125.569 32.1191 124.617 43.0901 124.28 53.2501L123.69 71.0001H115.345H107V38.4231V5.84609L104.077 2.92309C102.082 0.928088 100.152 9.12233e-05 98 9.12233e-05C95.848 9.12233e-05 93.918 0.928088 91.923 2.92309L89 5.84609V38.4231V71.0001H80.655H72.31L71.72 53.2501C71.383 43.0901 70.431 32.1191 69.493 27.5921C67.314 17.0811 62.519 5.03609 59.404 2.25009C55.998 -0.795909 51.059 -0.710905 47.646 2.45209C44.221 5.62609 44.191 9.92109 47.539 17.4911C51.71 26.9241 53.007 34.4791 53.676 53.2501L54.31 71.0001H45.272H36.235L35.787 54.7501C35.392 40.3751 35.025 37.5771 32.612 30.5001C27.194 14.6091 16.228 -0.02891 9.787 0.03009C7.979 0.04709 5.712 0.519093 4.75 1.08009ZM42.687 108.974C33.431 112.591 20.036 125.024 18.408 131.512C17.476 135.223 20.677 140.453 28.253 147.599C37.495 156.319 44.191 159.471 53.5 159.485C59.317 159.494 61.645 158.953 67.274 156.289C77.634 151.385 88.987 139.161 88.996 132.9C89.004 127.304 76.787 114.707 66.745 109.956C59.16 106.368 50.285 106.006 42.687 108.974ZM129.255 109.904C119.151 114.768 106.996 127.33 107.004 132.9C107.013 139.108 118.562 151.475 128.939 156.389C134.338 158.945 136.744 159.496 142.521 159.498C152.526 159.501 160.369 155.502 169.771 145.605C180.444 134.368 180.278 130.975 168.486 119.388C160.043 111.094 152.727 107.595 143 107.201C136.364 106.933 134.78 107.244 129.255 109.904ZM48.5 125.922C46.3 126.969 43.152 128.945 41.505 130.314L38.511 132.802L40.504 135.005C41.601 136.216 44.434 138.342 46.8 139.728C52.577 143.114 57.36 142.466 64.009 137.395L68.978 133.606L66.756 131.24C60.944 125.054 54.357 123.135 48.5 125.922ZM138.386 125.063C136.674 125.571 133.375 127.677 131.057 129.743L126.841 133.5L131.901 137.343C138.65 142.468 143.407 143.124 149.2 139.728C151.566 138.342 154.351 136.269 155.389 135.122C157.684 132.587 156.742 131.097 150.58 127.511C145.438 124.519 142.329 123.895 138.386 125.063ZM91.923 162.923C89.043 165.804 89 166.008 89 176.973C89 184.805 89.435 188.941 90.47 190.941C92.356 194.589 96.918 196.273 101.03 194.84C105.82 193.17 107 189.638 107 176.973C107 166.008 106.957 165.804 104.077 162.923C102.082 160.928 100.152 160 98 160C95.848 160 93.918 160.928 91.923 162.923ZM94.5 232.155C91.026 234.055 90 236.229 90 241.691V247H98H106V242.082C106 235.732 105.37 234.242 101.928 232.463C98.591 230.737 97.197 230.679 94.5 232.155Z" fill="url(#paint0_linear_55_11)"/>
|
|
370
370
|
<defs><linearGradient id="paint0_linear_55_11" x1="98" y1="0.000244141" x2="98" y2="247" gradientUnits="userSpaceOnUse">
|
|
371
371
|
<stop stop-color="#03B79C"/><stop offset="0.504808" stop-color="#4EDAA4"/><stop offset="0.865285" stop-color="#84F3AA"/>
|
|
372
|
-
</linearGradient></defs></svg>`,
|
|
372
|
+
</linearGradient></defs></svg>`,wt=`<svg width="32" height="40" viewBox="0 0 196 247" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
373
373
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.75 1.08009C2.034 2.66209 -0.130999 7.63009 0.610001 10.5821C0.969001 12.0121 3.021 15.2131 5.17 17.6971C14.375 28.3321 18 39.7791 18 58.2101V71.0001H12.434C1.16501 71.0001 0 73.4641 0 97.3051C0 106.858 0.298003 128.922 0.662003 146.337L1.323 178H33.606C65.786 178 65.897 178.007 68.544 180.284C72.228 183.453 72.244 189.21 68.579 192.877L65.957 195.5L33.479 195.801L1 196.103V204.551V213H24.577H48.154L51.077 215.923C55.007 219.853 55.007 224.147 51.077 228.077L48.154 231H26.469H4.783L5.41901 233.534C5.76901 234.927 7.143 238.527 8.472 241.534L10.89 247H40.945H71L71.006 241.75C71.017 230.748 76.027 221.606 84.697 216.767C97.854 209.424 114.086 213.895 121.323 226.857C123.659 231.041 124.418 233.833 124.789 239.607L125.263 247H155.187H185.11L187.528 241.534C188.857 238.527 190.231 234.927 190.581 233.534L191.217 231H169.531H147.846L144.923 228.077C142.928 226.082 142 224.152 142 222C142 219.848 142.928 217.918 144.923 215.923L147.846 213H171.423H195V204.551V196.103L162.521 195.801L130.043 195.5L127.421 192.877C123.991 189.445 123.835 183.869 127.074 180.421L129.349 178H162.013H194.677L195.338 146.337C195.702 128.922 196 106.858 196 97.3051C196 73.4641 194.835 71.0001 183.566 71.0001H178V58.2101C178 39.6501 181.397 28.7731 190.538 18.0651C195.631 12.0971 196.572 9.00809 194.511 5.02109C192.672 1.46509 190.197 9.12233e-05 186.028 9.12233e-05C179.761 9.12233e-05 168.713 14.8831 163.388 30.5001C160.975 37.5771 160.608 40.3751 160.213 54.7501L159.765 71.0001H150.732H141.7L142.286 53.2501C142.904 34.5511 144.727 24.3761 148.938 16.1211C151.823 10.4671 151.628 5.90109 148.364 2.63609C145 -0.726907 140.105 -0.887909 136.596 2.25009C133.481 5.03609 128.686 17.0811 126.507 27.5921C125.569 32.1191 124.617 43.0901 124.28 53.2501L123.69 71.0001H115.345H107V38.4231V5.84609L104.077 2.92309C102.082 0.928088 100.152 9.12233e-05 98 9.12233e-05C95.848 9.12233e-05 93.918 0.928088 91.923 2.92309L89 5.84609V38.4231V71.0001H80.655H72.31L71.72 53.2501C71.383 43.0901 70.431 32.1191 69.493 27.5921C67.314 17.0811 62.519 5.03609 59.404 2.25009C55.998 -0.795909 51.059 -0.710905 47.646 2.45209C44.221 5.62609 44.191 9.92109 47.539 17.4911C51.71 26.9241 53.007 34.4791 53.676 53.2501L54.31 71.0001H45.272H36.235L35.787 54.7501C35.392 40.3751 35.025 37.5771 32.612 30.5001C27.194 14.6091 16.228 -0.02891 9.787 0.03009C7.979 0.04709 5.712 0.519093 4.75 1.08009ZM42.687 108.974C33.431 112.591 20.036 125.024 18.408 131.512C17.476 135.223 20.677 140.453 28.253 147.599C37.495 156.319 44.191 159.471 53.5 159.485C59.317 159.494 61.645 158.953 67.274 156.289C77.634 151.385 88.987 139.161 88.996 132.9C89.004 127.304 76.787 114.707 66.745 109.956C59.16 106.368 50.285 106.006 42.687 108.974ZM129.255 109.904C119.151 114.768 106.996 127.33 107.004 132.9C107.013 139.108 118.562 151.475 128.939 156.389C134.338 158.945 136.744 159.496 142.521 159.498C152.526 159.501 160.369 155.502 169.771 145.605C180.444 134.368 180.278 130.975 168.486 119.388C160.043 111.094 152.727 107.595 143 107.201C136.364 106.933 134.78 107.244 129.255 109.904ZM48.5 125.922C46.3 126.969 43.152 128.945 41.505 130.314L38.511 132.802L40.504 135.005C41.601 136.216 44.434 138.342 46.8 139.728C52.577 143.114 57.36 142.466 64.009 137.395L68.978 133.606L66.756 131.24C60.944 125.054 54.357 123.135 48.5 125.922ZM138.386 125.063C136.674 125.571 133.375 127.677 131.057 129.743L126.841 133.5L131.901 137.343C138.65 142.468 143.407 143.124 149.2 139.728C151.566 138.342 154.351 136.269 155.389 135.122C157.684 132.587 156.742 131.097 150.58 127.511C145.438 124.519 142.329 123.895 138.386 125.063ZM91.923 162.923C89.043 165.804 89 166.008 89 176.973C89 184.805 89.435 188.941 90.47 190.941C92.356 194.589 96.918 196.273 101.03 194.84C105.82 193.17 107 189.638 107 176.973C107 166.008 106.957 165.804 104.077 162.923C102.082 160.928 100.152 160 98 160C95.848 160 93.918 160.928 91.923 162.923ZM94.5 232.155C91.026 234.055 90 236.229 90 241.691V247H98H106V242.082C106 235.732 105.37 234.242 101.928 232.463C98.591 230.737 97.197 230.679 94.5 232.155Z" fill="url(#paint0_linear_55_11)"/>
|
|
374
374
|
<defs><linearGradient id="paint0_linear_55_11" x1="98" y1="0.000244141" x2="98" y2="247" gradientUnits="userSpaceOnUse">
|
|
375
375
|
<stop stop-color="#03B79C"/><stop offset="0.504808" stop-color="#4EDAA4"/><stop offset="0.865285" stop-color="#84F3AA"/>
|
|
376
|
-
</linearGradient></defs></svg>`;var
|
|
376
|
+
</linearGradient></defs></svg>`;var kt=`
|
|
377
377
|
/* \u2500\u2500 Utilities \u2500\u2500 */
|
|
378
378
|
function esc(s){if(!s)return '';return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,''')}
|
|
379
379
|
function fmtDur(ms){if(!ms||ms<=0)return '\\u2014';if(ms<1000)return Math.round(ms)+'ms';if(ms<60000)return (ms/1000).toFixed(1)+'s';var m=Math.floor(ms/60000),s=Math.round((ms%60000)/1000);return s>0?m+'m '+s+'s':m+'m'}
|
|
@@ -658,7 +658,7 @@ function renderFlowList(){
|
|
|
658
658
|
}
|
|
659
659
|
el.innerHTML=h;
|
|
660
660
|
}
|
|
661
|
-
`;var
|
|
661
|
+
`;var Ct=`
|
|
662
662
|
/* \u2500\u2500 Drawer Open/Close \u2500\u2500 */
|
|
663
663
|
function openDrawer(flowIdx){
|
|
664
664
|
openFlowIdx=flowIdx;
|
|
@@ -796,7 +796,7 @@ function renderRootCauseAnalysis(t,flow){
|
|
|
796
796
|
h+='</div></div>';
|
|
797
797
|
return h;
|
|
798
798
|
}
|
|
799
|
-
`;var
|
|
799
|
+
`;var Rt=`
|
|
800
800
|
function renderStepsTab(flow){
|
|
801
801
|
var actions=flow.test.actions||[];
|
|
802
802
|
if(actions.length===0)return '<div class="no-tests">No step data available for this flow.</div>';
|
|
@@ -867,7 +867,7 @@ function getCmdBadge(cat){
|
|
|
867
867
|
var pair=m[cat]||['CMD','cmd-badge-cmd'];
|
|
868
868
|
return '<span class="cmd-badge '+pair[1]+'">'+pair[0]+'</span>';
|
|
869
869
|
}
|
|
870
|
-
`;var
|
|
870
|
+
`;var St=`
|
|
871
871
|
function renderAssertionsTab(flow){
|
|
872
872
|
var actions=flow.test.actions||[];
|
|
873
873
|
var asserts=actions.filter(function(a){return a.category==='assertion'});
|
|
@@ -898,7 +898,7 @@ function renderAssertionsTab(flow){
|
|
|
898
898
|
h+='</tbody></table>';
|
|
899
899
|
return h;
|
|
900
900
|
}
|
|
901
|
-
`;var
|
|
901
|
+
`;var Tt=`
|
|
902
902
|
function renderAiDefectsTab(){
|
|
903
903
|
if(aiDefects.length===0)return '<div class="ai-empty">\\u2714 No AI defects detected.</div>';
|
|
904
904
|
var h='<div style="font-size:12px;color:var(--fg-1);margin-bottom:16px">'+aiDefects.length+' defect'+(aiDefects.length>1?'s':'')+' found by Maestro AI analysis</div>';
|
|
@@ -978,7 +978,7 @@ function genericFixPlaybook(d){
|
|
|
978
978
|
+'<li>Reproduce on a physical device</li>'
|
|
979
979
|
+'<li>Add <code>assertNoDefectsWithAI</code> for regression detection</li></ul>';
|
|
980
980
|
}
|
|
981
|
-
`;var
|
|
981
|
+
`;var At=`
|
|
982
982
|
/* \u2500\u2500 Theme \u2500\u2500 */
|
|
983
983
|
function applyTheme(){
|
|
984
984
|
var pref=localStorage.getItem('tr-theme')||'system';
|
|
@@ -1142,19 +1142,19 @@ document.addEventListener('input',function(e){
|
|
|
1142
1142
|
document.addEventListener('keydown',function(e){
|
|
1143
1143
|
if(e.key==='Escape'&&$('drawer').classList.contains('open'))closeDrawer();
|
|
1144
1144
|
});
|
|
1145
|
-
`;var
|
|
1145
|
+
`;var po=`
|
|
1146
1146
|
(function(){
|
|
1147
1147
|
var payload=JSON.parse(document.getElementById('report-data').textContent);
|
|
1148
1148
|
var report=payload.report;
|
|
1149
1149
|
var aiDefects=payload.aiDefects||[];
|
|
1150
1150
|
var screenshotPaths=payload.screenshotPaths||[];
|
|
1151
1151
|
|
|
1152
|
-
${bt}
|
|
1153
|
-
${yt}
|
|
1154
|
-
${xt}
|
|
1155
|
-
${vt}
|
|
1156
|
-
${wt}
|
|
1157
1152
|
${kt}
|
|
1153
|
+
${Ct}
|
|
1154
|
+
${Rt}
|
|
1155
|
+
${St}
|
|
1156
|
+
${Tt}
|
|
1157
|
+
${At}
|
|
1158
1158
|
|
|
1159
1159
|
applyTheme();
|
|
1160
1160
|
renderRunMeta();
|
|
@@ -1164,7 +1164,7 @@ document.addEventListener('keydown',function(e){
|
|
|
1164
1164
|
renderFlowList();
|
|
1165
1165
|
|
|
1166
1166
|
var _lo=document.getElementById('loading-overlay');if(_lo)_lo.remove();
|
|
1167
|
-
})();`;function
|
|
1167
|
+
})();`;function Le(e){let t=e.replace(/<\//g,"<\\/");return `<!-- TestRelic Maestro Report \u2014 self-contained, no external dependencies -->
|
|
1168
1168
|
<!DOCTYPE html>
|
|
1169
1169
|
<html lang="en" data-theme="">
|
|
1170
1170
|
<head>
|
|
@@ -1172,15 +1172,15 @@ document.addEventListener('keydown',function(e){
|
|
|
1172
1172
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
1173
1173
|
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; img-src data: blob: file: 'self'; media-src blob: 'self'; connect-src 'self';">
|
|
1174
1174
|
<title>TestRelic Maestro Test Report</title>
|
|
1175
|
-
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml;base64,${Buffer.from(
|
|
1176
|
-
<style>${
|
|
1175
|
+
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml;base64,${Buffer.from(vt).toString("base64")}">
|
|
1176
|
+
<style>${xt}</style>
|
|
1177
1177
|
<script>(function(){var p=localStorage.getItem('tr-theme')||'system';var t=p==='system'?(window.matchMedia('(prefers-color-scheme:light)').matches?'light':'dark'):p;document.documentElement.setAttribute('data-theme',t);})()</script>
|
|
1178
1178
|
</head>
|
|
1179
1179
|
<body>
|
|
1180
1180
|
<div class="wrap">
|
|
1181
1181
|
<div class="top-bar">
|
|
1182
1182
|
<div class="brand">
|
|
1183
|
-
${
|
|
1183
|
+
${wt}
|
|
1184
1184
|
<div class="brand-text">
|
|
1185
1185
|
<span class="brand-title">TestRelic AI</span>
|
|
1186
1186
|
<span class="brand-sub">Maestro Test Report</span>
|
|
@@ -1225,32 +1225,32 @@ document.addEventListener('keydown',function(e){
|
|
|
1225
1225
|
<div class="drawer-body" id="drawer-body"></div>
|
|
1226
1226
|
</aside>
|
|
1227
1227
|
<script id="report-data" type="application/json">${t}</script>
|
|
1228
|
-
<script>${
|
|
1228
|
+
<script>${po}</script>
|
|
1229
1229
|
</body>
|
|
1230
|
-
</html>`}function
|
|
1231
|
-
`}function
|
|
1230
|
+
</html>`}function _e(e,t,r,o){let s=resolve(o),n=dirname(s);existsSync(n)||mkdirSync(n,{recursive:true});let i=JSON.stringify({report:e,aiDefects:t,screenshotPaths:r}),l=Le(i);writeFileSync(s,l,"utf-8");}function yo(e){let t=60-e.length;return t>0?e+" ".repeat(t):e}function _(e){return `\u2502 ${yo(e)} \u2502
|
|
1231
|
+
`}function Pe(e,t,r,o,s){if(o||e.total===0)return;let n=`\u250C${"\u2500".repeat(62)}\u2510
|
|
1232
1232
|
`,a=`\u2514${"\u2500".repeat(62)}\u2518
|
|
1233
|
-
`,i=_(""),l=
|
|
1234
|
-
`,process.stderr.write(l);}function
|
|
1235
|
-
`)[0]?.trim();return o?
|
|
1233
|
+
`,i=_(""),l=n;l+=_("TestRelic AI - Maestro Test Report"),l+=i;let d=[];if(e.passed>0&&d.push(`${e.passed} \u2713`),e.failed>0&&d.push(`${e.failed} \u2717`),e.flaky>0&&d.push(`${e.flaky} \u26A0`),e.skipped>0&&d.push(`${e.skipped} skipped`),e.timedout>0&&d.push(`${e.timedout} timedout`),l+=_(`Flows: ${e.total} total (${d.join(" ")})`),e.totalAssertions>0&&(l+=_(`Assertions: ${e.totalAssertions} total (${e.passedAssertions} \u2713 ${e.failedAssertions} \u2717)`)),e.totalActionSteps>0){let c=[],u=e.actionStepsByCategory;u.ui_action&&c.push(`${u.ui_action} UI`),u.navigation&&c.push(`${u.navigation} nav`),u.custom_step&&c.push(`${u.custom_step} custom`);let p=c.length>0?` (${c.join(" ")})`:"";l+=_(`Steps: ${e.totalActionSteps} total${p}`);}if(s&&s.length>0){let c=s.filter(x=>x.severity==="critical").length,u=s.filter(x=>x.severity==="warning").length,p=s.filter(x=>x.severity==="info").length,R=[];c>0&&R.push(`${c} critical`),u>0&&R.push(`${u} warning`),p>0&&R.push(`${p} info`),l+=_(`AI Defects: ${s.length} found (${R.join(" ")})`);}l+=_(`Report: ${r}`),l+=_(`Data: ${t}`),l+=a,l+=`For more information visit us at https://docs.testrelic.ai
|
|
1234
|
+
`,process.stderr.write(l);}function De(e){let t=process.platform,r;t==="darwin"?r=`open "${e}"`:t==="win32"?r=`start "" "${e}"`:r=`xdg-open "${e}"`,exec(r,()=>{});}function Ro(){let e=randomBytes(8).toString("hex");return join(tmpdir(),`testrelic-maestro-${e}`)}function Mt(e,t){let r=[];e.platform&&r.push("--platform",e.platform),e.device&&r.push("--device",e.device),r.push("test");let o=join(t,"report.xml"),s=join(t,"artifacts"),n=join(t,"debug");if(r.push("--format","junit"),r.push("--output",o),r.push("--test-output-dir",s),r.push("--debug-output",n),e.analyze&&r.push("--analyze"),e.includeTags&&r.push("--include-tags",e.includeTags),e.excludeTags&&r.push("--exclude-tags",e.excludeTags),e.shards&&e.shards>1&&r.push("--shards",String(e.shards)),e.config&&r.push("--config",e.config),e.env)for(let[a,i]of Object.entries(e.env))r.push("-e",`${a}=${i}`);return e.maestroArgs&&r.push(...e.maestroArgs),r.push(...e.flowPaths),r}async function So(e){let t=e.outputDir?resolve(e.outputDir):Ro();mkdirSync(join(t,"artifacts"),{recursive:true}),mkdirSync(join(t,"debug"),{recursive:true});let r=Mt(e,t),o=join(t,"report.xml"),s=join(t,"artifacts"),n=join(t,"debug");return new Promise(a=>{let i=[],l=[],d=spawn("maestro",r,{stdio:["inherit","pipe","pipe"],shell:true});d.stdout.on("data",c=>{i.push(c),e.quiet||process.stdout.write(c);}),d.stderr.on("data",c=>{l.push(c),e.quiet||process.stderr.write(c);}),d.on("close",c=>{a({exitCode:c??1,junitPath:o,testOutputDir:s,debugOutputDir:n,stdout:Buffer.concat(i).toString("utf-8"),stderr:Buffer.concat(l).toString("utf-8")});}),d.on("error",c=>{a({exitCode:127,junitPath:o,testOutputDir:s,debugOutputDir:n,stdout:"",stderr:`Failed to start maestro CLI: ${c.message}`});});})}var Io=new Set(["localhost","127.0.0.1","0.0.0.0"]);function Ne(e){let t=new URL(e);if(t.protocol!=="https:"&&!(t.protocol==="http:"&&Io.has(t.hostname)))throw createError(ErrorCode.CLOUD_CONFIG_INVALID,`HTTPS is required for cloud communication. Got: ${t.protocol}//${t.hostname}`)}var Mo=3e3;async function W(e){let t=new AbortController,r=setTimeout(()=>t.abort(),Mo);try{return (await fetch(`${e}/health`,{method:"GET",signal:t.signal})).ok}catch{return false}finally{clearTimeout(r);}}async function Ft(e){return new Promise(t=>setTimeout(t,e))}async function Et(e){try{let r=(await e.json()).error;if(r&&typeof r.message=="string")return r.message}catch{}return `HTTP ${e.status}`}async function X(e,t,r){let o=new AbortController,s=setTimeout(()=>o.abort(),r);try{let n=await fetch(`${e}/sdk/auth/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t}),signal:o.signal});if(n.ok){let i=await n.json();return {accessToken:i.accessToken,refreshToken:i.refreshToken,expiresIn:i.expiresIn,orgId:i.orgId,orgName:i.orgName,userId:i.userId,userName:i.userName}}if(n.status===429){let i=n.headers.get("Retry-After"),l=i?parseInt(i,10)*1e3:5e3;if(!isNaN(l)&&l>0){await Ft(l);let d=await fetch(`${e}/sdk/auth/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t}),signal:o.signal});if(d.ok){let c=await d.json();return {accessToken:c.accessToken,refreshToken:c.refreshToken,expiresIn:c.expiresIn,orgId:c.orgId,orgName:c.orgName,userId:c.userId,userName:c.userName}}}return {code:"rate_limited",message:"Rate limited during token exchange.",statusCode:429}}return n.status===400?{code:"validation_error",message:await Et(n),statusCode:400}:n.status===401?{code:"invalid_key",message:"API key is invalid or has been revoked.",statusCode:401}:n.status===403?{code:"expired_key",message:"API key has expired.",statusCode:403}:{code:"server_error",message:await Et(n),statusCode:n.status}}catch(n){return n instanceof DOMException&&n.name==="AbortError"?{code:"timeout",message:"Token exchange timed out.",statusCode:null}:{code:"network_error",message:"Failed to reach cloud for token exchange.",statusCode:null}}finally{clearTimeout(s);}}function Y(e){return "code"in e&&typeof e.code=="string"&&["invalid_key","expired_key","validation_error","rate_limited","server_error","network_error","timeout"].includes(e.code)}async function Ue(e,t,r){let o=new AbortController,s=setTimeout(()=>o.abort(),r);try{let n=await fetch(`${e}/sdk/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t}),signal:o.signal});if(n.status===429){let i=n.headers.get("Retry-After"),l=i?parseInt(i,10)*1e3:5e3;!isNaN(l)&&l>0&&(await Ft(l),n=await fetch(`${e}/sdk/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t}),signal:o.signal}));}if(!n.ok)return null;let a=await n.json();return {accessToken:a.accessToken,refreshToken:a.refreshToken,expiresIn:a.expiresIn}}catch{return null}finally{clearTimeout(s);}}async function Oe(e,t,r,o,s,n){let a=new AbortController,i=setTimeout(()=>a.abort(),s);try{let l={gitId:r,displayName:o};n&&(l.branch=n);let d=await fetch(`${e}/repos/resolve`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(l),signal:a.signal});if(!d.ok)return null;let c=await d.json();return {repoId:c.repoId,displayName:c.displayName}}catch{return null}finally{clearTimeout(i);}}var Po=5e3;function P(e,t){try{return execSync(e,{cwd:t,timeout:Po,encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim()||null}catch{return null}}function ze(e){let t=P("git rev-parse --abbrev-ref HEAD",e),r=P("git rev-parse --short HEAD",e),o=P("git log -1 --pretty=%s",e),s=P("git log -1 --format=%an",e)??P("git config user.name",e),n=Do(e),a=n?O(n):null;return {branch:t,commitSha:r,commitMessage:o,commitAuthor:s,remoteUrl:a}}function Do(e){let t=P("git remote get-url origin",e);if(t)return t;let r=P("git remote",e);if(!r)return null;let o=r.split(`
|
|
1235
|
+
`)[0]?.trim();return o?P(`git remote get-url ${o}`,e):null}function O(e){let t=e.trim();return t=t.replace(/^[a-z+]+:\/\//,""),t=t.replace(/^[^@]+@/,""),t=t.replace(/:(?!\d)/,"/"),t=t.replace(/\.git$/,""),t=t.replace(/\/+$/,""),t=t.replace(/^[^@/]+@/,""),t.toLowerCase()}function je(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function Lt(e){try{let t=readFileSync(join(e,"package.json"),"utf-8"),r=JSON.parse(t);return typeof r.name=="string"&&r.name.length>0?r.name:null}catch{return null}}function z(e){let t=Lt(e);return t||`local/${basename(e)}`}var $o="1.0.0",_t=10;function Z(e,t,r,o,s,n,a,i){try{mkdirSync(e,{recursive:!0});let l=Date.now(),d=`${l}-${t}-${r}.json`,c=join(e,d),u={version:$o,queuedAt:new Date(l).toISOString(),reason:o,retryCount:0,targetEndpoint:s,method:n,payload:a,headers:i},p=c+".tmp";writeFileSync(p,JSON.stringify(u,null,2),"utf-8"),renameSync(p,c);}catch(l){l.code==="ENOSPC"?process.stderr.write(`\u26A0 TestRelic: Disk full \u2014 unable to queue upload data.
|
|
1236
1236
|
`):process.stderr.write(`\u26A0 TestRelic: Unable to queue upload data.
|
|
1237
|
-
`);}}async function
|
|
1238
|
-
`);return}try{if(
|
|
1239
|
-
`);return}let r=await
|
|
1240
|
-
`),await this.resolveRepoId(),this.config.queueDirectory&&(
|
|
1241
|
-
`);}}getMode(){return this.authState.mode}isCloudMode(){return this.authState.mode==="cloud"}isLocalMode(){return this.authState.mode==="local"}getAccessToken(){return this.authState.accessToken}getRepoId(){return this.repoId}getGitMetadata(){return this.gitMetadata}getConfig(){return this.config}getFailureReason(){return this.failureReason}getEndpoint(){return this.config?.endpoint??"https://platform.testrelic.ai/api/v1"}async ensureValidToken(){if(!this.isCloudMode()||!this.authState.accessToken)return false;let t=this.authState.expiresAt??0;if(Date.now()
|
|
1242
|
-
`));}async dispose(){if(this.healthCheckTimer&&(clearInterval(this.healthCheckTimer),this.healthCheckTimer=null),this.flushPromise){try{await Promise.race([this.flushPromise,new Promise(t=>setTimeout(t,
|
|
1243
|
-
\u2192 Manage keys: ${
|
|
1237
|
+
`);}}async function Be(e,t,r){let o;try{o=readdirSync(e).filter(n=>n.endsWith(".json")&&!n.endsWith(".tmp")).sort();}catch{return}if(o.length===0)return;let s=[];for(let n=0;n<o.length;n+=_t)s.push(o.slice(n,n+_t));for(let n of s)for(let a of n){let i=join(e,a);try{if(!statSync(i).isFile())continue;let d=readFileSync(i,"utf-8"),c=JSON.parse(d);if(!isValidQueueEntry(c)){unlinkSync(i);continue}let u=c;if((await fetch(u.targetEndpoint,{method:u.method,headers:{...u.headers,Authorization:`Bearer ${r}`},body:JSON.stringify(u.payload)})).ok)unlinkSync(i);else return}catch{return}}}function He(e,t){try{let r=readdirSync(e).filter(s=>s.endsWith(".json")&&!s.endsWith(".tmp")),o=Date.now();for(let s of r){let n=join(e,s);try{let a=readFileSync(n,"utf-8"),l=JSON.parse(a).queuedAt;if(typeof l=="string"){let d=new Date(l).getTime();o-d>t&&unlinkSync(n);}}catch{try{unlinkSync(n);}catch{}}}}catch{}}var Ko=3e5,Wo=864e5,Xo=6e4,Nt=3e4,Ut="https://platform.testrelic.ai/settings/api-keys",H=class{constructor(t){this.gitMetadata=null;this.repoId=null;this.failureReason=null;this.flushPromise=null;this.healthCheckTimer=null;this.config=t,this.authState={mode:"pending",accessToken:null,refreshToken:null,expiresAt:null,orgId:null,orgName:null,userId:null,userName:null};}async initialize(){if(!this.config||!this.config.apiKey){this.setLocalMode("no_api_key"),process.stderr.write(`\u2139 TestRelic: No API key configured. Running in local mode.
|
|
1238
|
+
`);return}try{if(Ne(this.config.endpoint),this.gitMetadata=ze(),!await W(this.config.endpoint)){this.setLocalMode("cloud_unreachable"),process.stderr.write(`\u26A0 TestRelic: Cloud unreachable. Switching to local mode.
|
|
1239
|
+
`);return}let r=await X(this.config.endpoint,this.config.apiKey,this.config.timeout);if(Y(r)){this.handleAuthError(r.code,r.statusCode);return}let o=r;this.authState={mode:"cloud",accessToken:o.accessToken,refreshToken:o.refreshToken,expiresAt:Date.now()+o.expiresIn*1e3,orgId:o.orgId,orgName:o.orgName,userId:o.userId,userName:o.userName},process.stderr.write(`\u2713 TestRelic: Connected to cloud (${o.orgName} / ${o.userName})
|
|
1240
|
+
`),await this.resolveRepoId(),this.config.queueDirectory&&(He(this.config.queueDirectory,this.config.queueMaxAge),this.startBackgroundFlush()),this.startHealthCheck();}catch(t){this.setLocalMode("unexpected_error"),process.stderr.write(`\u26A0 TestRelic: Unexpected error during cloud initialization. ${t instanceof Error?t.message:String(t)}
|
|
1241
|
+
`);}}getMode(){return this.authState.mode}isCloudMode(){return this.authState.mode==="cloud"}isLocalMode(){return this.authState.mode==="local"}getAccessToken(){return this.authState.accessToken}getRepoId(){return this.repoId}getGitMetadata(){return this.gitMetadata}getConfig(){return this.config}getFailureReason(){return this.failureReason}getEndpoint(){return this.config?.endpoint??"https://platform.testrelic.ai/api/v1"}async ensureValidToken(){if(!this.isCloudMode()||!this.authState.accessToken)return false;let t=this.authState.expiresAt??0;if(Date.now()+Ko<t)return true;if(!this.config||!this.authState.refreshToken)return this.switchToLocalMode("token_expired_no_refresh"),false;try{let r=await Ue(this.config.endpoint,this.authState.refreshToken,this.config.timeout);return r?(this.authState.accessToken=r.accessToken,this.authState.refreshToken=r.refreshToken,this.authState.expiresAt=Date.now()+r.expiresIn*1e3,!0):(this.switchToLocalMode("token_refresh_failed"),!1)}catch{return this.switchToLocalMode("token_refresh_error"),false}}switchToLocalMode(t){this.authState.mode!=="local"&&(this.authState.mode="local",this.failureReason=t,process.stderr.write(`\u26A0 TestRelic: Switched to local mode (${t}).
|
|
1242
|
+
`));}async dispose(){if(this.healthCheckTimer&&(clearInterval(this.healthCheckTimer),this.healthCheckTimer=null),this.flushPromise){try{await Promise.race([this.flushPromise,new Promise(t=>setTimeout(t,Nt))]);}catch{}this.flushPromise=null;}this.authState={mode:"local",accessToken:null,refreshToken:null,expiresAt:null,orgId:null,orgName:null,userId:null,userName:null},this.repoId=null,this.gitMetadata=null;}setLocalMode(t){this.authState.mode="local",this.failureReason=t;}handleAuthError(t,r){switch(t){case "invalid_key":this.setLocalMode("invalid_api_key"),process.stderr.write(`\u26A0 TestRelic: API key is invalid or revoked. Running in local mode.
|
|
1243
|
+
\u2192 Manage keys: ${Ut}
|
|
1244
1244
|
`);break;case "expired_key":this.setLocalMode("expired_api_key"),process.stderr.write(`\u26A0 TestRelic: API key has expired. Running in local mode.
|
|
1245
|
-
\u2192 Generate a new key: ${
|
|
1245
|
+
\u2192 Generate a new key: ${Ut}
|
|
1246
1246
|
`);break;case "rate_limited":this.setLocalMode("rate_limited"),process.stderr.write(`\u26A0 TestRelic: Rate limited during authentication. Running in local mode.
|
|
1247
1247
|
`);break;default:this.setLocalMode(`auth_error_${r??"unknown"}`),process.stderr.write(`\u26A0 TestRelic: Cloud authentication failed. Running in local mode.
|
|
1248
|
-
`);break}}async resolveRepoId(){if(!this.config||!this.authState.accessToken)return;let t=this.gitMetadata?.remoteUrl?
|
|
1249
|
-
`),this.startBackgroundFlush();}}}catch{}},
|
|
1250
|
-
`);}if(
|
|
1251
|
-
`);for(let[
|
|
1252
|
-
`);}}}}if(e.isCloudMode())if(await e.ensureValidToken()){let
|
|
1253
|
-
`);else {let
|
|
1254
|
-
`);}}else {let
|
|
1255
|
-
`);}let a=
|
|
1248
|
+
`);break}}async resolveRepoId(){if(!this.config||!this.authState.accessToken)return;let t=this.gitMetadata?.remoteUrl?O(this.gitMetadata.remoteUrl):null,r=t?je(t):this.config.projectName??z(process.cwd()),o=t??this.config.projectName??z(process.cwd()),s=this.readRepoCache(o);if(s){this.repoId=s.repoId;return}try{let n=await Oe(this.config.endpoint,this.authState.accessToken,o,r,this.config.timeout,this.gitMetadata?.branch);n&&(this.repoId=n.repoId,this.writeRepoCache(o,n.repoId,n.displayName));}catch{}}readRepoCache(t){if(!this.config)return null;let r=join(this.config.queueDirectory,"..","cache","repo.json");try{if(!existsSync(r))return null;let o=readFileSync(r,"utf-8"),s=JSON.parse(o);if(s.gitId!==t||Date.now()-s.resolvedAt>Wo)return null;let n=this.hashApiKey();return n&&s.apiKeyHash!==n?null:s}catch{return null}}writeRepoCache(t,r,o){if(!this.config)return;let s=join(this.config.queueDirectory,"..","cache"),n=join(s,"repo.json");try{mkdirSync(s,{recursive:!0});let a={repoId:r,gitId:t,displayName:o,resolvedAt:Date.now(),apiKeyHash:this.hashApiKey()??""},i=n+".tmp";writeFileSync(i,JSON.stringify(a,null,2),"utf-8"),renameSync(i,n);}catch{}}hashApiKey(){return this.config?.apiKey?createHash("sha256").update(this.config.apiKey).digest("hex").substring(0,16):null}startBackgroundFlush(){if(!this.config||!this.authState.accessToken)return;let t=this.authState.accessToken,r=this.config.queueDirectory,o=this.config.endpoint;this.flushPromise=Promise.race([Be(r,o,t),new Promise(s=>setTimeout(s,Nt))]).catch(()=>{});}startHealthCheck(){if(!this.config)return;let t=this.config.endpoint;this.healthCheckTimer=setInterval(async()=>{if(!this.isCloudMode()&&!(!this.failureReason||!["cloud_unreachable","auth_timeout","network_error"].includes(this.failureReason)))try{if(!await W(t))return;if(this.config?.apiKey){let o=await X(this.config.endpoint,this.config.apiKey,this.config.timeout);if(!Y(o)){let s=o;this.authState={mode:"cloud",accessToken:s.accessToken,refreshToken:s.refreshToken,expiresAt:Date.now()+s.expiresIn*1e3,orgId:s.orgId,orgName:s.orgName,userId:s.userId,userName:s.userName},this.failureReason=null,process.stderr.write(`\u2713 TestRelic: Cloud connectivity restored.
|
|
1249
|
+
`),this.startBackgroundFlush();}}}catch{}},Xo);}};var Qo=1048576,ee=[1e3,3e3,9e3],te=3;function oe(e,t,r,o,s){let n=o?.provider&&o.provider!=="unknown"?o.provider:"local";return {runId:e.testRunId,repoGitId:t,startedAt:e.startedAt,summary:e.summary,timeline:e.timeline,environment:n,testFramework:"maestro",...s&&s.length>0?{tests:s}:{},...r?.branch?{branch:r.branch}:{},...r?.commitSha?{commit:r.commitSha}:{},...r?.commitMessage?{commitMessage:r.commitMessage}:{},...r?.commitAuthor?{commitAuthor:r.commitAuthor}:{},...e.completedAt?{finishedAt:e.completedAt}:{},...e.totalDuration?{duration:e.totalDuration}:{},...o?.provider?{ciProvider:o.provider}:{},...o?.runUrl?{ciRunUrl:o.runUrl}:{}}}async function re(e){return new Promise(t=>setTimeout(t,e))}async function Ot(e,t,r){for(let o=0;o<te;o++)try{let s=await fetch(e,t);if(s.ok)return s;if(s.status===401&&r&&o===0){let n=await r();if(n){let a={...t,headers:{...t.headers,Authorization:`Bearer ${n}`}},i=await fetch(e,a);if(i.ok)return i}return null}if(s.status===429&&o<te-1){let n=s.headers.get("Retry-After"),a=n?parseInt(n,10)*1e3:ee[o];!isNaN(a)&&a>0?await re(a):await re(ee[o]);continue}if(s.status>=500&&o<te-1){await re(ee[o]);continue}return s}catch{if(o<te-1){await re(ee[o]);continue}return null}return null}function Zo(e){let t=JSON.stringify(e),r={"Content-Type":"application/json"};if(Buffer.byteLength(t,"utf-8")>Qo){let o=gzipSync(Buffer.from(t,"utf-8"));return r["Content-Encoding"]="gzip",{body:o,headers:r}}return {body:t,headers:r}}async function Ve(e,t,r,o){let s=`${e}/runs`,{body:n,headers:a}=Zo(r);a.Authorization=`Bearer ${t}`;let i=await Ot(s,{method:"POST",headers:a,body:n},o);return i?.ok?{success:true,statusCode:i.status,error:null}:i?.status===409?{success:true,statusCode:409,error:null}:{success:false,reason:i?`Upload failed with status ${i.status}`:"Upload failed after retries",statusCode:i?.status??null,payload:r,targetEndpoint:s,method:"POST"}}function es(e){let t={};for(let[r,o]of Object.entries(e))o!=null&&(t[r]=o);return t}async function ts(e,t,r){let o=`${e}/runs/init`;try{let s=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(es(r))});return s.ok?{runId:(await s.json()).runId}:null}catch{return null}}async function rs(e,t,r,o){let s=`${e}/runs/${r}/finalize`;return (await Ot(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(o)}))?.ok??false}var is=5,se=[1e3,3e3,9e3],j=3,ls={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".webm":"video/webm",".mp4":"video/mp4",".mov":"video/quicktime",".zip":"application/zip"},qe=0,Je=[];async function cs(){qe>=is&&await new Promise(e=>Je.push(e)),qe++;}function ds(){qe--,Je.length>0&&Je.shift()();}async function ne(e){return new Promise(t=>setTimeout(t,e))}function us(e){let t=e.substring(e.lastIndexOf(".")).toLowerCase();return ls[t]??"application/octet-stream"}function ps(e){try{return statSync(e).size}catch{return 0}}async function fs(e,t,r,o,s){let n=`${e}/artifacts/upload-url`,a=JSON.stringify({runId:r.runId,testId:r.testId,fileName:basename(r.filePath),contentType:s,type:r.type,sizeBytes:o});for(let i=0;i<j;i++)try{let l=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:a});if(l.ok)return await l.json();if(l.status>=500&&i<j-1){await ne(se[i]);continue}return null}catch{if(i<j-1){await ne(se[i]);continue}return null}return null}async function gs(e,t,r,o){for(let s=0;s<j;s++)try{let n=createReadStream(t),a=Readable.toWeb(n),i=await fetch(e,{method:"PUT",headers:{"Content-Type":r,"Content-Length":String(o)},body:a,duplex:"half"});if(i.ok)return !0;if(i.status>=500&&s<j-1){await ne(se[s]);continue}return !1}catch{if(s<j-1){await ne(se[s]);continue}return false}return false}async function ms(e,t,r){try{return (await fetch(`${e}/artifacts/confirm`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({artifactId:r})})).ok}catch{return false}}async function zt(e,t,r,o){let s=ps(r.filePath);if(s===0)return {success:false,storageKey:null,artifactId:null,error:"file_not_found_or_empty"};if(s>o*1024*1024)return {success:false,storageKey:null,artifactId:null,error:"file_too_large"};let n=us(r.filePath);await cs();try{let a=await fs(e,t,r,s,n);if(!a)return {success:!1,storageKey:null,artifactId:null,error:"upload_url_request_failed"};if(!await gs(a.uploadUrl,r.filePath,n,s))return {success:!1,storageKey:a.storageKey,artifactId:a.artifactId,error:"presigned_put_failed"};let l=await ms(e,t,a.artifactId);return {success:l,storageKey:a.storageKey,artifactId:a.artifactId,error:l?null:"confirm_failed"}}finally{ds();}}async function Ke(e,t,r,o){let s=new Map,n=r.map(async a=>{let i=await zt(e,t,a,o);s.set(a.filePath,i);});return await Promise.allSettled(n),s}function hs(e){return e.GITHUB_ACTIONS!=="true"?null:{provider:"github-actions",buildId:e.GITHUB_RUN_ID??null,commitSha:e.GITHUB_SHA??null,branch:e.GITHUB_REF_NAME??null,runUrl:e.GITHUB_SERVER_URL&&e.GITHUB_REPOSITORY&&e.GITHUB_RUN_ID?`${e.GITHUB_SERVER_URL}/${e.GITHUB_REPOSITORY}/actions/runs/${e.GITHUB_RUN_ID}`:null}}function bs(e){return e.GITLAB_CI!=="true"?null:{provider:"gitlab-ci",buildId:e.CI_PIPELINE_ID??null,commitSha:e.CI_COMMIT_SHA??null,branch:e.CI_COMMIT_BRANCH??e.CI_COMMIT_REF_NAME??null,runUrl:e.CI_PIPELINE_URL??null}}function ys(e){if(!e.JENKINS_URL)return null;let t=e.GIT_BRANCH??null;return t?.startsWith("origin/")&&(t=t.slice(7)),{provider:"jenkins",buildId:e.BUILD_ID??null,commitSha:e.GIT_COMMIT??null,branch:t,runUrl:e.BUILD_URL??null}}function xs(e){return e.CIRCLECI!=="true"?null:{provider:"circleci",buildId:e.CIRCLE_BUILD_NUM??null,commitSha:e.CIRCLE_SHA1??null,branch:e.CIRCLE_BRANCH??null,runUrl:e.CIRCLE_BUILD_URL??null}}function vs(e){if(!e.BITBUCKET_PIPELINE_UUID)return null;let t=e.BITBUCKET_WORKSPACE&&e.BITBUCKET_REPO_SLUG&&e.BITBUCKET_PIPELINE_UUID?`https://bitbucket.org/${e.BITBUCKET_WORKSPACE}/${e.BITBUCKET_REPO_SLUG}/pipelines/results/${e.BITBUCKET_PIPELINE_UUID}`:null;return {provider:"bitbucket-pipelines",buildId:e.BITBUCKET_BUILD_NUMBER??null,commitSha:e.BITBUCKET_COMMIT??null,branch:e.BITBUCKET_BRANCH??null,runUrl:t}}var ws=[hs,bs,ys,xs,vs];function ae(e){let t=e??process.env;for(let r of ws){let o=r(t);if(o)return o}return null}function ks(e){let t=[];for(let r of e){let o=r,s=o.tests;if(!Array.isArray(s)||s.length===0){t.push(r);continue}for(let n of s){t.push({timestamp:n.startedAt,title:n.title,category:"test",navigationType:o.navigationType,url:o.url,visitedAt:o.visitedAt,duration:n.duration,status:n.status,test_status:n.status,test_id:n.testId,test_title:n.title,specfile:n.filePath,suiteName:n.suiteName,type:"test",...n.failure?{error:n.failure.message,errorMessage:n.failure.message}:{}});for(let a of n.actions??[])t.push({timestamp:a.timestamp,title:a.title,category:a.category,status:a.status,test_status:n.status,duration:a.duration,error:a.error,test_id:n.testId,test_title:n.title,specfile:n.filePath,url:o.url,type:a.category==="assertion"?"assert":"action"});}}return t}function jt(e){let r=e.getGitMetadata()?.remoteUrl;return r?O(r):e.getConfig()?.projectName??z(process.cwd())}async function We(e,t,r,o,s,n,a,i,l,d,c){try{let u=c?.length??0,p=(i?.length??0)+(l?.length??0)+u>0;if(e.isCloudMode()&&p&&await e.ensureValidToken()){let x=e.getEndpoint(),g=e.getAccessToken(),m=t?.artifactMaxSizeMb??50,v=[];for(let k of i??[])v.push({filePath:k,runId:r,testId:"maestro-suite",type:"screenshot"});let E=new Set;for(let k of c??[])v.push({filePath:k.path,runId:r,testId:k.testId,type:"video"}),E.add(k.path);for(let k of l??[])E.has(k)||v.push({filePath:k,runId:r,testId:"maestro-suite",type:"video"});if(v.length>0){let k=await Ke(x,g,v,m),A=Array.from(k.entries()),f=A.filter(([,y])=>y.success).length,b=A.filter(([,y])=>!y.success);if(f>0){let y=v.filter(h=>h.type==="video").length,I=c?.length??0,S=v.filter(h=>h.type==="screenshot").length,w=[];if(S>0&&w.push(`${S} screenshot(s)`),y>0){let h=I>0?` (${I} per-flow)`:"";w.push(`${y} video(s)${h}`);}process.stderr.write(`\u2713 TestRelic: Uploaded ${f} artifact(s) [${w.join(", ")}] to cloud storage.
|
|
1250
|
+
`);}if(b.length>0){process.stderr.write(`\u26A0 TestRelic: ${b.length} artifact(s) failed to upload:
|
|
1251
|
+
`);for(let[y,I]of b){let S=v.find(h=>h.filePath===y),w=S?`[${S.type}] ${y}`:y;process.stderr.write(` \u2717 ${w} \u2014 reason: ${I.error??"unknown"}
|
|
1252
|
+
`);}}}}if(e.isCloudMode())if(await e.ensureValidToken()){let x=e.getGitMetadata(),g=ae(),m=jt(e),v=ks(o.timeline),E={...o,timeline:v},k=oe(E,m,x,g,d),A=await Ve(e.getEndpoint(),e.getAccessToken(),k,async()=>await e.ensureValidToken()?e.getAccessToken():null);if(A.success)process.stderr.write(`\u2713 TestRelic: Cloud upload succeeded \u2192 ${e.getEndpoint()}/runs/${r}
|
|
1253
|
+
`);else {let f=A,b=t?.queueDirectory??".testrelic/queue";Z(b,r,"batch",f.reason,f.targetEndpoint,f.method,f.payload,{"Content-Type":"application/json"}),process.stderr.write(`\u26A0 TestRelic: Cloud upload failed, queued for retry.
|
|
1254
|
+
`);}}else {let x=t?.queueDirectory??".testrelic/queue",g=e.getGitMetadata(),m=ae(),v=jt(e),E=oe(o,v,g,m);Z(x,r,"batch",e.getFailureReason()??"token_invalid",`${e.getEndpoint()}/runs`,"POST",E,{"Content-Type":"application/json"});}await e.dispose();}catch{try{await e.dispose();}catch{}}}function Bt(e,t,r){if(t.length===0)return null;let o=basename(e,extname(e)).toLowerCase(),s=t.find(i=>basename(i,extname(i)).toLowerCase()===o);if(s)return s;let n=t.find(i=>basename(i).toLowerCase().includes(o));if(n)return n;let a=t.find(i=>{let l=basename(i,extname(i)).toLowerCase();return l.length>=3&&(o.startsWith(l)||o.includes(l))});if(a)return a;if(r){let i=basename(r,extname(r)).toLowerCase(),l=t.find(c=>basename(c,extname(c)).toLowerCase()===i);if(l)return l;let d=t.find(c=>basename(c).toLowerCase().includes(i));if(d)return d}return null}function As(e,t){if(t.length===0)return [];let r=basename(e,extname(e)).toLowerCase(),o=t.filter(s=>{let n=basename(s).toLowerCase(),a=basename(s,extname(s)).toLowerCase();return n.startsWith(r)||n.includes(r)?true:a.length>=3&&(r.startsWith(a)||r.includes(a))});return o.length>0?o:t.slice()}function Is(e){for(let t of e)if(t.command==="startRecording"){let r=t.metadata,o=r?.path??r?.recording??r?.fileName;if(typeof o=="string")return o;if(typeof t.selector=="string")return t.selector}return null}function Ms(e){let t=new Map;for(let[r,o]of e){let s=basename(r).replace(/^commands[-_]?/i,"").replace(/\.json$/i,"").toLowerCase(),n=Is(o);n&&s&&t.set(s,n);}return t}function Es(e,t){let r=basename(t,extname(t)).toLowerCase();if(!r||e.size===0)return {commands:[],matchedAnyFile:false};let o=s=>basename(s,extname(s)).replace(/^commands[-_]?/i,"").toLowerCase();for(let[s,n]of e)if(o(s)===r)return {commands:n,matchedAnyFile:true};for(let[s,n]of e){let a=o(s);if(a.length>=3&&a.includes(r))return {commands:n,matchedAnyFile:true}}for(let[s,n]of e){let a=o(s);if(a.length>=3&&r.includes(a))return {commands:n,matchedAnyFile:true}}return {commands:[],matchedAnyFile:false}}function Fs(e){switch(e){case "android":return "Android";case "ios":return "iOS";case "web":return "Web";default:return}}function Ls(e){let t=e.logEntries.length>0?e.logEntries.map(r=>({level:r.level.toLowerCase(),message:r.message,timestamp:r.timestamp,source:r.source})):void 0;return {testId:`${e.flowFile}::${e.flowName}`,title:e.flowName,status:e.status,duration:e.duration,suiteName:e.appId??"maestro-suite",filePath:e.flowFile,testType:"mobile",isFlaky:false,startedAt:e.startedAt,completedAt:e.completedAt,tags:e.tags,failure:e.failureMessage?{message:e.failureMessage}:null,retry:0,retryCount:0,retryStatus:null,source:"maestro",platform:e.platform!=="unknown"?e.platform:void 0,os:Fs(e.platform),deviceName:e.deviceId,...t?{consoleLogs:t}:{}}}function _s(e,t,r){if(e.length===0)return [];let o=Date.parse(t),s=Date.parse(r);return Number.isNaN(o)||Number.isNaN(s)?e.slice():e.filter(n=>{let a=Date.parse(n.timestamp);return Number.isNaN(a)?true:a>=o&&a<=s})}async function Ps(e){let{config:t}=e,r=new Date().toISOString(),o=t.testRunId??randomUUID(),s=Ee(e.testOutputDir,e.debugOutputDir),n=e.junitPath??s.junitReportPath,a=e.debugOutputDir?we(e.debugOutputDir):s.logPaths,i=[];for(let f of a){let b=xe(f);b.length>0&&i.push(...b);}let l=e.platform??"unknown";if(l==="unknown"&&i.length>0){let f=ve(i);f!=="unknown"&&(l=f);}let d=new Map;if(e.flowsDir&&existsSync(e.flowsDir)){let f=ye(e.flowsDir);for(let b of f){let y=be(b),I=y.name??b;d.set(I,y);}}let c=new Map,u=e.testOutputDir?he(e.testOutputDir):s.commandJsonPaths;for(let f of u)c.set(f,me(f));let p=[],R=e.testOutputDir?Me(e.testOutputDir):s.aiReportPaths;for(let f of R){let b=Ie(f);p.push(...b.defects);}let x=Ms(c),g=[];if(n&&existsSync(n)){let f=ge(n),b=Array.from(c.values()).flat(),y=b.filter(S=>S.category==="assertion"),I=b.filter(S=>S.category!=="assertion");for(let S of f.testSuites)for(let w of S.testCases){let h=w.name,M=d.get(h),D=w.status==="SUCCESS"?"passed":w.status==="SKIPPED"?"skipped":"failed",L=w.time*1e3,N=r,$=new Date(new Date(N).getTime()+L).toISOString(),U=w.classname||h,Gt=basename(U,extname(U)).toLowerCase(),Vt=x.get(Gt)??null,{commands:Xe,matchedAnyFile:Ye}=Es(c,U),qt=Ye?Xe.filter(le=>le.category!=="assertion"):I,Jt=Ye?Xe.filter(le=>le.category==="assertion"):y;g.push({flowName:h,flowFile:U,appId:M?.appId??null,platform:l,deviceId:e.device,status:D,duration:L,startedAt:N,completedAt:$,tags:M?.tags??[],properties:M?.properties??{},commands:qt,assertions:Jt,screenshotPaths:As(U,s.screenshotPaths),videoPath:Bt(U,s.videoPaths,Vt),aiDefects:p,logEntries:_s(i,N,$),failureMessage:w.failureMessage??w.errorMessage??null,failureType:w.failureType??w.errorType??null,subflowRefs:M?.subflowRefs??[],metadata:M??null});}}if(g.length===0&&d.size>0)for(let[,f]of d)g.push({flowName:f.name??f.filePath,flowFile:f.filePath,appId:f.appId,platform:l,deviceId:e.device,status:"passed",duration:0,startedAt:r,completedAt:r,tags:f.tags,properties:f.properties,commands:[],assertions:[],screenshotPaths:[],videoPath:null,aiDefects:[],logEntries:i.slice(),failureMessage:null,failureType:null,subflowRefs:f.subflowRefs,metadata:f});let m=Fe(g),v=B(m),E=new Date().toISOString(),k=Date.now()-new Date(r).getTime(),A={schemaVersion:"1.0.0",testRunId:o,startedAt:r,completedAt:E,totalDuration:k,summary:v,ci:null,metadata:t.metadata??null,timeline:m,shardRunIds:null};if(mkdirSync(dirname(resolve(t.outputPath)),{recursive:true}),writeFileSync(resolve(t.outputPath),JSON.stringify(A,null,2),"utf-8"),_e(A,p,s.screenshotPaths,resolve(t.htmlReportPath)),Pe(v,t.outputPath,t.htmlReportPath,t.quiet,p),t.openReport&&De(resolve(t.htmlReportPath)),t.cloud){let f=new H(t.cloud);await f.initialize();let b=t.includeVideo?s.videoPaths:[],y=[];if(b.length>0){for(let h of g){let M=basename(h.flowFile,extname(h.flowFile)).toLowerCase(),D=x.get(M)??null,L=Bt(h.flowFile,b,D);if(L){let N=`${h.flowFile}::${h.flowName}`;y.some($=>$.path===L&&$.testId===N)||y.push({path:L,testId:N});}}if(b.length===1){let h=b[0];for(let M of g){let D=`${M.flowFile}::${M.flowName}`;y.some(L=>L.testId===D)||y.push({path:h,testId:D});}}}let I=new Set(y.map(h=>h.path)),S=b.filter(h=>!I.has(h)),w=g.map(Ls);await We(f,t.cloud,o,A,E,k,v,t.includeScreenshots?s.screenshotPaths:[],S,w,y);}return {report:A,flowResults:g,aiDefects:p,artifacts:s}}function $s(e){return "tests"in e&&"visitedAt"in e}function Ht(e){let t=[],r=[],o="",s="",n="";for(let d of e)try{let c=readFileSync(d,"utf-8"),u=JSON.parse(c);n||(n=u.testRunId),(!o||u.startedAt<o)&&(o=u.startedAt),(!s||u.completedAt&&u.completedAt>s)&&(s=u.completedAt);for(let p of u.timeline)t.push(p),$s(p)&&r.push(p);}catch{process.stderr.write(`\u26A0 TestRelic: Unable to read report file: ${d}
|
|
1255
|
+
`);}let a=B(r),i=o?new Date(o).getTime():Date.now(),l=s?new Date(s).getTime():Date.now();return {schemaVersion:"1.0.0",testRunId:n||`maestro-merged-${Date.now()}`,startedAt:o||new Date().toISOString(),completedAt:s||new Date().toISOString(),totalDuration:l-i,summary:a,ci:null,metadata:null,timeline:t,shardRunIds:null}}function Bs(e,t){if(!existsSync(e))throw new Error(`Directory does not exist: ${e}`);let r=readdirSync(e).filter(s=>extname(s)===".json"&&s.includes("testrelic")).map(s=>join(e,s)),o=Ht(r);return writeFileSync(t,JSON.stringify(o,null,2),"utf-8"),o}export{H as CloudClient,ce as DEFAULT_CLOUD_CONFIG,Mt as buildMaestroArgs,B as buildSummary,Fe as buildTimeline,yt as buildTimelineEntry,oe as buildUploadPayload,lt as categorizeCommand,He as cleanupExpiredQueue,Ee as collectArtifacts,ze as collectGitMetadata,z as deriveNonGitProjectId,je as deriveRepoDisplayName,ae as detectCI,ve as detectPlatformFromLogs,Me as discoverAiReports,he as discoverCommandFiles,ue as discoverConfigFile,ye as discoverFlowFiles,we as discoverLogFiles,Ne as enforceHttps,X as exchangeToken,We as finalizeAndUpload,rs as finalizeRun,Be as flushQueue,_e as generateHtmlReport,io as getArtifactStats,W as healthCheck,ts as initRealtimeRun,Y as isAuthError,fe as mergeCloudConfig,Ht as mergeReports,Bs as mergeReportsFromDirectory,O as normalizeGitRemoteUrl,De as openInBrowser,Ps as orchestrateReport,Ie as parseAiReportFile,mt as parseAiReportHtml,me as parseCommandsFile,ct as parseCommandsJson,pe as parseConfigFile,de as parseDuration,be as parseFlowFile,pt as parseFlowYaml,ge as parseJUnitFile,at as parseJUnitXml,gt as parseLogContent,xe as parseLogFile,Pe as printConsoleSummary,Lt as readPackageJsonName,Ue as refreshAccessToken,Le as renderHtmlDocument,lr as resolveConfig,G as resolveEnvVar,V as resolveEnvVars,Oe as resolveRepo,So as runMaestro,zt as uploadArtifact,Ke as uploadArtifacts,Ve as uploadBatchRun,Z as writeToQueue};//# sourceMappingURL=index.js.map
|
|
1256
1256
|
//# sourceMappingURL=index.js.map
|