@testrelic/playwright-analytics 2.16.3 → 2.16.4-next.167
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/index.cjs +190 -131
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +190 -131
- package/dist/index.js.map +1 -1
- package/dist/reporter-entry.cjs +188 -129
- package/dist/reporter-entry.cjs.map +1 -1
- package/dist/reporter-entry.js +187 -128
- package/dist/reporter-entry.js.map +1 -1
- package/package.json +2 -2
package/dist/reporter-entry.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
'use strict';var crypto=require('crypto'),fs
|
|
2
|
-
`),false}}moveFile(t,r){try{fs
|
|
3
|
-
`);}}}writeIndex(t){let r=path.join(this.reportDir,"index.json"),a=r+".tmp",
|
|
4
|
-
`),
|
|
5
|
-
`);let c=e.queue;if(c&&typeof c=="object"){if(typeof c.maxAge=="string"){let
|
|
6
|
-
`);if(t<1||t>
|
|
7
|
-
`)}catch{return null}}function
|
|
1
|
+
'use strict';var crypto=require('crypto'),fs=require('fs'),path=require('path'),os$1=require('os'),core=require('@testrelic/core'),child_process=require('child_process'),http=require('http'),readline=require('readline'),promises=require('fs/promises'),zlib=require('zlib'),util=require('util'),stream=require('stream');var us=".testrelic-report";function Be(e,t,r,a){let s=`${e}|${t.join("|")}|${r}|${a}`;return crypto.createHash("sha256").update(s).digest("hex").substring(0,12)}function Oe(e,t,r){let a=`${e}|${t.join("|")}|${r}`;return crypto.createHash("sha256").update(a).digest("hex").substring(0,12)}var ie=class{constructor(t){this.writeErrors=[];this.totalBytesWritten=0;this.reportDir=path.join(t,us),this.testsDir=path.join(this.reportDir,"tests"),fs.mkdirSync(this.testsDir,{recursive:true});}getReportDir(){return this.reportDir}getWriteErrors(){return this.writeErrors}writeTestDetail(t,r,a){try{let s=path.join(this.testsDir,t);fs.mkdirSync(s,{recursive:!0});let n=path.join(s,"meta.json"),o=n+".tmp",i=JSON.stringify(r);return fs.writeFileSync(o,i,"utf-8"),fs.renameSync(o,n),this.totalBytesWritten+=Buffer.byteLength(i,"utf-8"),a?.networkRequestsFile&&this.moveFile(a.networkRequestsFile,path.join(s,"network.jsonl")),a?.consoleLogsFile&&this.moveFile(a.consoleLogsFile,path.join(s,"console.jsonl")),a?.apiCallsFile&&this.moveFile(a.apiCallsFile,path.join(s,"api-calls.jsonl")),!0}catch(s){let n=s instanceof Error?s.message:String(s);return this.writeErrors.push({testId:t,error:n,timestamp:new Date().toISOString()}),process.stderr.write(`[testrelic] Failed to write test detail for ${t}: ${n}
|
|
2
|
+
`),false}}moveFile(t,r){try{fs.renameSync(t,r);}catch{try{fs.copyFileSync(t,r);try{fs.unlinkSync(t);}catch{}}catch(a){process.stderr.write(`[testrelic] Failed to move file ${t} \u2192 ${r}: ${a instanceof Error?a.message:String(a)}
|
|
3
|
+
`);}}}writeIndex(t){let r=path.join(this.reportDir,"index.json"),a=r+".tmp",s=JSON.stringify(t);fs.writeFileSync(a,s,"utf-8"),fs.renameSync(a,r),this.totalBytesWritten+=Buffer.byteLength(s,"utf-8");}writeCompactIndex(t){let r=path.join(this.reportDir,"index-compact.json"),a=r+".tmp",s=t.map(({titlePath:o,project:i,...l})=>l),n=JSON.stringify(s);fs.writeFileSync(a,n,"utf-8"),fs.renameSync(a,r),this.totalBytesWritten+=Buffer.byteLength(n,"utf-8");}writeSummary(t){let r=path.join(this.reportDir,"summary.json"),a=r+".tmp",s=JSON.stringify(t);fs.writeFileSync(a,s,"utf-8"),fs.renameSync(a,r),this.totalBytesWritten+=Buffer.byteLength(s,"utf-8");}writeManifest(t){let r=path.join(this.reportDir,"manifest.json"),a=r+".tmp",s=JSON.stringify(t);fs.writeFileSync(a,s,"utf-8"),fs.renameSync(a,r),this.totalBytesWritten+=Buffer.byteLength(s,"utf-8");}computeTotalSize(){return this.totalBytesWritten}dispose(){}};var dr=".testrelic",vs="testrelic-config.json",bs=".testrelic",ys=5,xs=new Set(["__proto__","constructor","prototype"]),or=Object.freeze({apiKey:null,endpoint:"https://platform.testrelic.ai/api/v1",uploadStrategy:"batch",timeout:3e4,uploadBudgetMs:12e4,projectName:null,queueMaxAge:6048e5,queueDirectory:`${dr}/queue`,uploadArtifacts:true,artifactMaxSizeMb:50}),ws={s:1e3,m:60*1e3,h:3600*1e3,d:1440*60*1e3};function cr(e){let t=path.resolve(e);for(let r=0;r<=ys;r++){let a=path.join(t,dr,vs);if(fs.existsSync(a))try{if(fs.statSync(a).isFile())return a}catch{}let s=path.join(t,bs);if(fs.existsSync(s))try{if(fs.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.
|
|
4
|
+
`),s}catch{}let n=path.dirname(t);if(n===t)break;t=n;}return null}function ur(e){try{let t=fs.readFileSync(e,"utf-8"),r=JSON.parse(t);return typeof r!="object"||r===null||Array.isArray(r)||!pr(r)?null:r}catch{return null}}function pr(e){for(let t of Object.keys(e)){if(xs.has(t))return false;let r=e[t];if(typeof r=="object"&&r!==null&&!Array.isArray(r)&&!pr(r))return false}return true}function fr(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 Ue(e){let t=Object.create(null);for(let r of Object.keys(e)){let a=e[r];typeof a=="string"&&a.startsWith("$")?t[r]=fr(a):typeof a=="object"&&a!==null&&!Array.isArray(a)?t[r]=Ue(a):t[r]=a;}return t}function lr(e){let t=/^(\d+)\s*([smhd])$/.exec(e.trim());if(!t)return null;let r=parseInt(t[1],10),a=t[2],s=ws[a];return !s||r<=0?null:r*s}function gr(e,t){let r=Object.create(null);if(Object.assign(r,or),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.uploadBudgetMs=="number"&&(r.uploadBudgetMs=l.uploadBudgetMs),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),e.project&&!e["testrelic-repo"]&&process.stderr.write(`[testrelic] Deprecation: "project" key in config is deprecated. Rename it to "testrelic-repo".
|
|
5
|
+
`);let c=e.queue;if(c&&typeof c=="object"){if(typeof c.maxAge=="string"){let p=lr(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("$")?fr(t.apiKey):t.apiKey;l&&(r.apiKey=l);}if(typeof t.endpoint=="string"&&(r.endpoint=t.endpoint),typeof t.upload=="string"&&(r.uploadStrategy=t.upload),typeof t.timeout=="number"&&(r.timeout=t.timeout),typeof t.uploadBudgetMs=="number"&&(r.uploadBudgetMs=t.uploadBudgetMs),typeof t.projectName=="string"&&(r.projectName=t.projectName),typeof t.queueMaxAge=="string"){let l=lr(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 a=process.env.TESTRELIC_API_KEY;a&&a.length>0&&(r.apiKey=a);let s=process.env.TESTRELIC_CLOUD_ENDPOINT;s&&core.isValidEndpointUrl(s)&&(r.endpoint=s);let n=process.env.TESTRELIC_UPLOAD_STRATEGY;n&&["batch","realtime","both"].includes(n)&&(r.uploadStrategy=n);let o=process.env.TESTRELIC_CLOUD_TIMEOUT;if(o){let l=parseInt(o,10);!isNaN(l)&&l>=1e3&&l<=12e4&&(r.timeout=l);}let i=Object.freeze(r);return core.isValidCloudConfig(i)?i:or}var Ts=[/AKIA[A-Z0-9]{16}/g,/Bearer\s+[A-Za-z0-9\-._~+/]+=*/g,/-----BEGIN\s+(RSA\s+)?PRIVATE\sKEY-----[\s\S]*?-----END/g,/\/\/[^:]+:[^@]+@/g],Rs=["authorization","cookie","set-cookie","x-api-key"],As=["password","secret","token","apiKey","api_key"];function hr(e){let t=Object.create(null);return t.trackApiCalls=e?.trackApiCalls??true,t.captureRequestHeaders=e?.captureRequestHeaders??true,t.captureResponseHeaders=e?.captureResponseHeaders??true,t.captureRequestBody=e?.captureRequestBody??true,t.captureResponseBody=e?.captureResponseBody??true,t.captureAssertions=e?.captureAssertions??true,t.redactHeaders=e?.redactHeaders??[...Rs],t.redactBodyFields=e?.redactBodyFields??[...As],t.apiIncludeUrls=e?.apiIncludeUrls??[],t.apiExcludeUrls=e?.apiExcludeUrls??[],Object.freeze(t)}function mr(e){if(e!==void 0&&!core.isValidConfig(e))throw core.createError(core.ErrorCode.CONFIG_INVALID,"Invalid reporter configuration");let t=Object.create(null);t.outputPath=e?.outputPath??"./test-results/analytics-timeline.json",t.includeStackTrace=e?.includeStackTrace??false,t.includeCodeSnippets=e?.includeCodeSnippets??true,t.codeContextLines=e?.codeContextLines??3,t.includeNetworkStats=e?.includeNetworkStats??true,t.captureNavigation=e?.captureNavigation??true,t.navigationTypes=e?.navigationTypes??null,t.redactPatterns=[...Ts,...e?.redactPatterns??[]],t.testRunId=e?.testRunId??null,t.metadata=e?.metadata??null;let r=t.outputPath;t.openReport=e?.openReport??true,t.htmlReportPath=e?.htmlReportPath??r.replace(/\.json$/,".html"),t.includeArtifacts=e?.includeArtifacts??true,t.trackApiCalls=e?.trackApiCalls??true,t.quiet=e?.quiet??false,t.includeActionSteps=e?.includeActionSteps??true,t.captureConsoleLogs=e?.captureConsoleLogs??true;let a=cr(process.cwd()),s=a?ur(a):null,n=s?Ue(s):null,o=gr(n,e?.cloud);return t.cloud=o.apiKey?o:null,t.reportMode=e?.reportMode??"streaming",t.streamingThreshold=e?.streamingThreshold??0,Object.freeze(t)}var ze="1.9.0";function vr(e,t,r){try{let s=fs.readFileSync(e,"utf-8").split(`
|
|
6
|
+
`);if(t<1||t>s.length)return null;let n=Math.max(1,t-r),o=Math.min(s.length,t+r),i=[];for(let l=n;l<=o;l++){let d=l===t?">":" ",c=String(l).padStart(String(o).length," ");i.push(`${d} ${c} | ${s[l-1]}`);}return i.join(`
|
|
7
|
+
`)}catch{return null}}function br(e){return t=>{let r=t;for(let a of e)if(typeof a=="string"){let s=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");r=r.replace(new RegExp(s,"g"),"[REDACTED]");}else {let s=a.flags.includes("g")?a.flags:a.flags+"g",n=new RegExp(a.source,s);r=r.replace(n,"[REDACTED]");}return r}}function Is(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 Ms(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 Es(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 Ps(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 Ds(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 Ls=[Is,Ms,Es,Ps,Ds];function U(e){let t=process.env;for(let r of Ls){let a=r(t);if(a)return a}return null}var He=`
|
|
8
8
|
/* Theme Variables */
|
|
9
9
|
:root,[data-theme="dark"]{
|
|
10
10
|
--bg:#0f1117;--bg-1:#161b22;--bg-2:#1c2128;--bg-3:#21262d;--bg-code:#13111c;
|
|
@@ -162,6 +162,7 @@ body{
|
|
|
162
162
|
.trb-tag{background:rgba(59,130,246,0.12);color:#60a5fa}
|
|
163
163
|
.trb-retry{background:rgba(245,158,11,0.12);color:#fbbf24}
|
|
164
164
|
.trb-flaky{background:rgba(245,158,11,0.12);color:#fbbf24}
|
|
165
|
+
.trb-xfail{background:rgba(107,114,128,0.12);color:var(--fg-1)}
|
|
165
166
|
.test-row-dur{font-size:13px;font-weight:700;color:var(--fg-1);flex-shrink:0;white-space:nowrap}
|
|
166
167
|
.test-row-arrow{color:var(--fg-2);flex-shrink:0;transition:color .15s}
|
|
167
168
|
.test-row:hover .test-row-arrow{color:var(--fg-1)}
|
|
@@ -289,6 +290,8 @@ body{
|
|
|
289
290
|
.dm-tag{background:rgba(59,130,246,0.12);color:#60a5fa}
|
|
290
291
|
.dm-retry{background:rgba(245,158,11,0.12);color:#fbbf24}
|
|
291
292
|
.dm-flaky{background:rgba(245,158,11,0.12);color:#fbbf24}
|
|
293
|
+
.dm-xfail{background:rgba(34,197,94,0.1);color:#22c55e}
|
|
294
|
+
.dm-xfail-bad{background:rgba(239,68,68,0.12);color:#ef4444}
|
|
292
295
|
.detail-sub-meta{display:flex;gap:14px;font-size:11px;color:var(--fg-1);flex-wrap:wrap;margin-top:6px}
|
|
293
296
|
.meta-k{font-weight:600;color:var(--fg-2);text-transform:uppercase;letter-spacing:.04em;font-size:10px;margin-right:3px}
|
|
294
297
|
.detail-id{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:10px;color:var(--fg-1);background:var(--bg-2);padding:1px 6px;border-radius:4px}
|
|
@@ -571,11 +574,11 @@ body{
|
|
|
571
574
|
<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)"/>
|
|
572
575
|
<defs><linearGradient id="paint0_linear_55_11" x1="98" y1="0.000244141" x2="98" y2="247" gradientUnits="userSpaceOnUse">
|
|
573
576
|
<stop stop-color="#03B79C"/><stop offset="0.504808" stop-color="#4EDAA4"/><stop offset="0.865285" stop-color="#84F3AA"/>
|
|
574
|
-
</linearGradient></defs></svg
|
|
577
|
+
</linearGradient></defs></svg>`,Ve=`<svg width="32" height="40" viewBox="0 0 196 247" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
575
578
|
<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)"/>
|
|
576
579
|
<defs><linearGradient id="paint0_linear_55_11" x1="98" y1="0.000244141" x2="98" y2="247" gradientUnits="userSpaceOnUse">
|
|
577
580
|
<stop stop-color="#03B79C"/><stop offset="0.504808" stop-color="#4EDAA4"/><stop offset="0.865285" stop-color="#84F3AA"/>
|
|
578
|
-
</linearGradient></defs></svg>`;var
|
|
581
|
+
</linearGradient></defs></svg>`;var $e={"failed|failed":"passed","failed|passed":"failed"},yr={"failed|failed":"Failed as expected","failed|passed":"Expected to fail, but passed."};function Ns(e,t){return `${t??"passed"}|${e}`}function Fs(e,t){return $e[Ns(e,t)]??e}function je(e,t){let r={passed:e.passed,failed:e.failed,flaky:e.flaky,skipped:e.skipped,timedout:e.timedout},a=0,s=0;for(let n of t){let o=Fs(n.status,n.expectedStatus);o!==n.status&&(r[n.status]--,r[o]++,o==="passed"?a++:s++);}return {total:e.total,...r,expectedFailures:a,unexpectedPasses:s}}var Ge=`
|
|
579
582
|
/* \u2500\u2500 Utilities \u2500\u2500 */
|
|
580
583
|
function esc(s){if(!s)return '';return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,''')}
|
|
581
584
|
function stripAnsi(s){return s?s.replace(/\\u001b\\[[0-9;]*m/g,'').replace(/\\x1b\\[[0-9;]*m/g,''):''}
|
|
@@ -584,15 +587,33 @@ body{
|
|
|
584
587
|
function fmtDate(iso){try{return new Date(iso).toLocaleString()}catch(e){return iso}}
|
|
585
588
|
function shortTitle(t){var p=t.split(' > ');return p.length>1?p[p.length-1]:t}
|
|
586
589
|
|
|
590
|
+
/* \u2500\u2500 Playwright's verdict \u2500\u2500
|
|
591
|
+
The status on an index row or a timeline entry is the actual result.
|
|
592
|
+
Playwright counts a result as expected only when it equals the test's
|
|
593
|
+
expected status, so a test.fail() that failed is a pass and one that
|
|
594
|
+
passed is a failure. The tables are expected-status.ts's own,
|
|
595
|
+
interpolated as JSON data (not code), so the report and the terminal box
|
|
596
|
+
cannot disagree about a pair. Defined before the data transformation
|
|
597
|
+
below, which is their first caller. */
|
|
598
|
+
var PW_VERDICT=${JSON.stringify($e)};var PW_NOTE=${JSON.stringify(yr)};
|
|
599
|
+
function pwKey(s,e){return (e||'passed')+'|'+s;}
|
|
600
|
+
function pwVerdict(s,e){return PW_VERDICT[pwKey(s,e)]||s;}
|
|
601
|
+
function pwNote(s,e){return PW_NOTE[pwKey(s,e)]||null;}
|
|
602
|
+
|
|
587
603
|
/* \u2500\u2500 Data Transformation \u2500\u2500 */
|
|
588
604
|
var testMap={};
|
|
589
605
|
for(var i=0;i<data.timeline.length;i++){
|
|
590
606
|
var entry=data.timeline[i];
|
|
591
607
|
for(var j=0;j<entry.tests.length;j++){
|
|
592
608
|
var t=entry.tests[j];
|
|
609
|
+
/* Known and not fixed here: this keeps the FIRST attempt the timeline
|
|
610
|
+
lists, so a retried test's row can show an earlier attempt's status
|
|
611
|
+
while the verdict band counts final attempts. */
|
|
593
612
|
if(!testMap[t.testId]){
|
|
613
|
+
/* status is the verdict every surface reads (colour, filters, needs
|
|
614
|
+
attention); rawStatus keeps the actual result for the detail notes. */
|
|
594
615
|
testMap[t.testId]={
|
|
595
|
-
testId:t.testId,title:t.title,status:t.status,duration:t.duration,
|
|
616
|
+
testId:t.testId,title:t.title,status:pwVerdict(t.status,t.expectedStatus),rawStatus:t.status,duration:t.duration,
|
|
596
617
|
startedAt:t.startedAt,completedAt:t.completedAt,retryCount:t.retryCount,
|
|
597
618
|
tags:t.tags,failure:t.failure,filePath:t.filePath,suiteName:t.suiteName,
|
|
598
619
|
testType:t.testType,isFlaky:t.isFlaky,retryStatus:t.retryStatus,
|
|
@@ -660,13 +681,15 @@ body{
|
|
|
660
681
|
}
|
|
661
682
|
if(!final)continue;
|
|
662
683
|
var ix2=final;
|
|
684
|
+
/* The row carries expectedStatus since #135; it was thrown away here,
|
|
685
|
+
so a test.fail() that failed as expected rendered as a failure. */
|
|
663
686
|
var st={
|
|
664
|
-
testId:ix2.id,title:ix2.title,status:ix2.status,duration:ix2.duration,
|
|
687
|
+
testId:ix2.id,title:ix2.title,status:pwVerdict(ix2.status,ix2.expectedStatus),rawStatus:ix2.status,duration:ix2.duration,
|
|
665
688
|
filePath:ix2.filePath,tags:ix2.tags||[],isFlaky:ix2.status==='flaky',
|
|
666
689
|
testType:ix2.testType||'e2e',retryCount:grp.attempts.length,suiteName:'',
|
|
667
690
|
startedAt:'',completedAt:'',
|
|
668
691
|
networkRequests:[],steps:[],apiCalls:[],actions:[],consoleLogs:[],
|
|
669
|
-
artifacts:null,failure:null,retryStatus:null,expectedStatus:
|
|
692
|
+
artifacts:null,failure:null,retryStatus:null,expectedStatus:ix2.expectedStatus||'passed',actualStatus:null,
|
|
670
693
|
hasNetworkData:ix2.hasNetworkData,hasConsoleData:ix2.hasConsoleData,
|
|
671
694
|
hasActionSteps:ix2.hasActionSteps,hasArtifacts:ix2.hasArtifacts,
|
|
672
695
|
errorMessage:ix2.errorMessage,networkCount:ix2.networkCount||0,
|
|
@@ -684,7 +707,7 @@ body{
|
|
|
684
707
|
deviceLogErrors:ix2.deviceLogErrors||0,hasCrashLog:!!ix2.hasCrashLog,
|
|
685
708
|
hasVideo:!!ix2.hasVideo,aiDefectCount:ix2.aiDefectCount||0,
|
|
686
709
|
retryAttempts:grp.attempts.slice().sort(function(a,b){return a.retryIndex-b.retryIndex;}).map(function(a){
|
|
687
|
-
return {testId:a.id,retryIndex:a.retryIndex,status:a.status,duration:a.duration,errorMessage:a.errorMessage};
|
|
710
|
+
return {testId:a.id,retryIndex:a.retryIndex,status:pwVerdict(a.status,a.expectedStatus),rawStatus:a.status,expectedStatus:a.expectedStatus||'passed',duration:a.duration,errorMessage:a.errorMessage};
|
|
688
711
|
})
|
|
689
712
|
};
|
|
690
713
|
testMap[st.testId]=st;
|
|
@@ -695,12 +718,12 @@ body{
|
|
|
695
718
|
for(var ai=0;ai<st.retryAttempts.length;ai++){
|
|
696
719
|
var ra=st.retryAttempts[ai];
|
|
697
720
|
testMap[ra.testId]={
|
|
698
|
-
testId:ra.testId,title:st.title+' (attempt '+(ra.retryIndex+1)+')',status:ra.status,
|
|
721
|
+
testId:ra.testId,title:st.title+' (attempt '+(ra.retryIndex+1)+')',status:ra.status,rawStatus:ra.rawStatus,
|
|
699
722
|
duration:ra.duration,filePath:st.filePath,tags:st.tags,isFlaky:false,
|
|
700
723
|
testType:st.testType,retryCount:0,suiteName:'',startedAt:'',completedAt:'',
|
|
701
724
|
networkRequests:[],steps:[],apiCalls:[],actions:[],consoleLogs:[],
|
|
702
725
|
artifacts:null,failure:null,retryStatus:'attempt '+(ra.retryIndex+1)+' of '+(st.retryAttempts.length+1),
|
|
703
|
-
expectedStatus:
|
|
726
|
+
expectedStatus:ra.expectedStatus,actualStatus:null,errorMessage:ra.errorMessage,
|
|
704
727
|
networkCount:0,consoleCount:0,actionCount:0
|
|
705
728
|
};
|
|
706
729
|
}
|
|
@@ -863,11 +886,13 @@ body{
|
|
|
863
886
|
h+='<div class="status-indicator si-'+t.status+'"></div>';
|
|
864
887
|
h+='<div class="test-row-info tri-inline">';
|
|
865
888
|
h+='<div class="test-row-title" title="'+esc(t.title)+'">'+esc(shortTitle(t.title))+'</div>';
|
|
866
|
-
var hasBadges=(t.testType&&t.testType!=='unknown')||t.isFlaky||(t.tags&&t.tags.length>0);
|
|
889
|
+
var hasBadges=(t.testType&&t.testType!=='unknown')||t.isFlaky||(t.tags&&t.tags.length>0)||t.expectedStatus==='failed';
|
|
867
890
|
if(hasBadges){
|
|
868
891
|
h+='<div class="test-row-badges">';
|
|
869
892
|
if(t.testType&&t.testType!=='unknown')h+='<span class="trb trb-type">'+esc(t.testType)+'</span>';
|
|
870
893
|
if(t.isFlaky)h+='<span class="trb trb-flaky">flaky</span>';
|
|
894
|
+
/* A green row whose test failed needs saying so, or it reads as a bug. */
|
|
895
|
+
if(t.expectedStatus==='failed')h+='<span class="trb trb-xfail" title="test.fail(): Playwright expects this test to fail">expected to fail</span>';
|
|
871
896
|
if(t.retryCount>0)h+='<span class="trb trb-retry">'+t.retryCount+' retries</span>';
|
|
872
897
|
if(t.tags){for(var ti=0;ti<t.tags.length;ti++){if(t.tags[ti])h+='<span class="trb trb-tag">'+esc(t.tags[ti])+'</span>';}}
|
|
873
898
|
h+='</div>';
|
|
@@ -884,7 +909,8 @@ body{
|
|
|
884
909
|
var ra=t.retryAttempts[ri];
|
|
885
910
|
h+='<div class="test-row test-row-retry-item" data-testid="'+esc(ra.testId)+'">';
|
|
886
911
|
h+='<div class="status-indicator si-'+ra.status+'"></div>';
|
|
887
|
-
|
|
912
|
+
var _raNote=ra.errorMessage?null:pwNote(ra.rawStatus,ra.expectedStatus);
|
|
913
|
+
h+='<div class="test-row-info"><div class="test-row-title">Attempt '+(ra.retryIndex+1)+' — '+esc(ra.status)+(ra.errorMessage?': '+esc(ra.errorMessage):(_raNote?': '+esc(_raNote):''))+'</div></div>';
|
|
888
914
|
h+='<span class="test-row-dur">'+fmtDur(ra.duration)+'</span>';
|
|
889
915
|
h+='<svg class="test-row-arrow" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>';
|
|
890
916
|
h+='</div>';
|
|
@@ -1020,6 +1046,9 @@ body{
|
|
|
1020
1046
|
function renderDrawer(testId,detail){
|
|
1021
1047
|
var t=detail||testMap[testId];
|
|
1022
1048
|
if(!t){drawerBodyEl.innerHTML='';return;}
|
|
1049
|
+
/* t.status is the verdict; _raw is what actually happened, which decides
|
|
1050
|
+
whether there is an error to show. */
|
|
1051
|
+
var _raw=t.rawStatus||t.status,_note=pwNote(_raw,t.expectedStatus);
|
|
1023
1052
|
var h='<div class="test-detail">';
|
|
1024
1053
|
|
|
1025
1054
|
/* \u2500\u2500 Top: Metadata \u2500\u2500 */
|
|
@@ -1031,7 +1060,8 @@ body{
|
|
|
1031
1060
|
if(t.retryCount>0)h+='<span class="dm-badge dm-retry">'+t.retryCount+' retries</span>';
|
|
1032
1061
|
if(t.retryStatus)h+='<span class="dm-badge dm-retry">'+esc(t.retryStatus)+'</span>';
|
|
1033
1062
|
if(t.tags&&t.tags.length>0){for(var ti=0;ti<t.tags.length;ti++){if(t.tags[ti])h+='<span class="dm-badge dm-tag">'+esc(t.tags[ti])+'</span>';}}
|
|
1034
|
-
if(
|
|
1063
|
+
if(_note)h+='<span class="dm-badge '+(t.status==='passed'?'dm-xfail':'dm-xfail-bad')+'">'+esc(_note)+'</span>';
|
|
1064
|
+
else if(t.expectedStatus&&t.actualStatus&&t.expectedStatus!==t.actualStatus)h+='<span class="dm-badge" style="background:rgba(239,68,68,0.12);color:#ef4444">expected: '+esc(t.expectedStatus)+' actual: '+esc(t.actualStatus)+'</span>';
|
|
1035
1065
|
h+='</div>';
|
|
1036
1066
|
if(t.testId||t.filePath||t.suiteName){h+='<div class="detail-sub-meta">';if(t.testId)h+='<span><span class="meta-k">ID</span><span class="detail-id" title="'+esc(t.testId)+'">'+esc(t.testId.substring(0,12))+'</span></span>';if(t.filePath)h+='<span><span class="meta-k">File</span><span class="detail-file">'+esc(t.filePath)+'</span></span>';if(t.suiteName)h+='<span><span class="meta-k">Suite</span><span class="detail-suite">'+esc(t.suiteName)+'</span></span>';h+='</div>';}
|
|
1037
1067
|
h+='</div><div class="detail-duration">'+fmtDur(t.duration)+'</div></div></div>';
|
|
@@ -1051,14 +1081,17 @@ body{
|
|
|
1051
1081
|
if(hasVideo&&t.startedAt){baseTime=Date.parse(t.startedAt);}
|
|
1052
1082
|
if(!baseTime&&hasVideo&&t.consoleLogs&&t.consoleLogs.length>0&&t.consoleLogs[0].timestamp){baseTime=Date.parse(t.consoleLogs[0].timestamp);}
|
|
1053
1083
|
|
|
1054
|
-
|
|
1084
|
+
/* From the actual result: an expected failure keeps its error, as it does
|
|
1085
|
+
in Playwright's own report, under an 'Expected failure' rail entry. */
|
|
1086
|
+
var hasFailure=(_raw==='failed'||_raw==='flaky')&&t.failure;
|
|
1055
1087
|
var hasDom=false;
|
|
1056
1088
|
if(t.visual){for(var dv=0;dv<t.visual.length;dv++){if(t.visual[dv].domChangeCount)hasDom=true;}}
|
|
1057
1089
|
|
|
1058
1090
|
/* What the rail is allowed to offer \u2014 built from what actually rendered,
|
|
1059
1091
|
so a jump can never land on a section that is not there. */
|
|
1060
1092
|
var present={};
|
|
1061
|
-
if(hasFailure)present.failure={};
|
|
1093
|
+
if(hasFailure)present.failure={xfail:t.status==='passed'};
|
|
1094
|
+
else if(_note&&t.status==='failed')present.failure={};
|
|
1062
1095
|
if(hasVisual)present.visual={n:t.visual.length};
|
|
1063
1096
|
if(hasDom)present.dom={n:(function(){var n=0;for(var q=0;q<t.visual.length;q++)n+=t.visual[q].domChangeCount||0;return n;})()};
|
|
1064
1097
|
if(hasArt)present.artifacts={};
|
|
@@ -1082,6 +1115,8 @@ body{
|
|
|
1082
1115
|
h+='<div class="drawer-main">';
|
|
1083
1116
|
|
|
1084
1117
|
if(hasFailure)h+='<div class="drawer-section" data-section="failure">'+renderFailure(t.failure,t.filePath,t.title,t.tags)+'</div>';
|
|
1118
|
+
/* A test.fail() that passed has no error of its own; the failure is the pass. */
|
|
1119
|
+
else if(_note&&t.status==='failed')h+='<div class="drawer-section" data-section="failure"><div class="failure-panel"><div class="failure-message">'+esc(_note)+'</div></div></div>';
|
|
1085
1120
|
else if(t.status==='failed')h+='<div class="drawer-section" data-section="failure" style="padding:14px;background:var(--bg-2);border:1px solid var(--bd);border-radius:10px;font-size:12px;color:var(--fg-2);font-style:italic">No diagnostic information available</div>';
|
|
1086
1121
|
|
|
1087
1122
|
if(anySection){
|
|
@@ -1211,7 +1246,7 @@ body{
|
|
|
1211
1246
|
clearTimeout(_searchTimer);
|
|
1212
1247
|
_searchTimer=setTimeout(function(){searchQuery=q;applyFilters();},150);
|
|
1213
1248
|
}
|
|
1214
|
-
`;var
|
|
1249
|
+
`;var We=`
|
|
1215
1250
|
/* \u2500\u2500 Network Visualization Helpers \u2500\u2500 */
|
|
1216
1251
|
var RES_COLORS={xhr:'#60a5fa',document:'#818cf8',script:'#fbbf24',stylesheet:'#a78bfa',image:'#34d399',font:'#f472b6',other:'#6b7280'};
|
|
1217
1252
|
var RES_LABELS={xhr:'XHR',document:'Doc',script:'JS',stylesheet:'CSS',image:'Img',font:'Font',other:'Other'};
|
|
@@ -1946,7 +1981,7 @@ body{
|
|
|
1946
1981
|
var countEl=ndt.querySelector('.ndt-count');
|
|
1947
1982
|
if(countEl)countEl.textContent=visible+' / '+rows.length+' requests';
|
|
1948
1983
|
}
|
|
1949
|
-
`;var
|
|
1984
|
+
`;var Ke=`
|
|
1950
1985
|
var _filterState={status:{},type:{},specFile:{},visual:{},evidence:{}};
|
|
1951
1986
|
|
|
1952
1987
|
/* Evidence filters: one predicate per chip, so API and mobile runs share the
|
|
@@ -2106,9 +2141,13 @@ function renderFilterBar(){
|
|
|
2106
2141
|
function initFilters(){
|
|
2107
2142
|
_filterState={status:{},type:{},specFile:{},visual:{},evidence:{}};
|
|
2108
2143
|
_totalTests=tests.length;
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2144
|
+
/* The presented counts (test.fail() read as Playwright reads it), so an
|
|
2145
|
+
unfiltered view agrees with the verdict band and with the chips, which
|
|
2146
|
+
count each test's presented status. */
|
|
2147
|
+
var _ps=data.presentedSummary||data.summary;
|
|
2148
|
+
_originalSummary={total:_ps.total,passed:_ps.passed,
|
|
2149
|
+
failed:_ps.failed,flaky:_ps.flaky,
|
|
2150
|
+
skipped:_ps.skipped,timedout:_ps.timedout||0};
|
|
2112
2151
|
}
|
|
2113
2152
|
|
|
2114
2153
|
function getFilteredTests(){
|
|
@@ -2201,7 +2240,7 @@ function _updateCard(cls,val){
|
|
|
2201
2240
|
var el=document.querySelector('.'+cls+' .s-count');
|
|
2202
2241
|
if(el)el.textContent=''+val;
|
|
2203
2242
|
}
|
|
2204
|
-
`;var
|
|
2243
|
+
`;var Je=`
|
|
2205
2244
|
/* \u2500\u2500 Event Delegation \u2500\u2500 */
|
|
2206
2245
|
document.addEventListener('click',function(e){
|
|
2207
2246
|
var target=e.target;
|
|
@@ -2472,7 +2511,7 @@ function _updateCard(cls,val){
|
|
|
2472
2511
|
var d=document.getElementById('filter-drawer');if(d)d.classList.remove('open');
|
|
2473
2512
|
var b=document.getElementById('filter-drawer-backdrop');if(b)b.classList.remove('open');
|
|
2474
2513
|
}
|
|
2475
|
-
`;var
|
|
2514
|
+
`;var Ye=`
|
|
2476
2515
|
/* \u2500\u2500 Category badge helpers \u2500\u2500 */
|
|
2477
2516
|
function actionBadgeClass(cat){
|
|
2478
2517
|
if(cat==='assertion')return 'action-badge-assertion';
|
|
@@ -2518,7 +2557,7 @@ function _updateCard(cls,val){
|
|
|
2518
2557
|
h+='</div>';
|
|
2519
2558
|
return h;
|
|
2520
2559
|
}
|
|
2521
|
-
`;var
|
|
2560
|
+
`;var Xe=`
|
|
2522
2561
|
/* \u2500\u2500 Console Log Level Colors & Labels \u2500\u2500 */
|
|
2523
2562
|
var LOG_COLORS={log:'#9ca3af',warn:'#fbbf24',error:'#f87171',info:'#60a5fa',debug:'#a78bfa',stdout:'#9ca3af',stderr:'#f87171'};
|
|
2524
2563
|
var LOG_LABELS={log:'LOG',warn:'WARN',error:'ERR',info:'INFO',debug:'DBG',stdout:'OUT',stderr:'ERR'};
|
|
@@ -2705,7 +2744,7 @@ function _updateCard(cls,val){
|
|
|
2705
2744
|
}
|
|
2706
2745
|
return h;
|
|
2707
2746
|
}
|
|
2708
|
-
`;var
|
|
2747
|
+
`;var Ze=`
|
|
2709
2748
|
/* \u2500\u2500 Artifact Utilities \u2500\u2500 */
|
|
2710
2749
|
function formatBytes(bytes){
|
|
2711
2750
|
if(bytes===0)return '0 B';
|
|
@@ -2714,7 +2753,7 @@ function _updateCard(cls,val){
|
|
|
2714
2753
|
if(i>=sizes.length)i=sizes.length-1;
|
|
2715
2754
|
return parseFloat((bytes/Math.pow(k,i)).toFixed(1))+' '+sizes[i];
|
|
2716
2755
|
}
|
|
2717
|
-
`;var
|
|
2756
|
+
`;var Qe=`
|
|
2718
2757
|
/* \u2500\u2500 Visual Regression \u2500\u2500 */
|
|
2719
2758
|
|
|
2720
2759
|
function visStatusLabel(status){
|
|
@@ -2871,7 +2910,7 @@ function _updateCard(cls,val){
|
|
|
2871
2910
|
if(otop)otop.style.opacity=String(el.value/100);
|
|
2872
2911
|
}
|
|
2873
2912
|
});
|
|
2874
|
-
`;var
|
|
2913
|
+
`;var et=`
|
|
2875
2914
|
/* \u2500\u2500 DOM comparison \u2500\u2500 */
|
|
2876
2915
|
|
|
2877
2916
|
/* Rank-cycled so a row and its box always share a colour. */
|
|
@@ -3023,7 +3062,7 @@ function _updateCard(cls,val){
|
|
|
3023
3062
|
var card=row.closest('.vis-card');
|
|
3024
3063
|
if(card&&!row.classList.contains('pinned'))domSetActive(card,row.getAttribute('data-dom-row'),false);
|
|
3025
3064
|
});
|
|
3026
|
-
`;var
|
|
3065
|
+
`;var tt=`
|
|
3027
3066
|
/* \u2500\u2500 Verdict band \u2500\u2500 */
|
|
3028
3067
|
|
|
3029
3068
|
/* Both report modes hand us a summary; streaming's carries fewer fields. */
|
|
@@ -3067,19 +3106,24 @@ function _updateCard(cls,val){
|
|
|
3067
3106
|
}
|
|
3068
3107
|
|
|
3069
3108
|
function renderSummary(){
|
|
3070
|
-
|
|
3071
|
-
|
|
3109
|
+
/* Two objects on purpose. data.summary counts by actual status and also
|
|
3110
|
+
carries the run's volume totals (the tiles below). presentedSummary has
|
|
3111
|
+
only the status counts, read the way Playwright reads test.fail(), so it
|
|
3112
|
+
drives the verdict and nothing else \u2014 reading the tiles from it would
|
|
3113
|
+
blank them. */
|
|
3114
|
+
var s=data.summary||{};var c=data.presentedSummary||s;
|
|
3115
|
+
var failed=vNum(c.failed),flaky=vNum(c.flaky);
|
|
3072
3116
|
var cls=failed>0?'v-failed':(flaky>0?'':'v-passed');
|
|
3073
3117
|
|
|
3074
3118
|
var h='<div class="verdict"><div class="verdict-main '+cls+'">';
|
|
3075
3119
|
|
|
3076
|
-
h+='<div class="verdict-head"><div class="verdict-title">'+esc(renderVerdictHeadline(
|
|
3120
|
+
h+='<div class="verdict-head"><div class="verdict-title">'+esc(renderVerdictHeadline(c))+'</div>';
|
|
3077
3121
|
var where=failed>0?failureLocation():null;
|
|
3078
3122
|
if(where)h+='<div class="verdict-where">all in <code>'+esc(where.split('/').pop())+'</code></div>';
|
|
3079
3123
|
h+='<div class="verdict-dur"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg>'+fmtDur(data.totalDuration||0)+'</div>';
|
|
3080
3124
|
h+='</div>';
|
|
3081
3125
|
|
|
3082
|
-
h+=renderVerdictBar(
|
|
3126
|
+
h+=renderVerdictBar(c);
|
|
3083
3127
|
|
|
3084
3128
|
/* Non-zero statuses get a real count; the rest collapse to one grey line
|
|
3085
3129
|
rather than each taking a sixth of the width. */
|
|
@@ -3090,7 +3134,7 @@ function _updateCard(cls,val){
|
|
|
3090
3134
|
];
|
|
3091
3135
|
var counts='',zeros=[];
|
|
3092
3136
|
for(var m=0;m<kinds.length;m++){
|
|
3093
|
-
var kk=kinds[m],n=vNum(
|
|
3137
|
+
var kk=kinds[m],n=vNum(c[kk.k]);
|
|
3094
3138
|
if(n>0){
|
|
3095
3139
|
counts+='<div class="vc"><span class="vc-dot" style="background:'+kk.c+'"></span><span class="vc-n">'+n+'</span><span class="vc-l">'+kk.l+'</span></div>';
|
|
3096
3140
|
}else{
|
|
@@ -3099,6 +3143,16 @@ function _updateCard(cls,val){
|
|
|
3099
3143
|
}
|
|
3100
3144
|
h+='<div class="verdict-counts">'+counts;
|
|
3101
3145
|
if(zeros.length>0)h+='<div class="verdict-zeros">'+esc(zeros.join(' \\u00b7 '))+'</div>';
|
|
3146
|
+
/* Say why these counts differ from report.json and summary.json. Its own
|
|
3147
|
+
line: a second margin-left:auto item would split the free space with
|
|
3148
|
+
the zeros and strand them mid-row. */
|
|
3149
|
+
var xf=vNum(c.expectedFailures),xp=vNum(c.unexpectedPasses);
|
|
3150
|
+
if(xf>0||xp>0){
|
|
3151
|
+
var notes=[];
|
|
3152
|
+
if(xf>0)notes.push(xf+' failed as expected');
|
|
3153
|
+
if(xp>0)notes.push(xp+' expected to fail, but passed');
|
|
3154
|
+
h+='<div class="verdict-xnote">'+esc(notes.join(' \\u00b7 ')+' (test.fail)')+'</div>';
|
|
3155
|
+
}
|
|
3102
3156
|
h+='</div>';
|
|
3103
3157
|
|
|
3104
3158
|
h+='</div>';
|
|
@@ -3139,7 +3193,8 @@ function _updateCard(cls,val){
|
|
|
3139
3193
|
var px=t.errorMessage.match(/([\\d,]+) pixels \\(ratio ([\\d.]+)/);
|
|
3140
3194
|
if(px)return '<em>'+esc(px[1])+' px differ</em>';
|
|
3141
3195
|
}
|
|
3142
|
-
|
|
3196
|
+
/* A test.fail() that passed has no error; its note is the cause. */
|
|
3197
|
+
if(!t.errorMessage){var _n=pwNote(t.rawStatus||t.status,t.expectedStatus);return _n&&t.status!=='passed'?'<em>'+esc(_n)+'</em>':'';}
|
|
3143
3198
|
var first=String(t.errorMessage).split('\\n')[0].trim();
|
|
3144
3199
|
if(first.length>150)first=first.slice(0,150)+'\\u2026';
|
|
3145
3200
|
return '<em>'+esc(first)+'</em>';
|
|
@@ -3261,9 +3316,10 @@ function _updateCard(cls,val){
|
|
|
3261
3316
|
var sec=RAIL_SECTIONS[i];
|
|
3262
3317
|
var info=present[sec.id];
|
|
3263
3318
|
if(!info)continue;
|
|
3264
|
-
|
|
3319
|
+
/* An expected failure's error is shown, but it is not why anything failed. */
|
|
3320
|
+
h+='<button class="rail-item'+(sec.fail&&!info.xfail?' rail-fail':'')+(first?' active':'')+'" data-rail="'+sec.id+'">';
|
|
3265
3321
|
h+=railIcon(sec.id);
|
|
3266
|
-
h+='<span class="rail-name">'+esc(sec.label)+'</span>';
|
|
3322
|
+
h+='<span class="rail-name">'+esc(info.xfail?'Expected failure':sec.label)+'</span>';
|
|
3267
3323
|
if(info.n)h+='<span class="rail-n'+(sec.dom?' rail-n-dom':'')+'">'+info.n+'</span>';
|
|
3268
3324
|
h+='</button>';
|
|
3269
3325
|
first=false;
|
|
@@ -3327,7 +3383,7 @@ function _updateCard(cls,val){
|
|
|
3327
3383
|
if(!card)return;
|
|
3328
3384
|
openTest(card.getAttribute('data-testid'));
|
|
3329
3385
|
});
|
|
3330
|
-
`,
|
|
3386
|
+
`,rt=`
|
|
3331
3387
|
var overviewViewEl=document.getElementById('view-overview');
|
|
3332
3388
|
var detailViewEl=document.getElementById('view-detail');
|
|
3333
3389
|
var detailNavEl=document.getElementById('detail-nav');
|
|
@@ -3468,7 +3524,7 @@ function _updateCard(cls,val){
|
|
|
3468
3524
|
|
|
3469
3525
|
window.addEventListener('hashchange',routeFromHash);
|
|
3470
3526
|
window.addEventListener('popstate',routeFromHash);
|
|
3471
|
-
`;var
|
|
3527
|
+
`;var at=`
|
|
3472
3528
|
var API_METHOD_COLOR={GET:'#60a5fa',POST:'#34d399',PUT:'#fbbf24',PATCH:'#a78bfa',DELETE:'#f87171',HEAD:'#6b7280',OPTIONS:'#6b7280'};
|
|
3473
3529
|
var API_STATUS_ORDER=['2xx','3xx','4xx','5xx','error'];
|
|
3474
3530
|
var API_STATUS_COLOR={'2xx':'#22c55e','3xx':'#60a5fa','4xx':'#fb923c','5xx':'#ef4444','error':'#ef4444'};
|
|
@@ -3694,7 +3750,7 @@ function _updateCard(cls,val){
|
|
|
3694
3750
|
}
|
|
3695
3751
|
return '';
|
|
3696
3752
|
}
|
|
3697
|
-
`;var
|
|
3753
|
+
`;var st=`
|
|
3698
3754
|
.vis-header{font-size:11px;font-weight:700;color:var(--fg-1);text-transform:uppercase;letter-spacing:.06em;margin-bottom:12px;display:flex;align-items:center;gap:6px}
|
|
3699
3755
|
.vis-header svg{opacity:.6}
|
|
3700
3756
|
.vis-count{font-weight:400;color:var(--fg-2);font-size:10px}
|
|
@@ -3727,7 +3783,7 @@ function _updateCard(cls,val){
|
|
|
3727
3783
|
|
|
3728
3784
|
/* A checkerboard behind the diff so fully transparent regions stay legible. */
|
|
3729
3785
|
.vis-diff-wrap{background-image:linear-gradient(45deg,var(--bd-xs) 25%,transparent 25%),linear-gradient(-45deg,var(--bd-xs) 25%,transparent 25%),linear-gradient(45deg,transparent 75%,var(--bd-xs) 75%),linear-gradient(-45deg,transparent 75%,var(--bd-xs) 75%);background-size:16px 16px;background-position:0 0,0 8px,8px -8px,-8px 0;border-radius:8px}
|
|
3730
|
-
`,
|
|
3786
|
+
`,nt=`
|
|
3731
3787
|
.dom-figure{position:relative;line-height:0;border:1px solid var(--bd);border-radius:8px;overflow:hidden;margin-bottom:12px}
|
|
3732
3788
|
.dom-img{display:block;width:100%;height:auto}
|
|
3733
3789
|
.dom-ov{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none}
|
|
@@ -3759,7 +3815,7 @@ function _updateCard(cls,val){
|
|
|
3759
3815
|
.dom-from{color:#ef4444;word-break:break-all}
|
|
3760
3816
|
.dom-arrow{color:var(--fg-2)}
|
|
3761
3817
|
.dom-to{color:#2dd4a8;word-break:break-all}
|
|
3762
|
-
`;var
|
|
3818
|
+
`;var it=`
|
|
3763
3819
|
/* \u2500\u2500 Wider shell \u2500\u2500
|
|
3764
3820
|
960px was sized for a list. The row now carries evidence and timing, and
|
|
3765
3821
|
the detail panel shows two screenshots side by side; both were cramped. */
|
|
@@ -3790,6 +3846,8 @@ function _updateCard(cls,val){
|
|
|
3790
3846
|
.vc-l{font-size:12px;color:var(--fg-1)}
|
|
3791
3847
|
/* Statuses with nothing in them stop taking a sixth of the width. */
|
|
3792
3848
|
.verdict-zeros{margin-left:auto;font-size:11px;color:var(--fg-2)}
|
|
3849
|
+
/* Why the counts above differ from report.json: test.fail() read as Playwright reads it. */
|
|
3850
|
+
.verdict-xnote{flex-basis:100%;font-size:11px;color:var(--fg-2)}
|
|
3793
3851
|
|
|
3794
3852
|
.verdict-side{width:268px;flex-shrink:0;background:var(--bg-1);border:1px solid var(--bd);border-radius:12px;padding:18px 20px;display:flex;flex-direction:column;gap:12px}
|
|
3795
3853
|
.verdict-side-label{font-size:10px;font-weight:600;color:var(--fg-2);letter-spacing:.06em;text-transform:uppercase}
|
|
@@ -3884,7 +3942,7 @@ function _updateCard(cls,val){
|
|
|
3884
3942
|
.verdict{flex-direction:column}
|
|
3885
3943
|
.verdict-side{width:100%}
|
|
3886
3944
|
}
|
|
3887
|
-
`,
|
|
3945
|
+
`,ot=`
|
|
3888
3946
|
/* The overlay is gone. Anything still carrying .drawer must not float. */
|
|
3889
3947
|
.drawer,.drawer-backdrop{display:none}
|
|
3890
3948
|
|
|
@@ -3905,7 +3963,7 @@ function _updateCard(cls,val){
|
|
|
3905
3963
|
/* The page scrolls now, so the old panel body must not scroll inside it. */
|
|
3906
3964
|
#view-detail .drawer-body{flex:none;overflow:visible;padding:0}
|
|
3907
3965
|
.detail-page .detail-rail,.detail-page .drawer-rail{top:16px}
|
|
3908
|
-
`;var
|
|
3966
|
+
`;var lt=`
|
|
3909
3967
|
/* \u2500\u2500 Run-level type band \u2500\u2500 */
|
|
3910
3968
|
.tband{display:grid;gap:16px;margin-bottom:20px}
|
|
3911
3969
|
.tband-3{grid-template-columns:1.1fr 1.1fr .9fr}
|
|
@@ -4003,21 +4061,21 @@ function _updateCard(cls,val){
|
|
|
4003
4061
|
@media (max-width:1100px){
|
|
4004
4062
|
.tband-3,.tband-2{grid-template-columns:1fr}
|
|
4005
4063
|
}
|
|
4006
|
-
`;var
|
|
4064
|
+
`;var Bs=`
|
|
4007
4065
|
(function(){
|
|
4008
4066
|
var data=JSON.parse(document.getElementById('report-data').textContent);
|
|
4009
|
-
${Ve}
|
|
4010
|
-
${Ke}
|
|
4011
|
-
${Je}
|
|
4012
|
-
${je}
|
|
4013
4067
|
${Ge}
|
|
4014
4068
|
${Ye}
|
|
4015
|
-
${Ze}
|
|
4016
4069
|
${Xe}
|
|
4017
4070
|
${We}
|
|
4071
|
+
${Ke}
|
|
4072
|
+
${Ze}
|
|
4073
|
+
${et}
|
|
4018
4074
|
${Qe}
|
|
4075
|
+
${Je}
|
|
4019
4076
|
${tt}
|
|
4020
|
-
${
|
|
4077
|
+
${at}
|
|
4078
|
+
${rt}
|
|
4021
4079
|
applyTheme();
|
|
4022
4080
|
renderRunMeta();
|
|
4023
4081
|
renderSummary();
|
|
@@ -4028,7 +4086,7 @@ function _updateCard(cls,val){
|
|
|
4028
4086
|
renderNeedsAttention();
|
|
4029
4087
|
routeFromHash();
|
|
4030
4088
|
var _lo=document.getElementById('loading-overlay');if(_lo)_lo.remove();
|
|
4031
|
-
})();`;function
|
|
4089
|
+
})();`;function xr(e,t,r){let a=e.replace(/<\//g,"<\\/"),s=r?r.replace(/<\//g,"<\\/"):null;return `<!-- TestRelic AI Analytics Report \u2014 self-contained, no external dependencies -->
|
|
4032
4090
|
<!DOCTYPE html>
|
|
4033
4091
|
<html lang="en" data-theme="">
|
|
4034
4092
|
<head>
|
|
@@ -4038,14 +4096,14 @@ function _updateCard(cls,val){
|
|
|
4038
4096
|
<title>TestRelic AI Analytics Report</title>
|
|
4039
4097
|
${""}
|
|
4040
4098
|
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml;base64,${Buffer.from(qe).toString("base64")}">
|
|
4041
|
-
<style>${He}${
|
|
4099
|
+
<style>${He}${st}${nt}${it}${ot}${lt}</style>
|
|
4042
4100
|
<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>
|
|
4043
4101
|
</head>
|
|
4044
4102
|
<body>
|
|
4045
4103
|
<div class="wrap">
|
|
4046
4104
|
<div class="top-bar">
|
|
4047
4105
|
<div class="brand">
|
|
4048
|
-
${
|
|
4106
|
+
${Ve}
|
|
4049
4107
|
<div class="brand-text">
|
|
4050
4108
|
<span class="brand-title">TestRelic AI</span>
|
|
4051
4109
|
<span class="brand-sub">Analytics Report</span>
|
|
@@ -4081,24 +4139,25 @@ ${""}
|
|
|
4081
4139
|
<div class="filter-drawer-body" id="filter-drawer-body"></div>
|
|
4082
4140
|
</aside>
|
|
4083
4141
|
<script id="report-data" type="application/json">${a}</script>
|
|
4084
|
-
${
|
|
4085
|
-
<script>${
|
|
4142
|
+
${s?`<script id="artifact-manifest-data" type="application/json">${s}</script>`:""}
|
|
4143
|
+
<script>${Bs}</script>
|
|
4086
4144
|
</body>
|
|
4087
|
-
</html>`}function
|
|
4145
|
+
</html>`}function dt(e,t,r,a,s){let n=e.replace(/<\//g,"<\\/"),o=s?s.replace(/<\//g,"<\\/"):"null",i=t.replace(/<\//g,"<\\/"),l=a?a.replace(/<\//g,"<\\/"):null,d={};try{d=JSON.parse(e);}catch{}let c=`{
|
|
4088
4146
|
"schemaVersion":"2.0",
|
|
4089
4147
|
"reportMode":"streaming",
|
|
4090
4148
|
"serverPort":${r??"null"},
|
|
4091
4149
|
"summary":${n},
|
|
4092
|
-
"
|
|
4150
|
+
"presentedSummary":${o},
|
|
4151
|
+
"index":${i},
|
|
4093
4152
|
"timeline":[],
|
|
4094
|
-
"testRunId":${JSON.stringify(String(
|
|
4095
|
-
"startedAt":${JSON.stringify(String(
|
|
4096
|
-
"completedAt":${JSON.stringify(String(
|
|
4097
|
-
"totalDuration":${Number(
|
|
4098
|
-
"ci":${
|
|
4099
|
-
"metadata":${
|
|
4100
|
-
"shardRunIds":${
|
|
4101
|
-
}`,
|
|
4153
|
+
"testRunId":${JSON.stringify(String(d.testRunId??""))},
|
|
4154
|
+
"startedAt":${JSON.stringify(String(d.startedAt??""))},
|
|
4155
|
+
"completedAt":${JSON.stringify(String(d.completedAt??""))},
|
|
4156
|
+
"totalDuration":${Number(d.totalDuration)||0},
|
|
4157
|
+
"ci":${d.ci?JSON.stringify(d.ci).replace(/<\//g,"<\\/"):"null"},
|
|
4158
|
+
"metadata":${d.metadata?JSON.stringify(d.metadata).replace(/<\//g,"<\\/"):"null"},
|
|
4159
|
+
"shardRunIds":${d.shardRunIds?JSON.stringify(d.shardRunIds).replace(/<\//g,"<\\/"):"null"}
|
|
4160
|
+
}`,p=`
|
|
4102
4161
|
(function(){
|
|
4103
4162
|
var data=JSON.parse(document.getElementById('report-data').textContent);
|
|
4104
4163
|
var _serverPort=data.serverPort||null;
|
|
@@ -4168,18 +4227,18 @@ ${n?`<script id="artifact-manifest-data" type="application/json">${n}</script>`:
|
|
|
4168
4227
|
window.__trServerPort=_serverPort;
|
|
4169
4228
|
window.__trIsStreaming=true;
|
|
4170
4229
|
|
|
4171
|
-
${Ve}
|
|
4172
|
-
${Ke}
|
|
4173
|
-
${Je}
|
|
4174
|
-
${je}
|
|
4175
4230
|
${Ge}
|
|
4176
4231
|
${Ye}
|
|
4177
|
-
${Ze}
|
|
4178
4232
|
${Xe}
|
|
4179
4233
|
${We}
|
|
4234
|
+
${Ke}
|
|
4235
|
+
${Ze}
|
|
4236
|
+
${et}
|
|
4180
4237
|
${Qe}
|
|
4238
|
+
${Je}
|
|
4181
4239
|
${tt}
|
|
4182
|
-
${
|
|
4240
|
+
${at}
|
|
4241
|
+
${rt}
|
|
4183
4242
|
applyTheme();
|
|
4184
4243
|
renderRunMeta();
|
|
4185
4244
|
renderSummary();
|
|
@@ -4204,14 +4263,14 @@ ${n?`<script id="artifact-manifest-data" type="application/json">${n}</script>`:
|
|
|
4204
4263
|
${r?`<meta name="report-server-port" content="${r}">`:""}
|
|
4205
4264
|
${r?`<meta name="artifact-server-port" content="${r}">`:""}
|
|
4206
4265
|
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml;base64,${Buffer.from(qe).toString("base64")}">
|
|
4207
|
-
<style>${He}${
|
|
4266
|
+
<style>${He}${st}${nt}${it}${ot}${lt}</style>
|
|
4208
4267
|
<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>
|
|
4209
4268
|
</head>
|
|
4210
4269
|
<body>
|
|
4211
4270
|
<div class="wrap">
|
|
4212
4271
|
<div class="top-bar">
|
|
4213
4272
|
<div class="brand">
|
|
4214
|
-
${
|
|
4273
|
+
${Ve}
|
|
4215
4274
|
<div class="brand-text">
|
|
4216
4275
|
<span class="brand-title">TestRelic AI</span>
|
|
4217
4276
|
<span class="brand-sub">Analytics Report</span>
|
|
@@ -4246,76 +4305,76 @@ ${r?`<meta name="artifact-server-port" content="${r}">`:""}
|
|
|
4246
4305
|
</div>
|
|
4247
4306
|
<div class="filter-drawer-body" id="filter-drawer-body"></div>
|
|
4248
4307
|
</aside>
|
|
4249
|
-
<script id="report-data" type="application/json">${
|
|
4308
|
+
<script id="report-data" type="application/json">${c}</script>
|
|
4250
4309
|
${l?`<script id="artifact-manifest-data" type="application/json">${l}</script>`:""}
|
|
4251
|
-
<script>${
|
|
4310
|
+
<script>${p}</script>
|
|
4252
4311
|
</body>
|
|
4253
|
-
</html>`}function
|
|
4254
|
-
`);});}catch{}}path.join(os.tmpdir(),"testrelic-data");async function br(e,t,r,a){let n=(t-1)*r,s=[],l=0,i=readline.createInterface({input:fs$1.createReadStream(e,{encoding:"utf-8"}),crlfDelay:1/0});for await(let c of i)if(c.length!==0){if(l>=n&&s.length<r)try{s.push(JSON.parse(c));}catch{}if(l++,s.length>=r&&a!==void 0)break}let d=a??l,o=Math.max(1,Math.ceil(d/r));return {items:s,total:d,page:t,pageSize:r,totalPages:o}}var kr=/^[a-f0-9]{12}$/,ut=/^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}(-\d+)?$/,Sr=500;function k(e,t,r){e.writeHead(t,{"Content-Type":"application/json"}),e.end(JSON.stringify(r));}function Cr(e){e.setHeader("Access-Control-Allow-Origin","*"),e.setHeader("Access-Control-Allow-Methods","GET, DELETE, OPTIONS"),e.setHeader("Access-Control-Allow-Headers","Content-Type");}function he(e){try{return fs$1.existsSync(e)?JSON.parse(fs$1.readFileSync(e,"utf-8")):null}catch{return null}}function me(e){let t=0;try{let r=fs$1.readdirSync(e,{withFileTypes:!0});for(let a of r){let n=path.join(e,a.name);a.isFile()?t+=fs$1.statSync(n).size:a.isDirectory()&&(t+=me(n));}}catch{}return t}function Tr(e,t,r,a){let n=he(path.join(r,"index.json"));k(t,200,{status:"ok",reportMode:"streaming",testCount:n?.length??0,uptime:Math.floor((Date.now()-a)/1e3)});}function Rr(e,t,r){let a=he(path.join(r,"summary.json"));if(!a){k(t,404,{error:"Summary not found"});return}k(t,200,a);}function Ar(e,t,r){let a=he(path.join(r,"index.json"));if(!a){k(t,404,{error:"Test index not found"});return}let s=new URL(e.url??"/",`http://${e.headers.host}`).searchParams,l=Math.max(1,parseInt(s.get("page")??"1",10)||1),i=Math.min(Sr,Math.max(1,parseInt(s.get("pageSize")??"100",10)||100)),d=s.get("status")?.split(",").filter(Boolean)??null,o=s.get("file")??null,c=s.get("search")?.toLowerCase()??null,f=s.get("tag")?.split(",").filter(Boolean)??null,v=s.get("sort")??"file",g=s.get("order")==="desc"?-1:1,p=a;d&&d.length>0&&(p=p.filter(y=>d.includes(y.status))),o&&(p=p.filter(y=>y.filePath===o||y.filePath.startsWith(o+"/"))),c&&(p=p.filter(y=>y.title.toLowerCase().includes(c)||y.filePath.toLowerCase().includes(c))),f&&f.length>0&&(p=p.filter(y=>f.some(w=>y.tags.includes(w)))),p=[...p].sort((y,w)=>{let C=0;switch(v){case "duration":C=y.duration-w.duration;break;case "status":C=y.status.localeCompare(w.status);break;case "title":C=y.title.localeCompare(w.title);break;default:C=y.filePath.localeCompare(w.filePath);break}return C*g});let m=p.length,u=Math.max(1,Math.ceil(m/i)),h=(l-1)*i,b=p.slice(h,h+i);k(t,200,{tests:b,pagination:{page:l,pageSize:i,totalItems:m,totalPages:u},filters:{status:d,file:o,search:c,tag:f}});}function _r(e,t,r,a){if(!kr.test(a)){k(t,400,{error:"Invalid test ID format"});return}let n=path.join(r,"tests",a,"meta.json"),s=path.join(r,"tests",`${a}.json`),l=fs$1.existsSync(n)?n:fs$1.existsSync(s)?s:null;if(!l){k(t,404,{error:`Test not found: ${a}`});return}try{let i=fs$1.readFileSync(l,"utf-8");t.writeHead(200,{"Content-Type":"application/json"}),t.end(i);}catch(i){k(t,500,{error:i instanceof Error?i.message:String(i)});}}async function Ir(e,t,r,a,n){if(!kr.test(a)){k(t,400,{error:"Invalid test ID format"});return}let l=path.join(r,"tests",a,{network:"network.jsonl",console:"console.jsonl","api-calls":"api-calls.jsonl"}[n]);if(!fs$1.existsSync(l)){k(t,200,{items:[],total:0,page:1,pageSize:50,totalPages:0});return}try{let d=new URL(e.url??"/",`http://${e.headers.host}`).searchParams,o=Math.max(1,parseInt(d.get("page")??"1",10)||1),c=Math.min(Sr,Math.max(1,parseInt(d.get("pageSize")??"50",10)||50)),f,v=path.join(r,"tests",a,"meta.json");if(fs$1.existsSync(v))try{let p=JSON.parse(fs$1.readFileSync(v,"utf-8"));switch(n){case "network":f=p.networkRequestsCount;break;case "console":f=p.consoleLogsCount;break;case "api-calls":f=p.apiCallsCount;break}}catch{}let g=await br(l,o,c,f);k(t,200,g);}catch(i){k(t,500,{error:i instanceof Error?i.message:String(i)});}}function Mr(e,t,r){let a=he(path.join(r,"index.json"));if(!a){k(t,404,{error:"Test index not found"});return}let n=new Map;for(let l of a){if(l.isRetry)continue;let i=n.get(l.filePath);switch(i||(i={total:0,passed:0,failed:0,flaky:0,skipped:0,timedOut:0},n.set(l.filePath,i)),i.total++,l.status){case "passed":i.passed++;break;case "failed":i.failed++;break;case "flaky":i.flaky++;break;case "skipped":i.skipped++;break;case "timedout":i.timedOut++;break}}let s=Array.from(n.entries()).map(([l,i])=>({filePath:l,...i})).sort((l,i)=>l.filePath.localeCompare(i.filePath));k(t,200,{files:s});}function Er(e,t,r){if(!fs$1.existsSync(r)){k(t,200,{runs:[],totalSizeBytes:0});return}try{let a=[],n=0,s=fs$1.readdirSync(r,{withFileTypes:!0});for(let l of s){if(!l.isDirectory()||!ut.test(l.name))continue;let i=path.join(r,l.name),d=me(i),o=fs$1.readdirSync(i,{withFileTypes:!0}).filter(c=>c.isDirectory());a.push({folderName:l.name,totalSizeBytes:d,testCount:o.length}),n+=d;}a.sort((l,i)=>i.folderName.localeCompare(l.folderName)),k(t,200,{runs:a,totalSizeBytes:n});}catch(a){k(t,500,{error:a instanceof Error?a.message:String(a)});}}function Pr(e,t,r){try{let a=0,n=0;if(fs$1.existsSync(r)){let s=fs$1.readdirSync(r,{withFileTypes:!0});for(let l of s){if(!l.isDirectory()||!ut.test(l.name))continue;let i=path.join(r,l.name),d=me(i);fs$1.rmSync(i,{recursive:!0,force:!0}),n+=d,a++;}}k(t,200,{deletedCount:a,freedBytes:n});}catch(a){k(t,500,{error:a instanceof Error?a.message:String(a)});}}function Lr(e,t,r,a){if(!ut.test(a)){k(t,400,{error:"Invalid folder name"});return}let n=path.join(r,a);try{if(!fs$1.statSync(n).isDirectory()){k(t,404,{error:"Not found"});return}}catch{k(t,404,{error:"Not found"});return}try{let s=me(n);fs$1.rmSync(n,{recursive:!0,force:!0}),k(t,200,{deleted:a,freedBytes:s});}catch(s){k(t,500,{error:s instanceof Error?s.message:String(s)});}}function Dr(e,t,r){k(t,200,{status:"shutting_down"}),r.close();}function pt(e,t,r){if(!fs$1.existsSync(r)){k(t,404,{error:"File not found"});return}try{let a=fs$1.statSync(r).size,n=path.extname(r).toLowerCase(),s=Hn[n]??"application/octet-stream",l=zn(e.headers.range,a);if(l==="unsatisfiable"){t.writeHead(416,{"Content-Range":`bytes */${a}`,"Accept-Ranges":"bytes"}),t.end();return}if(l){t.writeHead(206,{"Content-Type":s,"Content-Length":l.end-l.start+1,"Content-Range":`bytes ${l.start}-${l.end}/${a}`,"Accept-Ranges":"bytes"}),xr(fs$1.createReadStream(r,{start:l.start,end:l.end}),t);return}t.writeHead(200,{"Content-Type":s,"Content-Length":a,"Accept-Ranges":"bytes"}),xr(fs$1.createReadStream(r),t);}catch(a){k(t,500,{error:a instanceof Error?a.message:String(a)});}}function xr(e,t){e.on("error",()=>{e.destroy(),t.destroy();}),t.on("close",()=>{e.destroy();}),e.pipe(t);}function zn(e,t){if(!e)return null;let r=/^bytes=(\d*)-(\d*)$/.exec(e.trim());if(!r)return null;let[,a,n]=r;if(a===""&&n==="")return null;let s,l;if(a===""){let i=Number(n);if(i<=0)return "unsatisfiable";s=Math.max(0,t-i),l=t-1;}else s=Number(a),l=n===""?t-1:Math.min(Number(n),t-1);return !Number.isFinite(s)||!Number.isFinite(l)?null:t===0||s>=t||s>l?"unsatisfiable":{start:s,end:l}}var Hn={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".webm":"video/webm",".mp4":"video/mp4",".json":"application/json",".html":"text/html",".css":"text/css",".js":"text/javascript",".svg":"image/svg+xml"};var jn=9323,Gn=10,Wn=1800*1e3;function oe(e,t){return new Promise((r,a)=>{let n=t?.port??jn,s=Date.now(),l,i=0,d=fs$1.existsSync(path.join(e,"artifacts"))?path.join(e,"artifacts"):fs$1.existsSync(path.join(e,"..","artifacts"))?path.join(e,"..","artifacts"):path.join(e,"artifacts");function o(){clearTimeout(l),l=setTimeout(()=>{f.close();},Wn);}let c=t?.htmlPath??null;if(!c){let g=path.dirname(e);try{let p=fs$1.readdirSync(g).find(m=>m.endsWith(".html"));p&&(c=path.join(g,p));}catch{}}let f=http.createServer((g,p)=>{if(o(),Cr(p),g.method==="OPTIONS"){p.writeHead(204),p.end();return}let m;try{m=new URL(g.url??"/",`http://${g.headers.host??"localhost"}`).pathname;}catch{k(p,400,{error:"Invalid URL"});return}if(g.method==="GET"&&(m==="/"||m==="/index.html")){if(c&&fs$1.existsSync(c)){pt(g,p,c);return}k(p,404,{error:"HTML report not found"});return}if(g.method==="GET"&&m==="/api/health"){Tr(g,p,e,s);return}if(g.method==="GET"&&m==="/api/summary"){Rr(g,p,e);return}if(g.method==="GET"&&m==="/api/tests"){Ar(g,p,e);return}if(g.method==="GET"&&m==="/api/files"){Mr(g,p,e);return}let u=m.match(/^\/api\/tests\/([a-f0-9]+)\/(network|console|api-calls)$/);if(g.method==="GET"&&u){Ir(g,p,e,u[1],u[2]);return}let h=m.match(/^\/api\/tests\/([a-f0-9]+)$/);if(g.method==="GET"&&h){_r(g,p,e,h[1]);return}if(g.method==="GET"&&m==="/api/artifacts"){Er(g,p,d);return}if(g.method==="DELETE"&&m==="/api/artifacts"){Pr(g,p,d);return}let b=m.match(/^\/api\/artifacts\/(.+)$/);if(g.method==="DELETE"&&b){Lr(g,p,d,decodeURIComponent(b[1]));return}if(g.method==="GET"&&m.startsWith("/artifacts/")){let y=decodeURIComponent(m.slice(11));if(y.includes("..")||y.includes("\0")){k(p,400,{error:"Invalid path"});return}pt(g,p,path.join(d,y));return}if(g.method==="POST"&&m==="/api/shutdown"){Dr(g,p,f);return}k(p,404,{error:"Not found"});});function v(g){let p=m=>{m.code==="EADDRINUSE"&&i<Gn?(i++,v(g+1)):a(m);};f.once("error",p),f.listen(g,"127.0.0.1",()=>{f.removeListener("error",p);let m=f.address();if(!m||typeof m=="string"){a(new Error("Failed to get server address"));return}o(),r({port:m.port,dispose:()=>new Promise(u=>{clearTimeout(l),f.close(()=>u());})});});}v(n);})}async function Nr(e){let t=await oe(e);return {port:t.port,dispose:t.dispose}}function Yn(e,t,r){let a=JSON.stringify(e),n=r?JSON.stringify(r):null;return vr(a,t,n)}async function gt(e,t,r){try{let a=null,n=null,s=t.reportMode==="streaming"||t.reportMode==="auto"&&e.timeline.length===0&&e.summary.total>=t.streamingThreshold,l,i=t.htmlReportPath,d=path.dirname(i);fs$1.mkdirSync(d,{recursive:!0});let o="",c="[]",f=null;if(s){o=JSON.stringify({...e.summary,testRunId:e.testRunId,startedAt:e.startedAt,completedAt:e.completedAt,totalDuration:e.totalDuration,ci:e.ci,metadata:e.metadata,shardRunIds:e.shardRunIds});let g=path.dirname(t.outputPath),p=path.join(g,".testrelic-report");try{let m=path.join(p,"index-compact.json"),u=path.join(p,"index.json");fs$1.existsSync(m)?c=fs$1.readFileSync(m,"utf-8"):fs$1.existsSync(u)&&(c=fs$1.readFileSync(u,"utf-8"));}catch{}f=r?JSON.stringify(r):null,l=ot(o,c,null,f);}else l=Yn(e,null,r);let v=i+".tmp";if(fs$1.writeFileSync(v,l,"utf-8"),fs$1.renameSync(v,i),s){if(e.ci===null){let g=path.dirname(t.outputPath),p=path.join(g,".testrelic-report"),m=path.resolve(i);try{if(await Zn(),a=await Qn(p),!a){n=await oe(p,{htmlPath:m}),a=n.port;let u=setInterval(()=>{},6e4),h=()=>{clearInterval(u),n?.dispose();};process.on("SIGINT",h),process.on("SIGTERM",h),setTimeout(h,1800*1e3).unref();}if(a){process.stderr.write(`
|
|
4255
|
-
Report server: http://127.0.0.1:${
|
|
4256
|
-
`);try{let
|
|
4257
|
-
`);}}var ye=9323,zr=10;async function Xn(){for(let e=ye;e<ye+zr;e++)try{let t=new AbortController,r=setTimeout(()=>t.abort(),500),a=await fetch(`http://127.0.0.1:${e}/api/health`,{signal:t.signal});if(clearTimeout(r),a.ok)return e}catch{}return null}async function Zn(){for(let e=ye;e<ye+zr;e++)try{let t=new AbortController,r=setTimeout(()=>t.abort(),1e3);await fetch(`http://127.0.0.1:${e}/api/shutdown`,{method:"POST",signal:t.signal}),clearTimeout(r);}catch{}await new Promise(e=>setTimeout(e,300));}async function Qn(e){let r=[path.join(__dirname,"cli.cjs"),path.join(__dirname,"cli.js"),path.join(__dirname,"..","dist","cli.cjs"),path.join(__dirname,"..","dist","cli.js")].find(a=>fs$1.existsSync(a));if(!r){let a=await oe(e);return process.on("exit",()=>{a?.dispose();}),a.port}return new Promise(a=>{let n=child_process.spawn(process.execPath,[r,"serve",e],{detached:true,stdio:["ignore","ignore","pipe"],env:{...process.env}}),s="",l=false,i=setTimeout(()=>{l||(l=true,n.stderr?.removeAllListeners(),Xn().then(a));},5e3);n.stderr?.on("data",d=>{s+=d.toString();let o=s.match(/127\.0\.0\.1:(\d+)/);o&&!l&&(l=true,clearTimeout(i),n.stderr?.removeAllListeners(),n.unref(),a(Number(o[1])));}),n.on("error",()=>{l||(l=true,clearTimeout(i),a(null));}),n.on("exit",()=>{l||(l=true,clearTimeout(i),a(null));}),n.unref();})}var Hr=Buffer.from([137,80,78,71,13,10,26,10]),es=16,ts=20,xe=24;function qr(e){if(e.length<xe||!e.subarray(0,Hr.length).equals(Hr))return null;let t=e.readUInt32BE(es),r=e.readUInt32BE(ts);return t===0||r===0?null:{width:t,height:r}}var rs=/(\d+) pixels \(ratio [\d.]+ of all image pixels\) are different/,$r=/Expected an image (\d+)px by (\d+)px, received (\d+)px by (\d+)px/;function Vr(e){return e?$r.test(e):false}var as=/^\s*Snapshot:\s*(.+?)\s*$/m;function jr(e){if(!e)return {};let t={},r=rs.exec(e);if(r){let s=Number.parseInt(r[1],10);Number.isFinite(s)&&(t.diffPixels=s);}let a=$r.exec(e);if(a){let[,s,l,i,d]=a,o=[s,l,i,d].map(c=>Number.parseInt(c,10));o.every(c=>Number.isFinite(c))&&(t.expectedWidth=o[0],t.expectedHeight=o[1],t.actualWidth=o[2],t.actualHeight=o[3]);}let n=as.exec(e);return n&&(t.snapshotName=n[1]),t}function Gr(e,t){if(e===void 0||!t)return;let r=t.width*t.height;if(!(r<=0))return e/r}var cs=20,ht=0,mt=[];async function le(e,t){ht>=cs&&await new Promise(r=>mt.push(r)),ht++;try{return await promises.copyFile(e,t),!0}catch{return false}finally{ht--,mt.length>0&&mt.shift()();}}var H=[];async function Jr(){H.length!==0&&(await Promise.allSettled(H),H.length=0);}function Yr(e){let t=new Date,r=s=>String(s).padStart(2,"0"),a=`${t.getFullYear()}-${r(t.getMonth()+1)}-${r(t.getDate())}T${r(t.getHours())}-${r(t.getMinutes())}-${r(t.getSeconds())}`;if(!fs$1.existsSync(path.join(e,a)))return a;let n=1;for(;fs$1.existsSync(path.join(e,`${a}-${n}`));)n++;return `${a}-${n}`}function vt(e){let t=e.replace(/[^a-zA-Z0-9\-_ ]/g,"-").replace(/\s+/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");return t.length>100&&(t=t.substring(0,100).replace(/-+$/,"")),t||"unnamed-test"}var us=8;function Xr(e,t,r){let a=vt(e),n=r?vt(r).substring(0,us):"";return n&&(a+=`--${n}`),t>0&&(a+=`--retry-${t}`),a}function Zr(e,t,r,a,n,s){let l=e.find(p=>p.name==="screenshot"&&p.path),i=e.find(p=>p.name==="video"&&p.path),d=e.find(p=>p.name==="trace"&&p.path);if(!l&&!i&&!d)return null;let o=Xr(t,r,s),c=n?["artifacts",n,o]:["artifacts",o],f=path.join(a,...c),v=c,g={};try{fs$1.mkdirSync(f,{recursive:!0});}catch{return null}if(l?.path&&fs$1.existsSync(l.path)){let m=`screenshot${path.extname(l.path)||".png"}`,u=path.join(f,m);H.push(le(l.path,u).then(()=>{})),g.screenshot=`${v.join("/")}/${m}`;}if(i?.path&&fs$1.existsSync(i.path)){let m=`video${path.extname(i.path)||".webm"}`,u=path.join(f,m);H.push(le(i.path,u).then(()=>{})),g.video=`${v.join("/")}/${m}`;}if(d?.path&&fs$1.existsSync(d.path)){let m=`trace${path.extname(d.path)||".zip"}`,u=path.join(f,m);H.push(le(d.path,u).then(()=>{})),g.trace=`${v.join("/")}/${m}`;}return !g.screenshot&&!g.video&&!g.trace?null:g}var bt="visual",ps=6;function fs(e){let t=crypto.createHash("sha256").update(e).digest("hex").substring(0,ps);return `${vt(e)}--${t}`}function Wr(e){let t=null;try{t=fs$1.openSync(e,"r");let r=Buffer.alloc(xe),a=fs$1.readSync(t,r,0,xe,0);return qr(r.subarray(0,a))}catch{return null}finally{if(t!==null)try{fs$1.closeSync(t);}catch{}}}var Kr=[{key:"expectedPath",dest:"baseline",field:"baseline"},{key:"actualPath",dest:"actual",field:"actual"},{key:"diffPath",dest:"diff",field:"diff"},{key:"previousPath",dest:"previous",field:"previous"}],gs=[{key:"baselineDomPath",dest:"baseline.dom.json",field:"baselineDom"},{key:"actualDomPath",dest:"actual.dom.json",field:"actualDom"}];function hs(e,t,r,a){let n=fs(e.name),s=path.join(t,n),l=Kr.some(p=>e[p.key]);if(l||e.dom)try{fs$1.mkdirSync(s,{recursive:!0});}catch{return null}let i={},d=false;for(let p of Kr){let m=e[p.key];if(!m||!fs$1.existsSync(m))continue;let u=path.extname(m)||".png",h=`${p.dest}${u}`;H.push(le(m,path.join(s,h)).then(()=>{})),i[p.field]=`${r}/${bt}/${n}/${h}`,d=true;}let o=e.dom;if(o)for(let p of gs){let m=o[p.key];!m||!fs$1.existsSync(m)||(H.push(le(m,path.join(s,p.dest)).then(()=>{})),i[p.field]=`${r}/${bt}/${n}/${p.dest}`);}if(!d&&l)return null;let c=e.expectedPath?Wr(e.expectedPath):e.actualPath?Wr(e.actualPath):null,f=Gr(e.diffPixels,c),v=e.committedPath??e.expectedPath,g=v?path.relative(a,v).replace(/\\/g,"/"):void 0;return {name:e.name,status:e.status,source:e.source,...i,...g?{baselinePath:g}:{},...c?{width:c.width,height:c.height}:{},...e.actualWidth!==void 0?{actualWidth:e.actualWidth}:{},...e.actualHeight!==void 0?{actualHeight:e.actualHeight}:{},...e.diffPixels!==void 0?{diffPixels:e.diffPixels}:{},...f!==void 0?{diffPixelRatio:f}:{},...o?{domChanges:o.changes,domChangeCount:o.total,domRootCauses:o.rootCauses,domTruncated:o.truncated,domCaptureBox:o.captureBox}:{}}}function Qr(e,t,r,a,n,s,l=process.cwd()){if(e.length===0)return null;let i=Xr(t,r,s),d=n?["artifacts",n,i]:["artifacts",i],o=path.join(a,...d,bt),c=d.join("/");try{fs$1.mkdirSync(o,{recursive:!0});}catch{return null}let f=[];for(let v of e){let g=hs(v,o,c,l);g&&f.push(g);}return f.length>0?f:null}var ea="testrelic-visual-dom";var ms="testrelic-visual",vs=/^(.+)-(expected|actual|diff|previous)(\.[A-Za-z0-9]+)$/;function bs(e){let t=new Map;for(let r of e)if(!(r.name!==ms||!r.body))try{let a=JSON.parse(r.body.toString("utf-8"));if(!Array.isArray(a))continue;for(let n of a){let s=xs(n);s&&t.set(s.stem,s);}}catch{}return t}var ys=["passed","failed","new","updated"];function xs(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.stem!="string"||!t.stem||typeof t.name!="string"||!t.name||typeof t.status!="string"||!ys.includes(t.status)?null:{stem:t.stem,name:t.name,status:t.status,...typeof t.committedPath=="string"&&t.committedPath?{committedPath:t.committedPath}:{}}}function ws(e){let t=new Map;for(let r of e)if(!(r.name!==ea||!r.body))try{let a=JSON.parse(r.body.toString("utf-8"));if(!Array.isArray(a))continue;for(let n of a){if(typeof n!="object"||n===null)continue;let s=n;typeof s.stem!="string"||!Array.isArray(s.changes)||t.set(s.stem,n);}}catch{}return t}function ks(e){let t=new Map;for(let r of e){if(!r.path)continue;let a=vs.exec(r.name);if(!a)continue;let[,n,s]=a,l=t.get(n)??{};l[s]=r.path,t.set(n,l);}return t}function Ss(e){return !!(e.actual&&(e.expected||e.diff))}function Cs(e,t,r){return e.diff||Vr(r)?"failed":t?"updated":"new"}function Ts(e,t){if(e.length===0)return null;if(e.length===1)return e[0];if(!t)return null;let r=t.replace(/\.[A-Za-z0-9]+$/,""),a=e.filter(n=>n===r||n.endsWith(`/${r}`));return a.length===1?a[0]:null}function aa(e,t={}){if(e.length===0)return [];let r=bs(e),a=ws(e),n=ks(e);if(n.size===0&&r.size===0)return [];let s=t.updatingSnapshots===true,l=[];for(let[i,d]of n){let o=r.get(i);!o&&!Ss(d)||l.push({name:o?.name??i,status:o?.status??Cs(d,s,t.failureMessage),source:o?"toMatchVisualBaseline":"toHaveScreenshot",...d.expected?{expectedPath:d.expected}:{},...o?.committedPath?{committedPath:o.committedPath}:{},...d.actual?{actualPath:d.actual}:{},...d.diff?{diffPath:d.diff}:{},...d.previous?{previousPath:d.previous}:{},...a.has(i)?{dom:a.get(i)}:{}});}for(let[i,d]of r)n.has(i)||l.push({name:d.name,status:d.status,source:"toMatchVisualBaseline",...d.committedPath?{committedPath:d.committedPath}:{},...a.has(i)?{dom:a.get(i)}:{}});return Rs(l,n,t.failureMessage)}function Rs(e,t,r){let a=jr(r);if(a.diffPixels===void 0&&a.actualWidth===void 0)return [...e];let n=e.filter(l=>l.status==="failed"&&ta(l)).map(l=>ra(l,t)),s=Ts(n,a.snapshotName);return s===null?[...e]:e.map(l=>ta(l)&&ra(l,t)===s?{...l,...a.diffPixels!==void 0?{diffPixels:a.diffPixels}:{},...a.actualWidth!==void 0?{actualWidth:a.actualWidth}:{},...a.actualHeight!==void 0?{actualHeight:a.actualHeight}:{}}:l)}function ta(e){return !!(e.expectedPath||e.actualPath||e.diffPath||e.previousPath)}function ra(e,t){if(t.has(e.name))return e.name;for(let[r,a]of t)if(a.actual===e.actualPath&&a.expected===e.expectedPath&&a.diff===e.diffPath)return r;return e.name}var As=new RegExp("[\x1B\x9B][[\\]()#;?]*(?:\\d{1,4}(?:;\\d{0,4})*)?[0-9A-PR-TZcf-nqry=><]","g");function ke(e){return !e||e.indexOf("\x1B")===-1&&e.indexOf("\x9B")===-1?e:e.replace(As,"")}function na(e){return e==null?null:ke(e)}var _s=/^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}(-\d+)?$/,Is="1.0",xt="visual";function la(e){let t=path.extname(e).toLowerCase();return [".png",".jpg",".jpeg",".gif",".bmp",".webp"].includes(t)?"screenshot":[".webm",".mp4",".avi",".mov"].includes(t)?"video":t===".zip"&&path.basename(e,t)==="trace"?"trace":"other"}function Ms(e){if(e.endsWith(".dom.json"))return "dom";let t=path.basename(e,path.extname(e));return t==="baseline"?"baseline":t==="diff"?"diff":la(e)}function Es(e,t,r){let a=[];try{for(let n of fs$1.readdirSync(e,{withFileTypes:!0})){if(!n.isFile())continue;let s=fs$1.statSync(path.join(e,n.name));a.push({name:`${xt}/${r}/${n.name}`,type:Ms(n.name),relativePath:`${t}/${xt}/${r}/${n.name}`,sizeBytes:s.size});}}catch{}return a}function da(e,t,r){let a=[],n=`artifacts/${t}/${r}`;try{let s=fs$1.readdirSync(e,{withFileTypes:!0});for(let l of s){if(l.isDirectory()&&l.name===xt){let o=path.join(e,l.name);for(let c of fs$1.readdirSync(o,{withFileTypes:!0}))c.isDirectory()&&a.push(...Es(path.join(o,c.name),n,c.name));continue}if(!l.isFile())continue;let i=path.join(e,l.name),d=fs$1.statSync(i);a.push({name:l.name,type:la(l.name),relativePath:`${n}/${l.name}`,sizeBytes:d.size});}}catch{}return {testName:r,files:a}}function Ps(e,t){let r=path.join(e,t),a=[],n=0;try{let l=fs$1.readdirSync(r,{withFileTypes:!0});for(let i of l){if(!i.isDirectory())continue;let d=da(path.join(r,i.name),t,i.name);a.push(d);for(let o of d.files)n+=o.sizeBytes;}}catch{}let s=t.replace(/^(\d{4}-\d{2}-\d{2})T(\d{2})-(\d{2})-(\d{2})/,"$1T$2:$3:$4").replace(/-\d+$/,"");return a.sort((l,i)=>l.testName.localeCompare(i.testName)),{folderName:t,timestamp:s,totalSizeBytes:n,testCount:a.length,tests:a,isCurrentRun:false}}function ca(e,t){let r=path.join(e,"artifacts"),a=[],n=[],s=0;try{let i=fs$1.readdirSync(r,{withFileTypes:!0});for(let d of i)if(d.isDirectory())if(_s.test(d.name)){let o=Ps(r,d.name);a.push({...o,isCurrentRun:d.name===t});}else {let o=da(path.join(r,d.name),d.name,d.name);n.push(o);for(let c of o.files)s+=c.sizeBytes;}}catch{}a.sort((i,d)=>d.timestamp.localeCompare(i.timestamp)),n.length>0&&(n.sort((i,d)=>i.testName.localeCompare(d.testName)),a.push({folderName:"__legacy__",timestamp:"1970-01-01T00:00:00",totalSizeBytes:s,testCount:n.length,tests:n,isCurrentRun:false}));let l=a.reduce((i,d)=>i+d.totalSizeBytes,0);return {schemaVersion:Is,generatedAt:new Date().toISOString(),artifactBaseDir:"artifacts",totalSizeBytes:l,runs:a,serverPort:null}}var Os=256;function Us(e){let t=path.resolve(e);for(let r=0;r<Os;r++){if(fs$1.existsSync(path.join(t,".git")))return t;let a=path.dirname(t);if(a===t)return null;t=a;}return null}function fa(e){try{let t=Us(e);if(!t)return;let r=path.join(t,".gitignore"),a=path.relative(t,e).replace(/\\/g,"/"),n=a.endsWith("/")?a:`${a}/`;if(fs$1.existsSync(r)&&fs$1.readFileSync(r,"utf-8").split(`
|
|
4258
|
-
`).map(
|
|
4312
|
+
</html>`}function ct(e){try{let t=process.platform,r,a;t==="darwin"?(r="open",a=[e]):t==="win32"?(r="cmd",a=["/c","start","",e]):(r="xdg-open",a=[e]),child_process.execFile(r,a,s=>{s&&process.stderr.write(`[testrelic] Failed to open browser: ${s.message}
|
|
4313
|
+
`);});}catch{}}path.join(os$1.tmpdir(),"testrelic-data");async function wr(e,t,r,a){let s=(t-1)*r,n=[],o=0,i=readline.createInterface({input:fs.createReadStream(e,{encoding:"utf-8"}),crlfDelay:1/0});for await(let c of i)if(c.length!==0){if(o>=s&&n.length<r)try{n.push(JSON.parse(c));}catch{}if(o++,n.length>=r&&a!==void 0)break}let l=a??o,d=Math.max(1,Math.ceil(l/r));return {items:n,total:l,page:t,pageSize:r,totalPages:d}}var Tr=/^[a-f0-9]{12}$/,ft=/^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}(-\d+)?$/,Rr=500;function S(e,t,r){e.writeHead(t,{"Content-Type":"application/json"}),e.end(JSON.stringify(r));}function Ar(e){e.setHeader("Access-Control-Allow-Origin","*"),e.setHeader("Access-Control-Allow-Methods","GET, DELETE, OPTIONS"),e.setHeader("Access-Control-Allow-Headers","Content-Type");}function he(e){try{return fs.existsSync(e)?JSON.parse(fs.readFileSync(e,"utf-8")):null}catch{return null}}function me(e){let t=0;try{let r=fs.readdirSync(e,{withFileTypes:!0});for(let a of r){let s=path.join(e,a.name);a.isFile()?t+=fs.statSync(s).size:a.isDirectory()&&(t+=me(s));}}catch{}return t}function _r(e,t,r,a){let s=he(path.join(r,"index.json"));S(t,200,{status:"ok",reportMode:"streaming",testCount:s?.length??0,uptime:Math.floor((Date.now()-a)/1e3)});}function Ir(e,t,r){let a=he(path.join(r,"summary.json"));if(!a){S(t,404,{error:"Summary not found"});return}S(t,200,a);}function Mr(e,t,r){let a=he(path.join(r,"index.json"));if(!a){S(t,404,{error:"Test index not found"});return}let n=new URL(e.url??"/",`http://${e.headers.host}`).searchParams,o=Math.max(1,parseInt(n.get("page")??"1",10)||1),i=Math.min(Rr,Math.max(1,parseInt(n.get("pageSize")??"100",10)||100)),l=n.get("status")?.split(",").filter(Boolean)??null,d=n.get("file")??null,c=n.get("search")?.toLowerCase()??null,p=n.get("tag")?.split(",").filter(Boolean)??null,v=n.get("sort")??"file",g=n.get("order")==="desc"?-1:1,u=a;l&&l.length>0&&(u=u.filter(b=>l.includes(b.status))),d&&(u=u.filter(b=>b.filePath===d||b.filePath.startsWith(d+"/"))),c&&(u=u.filter(b=>b.title.toLowerCase().includes(c)||b.filePath.toLowerCase().includes(c))),p&&p.length>0&&(u=u.filter(b=>p.some(x=>b.tags.includes(x)))),u=[...u].sort((b,x)=>{let w=0;switch(v){case "duration":w=b.duration-x.duration;break;case "status":w=b.status.localeCompare(x.status);break;case "title":w=b.title.localeCompare(x.title);break;default:w=b.filePath.localeCompare(x.filePath);break}return w*g});let m=u.length,h=Math.max(1,Math.ceil(m/i)),y=(o-1)*i,f=u.slice(y,y+i);S(t,200,{tests:f,pagination:{page:o,pageSize:i,totalItems:m,totalPages:h},filters:{status:l,file:d,search:c,tag:p}});}function Er(e,t,r,a){if(!Tr.test(a)){S(t,400,{error:"Invalid test ID format"});return}let s=path.join(r,"tests",a,"meta.json"),n=path.join(r,"tests",`${a}.json`),o=fs.existsSync(s)?s:fs.existsSync(n)?n:null;if(!o){S(t,404,{error:`Test not found: ${a}`});return}try{let i=fs.readFileSync(o,"utf-8");t.writeHead(200,{"Content-Type":"application/json"}),t.end(i);}catch(i){S(t,500,{error:i instanceof Error?i.message:String(i)});}}async function Pr(e,t,r,a,s){if(!Tr.test(a)){S(t,400,{error:"Invalid test ID format"});return}let o=path.join(r,"tests",a,{network:"network.jsonl",console:"console.jsonl","api-calls":"api-calls.jsonl"}[s]);if(!fs.existsSync(o)){S(t,200,{items:[],total:0,page:1,pageSize:50,totalPages:0});return}try{let l=new URL(e.url??"/",`http://${e.headers.host}`).searchParams,d=Math.max(1,parseInt(l.get("page")??"1",10)||1),c=Math.min(Rr,Math.max(1,parseInt(l.get("pageSize")??"50",10)||50)),p,v=path.join(r,"tests",a,"meta.json");if(fs.existsSync(v))try{let u=JSON.parse(fs.readFileSync(v,"utf-8"));switch(s){case "network":p=u.networkRequestsCount;break;case "console":p=u.consoleLogsCount;break;case "api-calls":p=u.apiCallsCount;break}}catch{}let g=await wr(o,d,c,p);S(t,200,g);}catch(i){S(t,500,{error:i instanceof Error?i.message:String(i)});}}function Dr(e,t,r){let a=he(path.join(r,"index.json"));if(!a){S(t,404,{error:"Test index not found"});return}let s=new Map;for(let o of a){if(o.isRetry)continue;let i=s.get(o.filePath);switch(i||(i={total:0,passed:0,failed:0,flaky:0,skipped:0,timedOut:0},s.set(o.filePath,i)),i.total++,o.status){case "passed":i.passed++;break;case "failed":i.failed++;break;case "flaky":i.flaky++;break;case "skipped":i.skipped++;break;case "timedout":i.timedOut++;break}}let n=Array.from(s.entries()).map(([o,i])=>({filePath:o,...i})).sort((o,i)=>o.filePath.localeCompare(i.filePath));S(t,200,{files:n});}function Lr(e,t,r){if(!fs.existsSync(r)){S(t,200,{runs:[],totalSizeBytes:0});return}try{let a=[],s=0,n=fs.readdirSync(r,{withFileTypes:!0});for(let o of n){if(!o.isDirectory()||!ft.test(o.name))continue;let i=path.join(r,o.name),l=me(i),d=fs.readdirSync(i,{withFileTypes:!0}).filter(c=>c.isDirectory());a.push({folderName:o.name,totalSizeBytes:l,testCount:d.length}),s+=l;}a.sort((o,i)=>i.folderName.localeCompare(o.folderName)),S(t,200,{runs:a,totalSizeBytes:s});}catch(a){S(t,500,{error:a instanceof Error?a.message:String(a)});}}function Nr(e,t,r){try{let a=0,s=0;if(fs.existsSync(r)){let n=fs.readdirSync(r,{withFileTypes:!0});for(let o of n){if(!o.isDirectory()||!ft.test(o.name))continue;let i=path.join(r,o.name),l=me(i);fs.rmSync(i,{recursive:!0,force:!0}),s+=l,a++;}}S(t,200,{deletedCount:a,freedBytes:s});}catch(a){S(t,500,{error:a instanceof Error?a.message:String(a)});}}function Fr(e,t,r,a){if(!ft.test(a)){S(t,400,{error:"Invalid folder name"});return}let s=path.join(r,a);try{if(!fs.statSync(s).isDirectory()){S(t,404,{error:"Not found"});return}}catch{S(t,404,{error:"Not found"});return}try{let n=me(s);fs.rmSync(s,{recursive:!0,force:!0}),S(t,200,{deleted:a,freedBytes:n});}catch(n){S(t,500,{error:n instanceof Error?n.message:String(n)});}}function Br(e,t,r){S(t,200,{status:"shutting_down"}),r.close();}function gt(e,t,r){if(!fs.existsSync(r)){S(t,404,{error:"File not found"});return}try{let a=fs.statSync(r).size,s=path.extname(r).toLowerCase(),n=js[s]??"application/octet-stream",o=$s(e.headers.range,a);if(o==="unsatisfiable"){t.writeHead(416,{"Content-Range":`bytes */${a}`,"Accept-Ranges":"bytes"}),t.end();return}if(o){t.writeHead(206,{"Content-Type":n,"Content-Length":o.end-o.start+1,"Content-Range":`bytes ${o.start}-${o.end}/${a}`,"Accept-Ranges":"bytes"}),Sr(fs.createReadStream(r,{start:o.start,end:o.end}),t);return}t.writeHead(200,{"Content-Type":n,"Content-Length":a,"Accept-Ranges":"bytes"}),Sr(fs.createReadStream(r),t);}catch(a){S(t,500,{error:a instanceof Error?a.message:String(a)});}}function Sr(e,t){e.on("error",()=>{e.destroy(),t.destroy();}),t.on("close",()=>{e.destroy();}),e.pipe(t);}function $s(e,t){if(!e)return null;let r=/^bytes=(\d*)-(\d*)$/.exec(e.trim());if(!r)return null;let[,a,s]=r;if(a===""&&s==="")return null;let n,o;if(a===""){let i=Number(s);if(i<=0)return "unsatisfiable";n=Math.max(0,t-i),o=t-1;}else n=Number(a),o=s===""?t-1:Math.min(Number(s),t-1);return !Number.isFinite(n)||!Number.isFinite(o)?null:t===0||n>=t||n>o?"unsatisfiable":{start:n,end:o}}var js={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".webm":"video/webm",".mp4":"video/mp4",".json":"application/json",".html":"text/html",".css":"text/css",".js":"text/javascript",".svg":"image/svg+xml"};var Js=9323,Ys=10,Xs=1800*1e3;function oe(e,t){return new Promise((r,a)=>{let s=t?.port??Js,n=Date.now(),o,i=0,l=fs.existsSync(path.join(e,"artifacts"))?path.join(e,"artifacts"):fs.existsSync(path.join(e,"..","artifacts"))?path.join(e,"..","artifacts"):path.join(e,"artifacts");function d(){clearTimeout(o),o=setTimeout(()=>{p.close();},Xs);}let c=t?.htmlPath??null;if(!c){let g=path.dirname(e);try{let u=fs.readdirSync(g).find(m=>m.endsWith(".html"));u&&(c=path.join(g,u));}catch{}}let p=http.createServer((g,u)=>{if(d(),Ar(u),g.method==="OPTIONS"){u.writeHead(204),u.end();return}let m;try{m=new URL(g.url??"/",`http://${g.headers.host??"localhost"}`).pathname;}catch{S(u,400,{error:"Invalid URL"});return}if(g.method==="GET"&&(m==="/"||m==="/index.html")){if(c&&fs.existsSync(c)){gt(g,u,c);return}S(u,404,{error:"HTML report not found"});return}if(g.method==="GET"&&m==="/api/health"){_r(g,u,e,n);return}if(g.method==="GET"&&m==="/api/summary"){Ir(g,u,e);return}if(g.method==="GET"&&m==="/api/tests"){Mr(g,u,e);return}if(g.method==="GET"&&m==="/api/files"){Dr(g,u,e);return}let h=m.match(/^\/api\/tests\/([a-f0-9]+)\/(network|console|api-calls)$/);if(g.method==="GET"&&h){Pr(g,u,e,h[1],h[2]);return}let y=m.match(/^\/api\/tests\/([a-f0-9]+)$/);if(g.method==="GET"&&y){Er(g,u,e,y[1]);return}if(g.method==="GET"&&m==="/api/artifacts"){Lr(g,u,l);return}if(g.method==="DELETE"&&m==="/api/artifacts"){Nr(g,u,l);return}let f=m.match(/^\/api\/artifacts\/(.+)$/);if(g.method==="DELETE"&&f){Fr(g,u,l,decodeURIComponent(f[1]));return}if(g.method==="GET"&&m.startsWith("/artifacts/")){let b=decodeURIComponent(m.slice(11));if(b.includes("..")||b.includes("\0")){S(u,400,{error:"Invalid path"});return}gt(g,u,path.join(l,b));return}if(g.method==="POST"&&m==="/api/shutdown"){Br(g,u,p);return}S(u,404,{error:"Not found"});});function v(g){let u=m=>{m.code==="EADDRINUSE"&&i<Ys?(i++,v(g+1)):a(m);};p.once("error",u),p.listen(g,"127.0.0.1",()=>{p.removeListener("error",u);let m=p.address();if(!m||typeof m=="string"){a(new Error("Failed to get server address"));return}d(),r({port:m.port,dispose:()=>new Promise(h=>{clearTimeout(o),p.close(()=>h());})});});}v(s);})}async function Or(e){let t=await oe(e);return {port:t.port,dispose:t.dispose}}function en(e,t,r,a){let s=JSON.stringify(a?{...e,presentedSummary:a}:e),n=r?JSON.stringify(r):null;return xr(s,t,n)}async function mt(e,t,r,a){try{let s=null,n=null,o=t.reportMode==="streaming"||t.reportMode==="auto"&&e.timeline.length===0&&e.summary.total>=t.streamingThreshold,i,l=t.htmlReportPath,d=path.dirname(l);fs.mkdirSync(d,{recursive:!0});let c="",p="[]",v=null,g=a?JSON.stringify(a):null;if(o){c=JSON.stringify({...e.summary,testRunId:e.testRunId,startedAt:e.startedAt,completedAt:e.completedAt,totalDuration:e.totalDuration,ci:e.ci,metadata:e.metadata,shardRunIds:e.shardRunIds});let m=path.dirname(t.outputPath),h=path.join(m,".testrelic-report");try{let y=path.join(h,"index-compact.json"),f=path.join(h,"index.json");fs.existsSync(y)?p=fs.readFileSync(y,"utf-8"):fs.existsSync(f)&&(p=fs.readFileSync(f,"utf-8"));}catch{}v=r?JSON.stringify(r):null,i=dt(c,p,null,v,g);}else i=en(e,null,r,a);let u=l+".tmp";if(fs.writeFileSync(u,i,"utf-8"),fs.renameSync(u,l),o){if(e.ci===null){let m=path.dirname(t.outputPath),h=path.join(m,".testrelic-report"),y=path.resolve(l);try{if(await rn(),s=await an(h),!s){n=await oe(h,{htmlPath:y}),s=n.port;let f=setInterval(()=>{},6e4),b=()=>{clearInterval(f),n?.dispose();};process.on("SIGINT",b),process.on("SIGTERM",b),setTimeout(b,1800*1e3).unref();}if(s){process.stderr.write(`
|
|
4314
|
+
Report server: http://127.0.0.1:${s}
|
|
4315
|
+
`);try{let f=dt(c,p,s,v,g),b=l+".tmp";fs.writeFileSync(b,f,"utf-8"),fs.renameSync(b,l);}catch{}}}catch{}}}else if(t.openReport&&e.ci===null&&t.includeArtifacts){let m=path.dirname(t.outputPath),h=path.join(m,"artifacts");if(fs.existsSync(h))try{let y=await Or(h);s=y.port,process.on("exit",()=>{y.dispose();});}catch{}}if(t.openReport&&e.ci===null)if(o&&s)ct(`http://127.0.0.1:${s}`);else {let m=path.resolve(l);ct(m);}}catch(s){process.stderr.write(`[testrelic] Failed to write HTML report: ${s instanceof Error?s.message:String(s)}
|
|
4316
|
+
`);}}var ye=9323,Vr=10;async function tn(){for(let e=ye;e<ye+Vr;e++)try{let t=new AbortController,r=setTimeout(()=>t.abort(),500),a=await fetch(`http://127.0.0.1:${e}/api/health`,{signal:t.signal});if(clearTimeout(r),a.ok)return e}catch{}return null}async function rn(){for(let e=ye;e<ye+Vr;e++)try{let t=new AbortController,r=setTimeout(()=>t.abort(),1e3);await fetch(`http://127.0.0.1:${e}/api/shutdown`,{method:"POST",signal:t.signal}),clearTimeout(r);}catch{}await new Promise(e=>setTimeout(e,300));}async function an(e){let r=[path.join(__dirname,"cli.cjs"),path.join(__dirname,"cli.js"),path.join(__dirname,"..","dist","cli.cjs"),path.join(__dirname,"..","dist","cli.js")].find(a=>fs.existsSync(a));if(!r){let a=await oe(e);return process.on("exit",()=>{a?.dispose();}),a.port}return new Promise(a=>{let s=child_process.spawn(process.execPath,[r,"serve",e],{detached:true,stdio:["ignore","ignore","pipe"],env:{...process.env}}),n="",o=false,i=setTimeout(()=>{o||(o=true,s.stderr?.removeAllListeners(),tn().then(a));},5e3);s.stderr?.on("data",l=>{n+=l.toString();let d=n.match(/127\.0\.0\.1:(\d+)/);d&&!o&&(o=true,clearTimeout(i),s.stderr?.removeAllListeners(),s.unref(),a(Number(d[1])));}),s.on("error",()=>{o||(o=true,clearTimeout(i),a(null));}),s.on("exit",()=>{o||(o=true,clearTimeout(i),a(null));}),s.unref();})}var $r=Buffer.from([137,80,78,71,13,10,26,10]),sn=16,nn=20,xe=24;function jr(e){if(e.length<xe||!e.subarray(0,$r.length).equals($r))return null;let t=e.readUInt32BE(sn),r=e.readUInt32BE(nn);return t===0||r===0?null:{width:t,height:r}}var on=/(\d+) pixels \(ratio [\d.]+ of all image pixels\) are different/,Gr=/Expected an image (\d+)px by (\d+)px, received (\d+)px by (\d+)px/;function Wr(e){return e?Gr.test(e):false}var ln=/^\s*Snapshot:\s*(.+?)\s*$/m;function Kr(e){if(!e)return {};let t={},r=on.exec(e);if(r){let n=Number.parseInt(r[1],10);Number.isFinite(n)&&(t.diffPixels=n);}let a=Gr.exec(e);if(a){let[,n,o,i,l]=a,d=[n,o,i,l].map(c=>Number.parseInt(c,10));d.every(c=>Number.isFinite(c))&&(t.expectedWidth=d[0],t.expectedHeight=d[1],t.actualWidth=d[2],t.actualHeight=d[3]);}let s=ln.exec(e);return s&&(t.snapshotName=s[1]),t}function Jr(e,t){if(e===void 0||!t)return;let r=t.width*t.height;if(!(r<=0))return e/r}var hn=20,vt=0,bt=[];async function le(e,t){vt>=hn&&await new Promise(r=>bt.push(r)),vt++;try{return await promises.copyFile(e,t),!0}catch{return false}finally{vt--,bt.length>0&&bt.shift()();}}var H=[];async function Zr(){H.length!==0&&(await Promise.allSettled(H),H.length=0);}function Qr(e){let t=new Date,r=n=>String(n).padStart(2,"0"),a=`${t.getFullYear()}-${r(t.getMonth()+1)}-${r(t.getDate())}T${r(t.getHours())}-${r(t.getMinutes())}-${r(t.getSeconds())}`;if(!fs.existsSync(path.join(e,a)))return a;let s=1;for(;fs.existsSync(path.join(e,`${a}-${s}`));)s++;return `${a}-${s}`}function yt(e){let t=e.replace(/[^a-zA-Z0-9\-_ ]/g,"-").replace(/\s+/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");return t.length>100&&(t=t.substring(0,100).replace(/-+$/,"")),t||"unnamed-test"}var mn=8;function ea(e,t,r){let a=yt(e),s=r?yt(r).substring(0,mn):"";return s&&(a+=`--${s}`),t>0&&(a+=`--retry-${t}`),a}function ta(e,t,r,a,s,n){let o=e.find(u=>u.name==="screenshot"&&u.path),i=e.find(u=>u.name==="video"&&u.path),l=e.find(u=>u.name==="trace"&&u.path);if(!o&&!i&&!l)return null;let d=ea(t,r,n),c=s?["artifacts",s,d]:["artifacts",d],p=path.join(a,...c),v=c,g={};try{fs.mkdirSync(p,{recursive:!0});}catch{return null}if(o?.path&&fs.existsSync(o.path)){let m=`screenshot${path.extname(o.path)||".png"}`,h=path.join(p,m);H.push(le(o.path,h).then(()=>{})),g.screenshot=`${v.join("/")}/${m}`;}if(i?.path&&fs.existsSync(i.path)){let m=`video${path.extname(i.path)||".webm"}`,h=path.join(p,m);H.push(le(i.path,h).then(()=>{})),g.video=`${v.join("/")}/${m}`;}if(l?.path&&fs.existsSync(l.path)){let m=`trace${path.extname(l.path)||".zip"}`,h=path.join(p,m);H.push(le(l.path,h).then(()=>{})),g.trace=`${v.join("/")}/${m}`;}return !g.screenshot&&!g.video&&!g.trace?null:g}var xt="visual",vn=6;function bn(e){let t=crypto.createHash("sha256").update(e).digest("hex").substring(0,vn);return `${yt(e)}--${t}`}function Yr(e){let t=null;try{t=fs.openSync(e,"r");let r=Buffer.alloc(xe),a=fs.readSync(t,r,0,xe,0);return jr(r.subarray(0,a))}catch{return null}finally{if(t!==null)try{fs.closeSync(t);}catch{}}}var Xr=[{key:"expectedPath",dest:"baseline",field:"baseline"},{key:"actualPath",dest:"actual",field:"actual"},{key:"diffPath",dest:"diff",field:"diff"},{key:"previousPath",dest:"previous",field:"previous"}],yn=[{key:"baselineDomPath",dest:"baseline.dom.json",field:"baselineDom"},{key:"actualDomPath",dest:"actual.dom.json",field:"actualDom"}];function xn(e,t,r,a){let s=bn(e.name),n=path.join(t,s),o=Xr.some(u=>e[u.key]);if(o||e.dom)try{fs.mkdirSync(n,{recursive:!0});}catch{return null}let i={},l=false;for(let u of Xr){let m=e[u.key];if(!m||!fs.existsSync(m))continue;let h=path.extname(m)||".png",y=`${u.dest}${h}`;H.push(le(m,path.join(n,y)).then(()=>{})),i[u.field]=`${r}/${xt}/${s}/${y}`,l=true;}let d=e.dom;if(d)for(let u of yn){let m=d[u.key];!m||!fs.existsSync(m)||(H.push(le(m,path.join(n,u.dest)).then(()=>{})),i[u.field]=`${r}/${xt}/${s}/${u.dest}`);}if(!l&&o)return null;let c=e.expectedPath?Yr(e.expectedPath):e.actualPath?Yr(e.actualPath):null,p=Jr(e.diffPixels,c),v=e.committedPath??e.expectedPath,g=v?path.relative(a,v).replace(/\\/g,"/"):void 0;return {name:e.name,status:e.status,source:e.source,...i,...g?{baselinePath:g}:{},...c?{width:c.width,height:c.height}:{},...e.actualWidth!==void 0?{actualWidth:e.actualWidth}:{},...e.actualHeight!==void 0?{actualHeight:e.actualHeight}:{},...e.diffPixels!==void 0?{diffPixels:e.diffPixels}:{},...p!==void 0?{diffPixelRatio:p}:{},...d?{domChanges:d.changes,domChangeCount:d.total,domRootCauses:d.rootCauses,domTruncated:d.truncated,domCaptureBox:d.captureBox}:{}}}function ra(e,t,r,a,s,n,o=process.cwd()){if(e.length===0)return null;let i=ea(t,r,n),l=s?["artifacts",s,i]:["artifacts",i],d=path.join(a,...l,xt),c=l.join("/");try{fs.mkdirSync(d,{recursive:!0});}catch{return null}let p=[];for(let v of e){let g=xn(v,d,c,o);g&&p.push(g);}return p.length>0?p:null}var aa="testrelic-visual-dom";var wn="testrelic-visual",kn=/^(.+)-(expected|actual|diff|previous)(\.[A-Za-z0-9]+)$/;function Sn(e){let t=new Map;for(let r of e)if(!(r.name!==wn||!r.body))try{let a=JSON.parse(r.body.toString("utf-8"));if(!Array.isArray(a))continue;for(let s of a){let n=Tn(s);n&&t.set(n.stem,n);}}catch{}return t}var Cn=["passed","failed","new","updated"];function Tn(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.stem!="string"||!t.stem||typeof t.name!="string"||!t.name||typeof t.status!="string"||!Cn.includes(t.status)?null:{stem:t.stem,name:t.name,status:t.status,...typeof t.committedPath=="string"&&t.committedPath?{committedPath:t.committedPath}:{}}}function Rn(e){let t=new Map;for(let r of e)if(!(r.name!==aa||!r.body))try{let a=JSON.parse(r.body.toString("utf-8"));if(!Array.isArray(a))continue;for(let s of a){if(typeof s!="object"||s===null)continue;let n=s;typeof n.stem!="string"||!Array.isArray(n.changes)||t.set(n.stem,s);}}catch{}return t}function An(e){let t=new Map;for(let r of e){if(!r.path)continue;let a=kn.exec(r.name);if(!a)continue;let[,s,n]=a,o=t.get(s)??{};o[n]=r.path,t.set(s,o);}return t}function _n(e){return !!(e.actual&&(e.expected||e.diff))}function In(e,t,r){return e.diff||Wr(r)?"failed":t?"updated":"new"}function Mn(e,t){if(e.length===0)return null;if(e.length===1)return e[0];if(!t)return null;let r=t.replace(/\.[A-Za-z0-9]+$/,""),a=e.filter(s=>s===r||s.endsWith(`/${r}`));return a.length===1?a[0]:null}function ia(e,t={}){if(e.length===0)return [];let r=Sn(e),a=Rn(e),s=An(e);if(s.size===0&&r.size===0)return [];let n=t.updatingSnapshots===true,o=[];for(let[i,l]of s){let d=r.get(i);!d&&!_n(l)||o.push({name:d?.name??i,status:d?.status??In(l,n,t.failureMessage),source:d?"toMatchVisualBaseline":"toHaveScreenshot",...l.expected?{expectedPath:l.expected}:{},...d?.committedPath?{committedPath:d.committedPath}:{},...l.actual?{actualPath:l.actual}:{},...l.diff?{diffPath:l.diff}:{},...l.previous?{previousPath:l.previous}:{},...a.has(i)?{dom:a.get(i)}:{}});}for(let[i,l]of r)s.has(i)||o.push({name:l.name,status:l.status,source:"toMatchVisualBaseline",...l.committedPath?{committedPath:l.committedPath}:{},...a.has(i)?{dom:a.get(i)}:{}});return En(o,s,t.failureMessage)}function En(e,t,r){let a=Kr(r);if(a.diffPixels===void 0&&a.actualWidth===void 0)return [...e];let s=e.filter(o=>o.status==="failed"&&sa(o)).map(o=>na(o,t)),n=Mn(s,a.snapshotName);return n===null?[...e]:e.map(o=>sa(o)&&na(o,t)===n?{...o,...a.diffPixels!==void 0?{diffPixels:a.diffPixels}:{},...a.actualWidth!==void 0?{actualWidth:a.actualWidth}:{},...a.actualHeight!==void 0?{actualHeight:a.actualHeight}:{}}:o)}function sa(e){return !!(e.expectedPath||e.actualPath||e.diffPath||e.previousPath)}function na(e,t){if(t.has(e.name))return e.name;for(let[r,a]of t)if(a.actual===e.actualPath&&a.expected===e.expectedPath&&a.diff===e.diffPath)return r;return e.name}var Pn=new RegExp("[\x1B\x9B][[\\]()#;?]*(?:\\d{1,4}(?:;\\d{0,4})*)?[0-9A-PR-TZcf-nqry=><]","g");function ke(e){return !e||e.indexOf("\x1B")===-1&&e.indexOf("\x9B")===-1?e:e.replace(Pn,"")}function oa(e){return e==null?null:ke(e)}var Dn=/^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}(-\d+)?$/,Ln="1.0",kt="visual";function ua(e){let t=path.extname(e).toLowerCase();return [".png",".jpg",".jpeg",".gif",".bmp",".webp"].includes(t)?"screenshot":[".webm",".mp4",".avi",".mov"].includes(t)?"video":t===".zip"&&path.basename(e,t)==="trace"?"trace":"other"}function Nn(e){if(e.endsWith(".dom.json"))return "dom";let t=path.basename(e,path.extname(e));return t==="baseline"?"baseline":t==="diff"?"diff":ua(e)}function Fn(e,t,r){let a=[];try{for(let s of fs.readdirSync(e,{withFileTypes:!0})){if(!s.isFile())continue;let n=fs.statSync(path.join(e,s.name));a.push({name:`${kt}/${r}/${s.name}`,type:Nn(s.name),relativePath:`${t}/${kt}/${r}/${s.name}`,sizeBytes:n.size});}}catch{}return a}function pa(e,t,r){let a=[],s=`artifacts/${t}/${r}`;try{let n=fs.readdirSync(e,{withFileTypes:!0});for(let o of n){if(o.isDirectory()&&o.name===kt){let d=path.join(e,o.name);for(let c of fs.readdirSync(d,{withFileTypes:!0}))c.isDirectory()&&a.push(...Fn(path.join(d,c.name),s,c.name));continue}if(!o.isFile())continue;let i=path.join(e,o.name),l=fs.statSync(i);a.push({name:o.name,type:ua(o.name),relativePath:`${s}/${o.name}`,sizeBytes:l.size});}}catch{}return {testName:r,files:a}}function Bn(e,t){let r=path.join(e,t),a=[],s=0;try{let o=fs.readdirSync(r,{withFileTypes:!0});for(let i of o){if(!i.isDirectory())continue;let l=pa(path.join(r,i.name),t,i.name);a.push(l);for(let d of l.files)s+=d.sizeBytes;}}catch{}let n=t.replace(/^(\d{4}-\d{2}-\d{2})T(\d{2})-(\d{2})-(\d{2})/,"$1T$2:$3:$4").replace(/-\d+$/,"");return a.sort((o,i)=>o.testName.localeCompare(i.testName)),{folderName:t,timestamp:n,totalSizeBytes:s,testCount:a.length,tests:a,isCurrentRun:false}}function fa(e,t){let r=path.join(e,"artifacts"),a=[],s=[],n=0;try{let i=fs.readdirSync(r,{withFileTypes:!0});for(let l of i)if(l.isDirectory())if(Dn.test(l.name)){let d=Bn(r,l.name);a.push({...d,isCurrentRun:l.name===t});}else {let d=pa(path.join(r,l.name),l.name,l.name);s.push(d);for(let c of d.files)n+=c.sizeBytes;}}catch{}a.sort((i,l)=>l.timestamp.localeCompare(i.timestamp)),s.length>0&&(s.sort((i,l)=>i.testName.localeCompare(l.testName)),a.push({folderName:"__legacy__",timestamp:"1970-01-01T00:00:00",totalSizeBytes:n,testCount:s.length,tests:s,isCurrentRun:false}));let o=a.reduce((i,l)=>i+l.totalSizeBytes,0);return {schemaVersion:Ln,generatedAt:new Date().toISOString(),artifactBaseDir:"artifacts",totalSizeBytes:o,runs:a,serverPort:null}}var Vn=256;function $n(e){let t=path.resolve(e);for(let r=0;r<Vn;r++){if(fs.existsSync(path.join(t,".git")))return t;let a=path.dirname(t);if(a===t)return null;t=a;}return null}function ma(e){try{let t=$n(e);if(!t)return;let r=path.join(t,".gitignore"),a=path.relative(t,e).replace(/\\/g,"/"),s=a.endsWith("/")?a:`${a}/`;if(fs.existsSync(r)&&fs.readFileSync(r,"utf-8").split(`
|
|
4317
|
+
`).map(l=>l.trim()).some(l=>l===s||l===a))return;let n=`
|
|
4259
4318
|
# TestRelic test artifacts
|
|
4260
|
-
${
|
|
4261
|
-
`;fs
|
|
4262
|
-
`);return}return
|
|
4263
|
-
`);return}finally{a&&clearTimeout(a);}}function
|
|
4264
|
-
`}function
|
|
4265
|
-
`,
|
|
4266
|
-
`,
|
|
4267
|
-
`,process.stderr.write(
|
|
4268
|
-
`)[0]?.trim();return a
|
|
4269
|
-
`),a=JSON.stringify(
|
|
4270
|
-
`),a=JSON.stringify(
|
|
4271
|
-
`),a=JSON.stringify(
|
|
4272
|
-
`),a=JSON.stringify(
|
|
4319
|
+
${s}
|
|
4320
|
+
`;fs.appendFileSync(r,n,"utf-8");}catch{}}var va=Symbol("testrelic.timeout"),ba=3e4,St=12e4,Ct=6e4,ya=15e3;async function J(e,t,r){let a,s=new Promise(n=>{a=setTimeout(()=>n(va),t),typeof a?.unref=="function"&&a.unref();});try{let n=await Promise.race([e(),s]);if(n===va){process.stderr.write(`[testrelic] ${r} timed out after ${Math.round(t/1e3)}s \u2014 continuing without it. Your tests are unaffected.
|
|
4321
|
+
`);return}return n}catch(n){process.stderr.write(`[testrelic] ${r} failed \u2014 continuing without it. Your tests are unaffected. (${n instanceof Error?n.message:String(n)})
|
|
4322
|
+
`);return}finally{a&&clearTimeout(a);}}function ka(e,t){let r=[];for(let a of e){let s=jn(a),n=Gn(a),o=Wn(a,s,n,t),i=Kn(a,s,n);if(o.length===0&&i.length===0){r.push({type:"navigation",url:"about:blank",timestamp:a.startedAt,durationOnUrl:a.duration,navigationType:"dummy",domContentLoadedAt:null,networkIdleAt:null,networkStats:null,specFile:a.specFile,test:s,tests:[n],_testTitle:a.title});continue}r.push(...o,...i);}return r.sort(Jn),Yn(r,e),r.map((a,s)=>a.type==="navigation"?{...{index:s,type:"navigation",url:a.url,timestamp:a.timestamp,durationOnUrl:a.durationOnUrl??0,navigationType:a.navigationType,domContentLoadedAt:a.domContentLoadedAt??null,networkIdleAt:a.networkIdleAt??null,networkStats:a.networkStats??null,specFile:a.specFile,test:a.test},tests:a.tests}:{...{index:s,type:"api_call",callId:a.callId,method:a.method,url:a.url,timestamp:a.timestamp,responseTime:a.responseTime??null,request:a.request,response:a.response??null,...a.error?{error:a.error}:{},assertions:a.assertions??[],specFile:a.specFile,test:a.test},tests:a.tests})}function jn(e){return {title:e.title,fullTitle:e.titlePath,status:e.status,duration:e.duration,retries:e.retryCount,retry:e.retry,tags:e.tags,failure:e.failure}}function Gn(e){return {title:e.title,status:e.status,duration:e.duration,startedAt:e.startedAt,completedAt:e.completedAt,retryCount:e.retryCount,tags:e.tags,failure:e.failure,testId:e.testId,filePath:e.filePath,suiteName:e.suiteName,testType:e.testType,isFlaky:e.isFlaky,retryStatus:e.retryStatus,expectedStatus:e.expectedStatus,actualStatus:e.actualStatus,artifacts:e.artifacts,networkRequests:e.networkRequests,apiCalls:e.apiCalls,apiAssertions:e.apiAssertions,actions:e.actions,consoleLogs:e.consoleLogs}}function Wn(e,t,r,a){let s=[];for(let n of e.navigations)a.navigationTypes!==null&&!a.navigationTypes.includes(n.navigationType)||s.push({type:"navigation",url:n.url,timestamp:n.timestamp,durationOnUrl:0,navigationType:n.navigationType,domContentLoadedAt:n.domContentLoadedAt??null,networkIdleAt:n.networkIdleAt??null,networkStats:n.networkStats??null,specFile:e.specFile,test:t,tests:[r],_testTitle:e.title});return s}function Kn(e,t,r){if(!e.apiCalls||e.apiCalls.length===0)return [];let a=e.apiAssertions??[];return e.apiCalls.map(s=>{let n=a.filter(i=>i.callId===s.id).map(i=>({type:i.type,expected:i.expected,actual:i.actual,status:i.status,location:i.location,...i.expression!==void 0?{expression:i.expression}:{}})),o=null;return s.responseStatusCode!==null&&s.responseStatusText!==null&&(o={statusCode:s.responseStatusCode,statusText:s.responseStatusText,headers:s.responseHeaders,body:wa(s.responseBody)}),{type:"api_call",callId:s.id,method:s.method,url:s.url,timestamp:s.timestamp,responseTime:s.error?null:s.responseTimeMs,request:{headers:s.requestHeaders,body:wa(s.requestBody)},response:o,...s.error?{error:s.error}:{},assertions:n,specFile:e.specFile,test:t,tests:[r],_testTitle:e.title}})}function Jn(e,t){let r=new Date(e.timestamp).getTime(),a=new Date(t.timestamp).getTime();if(r!==a)return r-a;let s={navigation:0,api_call:1},n=s[e.type],o=s[t.type];return n!==o?n-o:e.type==="api_call"&&t.type==="api_call"&&e.callId&&t.callId?xa(e.callId)-xa(t.callId):0}function xa(e){let t=e.match(/(\d+)$/);return t?parseInt(t[1],10):0}function Yn(e,t){for(let r=0;r<e.length;r++){let a=e[r];if(a.type!=="navigation")continue;let s=new Date(a.timestamp).getTime(),n=null;for(let o=r+1;o<e.length;o++)if(e[o]._testTitle===a._testTitle){n=new Date(e[o].timestamp).getTime();break}if(n!==null)a.durationOnUrl=Math.max(0,n-s);else {let o=t.find(i=>i.title===a._testTitle);if(o){let i=new Date(o.completedAt).getTime();a.durationOnUrl=Math.max(0,i-s);}}}}function wa(e){if(e==null)return null;try{return JSON.parse(e)}catch{return e}}function Y(e,t){let r=e.length,a=Math.min(Math.ceil(t/100*r)-1,r-1);return e[Math.max(0,a)]}function Tt(e){try{let t=new URL(e);return t.origin+t.pathname}catch{return e}}function Xn(e){return e==null?"error":e>=200&&e<300?"2xx":e>=300&&e<400?"3xx":e>=400&&e<500?"4xx":e>=500&&e<600?"5xx":"error"}function Sa(e,t){let r=0,a=0,s=0,n=0,o=0;for(let k of e)switch(k.status){case "passed":r++;break;case "failed":a++;break;case "flaky":s++;break;case "skipped":n++;break;case "timedout":o++;break}let i=[];for(let k of e)k.apiCalls&&i.push(...k.apiCalls);let l=i.length,d=new Set,c={},p={"2xx":0,"3xx":0,"4xx":0,"5xx":0,error:0},v=[];for(let k of i)d.add(Tt(k.url)),c[k.method]=(c[k.method]??0)+1,p[Xn(k.responseStatusCode)]+=1,v.push(k.responseTimeMs);let g=null;if(v.length>0){let k=[...v].sort((X,G)=>X-G),C=k.reduce((X,G)=>X+G,0);g={avg:Math.round(C/k.length),min:k[0],max:k[k.length-1],p50:Y(k,50),p95:Y(k,95),p99:Y(k,99)};}let u=0,m=0,h=0;for(let k of e)if(k.apiAssertions)for(let C of k.apiAssertions)u++,C.status==="passed"?m++:h++;let y=0,f=new Set;for(let k of e){y+=k.navigations.length;for(let C of k.navigations)f.add(C.url);}let b=0,x={};function w(k){for(let C of k)b++,x[C.category]=(x[C.category]??0)+1,C.children.length>0&&w(C.children);}for(let k of e)k.actions&&w(k.actions);let M=0,A=0,R=0,D=0;for(let k of e)if(k.visual)for(let C of k.visual)M++,C.status==="failed"?A++:(C.status==="new"||C.status==="updated")&&R++,D+=C.domChangeCount??0;return {total:e.length,passed:r,failed:a,flaky:s,skipped:n,timedout:o,totalApiCalls:l,uniqueApiUrls:d.size,apiCallsByMethod:c,apiCallsByStatusRange:p,apiResponseTime:g,totalAssertions:u,passedAssertions:m,failedAssertions:h,totalNavigations:y,uniqueNavigationUrls:f.size,totalTimelineSteps:t,totalActionSteps:b,actionStepsByCategory:x,visualChecks:M,visualFailures:A,visualNew:R,visualDomChanges:D}}function Zn(e){let t=56-e.length;return t>0?e+" ".repeat(t):e}function I(e){return `\u2502 ${Zn(e)} \u2502
|
|
4323
|
+
`}function Rt(e,t,r,a,s){if(a||e.total===0)return;let n=`\u250C${"\u2500".repeat(58)}\u2510
|
|
4324
|
+
`,o=`\u2514${"\u2500".repeat(58)}\u2518
|
|
4325
|
+
`,i=I(""),l=n;l+=I("TestRelic AI - Playwright Test Report"),l+=i;let d=s??e,c=[];if(d.passed>0&&c.push(`${d.passed} \u2713`),d.failed>0&&c.push(`${d.failed} \u2717`),d.flaky>0&&c.push(`${d.flaky} \u26A0`),d.skipped>0&&c.push(`${d.skipped} skipped`),d.timedout>0&&c.push(`${d.timedout} timedout`),l+=I(`Tests: ${e.total} total (${c.join(" ")})`),s&&s.expectedFailures>0&&(l+=I(` ${s.expectedFailures} failed as expected (test.fail)`)),s&&s.unexpectedPasses>0&&(l+=I(` ${s.unexpectedPasses} expected to fail, but passed (test.fail)`)),e.totalNavigations>0&&(l+=I(`Navigations: ${e.totalNavigations} visits across ${e.uniqueNavigationUrls} unique URLs`)),e.totalApiCalls>0){l+=I(`API Calls: ${e.totalApiCalls} calls across ${e.uniqueApiUrls} unique endpoints`);let p=Object.entries(e.apiCallsByMethod).filter(([,g])=>g>0).map(([g,u])=>`${g}: ${u}`);p.length>0&&(l+=I(` ${p.join(" ")}`));let v=Object.entries(e.apiCallsByStatusRange).filter(([,g])=>g>0).map(([g,u])=>`${g}: ${u}`);v.length>0&&(l+=I(` ${v.join(" ")}`)),e.apiResponseTime&&(l+=I(` Avg response: ${e.apiResponseTime.avg}ms P95: ${e.apiResponseTime.p95}ms`));}if(e.totalAssertions>0&&(l+=I(`Assertions: ${e.totalAssertions} total (${e.passedAssertions} \u2713 ${e.failedAssertions} \u2717)`)),e.totalActionSteps>0){let p=[],v=e.actionStepsByCategory;v.ui_action&&p.push(`${v.ui_action} UI`),v.assertion&&p.push(`${v.assertion} assertions`),v.custom_step&&p.push(`${v.custom_step} custom`);let g=p.length>0?` (${p.join(" ")})`:"";l+=I(`Actions: ${e.totalActionSteps} steps${g}`);}l+=I(`Report: ${r}`),l+=I(`Data: ${t}`),l+=o,l+=`For more information visit us at https://docs.testrelic.ai
|
|
4326
|
+
`,process.stderr.write(l);}var Qn=new Set(["pw:api","expect","test.step"]);function ei(e){return e==="expect"?"assertion":e==="test.step"?"custom_step":"ui_action"}function At(e,t,r){if(Qn.has(e.category)){let a=[];for(let n of e.steps)At(n,t,a);let s=e.startTime.getTime()-t.getTime();r.push({title:e.title,category:ei(e.category),timestamp:e.startTime.toISOString(),duration:e.duration,videoOffset:s>=0?s/1e3:null,status:e.error?"failed":"passed",error:oa(e.error?.message),children:a});}else for(let a of e.steps)At(a,t,r);}function Ca(e,t){let r=[];for(let a of e)At(a,t,r);return r}var ai=new Set(["localhost","127.0.0.1","0.0.0.0"]);function Ra(e){let t=new URL(e);if(t.protocol!=="https:"&&!(t.protocol==="http:"&&ai.has(t.hostname)))throw core.createError(core.ErrorCode.CLOUD_CONFIG_INVALID,`HTTPS is required for cloud communication. Got: ${t.protocol}//${t.hostname}`)}var si=3e3;async function _t(e){let t=new AbortController,r=setTimeout(()=>t.abort(),si);try{return (await fetch(`${e}/health`,{method:"GET",signal:t.signal})).ok}catch{return false}finally{clearTimeout(r);}}async function Aa(e){return new Promise(t=>setTimeout(t,e))}async function Ta(e){try{let r=(await e.json()).error;if(r&&typeof r.message=="string"){let a=r.details;if(Array.isArray(a)&&a.length>0){let s=a.map(n=>`${n.field}: ${n.message}`).join(", ");return `${r.message} (${s})`}return r.message}}catch{}return `HTTP ${e.status}`}async function It(e,t,r){let a=new AbortController,s=setTimeout(()=>a.abort(),r);try{let n=await fetch(`${e}/sdk/auth/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t}),signal:a.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 Aa(l);let d=await fetch(`${e}/sdk/auth/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t}),signal:a.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 Ta(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 Ta(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 Mt(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 _a(e,t,r){let a=new AbortController,s=setTimeout(()=>a.abort(),r);try{let n=await fetch(`${e}/sdk/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t}),signal:a.signal});if(n.status===429){let i=n.headers.get("Retry-After"),l=i?parseInt(i,10)*1e3:5e3;!isNaN(l)&&l>0&&(await Aa(l),n=await fetch(`${e}/sdk/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t}),signal:a.signal}));}if(!n.ok)return null;let o=await n.json();return {accessToken:o.accessToken,refreshToken:o.refreshToken,expiresIn:o.expiresIn}}catch{return null}finally{clearTimeout(s);}}async function Ia(e,t,r,a,s,n){let o=new AbortController,i=setTimeout(()=>o.abort(),s);try{let l={gitId:r,displayName:a};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:o.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 di=5e3;function V(e,t){try{return child_process.execSync(e,{cwd:t,timeout:di,encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim()||null}catch{return null}}function Ma(e){let t=V("git rev-parse --abbrev-ref HEAD",e),r=V("git rev-parse --short HEAD",e),a=V("git log -1 --pretty=%s",e),s=V("git log -1 --format=%an",e)??V("git config user.name",e),n=ci(e),o=n?ce(n):null;return {branch:t,commitSha:r,commitMessage:a,commitAuthor:s,remoteUrl:o}}function ci(e){let t=V("git remote get-url origin",e);if(t)return t;let r=V("git remote",e);if(!r)return null;let a=r.split(`
|
|
4327
|
+
`)[0]?.trim();return a?V(`git remote get-url ${a}`,e):null}function ce(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 Ea(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function Et(e){try{let t=fs.readFileSync(path.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 ue(e){let t=Et(e);return t||`local/${path.basename(e)}`}var ui=new Set(["smoke","regression","nightly","ci"]);function Se(){let e=process.env.TESTRELIC_RUN_TYPE?.trim().toLowerCase();if(e&&ui.has(e))return e}async function $(e,t,r){let a=new AbortController,s=setTimeout(()=>a.abort(),Math.max(1,r));try{return await fetch(e,{...t,signal:a.signal})}finally{clearTimeout(s);}}function Pa(e,t){let r=t+Math.ceil(Math.max(0,e)/1e3);return Math.min(6e5,Math.max(3e4,r))}var Ce=class{constructor(t=12e4,r=Date.now()){this.deadline=r+Math.max(0,t);}remaining(t=Date.now()){return Math.max(0,this.deadline-t)}expired(t=Date.now()){return this.remaining(t)===0}slice(t,r=Date.now()){return Math.min(t,this.remaining(r))}};var gi=1048576,Te=[1e3,3e3,9e3],Re=3,La=3e4,hi=90*1048576,mi=new Set(["e2e","mobile","unit"]);function Dt(e){if(e&&e.length>0&&e.every(s=>s.testType==="api")){let s=new Map;for(let i of e){let l=i.apiProtocol??"rest";s.set(l,(s.get(l)??0)+1);}let n="rest",o=0;for(let[i,l]of s)l>o&&(o=l,n=i);return {testType:"api",apiProtocol:n,metadata:{testType:"api",primaryProtocol:n}}}let t=new Map;for(let s of e??[])mi.has(s.testType)&&t.set(s.testType,(t.get(s.testType)??0)+1);let r=null,a=0;for(let[s,n]of t)n>a&&(a=n,r=s);return {testType:r??"e2e"}}function Lt(e,t,r,a,s,n){let o=n?.cloudPlatform?n.cloudPlatform:a?.provider&&a.provider!=="unknown"?a.provider:"local",i=Se(),l=Dt(s),d=l.testType==="api"?l:null,c=d&&s?s.map(v=>v.apiProtocol?v:{...v,apiProtocol:d.apiProtocol}):s;return {runId:e.testRunId,repoGitId:t,startedAt:e.startedAt,summary:e.summary,timeline:e.timeline,environment:o,...i?{runType:i}:{},...d?{testType:d.testType,apiProtocol:d.apiProtocol,metadata:d.metadata}:{testType:l.testType},...c&&c.length>0?{tests:c}:{},...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}:{},...a?.provider?{ciProvider:a.provider}:{},...a?.runUrl?{ciRunUrl:a.runUrl}:{},...n?.cloudPlatform?{cloudPlatform:n.cloudPlatform}:{},...n?.cloudBuildId?{cloudBuildId:n.cloudBuildId}:{},...n?.cloudSessionId?{cloudSessionId:n.cloudSessionId}:{}}}function Pt(e){return typeof e=="string"?Buffer.byteLength(e,"utf-8"):0}function Nt(e){return Array.isArray(e)?e.map(t=>{let r=t.statusCode??t.responseStatusCode??null;return {...t.id!=null?{id:t.id}:{},...t.protocol!=null?{protocol:t.protocol}:{},method:t.method??null,url:t.url??null,statusCode:r,statusText:t.statusText??t.responseStatusText??null,ok:typeof r=="number"?r<400:t.ok??null,durationMs:t.durationMs??t.responseTimeMs??null,bytesIn:typeof t.bytesIn=="number"?t.bytesIn:Pt(t.responseBody),bytesOut:typeof t.bytesOut=="number"?t.bytesOut:Pt(t.requestBody),requestHeaders:t.requestHeaders??null,responseHeaders:t.responseHeaders??null,requestBody:t.requestBody??null,responseBody:t.responseBody??null,requestCookies:t.requestCookies??null,responseCookies:t.responseCookies??null}}):[]}function Ft(e){return Array.isArray(e)?e.map(t=>{let r=t.responseStatusCode??t.statusCode??0,a=t.timestamp??null;return {method:t.method??"GET",url:t.url??"",status:r,statusCode:r,type:"xhr",size:Pt(t.responseBody),duration:t.responseTimeMs??t.durationMs??0,responseTimeMs:t.responseTimeMs??t.durationMs??0,requestHeaders:t.requestHeaders??null,responseHeaders:t.responseHeaders??null,requestBody:t.requestBody??null,responseBody:t.responseBody??null,timestamp:a,startedAt:a}}):[]}function Bt(e){if(!Array.isArray(e))return [];let t=r=>{if(r==null)return String(r);if(typeof r=="string")return r;try{return JSON.stringify(r)}catch{return String(r)}};return e.map(r=>{let a=r.status==="failed"?"failed":"passed",s=typeof r.expression=="string"&&r.expression.trim()?r.expression.trim():null,n=r.kind??r.type??"assertion",o=a==="failed"?`expected ${t(r.expected)}, received ${t(r.actual)}`:r.expected!==void 0?`expected ${t(r.expected)}`:null;return {...r.callId!=null?{callId:r.callId}:{},kind:n,description:s??r.description??`${n} assertion`,status:a,detail:o}})}async function Ae(e){return new Promise(t=>setTimeout(t,e))}function vi(e){let t={};for(let[r,a]of Object.entries(e))a!=null&&(t[r]=a);return t}async function Na(e,t,r,a=La,s){for(let n=0;n<Re;n++){if(s?.expired())return null;let o=s?s.slice(a):a;if(o<=0)return null;try{let i=await $(e,t,o);if(i.ok)return i;if(i.status===401&&r&&n===0){let l=await r();if(l){let d={...t,headers:{...t.headers,Authorization:`Bearer ${l}`}},c=await $(e,d,o);if(c.ok)return c}return null}if(i.status===429&&n<Re-1){let l=i.headers.get("Retry-After"),d=l?parseInt(l,10)*1e3:Te[n];!isNaN(d)&&d>0?await Ae(d):await Ae(Te[n]);continue}if(i.status>=500&&n<Re-1){await Ae(Te[n]);continue}return i}catch{if(n<Re-1){await Ae(Te[n]);continue}return null}}return null}var bi=util.promisify(zlib.gzip);function Da(e,t){if(!Array.isArray(e.tests))return e;let r=e.tests.map(a=>{let{consoleLogs:s,networkRequests:n,apiCalls:o,...i}=a;return t?i:{...i,...o!==void 0?{apiCalls:o}:{}}});return {...e,tests:r}}var yi=["consoleLogs","networkRequests","apiCalls","actions","navigations","protocolAssertions","visual"];function xi(e){if(!Array.isArray(e.tests))return e;let t=new Set(yi),r=e.tests.map(a=>{let s={};for(let n in a)if(!t.has(n))if(n==="failure"&&a[n]&&typeof a[n]=="object"){let o=a[n];s.failure={message:o.message??null,line:o.line??null};}else s[n]=a[n];return s});return {...e,tests:r}}function wi(e){let t=new Set(["tests","timeline","unifiedTimeline","navigations"]),r={};for(let a in e)t.has(a)||(r[a]=e[a]);return r.tests=[],r}async function Ot(e,t=hi){let r={"Content-Type":"application/json"},a=JSON.stringify(e),s=e,n=Array.isArray(s?.tests)?s.tests.length:0,o=i=>Buffer.byteLength(i,"utf-8")>t;if(n>0&&o(a)){let i=Math.max(1,Math.round(t/1048576));process.stderr.write(`[testrelic] WARNING: batch payload exceeds ${i}MB \u2014 dropping consoleLogs/networkRequests from ${n} test(s) to avoid HTTP 413. Console/network detail will be missing in the cloud.
|
|
4328
|
+
`),a=JSON.stringify(Da(s,false)),o(a)&&(process.stderr.write(`[testrelic] WARNING: batch still exceeds ${i}MB after dropping logs \u2014 also dropping apiCalls from ${n} test(s). API request/response detail will be missing in the cloud.
|
|
4329
|
+
`),a=JSON.stringify(Da(s,true))),o(a)&&(process.stderr.write(`[testrelic] WARNING: batch still exceeds ${i}MB \u2014 shedding remaining per-test detail (actions/navigations/assertions) from ${n} test(s). Only test results + summary will reach the cloud.
|
|
4330
|
+
`),a=JSON.stringify(xi(s))),o(a)&&(process.stderr.write(`[testrelic] ERROR: batch still exceeds ${i}MB after shedding all per-test detail \u2014 uploading run summary only (${n} per-test result(s) omitted) to avoid losing the run to HTTP 413.
|
|
4331
|
+
`),a=JSON.stringify(wi(s)));}if(Buffer.byteLength(a,"utf-8")>gi){r["Content-Encoding"]="gzip";let i=await bi(Buffer.from(a,"utf-8")),l=i.buffer;return {body:new Uint8Array(l,i.byteOffset,i.byteLength),headers:r}}return {body:a,headers:r}}async function Fa(e,t,r,a,s,n){let o=`${e}/runs`,{body:i,headers:l}=await Ot(r);l.Authorization=`Bearer ${t}`;let d=await Na(o,{method:"POST",headers:l,body:i},a,s,n);return d?.ok?{success:true,statusCode:d.status,error:null}:d?.status===409?{success:true,statusCode:409,error:null}:{success:false,reason:d?`Upload failed with status ${d.status}`:"Upload failed after retries",statusCode:d?.status??null,payload:r,targetEndpoint:o,method:"POST"}}async function Ba(e,t,r,a){let s=`${e}/runs/init`;try{let n=await $(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(vi(r))},a??La);return n.ok?{runId:(await n.json()).runId}:null}catch{return null}}function Oa(e,t,r,a){let s=`${e}/runs/${r}/tests`;fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(a)}).catch(()=>{});}async function Ua(e,t,r,a){let s=`${e}/runs/${r}/finalize`;return (await Na(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(a)}))?.ok??false}function Ut(e,t,r,a){let s=`${e}/runs/${r}/finalize`,n=new Date,o={finishedAt:n.toISOString(),duration:n.getTime()-new Date(a).getTime(),summary:{}};fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(o)}).catch(()=>{});}var Ri="1.0.0",za=10;function Ha(e){return e instanceof Error?e.message:String(e)}function Ai(e){return e>=400&&e<500&&e!==408&&e!==429}function pe(e,t,r,a,s,n,o,i){try{fs.mkdirSync(e,{recursive:!0});let l=Date.now(),d=`${l}-${t}-${r}.json`,c=path.join(e,d),p={version:Ri,queuedAt:new Date(l).toISOString(),reason:a,retryCount:0,targetEndpoint:s,method:n,payload:o,headers:i},v=c+".tmp";fs.writeFileSync(v,JSON.stringify(p,null,2),"utf-8"),fs.renameSync(v,c);}catch(l){l.code==="ENOSPC"?process.stderr.write(`\u26A0 TestRelic: Disk full \u2014 unable to queue upload data.
|
|
4273
4332
|
`):process.stderr.write(`\u26A0 TestRelic: Unable to queue upload data.
|
|
4274
|
-
`);}}async function
|
|
4275
|
-
`),fs
|
|
4276
|
-
`);try{fs
|
|
4277
|
-
`);try{fs
|
|
4278
|
-
`);return}}catch(
|
|
4279
|
-
`);return}}}function
|
|
4280
|
-
`);return}try{if(
|
|
4281
|
-
`);return}let r=await
|
|
4282
|
-
`),await this.resolveRepoId(),this.config.queueDirectory&&(
|
|
4283
|
-
`);}}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()+
|
|
4284
|
-
`));}async dispose(){if(this.healthCheckTimer&&(clearInterval(this.healthCheckTimer),this.healthCheckTimer=null),this.flushPromise){try{await Promise.race([this.flushPromise,
|
|
4285
|
-
\u2192 Manage keys: ${
|
|
4333
|
+
`);}}async function ja(e,t,r){let a;try{a=fs.readdirSync(e).filter(n=>n.endsWith(".json")&&!n.endsWith(".tmp")).sort();}catch{return}if(a.length===0)return;let s=[];for(let n=0;n<a.length;n+=za)s.push(a.slice(n,n+za));for(let n of s)for(let o of n){let i=path.join(e,o),l;try{if(!fs.statSync(i).isFile())continue;let c=JSON.parse(fs.readFileSync(i,"utf-8"));if(!core.isValidQueueEntry(c)){process.stderr.write(`\u26A0 TestRelic: Corrupted queue file deleted: ${o}
|
|
4334
|
+
`),fs.unlinkSync(i);continue}l=c;}catch(d){process.stderr.write(`\u26A0 TestRelic: Skipping unreadable queue file ${o}: ${Ha(d)}
|
|
4335
|
+
`);try{fs.unlinkSync(i);}catch{}continue}try{let{body:d,headers:c}=await Ot(l.payload),p={...l.headers,...c,Authorization:`Bearer ${r}`},v=await fetch(l.targetEndpoint,{method:l.method,headers:p,body:d});if(v.ok)fs.unlinkSync(i);else if(Ai(v.status)){process.stderr.write(`\u26A0 TestRelic: Queue entry ${o} rejected (HTTP ${v.status}) \u2014 moving aside; it will not be retried.
|
|
4336
|
+
`);try{fs.renameSync(i,`${i}.failed`);}catch{try{fs.unlinkSync(i);}catch{}}}else {process.stderr.write(`\u26A0 TestRelic: Queue flush paused \u2014 server returned HTTP ${v.status} for ${o}; will retry later.
|
|
4337
|
+
`);return}}catch(d){process.stderr.write(`\u26A0 TestRelic: Queue flush paused \u2014 ${Ha(d)}; will retry later.
|
|
4338
|
+
`);return}}}function Ga(e,t){try{let r=fs.readdirSync(e).filter(s=>(s.endsWith(".json")||s.endsWith(".failed"))&&!s.endsWith(".tmp")),a=Date.now();for(let s of r){let n=path.join(e,s);try{let o=fs.readFileSync(n,"utf-8"),l=JSON.parse(o).queuedAt;if(typeof l=="string"){let d=new Date(l).getTime();a-d>t&&fs.unlinkSync(n);}}catch{try{fs.unlinkSync(n);}catch{}}}}catch{}}var Li=3e5,Ni=864e5,Fi=6e4,Wa=3e4,qt="https://platform.testrelic.ai/settings/api-keys";function Ka(e){return new Promise(t=>{let r=setTimeout(t,e);typeof r?.unref=="function"&&r.unref();})}var _e=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.
|
|
4339
|
+
`);return}try{if(Ra(this.config.endpoint),this.gitMetadata=Ma(),!await _t(this.config.endpoint)){this.setLocalMode("cloud_unreachable"),process.stderr.write(`\u26A0 TestRelic: Cloud unreachable. Switching to local mode. Data will be queued for later upload.
|
|
4340
|
+
`);return}let r=await It(this.config.endpoint,this.config.apiKey,this.config.timeout);if(Mt(r)){this.handleAuthError(r.code,r.statusCode);return}let a=r;this.authState={mode:"cloud",accessToken:a.accessToken,refreshToken:a.refreshToken,expiresAt:Date.now()+a.expiresIn*1e3,orgId:a.orgId,orgName:a.orgName,userId:a.userId,userName:a.userName},process.stderr.write(`\u2713 TestRelic: Connected to cloud (${a.orgName} / ${a.userName})
|
|
4341
|
+
`),await this.resolveRepoId(),this.config.queueDirectory&&(Ga(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. Running in local mode. ${t instanceof Error?t.message:String(t)}
|
|
4342
|
+
`);}}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()+Li<t)return true;if(!this.config||!this.authState.refreshToken)return this.switchToLocalMode("token_expired_no_refresh"),false;try{let r=await _a(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}).
|
|
4343
|
+
`));}async dispose(){if(this.healthCheckTimer&&(clearInterval(this.healthCheckTimer),this.healthCheckTimer=null),this.flushPromise){try{await Promise.race([this.flushPromise,Ka(Wa)]);}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.
|
|
4344
|
+
\u2192 Manage keys: ${qt}
|
|
4286
4345
|
`);break;case "expired_key":this.setLocalMode("expired_api_key"),process.stderr.write(`\u26A0 TestRelic: API key has expired. Running in local mode.
|
|
4287
|
-
\u2192 Generate a new key: ${
|
|
4346
|
+
\u2192 Generate a new key: ${qt}
|
|
4288
4347
|
`);break;case "validation_error":this.setLocalMode("validation_error"),process.stderr.write(`\u26A0 TestRelic: API key format invalid. Running in local mode.
|
|
4289
|
-
\u2192 Manage keys: ${
|
|
4348
|
+
\u2192 Manage keys: ${qt}
|
|
4290
4349
|
`);break;case "rate_limited":this.setLocalMode("rate_limited"),process.stderr.write(`\u26A0 TestRelic: Rate limited during authentication. Running in local mode.
|
|
4291
4350
|
`);break;case "timeout":this.setLocalMode("auth_timeout"),process.stderr.write(`\u26A0 TestRelic: Authentication timed out. Running in local mode.
|
|
4292
4351
|
`);break;default:this.setLocalMode(`auth_error_${r??"unknown"}`),process.stderr.write(`\u26A0 TestRelic: Cloud authentication failed. Running in local mode.
|
|
4293
|
-
`);break}}async resolveRepoId(){if(!this.config||!this.authState.accessToken)return;let t=this.gitMetadata?.remoteUrl?ce(this.gitMetadata.remoteUrl):null,r=t?
|
|
4294
|
-
`);}readRepoCache(t){if(!this.config)return null;let r=path.join(this.config.queueDirectory,"..","cache","repo.json");try{if(!fs
|
|
4295
|
-
`),this.startBackgroundFlush();}}}catch{}},
|
|
4296
|
-
`);}return
|
|
4297
|
-
`),{navigations:
|
|
4298
|
-
`),{keyMap:
|
|
4299
|
-
`).filter(r=>r.length>0).map(r=>{try{return JSON.parse(r)}catch{return null}}).filter(r=>r!==null)}catch{return []}}function
|
|
4300
|
-
`).map(
|
|
4301
|
-
`),this.activeReportMode==="streaming"){let i=path.dirname(this.config.outputPath);this.streamingWriter=new ie(i);let
|
|
4302
|
-
`)});if(_.length>0){let T=path.dirname(this.config.outputPath),B=
|
|
4352
|
+
`);break}}async resolveRepoId(){if(!this.config||!this.authState.accessToken)return;let t=this.gitMetadata?.remoteUrl?ce(this.gitMetadata.remoteUrl):null,r=t?Ea(t):this.config.projectName??ue(process.cwd()),a=t??this.config.projectName??ue(process.cwd()),s=this.readRepoCache(a);if(s){this.repoId=s.repoId;return}try{let n=await Ia(this.config.endpoint,this.authState.accessToken,a,r,this.config.timeout,this.gitMetadata?.branch);n&&(this.repoId=n.repoId,this.writeRepoCache(a,n.repoId,n.displayName));}catch{}!t&&!this.config.projectName&&!Et(process.cwd())&&process.stderr.write(`\u2139 TestRelic: No git remote or package.json detected. Set project.name in .testrelic for stable project identity.
|
|
4353
|
+
`);}readRepoCache(t){if(!this.config)return null;let r=path.join(this.config.queueDirectory,"..","cache","repo.json");try{if(!fs.existsSync(r))return null;let a=fs.readFileSync(r,"utf-8"),s=JSON.parse(a);if(s.gitId!==t||Date.now()-s.resolvedAt>Ni)return null;let n=this.hashApiKey();return n&&s.apiKeyHash!==n?null:s}catch{return null}}writeRepoCache(t,r,a){if(!this.config)return;let s=path.join(this.config.queueDirectory,"..","cache"),n=path.join(s,"repo.json");try{fs.mkdirSync(s,{recursive:!0});let o={repoId:r,gitId:t,displayName:a,resolvedAt:Date.now(),apiKeyHash:this.hashApiKey()??""},i=n+".tmp";fs.writeFileSync(i,JSON.stringify(o,null,2),"utf-8"),fs.renameSync(i,n);}catch{}}hashApiKey(){return this.config?.apiKey?crypto.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,a=this.config.endpoint;this.flushPromise=Promise.race([ja(r,a,t),Ka(Wa)]).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 _t(t))return;if(this.config?.apiKey){let a=await It(this.config.endpoint,this.config.apiKey,this.config.timeout);if(!Mt(a)){let s=a;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.
|
|
4354
|
+
`),this.startBackgroundFlush();}}}catch{}},Fi),typeof this.healthCheckTimer?.unref=="function"&&this.healthCheckTimer.unref();}};function zi(e,t){return t?e?{"2xx":e["2xx"]+t["2xx"],"3xx":e["3xx"]+t["3xx"],"4xx":e["4xx"]+t["4xx"],"5xx":e["5xx"]+t["5xx"],error:e.error+t.error}:{...t}:e}function Ja(e,t,r,a){let s=[],n=[],o=null,i=0,l=null,d=0,c=null,p=0,v=null,g=e.filter(h=>h.name===core.ATTACHMENT_NAME&&h.body),u=false;if(g.length>0)for(let h of g)try{let y=JSON.parse(h.body.toString());if(core.isTestRelicFilePayload(y)){s=s.concat(y.navigations),n=n.concat(y.apiAssertions),y.networkRequestsFile&&(o=y.networkRequestsFile,i+=y.networkRequestsCount),y.consoleLogsFile&&(l=y.consoleLogsFile,d+=y.consoleLogsCount),y.apiCallsFile&&(c=y.apiCallsFile,p+=y.apiCallsCount),v=zi(v,y.apiStatusMix),u=!0;continue}if(core.isTestRelicDataPayload(y)){s=s.concat(y.navigations),Array.isArray(y.apiAssertions)&&(n=n.concat(y.apiAssertions)),i+=y.networkRequests?.length??0,p+=y.apiCalls?.length??0;let f=y.consoleLogs;Array.isArray(f)&&(d+=f.length),u=!0;}}catch{process.stderr.write(`[testrelic] Warning: Corrupt attachment for test "${r}"
|
|
4355
|
+
`);}return u||(s=t.filter(h=>h.type==="lambdatest-navigation"&&h.description).map(h=>{try{return JSON.parse(h.description)}catch{return null}}).filter(h=>h!==null)),s.length===0&&i===0&&p===0&&!a&&!u&&process.stderr.write(`[testrelic] Warning: No data found for test "${r}". Make sure your tests import { test, expect } from '@testrelic/playwright-analytics/fixture' instead of '@playwright/test'. Without the TestRelic fixture, network logs, video sync, and Test Navigation data cannot be captured.
|
|
4356
|
+
`),{navigations:s,apiAssertions:n,networkRequestsFile:o,networkRequestsCount:i,consoleLogsFile:l,consoleLogsCount:d,apiCallsFile:c,apiCallsCount:p,apiStatusMix:v}}function Ie(e=process.env){let t=Hi(e.TESTRELIC_CLOUD_PLATFORM);if(t)return {cloudPlatform:t,cloudBuildId:e.TESTRELIC_CLOUD_BUILD_ID||void 0,cloudSessionId:e.TESTRELIC_CLOUD_SESSION_ID||void 0};if(e.BROWSERSTACK_USERNAME||e.BROWSERSTACK_ACCESS_KEY)return {cloudPlatform:"browserstack",cloudBuildId:e.BROWSERSTACK_BUILD_NAME||e.BROWSERSTACK_BUILD_ID||void 0,cloudSessionId:e.BROWSERSTACK_SESSION_ID||void 0};if(e.LT_USERNAME||e.LAMBDATEST_USERNAME||e.LT_ACCESS_KEY||e.LAMBDATEST_ACCESS_KEY)return {cloudPlatform:"lambdatest",cloudBuildId:e.LT_BUILD||e.LAMBDATEST_BUILD||void 0,cloudSessionId:e.LT_SESSION_ID||e.LAMBDATEST_SESSION_ID||void 0};let r=e.PLAYWRIGHT_WS_ENDPOINT;if(r){if(/cdp\.lambdatest\.com/i.test(r))return {cloudPlatform:"lambdatest"};if(/cdp\.browserstack\.com/i.test(r))return {cloudPlatform:"browserstack"}}return {}}function Hi(e){if(!e)return;let t=e.toLowerCase().trim();if(t==="browserstack"||t==="bs")return "browserstack";if(t==="lambdatest"||t==="lt")return "lambdatest"}var Gi=5,Me=[1e3,3e3,9e3],te=3,jt=3e4,Wi={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".webm":"video/webm",".mp4":"video/mp4",".zip":"application/zip",".json":"application/json"},Vt=0,$t=[];async function Ki(){Vt>=Gi&&await new Promise(e=>$t.push(e)),Vt++;}function Ji(){Vt--,$t.length>0&&$t.shift()();}async function Ee(e){return new Promise(t=>setTimeout(t,e))}function Yi(e){let t=e.substring(e.lastIndexOf(".")).toLowerCase();return Wi[t]??"application/octet-stream"}function Xi(e){try{return fs.statSync(e).size}catch{return 0}}async function Zi(e,t,r,a,s){let n=`${e}/artifacts/upload-url`,o=JSON.stringify({runId:r.runId,testId:r.testId,fileName:path.basename(r.filePath),contentType:s,type:r.type,sizeBytes:a});for(let i=0;i<te;i++)try{let l=await $(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:o},jt);if(l.ok)return await l.json();if(l.status>=500&&i<te-1){await Ee(Me[i]);continue}return null}catch{if(i<te-1){await Ee(Me[i]);continue}return null}return null}async function Qi(e,t,r,a){let s=Pa(a,jt);for(let n=0;n<te;n++)try{let o=fs.createReadStream(t),i=stream.Readable.toWeb(o),l=await $(e,{method:"PUT",headers:{"Content-Type":r,"Content-Length":String(a)},body:i,duplex:"half"},s);if(l.ok)return !0;if(l.status>=500&&n<te-1){await Ee(Me[n]);continue}return !1}catch{if(n<te-1){await Ee(Me[n]);continue}return false}return false}async function eo(e,t,r){let a=`${e}/artifacts/confirm`;try{return (await $(a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({artifactId:r})},jt)).ok}catch{return false}}async function to(e,t,r,a){let s=Xi(r.filePath);if(s===0)return {success:false,storageKey:null,artifactId:null,error:"file_not_found_or_empty"};if(s>a*1024*1024)return {success:false,storageKey:null,artifactId:null,error:"file_too_large"};let n=Yi(r.filePath);await Ki();try{let o=await Zi(e,t,r,s,n);if(!o)return {success:!1,storageKey:null,artifactId:null,error:"upload_url_request_failed"};if(!await Qi(o.uploadUrl,r.filePath,n,s))return {success:!1,storageKey:o.storageKey,artifactId:o.artifactId,error:"presigned_put_failed"};let l=await eo(e,t,o.artifactId);return {success:l,storageKey:o.storageKey,artifactId:o.artifactId,error:l?null:"confirm_failed"}}finally{Ji();}}async function Ya(e,t,r,a,s){let n=new Map,o=r.map(async i=>{if(s?.expired()){n.set(i.filePath,{success:false,storageKey:null,artifactId:null,error:"upload_budget_exhausted"});return}let l=await to(e,t,i,a);n.set(i.filePath,l);});return await Promise.allSettled(o),n}function Wt(e){let r=e.getGitMetadata()?.remoteUrl;return r?ce(r):e.getConfig()?.projectName??ue(process.cwd())}async function Xa(e,t,r,a,s){if(!e.isCloudMode()||t!=="realtime"&&t!=="both"||!await e.ensureValidToken())return null;let o=e.getGitMetadata(),i=U(),l=Ie(),d=Se();return (await Ba(e.getEndpoint(),e.getAccessToken(),{runId:r,repoGitId:Wt(e),branch:o?.branch??null,commit:o?.commitSha??null,commitMessage:o?.commitMessage??null,commitAuthor:o?.commitAuthor??null,startedAt:a,totalTests:null,ciProvider:i?.provider??null,ciRunUrl:i?.runUrl??null,environment:s??l.cloudPlatform??null,cloudPlatform:l.cloudPlatform??null,cloudBuildId:l.cloudBuildId??null,cloudSessionId:l.cloudSessionId??null,...d?{runType:d}:{},testType:"e2e"}))?.runId??null}var ao=[{field:"baseline",keyField:"baselineKey",type:"baseline"},{field:"actual",keyField:"actualKey",type:"screenshot"},{field:"diff",keyField:"diffKey",type:"diff"},{field:"baselineDom",keyField:"baselineDomKey",type:"dom"},{field:"actualDom",keyField:"actualDomKey",type:"dom"}],so=true,no=50,Gt={keyMap:new Map,visualKeyMap:new Map,total:0,uploaded:0};async function io(e,t,r,a,s){let n=new Map,o=new Map;if(!(t?.uploadArtifacts??so)||!await e.ensureValidToken())return Gt;let d=[],c=new Map,p=new Map;for(let h of a){if(h.artifacts.screenshot){let f=path.join(h.outputDir,h.artifacts.screenshot);d.push({filePath:f,runId:r,testId:h.testId,type:"screenshot"}),c.set(f,{testId:h.testId,field:"screenshot"});}if(h.artifacts.video){let f=path.join(h.outputDir,h.artifacts.video);d.push({filePath:f,runId:r,testId:h.testId,type:"video"}),c.set(f,{testId:h.testId,field:"video"});}if(h.artifacts.trace){let f=path.join(h.outputDir,h.artifacts.trace);d.push({filePath:f,runId:r,testId:h.testId,type:"trace"}),c.set(f,{testId:h.testId,field:"trace"});}let y=h.visual??[];for(let f=0;f<y.length;f++){let b=y[f];if(b)for(let x of ao){let w=b[x.field];if(!w)continue;let M=path.join(h.outputDir,w);d.push({filePath:M,runId:r,testId:h.testId,type:x.type}),c.set(M,{testId:h.testId,field:"visual",visualIndex:f,visualKey:x.keyField});}}}if(d.length===0)return Gt;let v=t?.artifactMaxSizeMb??no,g=await Ya(e.getEndpoint(),e.getAccessToken(),d,v,s),u=new Map;for(let[h,y]of g){if(!y.success||!y.storageKey)continue;let f=c.get(h);if(!f)continue;let b=u.get(f.testId)??{};if(f.field==="screenshot"&&(b.screenshotKey=y.storageKey),f.field==="video"&&(b.videoKey=y.storageKey),f.field==="trace"&&(b.traceKey=y.storageKey),f.field==="visual"&&f.visualIndex!==void 0&&f.visualKey){let x=p.get(f.testId)??new Map,w=x.get(f.visualIndex)??{};w[f.visualKey]=y.storageKey,x.set(f.visualIndex,w),p.set(f.testId,x);}u.set(f.testId,b);}for(let h of a){if(h.visual&&h.visual.length>0){let f=p.get(h.testId);o.set(h.testId,h.visual.map((b,x)=>({...b,...f?.get(x)??{}})));}let y=u.get(h.testId);n.set(h.testId,{...h.artifacts,...y?.screenshotKey?{screenshotKey:y.screenshotKey}:{},...y?.videoKey?{videoKey:y.videoKey}:{},...y?.traceKey?{traceKey:y.traceKey}:{}});}let m=Array.from(g.values()).filter(h=>h.success).length;return m>0&&process.stderr.write(`\u2713 TestRelic: Uploaded ${m} artifact(s) to cloud storage.
|
|
4357
|
+
`),{keyMap:n,visualKeyMap:o,total:d.length,uploaded:m}}async function Kt(e,t,r,a,s,n,o,i,l,d,c){let p={realtimeFinalizeAttempted:false,realtimeFinalized:false,batchAttempted:false,batchAcknowledged:false,artifactsTotal:0,artifactsUploaded:0,failureReason:null},v=new Ce(t?.uploadBudgetMs??12e4),g=u=>{p.failureReason||(p.failureReason=u);};try{if(e.isCloudMode()&&s&&(r==="realtime"||r==="both")){p.realtimeFinalizeAttempted=!0;let h=await e.ensureValidToken(),y=e.getGitMetadata(),f=Dt(c),b={finishedAt:o,duration:i,summary:l,...y?.commitMessage?{commitMessage:y.commitMessage}:{},testType:f.testType,...f.testType==="api"?{apiProtocol:f.apiProtocol,metadata:f.metadata}:{}};if(h){let x=await Ua(e.getEndpoint(),e.getAccessToken(),s,b);if(p.realtimeFinalized=x,!x){g("finalize_failed_after_retries");let w=t?.queueDirectory??".testrelic/queue";pe(w,a,"finalize","finalize_failed_after_retries",`${e.getEndpoint()}/runs/${s}/finalize`,"POST",b,{"Content-Type":"application/json"});}}else {g(e.getFailureReason()??"token_invalid");let x=t?.queueDirectory??".testrelic/queue";pe(x,a,"finalize",e.getFailureReason()??"token_invalid",`${e.getEndpoint()}/runs/${s}/finalize`,"POST",b,{"Content-Type":"application/json"});}}let u=new Map,m=new Map;if(e.isCloudMode()&&d&&d.length>0){let h=await io(e,t,a,d,v);u=h.keyMap,m=h.visualKeyMap,p.artifactsTotal=h.total,p.artifactsUploaded=h.uploaded;}if(e.isCloudMode()&&(!r||r==="batch"||r==="both"))if(p.batchAttempted=!0,await e.ensureValidToken()){let y=e.getGitMetadata(),f=U(),b=Wt(e),x=lo(co(n,u),m),w=Lt(x,b,y,f,oo(c,m),Ie()),M=await Fa(e.getEndpoint(),e.getAccessToken(),w,async()=>await e.ensureValidToken()?e.getAccessToken():null,t?.timeout,v);if(p.batchAcknowledged=M.success,!M.success){let A=M;g(A.reason);let R=t?.queueDirectory??".testrelic/queue";pe(R,a,"batch",A.reason,A.targetEndpoint,A.method,A.payload,{"Content-Type":"application/json"});}}else {g(e.getFailureReason()??"token_invalid");let y=t?.queueDirectory??".testrelic/queue",f=e.getGitMetadata(),b=U(),x=Wt(e),w=Lt(n,x,f,b,void 0,Ie());pe(y,a,"batch",e.getFailureReason()??"token_invalid",`${e.getEndpoint()}/runs`,"POST",w,{"Content-Type":"application/json"});}await e.dispose();}catch(u){g(u instanceof Error?u.message:"unexpected_upload_error");try{await e.dispose();}catch{}}return p}function oo(e,t){return !e||t.size===0?e:e.map(r=>{let a=t.get(r.testId);return a?{...r,visual:a}:r})}function lo(e,t){if(t.size===0)return e;let r=e.timeline.map(a=>{let s=a.tests;if(!Array.isArray(s))return a;let n=false,o=s.map(i=>{let l=i.testId;if(!l)return i;let d=t.get(l);return d?(n=true,{...i,visual:d}):i});return n?{...a,tests:o}:a});return {...e,timeline:r}}function co(e,t){if(t.size===0)return e;let r=e.timeline.map(a=>{let s=a.testId;if(!s)return a;let n=t.get(s);return n?{...a,...n.screenshotKey?{screenshotKey:n.screenshotKey}:{},...n.videoKey?{videoKey:n.videoKey}:{}}:a});return {...e,timeline:r}}var uo=new Set(["batch","realtime","both"]),fe=Object.freeze({attempted:false,acknowledged:false,runId:null,endpoint:null,finalized:false,artifactsUploaded:0,artifactsTotal:0,detail:"cloud reporting was never initialised"});function po(e){switch(e){case "no_api_key":return "cloud mode off \u2014 no API key configured";case "cloud_unreachable":case "network_error":return "cloud endpoint unreachable \u2014 the run stayed local";case "invalid_api_key":return "API key rejected as invalid or revoked \u2014 the run stayed local";case "expired_api_key":return "API key has expired \u2014 the run stayed local";case "validation_error":return "API key format rejected \u2014 the run stayed local";case "rate_limited":return "rate limited during authentication \u2014 the run stayed local";case "auth_timeout":return "authentication timed out \u2014 the run stayed local";case "token_expired_no_refresh":case "token_refresh_failed":case "token_refresh_error":return "access token could not be refreshed \u2014 the run stayed local";case "init_error":return "cloud initialisation timed out \u2014 the run stayed local";case "unexpected_error":return "cloud initialisation failed \u2014 the run stayed local";default:return e?`cloud mode off (${e}) \u2014 the run stayed local`:"cloud mode off \u2014 the run stayed local"}}function Za(e,t,r){if(!e)return fe;if(!e.isCloudMode())return {...fe,detail:po(e.getFailureReason())};let a=t??"batch";if(!uo.has(a))return {...fe,detail:`upload strategy '${a}' is not recognised \u2014 nothing was sent`};let s=e.getEndpoint(),n=a==="realtime"||a==="both";return n&&r?{attempted:true,acknowledged:true,runId:r,endpoint:s,finalized:false,artifactsUploaded:0,artifactsTotal:0,detail:null}:{attempted:true,acknowledged:false,runId:null,endpoint:s,finalized:false,artifactsUploaded:0,artifactsTotal:0,detail:n?"run init failed \u2014 the platform did not acknowledge this run":`upload runs at the end of the run under the '${a}' strategy \u2014 not sent yet`}}function Jt(e,t,r){if(!e.attempted)return e;if(!t)return {...e,detail:e.acknowledged?"upload timed out before it completed \u2014 the run may be incomplete on the platform":"upload timed out before the platform acknowledged this run",acknowledged:e.acknowledged};let a=e.acknowledged||t.batchAcknowledged,s=e.runId??(t.batchAcknowledged?r:null),n=t.realtimeFinalizeAttempted?t.realtimeFinalized:t.batchAcknowledged,o=null;return a?n||(o="run acknowledged but not closed out \u2014 finalize failed and was queued for retry"):o=t.failureReason?`upload failed (${t.failureReason}) \u2014 queued locally for retry`:"upload failed \u2014 the platform did not acknowledge this run",{attempted:true,acknowledged:a,runId:s,endpoint:e.endpoint,finalized:n,artifactsUploaded:t.artifactsUploaded,artifactsTotal:t.artifactsTotal,detail:o}}function j(e){try{return fs.readFileSync(e,"utf-8").split(`
|
|
4358
|
+
`).filter(r=>r.length>0).map(r=>{try{return JSON.parse(r)}catch{return null}}).filter(r=>r!==null)}catch{return []}}function yo(e){if(!e)return null;let t=e.split(`
|
|
4359
|
+
`).map(n=>n.trim()).filter(Boolean);if(t.length===0)return null;let r=t.filter(n=>!/^Error:\s*expect\(/.test(n));if(r.length===0)return t[0]??null;let a=r[0],s=r[1];return s!==void 0&&/^Received:/.test(s)&&/^Expected:/.test(a)?`${a} \xB7 ${s}`:a}function Xt(e){switch(e){case "passed":return "passed";case "failed":return "failed";case "timedOut":return "timedout";case "skipped":return "skipped";case "interrupted":return "failed";default:return "failed"}}function xo(e,t,r){let a=`${e}::${t}::${r}`;return crypto.createHash("sha256").update(a).digest("hex").substring(0,16)}function wo(e){return e.length<=3?"":e[e.length-2]}function ko(e){let t=e.findIndex(r=>r.status==="passed");return t>0?`passed on retry ${t}`:null}function ns(e){return e===null?"error":e>=200&&e<300?"2xx":e>=300&&e<400?"3xx":e>=400&&e<500?"4xx":e>=500&&e<600?"5xx":"error"}function So(e){let t={"2xx":0,"3xx":0,"4xx":0,"5xx":0,error:0},r=t;for(let a of e){let s=typeof a.responseStatusCode=="number"?a.responseStatusCode:null;r[ns(s)]++;}return t}function rs(e){if(e){for(let t of e)if(t.status==="failed")return {type:t.type,expected:as(t.expected),actual:as(t.actual),...t.expression?{expression:t.expression}:{}}}}function as(e){if(e===void 0)return "undefined";if(e===null)return "null";let t;if(typeof e=="string")t=e;else try{t=JSON.stringify(e)??String(e);}catch{t=String(e);}return t.length>200?t.slice(0,200)+"\u2026":t}function De(e,t){if(!e)return 0;let r=0;for(let a of e)a.status===t&&r++;return r}function is(e,t){for(let r of e)t[r.category]=(t[r.category]??0)+1,r.children.length>0&&is(r.children,t);}function Co(e){if(e.length===0)return null;let t=[...e].sort((a,s)=>a-s),r=t.reduce((a,s)=>a+s,0);return {avg:Math.round(r/t.length),min:t[0],max:t[t.length-1],p50:Y(t,50),p95:Y(t,95),p99:Y(t,99)}}var os=2e5,Le=1e5;function ss(e,t,r,a,s,n,o){let i={retryIndex:e,apiCalls:t?.length??0,apiUrls:[],methodCounts:{},statusRanges:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,error:0},responseTimes:[],passedAssertions:0,failedAssertions:0,assertions:r.length,navigations:a.length,navUrls:[],networkRequests:s,consoleLogs:n,actionSteps:o?.length??0,actionCategories:{}};if(t){let d=new Set;for(let c of t){let p=typeof c.method=="string"?c.method:"OTHER";i.methodCounts[p]=(i.methodCounts[p]??0)+1;let v=typeof c.url=="string"?c.url:null;v&&d.size<Le&&d.add(Tt(v));let g=typeof c.responseStatusCode=="number"?c.responseStatusCode:typeof c.statusCode=="number"?c.statusCode:null,u=g!==null&&Number.isFinite(g)?g:null;i.statusRanges[ns(u)]++;let m=typeof c.responseTimeMs=="number"?c.responseTimeMs:typeof c.durationMs=="number"?c.durationMs:null;m!==null&&Number.isFinite(m)&&i.responseTimes.length<os&&i.responseTimes.push(m);}i.apiUrls=Array.from(d);}for(let d of r)d.status==="passed"?i.passedAssertions++:i.failedAssertions++;let l=new Set;for(let d of a)d.url&&l.size<Le&&l.add(d.url);return i.navUrls=Array.from(l),o&&is(o,i.actionCategories),i}function To(){return {apiUrlSet:new Set,methodCounts:{},statusRanges:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,error:0},responseTimes:[],passedAssertions:0,failedAssertions:0,navUrlSet:new Set,actionCategoryCounts:{},volApiCalls:0,volAssertions:0,volNavigations:0,volNetworkRequests:0,volConsoleLogs:0,volActionSteps:0}}function Ro(e){return process.env.BROWSERSTACK_USERNAME?"BrowserStack":e?{"github-actions":"GitHub Actions","gitlab-ci":"GitLab CI",jenkins:"Jenkins",circleci:"CircleCI","bitbucket-pipelines":"Bitbucket Pipelines"}[e.provider]??"CI":"Local"}function Ao(){let e=os$1.platform();return e==="win32"?"Windows":e==="darwin"?"macOS":"Linux"}function _o(e){let t=e.parent?.project?.()?.use;if(!t)return;let{browserName:r,channel:a}=t;if(a){let n=a.toLowerCase();return n==="chrome"||n==="chrome-stable"?"Chrome":n.startsWith("chrome-beta")?"Chrome Beta":n.startsWith("chrome-dev")?"Chrome Dev":n.startsWith("chrome-canary")?"Chrome Canary":n==="msedge"||n==="msedge-stable"?"Microsoft Edge":n.startsWith("msedge-beta")?"Edge Beta":n.startsWith("msedge-dev")?"Edge Dev":n.startsWith("msedge-canary")?"Edge Canary":a}if(r){let n=r.toLowerCase();return n==="chromium"?"Chromium":n==="firefox"?"Firefox":n==="webkit"?"WebKit":r}let s=t.defaultBrowserType;if(s){let n=s.toLowerCase();return n==="chromium"?"Chromium":n==="firefox"?"Firefox":n==="webkit"?"WebKit":s}}function Io(e,t,r){let a=r.parent?.project?.(),s="unknown";a!==void 0&&(a.use.isMobile===true?s="mobile":s="e2e");let n=["e2e","api","unit","mobile"];for(let l of n)if(e.some(d=>d===`@${l}`||d===l))return l;let o=t.replace(/\\/g,"/"),i=["e2e","api","unit"];for(let l of i)if(o.includes(`/${l}/`))return l;return s}var Mo="__testrelic_api_config";function Eo(e){return JSON.stringify(e,(t,r)=>r instanceof RegExp?{__regexp:true,source:r.source,flags:r.flags}:r)}var Ne=class{constructor(t){this.rootDir="";this.configDir="";this.startedAt="";this.testRunId="";this.collectedTests=[];this.fixtureDataReceived=false;this.navigationsCaptured=false;this.memoryPressureWarned=false;this.testCount=0;this.cloudClient=null;this.cloudRunId=null;this.runTimestamp="";this.updatingSnapshots=false;this.cloudReceipt=fe;this.pendingArtifactEntries=[];this.detectedOs="";this.detectedSource="";this.cloudTestsBuffer=[];this.activeReportMode="embedded";this.streamingWriter=null;this.testIndex=[];this.summaryCounters={total:0,passed:0,failed:0,flaky:0,skipped:0,timedOut:0,interrupted:0,totalApiCalls:0,totalAssertions:0,totalNavigations:0,totalNetworkRequests:0,totalConsoleLogs:0,totalActionSteps:0,visualChecks:0,visualFailures:0,visualDomChanges:0};this.streamingTestAgg=new Map;this.config=mr(t),this.apiConfig=hr(t);}upsertAggContribution(t,r){let a=this.streamingTestAgg.get(t);(!a||r.retryIndex>a.retryIndex)&&this.streamingTestAgg.set(t,r);}async onBegin(t,r){try{this.rootDir=t.rootDir,this.configDir=t.configFile?path.dirname(t.configFile):"";let a=t.updateSnapshots;if(this.updatingSnapshots=a==="all"||a==="changed",this.startedAt=new Date().toISOString(),this.testRunId=this.config.testRunId??crypto.randomUUID(),this.config.reportMode==="auto"){let i=r.allTests().length;this.activeReportMode=i>=this.config.streamingThreshold?"streaming":"embedded";}else this.activeReportMode=this.config.reportMode;let s=r.allTests().length;if(process.stderr.write(`[testrelic] Report mode: ${this.activeReportMode} (${s} tests)
|
|
4360
|
+
`),this.activeReportMode==="streaming"){let i=path.dirname(this.config.outputPath);this.streamingWriter=new ie(i);let l=()=>{if(this.streamingWriter){try{this.streamingWriter.writeIndex(this.testIndex);let d={testRunId:this.testRunId??"",startedAt:this.startedAt,completedAt:new Date().toISOString(),totalDuration:Date.now()-new Date(this.startedAt).getTime(),...this.summaryCounters,metadata:null,reportMode:"streaming",files:[],enrichedSummary:null,validation:null,writeErrors:this.streamingWriter.getWriteErrors(),cloudUpload:this.cloudReceipt};this.streamingWriter.writeSummary(d);}catch{}this.streamingWriter.dispose();}try{if(this.cloudClient?.isCloudMode()&&this.cloudRunId){let d=this.cloudClient.getAccessToken();d&&Ut(this.cloudClient.getEndpoint(),d,this.cloudRunId,this.startedAt);}}catch{}};process.on("SIGTERM",l),process.on("SIGINT",l);}if(this.config.includeArtifacts){let i=path.dirname(this.config.outputPath);this.runTimestamp=Qr(path.join(i,"artifacts"));try{ma(path.join(i,"artifacts"));}catch{}}let n=U();this.detectedOs=Ao(),this.detectedSource=Ro(n);let o=await J(async()=>(this.cloudClient=new _e(this.config.cloud),await this.cloudClient.initialize(),Xa(this.cloudClient,this.config.cloud?.uploadStrategy,this.testRunId,this.startedAt,this.detectedSource)),ba,"Cloud initialization");if(this.cloudRunId=o??null,o===void 0&&this.cloudClient?.switchToLocalMode("init_error"),this.cloudReceipt=Za(this.cloudClient,this.config.cloud?.uploadStrategy,this.cloudRunId),this.activeReportMode!=="streaming"){let i=()=>{try{if(this.cloudClient?.isCloudMode()&&this.cloudRunId){let l=this.cloudClient.getAccessToken();l&&Ut(this.cloudClient.getEndpoint(),l,this.cloudRunId,this.startedAt);}}catch{}};process.on("SIGTERM",i),process.on("SIGINT",i);}}catch{}}onTestBegin(t,r){try{t.annotations.push({type:Mo,description:Eo(this.apiConfig)});}catch{}}onTestEnd(t,r){try{let a=r,s=t.outcome(),n;s==="flaky"?n="flaky":s==="skipped"?n="skipped":n=Xt(a.status);let o=a.startTime.toISOString(),i=new Date(a.startTime.getTime()+a.duration).toISOString(),l=t.tags?[...t.tags]:t.annotations.filter(_=>_.type==="tag").map(_=>_.description??""),d=Ja(a.attachments,t.annotations,t.title,n==="skipped");(d.navigations.length>0||d.networkRequestsCount>0||d.apiCallsCount>0)&&(this.fixtureDataReceived=!0),d.navigations.length>0&&(this.navigationsCaptured=!0),!this.config.captureNavigation&&d.navigations.length>0&&(d={...d,navigations:[]});let c=null;if(n==="failed"||n==="flaky"){let T=(n==="flaky"?t.results.find(B=>B.status!=="passed")?.errors??[]:a.errors)[0];if(T){let B=br(this.config.redactPatterns),ae=T.location?.file??null,E=d.apiAssertions.find(ls=>ls.status==="failed")?.location??null,Z=E!==null&&(ae===null||path.resolve(ae)!==path.resolve(t.location.file)),tr=Z?E.file:ae,Fe=Z?E.line:T.location?.line??null,se=null;this.config.includeCodeSnippets&&Fe!==null&&tr&&(se=vr(tr,Fe,this.config.codeContextLines),se&&(se=B(se))),c={message:B(ke(T.message??"Unknown error")),line:Fe,code:se,stack:this.config.includeStackTrace&&T.stack?B(ke(T.stack)):null};}}let p=t.titlePath().filter(Boolean),v=path.relative(this.rootDir||".",t.location.file).replace(/\\/g,"/"),g=wo(p),u=p.join(" > "),m=v,h=xo(m,g,u),y=Io(l,m,t),f=y!=="mobile"&&d.apiCallsCount>0?"api":y,b=s==="flaky",x=ko(t.results),w=Xt(t.expectedStatus),M=Xt(a.status),A=null;if(this.config.includeArtifacts&&n!=="skipped"&&a.attachments){let _=path.dirname(this.config.outputPath),T=p[p.length-1]??t.title;A=ta(a.attachments,T,a.retry,_,this.runTimestamp||void 0,h);}let R=null;if(this.config.includeArtifacts&&n!=="skipped"&&a.attachments)try{let _=ia(a.attachments,{updatingSnapshots:this.updatingSnapshots,failureMessage:a.errors.map(T=>T.message??"").join(`
|
|
4361
|
+
`)});if(_.length>0){let T=path.dirname(this.config.outputPath),B=p[p.length-1]??t.title;R=ra(_,B,a.retry,T,this.runTimestamp||void 0,h,this.configDir||this.rootDir||process.cwd());}}catch{}let D=this.config.includeActionSteps&&a.steps?Ca(a.steps,a.startTime):null,k=_o(t),C={titlePath:p,title:u,status:n,duration:a.duration,startedAt:o,completedAt:i,retryCount:t.results.length-1,retry:a.retry,tags:l,failure:c,specFile:v,navigations:d.navigations,testId:h,filePath:m,suiteName:g,testType:f,isFlaky:b,retryStatus:x,expectedStatus:w,actualStatus:M,artifacts:A,visual:R,apiAssertions:d.apiAssertions,actions:D,networkRequestsFile:d.networkRequestsFile,networkRequestsCount:d.networkRequestsCount,consoleLogsFile:d.consoleLogsFile,consoleLogsCount:d.consoleLogsCount,apiCallsFile:d.apiCallsFile,apiCallsCount:d.apiCallsCount,apiStatusMix:d.apiStatusMix,browser:k,os:this.detectedOs||void 0,source:this.detectedSource||void 0},X=d.consoleLogsFile&&d.consoleLogsCount>0?j(d.consoleLogsFile):void 0,G=d.networkRequestsFile&&d.networkRequestsCount>0?j(d.networkRequestsFile):void 0,re=d.apiCallsFile&&d.apiCallsCount>0?j(d.apiCallsFile):void 0,Zt=re?Nt(re):void 0,Qt=!G&&re?Ft(re):void 0,er=d.apiAssertions&&d.apiAssertions.length>0?Bt(d.apiAssertions):void 0;this.cloudTestsBuffer.push({testId:h,title:u,status:n,duration:a.duration,suiteName:g,filePath:m,testType:f,isFlaky:b,startedAt:o,completedAt:i,tags:l,failure:c,retry:a.retry,retryCount:t.results.length-1,retryStatus:x,browser:k,os:this.detectedOs||void 0,source:this.detectedSource||void 0,...D&&D.length>0?{actions:D}:{},...d.navigations&&d.navigations.length>0?{navigations:d.navigations}:{},...X?{consoleLogs:X}:{},...G?{networkRequests:G}:Qt?{networkRequests:Qt}:{},...Zt?{apiCalls:Zt}:{},...er?{protocolAssertions:er}:{},...R&&R.length>0?{visual:R}:{}});try{let _=this.config.cloud?.uploadStrategy;if(this.cloudClient?.isCloudMode()&&this.cloudRunId&&(_==="realtime"||_==="both")){let T=this.cloudClient.getAccessToken();T&&Oa(this.cloudClient.getEndpoint(),T,this.cloudRunId,this.buildCloudTestPayload(C));}}catch{}if(this.activeReportMode==="streaming"&&this.streamingWriter){let _=Be(m,p,t.id??"",a.retry),T=a.retry===t.results.length-1,B={id:_,...w!=="passed"?{expectedStatus:w}:{},navigations:d.navigations,apiAssertions:d.apiAssertions,actions:D??[],artifacts:A,visual:R,failureDiagnostic:c,hasNetworkFile:d.networkRequestsFile!==null,networkRequestsCount:d.networkRequestsCount,hasConsoleFile:d.consoleLogsFile!==null,consoleLogsCount:d.consoleLogsCount,hasApiCallsFile:d.apiCallsFile!==null,apiCallsCount:d.apiCallsCount,startedAt:o};this.streamingWriter.writeTestDetail(_,B,{networkRequestsFile:d.networkRequestsFile,consoleLogsFile:d.consoleLogsFile,apiCallsFile:d.apiCallsFile});let ae={id:_,title:p[p.length-1]??t.title,titlePath:p,filePath:m,status:n,...w!=="passed"?{expectedStatus:w}:{},duration:a.duration,project:p[1]??"",retryIndex:a.retry,tags:l,hasNetworkData:d.networkRequestsCount>0,hasConsoleData:d.consoleLogsCount>0,hasArtifacts:A!==null,hasActionSteps:(D?.length??0)>0,visualCount:R?.length??0,visualFailedCount:R?.filter(E=>E.status==="failed").length??0,domChangeCount:R?.reduce((E,Z)=>E+(Z.domChangeCount??0),0)??0,...(()=>{let E=R?.find(Z=>Z.diff);return E?.diff?{visualDiffPath:E.diff}:{}})(),errorMessage:yo(c?.message),networkCount:d.networkRequestsCount,consoleCount:d.consoleLogsCount,actionCount:D?.length??0,testType:f,apiCallCount:d.apiCallsCount,...d.apiStatusMix?{apiStatusMix:d.apiStatusMix}:{},assertionsPassed:De(d.apiAssertions,"passed"),assertionsFailed:De(d.apiAssertions,"failed"),...(()=>{let E=rs(d.apiAssertions);return E?{firstFailedAssertion:E}:{}})(),isRetry:!T,retryGroupKey:Oe(m,p,t.id??"")};if(this.testIndex.push(ae),T)switch(this.summaryCounters.total++,n){case "passed":this.summaryCounters.passed++;break;case "failed":this.summaryCounters.failed++;break;case "flaky":this.summaryCounters.flaky++;break;case "skipped":this.summaryCounters.skipped++;break;case "timedout":this.summaryCounters.timedOut++;break;default:this.summaryCounters.interrupted++;break}this.upsertAggContribution(`${m}::${p.join(" > ")}`,ss(a.retry,re,d.apiAssertions,d.navigations,d.networkRequestsCount,d.consoleLogsCount,D)),(A||R)&&this.pendingArtifactEntries.push({testId:h,artifacts:A??{},visual:R,outputDir:path.dirname(this.config.outputPath)}),C.actions=null,C.apiAssertions=null,C.navigations=[],C.artifacts=null,C.failure=null,C.networkRequestsFile=null,C.consoleLogsFile=null,C.apiCallsFile=null;}this.activeReportMode!=="streaming"&&this.collectedTests.push(C),this.testCount++,this.checkMemoryPressure();}catch{}}async onEnd(t){try{let r=new Date().toISOString(),a=new Date(this.startedAt).getTime(),n=new Date(r).getTime()-a,o=this.activeReportMode==="streaming"?this.testIndex.some(l=>l.status!=="skipped"):this.collectedTests.some(l=>l.status!=="skipped");!this.fixtureDataReceived&&o&&process.stderr.write(`
|
|
4303
4362
|
\u26A0 TestRelic: No fixture data received from any test.
|
|
4304
4363
|
To enable network logs, video sync, and Test Navigation tracking, import the TestRelic fixture:
|
|
4305
4364
|
import { test, expect } from '@testrelic/playwright-analytics/fixture';
|
|
4306
4365
|
instead of:
|
|
4307
4366
|
import { test, expect } from '@playwright/test';
|
|
4308
4367
|
|
|
4309
|
-
`),this.config.captureNavigation?this.fixtureDataReceived&&!this.navigationsCaptured&&
|
|
4368
|
+
`),this.config.captureNavigation?this.fixtureDataReceived&&!this.navigationsCaptured&&o&&process.stderr.write(`[testrelic] Test Navigation: 0 navigation events captured this run. Navigation is recorded automatically on page.goto()/clicks; if you expected a navigation graph, ensure your tests drive page navigations (and use the '@testrelic/playwright-analytics/fixture' import).
|
|
4310
4369
|
`):process.stderr.write(`[testrelic] Test Navigation capture is disabled (captureNavigation: false). Remove the option or set it to true to capture the navigation graph.
|
|
4311
|
-
`),await J(()=>
|
|
4312
|
-
`);let
|
|
4370
|
+
`),await J(()=>Zr(),Ct,"Artifact flush");let i=null;if(this.config.includeArtifacts&&this.runTimestamp)try{let l=path.dirname(this.config.outputPath);i=fa(l,this.runTimestamp);let d=path.join(l,"artifact-manifest.json"),c=JSON.stringify(i),p=d+".tmp";fs.writeFileSync(p,c,"utf-8"),fs.renameSync(p,d);}catch{}if(this.activeReportMode==="streaming"&&this.streamingWriter)await J(()=>this.finalizeStreamingReport(r,n,t,i),St,"Report finalization");else {let l=this.buildTimeline(),d=new Map;for(let u of this.collectedTests){let m=d.get(u.testId);(!m||u.retry>m.retry)&&d.set(u.testId,u);}let c=Array.from(d.values()),p=Sa(c,l.length),v={schemaVersion:ze,testRunId:this.testRunId,startedAt:this.startedAt,completedAt:r,totalDuration:n,summary:p,ci:U(),metadata:this.config.metadata,timeline:l,shardRunIds:null},g=je(p,c);if(this.writeReport(v),await J(()=>mt(v,this.config,i,g),Ct,"HTML report write"),Rt(p,this.config.outputPath,this.config.htmlReportPath,this.config.quiet,g),this.cloudClient){let u=this.collectArtifactEntries(),m=this.cloudTestsBuffer.slice();this.cloudTestsBuffer.length=0;let h=await J(()=>Kt(this.cloudClient,this.config.cloud,this.config.cloud?.uploadStrategy,this.testRunId,this.cloudRunId,v,r,n,p,u,m),St,"Cloud upload");this.cloudReceipt=Jt(this.cloudReceipt,h,this.testRunId);}}}catch{}finally{await this.disposeCloudClient();}}async disposeCloudClient(){let t=this.cloudClient;t&&(this.cloudClient=null,await J(()=>t.dispose(),ya,"Cloud client shutdown"));}collectArtifactEntries(){if(this.activeReportMode==="streaming")return this.pendingArtifactEntries;let t=path.dirname(this.config.outputPath),r=[];for(let a of this.collectedTests)(a.artifacts||a.visual)&&r.push({testId:a.testId,artifacts:a.artifacts??{},visual:a.visual,outputDir:t});return r}async finalizeStreamingReport(t,r,a,s){if(!this.streamingWriter)return;this.summaryCounters={total:0,passed:0,failed:0,flaky:0,skipped:0,timedOut:0,interrupted:0,totalApiCalls:0,totalAssertions:0,totalNavigations:0,totalNetworkRequests:0,totalConsoleLogs:0,totalActionSteps:0,visualChecks:0,visualFailures:0,visualDomChanges:0};let n=new Map,o=new Map;for(let f of this.testIndex){let b=`${f.filePath}::${f.titlePath.join(" > ")}`,x=n.get(b);(x===void 0||f.retryIndex>x)&&n.set(b,f.retryIndex);}let i=0,l=[];for(let f of this.testIndex){let b=`${f.filePath}::${f.titlePath.join(" > ")}`,x=n.get(b);if(f.isRetry=f.retryIndex<x,f.isRetry)continue;switch(l.push(f),i++,this.summaryCounters.total++,f.status){case "passed":this.summaryCounters.passed++;break;case "failed":this.summaryCounters.failed++;break;case "flaky":this.summaryCounters.flaky++;break;case "skipped":this.summaryCounters.skipped++;break;case "timedout":this.summaryCounters.timedOut++;break;default:this.summaryCounters.interrupted++;break}this.summaryCounters.visualChecks+=f.visualCount??0,this.summaryCounters.visualFailures+=f.visualFailedCount??0,this.summaryCounters.visualDomChanges+=f.domChangeCount??0;let w=o.get(f.filePath);switch(w||(w={filePath:f.filePath,total:0,passed:0,failed:0,flaky:0,skipped:0,timedOut:0},o.set(f.filePath,w)),w.total++,f.status){case "passed":w.passed++;break;case "failed":w.failed++;break;case "flaky":w.flaky++;break;case "skipped":w.skipped++;break;case "timedout":w.timedOut++;break}}let d=Array.from(o.values()),c=To();for(let f of this.streamingTestAgg.values()){c.volApiCalls+=f.apiCalls,c.volAssertions+=f.assertions,c.volNavigations+=f.navigations,c.volNetworkRequests+=f.networkRequests,c.volConsoleLogs+=f.consoleLogs,c.volActionSteps+=f.actionSteps;for(let b in f.methodCounts)c.methodCounts[b]=(c.methodCounts[b]??0)+f.methodCounts[b];c.statusRanges["2xx"]+=f.statusRanges["2xx"],c.statusRanges["3xx"]+=f.statusRanges["3xx"],c.statusRanges["4xx"]+=f.statusRanges["4xx"],c.statusRanges["5xx"]+=f.statusRanges["5xx"],c.statusRanges.error+=f.statusRanges.error,c.passedAssertions+=f.passedAssertions,c.failedAssertions+=f.failedAssertions;for(let b in f.actionCategories)c.actionCategoryCounts[b]=(c.actionCategoryCounts[b]??0)+f.actionCategories[b];for(let b of f.apiUrls){if(c.apiUrlSet.size>=Le)break;c.apiUrlSet.add(b);}for(let b of f.navUrls){if(c.navUrlSet.size>=Le)break;c.navUrlSet.add(b);}for(let b of f.responseTimes){if(c.responseTimes.length>=os)break;c.responseTimes.push(b);}}this.summaryCounters.totalApiCalls=c.volApiCalls,this.summaryCounters.totalAssertions=c.volAssertions,this.summaryCounters.totalNavigations=c.volNavigations,this.summaryCounters.totalNetworkRequests=c.volNetworkRequests,this.summaryCounters.totalConsoleLogs=c.volConsoleLogs,this.summaryCounters.totalActionSteps=c.volActionSteps,this.streamingWriter.writeIndex(this.testIndex),this.streamingWriter.writeCompactIndex(this.testIndex);let p={reporterTotal:this.summaryCounters.total,indexTotal:i,playwrightStatus:a.status,isValid:this.summaryCounters.total===i};p.isValid||process.stderr.write(`[testrelic] WARNING: Summary count mismatch \u2014 reporter: ${p.reporterTotal}, index: ${p.indexTotal}
|
|
4371
|
+
`);let v={total:this.summaryCounters.total,passed:this.summaryCounters.passed,failed:this.summaryCounters.failed,flaky:this.summaryCounters.flaky,skipped:this.summaryCounters.skipped,timedout:this.summaryCounters.timedOut,totalApiCalls:this.summaryCounters.totalApiCalls,uniqueApiUrls:c.apiUrlSet.size,apiCallsByMethod:{...c.methodCounts},apiCallsByStatusRange:{"2xx":c.statusRanges["2xx"],"3xx":c.statusRanges["3xx"],"4xx":c.statusRanges["4xx"],"5xx":c.statusRanges["5xx"],error:c.statusRanges.error},apiResponseTime:Co(c.responseTimes),totalAssertions:this.summaryCounters.totalAssertions,passedAssertions:c.passedAssertions,failedAssertions:c.failedAssertions,totalNavigations:this.summaryCounters.totalNavigations,uniqueNavigationUrls:c.navUrlSet.size,totalTimelineSteps:i,totalActionSteps:this.summaryCounters.totalActionSteps,actionStepsByCategory:{...c.actionCategoryCounts},visualChecks:this.summaryCounters.visualChecks,visualFailures:this.summaryCounters.visualFailures,visualDomChanges:this.summaryCounters.visualDomChanges},g={testRunId:this.testRunId,startedAt:this.startedAt,completedAt:t,totalDuration:r,...this.summaryCounters,metadata:this.config.metadata,reportMode:"streaming",files:d,enrichedSummary:v,validation:p,writeErrors:this.streamingWriter.getWriteErrors(),cloudUpload:this.cloudReceipt};this.streamingWriter.writeSummary(g);let u={schemaVersion:"2.0",generatedAt:new Date().toISOString(),reportMode:"streaming",summaryFile:"summary.json",indexFile:"index.json",testsDir:"tests",artifactsDir:"artifacts",testCount:this.testIndex.length,totalSizeBytes:this.streamingWriter.computeTotalSize()};this.streamingWriter.writeManifest(u);let m=je(v,l);await mt(this.buildStreamingReport(g,v,t,r),this.config,s,m),Rt(v,this.config.outputPath,this.config.htmlReportPath,this.config.quiet,m);let h=this.streamingWriter.getReportDir();process.stderr.write(`[testrelic] Streaming report written to ${h}
|
|
4313
4372
|
[testrelic] ${this.testIndex.length} test detail files on disk
|
|
4314
|
-
[testrelic] View report: npx testrelic serve ${
|
|
4373
|
+
[testrelic] View report: npx testrelic serve ${h}
|
|
4315
4374
|
`),this.streamingWriter.getWriteErrors().length>0&&process.stderr.write(`[testrelic] WARNING: ${this.streamingWriter.getWriteErrors().length} write error(s) during streaming
|
|
4316
|
-
`);let
|
|
4375
|
+
`);let y=this.streamingWriter;try{if(this.cloudClient){let f=this.buildStreamingReport(g,v,t,r),b=this.collectArtifactEntries(),x=this.cloudTestsBuffer.slice();this.cloudTestsBuffer.length=0;let w=await Kt(this.cloudClient,this.config.cloud,this.config.cloud?.uploadStrategy,this.testRunId,this.cloudRunId,f,t,r,v,b,x);this.cloudReceipt=Jt(this.cloudReceipt,w,this.testRunId);let M={...g,cloudUpload:this.cloudReceipt};try{y.writeSummary(M);}catch{}}}finally{y.dispose();}this.testIndex.length=0,this.collectedTests.length=0,this.pendingArtifactEntries.length=0,this.cloudTestsBuffer.length=0,this.streamingWriter=null,this.cloudClient=null;}buildStreamingReport(t,r,a,s){return {schemaVersion:ze,testRunId:this.testRunId,startedAt:this.startedAt,completedAt:a,totalDuration:s,summary:r,ci:U(),metadata:this.config.metadata,timeline:[],shardRunIds:null}}printsToStdio(){return false}checkMemoryPressure(){try{let t=process.memoryUsage(),r=t.heapUsed/1024/1024;if(r<200)return;let a=t.heapUsed/t.heapTotal;a>.9&&this.activeReportMode==="embedded"?(process.stderr.write(`[testrelic] WARNING: High memory (${Math.round(r)} MB). Auto-switching to streaming mode.
|
|
4317
4376
|
`),this.switchToStreamingMode()):a>.8&&r>=500&&!this.memoryPressureWarned&&(this.memoryPressureWarned=!0,process.stderr.write(`[testrelic] WARNING: Memory pressure detected (${Math.round(r)} MB used).
|
|
4318
|
-
`));}catch{}}switchToStreamingMode(){try{if(this.activeReportMode==="streaming")return;this.activeReportMode="streaming";let t=path.dirname(this.config.outputPath);this.streamingWriter=new ie(t);for(let r of this.collectedTests){let a=Be(r.filePath,r.titlePath,r.testId,r.retry),
|
|
4319
|
-
`)[0]??null,networkCount:r.networkRequestsCount,consoleCount:r.consoleLogsCount,actionCount:r.actions?.length??0,testType:r.testType,apiCallCount:r.apiCallsCount,...r.apiStatusMix?{apiStatusMix:r.apiStatusMix}:
|
|
4377
|
+
`));}catch{}}switchToStreamingMode(){try{if(this.activeReportMode==="streaming")return;this.activeReportMode="streaming";let t=path.dirname(this.config.outputPath);this.streamingWriter=new ie(t);for(let r of this.collectedTests){let a=Be(r.filePath,r.titlePath,r.testId,r.retry),s=r.apiCallsFile&&r.apiCallsCount>0?j(r.apiCallsFile):void 0,n={id:a,...r.expectedStatus!=="passed"?{expectedStatus:r.expectedStatus}:{},navigations:r.navigations??[],apiAssertions:r.apiAssertions??[],actions:r.actions??[],artifacts:r.artifacts,failureDiagnostic:r.failure,hasNetworkFile:r.networkRequestsFile!==null,networkRequestsCount:r.networkRequestsCount,hasConsoleFile:r.consoleLogsFile!==null,consoleLogsCount:r.consoleLogsCount,hasApiCallsFile:r.apiCallsFile!==null,apiCallsCount:r.apiCallsCount,startedAt:r.startedAt};this.streamingWriter.writeTestDetail(a,n,{networkRequestsFile:r.networkRequestsFile,consoleLogsFile:r.consoleLogsFile,apiCallsFile:r.apiCallsFile});let o={id:a,title:r.titlePath[r.titlePath.length-1]??r.title,titlePath:r.titlePath,filePath:r.filePath,status:r.status,...r.expectedStatus!=="passed"?{expectedStatus:r.expectedStatus}:{},duration:r.duration,project:r.titlePath[1]??"",retryIndex:r.retry,tags:r.tags,hasNetworkData:r.networkRequestsCount>0,hasConsoleData:r.consoleLogsCount>0,hasArtifacts:r.artifacts!==null,hasActionSteps:(r.actions?.length??0)>0,errorMessage:r.failure?.message?.split(`
|
|
4378
|
+
`)[0]??null,networkCount:r.networkRequestsCount,consoleCount:r.consoleLogsCount,actionCount:r.actions?.length??0,testType:r.testType,apiCallCount:r.apiCallsCount,...r.apiStatusMix?{apiStatusMix:r.apiStatusMix}:s?{apiStatusMix:So(s)}:{},assertionsPassed:De(r.apiAssertions,"passed"),assertionsFailed:De(r.apiAssertions,"failed"),...(()=>{let i=rs(r.apiAssertions);return i?{firstFailedAssertion:i}:{}})(),isRetry:!1,retryGroupKey:Oe(r.filePath,r.titlePath,r.testId)};switch(this.testIndex.push(o),this.summaryCounters.total++,r.status){case "passed":this.summaryCounters.passed++;break;case "failed":this.summaryCounters.failed++;break;case "flaky":this.summaryCounters.flaky++;break;case "skipped":this.summaryCounters.skipped++;break;case "timedout":this.summaryCounters.timedOut++;break;default:this.summaryCounters.interrupted++;break}this.upsertAggContribution(`${r.filePath}::${r.titlePath.join(" > ")}`,ss(r.retry,s,r.apiAssertions??[],r.navigations??[],r.networkRequestsCount,r.consoleLogsCount,r.actions??null));}this.collectedTests.length=0;}catch{}}buildTimeline(){let t=this.collectedTests.map(r=>({titlePath:r.titlePath,title:r.title,status:r.status,duration:r.duration,startedAt:r.startedAt,completedAt:r.completedAt,retryCount:r.retryCount,retry:r.retry,tags:r.tags,failure:r.failure,specFile:r.specFile,navigations:r.navigations,apiCalls:null,apiAssertions:r.apiAssertions,testId:r.testId,filePath:r.filePath,suiteName:r.suiteName,testType:r.testType,isFlaky:r.isFlaky,retryStatus:r.retryStatus,expectedStatus:r.expectedStatus,actualStatus:r.actualStatus,artifacts:r.artifacts,networkRequests:null,actions:r.actions,consoleLogs:null}));return ka(t,{navigationTypes:this.config.navigationTypes})}readJsonlFile(t){if(!t)return null;let r=j(t);return r.length>0?r:null}toTestResult(t,r){let a=null,s=null,n=null;return r?.loadFiles&&(a=this.readJsonlFile(t.networkRequestsFile),s=this.readJsonlFile(t.consoleLogsFile),n=this.readJsonlFile(t.apiCallsFile)),{title:t.title,status:t.status,duration:t.duration,startedAt:t.startedAt,completedAt:t.completedAt,retryCount:t.retryCount,tags:t.tags,failure:t.failure,testId:t.testId,filePath:t.filePath,suiteName:t.suiteName,testType:t.testType,isFlaky:t.isFlaky,retryStatus:t.retryStatus,expectedStatus:t.expectedStatus,actualStatus:t.actualStatus,artifacts:t.artifacts,visual:t.visual,networkRequests:a,apiCalls:n,apiAssertions:t.apiAssertions,actions:t.actions??null,consoleLogs:s}}buildCloudTestPayload(t){let r={title:t.title,status:t.status,duration:t.duration,startedAt:t.startedAt,completedAt:t.completedAt,retry:t.retry,retryCount:t.retryCount,retryStatus:t.retryStatus,tags:t.tags,failure:t.failure,testId:t.testId,filePath:t.filePath,suiteName:t.suiteName,testType:t.testType,isFlaky:t.isFlaky,expectedStatus:t.expectedStatus,actualStatus:t.actualStatus,artifacts:t.artifacts,visual:t.visual??[],actions:t.actions??[],navigations:t.navigations??[],steps:t.actions??[],browser:t.browser,os:t.os,source:t.source};if(t.apiAssertions&&t.apiAssertions.length>0&&(r.protocolAssertions=Bt(t.apiAssertions)),t.consoleLogsFile&&(r.consoleLogs=j(t.consoleLogsFile)),t.networkRequestsFile&&(r.networkRequests=j(t.networkRequestsFile)),t.apiCallsFile){let a=j(t.apiCallsFile);r.apiCalls=Nt(a),(!r.networkRequests||r.networkRequests.length===0)&&(r.networkRequests=Ft(a));}return r}writeReport(t){try{let r=JSON.stringify(t),a=this.config.outputPath,s=path.dirname(a);fs.mkdirSync(s,{recursive:!0});let n=a+".tmp";fs.writeFileSync(n,r,"utf-8"),fs.renameSync(n,a);}catch(r){process.stderr.write(`[testrelic] Failed to write report: ${r instanceof Error?r.message:String(r)}
|
|
4320
4379
|
`);}}};module.exports=Ne;//# sourceMappingURL=reporter-entry.cjs.map
|
|
4321
4380
|
//# sourceMappingURL=reporter-entry.cjs.map
|