@testrelic/playwright-analytics 2.2.6 → 2.2.7
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/api-fixture.cjs +1 -1
- package/dist/api-fixture.cjs.map +1 -1
- package/dist/api-fixture.js +1 -1
- package/dist/api-fixture.js.map +1 -1
- package/dist/fixture.cjs +1 -1
- package/dist/fixture.cjs.map +1 -1
- package/dist/fixture.js +1 -1
- package/dist/fixture.js.map +1 -1
- package/dist/index.cjs +553 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +553 -84
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var crypto=require('crypto'),fs=require('fs'),path=require('path'),core=require('@testrelic/core'),child_process=require('child_process'),zlib=require('zlib'),test=require('@playwright/test'),perf_hooks=require('perf_hooks');var
|
|
2
|
-
`);if(t<1||t>s.length)return null;let a=Math.max(1,t-r),l=Math.min(s.length,t+r),
|
|
3
|
-
`)}catch{return null}}function
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var crypto=require('crypto'),fs=require('fs'),path=require('path'),core=require('@testrelic/core'),child_process=require('child_process'),http=require('http'),zlib=require('zlib'),test=require('@playwright/test'),perf_hooks=require('perf_hooks');var er=".testrelic",rr=5,nr=new Set(["__proto__","constructor","prototype"]),At=Object.freeze({apiKey:null,endpoint:"https://api.testrelic.com/api/v1",uploadStrategy:"batch",timeout:3e4,projectName:null,queueMaxAge:6048e5,queueDirectory:".testrelic/queue"}),sr={s:1e3,m:60*1e3,h:3600*1e3,d:1440*60*1e3};function It(e){let t=path.resolve(e);for(let r=0;r<=rr;r++){let n=path.join(t,er);if(fs.existsSync(n))return n;let s=path.dirname(t);if(s===t)break;t=s;}return null}function Nt(e){try{let t=fs.readFileSync(e,"utf-8"),r=JSON.parse(t);return typeof r!="object"||r===null||Array.isArray(r)||!Lt(r)?null:r}catch{return null}}function Lt(e){for(let t of Object.keys(e)){if(nr.has(t))return false;let r=e[t];if(typeof r=="object"&&r!==null&&!Array.isArray(r)&&!Lt(r))return false}return true}function Et(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 rt(e){let t=Object.create(null);for(let r of Object.keys(e)){let n=e[r];typeof n=="string"&&n.startsWith("$")?t[r]=Et(n):typeof n=="object"&&n!==null&&!Array.isArray(n)?t[r]=rt(n):t[r]=n;}return t}function _t(e){let t=/^(\d+)\s*([smhd])$/.exec(e.trim());if(!t)return null;let r=parseInt(t[1],10),n=t[2],s=sr[n];return !s||r<=0?null:r*s}function Bt(e,t){let r=Object.create(null);if(Object.assign(r,At),e){let o=e.cloud;o&&typeof o=="object"&&(typeof o.endpoint=="string"&&(r.endpoint=o.endpoint),typeof o.upload=="string"&&(r.uploadStrategy=o.upload),typeof o.timeout=="number"&&(r.timeout=o.timeout),typeof o.apiKey=="string"&&o.apiKey.length>0&&(r.apiKey=o.apiKey));let c=e.project;c&&typeof c=="object"&&typeof c.name=="string"&&(r.projectName=c.name);let d=e.queue;if(d&&typeof d=="object"){if(typeof d.maxAge=="string"){let p=_t(d.maxAge);p!==null&&(r.queueMaxAge=p);}typeof d.directory=="string"&&(r.queueDirectory=d.directory);}}if(t){if(typeof t.apiKey=="string"&&t.apiKey.length>0){let o=t.apiKey.startsWith("$")?Et(t.apiKey):t.apiKey;o&&(r.apiKey=o);}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.projectName=="string"&&(r.projectName=t.projectName),typeof t.queueMaxAge=="string"){let o=_t(t.queueMaxAge);o!==null&&(r.queueMaxAge=o);}typeof t.queueDirectory=="string"&&(r.queueDirectory=t.queueDirectory);}let n=process.env.TESTRELIC_API_KEY;n&&n.length>0&&(r.apiKey=n);let s=process.env.TESTRELIC_CLOUD_ENDPOINT;s&&core.isValidEndpointUrl(s)&&(r.endpoint=s);let a=process.env.TESTRELIC_UPLOAD_STRATEGY;a&&["batch","realtime","both"].includes(a)&&(r.uploadStrategy=a);let l=process.env.TESTRELIC_CLOUD_TIMEOUT;if(l){let o=parseInt(l,10);!isNaN(o)&&o>=1e3&&o<=12e4&&(r.timeout=o);}let i=Object.freeze(r);return core.isValidCloudConfig(i)?i:At}var lr=[/AKIA[A-Z0-9]{16}/g,/Bearer\s+[A-Za-z0-9\-._~+/]+=*/g,/-----BEGIN\s+(RSA\s+)?PRIVATE\sKEY-----[\s\S]*?-----END/g,/\/\/[^:]+:[^@]+@/g],dr=["authorization","cookie","set-cookie","x-api-key"],cr=["password","secret","token","apiKey","api_key"];function Mt(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??[...dr],t.redactBodyFields=e?.redactBodyFields??[...cr],t.apiIncludeUrls=e?.apiIncludeUrls??[],t.apiExcludeUrls=e?.apiExcludeUrls??[],Object.freeze(t)}function Pt(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.navigationTypes=e?.navigationTypes??null,t.redactPatterns=[...lr,...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 n=It(process.cwd()),s=n?Nt(n):null,a=s?rt(s):null,l=Bt(a,e?.cloud);return t.cloud=l.apiKey?l:null,Object.freeze(t)}var nt="1.3.0";function qt(e,t,r){try{let s=fs.readFileSync(e,"utf-8").split(`
|
|
2
|
+
`);if(t<1||t>s.length)return null;let a=Math.max(1,t-r),l=Math.min(s.length,t+r),i=[];for(let o=a;o<=l;o++){let c=o===t?">":" ",d=String(o).padStart(String(l).length," ");i.push(`${c} ${d} | ${s[o-1]}`);}return i.join(`
|
|
3
|
+
`)}catch{return null}}function Dt(e){return t=>{let r=t;for(let n of e)if(typeof n=="string"){let s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");r=r.replace(new RegExp(s,"g"),"[REDACTED]");}else {let s=n.flags.includes("g")?n.flags:n.flags+"g",a=new RegExp(n.source,s);r=r.replace(a,"[REDACTED]");}return r}}function ur(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 fr(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 gr(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 hr(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 mr(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 vr=[ur,fr,gr,hr,mr];function _(e){let t=process.env;for(let r of vr){let n=r(t);if(n)return n}return null}var Ot=`
|
|
4
4
|
/* Theme Variables */
|
|
5
5
|
:root,[data-theme="dark"]{
|
|
6
6
|
--bg:#0f1117;--bg-1:#161b22;--bg-2:#1c2128;--bg-3:#21262d;--bg-code:#13111c;
|
|
@@ -511,6 +511,42 @@ body{
|
|
|
511
511
|
.detail-duration{font-size:20px}
|
|
512
512
|
}
|
|
513
513
|
|
|
514
|
+
/* \u2500\u2500 Test Artifacts Section \u2500\u2500 */
|
|
515
|
+
#artifact-section{margin-top:32px;margin-bottom:32px}
|
|
516
|
+
.as-header{display:flex;align-items:center;gap:10px;margin-bottom:14px}
|
|
517
|
+
.as-title{font-size:14px;font-weight:700;color:var(--fg)}
|
|
518
|
+
.as-total{font-size:11px;color:var(--fg-2);margin-left:auto}
|
|
519
|
+
.as-empty{text-align:center;padding:32px 20px;color:var(--fg-2);font-size:12px;font-style:italic;border:1px dashed var(--bd-m);border-radius:10px}
|
|
520
|
+
.as-runs{border:1px solid var(--bd);border-radius:10px;overflow:hidden;background:var(--bg-1)}
|
|
521
|
+
.as-run{border-bottom:1px solid var(--bd-s)}
|
|
522
|
+
.as-run:last-child{border-bottom:none}
|
|
523
|
+
.as-run-row{display:flex;align-items:center;gap:8px;padding:10px 14px;cursor:pointer;transition:background .1s}
|
|
524
|
+
.as-run-row:hover{background:var(--hvr)}
|
|
525
|
+
.as-run-arrow{font-size:9px;color:var(--fg-2);transition:transform .15s;display:inline-block;flex-shrink:0}
|
|
526
|
+
.as-run.expanded .as-run-arrow{transform:rotate(90deg)}
|
|
527
|
+
.as-run-label{font-size:12px;font-weight:500;color:var(--fg)}
|
|
528
|
+
.as-current-tag{font-size:9px;font-weight:600;padding:1px 6px;border-radius:4px;background:rgba(3,183,156,0.12);color:#2dd4a8;margin-left:4px}
|
|
529
|
+
.as-run-meta{font-size:11px;color:var(--fg-2);margin-left:auto;white-space:nowrap}
|
|
530
|
+
.as-run-legacy .as-run-label{font-style:italic;color:var(--fg-2)}
|
|
531
|
+
.as-run-detail{padding:0 14px 14px;background:var(--bg-2);border-top:1px solid var(--bd-s)}
|
|
532
|
+
.as-no-tests{padding:12px;text-align:center;font-size:11px;color:var(--fg-2);font-style:italic}
|
|
533
|
+
.as-test{padding:8px 0;border-bottom:1px solid var(--bd-xs)}
|
|
534
|
+
.as-test:last-child{border-bottom:none}
|
|
535
|
+
.as-test-name{font-size:11px;font-weight:600;color:var(--fg-1);margin-bottom:6px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
|
|
536
|
+
.as-test-files{display:flex;flex-wrap:wrap;gap:10px}
|
|
537
|
+
.as-file{display:flex;flex-direction:column;gap:4px;max-width:200px}
|
|
538
|
+
.as-thumb{max-width:180px;max-height:120px;border-radius:6px;cursor:pointer;border:1px solid var(--bd);transition:border-color .15s;object-fit:contain}
|
|
539
|
+
.as-thumb:hover{border-color:#03b79c}
|
|
540
|
+
.as-video-wrap{border-radius:6px;overflow:hidden;border:1px solid var(--bd);background:#000;max-width:180px}
|
|
541
|
+
.as-video-wrap video{width:100%;display:block;max-height:120px}
|
|
542
|
+
.as-file-info{font-size:9px;color:var(--fg-2)}
|
|
543
|
+
.as-file-icon{margin-right:4px}
|
|
544
|
+
.as-loading{text-align:center;padding:24px;color:var(--fg-2);font-size:12px}
|
|
545
|
+
.as-delete-btn{font-size:10px;padding:3px 10px;border-radius:4px;border:1px solid rgba(239,68,68,0.3);background:rgba(239,68,68,0.08);color:#ef4444;cursor:pointer;font-weight:500;transition:all .15s;flex-shrink:0}
|
|
546
|
+
.as-delete-btn:hover{background:rgba(239,68,68,0.15);border-color:rgba(239,68,68,0.5)}
|
|
547
|
+
.as-delete-all-btn{font-size:10px;padding:3px 12px;border-radius:4px;border:1px solid rgba(239,68,68,0.3);background:rgba(239,68,68,0.08);color:#ef4444;cursor:pointer;font-weight:600;transition:all .15s}
|
|
548
|
+
.as-delete-all-btn:hover{background:rgba(239,68,68,0.15);border-color:rgba(239,68,68,0.5)}
|
|
549
|
+
|
|
514
550
|
/* \u2500\u2500 Print \u2500\u2500 */
|
|
515
551
|
@media print{
|
|
516
552
|
body{background:#fff;color:#000}
|
|
@@ -521,15 +557,29 @@ body{
|
|
|
521
557
|
print-color-adjust:exact;-webkit-print-color-adjust:exact;
|
|
522
558
|
}
|
|
523
559
|
}
|
|
524
|
-
|
|
560
|
+
/* Loading Overlay */
|
|
561
|
+
.loading-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:var(--bg);z-index:9999;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px}
|
|
562
|
+
.loading-spinner{width:36px;height:36px;border:3px solid var(--bd-l);border-top-color:var(--fg-1);border-radius:50%;animation:spin .8s linear infinite}
|
|
563
|
+
.loading-text{font:13px/1 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;color:var(--fg-1)}
|
|
564
|
+
@keyframes spin{to{transform:rotate(360deg)}}
|
|
565
|
+
/* Global scrollbar styling */
|
|
566
|
+
*{scrollbar-width:thin;scrollbar-color:var(--scroll-thumb) transparent}
|
|
567
|
+
::-webkit-scrollbar{width:6px;height:6px}
|
|
568
|
+
::-webkit-scrollbar-track{background:transparent}
|
|
569
|
+
::-webkit-scrollbar-thumb{background:var(--scroll-thumb);border-radius:3px}
|
|
570
|
+
::-webkit-scrollbar-thumb:hover{background:var(--fg-2)}
|
|
571
|
+
::-webkit-scrollbar-corner{background:transparent}
|
|
572
|
+
/* Virtual grid sentinel */
|
|
573
|
+
.vg-sentinel{height:1px}
|
|
574
|
+
`;var Ft=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 196 247" fill="none">
|
|
525
575
|
<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)"/>
|
|
526
576
|
<defs><linearGradient id="paint0_linear_55_11" x1="98" y1="0.000244141" x2="98" y2="247" gradientUnits="userSpaceOnUse">
|
|
527
577
|
<stop stop-color="#03B79C"/><stop offset="0.504808" stop-color="#4EDAA4"/><stop offset="0.865285" stop-color="#84F3AA"/>
|
|
528
|
-
</linearGradient></defs></svg>`,
|
|
578
|
+
</linearGradient></defs></svg>`,Ht=`<svg width="32" height="40" viewBox="0 0 196 247" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
529
579
|
<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)"/>
|
|
530
580
|
<defs><linearGradient id="paint0_linear_55_11" x1="98" y1="0.000244141" x2="98" y2="247" gradientUnits="userSpaceOnUse">
|
|
531
581
|
<stop stop-color="#03B79C"/><stop offset="0.504808" stop-color="#4EDAA4"/><stop offset="0.865285" stop-color="#84F3AA"/>
|
|
532
|
-
</linearGradient></defs></svg>`;var
|
|
582
|
+
</linearGradient></defs></svg>`;var Ut=`
|
|
533
583
|
/* \u2500\u2500 Utilities \u2500\u2500 */
|
|
534
584
|
function esc(s){if(!s)return '';return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,''')}
|
|
535
585
|
function stripAnsi(s){return s?s.replace(/\\u001b\\[[0-9;]*m/g,'').replace(/\\x1b\\[[0-9;]*m/g,''):''}
|
|
@@ -618,18 +668,33 @@ body{
|
|
|
618
668
|
summaryEl.innerHTML=h;
|
|
619
669
|
}
|
|
620
670
|
|
|
621
|
-
/* \u2500\u2500
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
671
|
+
/* \u2500\u2500 Virtual Grid: progressive chunked rendering \u2500\u2500 */
|
|
672
|
+
var _vgGroups=[];
|
|
673
|
+
var _vgRenderedTo=0;
|
|
674
|
+
var _vgChunkSize=10;
|
|
675
|
+
var _vgSentinel=null;
|
|
676
|
+
var _vgObserver=null;
|
|
677
|
+
|
|
678
|
+
function _vgBuildGroups(filtered){
|
|
679
|
+
var groups=[];var lastFile='';var g=null;
|
|
626
680
|
for(var i=0;i<filtered.length;i++){
|
|
627
681
|
var t=filtered[i];
|
|
628
682
|
if(t.filePath!==lastFile){
|
|
629
|
-
|
|
630
|
-
|
|
683
|
+
g={filePath:t.filePath,tests:[]};
|
|
684
|
+
groups.push(g);
|
|
631
685
|
lastFile=t.filePath;
|
|
632
686
|
}
|
|
687
|
+
g.tests.push(t);
|
|
688
|
+
}
|
|
689
|
+
return groups;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
function _vgRenderGroupHtml(g){
|
|
693
|
+
var h='<div class="file-group">';
|
|
694
|
+
h+='<div class="file-group-header">'+esc(g.filePath)+'</div>';
|
|
695
|
+
h+='<div class="file-group-card">';
|
|
696
|
+
for(var i=0;i<g.tests.length;i++){
|
|
697
|
+
var t=g.tests[i];
|
|
633
698
|
h+='<div class="test-row" data-testid="'+esc(t.testId)+'">';
|
|
634
699
|
h+='<div class="status-indicator si-'+t.status+'"></div>';
|
|
635
700
|
h+='<div class="test-row-info">';
|
|
@@ -648,8 +713,66 @@ body{
|
|
|
648
713
|
h+='<svg class="test-row-arrow" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>';
|
|
649
714
|
h+='</div>';
|
|
650
715
|
}
|
|
651
|
-
|
|
716
|
+
h+='</div></div>';
|
|
717
|
+
return h;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
function _vgRenderChunk(){
|
|
721
|
+
if(_vgRenderedTo>=_vgGroups.length){
|
|
722
|
+
if(_vgSentinel)_vgSentinel.style.display='none';
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
var end=Math.min(_vgRenderedTo+_vgChunkSize,_vgGroups.length);
|
|
726
|
+
var frag=document.createDocumentFragment();
|
|
727
|
+
var tmp=document.createElement('div');
|
|
728
|
+
var h='';
|
|
729
|
+
for(var i=_vgRenderedTo;i<end;i++){h+=_vgRenderGroupHtml(_vgGroups[i]);}
|
|
730
|
+
tmp.innerHTML=h;
|
|
731
|
+
while(tmp.firstChild)frag.appendChild(tmp.firstChild);
|
|
732
|
+
/* Insert before sentinel */
|
|
733
|
+
if(_vgSentinel&&_vgSentinel.parentNode){
|
|
734
|
+
_vgSentinel.parentNode.insertBefore(frag,_vgSentinel);
|
|
735
|
+
}
|
|
736
|
+
_vgRenderedTo=end;
|
|
737
|
+
if(_vgRenderedTo>=_vgGroups.length&&_vgSentinel){
|
|
738
|
+
_vgSentinel.style.display='none';
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
function _vgSetupObserver(){
|
|
743
|
+
if(_vgObserver){_vgObserver.disconnect();_vgObserver=null;}
|
|
744
|
+
if(!_vgSentinel)return;
|
|
745
|
+
if(typeof IntersectionObserver==='undefined'){
|
|
746
|
+
/* Fallback: render everything */
|
|
747
|
+
while(_vgRenderedTo<_vgGroups.length)_vgRenderChunk();
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
_vgObserver=new IntersectionObserver(function(entries){
|
|
751
|
+
if(entries[0].isIntersecting)_vgRenderChunk();
|
|
752
|
+
},{rootMargin:'600px'});
|
|
753
|
+
_vgObserver.observe(_vgSentinel);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/* \u2500\u2500 Render: Test Grid \u2500\u2500 */
|
|
757
|
+
function renderTestGrid(){
|
|
758
|
+
if(_vgObserver){_vgObserver.disconnect();_vgObserver=null;}
|
|
759
|
+
var filtered=getFilteredTests();
|
|
760
|
+
if(filtered.length===0){testGridEl.innerHTML='<div class="no-tests">No tests match your filters</div>';_vgGroups=[];return;}
|
|
761
|
+
_vgGroups=_vgBuildGroups(filtered);
|
|
762
|
+
_vgRenderedTo=0;
|
|
763
|
+
/* Render initial batch directly, then progressively load the rest */
|
|
764
|
+
var initCount=Math.min(_vgChunkSize,_vgGroups.length);
|
|
765
|
+
var h='';
|
|
766
|
+
for(var i=0;i<initCount;i++){h+=_vgRenderGroupHtml(_vgGroups[i]);}
|
|
767
|
+
_vgRenderedTo=initCount;
|
|
768
|
+
h+='<div class="vg-sentinel" id="vg-sentinel"></div>';
|
|
652
769
|
testGridEl.innerHTML=h;
|
|
770
|
+
_vgSentinel=document.getElementById('vg-sentinel');
|
|
771
|
+
if(_vgRenderedTo<_vgGroups.length){
|
|
772
|
+
_vgSetupObserver();
|
|
773
|
+
}else if(_vgSentinel){
|
|
774
|
+
_vgSentinel.style.display='none';
|
|
775
|
+
}
|
|
653
776
|
}
|
|
654
777
|
|
|
655
778
|
/* \u2500\u2500 Render helpers (code, artifacts) \u2500\u2500 */
|
|
@@ -740,9 +863,13 @@ body{
|
|
|
740
863
|
if(v)v.pause();
|
|
741
864
|
}
|
|
742
865
|
|
|
743
|
-
/* \u2500\u2500 Search \u2500\u2500 */
|
|
744
|
-
|
|
745
|
-
|
|
866
|
+
/* \u2500\u2500 Search (debounced) \u2500\u2500 */
|
|
867
|
+
var _searchTimer=0;
|
|
868
|
+
function doSearch(q){
|
|
869
|
+
clearTimeout(_searchTimer);
|
|
870
|
+
_searchTimer=setTimeout(function(){searchQuery=q;applyFilters();},150);
|
|
871
|
+
}
|
|
872
|
+
`;var zt=`
|
|
746
873
|
/* \u2500\u2500 Network Visualization Helpers \u2500\u2500 */
|
|
747
874
|
var RES_COLORS={xhr:'#60a5fa',document:'#818cf8',script:'#fbbf24',stylesheet:'#a78bfa',image:'#34d399',font:'#f472b6',other:'#6b7280'};
|
|
748
875
|
var RES_LABELS={xhr:'XHR',document:'Doc',script:'JS',stylesheet:'CSS',image:'Img',font:'Font',other:'Other'};
|
|
@@ -832,7 +959,7 @@ body{
|
|
|
832
959
|
if(!body)return '<div class="ndt-body-empty">'+emptyLabel+'</div>';
|
|
833
960
|
var pretty=prettyBody(body,ct);
|
|
834
961
|
var h='<div class="ndt-body-wrap"><pre class="ndt-body-pre">'+esc(pretty||body)+'</pre>';
|
|
835
|
-
if(truncated)h+='<span class="ndt-body-truncated">
|
|
962
|
+
if(truncated)h+='<span class="ndt-body-truncated">Body truncated</span>';
|
|
836
963
|
h+='</div>';return h;
|
|
837
964
|
}
|
|
838
965
|
|
|
@@ -876,6 +1003,9 @@ body{
|
|
|
876
1003
|
h+='</div>';return h;
|
|
877
1004
|
}
|
|
878
1005
|
|
|
1006
|
+
var NDT_ROW_H=32;
|
|
1007
|
+
var NDT_VBUF=30;
|
|
1008
|
+
|
|
879
1009
|
function renderNetworkDevTools(reqs){
|
|
880
1010
|
if(!reqs||reqs.length===0)return '<div class="artifact-empty">No network requests captured</div>';
|
|
881
1011
|
var uid='ndt-'+Math.random().toString(36).substr(2,6);
|
|
@@ -896,22 +1026,80 @@ body{
|
|
|
896
1026
|
h+='<span class="ndt-count" data-ndt-count="'+uid+'">'+reqs.length+' requests</span>';
|
|
897
1027
|
h+='</div>';
|
|
898
1028
|
|
|
899
|
-
/*
|
|
900
|
-
h+='<div class="ndt-list" data-ndt-list="'+uid+'">';
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
1029
|
+
/* Virtualized request list */
|
|
1030
|
+
h+='<div class="ndt-list ndt-vlist" data-ndt-list="'+uid+'" data-ndt-uid="'+uid+'" style="overflow-y:auto;max-height:400px;position:relative">';
|
|
1031
|
+
h+='<div class="ndt-vspacer" style="height:'+(reqs.length*NDT_ROW_H)+'px;position:relative"></div>';
|
|
1032
|
+
h+='</div></div>';
|
|
1033
|
+
|
|
1034
|
+
/* Store reqs data for virtual rendering */
|
|
1035
|
+
setTimeout(function(){
|
|
1036
|
+
var el=document.getElementById(uid);if(!el)return;
|
|
1037
|
+
var list=el.querySelector('.ndt-vlist');if(!list)return;
|
|
1038
|
+
var spacer=list.querySelector('.ndt-vspacer');
|
|
1039
|
+
var allReqs=reqs;
|
|
1040
|
+
var filteredIdxs=null;
|
|
1041
|
+
var openIdx=-1;
|
|
1042
|
+
|
|
1043
|
+
function getVisible(){return filteredIdxs||allReqs.map(function(_,i){return i});}
|
|
1044
|
+
|
|
1045
|
+
function paint(){
|
|
1046
|
+
var vis=getVisible();
|
|
1047
|
+
spacer.style.height=(vis.length*NDT_ROW_H)+'px';
|
|
1048
|
+
var st=list.scrollTop;var vh=list.clientHeight;
|
|
1049
|
+
var startRow=Math.max(0,Math.floor(st/NDT_ROW_H)-NDT_VBUF);
|
|
1050
|
+
var endRow=Math.min(vis.length,Math.ceil((st+vh)/NDT_ROW_H)+NDT_VBUF);
|
|
1051
|
+
var out='';
|
|
1052
|
+
for(var vi=startRow;vi<endRow;vi++){
|
|
1053
|
+
var ri=vis[vi];var r=allReqs[ri];
|
|
1054
|
+
var isFail=r.statusCode>=400||r.statusCode===0;
|
|
1055
|
+
var isOpen=ri===openIdx;
|
|
1056
|
+
out+='<div class="ndt-row'+(isFail?' ndt-row--fail':'')+(isOpen?' ndt-row--open':'')+'" data-ndt-idx="'+ri+'" data-ndt-type="'+esc(r.resourceType)+'" data-ndt-url="'+esc(r.url.toLowerCase())+'" style="position:absolute;top:'+(vi*NDT_ROW_H)+'px;left:0;right:0;height:'+NDT_ROW_H+'px">';
|
|
1057
|
+
out+='<span class="ndt-status '+ndtStatusClass(r.statusCode)+'">'+r.statusCode+'</span>';
|
|
1058
|
+
out+='<span class="ndt-method">'+esc(r.method)+'</span>';
|
|
1059
|
+
out+='<span class="ndt-url" title="'+esc(r.url)+'">'+esc(urlPath(r.url))+'</span>';
|
|
1060
|
+
out+='<span class="ndt-type">'+esc(RES_LABELS[r.resourceType]||r.resourceType)+'</span>';
|
|
1061
|
+
out+='<span class="ndt-size">'+fmtBytes(r.responseSize||0)+'</span>';
|
|
1062
|
+
out+='<span class="ndt-time">'+fmtDur(r.responseTimeMs)+'</span>';
|
|
1063
|
+
out+='</div>';
|
|
1064
|
+
if(isOpen){out+=renderNdtDetail(r,ri);}
|
|
1065
|
+
}
|
|
1066
|
+
spacer.innerHTML=out;
|
|
1067
|
+
var countEl=el.querySelector('.ndt-count');
|
|
1068
|
+
if(countEl)countEl.textContent=vis.length+(vis.length!==allReqs.length?' / '+allReqs.length:'')+' requests';
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
var rafPending=false;
|
|
1072
|
+
list.addEventListener('scroll',function(){if(!rafPending){rafPending=true;requestAnimationFrame(function(){rafPending=false;paint();})}},{passive:true});
|
|
1073
|
+
|
|
1074
|
+
/* Click handler for rows */
|
|
1075
|
+
list.addEventListener('click',function(e){
|
|
1076
|
+
var row=e.target.closest('.ndt-row');if(!row)return;
|
|
1077
|
+
var idx=parseInt(row.getAttribute('data-ndt-idx'),10);
|
|
1078
|
+
openIdx=openIdx===idx?-1:idx;
|
|
1079
|
+
paint();
|
|
1080
|
+
});
|
|
1081
|
+
|
|
1082
|
+
/* Store filter/search handler on element */
|
|
1083
|
+
el.__ndtFilter=function(filterType,searchVal){
|
|
1084
|
+
var q=(searchVal||'').toLowerCase();
|
|
1085
|
+
if((!filterType||filterType==='all')&&!q){filteredIdxs=null;}
|
|
1086
|
+
else{
|
|
1087
|
+
filteredIdxs=[];
|
|
1088
|
+
for(var i=0;i<allReqs.length;i++){
|
|
1089
|
+
var r=allReqs[i];
|
|
1090
|
+
if(filterType&&filterType!=='all'&&r.resourceType!==filterType)continue;
|
|
1091
|
+
if(q&&r.url.toLowerCase().indexOf(q)<0)continue;
|
|
1092
|
+
filteredIdxs.push(i);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
openIdx=-1;
|
|
1096
|
+
list.scrollTop=0;
|
|
1097
|
+
paint();
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1100
|
+
paint();
|
|
1101
|
+
},0);
|
|
1102
|
+
return h;
|
|
915
1103
|
}
|
|
916
1104
|
|
|
917
1105
|
function renderTimelineColumn(steps,networkRequests,consoleLogs,testType){
|
|
@@ -1021,6 +1209,14 @@ body{
|
|
|
1021
1209
|
}
|
|
1022
1210
|
|
|
1023
1211
|
function ndtApplyFilters(ndt,filterType,searchVal){
|
|
1212
|
+
/* Use virtual filter handler if available */
|
|
1213
|
+
if(ndt.__ndtFilter){
|
|
1214
|
+
var searchInput=ndt.querySelector('.ndt-search');
|
|
1215
|
+
var q=(searchVal!==null&&searchVal!==undefined)?searchVal:(searchInput?searchInput.value:'');
|
|
1216
|
+
ndt.__ndtFilter(filterType,q);
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
/* Fallback for non-virtual lists (API calls panel) */
|
|
1024
1220
|
var list=ndt.querySelector('.ndt-list');if(!list)return;
|
|
1025
1221
|
var searchInput=ndt.querySelector('.ndt-search');
|
|
1026
1222
|
var q=(searchVal!==null&&searchVal!==undefined)?searchVal:(searchInput?searchInput.value:'');
|
|
@@ -1035,7 +1231,6 @@ body{
|
|
|
1035
1231
|
if(filterType&&filterType!=='all'&&type!==filterType)show=false;
|
|
1036
1232
|
if(show&&q&&url.indexOf(q)<0)show=false;
|
|
1037
1233
|
row.style.display=show?'':'none';
|
|
1038
|
-
/* Also hide detail if row is hidden */
|
|
1039
1234
|
var det=row.nextElementSibling;
|
|
1040
1235
|
if(det&&det.classList.contains('ndt-detail')){if(!show){det.classList.remove('show');row.classList.remove('ndt-row--open');}}
|
|
1041
1236
|
if(show)visible++;
|
|
@@ -1043,7 +1238,7 @@ body{
|
|
|
1043
1238
|
var countEl=ndt.querySelector('.ndt-count');
|
|
1044
1239
|
if(countEl)countEl.textContent=visible+' / '+rows.length+' requests';
|
|
1045
1240
|
}
|
|
1046
|
-
`;var
|
|
1241
|
+
`;var jt=`
|
|
1047
1242
|
var _filterState={status:{},type:{},specFile:{}};
|
|
1048
1243
|
var _totalTests=0;
|
|
1049
1244
|
var _originalSummary=null;
|
|
@@ -1214,7 +1409,7 @@ function _updateCard(cls,val){
|
|
|
1214
1409
|
var el=document.querySelector('.'+cls+' .s-count');
|
|
1215
1410
|
if(el)el.textContent=''+val;
|
|
1216
1411
|
}
|
|
1217
|
-
`;var
|
|
1412
|
+
`;var $t=`
|
|
1218
1413
|
/* \u2500\u2500 Event Delegation \u2500\u2500 */
|
|
1219
1414
|
document.addEventListener('click',function(e){
|
|
1220
1415
|
var target=e.target;
|
|
@@ -1269,6 +1464,9 @@ function _updateCard(cls,val){
|
|
|
1269
1464
|
/* Network DevTools: request row \u2192 expand/collapse detail */
|
|
1270
1465
|
var ndtRow=target.closest('.ndt-row');
|
|
1271
1466
|
if(ndtRow){
|
|
1467
|
+
/* Virtual lists handle their own click events */
|
|
1468
|
+
var vlist=ndtRow.closest('.ndt-vlist');
|
|
1469
|
+
if(vlist)return;
|
|
1272
1470
|
var idx=ndtRow.getAttribute('data-ndt-idx');
|
|
1273
1471
|
var det=document.getElementById('ndt-d-'+idx);
|
|
1274
1472
|
if(det){
|
|
@@ -1323,7 +1521,10 @@ function _updateCard(cls,val){
|
|
|
1323
1521
|
for(var bi=0;bi<btns.length;bi++)btns[bi].classList.remove('active');
|
|
1324
1522
|
consoleFilterBtn.classList.add('active');
|
|
1325
1523
|
var filterLevel=consoleFilterBtn.getAttribute('data-console-filter');
|
|
1326
|
-
var
|
|
1524
|
+
var panel=consoleFilterBtn.closest('.console-panel');
|
|
1525
|
+
/* Use virtual filter if available */
|
|
1526
|
+
if(panel&&panel.__conFilter){panel.__conFilter(filterLevel);return;}
|
|
1527
|
+
var list=panel?panel.querySelector('.console-list'):null;
|
|
1327
1528
|
if(list){
|
|
1328
1529
|
var entries=list.querySelectorAll('.console-entry');
|
|
1329
1530
|
for(var ei=0;ei<entries.length;ei++){
|
|
@@ -1352,6 +1553,37 @@ function _updateCard(cls,val){
|
|
|
1352
1553
|
return;
|
|
1353
1554
|
}
|
|
1354
1555
|
|
|
1556
|
+
/* Artifact section: run row toggle */
|
|
1557
|
+
var artToggle=target.closest('[data-artifact-toggle]');
|
|
1558
|
+
if(artToggle){
|
|
1559
|
+
var idx=artToggle.getAttribute('data-artifact-toggle');
|
|
1560
|
+
var detail=document.getElementById('as-run-detail-'+idx);
|
|
1561
|
+
var runEl=artToggle.closest('.as-run');
|
|
1562
|
+
if(detail){
|
|
1563
|
+
var isOpen=detail.style.display!=='none';
|
|
1564
|
+
detail.style.display=isOpen?'none':'block';
|
|
1565
|
+
if(runEl)runEl.classList.toggle('expanded',!isOpen);
|
|
1566
|
+
}
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
/* Artifact section: delete single run */
|
|
1571
|
+
var deleteBtn=target.closest('[data-artifact-action="delete"]');
|
|
1572
|
+
if(deleteBtn){
|
|
1573
|
+
e.stopPropagation();
|
|
1574
|
+
var folder=deleteBtn.getAttribute('data-run-folder');
|
|
1575
|
+
var isCurrent=deleteBtn.getAttribute('data-is-current')==='true';
|
|
1576
|
+
if(folder&&typeof deleteArtifactRun==='function')deleteArtifactRun(folder,isCurrent);
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
/* Artifact section: delete all */
|
|
1581
|
+
var deleteAllBtn=target.closest('[data-artifact-action="delete-all"]');
|
|
1582
|
+
if(deleteAllBtn){
|
|
1583
|
+
if(typeof deleteAllArtifacts==='function')deleteAllArtifacts();
|
|
1584
|
+
return;
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1355
1587
|
/* Stack trace toggle */
|
|
1356
1588
|
if(target.classList.contains('stack-toggle-btn')){var se=document.getElementById(target.getAttribute('data-stack'));if(se){var sv=se.classList.toggle('show');target.textContent=sv?'Hide stack trace':'Show stack trace';}return;}
|
|
1357
1589
|
|
|
@@ -1462,7 +1694,7 @@ function _updateCard(cls,val){
|
|
|
1462
1694
|
var d=document.getElementById('filter-drawer');if(d)d.classList.remove('open');
|
|
1463
1695
|
var b=document.getElementById('filter-drawer-backdrop');if(b)b.classList.remove('open');
|
|
1464
1696
|
}
|
|
1465
|
-
`;var
|
|
1697
|
+
`;var Gt=`
|
|
1466
1698
|
/* \u2500\u2500 Category badge helpers \u2500\u2500 */
|
|
1467
1699
|
function actionBadgeClass(cat){
|
|
1468
1700
|
if(cat==='assertion')return 'action-badge-assertion';
|
|
@@ -1508,7 +1740,7 @@ function _updateCard(cls,val){
|
|
|
1508
1740
|
h+='</div>';
|
|
1509
1741
|
return h;
|
|
1510
1742
|
}
|
|
1511
|
-
`;var
|
|
1743
|
+
`;var Vt=`
|
|
1512
1744
|
/* \u2500\u2500 Console Log Level Colors & Labels \u2500\u2500 */
|
|
1513
1745
|
var LOG_COLORS={log:'#9ca3af',warn:'#fbbf24',error:'#f87171',info:'#60a5fa',debug:'#a78bfa',stdout:'#9ca3af',stderr:'#f87171'};
|
|
1514
1746
|
var LOG_LABELS={log:'LOG',warn:'WARN',error:'ERR',info:'INFO',debug:'DBG',stdout:'OUT',stderr:'ERR'};
|
|
@@ -1523,6 +1755,9 @@ function _updateCard(cls,val){
|
|
|
1523
1755
|
return h;
|
|
1524
1756
|
}
|
|
1525
1757
|
|
|
1758
|
+
var CON_ROW_H=24;
|
|
1759
|
+
var CON_VBUF=40;
|
|
1760
|
+
|
|
1526
1761
|
function renderConsoleColumn(logs,testType){
|
|
1527
1762
|
if(!logs||logs.length===0)return '';
|
|
1528
1763
|
var isApi=testType==='api';
|
|
@@ -1531,7 +1766,8 @@ function _updateCard(cls,val){
|
|
|
1531
1766
|
var counts={};
|
|
1532
1767
|
for(var i=0;i<logs.length;i++){var l=logs[i].level;counts[l]=(counts[l]||0)+1;}
|
|
1533
1768
|
|
|
1534
|
-
var
|
|
1769
|
+
var uid='clog-'+Math.random().toString(36).substr(2,6);
|
|
1770
|
+
var h='<div class="console-panel" id="'+uid+'">';
|
|
1535
1771
|
h+='<div class="console-header">';
|
|
1536
1772
|
h+='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/></svg>';
|
|
1537
1773
|
h+=' '+label+' <span class="console-count">'+logs.length+'</span>';
|
|
@@ -1548,44 +1784,270 @@ function _updateCard(cls,val){
|
|
|
1548
1784
|
}
|
|
1549
1785
|
h+='</div>';
|
|
1550
1786
|
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1787
|
+
/* Use virtualization for large log lists */
|
|
1788
|
+
if(logs.length>200){
|
|
1789
|
+
h+='<div class="console-list console-vlist" style="overflow-y:auto;max-height:400px;position:relative">';
|
|
1790
|
+
h+='<div class="console-vspacer" style="height:'+(logs.length*CON_ROW_H)+'px;position:relative"></div>';
|
|
1791
|
+
h+='</div>';
|
|
1792
|
+
h+='</div>';
|
|
1793
|
+
|
|
1794
|
+
setTimeout(function(){
|
|
1795
|
+
var panel=document.getElementById(uid);if(!panel)return;
|
|
1796
|
+
var list=panel.querySelector('.console-vlist');if(!list)return;
|
|
1797
|
+
var spacer=list.querySelector('.console-vspacer');
|
|
1798
|
+
var allLogs=logs;
|
|
1799
|
+
var filteredIdxs=null;
|
|
1800
|
+
|
|
1801
|
+
function getVis(){return filteredIdxs||allLogs.map(function(_,i){return i});}
|
|
1802
|
+
|
|
1803
|
+
function paint(){
|
|
1804
|
+
var vis=getVis();
|
|
1805
|
+
spacer.style.height=(vis.length*CON_ROW_H)+'px';
|
|
1806
|
+
var st=list.scrollTop;var vh=list.clientHeight;
|
|
1807
|
+
var s0=Math.max(0,Math.floor(st/CON_ROW_H)-CON_VBUF);
|
|
1808
|
+
var s1=Math.min(vis.length,Math.ceil((st+vh)/CON_ROW_H)+CON_VBUF);
|
|
1809
|
+
var out='';
|
|
1810
|
+
for(var vi=s0;vi<s1;vi++){
|
|
1811
|
+
var entry=allLogs[vis[vi]];
|
|
1812
|
+
out+='<div class="console-entry console-level-'+esc(entry.level)+'" data-console-level="'+esc(entry.level)+'" style="position:absolute;top:'+(vi*CON_ROW_H)+'px;left:0;right:0;height:'+CON_ROW_H+'px">';
|
|
1813
|
+
out+='<span class="console-level-badge" style="color:'+LOG_COLORS[entry.level]+'">'+LOG_LABELS[entry.level]+'</span>';
|
|
1814
|
+
out+='<span class="console-time">'+fmtDate(entry.timestamp).split(', ').pop()+'</span>';
|
|
1815
|
+
out+='<span class="console-text">'+esc(stripAnsi(entry.text))+'</span>';
|
|
1816
|
+
if(entry.location){var short=entry.location.split('/').pop()||entry.location;out+='<span class="console-loc" title="'+esc(entry.location)+'">'+esc(short)+'</span>';}
|
|
1817
|
+
out+='</div>';
|
|
1818
|
+
}
|
|
1819
|
+
spacer.innerHTML=out;
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
var rafP=false;
|
|
1823
|
+
list.addEventListener('scroll',function(){if(!rafP){rafP=true;requestAnimationFrame(function(){rafP=false;paint();})}},{passive:true});
|
|
1824
|
+
|
|
1825
|
+
/* Store filter handler */
|
|
1826
|
+
panel.__conFilter=function(level){
|
|
1827
|
+
if(!level||level==='all'){filteredIdxs=null;}
|
|
1828
|
+
else{filteredIdxs=[];for(var i=0;i<allLogs.length;i++){if(allLogs[i].level===level)filteredIdxs.push(i);}}
|
|
1829
|
+
list.scrollTop=0;paint();
|
|
1830
|
+
};
|
|
1831
|
+
|
|
1832
|
+
paint();
|
|
1833
|
+
},0);
|
|
1834
|
+
}else{
|
|
1835
|
+
h+='<div class="console-list">';
|
|
1836
|
+
for(var i=0;i<logs.length;i++){h+=renderConsoleLogEntry(logs[i]);}
|
|
1837
|
+
h+='</div>';
|
|
1838
|
+
h+='</div>';
|
|
1839
|
+
}
|
|
1555
1840
|
return h;
|
|
1556
1841
|
}
|
|
1557
|
-
`;var
|
|
1842
|
+
`;var Jt=`
|
|
1843
|
+
/* \u2500\u2500 Test Artifacts Section \u2500\u2500 */
|
|
1844
|
+
var _artifactManifest=null;
|
|
1845
|
+
var _artifactServerPort=null;
|
|
1846
|
+
|
|
1847
|
+
function formatBytes(bytes){
|
|
1848
|
+
if(bytes===0)return '0 B';
|
|
1849
|
+
var k=1024;var sizes=['B','KB','MB','GB'];
|
|
1850
|
+
var i=Math.floor(Math.log(bytes)/Math.log(k));
|
|
1851
|
+
if(i>=sizes.length)i=sizes.length-1;
|
|
1852
|
+
return parseFloat((bytes/Math.pow(k,i)).toFixed(1))+' '+sizes[i];
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
function formatTimestamp(ts){
|
|
1856
|
+
try{
|
|
1857
|
+
var d=new Date(ts);
|
|
1858
|
+
if(isNaN(d.getTime()))return ts;
|
|
1859
|
+
return d.toLocaleDateString(undefined,{year:'numeric',month:'short',day:'numeric'})+' '+d.toLocaleTimeString(undefined,{hour:'2-digit',minute:'2-digit',second:'2-digit'});
|
|
1860
|
+
}catch(e){return ts;}
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
function renderArtifactSection(){
|
|
1864
|
+
var section=document.getElementById('artifact-section');
|
|
1865
|
+
if(!section)return;
|
|
1866
|
+
|
|
1867
|
+
/* Read server port from meta tag */
|
|
1868
|
+
var portMeta=document.querySelector('meta[name="artifact-server-port"]');
|
|
1869
|
+
var candidatePort=null;
|
|
1870
|
+
if(portMeta&&portMeta.content&&portMeta.content!=='null'){
|
|
1871
|
+
candidatePort=parseInt(portMeta.content,10);
|
|
1872
|
+
if(isNaN(candidatePort))candidatePort=null;
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
/* Read manifest from embedded script tag (self-contained HTML) */
|
|
1876
|
+
var manifestEl=document.getElementById('artifact-manifest-data');
|
|
1877
|
+
var manifest=null;
|
|
1878
|
+
if(manifestEl){
|
|
1879
|
+
try{manifest=JSON.parse(manifestEl.textContent);}catch(e){}
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
if(manifest){
|
|
1883
|
+
_artifactManifest=manifest;
|
|
1884
|
+
/* Verify server is actually reachable before enabling delete actions */
|
|
1885
|
+
if(candidatePort){
|
|
1886
|
+
fetch('http://127.0.0.1:'+candidatePort+'/api/health',{method:'GET'}).then(function(r){
|
|
1887
|
+
if(r.ok){_artifactServerPort=candidatePort;}
|
|
1888
|
+
renderArtifactContent(section,manifest);
|
|
1889
|
+
}).catch(function(){
|
|
1890
|
+
_artifactServerPort=null;
|
|
1891
|
+
renderArtifactContent(section,manifest);
|
|
1892
|
+
});
|
|
1893
|
+
}else{
|
|
1894
|
+
renderArtifactContent(section,manifest);
|
|
1895
|
+
}
|
|
1896
|
+
return;
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
/* Fallback: try fetch (works when served via HTTP) */
|
|
1900
|
+
fetch('artifact-manifest.json').then(function(r){
|
|
1901
|
+
if(!r.ok)throw new Error('HTTP '+r.status);
|
|
1902
|
+
return r.json();
|
|
1903
|
+
}).then(function(m){
|
|
1904
|
+
_artifactManifest=m;
|
|
1905
|
+
renderArtifactContent(section,m);
|
|
1906
|
+
}).catch(function(){
|
|
1907
|
+
/* No manifest embedded and fetch failed \u2014 hide section entirely */
|
|
1908
|
+
section.style.display='none';
|
|
1909
|
+
});
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
function renderArtifactContent(section,manifest){
|
|
1913
|
+
var runs=manifest.runs||[];
|
|
1914
|
+
var hasServer=!!_artifactServerPort;
|
|
1915
|
+
var html='<div class="as-header"><span class="as-title">Test Artifacts</span><span class="as-total">'+formatBytes(manifest.totalSizeBytes||0)+' total</span>';
|
|
1916
|
+
if(hasServer&&runs.length>0){
|
|
1917
|
+
html+='<button class="as-delete-all-btn" data-artifact-action="delete-all">Delete All</button>';
|
|
1918
|
+
}
|
|
1919
|
+
html+='</div>';
|
|
1920
|
+
|
|
1921
|
+
if(runs.length===0){
|
|
1922
|
+
html+='<div class="as-empty">No artifact runs found.</div>';
|
|
1923
|
+
}else{
|
|
1924
|
+
html+='<div class="as-runs">';
|
|
1925
|
+
for(var i=0;i<runs.length;i++){
|
|
1926
|
+
var run=runs[i];
|
|
1927
|
+
var isLegacy=run.folderName==='__legacy__';
|
|
1928
|
+
var label=isLegacy?'Legacy (pre-timestamp)':formatTimestamp(run.timestamp);
|
|
1929
|
+
var currentTag=run.isCurrentRun?' <span class="as-current-tag">Current</span>':'';
|
|
1930
|
+
var legacyClass=isLegacy?' as-run-legacy':'';
|
|
1931
|
+
html+='<div class="as-run'+legacyClass+'" data-run-folder="'+run.folderName+'">';
|
|
1932
|
+
html+='<div class="as-run-row" data-artifact-toggle="'+i+'">';
|
|
1933
|
+
html+='<span class="as-run-arrow">▶</span>';
|
|
1934
|
+
html+='<span class="as-run-label">'+label+currentTag+'</span>';
|
|
1935
|
+
html+='<span class="as-run-meta">'+run.testCount+' test'+(run.testCount!==1?'s':'')+' · '+formatBytes(run.totalSizeBytes)+'</span>';
|
|
1936
|
+
if(hasServer&&!isLegacy){
|
|
1937
|
+
html+='<button class="as-delete-btn" data-artifact-action="delete" data-run-folder="'+run.folderName+'"'+(run.isCurrentRun?' data-is-current="true"':'')+'>Delete</button>';
|
|
1938
|
+
}
|
|
1939
|
+
html+='</div>';
|
|
1940
|
+
html+='<div class="as-run-detail" id="as-run-detail-'+i+'" style="display:none;">';
|
|
1941
|
+
var tests=run.tests||[];
|
|
1942
|
+
if(tests.length===0){
|
|
1943
|
+
html+='<div class="as-no-tests">No test artifacts in this run.</div>';
|
|
1944
|
+
}else{
|
|
1945
|
+
for(var t=0;t<tests.length;t++){
|
|
1946
|
+
var test=tests[t];
|
|
1947
|
+
html+='<div class="as-test">';
|
|
1948
|
+
html+='<div class="as-test-name">'+test.testName+'</div>';
|
|
1949
|
+
html+='<div class="as-test-files">';
|
|
1950
|
+
for(var f=0;f<test.files.length;f++){
|
|
1951
|
+
var file=test.files[f];
|
|
1952
|
+
if(file.type==='screenshot'){
|
|
1953
|
+
html+='<div class="as-file"><img class="as-thumb artifact-col-img" src="'+file.relativePath+'" alt="'+file.name+'" loading="lazy"><span class="as-file-info">'+file.name+' ('+formatBytes(file.sizeBytes)+')</span></div>';
|
|
1954
|
+
}else if(file.type==='video'){
|
|
1955
|
+
html+='<div class="as-file"><div class="as-video-wrap"><video src="'+file.relativePath+'" controls preload="metadata"></video></div><span class="as-file-info">'+file.name+' ('+formatBytes(file.sizeBytes)+')</span></div>';
|
|
1956
|
+
}else{
|
|
1957
|
+
html+='<div class="as-file"><span class="as-file-icon">📄</span><a href="'+file.relativePath+'" target="_blank">'+file.name+'</a> ('+formatBytes(file.sizeBytes)+')</div>';
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
html+='</div></div>';
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
html+='</div></div>';
|
|
1964
|
+
}
|
|
1965
|
+
html+='</div>';
|
|
1966
|
+
}
|
|
1967
|
+
section.innerHTML=html;
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
function refreshArtifactSection(){
|
|
1971
|
+
var section=document.getElementById('artifact-section');
|
|
1972
|
+
if(!section)return;
|
|
1973
|
+
if(_artifactServerPort){
|
|
1974
|
+
fetch('http://127.0.0.1:'+_artifactServerPort+'/api/artifacts').then(function(r){
|
|
1975
|
+
if(!r.ok)throw new Error('HTTP '+r.status);
|
|
1976
|
+
return r.json();
|
|
1977
|
+
}).then(function(data){
|
|
1978
|
+
_artifactManifest={schemaVersion:'1.0',generatedAt:new Date().toISOString(),artifactBaseDir:'artifacts',totalSizeBytes:data.totalSizeBytes||0,runs:data.runs||[],serverPort:_artifactServerPort};
|
|
1979
|
+
renderArtifactContent(section,_artifactManifest);
|
|
1980
|
+
}).catch(function(){
|
|
1981
|
+
section.innerHTML='<div class="as-header"><span class="as-title">Test Artifacts</span></div><div class="as-empty">Failed to refresh artifact data.</div>';
|
|
1982
|
+
});
|
|
1983
|
+
}else{
|
|
1984
|
+
renderArtifactSection();
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
function deleteArtifactRun(folderName,isCurrent){
|
|
1989
|
+
var msg='Delete artifact run "'+folderName+'"?';
|
|
1990
|
+
if(isCurrent)msg+='\\n\\nWarning: This will remove the current run\\'s artifacts.';
|
|
1991
|
+
if(!confirm(msg))return;
|
|
1992
|
+
if(!_artifactServerPort)return;
|
|
1993
|
+
fetch('http://127.0.0.1:'+_artifactServerPort+'/api/artifacts/'+encodeURIComponent(folderName),{method:'DELETE'}).then(function(r){
|
|
1994
|
+
if(!r.ok)throw new Error('HTTP '+r.status);
|
|
1995
|
+
return r.json();
|
|
1996
|
+
}).then(function(){
|
|
1997
|
+
refreshArtifactSection();
|
|
1998
|
+
}).catch(function(err){
|
|
1999
|
+
alert('Failed to delete: '+err.message);
|
|
2000
|
+
});
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
function deleteAllArtifacts(){
|
|
2004
|
+
if(!confirm('Delete ALL artifact run folders? This cannot be undone.'))return;
|
|
2005
|
+
if(!_artifactServerPort)return;
|
|
2006
|
+
fetch('http://127.0.0.1:'+_artifactServerPort+'/api/artifacts',{method:'DELETE'}).then(function(r){
|
|
2007
|
+
if(!r.ok)throw new Error('HTTP '+r.status);
|
|
2008
|
+
return r.json();
|
|
2009
|
+
}).then(function(){
|
|
2010
|
+
refreshArtifactSection();
|
|
2011
|
+
}).catch(function(err){
|
|
2012
|
+
alert('Failed to delete all: '+err.message);
|
|
2013
|
+
});
|
|
2014
|
+
}
|
|
2015
|
+
`;var yr=`
|
|
1558
2016
|
(function(){
|
|
1559
2017
|
var data=JSON.parse(document.getElementById('report-data').textContent);
|
|
1560
|
-
${
|
|
1561
|
-
${
|
|
1562
|
-
${
|
|
1563
|
-
${
|
|
1564
|
-
${
|
|
1565
|
-
${
|
|
2018
|
+
${Ut}
|
|
2019
|
+
${Gt}
|
|
2020
|
+
${Vt}
|
|
2021
|
+
${zt}
|
|
2022
|
+
${jt}
|
|
2023
|
+
${Jt}
|
|
2024
|
+
${$t}
|
|
1566
2025
|
applyTheme();
|
|
1567
2026
|
renderRunMeta();
|
|
1568
2027
|
renderSummary();
|
|
1569
2028
|
initFilters();
|
|
1570
2029
|
renderFilterBar();
|
|
1571
2030
|
renderTestGrid();
|
|
1572
|
-
|
|
2031
|
+
renderArtifactSection();
|
|
2032
|
+
var _lo=document.getElementById('loading-overlay');if(_lo)_lo.remove();
|
|
2033
|
+
})();`;function Kt(e,t,r){let n=e.replace(/<\//g,"<\\/"),s=r?r.replace(/<\//g,"<\\/"):null;return `<!-- TestRelic AI Analytics Report \u2014 self-contained, no external dependencies -->
|
|
1573
2034
|
<!DOCTYPE html>
|
|
1574
2035
|
<html lang="en" data-theme="">
|
|
1575
2036
|
<head>
|
|
1576
2037
|
<meta charset="UTF-8">
|
|
1577
2038
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
1578
|
-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; img-src data: blob: 'self'; media-src blob: 'self';">
|
|
2039
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; img-src data: blob: 'self'; media-src blob: 'self'; connect-src 'self' http://127.0.0.1:*;">
|
|
1579
2040
|
<title>TestRelic AI Analytics Report</title>
|
|
1580
|
-
|
|
1581
|
-
<
|
|
2041
|
+
${t?`<meta name="artifact-server-port" content="${t}">`:""}
|
|
2042
|
+
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml;base64,${Buffer.from(Ft).toString("base64")}">
|
|
2043
|
+
<style>${Ot}</style>
|
|
1582
2044
|
<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>
|
|
1583
2045
|
</head>
|
|
1584
2046
|
<body>
|
|
1585
2047
|
<div class="wrap">
|
|
1586
2048
|
<div class="top-bar">
|
|
1587
2049
|
<div class="brand">
|
|
1588
|
-
${
|
|
2050
|
+
${Ht}
|
|
1589
2051
|
<div class="brand-text">
|
|
1590
2052
|
<span class="brand-title">TestRelic AI</span>
|
|
1591
2053
|
<span class="brand-sub">Analytics Report</span>
|
|
@@ -1602,7 +2064,9 @@ function _updateCard(cls,val){
|
|
|
1602
2064
|
<div id="summary-strip" class="summary-strip"></div>
|
|
1603
2065
|
<div id="filter-bar" class="filter-bar"></div>
|
|
1604
2066
|
<div id="test-grid"></div>
|
|
2067
|
+
<div id="artifact-section"></div>
|
|
1605
2068
|
</div>
|
|
2069
|
+
<div class="loading-overlay" id="loading-overlay"><div class="loading-spinner"></div><div class="loading-text">Loading report...</div></div>
|
|
1606
2070
|
<div class="drawer-backdrop" id="drawer-backdrop"></div>
|
|
1607
2071
|
<aside class="drawer" id="drawer">
|
|
1608
2072
|
<div class="drawer-bar">
|
|
@@ -1619,45 +2083,50 @@ function _updateCard(cls,val){
|
|
|
1619
2083
|
</div>
|
|
1620
2084
|
<div class="filter-drawer-body" id="filter-drawer-body"></div>
|
|
1621
2085
|
</aside>
|
|
1622
|
-
<script id="report-data" type="application/json">${
|
|
1623
|
-
|
|
2086
|
+
<script id="report-data" type="application/json">${n}</script>
|
|
2087
|
+
${s?`<script id="artifact-manifest-data" type="application/json">${s}</script>`:""}
|
|
2088
|
+
<script>${yr}</script>
|
|
1624
2089
|
</body>
|
|
1625
|
-
</html>`}function
|
|
1626
|
-
`);});}catch{}}function
|
|
1627
|
-
`);}}function
|
|
1628
|
-
`
|
|
2090
|
+
</html>`}function Wt(e){try{let t=process.platform,r;t==="darwin"?r=`open "${e}"`:t==="win32"?r=`start "" "${e}"`:r=`xdg-open "${e}"`,child_process.exec(r,n=>{n&&process.stderr.write(`[testrelic] Failed to open browser: ${n.message}
|
|
2091
|
+
`);});}catch{}}var st=/^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}(-\d+)?$/,wr=1800*1e3;function kr(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 R(e,t,r){e.writeHead(t,{"Content-Type":"application/json"}),e.end(JSON.stringify(r));}function j(e){let t=0;try{let r=fs.readdirSync(e,{withFileTypes:!0});for(let n of r){let s=path.join(e,n.name);n.isFile()?t+=fs.statSync(s).size:n.isDirectory()&&(t+=j(s));}}catch{}return t}function Qt(e){return new Promise((t,r)=>{let n;function s(){clearTimeout(n),n=setTimeout(()=>{a.close();},wr);}let a=http.createServer((l,i)=>{if(s(),kr(i),l.method==="OPTIONS"){i.writeHead(204),i.end();return}let c=new URL(l.url??"/",`http://${l.headers.host}`).pathname;if(l.method==="GET"&&c==="/api/health"){R(i,200,{status:"ok"});return}if(l.method==="GET"&&c==="/api/artifacts"){try{let p=[],f=0,u=fs.readdirSync(e,{withFileTypes:!0});for(let h of u){if(!h.isDirectory()||!st.test(h.name))continue;let g=path.join(e,h.name),v=j(g),y=fs.readdirSync(g,{withFileTypes:!0}).filter(b=>b.isDirectory());p.push({folderName:h.name,totalSizeBytes:v,testCount:y.length}),f+=v;}p.sort((h,g)=>g.folderName.localeCompare(h.folderName)),R(i,200,{runs:p,totalSizeBytes:f});}catch(p){R(i,500,{error:p instanceof Error?p.message:String(p)});}return}if(l.method==="DELETE"&&c==="/api/artifacts"){try{let p=0,f=0,u=fs.readdirSync(e,{withFileTypes:!0});for(let h of u){if(!h.isDirectory()||!st.test(h.name))continue;let g=path.join(e,h.name),v=j(g);fs.rmSync(g,{recursive:!0,force:!0}),f+=v,p++;}R(i,200,{deletedCount:p,freedBytes:f});}catch(p){R(i,500,{error:p instanceof Error?p.message:String(p)});}return}let d=c.match(/^\/api\/artifacts\/(.+)$/);if(l.method==="DELETE"&&d){let p=decodeURIComponent(d[1]);if(!st.test(p)){R(i,400,{error:"Invalid folder name"});return}let f=path.join(e,p);try{if(!fs.statSync(f).isDirectory()){R(i,404,{error:"Not found"});return}}catch{R(i,404,{error:"Not found"});return}try{let u=j(f);fs.rmSync(f,{recursive:!0,force:!0}),R(i,200,{deleted:p,freedBytes:u});}catch(u){R(i,500,{error:u instanceof Error?u.message:String(u)});}return}R(i,404,{error:"Not found"});});a.listen(0,"127.0.0.1",()=>{let l=a.address();if(!l||typeof l=="string"){r(new Error("Failed to get server address"));return}s(),t({port:l.port,dispose:()=>new Promise(i=>{clearTimeout(n),a.close(()=>i());})});}),a.on("error",r);})}function Ir(e,t,r){let n=JSON.stringify(e),s=r?JSON.stringify(r):null;return Kt(n,t,s)}async function te(e,t,r){try{let n=null;if(t.openReport&&e.ci===null&&t.includeArtifacts){let o=path.dirname(t.outputPath),c=path.join(o,"artifacts");if(fs.existsSync(c))try{let d=await Qt(c);n=d.port,process.on("exit",()=>{d.dispose();});}catch{}}let s=Ir(e,n,r),a=t.htmlReportPath,l=path.dirname(a);fs.mkdirSync(l,{recursive:!0});let i=a+".tmp";if(fs.writeFileSync(i,s,"utf-8"),fs.renameSync(i,a),t.openReport&&e.ci===null){let o=path.resolve(a);Wt(o);}}catch(n){process.stderr.write(`[testrelic] Failed to write HTML report: ${n instanceof Error?n.message:String(n)}
|
|
2092
|
+
`);}}function ne(e){let t=new Date,r=a=>String(a).padStart(2,"0"),n=`${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,n)))return n;let s=1;for(;fs.existsSync(path.join(e,`${n}-${s}`));)s++;return `${n}-${s}`}function Lr(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"}function se(e,t,r,n,s){let a=e.find(f=>f.name==="screenshot"&&f.path),l=e.find(f=>f.name==="video"&&f.path);if(!a&&!l)return null;let i=Lr(t);r>0&&(i+=`--retry-${r}`);let o=s?["artifacts",s,i]:["artifacts",i],c=path.join(n,...o),d=o,p={};try{fs.mkdirSync(c,{recursive:!0});}catch{return null}if(a?.path)try{if(fs.existsSync(a.path)){let u=`screenshot${path.extname(a.path)||".png"}`;fs.copyFileSync(a.path,path.join(c,u)),p.screenshot=`${d.join("/")}/${u}`;}}catch{}if(l?.path)try{if(fs.existsSync(l.path)){let u=`video${path.extname(l.path)||".webm"}`;fs.copyFileSync(l.path,path.join(c,u)),p.video=`${d.join("/")}/${u}`;}}catch{}return !p.screenshot&&!p.video?null:p}var Mr=/^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}(-\d+)?$/,Pr="1.0";function qr(e){let t=path.extname(e).toLowerCase();return [".png",".jpg",".jpeg",".gif",".bmp",".webp"].includes(t)?"screenshot":[".webm",".mp4",".avi",".mov"].includes(t)?"video":"other"}function ae(e,t,r){let n=[];try{let s=fs.readdirSync(e,{withFileTypes:!0});for(let a of s){if(!a.isFile())continue;let l=path.join(e,a.name),i=fs.statSync(l);n.push({name:a.name,type:qr(a.name),relativePath:`artifacts/${t}/${r}/${a.name}`,sizeBytes:i.size});}}catch{}return {testName:r,files:n}}function Dr(e,t){let r=path.join(e,t),n=[],s=0;try{let l=fs.readdirSync(r,{withFileTypes:!0});for(let i of l){if(!i.isDirectory())continue;let o=ae(path.join(r,i.name),t,i.name);n.push(o);for(let c of o.files)s+=c.sizeBytes;}}catch{}let a=t.replace(/^(\d{4}-\d{2}-\d{2})T(\d{2})-(\d{2})-(\d{2})/,"$1T$2:$3:$4").replace(/-\d+$/,"");return n.sort((l,i)=>l.testName.localeCompare(i.testName)),{folderName:t,timestamp:a,totalSizeBytes:s,testCount:n.length,tests:n,isCurrentRun:false}}function ie(e,t){let r=path.join(e,"artifacts"),n=[],s=[],a=0;try{let i=fs.readdirSync(r,{withFileTypes:!0});for(let o of i)if(o.isDirectory())if(Mr.test(o.name)){let c=Dr(r,o.name);n.push({...c,isCurrentRun:o.name===t});}else {let c=ae(path.join(r,o.name),o.name,o.name);s.push(c);for(let d of c.files)a+=d.sizeBytes;}}catch{}n.sort((i,o)=>o.timestamp.localeCompare(i.timestamp)),s.length>0&&(s.sort((i,o)=>i.testName.localeCompare(o.testName)),n.push({folderName:"__legacy__",timestamp:"1970-01-01T00:00:00",totalSizeBytes:a,testCount:s.length,tests:s,isCurrentRun:false}));let l=n.reduce((i,o)=>i+o.totalSizeBytes,0);return {schemaVersion:Pr,generatedAt:new Date().toISOString(),artifactBaseDir:"artifacts",totalSizeBytes:l,runs:n,serverPort:null}}function zr(e){let t=e,{root:r}=path.parse(t);for(;t!==r;){if(fs.existsSync(path.join(t,".git")))return t;t=path.join(t,"..");}return null}function le(e){try{let t=zr(e);if(!t)return;let r=path.join(t,".gitignore"),n=path.relative(t,e).replace(/\\/g,"/"),s=n.endsWith("/")?n:`${n}/`;if(fs.existsSync(r)&&fs.readFileSync(r,"utf-8").split(`
|
|
2093
|
+
`).map(o=>o.trim()).some(o=>o===s||o===n))return;let a=`
|
|
2094
|
+
# TestRelic test artifacts
|
|
2095
|
+
${s}
|
|
2096
|
+
`;fs.appendFileSync(r,a,"utf-8");}catch{}}function pe(e,t){let r=[];for(let n of e){let s=jr(n),a=$r(n),l=Gr(n,s,a,t),i=Vr(n,s,a);if(l.length===0&&i.length===0){r.push({type:"navigation",url:"about:blank",timestamp:n.startedAt,durationOnUrl:n.duration,navigationType:"dummy",domContentLoadedAt:null,networkIdleAt:null,networkStats:null,specFile:n.specFile,test:s,tests:[a],_testTitle:n.title});continue}r.push(...l,...i);}return r.sort(Jr),Kr(r,e),r.map((n,s)=>n.type==="navigation"?{...{index:s,type:"navigation",url:n.url,timestamp:n.timestamp,durationOnUrl:n.durationOnUrl??0,navigationType:n.navigationType,domContentLoadedAt:n.domContentLoadedAt??null,networkIdleAt:n.networkIdleAt??null,networkStats:n.networkStats??null,specFile:n.specFile,test:n.test},tests:n.tests}:{...{index:s,type:"api_call",callId:n.callId,method:n.method,url:n.url,timestamp:n.timestamp,responseTime:n.responseTime??null,request:n.request,response:n.response??null,...n.error?{error:n.error}:{},assertions:n.assertions??[],specFile:n.specFile,test:n.test},tests:n.tests})}function jr(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 $r(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 Gr(e,t,r,n){let s=[];for(let a of e.navigations)n.navigationTypes!==null&&!n.navigationTypes.includes(a.navigationType)||s.push({type:"navigation",url:a.url,timestamp:a.timestamp,durationOnUrl:0,navigationType:a.navigationType,domContentLoadedAt:a.domContentLoadedAt??null,networkIdleAt:a.networkIdleAt??null,networkStats:a.networkStats??null,specFile:e.specFile,test:t,tests:[r],_testTitle:e.title});return s}function Vr(e,t,r){if(!e.apiCalls||e.apiCalls.length===0)return [];let n=e.apiAssertions??[];return e.apiCalls.map(s=>{let a=n.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}:{}})),l=null;return s.responseStatusCode!==null&&s.responseStatusText!==null&&(l={statusCode:s.responseStatusCode,statusText:s.responseStatusText,headers:s.responseHeaders,body:ce(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:ce(s.requestBody)},response:l,...s.error?{error:s.error}:{},assertions:a,specFile:e.specFile,test:t,tests:[r],_testTitle:e.title}})}function Jr(e,t){let r=new Date(e.timestamp).getTime(),n=new Date(t.timestamp).getTime();if(r!==n)return r-n;let s={navigation:0,api_call:1},a=s[e.type],l=s[t.type];return a!==l?a-l:e.type==="api_call"&&t.type==="api_call"&&e.callId&&t.callId?de(e.callId)-de(t.callId):0}function de(e){let t=e.match(/(\d+)$/);return t?parseInt(t[1],10):0}function Kr(e,t){for(let r=0;r<e.length;r++){let n=e[r];if(n.type!=="navigation")continue;let s=new Date(n.timestamp).getTime(),a=null;for(let l=r+1;l<e.length;l++)if(e[l]._testTitle===n._testTitle){a=new Date(e[l].timestamp).getTime();break}if(a!==null)n.durationOnUrl=Math.max(0,a-s);else {let l=t.find(i=>i.title===n._testTitle);if(l){let i=new Date(l.completedAt).getTime();n.durationOnUrl=Math.max(0,i-s);}}}}function ce(e){if(e==null)return null;try{return JSON.parse(e)}catch{return e}}function ot(e,t){let r=e.length,n=Math.min(Math.ceil(t/100*r)-1,r-1);return e[Math.max(0,n)]}function Wr(e){try{let t=new URL(e);return t.origin+t.pathname}catch{return e}}function Yr(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 ue(e,t){let r=0,n=0,s=0,a=0,l=0;for(let m of e)switch(m.status){case "passed":r++;break;case "failed":n++;break;case "flaky":s++;break;case "skipped":a++;break;case "timedout":l++;break}let i=[];for(let m of e)m.apiCalls&&i.push(...m.apiCalls);let o=i.length,c=new Set,d={},p={"2xx":0,"3xx":0,"4xx":0,"5xx":0,error:0},f=[];for(let m of i)c.add(Wr(m.url)),d[m.method]=(d[m.method]??0)+1,p[Yr(m.responseStatusCode)]+=1,f.push(m.responseTimeMs);let u=null;if(f.length>0){let m=[...f].sort((B,M)=>B-M),k=m.reduce((B,M)=>B+M,0);u={avg:Math.round(k/m.length),min:m[0],max:m[m.length-1],p50:ot(m,50),p95:ot(m,95),p99:ot(m,99)};}let h=0,g=0,v=0;for(let m of e)if(m.apiAssertions)for(let k of m.apiAssertions)h++,k.status==="passed"?g++:v++;let y=0,b=new Set;for(let m of e){y+=m.navigations.length;for(let k of m.navigations)b.add(k.url);}let x=0,w={};function A(m){for(let k of m)x++,w[k.category]=(w[k.category]??0)+1,k.children.length>0&&A(k.children);}for(let m of e)m.actions&&A(m.actions);return {total:e.length,passed:r,failed:n,flaky:s,skipped:a,timedout:l,totalApiCalls:o,uniqueApiUrls:c.size,apiCallsByMethod:d,apiCallsByStatusRange:p,apiResponseTime:u,totalAssertions:h,passedAssertions:g,failedAssertions:v,totalNavigations:y,uniqueNavigationUrls:b.size,totalTimelineSteps:t,totalActionSteps:x,actionStepsByCategory:w}}function Zr(e){let t=56-e.length;return t>0?e+" ".repeat(t):e}function C(e){return `\u2502 ${Zr(e)} \u2502
|
|
2097
|
+
`}function fe(e,t,r,n){if(n||e.total===0)return;let s=`\u250C${"\u2500".repeat(58)}\u2510
|
|
1629
2098
|
`,a=`\u2514${"\u2500".repeat(58)}\u2518
|
|
1630
|
-
`,l=
|
|
1631
|
-
`,process.stderr.write(
|
|
1632
|
-
`)[0]?.trim();return n?I(`git remote get-url ${n}`,e):null}function
|
|
2099
|
+
`,l=C(""),i=s;i+=C("TestRelic AI - Playwright Test Report"),i+=l;let o=[];if(e.passed>0&&o.push(`${e.passed} \u2713`),e.failed>0&&o.push(`${e.failed} \u2717`),e.flaky>0&&o.push(`${e.flaky} \u26A0`),e.skipped>0&&o.push(`${e.skipped} skipped`),e.timedout>0&&o.push(`${e.timedout} timedout`),i+=C(`Tests: ${e.total} total (${o.join(" ")})`),e.totalNavigations>0&&(i+=C(`Navigations: ${e.totalNavigations} visits across ${e.uniqueNavigationUrls} unique URLs`)),e.totalApiCalls>0){i+=C(`API Calls: ${e.totalApiCalls} calls across ${e.uniqueApiUrls} unique endpoints`);let c=Object.entries(e.apiCallsByMethod).filter(([,p])=>p>0).map(([p,f])=>`${p}: ${f}`);c.length>0&&(i+=C(` ${c.join(" ")}`));let d=Object.entries(e.apiCallsByStatusRange).filter(([,p])=>p>0).map(([p,f])=>`${p}: ${f}`);d.length>0&&(i+=C(` ${d.join(" ")}`)),e.apiResponseTime&&(i+=C(` Avg response: ${e.apiResponseTime.avg}ms P95: ${e.apiResponseTime.p95}ms`));}if(e.totalAssertions>0&&(i+=C(`Assertions: ${e.totalAssertions} total (${e.passedAssertions} \u2713 ${e.failedAssertions} \u2717)`)),e.totalActionSteps>0){let c=[],d=e.actionStepsByCategory;d.ui_action&&c.push(`${d.ui_action} UI`),d.assertion&&c.push(`${d.assertion} assertions`),d.custom_step&&c.push(`${d.custom_step} custom`);let p=c.length>0?` (${c.join(" ")})`:"";i+=C(`Actions: ${e.totalActionSteps} steps${p}`);}i+=C(`Report: ${r}`),i+=C(`Data: ${t}`),i+=a,i+=`For more information visit us at https://docs.testrelic.ai
|
|
2100
|
+
`,process.stderr.write(i);}var Qr=new Set(["pw:api","expect","test.step"]);function Xr(e){return e==="expect"?"assertion":e==="test.step"?"custom_step":"ui_action"}function lt(e,t,r){if(Qr.has(e.category)){let n=[];for(let a of e.steps)lt(a,t,n);let s=e.startTime.getTime()-t.getTime();r.push({title:e.title,category:Xr(e.category),timestamp:e.startTime.toISOString(),duration:e.duration,videoOffset:s>=0?s/1e3:null,status:e.error?"failed":"passed",error:e.error?.message??null,children:n});}else for(let n of e.steps)lt(n,t,r);}function ge(e,t){let r=[];for(let n of e)lt(n,t,r);return r}var rn=new Set(["localhost","127.0.0.1","0.0.0.0"]);function me(e){let t=new URL(e);if(t.protocol!=="https:"&&!(t.protocol==="http:"&&rn.has(t.hostname)))throw core.createError(core.ErrorCode.CLOUD_CONFIG_INVALID,`HTTPS is required for cloud communication. Got: ${t.protocol}//${t.hostname}`)}var nn=3e3;async function dt(e){let t=new AbortController,r=setTimeout(()=>t.abort(),nn);try{return (await fetch(`${e}/health`,{method:"GET",signal:t.signal})).ok}catch{return false}finally{clearTimeout(r);}}async function ve(e){return new Promise(t=>setTimeout(t,e))}async function he(e){try{let r=(await e.json()).error;if(r&&typeof r.message=="string"){let n=r.details;if(Array.isArray(n)&&n.length>0){let s=n.map(a=>`${a.field}: ${a.message}`).join(", ");return `${r.message} (${s})`}return r.message}}catch{}return `HTTP ${e.status}`}async function ct(e,t,r){let n=new AbortController,s=setTimeout(()=>n.abort(),r);try{let a=await fetch(`${e}/sdk/auth/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t}),signal:n.signal});if(a.ok){let i=await a.json();return {accessToken:i.accessToken,refreshToken:i.refreshToken,expiresIn:i.expiresIn,orgId:i.orgId,orgName:i.orgName,userId:i.userId,userName:i.userName}}if(a.status===429){let i=a.headers.get("Retry-After"),o=i?parseInt(i,10)*1e3:5e3;if(!isNaN(o)&&o>0){await ve(o);let c=await fetch(`${e}/sdk/auth/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t}),signal:n.signal});if(c.ok){let d=await c.json();return {accessToken:d.accessToken,refreshToken:d.refreshToken,expiresIn:d.expiresIn,orgId:d.orgId,orgName:d.orgName,userId:d.userId,userName:d.userName}}}return {code:"rate_limited",message:"Rate limited during token exchange.",statusCode:429}}return a.status===400?{code:"validation_error",message:await he(a),statusCode:400}:a.status===401?{code:"invalid_key",message:"API key is invalid or has been revoked.",statusCode:401}:a.status===403?{code:"expired_key",message:"API key has expired.",statusCode:403}:{code:"server_error",message:await he(a),statusCode:a.status}}catch(a){return a instanceof DOMException&&a.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 pt(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 ye(e,t,r){let n=new AbortController,s=setTimeout(()=>n.abort(),r);try{let a=await fetch(`${e}/sdk/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t}),signal:n.signal});if(a.status===429){let i=a.headers.get("Retry-After"),o=i?parseInt(i,10)*1e3:5e3;!isNaN(o)&&o>0&&(await ve(o),a=await fetch(`${e}/sdk/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t}),signal:n.signal}));}if(!a.ok)return null;let l=await a.json();return {accessToken:l.accessToken,refreshToken:l.refreshToken,expiresIn:l.expiresIn}}catch{return null}finally{clearTimeout(s);}}async function be(e,t,r,n,s,a){let l=new AbortController,i=setTimeout(()=>l.abort(),s);try{let o={gitId:r,displayName:n};a&&(o.branch=a);let c=await fetch(`${e}/repos/resolve`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(o),signal:l.signal});if(!c.ok)return null;let d=await c.json();return {repoId:d.repoId,displayName:d.displayName}}catch{return null}finally{clearTimeout(i);}}var dn=5e3;function I(e,t){try{return child_process.execSync(e,{cwd:t,timeout:dn,encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim()||null}catch{return null}}function xe(e){let t=I("git rev-parse --abbrev-ref HEAD",e),r=I("git rev-parse --short HEAD",e),n=I("git log -1 --pretty=%s",e),s=cn(e),a=s?F(s):null;return {branch:t,commitSha:r,commitMessage:n,remoteUrl:a}}function cn(e){let t=I("git remote get-url origin",e);if(t)return t;let r=I("git remote",e);if(!r)return null;let n=r.split(`
|
|
2101
|
+
`)[0]?.trim();return n?I(`git remote get-url ${n}`,e):null}function F(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 we(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function ut(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 H(e){let t=ut(e);return t||`local/${path.basename(e)}`}var mn="1.0.0",ke=10;function gt(e,t,r,n,s,a,l,i){try{fs.mkdirSync(e,{recursive:!0});let o=Date.now(),c=`${o}-${t}-${r}.json`,d=path.join(e,c),p={version:mn,queuedAt:new Date(o).toISOString(),reason:n,retryCount:0,targetEndpoint:s,method:a,payload:l,headers:i},f=d+".tmp";fs.writeFileSync(f,JSON.stringify(p,null,2),"utf-8"),fs.renameSync(f,d);}catch(o){o.code==="ENOSPC"?process.stderr.write(`\u26A0 TestRelic: Disk full \u2014 unable to queue upload data.
|
|
1633
2102
|
`):process.stderr.write(`\u26A0 TestRelic: Unable to queue upload data.
|
|
1634
|
-
`);}}async function
|
|
1635
|
-
`),fs.unlinkSync(
|
|
1636
|
-
`);return}try{if(
|
|
1637
|
-
`);return}let r=await
|
|
1638
|
-
`),await this.resolveRepoId(),this.config.queueDirectory&&(
|
|
1639
|
-
`);}}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://api.testrelic.com/api/v1"}async ensureValidToken(){if(!this.isCloudMode()||!this.authState.accessToken)return false;let t=this.authState.expiresAt??0;if(Date.now()+
|
|
1640
|
-
`));}async dispose(){if(this.healthCheckTimer&&(clearInterval(this.healthCheckTimer),this.healthCheckTimer=null),this.flushPromise){try{await Promise.race([this.flushPromise,new Promise(t=>setTimeout(t,
|
|
1641
|
-
\u2192 Manage keys: ${
|
|
2103
|
+
`);}}async function Re(e,t,r){let n;try{n=fs.readdirSync(e).filter(a=>a.endsWith(".json")&&!a.endsWith(".tmp")).sort();}catch{return}if(n.length===0)return;let s=[];for(let a=0;a<n.length;a+=ke)s.push(n.slice(a,a+ke));for(let a of s)for(let l of a){let i=path.join(e,l);try{if(!fs.statSync(i).isFile())continue;let c=fs.readFileSync(i,"utf-8"),d=JSON.parse(c);if(!core.isValidQueueEntry(d)){process.stderr.write(`\u26A0 TestRelic: Corrupted queue file deleted: ${l}
|
|
2104
|
+
`),fs.unlinkSync(i);continue}let p=d;if((await fetch(p.targetEndpoint,{method:p.method,headers:{...p.headers,Authorization:`Bearer ${r}`},body:JSON.stringify(p.payload)})).ok)fs.unlinkSync(i);else return}catch{return}}}function Se(e,t){try{let r=fs.readdirSync(e).filter(s=>s.endsWith(".json")&&!s.endsWith(".tmp")),n=Date.now();for(let s of r){let a=path.join(e,s);try{let l=fs.readFileSync(a,"utf-8"),o=JSON.parse(l).queuedAt;if(typeof o=="string"){let c=new Date(o).getTime();n-c>t&&fs.unlinkSync(a);}}catch{try{fs.unlinkSync(a);}catch{}}}}catch{}}var Tn=3e5,Cn=864e5,Rn=6e4,Ae=3e4,mt="https://app.testrelic.com/settings/api-keys",V=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.
|
|
2105
|
+
`);return}try{if(me(this.config.endpoint),this.gitMetadata=xe(),!await dt(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.
|
|
2106
|
+
`);return}let r=await ct(this.config.endpoint,this.config.apiKey,this.config.timeout);if(pt(r)){this.handleAuthError(r.code,r.statusCode);return}let n=r;this.authState={mode:"cloud",accessToken:n.accessToken,refreshToken:n.refreshToken,expiresAt:Date.now()+n.expiresIn*1e3,orgId:n.orgId,orgName:n.orgName,userId:n.userId,userName:n.userName},process.stderr.write(`\u2713 TestRelic: Connected to cloud (${n.orgName} / ${n.userName})
|
|
2107
|
+
`),await this.resolveRepoId(),this.config.queueDirectory&&(Se(this.config.queueDirectory,this.config.queueMaxAge),this.startBackgroundFlush()),this.startHealthCheck();}catch{this.setLocalMode("unexpected_error"),process.stderr.write(`\u26A0 TestRelic: Unexpected error during cloud initialization. Running in local mode.
|
|
2108
|
+
`);}}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://api.testrelic.com/api/v1"}async ensureValidToken(){if(!this.isCloudMode()||!this.authState.accessToken)return false;let t=this.authState.expiresAt??0;if(Date.now()+Tn<t)return true;if(!this.config||!this.authState.refreshToken)return this.switchToLocalMode("token_expired_no_refresh"),false;try{let r=await ye(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}).
|
|
2109
|
+
`));}async dispose(){if(this.healthCheckTimer&&(clearInterval(this.healthCheckTimer),this.healthCheckTimer=null),this.flushPromise){try{await Promise.race([this.flushPromise,new Promise(t=>setTimeout(t,Ae))]);}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.
|
|
2110
|
+
\u2192 Manage keys: ${mt}
|
|
1642
2111
|
`);break;case "expired_key":this.setLocalMode("expired_api_key"),process.stderr.write(`\u26A0 TestRelic: API key has expired. Running in local mode.
|
|
1643
|
-
\u2192 Generate a new key: ${
|
|
2112
|
+
\u2192 Generate a new key: ${mt}
|
|
1644
2113
|
`);break;case "validation_error":this.setLocalMode("validation_error"),process.stderr.write(`\u26A0 TestRelic: API key format invalid. Running in local mode.
|
|
1645
|
-
\u2192 Manage keys: ${
|
|
2114
|
+
\u2192 Manage keys: ${mt}
|
|
1646
2115
|
`);break;case "rate_limited":this.setLocalMode("rate_limited"),process.stderr.write(`\u26A0 TestRelic: Rate limited during authentication. Running in local mode.
|
|
1647
2116
|
`);break;case "timeout":this.setLocalMode("auth_timeout"),process.stderr.write(`\u26A0 TestRelic: Authentication timed out. Running in local mode.
|
|
1648
2117
|
`);break;default:this.setLocalMode(`auth_error_${r??"unknown"}`),process.stderr.write(`\u26A0 TestRelic: Cloud authentication failed. Running in local mode.
|
|
1649
|
-
`);break}}async resolveRepoId(){if(!this.config||!this.authState.accessToken)return;let t=this.gitMetadata?.remoteUrl?
|
|
1650
|
-
`);}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 n=fs.readFileSync(r,"utf-8"),s=JSON.parse(n);if(s.gitId!==t||Date.now()-s.resolvedAt>
|
|
1651
|
-
`),this.startBackgroundFlush();}}}catch{}},
|
|
1652
|
-
`);}if(!d){s=t.filter(
|
|
1653
|
-
`),{navigations:s,networkRequests:a,apiCalls:l,apiAssertions:
|
|
2118
|
+
`);break}}async resolveRepoId(){if(!this.config||!this.authState.accessToken)return;let t=this.gitMetadata?.remoteUrl?F(this.gitMetadata.remoteUrl):null,r=t?we(t):this.config.projectName??H(process.cwd()),n=t??this.config.projectName??H(process.cwd()),s=this.readRepoCache(n);if(s){this.repoId=s.repoId;return}try{let a=await be(this.config.endpoint,this.authState.accessToken,n,r,this.config.timeout,this.gitMetadata?.branch);a&&(this.repoId=a.repoId,this.writeRepoCache(n,a.repoId,a.displayName));}catch{}!t&&!this.config.projectName&&!ut(process.cwd())&&process.stderr.write(`\u2139 TestRelic: No git remote or package.json detected. Set project.name in .testrelic for stable project identity.
|
|
2119
|
+
`);}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 n=fs.readFileSync(r,"utf-8"),s=JSON.parse(n);if(s.gitId!==t||Date.now()-s.resolvedAt>Cn)return null;let a=this.hashApiKey();return a&&s.apiKeyHash!==a?null:s}catch{return null}}writeRepoCache(t,r,n){if(!this.config)return;let s=path.join(this.config.queueDirectory,"..","cache"),a=path.join(s,"repo.json");try{fs.mkdirSync(s,{recursive:!0});let l={repoId:r,gitId:t,displayName:n,resolvedAt:Date.now(),apiKeyHash:this.hashApiKey()??""},i=a+".tmp";fs.writeFileSync(i,JSON.stringify(l,null,2),"utf-8"),fs.renameSync(i,a);}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,n=this.config.endpoint;this.flushPromise=Promise.race([Re(r,n,t),new Promise(s=>setTimeout(s,Ae))]).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 dt(t))return;if(this.config?.apiKey){let n=await ct(this.config.endpoint,this.config.apiKey,this.config.timeout);if(!pt(n)){let s=n;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.
|
|
2120
|
+
`),this.startBackgroundFlush();}}}catch{}},Rn);}};var An=1048576,J=[1e3,3e3,9e3],K=3;function vt(e,t,r,n){return {runId:e.testRunId,repoGitId:t,startedAt:e.startedAt,summary:e.summary,timeline:e.timeline,...r?.branch?{branch:r.branch}:{},...r?.commitSha?{commit:r.commitSha}:{},...r?.commitMessage?{commitMessage:r.commitMessage}:{},...e.completedAt?{finishedAt:e.completedAt}:{},...e.totalDuration?{duration:e.totalDuration}:{},...n?.provider?{ciProvider:n.provider}:{},...n?.runUrl?{ciRunUrl:n.runUrl}:{}}}async function W(e){return new Promise(t=>setTimeout(t,e))}function _n(e){let t={};for(let[r,n]of Object.entries(e))n!=null&&(t[r]=n);return t}async function In(e,t,r){for(let n=0;n<K;n++)try{let s=await fetch(e,t);if(s.ok)return s;if(s.status===401&&r&&n===0){let a=await r();if(a){let l={...t,headers:{...t.headers,Authorization:`Bearer ${a}`}},i=await fetch(e,l);if(i.ok)return i}return null}if(s.status===429&&n<K-1){let a=s.headers.get("Retry-After"),l=a?parseInt(a,10)*1e3:J[n];!isNaN(l)&&l>0?await W(l):await W(J[n]);continue}if(s.status>=500&&n<K-1){await W(J[n]);continue}return s}catch{if(n<K-1){await W(J[n]);continue}return null}return null}function Nn(e){let t=JSON.stringify(e),r={"Content-Type":"application/json"};if(Buffer.byteLength(t,"utf-8")>An){let n=zlib.gzipSync(Buffer.from(t,"utf-8"));return r["Content-Encoding"]="gzip",{body:n,headers:r}}return {body:t,headers:r}}async function _e(e,t,r,n){let s=`${e}/runs`,{body:a,headers:l}=Nn(r);l.Authorization=`Bearer ${t}`;let i=await In(s,{method:"POST",headers:l,body:a},n);return i?.ok?{success:true,statusCode:i.status,error:null}:i?.status===409?{success:true,statusCode:409,error:null}:{success:false,reason:i?`Upload failed with status ${i.status}`:"Upload failed after retries",statusCode:i?.status??null,payload:r,targetEndpoint:s,method:"POST"}}async function Ie(e,t,r){let n=`${e}/runs/init`;try{let s=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(_n(r))});return s.ok?{runId:(await s.json()).runId}:null}catch{return null}}function Ne(e,t,r,n){let s=`${e}/runs/${r}/tests`;fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(n)}).catch(()=>{});}async function Le(e,t,r,n){let s=`${e}/runs/${r}/finalize`;try{return (await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(n)})).ok}catch{return false}}function Ee(e,t,r,n){let s=[],a=null,l=null,i=null,o=null,c=e.filter(f=>f.name===core.ATTACHMENT_NAME&&f.body),d=false;if(c.length>0)for(let f of c)try{let u=JSON.parse(f.body.toString());if(core.isTestRelicDataPayload(u)){s=s.concat(u.navigations),u.networkRequests.length>0&&(a=(a??[]).concat(u.networkRequests)),u.apiCalls.length>0&&(l=(l??[]).concat(u.apiCalls)),u.apiAssertions.length>0&&(i=(i??[]).concat(u.apiAssertions));let h=u.consoleLogs;Array.isArray(h)&&h.length>0&&(o=(o??[]).concat(h)),d=!0;}}catch{process.stderr.write(`[testrelic] Warning: Corrupt attachment for test "${r}", falling back to annotations
|
|
2121
|
+
`);}if(!d){s=t.filter(g=>g.type==="lambdatest-navigation"&&g.description).map(g=>{try{return JSON.parse(g.description)}catch{return null}}).filter(g=>g!==null);let f=t.find(g=>g.type==="__testrelic_network_requests"&&g.description);if(f)try{a=JSON.parse(f.description);}catch{}let u=t.find(g=>g.type==="__testrelic_api_calls"&&g.description);if(u)try{l=JSON.parse(u.description);}catch{}let h=t.find(g=>g.type==="__testrelic_api_assertions"&&g.description);if(h)try{i=JSON.parse(h.description);}catch{}}return s.length===0&&!a&&!l&&!i&&!o&&!n&&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 timeline data cannot be captured.
|
|
2122
|
+
`),{navigations:s,networkRequests:a,apiCalls:l,apiAssertions:i,consoleLogs:o}}function yt(e){let r=e.getGitMetadata()?.remoteUrl;return r?F(r):e.getConfig()?.projectName??H(process.cwd())}async function Be(e,t,r,n){if(!e.isCloudMode()||t!=="realtime"&&t!=="both"||!await e.ensureValidToken())return null;let a=e.getGitMetadata(),l=_();return (await Ie(e.getEndpoint(),e.getAccessToken(),{runId:r,repoGitId:yt(e),branch:a?.branch??null,commit:a?.commitSha??null,startedAt:n,totalTests:null,ciProvider:l?.provider??null,ciRunUrl:l?.runUrl??null}))?.runId??null}async function Me(e,t,r,n,s,a,l,i,o){try{if(e.isCloudMode()&&s&&(r==="realtime"||r==="both")&&await e.ensureValidToken()&&await Le(e.getEndpoint(),e.getAccessToken(),s,{finishedAt:l,duration:i,summary:o}),e.isCloudMode()&&(!r||r==="batch"||r==="both"))if(await e.ensureValidToken()){let d=e.getGitMetadata(),p=_(),f=yt(e),u=vt(a,f,d,p),h=await _e(e.getEndpoint(),e.getAccessToken(),u,async()=>await e.ensureValidToken()?e.getAccessToken():null);if(!h.success){let g=h,v=t?.queueDirectory??".testrelic/queue";gt(v,n,"batch",g.reason,g.targetEndpoint,g.method,g.payload,{"Content-Type":"application/json"});}}else {let d=t?.queueDirectory??".testrelic/queue",p=e.getGitMetadata(),f=_(),u=yt(e),h=vt(a,u,p,f);gt(d,n,"batch",e.getFailureReason()??"token_invalid",`${e.getEndpoint()}/runs`,"POST",h,{"Content-Type":"application/json"});}await e.dispose();}catch{try{await e.dispose();}catch{}}}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 Dn(e,t,r){let n=`${e}::${t}::${r}`;return crypto.createHash("sha256").update(n).digest("hex").substring(0,16)}function On(e){return e.length<=4?"":e[e.length-2]}function Fn(e){let t=e.findIndex(r=>r.status==="passed");return t>0?`passed on retry ${t}`:null}function Hn(e,t){let r=["e2e","api","unit"];for(let s of r)if(e.some(a=>a===`@${s}`||a===s))return s;let n=t.replace(/\\/g,"/");for(let s of r)if(n.includes(`/${s}/`))return s;return "unknown"}var Un="__testrelic_api_config";function zn(e){return JSON.stringify(e,(t,r)=>r instanceof RegExp?{__regexp:true,source:r.source,flags:r.flags}:r)}var Z=class{constructor(t){this.rootDir="";this.startedAt="";this.testRunId="";this.collectedTests=[];this.fixtureDataReceived=false;this.cloudClient=null;this.cloudRunId=null;this.runTimestamp="";this.config=Pt(t),this.apiConfig=Mt(t);}async onBegin(t,r){try{if(this.rootDir=t.rootDir,this.startedAt=new Date().toISOString(),this.testRunId=this.config.testRunId??crypto.randomUUID(),this.config.includeArtifacts){let n=path.dirname(this.config.outputPath);this.runTimestamp=ne(path.join(n,"artifacts"));try{le(path.join(n,"artifacts"));}catch{}}try{this.cloudClient=new V(this.config.cloud),await this.cloudClient.initialize(),this.cloudRunId=await Be(this.cloudClient,this.config.cloud?.uploadStrategy,this.testRunId,this.startedAt);}catch{this.cloudClient?.switchToLocalMode("init_error");}}catch{}}onTestBegin(t,r){try{t.annotations.push({type:Un,description:zn(this.apiConfig)});}catch{}}onTestEnd(t,r){try{let n=r,s=t.outcome(),a;s==="flaky"?a="flaky":s==="skipped"?a="skipped":a=xt(n.status);let l=n.startTime.toISOString(),i=new Date(n.startTime.getTime()+n.duration).toISOString(),o=t.tags?[...t.tags]:t.annotations.filter(S=>S.type==="tag").map(S=>S.description??""),{navigations:c,networkRequests:d,apiCalls:p,apiAssertions:f,consoleLogs:u}=Ee(n.attachments,t.annotations,t.title,a==="skipped");(c.length>0||d||p)&&(this.fixtureDataReceived=!0);let h=null;if(a==="failed"||a==="flaky"){let T=(a==="flaky"?t.results.find(P=>P.status!=="passed")?.errors??[]:n.errors)[0];if(T){let P=Dt(this.config.redactPatterns),et=T.location?.line??null,q=null;this.config.includeCodeSnippets&&et!==null&&T.location?.file&&(q=qt(T.location.file,et,this.config.codeContextLines),q&&(q=P(q))),h={message:P(T.message??"Unknown error"),line:et,code:q,stack:this.config.includeStackTrace&&T.stack?P(T.stack):null};}}let g=t.titlePath().filter(Boolean),v=path.relative(this.rootDir||".",t.location.file),y=On(g),b=g.join(" > "),x=v,w=Dn(x,y,b),A=Hn(o,x),m=s==="flaky",k=Fn(t.results),B=xt(t.expectedStatus),M=xt(n.status),Rt=null;if(this.config.includeArtifacts&&a!=="skipped"&&n.attachments){let S=path.dirname(this.config.outputPath),T=g[g.length-1]??t.title;Rt=se(n.attachments,T,n.retry,S,this.runTimestamp||void 0);}let Je=this.config.includeActionSteps&&n.steps?ge(n.steps,n.startTime):null,St={titlePath:g,title:b,status:a,duration:n.duration,startedAt:l,completedAt:i,retryCount:t.results.length-1,retry:n.retry,tags:o,failure:h,specFile:v,navigations:c,testId:w,filePath:x,suiteName:y,testType:A,isFlaky:m,retryStatus:k,expectedStatus:B,actualStatus:M,artifacts:Rt,networkRequests:d,apiCalls:p,apiAssertions:f,actions:Je,consoleLogs:u};this.collectedTests.push(St);try{let S=this.config.cloud?.uploadStrategy;if(this.cloudClient?.isCloudMode()&&this.cloudRunId&&(S==="realtime"||S==="both")){let T=this.cloudClient.getAccessToken();T&&Ne(this.cloudClient.getEndpoint(),T,this.cloudRunId,this.toTestResult(St));}}catch{}}catch{}}async onEnd(t){try{let r=new Date().toISOString(),n=new Date(this.startedAt).getTime(),a=new Date(r).getTime()-n,l=this.buildTimeline(),i=ue(this.collectedTests,l.length),o={schemaVersion:nt,testRunId:this.testRunId,startedAt:this.startedAt,completedAt:r,totalDuration:a,summary:i,ci:_(),metadata:this.config.metadata,timeline:l,shardRunIds:null};!this.fixtureDataReceived&&this.collectedTests.some(d=>d.status!=="skipped")&&process.stderr.write(`
|
|
1654
2123
|
\u26A0 TestRelic: No fixture data received from any test.
|
|
1655
2124
|
To enable network logs, video sync, and timeline tracking, import the TestRelic fixture:
|
|
1656
2125
|
import { test, expect } from '@testrelic/playwright-analytics/fixture';
|
|
1657
2126
|
instead of:
|
|
1658
2127
|
import { test, expect } from '@playwright/test';
|
|
1659
2128
|
|
|
1660
|
-
`),this.writeReport(
|
|
1661
|
-
`);}}};var fn=["text/","application/json","application/xml","application/javascript","application/x-www-form-urlencoded","application/graphql"];function hn(e){let t=e.toLowerCase();return fn.some(r=>t.includes(r))}function me(e,t){let r=new TextEncoder().encode(e);return r.length<=t?{text:e,truncated:false}:{text:new TextDecoder().decode(r.slice(0,t)),truncated:true}}var $=class e{constructor(t,r){this.page=t;this.records=[];this.listeners=[];this.currentNetworkCounter=null;this.pendingRequests=new Map;this.capturedRequests=[];this.pendingBodyReads=[];this.requestIdCounter=0;this.requestCaptureCount=0;this.consoleLogs=[];this.includeNetworkStats=r?.includeNetworkStats??true,this.origGoto=t.goto.bind(t),this.origGoBack=t.goBack.bind(t),this.origGoForward=t.goForward.bind(t),this.origReload=t.reload.bind(t),this.interceptMethods(),this.attachListeners();}async init(){await this.injectSPADetection();}async getCapturedRequests(){await Promise.allSettled(this.pendingBodyReads),this.pendingBodyReads=[];for(let[t,r]of this.pendingRequests)this.capturedRequests.push({url:r.url,method:r.method,resourceType:r.resourceType,statusCode:0,responseTimeMs:Date.now()-r.startTimeMs,startedAt:r.startedAt,requestHeaders:r.headers,requestBody:r.postData,responseBody:null,responseHeaders:null,contentType:null,responseSize:0,requestBodyTruncated:r.postDataTruncated,responseBodyTruncated:false,isBinary:false,error:"incomplete"}),this.pendingRequests.delete(t);return [...this.capturedRequests].sort((t,r)=>t.startedAt.localeCompare(r.startedAt))}static mapConsoleType(t){switch(t){case "log":return "log";case "warning":return "warn";case "error":return "error";case "info":return "info";case "debug":return "debug";default:return "log"}}async getData(){this.includeNetworkStats&&this.currentNetworkCounter&&this.records.length>0&&(this.records[this.records.length-1].networkStats={totalRequests:this.currentNetworkCounter.totalRequests,failedRequests:this.currentNetworkCounter.failedRequests,failedRequestUrls:[...this.currentNetworkCounter.failedRequestUrls],totalBytes:this.currentNetworkCounter.totalBytes,byType:{...this.currentNetworkCounter.byType}});let t=this.records.map(n=>({url:n.url,navigationType:n.navigationType,timestamp:n.timestamp,domContentLoadedAt:n.domContentLoadedAt,networkIdleAt:n.networkIdleAt,networkStats:n.networkStats})),r=this.includeNetworkStats?await this.getCapturedRequests():[];return {navigations:t,networkRequests:r,consoleLogs:[...this.consoleLogs]}}async flushLegacyAnnotations(t){this.includeNetworkStats&&this.currentNetworkCounter&&this.records.length>0&&(this.records[this.records.length-1].networkStats={totalRequests:this.currentNetworkCounter.totalRequests,failedRequests:this.currentNetworkCounter.failedRequests,failedRequestUrls:[...this.currentNetworkCounter.failedRequestUrls],totalBytes:this.currentNetworkCounter.totalBytes,byType:{...this.currentNetworkCounter.byType}});for(let r of this.records){let n={url:r.url,navigationType:r.navigationType,timestamp:r.timestamp,domContentLoadedAt:r.domContentLoadedAt,networkIdleAt:r.networkIdleAt,networkStats:r.networkStats};t.annotations.push({type:"lambdatest-navigation",description:JSON.stringify(n)});}if(this.includeNetworkStats){let r=await this.getCapturedRequests();r.length>0&&t.annotations.push({type:"__testrelic_network_requests",description:JSON.stringify(r)});}}dispose(){this.page.goto=this.origGoto,this.page.goBack=this.origGoBack,this.page.goForward=this.origGoForward,this.page.reload=this.origReload;for(let{event:t,handler:r}of this.listeners)this.page.off(t,r);this.listeners=[],this.records=[],this.pendingRequests.clear(),this.capturedRequests=[],this.pendingBodyReads=[],this.requestCaptureCount=0;}getRecords(){return this.records}interceptMethods(){let t=this,r=this.page;r.goto=async function(n,s){return t.recordNavigation(n,"goto"),t.origGoto(n,s)},r.goBack=async function(n){let s=await t.origGoBack(n);return t.recordNavigation(r.url(),"back"),s},r.goForward=async function(n){let s=await t.origGoForward(n);return t.recordNavigation(r.url(),"forward"),s},r.reload=async function(n){return t.recordNavigation(r.url(),"refresh"),t.origReload(n)};}attachListeners(){let t=()=>{this.lastDomContentLoaded=new Date().toISOString(),this.records.length>0&&(this.records[this.records.length-1].domContentLoadedAt=this.lastDomContentLoaded);};this.page.on("domcontentloaded",t),this.listeners.push({event:"domcontentloaded",handler:t});let r=s=>{try{let a=s;if(typeof a.parentFrame=="function"&&a.parentFrame()!==null)return;let l=a.url(),o=this.records[this.records.length-1];if(o&&Date.now()-new Date(o.timestamp).getTime()<50&&o.url===l)return;this.recordNavigation(l,"navigation");}catch{}};this.page.on("framenavigated",r),this.listeners.push({event:"framenavigated",handler:r});let n=s=>{try{let a=s,l=a.type(),o=a.text();if(l==="debug"&&o.startsWith("__testrelic_nav:")){try{let i=JSON.parse(o.slice(16));i.type&&i.url&&this.recordNavigation(i.url,i.type);}catch{}return}{let i=null;try{let d=a.location();d&&d.url&&(i=`${d.url}:${d.lineNumber}:${d.columnNumber}`);}catch{}let c=e.mapConsoleType(l);this.consoleLogs.push({level:c,text:o,timestamp:new Date().toISOString(),location:i});}}catch{}};if(this.page.on("console",n),this.listeners.push({event:"console",handler:n}),this.includeNetworkStats){let s=o=>{if(this.currentNetworkCounter&&this.currentNetworkCounter.totalRequests++,!(this.requestCaptureCount>=500)){this.requestCaptureCount++;try{let i=o,c=String(this.requestIdCounter++),d=i.postData()??null,u=!1;if(d!==null){let p=me(d,10240);d=p.text,u=p.truncated;}let g={url:i.url(),method:i.method(),resourceType:this.mapResourceType(i.resourceType()),headers:i.headers(),postData:d,postDataTruncated:u,startedAt:new Date().toISOString(),startTimeMs:Date.now()};this.pendingRequests.set(c,g),o.__testrelic_id=c;}catch{}}};this.page.on("request",s),this.listeners.push({event:"request",handler:s});let a=o=>{try{let i=o;if(this.currentNetworkCounter){let y=i.status();y>=400&&(this.currentNetworkCounter.failedRequests++,this.currentNetworkCounter.failedRequestUrls.push(y+" "+i.url()));let b=i.headers()["content-length"];b&&(this.currentNetworkCounter.totalBytes+=parseInt(b,10)||0);let w=i.request().resourceType(),x=this.mapResourceType(w);this.currentNetworkCounter.byType[x]++;}let c=i.request().__testrelic_id;if(!c)return;let d=this.pendingRequests.get(c);if(!d)return;this.pendingRequests.delete(c);let u=Date.now()-d.startTimeMs,g=i.headers(),p=g["content-type"]??null,m=parseInt(g["content-length"]??"0",10)||0,f=p?!hn(p):!1,v=(async()=>{let y=null,b=!1;if(!f)try{let S=(await i.body()).toString("utf-8"),h=me(S,10240);y=h.text,b=h.truncated;}catch{}let w={url:d.url,method:d.method,resourceType:d.resourceType,statusCode:i.status(),responseTimeMs:u,startedAt:d.startedAt,requestHeaders:d.headers,requestBody:d.postData,responseBody:y,responseHeaders:g,contentType:p,responseSize:m,requestBodyTruncated:d.postDataTruncated,responseBodyTruncated:b,isBinary:f,error:null};this.capturedRequests.push(w);})();this.pendingBodyReads.push(v);}catch{}};this.page.on("response",a),this.listeners.push({event:"response",handler:a});let l=o=>{if(this.currentNetworkCounter){this.currentNetworkCounter.failedRequests++;try{let i=o;this.currentNetworkCounter.failedRequestUrls.push("ERR "+i.url());}catch{}}try{let i=o,c=i.__testrelic_id;if(!c)return;let d=this.pendingRequests.get(c);if(!d)return;this.pendingRequests.delete(c);let u={url:d.url,method:d.method,resourceType:d.resourceType,statusCode:0,responseTimeMs:Date.now()-d.startTimeMs,startedAt:d.startedAt,requestHeaders:d.headers,requestBody:d.postData,responseBody:null,responseHeaders:null,contentType:null,responseSize:0,requestBodyTruncated:d.postDataTruncated,responseBodyTruncated:!1,isBinary:!1,error:i.failure()?.errorText??"Unknown error"};this.capturedRequests.push(u);}catch{}};this.page.on("requestfailed",l),this.listeners.push({event:"requestfailed",handler:l});}}async injectSPADetection(){try{await this.page.addInitScript(()=>{let t=history.pushState.bind(history),r=history.replaceState.bind(history);history.pushState=function(...n){t(...n),console.debug("__testrelic_nav:"+JSON.stringify({type:"spa_route",url:location.href}));},history.replaceState=function(...n){r(...n),console.debug("__testrelic_nav:"+JSON.stringify({type:"spa_replace",url:location.href}));},window.addEventListener("popstate",()=>{console.debug("__testrelic_nav:"+JSON.stringify({type:"popstate",url:location.href}));}),window.addEventListener("hashchange",()=>{console.debug("__testrelic_nav:"+JSON.stringify({type:"hash_change",url:location.href}));});});}catch{}}recordNavigation(t,r){this.includeNetworkStats&&this.currentNetworkCounter&&this.records.length>0&&(this.records[this.records.length-1].networkStats={totalRequests:this.currentNetworkCounter.totalRequests,failedRequests:this.currentNetworkCounter.failedRequests,failedRequestUrls:[...this.currentNetworkCounter.failedRequestUrls],totalBytes:this.currentNetworkCounter.totalBytes,byType:{...this.currentNetworkCounter.byType}}),this.records.push({url:t,navigationType:r,timestamp:new Date().toISOString()}),this.includeNetworkStats&&(this.currentNetworkCounter=this.createNetworkCounter());}createNetworkCounter(){return {totalRequests:0,failedRequests:0,failedRequestUrls:[],totalBytes:0,byType:{xhr:0,document:0,script:0,stylesheet:0,image:0,font:0,other:0}}}mapResourceType(t){switch(t){case "xhr":case "fetch":return "xhr";case "document":return "document";case "script":return "script";case "stylesheet":return "stylesheet";case "image":return "image";case "font":return "font";default:return "other"}}};var ye=Symbol.for("__testrelic_call_id"),mn="__testrelic_api_assertions",L=new WeakMap,_=class{constructor(){this.assertions=[];this.currentCallId=null;}recordAssertion(t){this.assertions.push(t);}getAssertions(){return this.assertions}setCurrentCallId(t){this.currentCallId=t;}getCurrentCallId(){return this.currentCallId}getData(){return [...this.assertions]}flushLegacyAnnotations(t){this.assertions.length!==0&&t.annotations.push({type:mn,description:JSON.stringify(this.assertions)});}dispose(){this.assertions=[],this.currentCallId=null;}};var be="[REDACTED]";function pt(e,t){if(e===null||t.length===0)return e;let r=new Set(t.map(s=>s.toLowerCase())),n={};for(let s of Object.keys(e))Object.hasOwn(e,s)&&(n[s]=r.has(s.toLowerCase())?be:e[s]);return n}function G(e,t){if(e===null||t.length===0)return e;let r;try{r=JSON.parse(e);}catch{return e}if(typeof r!="object"||r===null)return e;let n=new Set(t),s=ct(r,n);return JSON.stringify(s)}function ct(e,t){if(Array.isArray(e))return e.map(r=>ct(r,t));if(typeof e=="object"&&e!==null){let r={};for(let n of Object.keys(e)){if(!Object.hasOwn(e,n))continue;let s=e[n];t.has(n)?r[n]=be:r[n]=ct(s,t);}return r}return e}function we(e,t,r){if(r.length>0){for(let n of r)if(ve(e,n))return false}if(t.length>0){for(let n of t)if(ve(e,n))return true;return false}return true}function ve(e,t){try{return t instanceof RegExp?t.test(e):yn(t).test(e)}catch{return console.warn(`[testrelic] Invalid URL filter pattern: ${String(t)}`),false}}function yn(e){let t="",r=0;for(;r<e.length;){let n=e[r];n==="*"&&e[r+1]==="*"?(t+=".*",r+=2,e[r]==="/"&&r++):n==="*"?(t+="[^/]*",r++):n==="?"?(t+="[^/]",r++):".+^${}()|[]\\".includes(n)?(t+="\\"+n,r++):(t+=n,r++);}return new RegExp(t)}var bn=["get","post","put","patch","delete","head","fetch"],vn=["text/","application/json","application/xml","application/javascript","application/x-www-form-urlencoded","application/graphql"],wn="__testrelic_api_calls";function xn(e){let t=e.toLowerCase();return vn.some(r=>t.includes(r))}function kn(e){if(!e)return null;if(e.data!==void 0&&e.data!==null){let t=e.data;return typeof t=="string"?t:Buffer.isBuffer(t)?t.toString("base64"):JSON.stringify(t)}if(e.form!==void 0&&e.form!==null)return JSON.stringify(e.form);if(e.multipart!==void 0&&e.multipart!==null){let t=e.multipart,r={};for(let[n,s]of Object.entries(t))typeof s=="string"||typeof s=="number"||typeof s=="boolean"?r[n]=String(s):s&&typeof s=="object"&&"name"in s?r[n]=`[file: ${s.name}]`:r[n]="[binary]";return JSON.stringify(r)}return null}var V=class V{constructor(t,r,n){this.originals=new Map;this.capturedCalls=[];this.callCounter=0;this.disposed=false;this._lastCallId=null;this.primitiveCallIds=new Map;this.context=t,this.assertionTracker=r??null,this.apiConfig=n??V.DEFAULT_API_CONFIG;}get lastCallId(){return this._lastCallId}getCallIdForValue(t){return t!=null&&typeof t=="object"?L.get(t)??null:this.primitiveCallIds.get(t)??null}intercept(){for(let r of bn){let n=this.context[r].bind(this.context);this.originals.set(r,n),this.context[r]=this.createWrapper(r,n);}let t=this.context.dispose.bind(this.context);this.originals.set("dispose",t),this.context.dispose=async r=>(this.disposed=true,t(r));}getData(){return [...this.capturedCalls]}flushLegacyAnnotations(t){this.capturedCalls.length!==0&&t.annotations.push({type:wn,description:JSON.stringify(this.capturedCalls)});}dispose(){for(let[t,r]of this.originals)this.context[t]=r;this.originals.clear(),this.capturedCalls=[],this.callCounter=0,this._lastCallId=null,this.primitiveCallIds.clear();}get isDisposed(){return this.disposed}getCapturedCalls(){return this.capturedCalls}tagResponseMethods(t,r){let n=this,s=t.headers.bind(t);t.headers=function(){let p=s();return L.set(p,r),p};let a=t.headersArray.bind(t);t.headersArray=function(){let p=a();return L.set(p,r),p};let l=t.json.bind(t);t.json=async function(){let p=await l();return p!=null&&typeof p=="object"&&L.set(p,r),p};let o=t.status.bind(t);t.status=function(){let p=o();return n.primitiveCallIds.set(p,r),p};let i=t.statusText.bind(t);t.statusText=function(){let p=i();return n.primitiveCallIds.set(p,r),p};let c=t.ok.bind(t);t.ok=function(){let p=c();return n.primitiveCallIds.set(p,r),p};let d=t.text.bind(t);t.text=async function(){let p=await d();return n.primitiveCallIds.set(p,r),p};let u=t.body.bind(t);t.body=async function(){let p=await u();return L.set(p,r),p};}createWrapper(t,r){let n=this;return async function(a,l){if(!we(a,n.apiConfig.apiIncludeUrls,n.apiConfig.apiExcludeUrls))return r(a,l);let o=`api-call-${n.callCounter++}`,i=new Date().toISOString(),c=t==="fetch"?(l?.method??"GET").toUpperCase():t.toUpperCase(),d=kn(l),u=perf_hooks.performance.now();n._lastCallId=o,n.assertionTracker&&n.assertionTracker.setCurrentCallId(o);let g;try{g=await r(a,l);}catch(p){let m=perf_hooks.performance.now();try{let f=n.apiConfig.captureRequestBody?G(d,n.apiConfig.redactBodyFields):null,v={id:o,timestamp:i,method:c,url:a,requestHeaders:null,requestBody:f,responseStatusCode:null,responseStatusText:null,responseHeaders:null,responseBody:null,responseTimeMs:Math.round((m-u)*100)/100,isBinary:!1,error:p instanceof Error?p.message:String(p)};n.capturedCalls.push(v);}catch{}throw p}try{let p=perf_hooks.performance.now(),m=g.headers(),f=m["content-type"]??null,v=f?!xn(f):!1,y=null;n.apiConfig.captureRequestHeaders&&l?.headers&&(y=l.headers);let b=null;n.apiConfig.captureResponseHeaders&&(b=m);let w=n.apiConfig.captureRequestBody?d:null,x=null;if(n.apiConfig.captureResponseBody)try{v?x=(await g.body()).toString("base64"):x=await g.text();}catch{}y=pt(y,n.apiConfig.redactHeaders),b=pt(b,n.apiConfig.redactHeaders),w=G(w,n.apiConfig.redactBodyFields),x=G(x,n.apiConfig.redactBodyFields);let S={id:o,timestamp:i,method:c,url:g.url(),requestHeaders:y,requestBody:w,responseStatusCode:g.status(),responseStatusText:g.statusText(),responseHeaders:b,responseBody:x,responseTimeMs:Math.round((p-u)*100)/100,isBinary:v,error:null};n.capturedCalls.push(S);}catch{}try{g[ye]=o,n.tagResponseMethods(g,o);}catch{}return g}}};V.DEFAULT_API_CONFIG=Object.freeze({trackApiCalls:true,captureRequestHeaders:true,captureResponseHeaders:true,captureRequestBody:true,captureResponseBody:true,captureAssertions:true,redactHeaders:["authorization","cookie","set-cookie","x-api-key"],redactBodyFields:["password","secret","token","apiKey","api_key"],apiIncludeUrls:[],apiExcludeUrls:[]});var N=V;var Tn="__testrelic_api_config",Rn="__testrelic_config_trackApiCalls";function gt(e){let t=e.annotations.find(n=>n.type===Tn&&n.description!==void 0);if(t)try{return JSON.parse(t.description,Sn)}catch{}let r=e.annotations.find(n=>n.type===Rn&&n.description!==void 0);return r?{trackApiCalls:r.description!=="false",captureRequestHeaders:true,captureResponseHeaders:true,captureRequestBody:true,captureResponseBody:true,captureAssertions:true,redactHeaders:["authorization","cookie","set-cookie","x-api-key"],redactBodyFields:["password","secret","token","apiKey","api_key"],apiIncludeUrls:[],apiExcludeUrls:[]}:{trackApiCalls:true,captureRequestHeaders:true,captureResponseHeaders:true,captureRequestBody:true,captureResponseBody:true,captureAssertions:true,redactHeaders:["authorization","cookie","set-cookie","x-api-key"],redactBodyFields:["password","secret","token","apiKey","api_key"],apiIncludeUrls:[],apiExcludeUrls:[]}}function Sn(e,t){if(typeof t=="object"&&t!==null&&t.__regexp===true&&typeof t.source=="string"){let{source:r,flags:n}=t;return new RegExp(r,n)}return t}var Te={page:async({page:e},t,r)=>{let n=new $(e);try{await n.init();}catch{}await t(e);try{let{navigations:s,networkRequests:a,consoleLogs:l}=await n.getData(),o={testRelicData:!0,version:core.PAYLOAD_VERSION,navigations:s,networkRequests:a,apiCalls:[],apiAssertions:[],consoleLogs:l};await r.attach(core.ATTACHMENT_NAME,{body:Buffer.from(JSON.stringify(o)),contentType:core.ATTACHMENT_CONTENT_TYPE});}catch{}try{await n.flushLegacyAnnotations(r);}catch{}n.dispose();},request:async({request:e},t,r)=>{let n=gt(r);if(!n.trackApiCalls){await t(e);return}let s=new _,a=new N(e,s,n);a.intercept(),await t(e);try{let l=a.getData(),o=n.captureAssertions?s.getData():[],i={testRelicData:!0,version:core.PAYLOAD_VERSION,navigations:[],networkRequests:[],apiCalls:l,apiAssertions:o,consoleLogs:[]};await r.attach(core.ATTACHMENT_NAME,{body:Buffer.from(JSON.stringify(i)),contentType:core.ATTACHMENT_CONTENT_TYPE});}catch{}try{a.flushLegacyAnnotations(r);}catch{}try{s.flushLegacyAnnotations(r);}catch{}a.dispose(),s.dispose();}};test.test.extend(Te);var Ln={request:async({request:e},t,r)=>{let n=gt(r);if(!n.trackApiCalls){await t(e);return}let s=new _,a=new N(e,s,n);a.intercept();let l=[],o=process.stdout.write,i=process.stderr.write;process.stdout.write=function(c,...d){try{let u=typeof c=="string"?c:Buffer.isBuffer(c)?c.toString("utf-8"):String(c);!u.startsWith("[testrelic]")&&!u.startsWith("\u2139 TestRelic")&&!u.startsWith("\u2713 TestRelic")&&!u.startsWith("\u26A0 TestRelic")&&l.push({level:"stdout",text:u.replace(/\n$/,""),timestamp:new Date().toISOString(),location:null});}catch{}return o.apply(process.stdout,[c,...d])},process.stderr.write=function(c,...d){try{let u=typeof c=="string"?c:Buffer.isBuffer(c)?c.toString("utf-8"):String(c);!u.startsWith("[testrelic]")&&!u.startsWith("\u26A0 TestRelic")&&l.push({level:"stderr",text:u.replace(/\n$/,""),timestamp:new Date().toISOString(),location:null});}catch{}return i.apply(process.stderr,[c,...d])};try{await t(e);}finally{process.stdout.write=o,process.stderr.write=i;}try{let c=a.getData(),d=n.captureAssertions?s.getData():[],u={testRelicData:!0,version:core.PAYLOAD_VERSION,navigations:[],networkRequests:[],apiCalls:c,apiAssertions:d,consoleLogs:l};await r.attach(core.ATTACHMENT_NAME,{body:Buffer.from(JSON.stringify(u)),contentType:core.ATTACHMENT_CONTENT_TYPE});}catch{}try{a.flushLegacyAnnotations(r);}catch{}try{s.flushLegacyAnnotations(r);}catch{}a.dispose(),s.dispose();}};var Re="@testrelic/playwright-analytics";function En(e){return Array.isArray(e)?e.some(t=>Array.isArray(t)&&typeof t[0]=="string"&&t[0]===Re):false}function qn(e,t){let n={video:"on",screenshot:"on",trace:"on",...e.use??{}},s;Array.isArray(e.reporter)?s=e.reporter:typeof e.reporter=="string"?s=[[e.reporter]]:s=[["list"]];let a=En(s)?s:[...s,[Re,t??{}]];return test.defineConfig({...e,use:n,reporter:a})}var Se=false;function Ga(e,t,r="manual_record"){if(!e||!e.annotations){Se||(Se=true,process.stderr.write(`[testrelic] recordNavigation: reporter not active, navigation not recorded
|
|
1662
|
-
`));return}let n={url:t,navigationType:r,timestamp:new Date().toISOString()};e.annotations.push({type:"lambdatest-navigation",description:JSON.stringify(n)});}Object.defineProperty(exports,"ATTACHMENT_CONTENT_TYPE",{enumerable:true,get:function(){return core.ATTACHMENT_CONTENT_TYPE}});Object.defineProperty(exports,"ATTACHMENT_NAME",{enumerable:true,get:function(){return core.ATTACHMENT_NAME}});Object.defineProperty(exports,"PAYLOAD_VERSION",{enumerable:true,get:function(){return core.PAYLOAD_VERSION}});Object.defineProperty(exports,"isTestRelicDataPayload",{enumerable:true,get:function(){return core.isTestRelicDataPayload}});exports.SCHEMA_VERSION=
|
|
2129
|
+
`);let c=null;if(this.config.includeArtifacts&&this.runTimestamp)try{let d=path.dirname(this.config.outputPath);c=ie(d,this.runTimestamp);let p=path.join(d,"artifact-manifest.json"),f=JSON.stringify(c,null,2),u=p+".tmp";fs.writeFileSync(u,f,"utf-8"),fs.renameSync(u,p);}catch{}this.writeReport(o),await te(o,this.config,c),fe(i,this.config.outputPath,this.config.htmlReportPath,this.config.quiet),this.cloudClient&&await Me(this.cloudClient,this.config.cloud,this.config.cloud?.uploadStrategy,this.testRunId,this.cloudRunId,o,r,a,i);}catch{}}printsToStdio(){return false}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:r.apiCalls,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:r.networkRequests,actions:r.actions,consoleLogs:r.consoleLogs}));return pe(t,{navigationTypes:this.config.navigationTypes})}toTestResult(t){return {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,networkRequests:t.networkRequests,apiCalls:t.apiCalls,apiAssertions:t.apiAssertions,actions:t.actions??null,consoleLogs:t.consoleLogs??null}}writeReport(t){try{let r=JSON.stringify(t,null,2),n=this.config.outputPath,s=path.dirname(n);fs.mkdirSync(s,{recursive:!0});let a=n+".tmp";fs.writeFileSync(a,r,"utf-8"),fs.renameSync(a,n);}catch(r){process.stderr.write(`[testrelic] Failed to write report: ${r instanceof Error?r.message:String(r)}
|
|
2130
|
+
`);}}};var Jn=["text/","application/json","application/xml","application/javascript","application/x-www-form-urlencoded","application/graphql"];function Kn(e){let t=e.toLowerCase();return Jn.some(r=>t.includes(r))}var Q=class e{constructor(t,r){this.page=t;this.records=[];this.listeners=[];this.currentNetworkCounter=null;this.pendingRequests=new Map;this.capturedRequests=[];this.pendingBodyReads=[];this.requestIdCounter=0;this.consoleLogs=[];this.includeNetworkStats=r?.includeNetworkStats??true,this.origGoto=t.goto.bind(t),this.origGoBack=t.goBack.bind(t),this.origGoForward=t.goForward.bind(t),this.origReload=t.reload.bind(t),this.interceptMethods(),this.attachListeners();}async init(){await this.injectSPADetection();}async getCapturedRequests(){await Promise.allSettled(this.pendingBodyReads),this.pendingBodyReads=[];for(let[t,r]of this.pendingRequests)this.capturedRequests.push({url:r.url,method:r.method,resourceType:r.resourceType,statusCode:0,responseTimeMs:Date.now()-r.startTimeMs,startedAt:r.startedAt,requestHeaders:r.headers,requestBody:r.postData,responseBody:null,responseHeaders:null,contentType:null,responseSize:0,requestBodyTruncated:r.postDataTruncated,responseBodyTruncated:false,isBinary:false,error:"incomplete"}),this.pendingRequests.delete(t);return [...this.capturedRequests].sort((t,r)=>t.startedAt.localeCompare(r.startedAt))}static mapConsoleType(t){switch(t){case "log":return "log";case "warning":return "warn";case "error":return "error";case "info":return "info";case "debug":return "debug";default:return "log"}}async getData(){this.includeNetworkStats&&this.currentNetworkCounter&&this.records.length>0&&(this.records[this.records.length-1].networkStats={totalRequests:this.currentNetworkCounter.totalRequests,failedRequests:this.currentNetworkCounter.failedRequests,failedRequestUrls:[...this.currentNetworkCounter.failedRequestUrls],totalBytes:this.currentNetworkCounter.totalBytes,byType:{...this.currentNetworkCounter.byType}});let t=this.records.map(n=>({url:n.url,navigationType:n.navigationType,timestamp:n.timestamp,domContentLoadedAt:n.domContentLoadedAt,networkIdleAt:n.networkIdleAt,networkStats:n.networkStats})),r=this.includeNetworkStats?await this.getCapturedRequests():[];return {navigations:t,networkRequests:r,consoleLogs:[...this.consoleLogs]}}async flushLegacyAnnotations(t){this.includeNetworkStats&&this.currentNetworkCounter&&this.records.length>0&&(this.records[this.records.length-1].networkStats={totalRequests:this.currentNetworkCounter.totalRequests,failedRequests:this.currentNetworkCounter.failedRequests,failedRequestUrls:[...this.currentNetworkCounter.failedRequestUrls],totalBytes:this.currentNetworkCounter.totalBytes,byType:{...this.currentNetworkCounter.byType}});for(let r of this.records){let n={url:r.url,navigationType:r.navigationType,timestamp:r.timestamp,domContentLoadedAt:r.domContentLoadedAt,networkIdleAt:r.networkIdleAt,networkStats:r.networkStats};t.annotations.push({type:"lambdatest-navigation",description:JSON.stringify(n)});}if(this.includeNetworkStats){let r=await this.getCapturedRequests();r.length>0&&t.annotations.push({type:"__testrelic_network_requests",description:JSON.stringify(r)});}}dispose(){this.page.goto=this.origGoto,this.page.goBack=this.origGoBack,this.page.goForward=this.origGoForward,this.page.reload=this.origReload;for(let{event:t,handler:r}of this.listeners)this.page.off(t,r);this.listeners=[],this.records=[],this.pendingRequests.clear(),this.capturedRequests=[],this.pendingBodyReads=[];}getRecords(){return this.records}interceptMethods(){let t=this,r=this.page;r.goto=async function(n,s){return t.recordNavigation(n,"goto"),t.origGoto(n,s)},r.goBack=async function(n){let s=await t.origGoBack(n);return t.recordNavigation(r.url(),"back"),s},r.goForward=async function(n){let s=await t.origGoForward(n);return t.recordNavigation(r.url(),"forward"),s},r.reload=async function(n){return t.recordNavigation(r.url(),"refresh"),t.origReload(n)};}attachListeners(){let t=()=>{this.lastDomContentLoaded=new Date().toISOString(),this.records.length>0&&(this.records[this.records.length-1].domContentLoadedAt=this.lastDomContentLoaded);};this.page.on("domcontentloaded",t),this.listeners.push({event:"domcontentloaded",handler:t});let r=s=>{try{let a=s;if(typeof a.parentFrame=="function"&&a.parentFrame()!==null)return;let l=a.url(),i=this.records[this.records.length-1];if(i&&Date.now()-new Date(i.timestamp).getTime()<50&&i.url===l)return;this.recordNavigation(l,"navigation");}catch{}};this.page.on("framenavigated",r),this.listeners.push({event:"framenavigated",handler:r});let n=s=>{try{let a=s,l=a.type(),i=a.text();if(l==="debug"&&i.startsWith("__testrelic_nav:")){try{let o=JSON.parse(i.slice(16));o.type&&o.url&&this.recordNavigation(o.url,o.type);}catch{}return}{let o=null;try{let d=a.location();d&&d.url&&(o=`${d.url}:${d.lineNumber}:${d.columnNumber}`);}catch{}let c=e.mapConsoleType(l);this.consoleLogs.push({level:c,text:i,timestamp:new Date().toISOString(),location:o});}}catch{}};if(this.page.on("console",n),this.listeners.push({event:"console",handler:n}),this.includeNetworkStats){let s=i=>{this.currentNetworkCounter&&this.currentNetworkCounter.totalRequests++;try{let o=i,c=String(this.requestIdCounter++),d=o.postData()??null,p={url:o.url(),method:o.method(),resourceType:this.mapResourceType(o.resourceType()),headers:o.headers(),postData:d,postDataTruncated:!1,startedAt:new Date().toISOString(),startTimeMs:Date.now()};this.pendingRequests.set(c,p),i.__testrelic_id=c;}catch{}};this.page.on("request",s),this.listeners.push({event:"request",handler:s});let a=i=>{try{let o=i;if(this.currentNetworkCounter){let y=o.status();y>=400&&(this.currentNetworkCounter.failedRequests++,this.currentNetworkCounter.failedRequestUrls.push(y+" "+o.url()));let b=o.headers()["content-length"];b&&(this.currentNetworkCounter.totalBytes+=parseInt(b,10)||0);let x=o.request().resourceType(),w=this.mapResourceType(x);this.currentNetworkCounter.byType[w]++;}let c=o.request().__testrelic_id;if(!c)return;let d=this.pendingRequests.get(c);if(!d)return;this.pendingRequests.delete(c);let p=Date.now()-d.startTimeMs,f=o.headers(),u=f["content-type"]??null,h=parseInt(f["content-length"]??"0",10)||0,g=u?!Kn(u):!1,v=(async()=>{let y=null;if(!g)try{y=(await o.body()).toString("utf-8");}catch{}let b={url:d.url,method:d.method,resourceType:d.resourceType,statusCode:o.status(),responseTimeMs:p,startedAt:d.startedAt,requestHeaders:d.headers,requestBody:d.postData,responseBody:y,responseHeaders:f,contentType:u,responseSize:h,requestBodyTruncated:d.postDataTruncated,responseBodyTruncated:!1,isBinary:g,error:null};this.capturedRequests.push(b);})();this.pendingBodyReads.push(v);}catch{}};this.page.on("response",a),this.listeners.push({event:"response",handler:a});let l=i=>{if(this.currentNetworkCounter){this.currentNetworkCounter.failedRequests++;try{let o=i;this.currentNetworkCounter.failedRequestUrls.push("ERR "+o.url());}catch{}}try{let o=i,c=o.__testrelic_id;if(!c)return;let d=this.pendingRequests.get(c);if(!d)return;this.pendingRequests.delete(c);let p={url:d.url,method:d.method,resourceType:d.resourceType,statusCode:0,responseTimeMs:Date.now()-d.startTimeMs,startedAt:d.startedAt,requestHeaders:d.headers,requestBody:d.postData,responseBody:null,responseHeaders:null,contentType:null,responseSize:0,requestBodyTruncated:d.postDataTruncated,responseBodyTruncated:!1,isBinary:!1,error:o.failure()?.errorText??"Unknown error"};this.capturedRequests.push(p);}catch{}};this.page.on("requestfailed",l),this.listeners.push({event:"requestfailed",handler:l});}}async injectSPADetection(){try{await this.page.addInitScript(()=>{let t=history.pushState.bind(history),r=history.replaceState.bind(history);history.pushState=function(...n){t(...n),console.debug("__testrelic_nav:"+JSON.stringify({type:"spa_route",url:location.href}));},history.replaceState=function(...n){r(...n),console.debug("__testrelic_nav:"+JSON.stringify({type:"spa_replace",url:location.href}));},window.addEventListener("popstate",()=>{console.debug("__testrelic_nav:"+JSON.stringify({type:"popstate",url:location.href}));}),window.addEventListener("hashchange",()=>{console.debug("__testrelic_nav:"+JSON.stringify({type:"hash_change",url:location.href}));});});}catch{}}recordNavigation(t,r){this.includeNetworkStats&&this.currentNetworkCounter&&this.records.length>0&&(this.records[this.records.length-1].networkStats={totalRequests:this.currentNetworkCounter.totalRequests,failedRequests:this.currentNetworkCounter.failedRequests,failedRequestUrls:[...this.currentNetworkCounter.failedRequestUrls],totalBytes:this.currentNetworkCounter.totalBytes,byType:{...this.currentNetworkCounter.byType}}),this.records.push({url:t,navigationType:r,timestamp:new Date().toISOString()}),this.includeNetworkStats&&(this.currentNetworkCounter=this.createNetworkCounter());}createNetworkCounter(){return {totalRequests:0,failedRequests:0,failedRequestUrls:[],totalBytes:0,byType:{xhr:0,document:0,script:0,stylesheet:0,image:0,font:0,other:0}}}mapResourceType(t){switch(t){case "xhr":case "fetch":return "xhr";case "document":return "document";case "script":return "script";case "stylesheet":return "stylesheet";case "image":return "image";case "font":return "font";default:return "other"}}};var De=Symbol.for("__testrelic_call_id"),Wn="__testrelic_api_assertions",L=new WeakMap,N=class{constructor(){this.assertions=[];this.currentCallId=null;}recordAssertion(t){this.assertions.push(t);}getAssertions(){return this.assertions}setCurrentCallId(t){this.currentCallId=t;}getCurrentCallId(){return this.currentCallId}getData(){return [...this.assertions]}flushLegacyAnnotations(t){this.assertions.length!==0&&t.annotations.push({type:Wn,description:JSON.stringify(this.assertions)});}dispose(){this.assertions=[],this.currentCallId=null;}};var Oe="[REDACTED]";function kt(e,t){if(e===null||t.length===0)return e;let r=new Set(t.map(s=>s.toLowerCase())),n={};for(let s of Object.keys(e))Object.hasOwn(e,s)&&(n[s]=r.has(s.toLowerCase())?Oe:e[s]);return n}function X(e,t){if(e===null||t.length===0)return e;let r;try{r=JSON.parse(e);}catch{return e}if(typeof r!="object"||r===null)return e;let n=new Set(t),s=wt(r,n);return JSON.stringify(s)}function wt(e,t){if(Array.isArray(e))return e.map(r=>wt(r,t));if(typeof e=="object"&&e!==null){let r={};for(let n of Object.keys(e)){if(!Object.hasOwn(e,n))continue;let s=e[n];t.has(n)?r[n]=Oe:r[n]=wt(s,t);}return r}return e}function He(e,t,r){if(r.length>0){for(let n of r)if(Fe(e,n))return false}if(t.length>0){for(let n of t)if(Fe(e,n))return true;return false}return true}function Fe(e,t){try{return t instanceof RegExp?t.test(e):Yn(t).test(e)}catch{return console.warn(`[testrelic] Invalid URL filter pattern: ${String(t)}`),false}}function Yn(e){let t="",r=0;for(;r<e.length;){let n=e[r];n==="*"&&e[r+1]==="*"?(t+=".*",r+=2,e[r]==="/"&&r++):n==="*"?(t+="[^/]*",r++):n==="?"?(t+="[^/]",r++):".+^${}()|[]\\".includes(n)?(t+="\\"+n,r++):(t+=n,r++);}return new RegExp(t)}var Zn=["get","post","put","patch","delete","head","fetch"],Qn=["text/","application/json","application/xml","application/javascript","application/x-www-form-urlencoded","application/graphql"],Xn="__testrelic_api_calls";function ts(e){let t=e.toLowerCase();return Qn.some(r=>t.includes(r))}function es(e){if(!e)return null;if(e.data!==void 0&&e.data!==null){let t=e.data;return typeof t=="string"?t:Buffer.isBuffer(t)?t.toString("base64"):JSON.stringify(t)}if(e.form!==void 0&&e.form!==null)return JSON.stringify(e.form);if(e.multipart!==void 0&&e.multipart!==null){let t=e.multipart,r={};for(let[n,s]of Object.entries(t))typeof s=="string"||typeof s=="number"||typeof s=="boolean"?r[n]=String(s):s&&typeof s=="object"&&"name"in s?r[n]=`[file: ${s.name}]`:r[n]="[binary]";return JSON.stringify(r)}return null}var tt=class tt{constructor(t,r,n){this.originals=new Map;this.capturedCalls=[];this.callCounter=0;this.disposed=false;this._lastCallId=null;this.primitiveCallIds=new Map;this.context=t,this.assertionTracker=r??null,this.apiConfig=n??tt.DEFAULT_API_CONFIG;}get lastCallId(){return this._lastCallId}getCallIdForValue(t){return t!=null&&typeof t=="object"?L.get(t)??null:this.primitiveCallIds.get(t)??null}intercept(){for(let r of Zn){let n=this.context[r].bind(this.context);this.originals.set(r,n),this.context[r]=this.createWrapper(r,n);}let t=this.context.dispose.bind(this.context);this.originals.set("dispose",t),this.context.dispose=async r=>(this.disposed=true,t(r));}getData(){return [...this.capturedCalls]}flushLegacyAnnotations(t){this.capturedCalls.length!==0&&t.annotations.push({type:Xn,description:JSON.stringify(this.capturedCalls)});}dispose(){for(let[t,r]of this.originals)this.context[t]=r;this.originals.clear(),this.capturedCalls=[],this.callCounter=0,this._lastCallId=null,this.primitiveCallIds.clear();}get isDisposed(){return this.disposed}getCapturedCalls(){return this.capturedCalls}tagResponseMethods(t,r){let n=this,s=t.headers.bind(t);t.headers=function(){let u=s();return L.set(u,r),u};let a=t.headersArray.bind(t);t.headersArray=function(){let u=a();return L.set(u,r),u};let l=t.json.bind(t);t.json=async function(){let u=await l();return u!=null&&typeof u=="object"&&L.set(u,r),u};let i=t.status.bind(t);t.status=function(){let u=i();return n.primitiveCallIds.set(u,r),u};let o=t.statusText.bind(t);t.statusText=function(){let u=o();return n.primitiveCallIds.set(u,r),u};let c=t.ok.bind(t);t.ok=function(){let u=c();return n.primitiveCallIds.set(u,r),u};let d=t.text.bind(t);t.text=async function(){let u=await d();return n.primitiveCallIds.set(u,r),u};let p=t.body.bind(t);t.body=async function(){let u=await p();return L.set(u,r),u};}createWrapper(t,r){let n=this;return async function(a,l){if(!He(a,n.apiConfig.apiIncludeUrls,n.apiConfig.apiExcludeUrls))return r(a,l);let i=`api-call-${n.callCounter++}`,o=new Date().toISOString(),c=t==="fetch"?(l?.method??"GET").toUpperCase():t.toUpperCase(),d=es(l),p=perf_hooks.performance.now();n._lastCallId=i,n.assertionTracker&&n.assertionTracker.setCurrentCallId(i);let f;try{f=await r(a,l);}catch(u){let h=perf_hooks.performance.now();try{let g=n.apiConfig.captureRequestBody?X(d,n.apiConfig.redactBodyFields):null,v={id:i,timestamp:o,method:c,url:a,requestHeaders:null,requestBody:g,responseStatusCode:null,responseStatusText:null,responseHeaders:null,responseBody:null,responseTimeMs:Math.round((h-p)*100)/100,isBinary:!1,error:u instanceof Error?u.message:String(u)};n.capturedCalls.push(v);}catch{}throw u}try{let u=perf_hooks.performance.now(),h=f.headers(),g=h["content-type"]??null,v=g?!ts(g):!1,y=null;n.apiConfig.captureRequestHeaders&&l?.headers&&(y=l.headers);let b=null;n.apiConfig.captureResponseHeaders&&(b=h);let x=n.apiConfig.captureRequestBody?d:null,w=null;if(n.apiConfig.captureResponseBody)try{v?w=(await f.body()).toString("base64"):w=await f.text();}catch{}y=kt(y,n.apiConfig.redactHeaders),b=kt(b,n.apiConfig.redactHeaders),x=X(x,n.apiConfig.redactBodyFields),w=X(w,n.apiConfig.redactBodyFields);let A={id:i,timestamp:o,method:c,url:f.url(),requestHeaders:y,requestBody:x,responseStatusCode:f.status(),responseStatusText:f.statusText(),responseHeaders:b,responseBody:w,responseTimeMs:Math.round((u-p)*100)/100,isBinary:v,error:null};n.capturedCalls.push(A);}catch{}try{f[De]=i,n.tagResponseMethods(f,i);}catch{}return f}}};tt.DEFAULT_API_CONFIG=Object.freeze({trackApiCalls:true,captureRequestHeaders:true,captureResponseHeaders:true,captureRequestBody:true,captureResponseBody:true,captureAssertions:true,redactHeaders:["authorization","cookie","set-cookie","x-api-key"],redactBodyFields:["password","secret","token","apiKey","api_key"],apiIncludeUrls:[],apiExcludeUrls:[]});var E=tt;var ns="__testrelic_api_config",ss="__testrelic_config_trackApiCalls";function Ct(e){let t=e.annotations.find(n=>n.type===ns&&n.description!==void 0);if(t)try{return JSON.parse(t.description,as)}catch{}let r=e.annotations.find(n=>n.type===ss&&n.description!==void 0);return r?{trackApiCalls:r.description!=="false",captureRequestHeaders:true,captureResponseHeaders:true,captureRequestBody:true,captureResponseBody:true,captureAssertions:true,redactHeaders:["authorization","cookie","set-cookie","x-api-key"],redactBodyFields:["password","secret","token","apiKey","api_key"],apiIncludeUrls:[],apiExcludeUrls:[]}:{trackApiCalls:true,captureRequestHeaders:true,captureResponseHeaders:true,captureRequestBody:true,captureResponseBody:true,captureAssertions:true,redactHeaders:["authorization","cookie","set-cookie","x-api-key"],redactBodyFields:["password","secret","token","apiKey","api_key"],apiIncludeUrls:[],apiExcludeUrls:[]}}function as(e,t){if(typeof t=="object"&&t!==null&&t.__regexp===true&&typeof t.source=="string"){let{source:r,flags:n}=t;return new RegExp(r,n)}return t}var $e={page:async({page:e},t,r)=>{let n=new Q(e);try{await n.init();}catch{}await t(e);try{let{navigations:s,networkRequests:a,consoleLogs:l}=await n.getData(),i={testRelicData:!0,version:core.PAYLOAD_VERSION,navigations:s,networkRequests:a,apiCalls:[],apiAssertions:[],consoleLogs:l};await r.attach(core.ATTACHMENT_NAME,{body:Buffer.from(JSON.stringify(i)),contentType:core.ATTACHMENT_CONTENT_TYPE});}catch{}try{await n.flushLegacyAnnotations(r);}catch{}n.dispose();},request:async({request:e},t,r)=>{let n=Ct(r);if(!n.trackApiCalls){await t(e);return}let s=new N,a=new E(e,s,n);a.intercept(),await t(e);try{let l=a.getData(),i=n.captureAssertions?s.getData():[],o={testRelicData:!0,version:core.PAYLOAD_VERSION,navigations:[],networkRequests:[],apiCalls:l,apiAssertions:i,consoleLogs:[]};await r.attach(core.ATTACHMENT_NAME,{body:Buffer.from(JSON.stringify(o)),contentType:core.ATTACHMENT_CONTENT_TYPE});}catch{}try{a.flushLegacyAnnotations(r);}catch{}try{s.flushLegacyAnnotations(r);}catch{}a.dispose(),s.dispose();}};test.test.extend($e);var ds={request:async({request:e},t,r)=>{let n=Ct(r);if(!n.trackApiCalls){await t(e);return}let s=new N,a=new E(e,s,n);a.intercept();let l=[],i=process.stdout.write,o=process.stderr.write;process.stdout.write=function(c,...d){try{let p=typeof c=="string"?c:Buffer.isBuffer(c)?c.toString("utf-8"):String(c);!p.startsWith("[testrelic]")&&!p.startsWith("\u2139 TestRelic")&&!p.startsWith("\u2713 TestRelic")&&!p.startsWith("\u26A0 TestRelic")&&l.push({level:"stdout",text:p.replace(/\n$/,""),timestamp:new Date().toISOString(),location:null});}catch{}return i.apply(process.stdout,[c,...d])},process.stderr.write=function(c,...d){try{let p=typeof c=="string"?c:Buffer.isBuffer(c)?c.toString("utf-8"):String(c);!p.startsWith("[testrelic]")&&!p.startsWith("\u26A0 TestRelic")&&l.push({level:"stderr",text:p.replace(/\n$/,""),timestamp:new Date().toISOString(),location:null});}catch{}return o.apply(process.stderr,[c,...d])};try{await t(e);}finally{process.stdout.write=i,process.stderr.write=o;}try{let c=a.getData(),d=n.captureAssertions?s.getData():[],p={testRelicData:!0,version:core.PAYLOAD_VERSION,navigations:[],networkRequests:[],apiCalls:c,apiAssertions:d,consoleLogs:l};await r.attach(core.ATTACHMENT_NAME,{body:Buffer.from(JSON.stringify(p)),contentType:core.ATTACHMENT_CONTENT_TYPE});}catch{}try{a.flushLegacyAnnotations(r);}catch{}try{s.flushLegacyAnnotations(r);}catch{}a.dispose(),s.dispose();}};var Ge="@testrelic/playwright-analytics";function ps(e){return Array.isArray(e)?e.some(t=>Array.isArray(t)&&typeof t[0]=="string"&&t[0]===Ge):false}function us(e,t){let n={video:"on",screenshot:"on",trace:"on",...e.use??{}},s;Array.isArray(e.reporter)?s=e.reporter:typeof e.reporter=="string"?s=[[e.reporter]]:s=[["list"]];let a=ps(s)?s:[...s,[Ge,t??{}]];return test.defineConfig({...e,use:n,reporter:a})}var Ve=false;function Fi(e,t,r="manual_record"){if(!e||!e.annotations){Ve||(Ve=true,process.stderr.write(`[testrelic] recordNavigation: reporter not active, navigation not recorded
|
|
2131
|
+
`));return}let n={url:t,navigationType:r,timestamp:new Date().toISOString()};e.annotations.push({type:"lambdatest-navigation",description:JSON.stringify(n)});}Object.defineProperty(exports,"ATTACHMENT_CONTENT_TYPE",{enumerable:true,get:function(){return core.ATTACHMENT_CONTENT_TYPE}});Object.defineProperty(exports,"ATTACHMENT_NAME",{enumerable:true,get:function(){return core.ATTACHMENT_NAME}});Object.defineProperty(exports,"PAYLOAD_VERSION",{enumerable:true,get:function(){return core.PAYLOAD_VERSION}});Object.defineProperty(exports,"isTestRelicDataPayload",{enumerable:true,get:function(){return core.isTestRelicDataPayload}});exports.SCHEMA_VERSION=nt;exports.default=Z;exports.defineConfig=us;exports.recordNavigation=Fi;exports.testRelicApiFixture=ds;exports.testRelicFixture=$e;//# sourceMappingURL=index.cjs.map
|
|
1663
2132
|
//# sourceMappingURL=index.cjs.map
|