@testrelic/playwright-analytics 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +3 -1
- package/dist/fixture.cjs +189 -15
- package/dist/fixture.cjs.map +1 -1
- package/dist/fixture.js +189 -15
- package/dist/fixture.js.map +1 -1
- package/dist/index.cjs +997 -175
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +993 -171
- package/dist/index.js.map +1 -1
- package/dist/merge.cjs +3 -1
- package/dist/merge.cjs.map +1 -1
- package/dist/merge.js +3 -1
- package/dist/merge.js.map +1 -1
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/reporter.ts
|
|
2
|
-
import { randomUUID } from "crypto";
|
|
3
|
-
import { mkdirSync as
|
|
2
|
+
import { randomUUID, createHash } from "crypto";
|
|
3
|
+
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync2, renameSync as renameSync2 } from "fs";
|
|
4
4
|
import { dirname as dirname2, relative } from "path";
|
|
5
5
|
|
|
6
6
|
// src/config.ts
|
|
@@ -31,11 +31,12 @@ function resolveConfig(options) {
|
|
|
31
31
|
const outputPath = target.outputPath;
|
|
32
32
|
target.openReport = options?.openReport ?? true;
|
|
33
33
|
target.htmlReportPath = options?.htmlReportPath ?? outputPath.replace(/\.json$/, ".html");
|
|
34
|
+
target.includeArtifacts = options?.includeArtifacts ?? true;
|
|
34
35
|
return Object.freeze(target);
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
// src/schema.ts
|
|
38
|
-
var SCHEMA_VERSION = "1.
|
|
39
|
+
var SCHEMA_VERSION = "1.2.0";
|
|
39
40
|
|
|
40
41
|
// src/code-extractor.ts
|
|
41
42
|
import { readFileSync } from "fs";
|
|
@@ -136,157 +137,413 @@ function detectCI(env) {
|
|
|
136
137
|
import { writeFileSync, renameSync, mkdirSync } from "fs";
|
|
137
138
|
import { dirname, resolve } from "path";
|
|
138
139
|
|
|
139
|
-
// src/html-
|
|
140
|
+
// src/html-logo.ts
|
|
140
141
|
var LOGO_SVG = `<svg width="32" height="40" viewBox="0 0 196 247" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
141
142
|
<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)"/>
|
|
142
143
|
<defs><linearGradient id="paint0_linear_55_11" x1="98" y1="0.000244141" x2="98" y2="247" gradientUnits="userSpaceOnUse">
|
|
143
144
|
<stop stop-color="#03B79C"/><stop offset="0.504808" stop-color="#4EDAA4"/><stop offset="0.865285" stop-color="#84F3AA"/>
|
|
144
145
|
</linearGradient></defs></svg>`;
|
|
146
|
+
|
|
147
|
+
// src/html-css.ts
|
|
145
148
|
var CSS = `
|
|
149
|
+
:root{
|
|
150
|
+
--bg-primary:#ffffff;--bg-secondary:#fafafa;--bg-tertiary:#f3f4f6;--bg-card:#ffffff;
|
|
151
|
+
--bg-code:#171717;--bg-code-text:#d4d4d4;--bg-code-highlight:rgba(239,68,68,.2);
|
|
152
|
+
--text-primary:#171717;--text-secondary:#6b7280;--text-muted:#9ca3af;--text-strong:#374151;
|
|
153
|
+
--border:#e5e7eb;--border-light:#f3f4f6;--border-hover:#d1d5db;
|
|
154
|
+
--accent:#03b79c;--accent-hover:#028a75;--accent-ring:rgba(3,183,156,.2);
|
|
155
|
+
--passed-bg:#d1fae5;--passed-text:#065f46;--passed-border:#bbf7d0;--passed-card-bg:#f0fdf4;--passed-count:#16a34a;
|
|
156
|
+
--failed-bg:#fecaca;--failed-text:#991b1b;--failed-border:#fecaca;--failed-card-bg:#fef2f2;--failed-count:#dc2626;
|
|
157
|
+
--flaky-bg:#fde68a;--flaky-text:#92400e;--flaky-border:#fde68a;--flaky-card-bg:#fffbeb;--flaky-count:#d97706;
|
|
158
|
+
--skipped-bg:#f3f4f6;--skipped-text:#6b7280;--skipped-card-bg:#f9fafb;
|
|
159
|
+
--timedout-bg:#ffedd5;--timedout-text:#9a3412;--timedout-card-bg:#fff7ed;--timedout-count:#ea580c;
|
|
160
|
+
--total-border:#c7d2fe;--total-bg:#eef2ff;--total-count:#4f46e5;
|
|
161
|
+
--ci-bg:#eff6ff;--ci-text:#1d4ed8;--merged-bg:#fef3c7;--merged-text:#92400e;
|
|
162
|
+
--tag-bg:#eff6ff;--tag-text:#1d4ed8;--type-bg:#ede9fe;--type-text:#5b21b6;
|
|
163
|
+
--net-2xx-bg:#d1fae5;--net-2xx-text:#065f46;--net-3xx-bg:#fef3c7;--net-3xx-text:#92400e;
|
|
164
|
+
--net-4xx-bg:#fecaca;--net-4xx-text:#991b1b;--net-5xx-bg:#fecaca;--net-5xx-text:#7f1d1d;
|
|
165
|
+
--net-0-bg:#f3f4f6;--net-0-text:#6b7280;
|
|
166
|
+
--passed-left:#22c55e;--failed-left:#ef4444;
|
|
167
|
+
--failure-msg-bg:#f8f8f8;
|
|
168
|
+
}
|
|
169
|
+
[data-theme="dark"]{
|
|
170
|
+
--bg-primary:#0f172a;--bg-secondary:#1e293b;--bg-tertiary:#334155;--bg-card:#1e293b;
|
|
171
|
+
--bg-code:#0f172a;--bg-code-text:#e2e8f0;--bg-code-highlight:rgba(239,68,68,.25);
|
|
172
|
+
--text-primary:#f1f5f9;--text-secondary:#94a3b8;--text-muted:#64748b;--text-strong:#cbd5e1;
|
|
173
|
+
--border:#334155;--border-light:#1e293b;--border-hover:#475569;
|
|
174
|
+
--accent:#2dd4bf;--accent-hover:#5eead4;--accent-ring:rgba(45,212,191,.25);
|
|
175
|
+
--passed-bg:#065f46;--passed-text:#6ee7b7;--passed-border:#064e3b;--passed-card-bg:#022c22;--passed-count:#34d399;
|
|
176
|
+
--failed-bg:#7f1d1d;--failed-text:#fca5a5;--failed-border:#991b1b;--failed-card-bg:#450a0a;--failed-count:#f87171;
|
|
177
|
+
--flaky-bg:#78350f;--flaky-text:#fde68a;--flaky-border:#92400e;--flaky-card-bg:#451a03;--flaky-count:#fbbf24;
|
|
178
|
+
--skipped-bg:#334155;--skipped-text:#94a3b8;--skipped-card-bg:#1e293b;
|
|
179
|
+
--timedout-bg:#7c2d12;--timedout-text:#fed7aa;--timedout-card-bg:#431407;--timedout-count:#fb923c;
|
|
180
|
+
--total-border:#4338ca;--total-bg:#1e1b4b;--total-count:#a5b4fc;
|
|
181
|
+
--ci-bg:#1e3a5f;--ci-text:#93c5fd;--merged-bg:#78350f;--merged-text:#fde68a;
|
|
182
|
+
--tag-bg:#1e3a5f;--tag-text:#93c5fd;--type-bg:#2e1065;--type-text:#c4b5fd;
|
|
183
|
+
--net-2xx-bg:#065f46;--net-2xx-text:#6ee7b7;--net-3xx-bg:#78350f;--net-3xx-text:#fde68a;
|
|
184
|
+
--net-4xx-bg:#7f1d1d;--net-4xx-text:#fca5a5;--net-5xx-bg:#7f1d1d;--net-5xx-text:#fca5a5;
|
|
185
|
+
--net-0-bg:#334155;--net-0-text:#94a3b8;
|
|
186
|
+
--passed-left:#22c55e;--failed-left:#ef4444;
|
|
187
|
+
--failure-msg-bg:#e2e8f0;
|
|
188
|
+
}
|
|
146
189
|
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
|
|
147
190
|
body{font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
|
|
148
|
-
color
|
|
191
|
+
color:var(--text-primary);background:var(--bg-primary);line-height:1.6;-webkit-font-smoothing:antialiased;
|
|
192
|
+
transition:background-color .15s ease,color .15s ease}
|
|
149
193
|
.container{max-width:1100px;margin:0 auto;padding:24px 20px}
|
|
150
194
|
/* Header */
|
|
151
195
|
.header{display:flex;align-items:center;gap:12px;margin-bottom:8px}
|
|
152
196
|
.header svg{flex-shrink:0}
|
|
153
|
-
.header h1{font-size:22px;font-weight:700;color
|
|
154
|
-
.meta{display:flex;flex-wrap:wrap;gap:8px 20px;font-size:13px;color
|
|
197
|
+
.header h1{font-size:22px;font-weight:700;color:var(--text-primary)}
|
|
198
|
+
.meta{display:flex;flex-wrap:wrap;gap:8px 20px;font-size:13px;color:var(--text-secondary);margin-bottom:20px}
|
|
155
199
|
.meta-item{display:flex;align-items:center;gap:4px}
|
|
156
|
-
.meta-label{font-weight:600;color
|
|
200
|
+
.meta-label{font-weight:600;color:var(--text-strong)}
|
|
157
201
|
.run-id{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;
|
|
158
|
-
background
|
|
159
|
-
.ci-badge{display:inline-flex;align-items:center;gap:4px;background
|
|
160
|
-
color
|
|
161
|
-
.merged-badge{background
|
|
202
|
+
background:var(--bg-tertiary);padding:2px 8px;border-radius:4px}
|
|
203
|
+
.ci-badge{display:inline-flex;align-items:center;gap:4px;background:var(--ci-bg);
|
|
204
|
+
color:var(--ci-text);padding:2px 8px;border-radius:4px;font-size:12px;font-weight:500}
|
|
205
|
+
.merged-badge{background:var(--merged-bg);color:var(--merged-text);padding:2px 8px;border-radius:4px;
|
|
162
206
|
font-size:12px;font-weight:500}
|
|
207
|
+
/* Theme Toggle */
|
|
208
|
+
.theme-toggle{display:flex;align-items:center;justify-content:center;width:32px;height:32px;
|
|
209
|
+
border-radius:8px;border:1px solid var(--border);background:var(--bg-secondary);
|
|
210
|
+
color:var(--text-secondary);cursor:pointer;margin-left:auto;flex-shrink:0;
|
|
211
|
+
transition:background .15s,border-color .15s,color .15s}
|
|
212
|
+
.theme-toggle:hover{background:var(--bg-tertiary);color:var(--text-primary);border-color:var(--border-hover)}
|
|
213
|
+
.theme-toggle svg{width:16px;height:16px}
|
|
163
214
|
/* Summary Cards */
|
|
164
215
|
.summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:12px;margin-bottom:28px}
|
|
165
|
-
.summary-card{border-radius:10px;padding:16px;text-align:center;border:1px solid
|
|
216
|
+
.summary-card{border-radius:10px;padding:16px;text-align:center;border:1px solid var(--border)}
|
|
166
217
|
.summary-card .count{font-size:32px;font-weight:800;line-height:1.1}
|
|
167
|
-
.summary-card .label{font-size:13px;font-weight:500;color
|
|
168
|
-
.card-passed{border-color
|
|
169
|
-
.card-failed{border-color
|
|
170
|
-
.card-flaky{border-color
|
|
171
|
-
.card-skipped{border-color
|
|
172
|
-
.card-total{border-color
|
|
218
|
+
.summary-card .label{font-size:13px;font-weight:500;color:var(--text-secondary);margin-top:2px}
|
|
219
|
+
.card-passed{border-color:var(--passed-border);background:var(--passed-card-bg)}.card-passed .count{color:var(--passed-count)}
|
|
220
|
+
.card-failed{border-color:var(--failed-border);background:var(--failed-card-bg)}.card-failed .count{color:var(--failed-count)}
|
|
221
|
+
.card-flaky{border-color:var(--flaky-border);background:var(--flaky-card-bg)}.card-flaky .count{color:var(--flaky-count)}
|
|
222
|
+
.card-skipped{border-color:var(--border);background:var(--skipped-card-bg)}.card-skipped .count{color:var(--skipped-text)}
|
|
223
|
+
.card-total{border-color:var(--total-border);background:var(--total-bg)}.card-total .count{color:var(--total-count)}
|
|
224
|
+
.card-timedout{border-color:var(--timedout-bg);background:var(--timedout-card-bg)}.card-timedout .count{color:var(--timedout-count)}
|
|
173
225
|
/* Timeline */
|
|
174
226
|
.timeline{display:flex;flex-direction:column;gap:8px}
|
|
175
|
-
.timeline-entry{border:1px solid
|
|
176
|
-
border-left:4px solid
|
|
177
|
-
.timeline-entry:hover{border-color
|
|
178
|
-
.timeline-entry--
|
|
227
|
+
.timeline-entry{border:1px solid var(--border);border-radius:10px;overflow:hidden;
|
|
228
|
+
border-left:4px solid var(--border);transition:border-color .15s}
|
|
229
|
+
.timeline-entry:hover{border-color:var(--border-hover)}
|
|
230
|
+
.timeline-entry--all-passed{border-left-color:var(--passed-left)}
|
|
231
|
+
.timeline-entry--all-passed:hover{border-color:#86efac}
|
|
232
|
+
.timeline-entry--has-failures{border-left-color:var(--failed-left)}
|
|
179
233
|
.timeline-entry--has-failures:hover{border-color:#fca5a5}
|
|
180
234
|
.timeline-header{display:flex;align-items:center;gap:10px;padding:12px 16px;cursor:pointer;
|
|
181
|
-
user-select:none;background
|
|
182
|
-
.timeline-header:hover{background
|
|
183
|
-
.chevron{width:16px;height:16px;flex-shrink:0;transition:transform .2s;color
|
|
235
|
+
user-select:none;background:var(--bg-secondary);transition:background .15s}
|
|
236
|
+
.timeline-header:hover{background:var(--bg-tertiary)}
|
|
237
|
+
.chevron{width:16px;height:16px;flex-shrink:0;transition:transform .2s;color:var(--text-muted)}
|
|
184
238
|
.timeline-entry.expanded .chevron{transform:rotate(90deg)}
|
|
185
|
-
.timeline-url{font-size:14px;font-weight:600;color
|
|
239
|
+
.timeline-url{font-size:14px;font-weight:600;color:var(--text-primary);overflow:hidden;
|
|
186
240
|
text-overflow:ellipsis;white-space:nowrap;max-width:500px;min-width:0}
|
|
187
241
|
.nav-type-badge{font-size:11px;font-weight:600;padding:2px 8px;border-radius:9999px;
|
|
188
242
|
white-space:nowrap;text-transform:uppercase;letter-spacing:.02em;flex-shrink:0}
|
|
189
|
-
.badge-goto
|
|
190
|
-
.badge-
|
|
191
|
-
.badge-
|
|
192
|
-
.badge-
|
|
243
|
+
.badge-goto{background:#dbeafe;color:#1e40af}
|
|
244
|
+
.badge-navigation{background:#e0e7ff;color:#3730a3}
|
|
245
|
+
.badge-page_load{background:#c7d2fe;color:#312e81}
|
|
246
|
+
.badge-back{background:#cffafe;color:#155e75}
|
|
247
|
+
.badge-forward{background:#a5f3fc;color:#164e63}
|
|
248
|
+
.badge-spa_route{background:#ede9fe;color:#5b21b6}
|
|
249
|
+
.badge-spa_replace{background:#ddd6fe;color:#4c1d95}
|
|
250
|
+
.badge-hash_change{background:#fae8ff;color:#86198f}
|
|
251
|
+
.badge-popstate{background:#f5d0fe;color:#701a75}
|
|
252
|
+
.badge-link_click{background:#fce7f3;color:#9d174d}
|
|
253
|
+
.badge-form_submit{background:#fbcfe8;color:#831843}
|
|
193
254
|
.badge-redirect{background:#ffedd5;color:#9a3412}
|
|
194
255
|
.badge-refresh{background:#e0f2fe;color:#075985}
|
|
195
|
-
.badge-dummy
|
|
196
|
-
.
|
|
256
|
+
.badge-dummy{background:var(--bg-tertiary);color:var(--text-secondary)}
|
|
257
|
+
.badge-fallback{background:var(--border);color:var(--text-strong)}
|
|
258
|
+
.badge-manual_record{background:#fef9c3;color:#854d0e}
|
|
259
|
+
.timeline-info{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--text-secondary);
|
|
197
260
|
margin-left:auto;flex-shrink:0;white-space:nowrap}
|
|
198
261
|
.spec-file{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;
|
|
199
|
-
color
|
|
200
|
-
.timeline-content{display:none;padding:0 16px 16px;border-top:1px solid
|
|
262
|
+
color:var(--text-secondary);background:var(--bg-tertiary);padding:1px 6px;border-radius:3px}
|
|
263
|
+
.timeline-content{display:none;padding:0 16px 16px;border-top:1px solid var(--border-light)}
|
|
201
264
|
.timeline-entry.expanded .timeline-content{display:block}
|
|
202
265
|
/* Test Cards */
|
|
203
266
|
.tests-section{margin-top:12px}
|
|
204
|
-
.spec-summary{font-size:12px;color
|
|
267
|
+
.spec-summary{font-size:12px;color:var(--text-secondary);margin-bottom:8px;display:flex;gap:12px;flex-wrap:wrap}
|
|
205
268
|
.spec-summary span{font-weight:600}
|
|
206
|
-
.spec-passed{color
|
|
207
|
-
.test-card{
|
|
208
|
-
border-bottom:1px solid #f3f4f6}
|
|
269
|
+
.spec-passed{color:var(--passed-count)}.spec-failed{color:var(--failed-count)}.spec-flaky{color:var(--flaky-count)}
|
|
270
|
+
.test-card{padding:8px 0;border-bottom:1px solid var(--border-light)}
|
|
209
271
|
.test-card:last-child{border-bottom:none}
|
|
272
|
+
.test-card-row{display:flex;align-items:flex-start;gap:8px}
|
|
210
273
|
.status-badge{font-size:11px;font-weight:700;padding:2px 8px;border-radius:9999px;
|
|
211
274
|
flex-shrink:0;margin-top:2px;text-transform:uppercase;letter-spacing:.03em}
|
|
212
|
-
.status-passed{background
|
|
213
|
-
.status-failed{background
|
|
214
|
-
.status-flaky{background
|
|
275
|
+
.status-passed{background:var(--passed-bg);color:var(--passed-text)}
|
|
276
|
+
.status-failed{background:var(--failed-bg);color:var(--failed-text)}
|
|
277
|
+
.status-flaky{background:var(--flaky-bg);color:var(--flaky-text)}
|
|
278
|
+
.status-skipped{background:var(--skipped-bg);color:var(--skipped-text)}
|
|
279
|
+
.status-timedout{background:var(--timedout-bg);color:var(--timedout-text)}
|
|
280
|
+
.type-badge{background:var(--type-bg);color:var(--type-text);padding:1px 5px;border-radius:3px;font-size:10px;font-weight:600}
|
|
281
|
+
.flaky-badge{background:var(--flaky-card-bg);color:var(--flaky-text);padding:1px 5px;border-radius:3px;font-size:10px;font-weight:600}
|
|
282
|
+
.file-path{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10px;color:var(--text-secondary)}
|
|
283
|
+
.suite-name{font-size:11px;color:var(--text-muted)}
|
|
284
|
+
.status-mismatch{font-size:10px;color:var(--failed-count);font-weight:600}
|
|
215
285
|
.test-info{flex:1;min-width:0}
|
|
216
|
-
.test-title{font-size:13px;color
|
|
217
|
-
.test-meta{display:flex;gap:8px;align-items:center;margin-top:2px;font-size:11px;color
|
|
218
|
-
.retry-badge{background
|
|
219
|
-
.tag-badge{background
|
|
220
|
-
.
|
|
286
|
+
.test-title{font-size:13px;color:var(--text-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
287
|
+
.test-meta{display:flex;gap:8px;align-items:center;margin-top:2px;font-size:11px;color:var(--text-muted)}
|
|
288
|
+
.retry-badge{background:var(--flaky-card-bg);color:var(--flaky-text);padding:1px 5px;border-radius:3px;font-size:10px;font-weight:600}
|
|
289
|
+
.tag-badge{background:var(--tag-bg);color:var(--tag-text);padding:1px 5px;border-radius:3px;font-size:10px}
|
|
290
|
+
.meta-prefix{font-size:10px;color:var(--text-secondary);font-weight:600;text-transform:uppercase;letter-spacing:.04em}
|
|
291
|
+
.test-id{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10px;
|
|
292
|
+
color:var(--text-secondary);background:var(--bg-tertiary);padding:1px 6px;border-radius:3px}
|
|
293
|
+
.network-panel--has-failures{border-color:var(--failed-border)}
|
|
294
|
+
.network-panel--has-failures .network-header{background:var(--failed-card-bg);color:var(--failed-text)}
|
|
295
|
+
.failed-requests-banner{display:flex;align-items:center;gap:6px;padding:8px 12px;
|
|
296
|
+
background:var(--failed-card-bg);color:var(--failed-text);font-size:12px;font-weight:600;border-top:1px solid var(--failed-border)}
|
|
297
|
+
.failed-urls-list{padding:6px 12px;background:var(--failed-card-bg);border-top:1px solid var(--failed-border);font-size:11px;
|
|
298
|
+
font-family:ui-monospace,SFMono-Regular,Menlo,monospace;max-height:200px;overflow-y:auto}
|
|
299
|
+
.failed-url-item{padding:2px 0;color:var(--failed-text);word-break:break-all}
|
|
300
|
+
.failed-url-status{font-weight:700;margin-right:4px}
|
|
301
|
+
.test-duration{font-size:12px;color:var(--text-muted);flex-shrink:0;margin-top:2px}
|
|
302
|
+
/* Tab Bar */
|
|
303
|
+
.tab-bar{display:flex;gap:0;border-bottom:1px solid var(--border);margin-top:8px}
|
|
304
|
+
.tab-btn{padding:8px 16px;font-size:12px;font-weight:500;color:var(--text-secondary);background:none;
|
|
305
|
+
border:none;border-bottom:2px solid transparent;cursor:pointer;font-family:inherit;
|
|
306
|
+
transition:color .15s,border-color .15s}
|
|
307
|
+
.tab-btn:hover{color:var(--text-strong)}
|
|
308
|
+
.tab-btn.active{color:var(--accent);border-bottom-color:var(--accent);font-weight:600}
|
|
309
|
+
.tab-panel{display:none;padding:12px 0}
|
|
310
|
+
.tab-panel.active{display:block}
|
|
311
|
+
.tab-empty-state{text-align:center;padding:24px 16px;color:var(--text-muted);font-size:13px;font-style:italic}
|
|
221
312
|
/* Failure Details */
|
|
222
|
-
.failure-toggle{font-size:12px;color
|
|
313
|
+
.failure-toggle{font-size:12px;color:var(--accent);cursor:pointer;margin-top:4px;
|
|
223
314
|
border:none;background:none;padding:0;text-decoration:underline;font-family:inherit}
|
|
224
|
-
.failure-toggle:hover{color
|
|
315
|
+
.failure-toggle:hover{color:var(--accent-hover)}
|
|
225
316
|
.failure-details{display:none;margin-top:8px;border-radius:8px;overflow:hidden;
|
|
226
|
-
border:1px solid
|
|
317
|
+
border:1px solid var(--border)}
|
|
227
318
|
.failure-details.show{display:block}
|
|
228
|
-
.failure-message{padding:12px;background
|
|
319
|
+
.failure-message{padding:12px;background:var(--bg-code);color:var(--failure-msg-bg);font-size:12px;
|
|
229
320
|
font-family:ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;
|
|
230
321
|
word-break:break-word;line-height:1.5;overflow-x:auto}
|
|
231
|
-
.code-snippet{background
|
|
322
|
+
.code-snippet{background:var(--bg-code);padding:0;font-size:12px;
|
|
232
323
|
font-family:ui-monospace,SFMono-Regular,Menlo,monospace;overflow-x:auto}
|
|
233
324
|
.code-line{display:flex;padding:0 12px;line-height:1.7}
|
|
234
|
-
.code-line.highlight{background:
|
|
235
|
-
.line-num{color
|
|
325
|
+
.code-line.highlight{background:var(--bg-code-highlight)}
|
|
326
|
+
.line-num{color:var(--text-secondary);min-width:40px;text-align:right;padding-right:12px;
|
|
236
327
|
user-select:none;flex-shrink:0}
|
|
237
|
-
.line-code{color
|
|
238
|
-
.stack-toggle{font-size:11px;color
|
|
239
|
-
border:none;background
|
|
240
|
-
border-top:1px solid
|
|
241
|
-
.stack-toggle:hover{background
|
|
242
|
-
.stack-trace{display:none;padding:12px;background
|
|
328
|
+
.line-code{color:var(--bg-code-text);white-space:pre;overflow-x:auto}
|
|
329
|
+
.stack-toggle{font-size:11px;color:var(--text-secondary);cursor:pointer;padding:8px 12px;
|
|
330
|
+
border:none;background:var(--bg-secondary);width:100%;text-align:left;font-family:inherit;
|
|
331
|
+
border-top:1px solid var(--border)}
|
|
332
|
+
.stack-toggle:hover{background:var(--bg-tertiary);color:var(--text-strong)}
|
|
333
|
+
.stack-trace{display:none;padding:12px;background:var(--bg-secondary);font-size:11px;
|
|
243
334
|
font-family:ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;
|
|
244
|
-
word-break:break-word;color
|
|
335
|
+
word-break:break-word;color:var(--text-secondary);border-top:1px solid var(--border);max-height:300px;overflow-y:auto}
|
|
245
336
|
.stack-trace.show{display:block}
|
|
246
337
|
/* Network Panel */
|
|
247
|
-
.network-panel{margin-top:16px;border:1px solid
|
|
248
|
-
.network-header{font-size:12px;font-weight:600;color
|
|
249
|
-
background
|
|
338
|
+
.network-panel{margin-top:16px;border:1px solid var(--border);border-radius:8px;overflow:hidden}
|
|
339
|
+
.network-header{font-size:12px;font-weight:600;color:var(--text-strong);padding:10px 12px;
|
|
340
|
+
background:var(--bg-secondary);border-bottom:1px solid var(--border);display:flex;align-items:center;gap:6px}
|
|
250
341
|
.network-summary{display:flex;gap:16px;padding:10px 12px;font-size:12px;flex-wrap:wrap}
|
|
251
342
|
.net-stat{display:flex;flex-direction:column;align-items:center;gap:1px}
|
|
252
|
-
.net-stat .val{font-weight:700;font-size:14px;color
|
|
253
|
-
.net-stat .lbl{color
|
|
254
|
-
.net-stat.has-failed .val{color
|
|
255
|
-
.resource-breakdown{display:flex;gap:6px;padding:8px 12px;flex-wrap:wrap;border-top:1px solid
|
|
343
|
+
.net-stat .val{font-weight:700;font-size:14px;color:var(--text-primary)}
|
|
344
|
+
.net-stat .lbl{color:var(--text-muted);font-size:11px}
|
|
345
|
+
.net-stat.has-failed .val{color:var(--failed-count)}
|
|
346
|
+
.resource-breakdown{display:flex;gap:6px;padding:8px 12px;flex-wrap:wrap;border-top:1px solid var(--border-light)}
|
|
256
347
|
.resource-type{display:flex;align-items:center;gap:4px;font-size:11px;padding:3px 8px;
|
|
257
|
-
border-radius:4px;background
|
|
348
|
+
border-radius:4px;background:var(--bg-tertiary);color:var(--text-strong)}
|
|
258
349
|
.resource-type .rt-count{font-weight:700}
|
|
259
350
|
.resource-type--zero{opacity:.45}
|
|
260
351
|
/* Empty State */
|
|
261
|
-
.empty-state{text-align:center;padding:60px 20px;color
|
|
352
|
+
.empty-state{text-align:center;padding:60px 20px;color:var(--text-muted)}
|
|
262
353
|
.empty-state svg{width:48px;height:48px;margin-bottom:12px;opacity:.4}
|
|
263
354
|
.empty-state p{font-size:15px;font-weight:500}
|
|
264
355
|
/* No-network */
|
|
265
|
-
.no-network{font-size:12px;color
|
|
356
|
+
.no-network{font-size:12px;color:var(--text-muted);padding:10px 12px;font-style:italic}
|
|
266
357
|
/* Section title */
|
|
267
|
-
.section-title{font-size:16px;font-weight:700;color
|
|
358
|
+
.section-title{font-size:16px;font-weight:700;color:var(--text-primary);margin-bottom:12px;
|
|
268
359
|
display:flex;align-items:center;gap:8px}
|
|
269
|
-
.section-title::before{content:'';width:4px;height:18px;background
|
|
360
|
+
.section-title::before{content:'';width:4px;height:18px;background:var(--accent);border-radius:2px}
|
|
361
|
+
/* Artifacts Panel */
|
|
362
|
+
.artifacts-panel{margin-top:10px;padding:10px 12px;background:var(--bg-secondary);border:1px solid var(--border);
|
|
363
|
+
border-radius:8px}
|
|
364
|
+
.artifacts-panel-header{display:flex;align-items:center;gap:6px;font-size:11px;font-weight:600;
|
|
365
|
+
color:var(--text-secondary);text-transform:uppercase;letter-spacing:.04em;margin-bottom:8px}
|
|
366
|
+
.artifacts-row{display:flex;gap:16px;align-items:flex-start;flex-wrap:wrap}
|
|
367
|
+
/* Screenshot */
|
|
368
|
+
.artifact-screenshot-wrap{display:flex;flex-direction:column;gap:4px;margin:8px 0}
|
|
369
|
+
.artifact-thumbnail{width:100%;max-width:100%;height:auto;border-radius:8px;cursor:pointer;
|
|
370
|
+
border:1px solid var(--border);transition:border-color .15s,box-shadow .15s;display:block}
|
|
371
|
+
.artifact-thumbnail:hover{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-ring)}
|
|
372
|
+
.artifact-label{font-size:10px;color:var(--text-muted);text-align:center}
|
|
373
|
+
/* Video */
|
|
374
|
+
.artifact-video-inline{margin:8px 0}
|
|
375
|
+
.artifact-video-player{display:block;width:100%;max-width:100%;height:auto;border-radius:8px;
|
|
376
|
+
border:1px solid var(--border);background:#000}
|
|
377
|
+
/* Lightbox */
|
|
378
|
+
.lightbox-overlay{position:fixed;inset:0;background:rgba(0,0,0,.85);z-index:1000;
|
|
379
|
+
display:flex;align-items:center;justify-content:center;cursor:zoom-out}
|
|
380
|
+
.lightbox-overlay img{max-width:90vw;max-height:90vh;border-radius:8px;box-shadow:0 4px 24px rgba(0,0,0,.4)}
|
|
381
|
+
.lightbox-close{position:fixed;top:16px;right:16px;z-index:1001;width:36px;height:36px;
|
|
382
|
+
border-radius:50%;border:none;background:rgba(255,255,255,.15);color:#fff;font-size:20px;
|
|
383
|
+
cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .15s}
|
|
384
|
+
.lightbox-close:hover{background:rgba(255,255,255,.3)}
|
|
385
|
+
/* Detailed Network Logs */
|
|
386
|
+
.network-log{margin-top:4px}
|
|
387
|
+
.network-log-summary{display:flex;gap:12px;align-items:center;font-size:12px;margin-bottom:8px}
|
|
388
|
+
.net-log-count{font-weight:600;color:var(--text-strong)}
|
|
389
|
+
.net-log-failed{font-weight:600;color:var(--failed-count)}
|
|
390
|
+
.network-entry{border-bottom:1px solid var(--border-light)}
|
|
391
|
+
.network-entry:last-child{border-bottom:none}
|
|
392
|
+
.network-entry--failed{border-left:3px solid var(--failed-count)}
|
|
393
|
+
.network-entry-row{display:flex;align-items:center;gap:8px;padding:6px 0;cursor:pointer;
|
|
394
|
+
font-size:12px;transition:background .1s}
|
|
395
|
+
.network-entry-row:hover{background:var(--bg-secondary)}
|
|
396
|
+
.network-entry-row.expanded .net-chevron{transform:rotate(90deg)}
|
|
397
|
+
.net-status-badge{font-size:11px;font-weight:700;padding:1px 6px;border-radius:4px;
|
|
398
|
+
min-width:36px;text-align:center;flex-shrink:0}
|
|
399
|
+
.net-status-2xx{background:var(--net-2xx-bg);color:var(--net-2xx-text)}
|
|
400
|
+
.net-status-3xx{background:var(--net-3xx-bg);color:var(--net-3xx-text)}
|
|
401
|
+
.net-status-4xx{background:var(--net-4xx-bg);color:var(--net-4xx-text)}
|
|
402
|
+
.net-status-5xx{background:var(--net-5xx-bg);color:var(--net-5xx-text);font-weight:800}
|
|
403
|
+
.net-status-0{background:var(--net-0-bg);color:var(--net-0-text)}
|
|
404
|
+
.net-method{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-weight:700;
|
|
405
|
+
font-size:11px;color:var(--text-strong);flex-shrink:0;min-width:40px}
|
|
406
|
+
.net-url{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;
|
|
407
|
+
color:var(--text-secondary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0}
|
|
408
|
+
.net-time{font-size:11px;color:var(--text-muted);flex-shrink:0;text-align:right;min-width:48px}
|
|
409
|
+
.net-chevron{flex-shrink:0;color:var(--text-muted);transition:transform .2s}
|
|
410
|
+
.network-entry-details{display:none;padding:8px 0 12px;border-top:1px solid var(--border-light)}
|
|
411
|
+
.network-entry-details.show{display:block}
|
|
412
|
+
.net-section-title{font-size:11px;font-weight:600;color:var(--text-secondary);text-transform:uppercase;
|
|
413
|
+
letter-spacing:.04em;margin:8px 0 4px;padding-top:4px}
|
|
414
|
+
.net-section-title:first-child{margin-top:0}
|
|
415
|
+
.net-headers-table{width:100%;font-size:11px;border-collapse:collapse}
|
|
416
|
+
.net-headers-table td{padding:2px 8px;vertical-align:top;border-bottom:1px solid var(--border-light)}
|
|
417
|
+
.net-header-key{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-weight:600;
|
|
418
|
+
color:var(--text-strong);white-space:nowrap;width:180px}
|
|
419
|
+
.net-header-val{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--text-secondary);
|
|
420
|
+
word-break:break-all}
|
|
421
|
+
.net-truncated-note{font-size:10px;color:var(--flaky-count);font-style:italic;margin-top:2px}
|
|
422
|
+
/* Code Editor */
|
|
423
|
+
.code-editor{border:1px solid var(--border);border-radius:8px;overflow:hidden;margin:4px 0}
|
|
424
|
+
.code-editor-toolbar{display:flex;align-items:center;justify-content:space-between;
|
|
425
|
+
padding:4px 8px 4px 12px;background:var(--bg-tertiary);border-bottom:1px solid var(--border);min-height:28px}
|
|
426
|
+
.code-editor-lang{font-size:10px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
|
|
427
|
+
color:var(--text-muted);text-transform:lowercase}
|
|
428
|
+
.code-editor-copy{font-size:11px;font-family:inherit;padding:2px 10px;border-radius:4px;
|
|
429
|
+
border:1px solid var(--border);background:var(--bg-secondary);color:var(--text-secondary);
|
|
430
|
+
cursor:pointer;transition:background .15s,color .15s,border-color .15s}
|
|
431
|
+
.code-editor-copy:hover{background:var(--accent);color:#fff;border-color:var(--accent)}
|
|
432
|
+
.code-editor-copy.copied{background:var(--passed-bg);color:var(--passed-text);border-color:var(--passed-border)}
|
|
433
|
+
.code-editor-body{display:flex;background:var(--bg-code);max-height:300px;overflow:auto}
|
|
434
|
+
.code-editor-lines{display:flex;flex-direction:column;padding:8px 0;
|
|
435
|
+
border-right:1px solid var(--border);flex-shrink:0;user-select:none;position:sticky;left:0;
|
|
436
|
+
background:var(--bg-code);z-index:1}
|
|
437
|
+
.code-editor-line-num{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;
|
|
438
|
+
color:var(--text-muted);text-align:right;padding:0 10px 0 12px;line-height:1.6;min-width:40px}
|
|
439
|
+
.code-editor-content{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;
|
|
440
|
+
color:var(--bg-code-text);padding:8px 12px;margin:0;white-space:pre;line-height:1.6;flex:1;
|
|
441
|
+
overflow-x:visible;tab-size:2}
|
|
442
|
+
.net-binary-note{font-size:11px;color:var(--text-muted);font-style:italic;padding:4px 0}
|
|
443
|
+
.net-empty-note{font-size:11px;color:var(--text-muted);font-style:italic;padding:2px 0}
|
|
444
|
+
.net-error-msg{font-size:12px;color:var(--failed-count);font-weight:600;padding:4px 0;margin-bottom:4px}
|
|
445
|
+
/* Filter Bar */
|
|
446
|
+
.filter-bar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:20px;
|
|
447
|
+
padding:12px 16px;background:var(--bg-secondary);border:1px solid var(--border);border-radius:10px}
|
|
448
|
+
.filter-section{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
|
|
449
|
+
.filter-section-label{font-size:11px;font-weight:600;color:var(--text-secondary);text-transform:uppercase;
|
|
450
|
+
letter-spacing:.04em;margin-right:2px}
|
|
451
|
+
.filter-chip{display:inline-flex;align-items:center;gap:4px;padding:4px 10px;border-radius:9999px;
|
|
452
|
+
font-size:12px;font-weight:500;border:1px solid var(--border);background:var(--bg-card);
|
|
453
|
+
color:var(--text-secondary);cursor:pointer;font-family:inherit;transition:background .15s,color .15s,border-color .15s}
|
|
454
|
+
.filter-chip:hover{border-color:var(--accent);color:var(--text-primary)}
|
|
455
|
+
.filter-chip--active{background:var(--accent);color:#fff;border-color:var(--accent)}
|
|
456
|
+
.filter-chip--active:hover{background:var(--accent-hover);border-color:var(--accent-hover)}
|
|
457
|
+
.filter-chip--dimmed{opacity:.45}
|
|
458
|
+
.filter-chip-count{font-size:11px;font-weight:600}
|
|
459
|
+
.filter-actions{display:flex;align-items:center;gap:12px;margin-left:auto}
|
|
460
|
+
.filter-clear{padding:4px 12px;border-radius:9999px;font-size:12px;font-weight:500;
|
|
461
|
+
border:1px solid var(--border);background:var(--bg-card);color:var(--text-secondary);
|
|
462
|
+
cursor:pointer;font-family:inherit;transition:background .15s,color .15s}
|
|
463
|
+
.filter-clear:hover{background:var(--failed-bg);color:var(--failed-text);border-color:var(--failed-border)}
|
|
464
|
+
.filter-indicator{font-size:12px;color:var(--text-secondary);font-weight:500}
|
|
465
|
+
.filter-indicator span{font-weight:700;color:var(--text-primary)}
|
|
466
|
+
.filter-hidden{display:none!important}
|
|
467
|
+
.filter-empty-state{text-align:center;padding:40px 20px;color:var(--text-muted)}
|
|
468
|
+
.filter-empty-state p{font-size:14px;margin-bottom:12px}
|
|
469
|
+
.filter-empty-state button{padding:6px 16px;border-radius:9999px;font-size:13px;font-weight:500;
|
|
470
|
+
border:1px solid var(--accent);background:transparent;color:var(--accent);cursor:pointer;
|
|
471
|
+
font-family:inherit;transition:background .15s,color .15s}
|
|
472
|
+
.filter-empty-state button:hover{background:var(--accent);color:#fff}
|
|
473
|
+
/* Reduced Motion */
|
|
474
|
+
@media(prefers-reduced-motion:reduce){
|
|
475
|
+
*,*::before,*::after{transition-duration:0s!important;animation-duration:0s!important}
|
|
476
|
+
}
|
|
270
477
|
`;
|
|
271
|
-
var JS = `
|
|
272
|
-
(function(){
|
|
273
|
-
var data=JSON.parse(document.getElementById('report-data').textContent);
|
|
274
478
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
479
|
+
// src/html-js-render.ts
|
|
480
|
+
var JS_RENDER = `
|
|
481
|
+
function esc(s){if(!s)return '';return s.replace(/&/g,'&').replace(/</g,'<')
|
|
482
|
+
.replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,''')}
|
|
483
|
+
function stripAnsi(s){return s?s.replace(/\\u001b\\[[0-9;]*m/g,'').replace(/\\x1b\\[[0-9;]*m/g,''):''}
|
|
484
|
+
function fmtDur(ms){if(ms<1000)return Math.round(ms)+'ms';
|
|
485
|
+
if(ms<60000)return (ms/1000).toFixed(1)+'s';
|
|
486
|
+
var m=Math.floor(ms/60000),s=Math.round((ms%60000)/1000);
|
|
487
|
+
return s>0?m+'m '+s+'s':m+'m'}
|
|
488
|
+
function fmtBytes(b){if(b===0)return '0 B';if(b<1024)return b+' B';
|
|
489
|
+
if(b<1048576)return (b/1024).toFixed(1)+' KB';return (b/1048576).toFixed(1)+' MB'}
|
|
490
|
+
function fmtTime(iso){try{return new Date(iso).toLocaleString()}catch(e){return iso}}
|
|
491
|
+
|
|
492
|
+
function renderCodeSnippet(code,failLine){
|
|
493
|
+
var lines=code.split('\\n');
|
|
494
|
+
var out='<div class="code-snippet">';
|
|
495
|
+
for(var k=0;k<lines.length;k++){
|
|
496
|
+
var raw=lines[k];
|
|
497
|
+
var numMatch=raw.match(/^\\s*(>?\\s*)(\\d+)\\s*\\|/);
|
|
498
|
+
var lineNum=numMatch?numMatch[2]:'';
|
|
499
|
+
var isHighlight=raw.trimStart().startsWith('>');
|
|
500
|
+
var codePart=raw.replace(/^\\s*>?\\s*\\d+\\s*\\|/,'');
|
|
501
|
+
out+='<div class="code-line'+(isHighlight?' highlight':'')+'">';
|
|
502
|
+
out+='<span class="line-num">'+esc(lineNum)+'</span>';
|
|
503
|
+
out+='<span class="line-code">'+esc(codePart)+'</span>';
|
|
504
|
+
out+='</div>';
|
|
505
|
+
}
|
|
506
|
+
out+='</div>';
|
|
507
|
+
return out;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function renderNetwork(stats){
|
|
511
|
+
if(!stats)return '<div class="no-network">No network data captured</div>';
|
|
512
|
+
var hasFailedReqs=stats.failedRequests>0;
|
|
513
|
+
var out='<div class="network-panel'+(hasFailedReqs?' network-panel--has-failures':'')+'">';
|
|
514
|
+
out+='<div class="network-header"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 12h-4l-3 9L9 3l-3 9H2"/></svg>Network</div>';
|
|
515
|
+
out+='<div class="network-summary">';
|
|
516
|
+
out+='<div class="net-stat"><span class="val">'+stats.totalRequests+'</span><span class="lbl">Requests</span></div>';
|
|
517
|
+
out+='<div class="net-stat'+(hasFailedReqs?' has-failed':'')+'"><span class="val">'+stats.failedRequests+'</span><span class="lbl">Failed</span></div>';
|
|
518
|
+
out+='<div class="net-stat"><span class="val">'+fmtBytes(stats.totalBytes)+'</span><span class="lbl">Transferred</span></div>';
|
|
519
|
+
out+='</div>';
|
|
520
|
+
if(hasFailedReqs){out+='<div class="failed-requests-banner"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 9v2m0 4h.01M10.29 3.86l-8.58 14.6A2 2 0 003.44 21h17.12a2 2 0 001.73-2.54l-8.58-14.6a2 2 0 00-3.42 0z"/></svg>'+stats.failedRequests+' network request'+(stats.failedRequests>1?'s':'')+' failed</div>';
|
|
521
|
+
if(stats.failedRequestUrls&&stats.failedRequestUrls.length>0){out+='<div class="failed-urls-list">';for(var fi=0;fi<stats.failedRequestUrls.length;fi++){var furl=stats.failedRequestUrls[fi];var spIdx=furl.indexOf(' ');var fStatus=spIdx>0?furl.substring(0,spIdx):'';var fPath=spIdx>0?furl.substring(spIdx+1):furl;out+='<div class="failed-url-item"><span class="failed-url-status">'+esc(fStatus)+'</span>'+esc(fPath)+'</div>';}out+='</div>';}
|
|
522
|
+
}
|
|
523
|
+
if(stats.byType){
|
|
524
|
+
var types=[['XHR','xhr'],['Document','document'],['Script','script'],['Stylesheet','stylesheet'],['Image','image'],['Font','font'],['Other','other']];
|
|
525
|
+
out+='<div class="resource-breakdown">';
|
|
526
|
+
for(var ti=0;ti<types.length;ti++){
|
|
527
|
+
var cnt=stats.byType[types[ti][1]]||0;
|
|
528
|
+
out+='<div class="resource-type'+(cnt===0?' resource-type--zero':'')+'"><span class="rt-count">'+cnt+'</span> '+types[ti][0]+'</div>';
|
|
529
|
+
}
|
|
530
|
+
out+='</div>';
|
|
531
|
+
}
|
|
532
|
+
out+='</div>';
|
|
533
|
+
return out;
|
|
534
|
+
}
|
|
285
535
|
|
|
536
|
+
(function(){
|
|
537
|
+
var data=JSON.parse(document.getElementById('report-data').textContent);
|
|
286
538
|
var app=document.getElementById('app');
|
|
539
|
+
var _testIdx=0;
|
|
287
540
|
|
|
288
541
|
// Header
|
|
289
|
-
var h='<div class="header">__LOGO_SVG__<h1>TestRelic Report</h1
|
|
542
|
+
var h='<div class="header">__LOGO_SVG__<h1>TestRelic Report</h1>';
|
|
543
|
+
h+='<button class="theme-toggle" onclick="toggleTheme()" title="Toggle theme" id="theme-toggle">';
|
|
544
|
+
h+='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="theme-icon-light"><path d="M21 12.79A9 9 0 1111.21 3a7 7 0 009.79 9.79z"/></svg>';
|
|
545
|
+
h+='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="theme-icon-dark" style="display:none"><circle cx="12" cy="12" r="5"/><path d="M12 1v2m0 18v2M4.22 4.22l1.42 1.42m12.72 12.72l1.42 1.42M1 12h2m18 0h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg>';
|
|
546
|
+
h+='</button></div>';
|
|
290
547
|
h+='<div class="meta">';
|
|
291
548
|
h+='<div class="meta-item"><span class="meta-label">Run ID</span><span class="run-id">'+esc(data.testRunId)+'</span></div>';
|
|
292
549
|
h+='<div class="meta-item"><span class="meta-label">Started</span>'+fmtTime(data.startedAt)+'</div>';
|
|
@@ -311,10 +568,15 @@ var JS = `
|
|
|
311
568
|
h+='<div class="summary-card card-failed"><div class="count">'+s.failed+'</div><div class="label">Failed</div></div>';
|
|
312
569
|
h+='<div class="summary-card card-flaky"><div class="count">'+s.flaky+'</div><div class="label">Flaky</div></div>';
|
|
313
570
|
h+='<div class="summary-card card-skipped"><div class="count">'+s.skipped+'</div><div class="label">Skipped</div></div>';
|
|
571
|
+
if(s.timedout!==undefined){h+='<div class="summary-card card-timedout"><div class="count">'+s.timedout+'</div><div class="label">Timed Out</div></div>';}
|
|
314
572
|
h+='</div>';
|
|
315
573
|
|
|
574
|
+
// Filter bar
|
|
575
|
+
h+=renderFilterBar(data);
|
|
576
|
+
|
|
316
577
|
// Timeline
|
|
317
578
|
h+='<div class="section-title">Navigation Timeline</div>';
|
|
579
|
+
h+='<div class="filter-empty-state" id="filter-empty" style="display:none"><p>No tests match the current filters</p><button onclick="clearAllFilters()">Clear all filters</button></div>';
|
|
318
580
|
if(data.timeline.length===0){
|
|
319
581
|
h+='<div class="empty-state">__LOGO_SVG__<p>No test data recorded</p></div>';
|
|
320
582
|
}else{
|
|
@@ -322,8 +584,10 @@ var JS = `
|
|
|
322
584
|
for(var i=0;i<data.timeline.length;i++){
|
|
323
585
|
var e=data.timeline[i];
|
|
324
586
|
var hasFail=e.tests.some(function(t){return t.status==='failed'});
|
|
325
|
-
var
|
|
326
|
-
|
|
587
|
+
var allPassed=!hasFail&&e.tests.length>0&&e.tests.every(function(t){return t.status==='passed'||t.status==='flaky'});
|
|
588
|
+
var cls='timeline-entry'+(hasFail?' timeline-entry--has-failures':'')+(allPassed?' timeline-entry--all-passed':'');
|
|
589
|
+
var _ss={},_ts={},_sp={};e.tests.forEach(function(t){_ss[t.status]=1;_ts[t.testType||'unknown']=1;if(t.filePath)_sp[t.filePath]=1;else if(e.specFile)_sp[e.specFile]=1});
|
|
590
|
+
h+='<div class="'+cls+'" data-idx="'+i+'" data-statuses="'+Object.keys(_ss).join(',')+'" data-types="'+Object.keys(_ts).join(',')+'" data-specs="'+esc(Object.keys(_sp).join(','))+'">';
|
|
327
591
|
h+='<div class="timeline-header" onclick="toggleEntry(this)">';
|
|
328
592
|
h+='<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>';
|
|
329
593
|
h+='<span class="timeline-url" title="'+esc(e.url)+'">'+esc(e.url)+'</span>';
|
|
@@ -334,7 +598,7 @@ var JS = `
|
|
|
334
598
|
h+='<span>'+fmtDur(e.duration)+'</span>';
|
|
335
599
|
h+='</div></div>';
|
|
336
600
|
h+='<div class="timeline-content">';
|
|
337
|
-
h+=renderTests(e.tests);
|
|
601
|
+
h+=renderTests(e.tests,e.networkStats);
|
|
338
602
|
h+=renderNetwork(e.networkStats);
|
|
339
603
|
h+='</div></div>';
|
|
340
604
|
}
|
|
@@ -342,118 +606,523 @@ var JS = `
|
|
|
342
606
|
}
|
|
343
607
|
|
|
344
608
|
app.innerHTML=h;
|
|
609
|
+
if(typeof initTheme==='function')initTheme();
|
|
610
|
+
if(typeof initFilters==='function')initFilters(data);
|
|
345
611
|
|
|
346
|
-
function renderTests(tests){
|
|
612
|
+
function renderTests(tests,networkStats){
|
|
347
613
|
if(!tests||tests.length===0)return '';
|
|
348
614
|
var out='<div class="tests-section">';
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
tests.forEach(function(t){if(t.status==='passed')pc++;else if(t.status==='failed')fc++;else if(t.status==='flaky')fkc++});
|
|
615
|
+
var pc=0,fc=0,fkc=0,sc=0,toc=0;
|
|
616
|
+
tests.forEach(function(t){if(t.status==='passed')pc++;else if(t.status==='failed')fc++;else if(t.status==='flaky')fkc++;else if(t.status==='skipped')sc++;else if(t.status==='timedout')toc++});
|
|
352
617
|
out+='<div class="spec-summary">';
|
|
353
618
|
if(pc>0)out+='<span class="spec-passed">'+pc+' passed</span>';
|
|
354
619
|
if(fc>0)out+='<span class="spec-failed">'+fc+' failed</span>';
|
|
355
620
|
if(fkc>0)out+='<span class="spec-flaky">'+fkc+' flaky</span>';
|
|
621
|
+
if(sc>0)out+='<span style="color:#6b7280;font-weight:600">'+sc+' skipped</span>';
|
|
622
|
+
if(toc>0)out+='<span style="color:#ea580c;font-weight:600">'+toc+' timed out</span>';
|
|
356
623
|
out+='</div>';
|
|
357
624
|
for(var j=0;j<tests.length;j++){
|
|
358
|
-
|
|
359
|
-
out+='<div class="test-card">';
|
|
360
|
-
out+='<span class="status-badge status-'+t.status+'">'+t.status+'</span>';
|
|
361
|
-
out+='<div class="test-info">';
|
|
362
|
-
out+='<div class="test-title" title="'+esc(t.title)+'">'+esc(t.title)+'</div>';
|
|
363
|
-
out+='<div class="test-meta">';
|
|
364
|
-
if(t.retryCount>0)out+='<span class="retry-badge">'+t.retryCount+' retries</span>';
|
|
365
|
-
if(t.tags)t.tags.forEach(function(tag){if(tag)out+='<span class="tag-badge">'+esc(tag)+'</span>'});
|
|
366
|
-
out+='</div>';
|
|
367
|
-
if((t.status==='failed'||t.status==='flaky')&&t.failure){
|
|
368
|
-
var fid='fail-'+Math.random().toString(36).substr(2,9);
|
|
369
|
-
out+='<button class="failure-toggle" onclick="toggleFail(\\''+fid+'\\')">Show details</button>';
|
|
370
|
-
out+='<div class="failure-details" id="'+fid+'">';
|
|
371
|
-
out+='<div class="failure-message">'+esc(stripAnsi(t.failure.message))+'</div>';
|
|
372
|
-
if(t.failure.code){
|
|
373
|
-
out+=renderCodeSnippet(t.failure.code,t.failure.line);
|
|
374
|
-
}
|
|
375
|
-
if(t.failure.line!==null){
|
|
376
|
-
out+='<div style="padding:4px 12px;font-size:11px;color:#9ca3af;background:#f9fafb">Line '+t.failure.line+'</div>';
|
|
377
|
-
}
|
|
378
|
-
if(t.failure.stack){
|
|
379
|
-
var sid='stack-'+Math.random().toString(36).substr(2,9);
|
|
380
|
-
out+='<button class="stack-toggle" onclick="toggleStack(\\''+sid+'\\')">Show stack trace</button>';
|
|
381
|
-
out+='<div class="stack-trace" id="'+sid+'">'+esc(stripAnsi(t.failure.stack))+'</div>';
|
|
382
|
-
}
|
|
383
|
-
out+='</div>';
|
|
384
|
-
} else if(t.status==='failed'&&!t.failure){
|
|
385
|
-
out+='<div style="margin-top:4px;font-size:12px;color:#9ca3af;font-style:italic">No diagnostic information available</div>';
|
|
386
|
-
}
|
|
387
|
-
out+='</div>';
|
|
388
|
-
out+='<span class="test-duration">'+fmtDur(t.duration)+'</span>';
|
|
389
|
-
out+='</div>';
|
|
625
|
+
out+=renderTestCard(tests[j],_testIdx++,networkStats);
|
|
390
626
|
}
|
|
391
627
|
out+='</div>';
|
|
392
628
|
return out;
|
|
393
629
|
}
|
|
394
630
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
631
|
+
})();
|
|
632
|
+
`;
|
|
633
|
+
|
|
634
|
+
// src/html-js-tabs.ts
|
|
635
|
+
var JS_TABS = `
|
|
636
|
+
function renderTestCard(t,idx,networkStats){
|
|
637
|
+
var id='test-'+idx;
|
|
638
|
+
var out='<div class="test-card" id="'+id+'" data-status="'+t.status+'" data-type="'+(t.testType||'unknown')+'" data-spec="'+esc(t.filePath||'')+'">';
|
|
639
|
+
out+='<div class="test-card-row">';
|
|
640
|
+
out+='<span class="status-badge status-'+t.status+'">'+t.status+'</span>';
|
|
641
|
+
out+='<div class="test-info">';
|
|
642
|
+
out+='<div class="test-title" title="'+esc(t.title)+'">'+esc(t.title)+'</div>';
|
|
643
|
+
out+='<div class="test-meta">';
|
|
644
|
+
if(t.testType&&t.testType!=='unknown')out+='<span class="type-badge">'+esc(t.testType)+'</span>';
|
|
645
|
+
if(t.isFlaky)out+='<span class="flaky-badge">flaky</span>';
|
|
646
|
+
if(t.retryCount>0)out+='<span class="retry-badge">'+t.retryCount+' retries</span>';
|
|
647
|
+
if(t.retryStatus)out+='<span class="retry-badge">'+esc(t.retryStatus)+'</span>';
|
|
648
|
+
if(t.tags&&t.tags.length>0){out+='<span class="meta-prefix">Tags:</span>';t.tags.forEach(function(tag){if(tag)out+='<span class="tag-badge">'+esc(tag)+'</span>'});}
|
|
649
|
+
if(t.expectedStatus&&t.actualStatus&&t.expectedStatus!==t.actualStatus)out+='<span class="status-mismatch">expected: '+esc(t.expectedStatus)+' actual: '+esc(t.actualStatus)+'</span>';
|
|
650
|
+
out+='</div>';
|
|
651
|
+
if(t.testId||t.filePath||t.suiteName){out+='<div class="test-meta">';
|
|
652
|
+
if(t.testId)out+='<span class="meta-prefix">ID:</span><span class="test-id" title="Full ID: '+esc(t.testId)+'">'+esc(t.testId.substring(0,12))+'</span>';
|
|
653
|
+
if(t.filePath)out+='<span class="meta-prefix">File:</span><span class="file-path">'+esc(t.filePath)+'</span>';
|
|
654
|
+
if(t.suiteName)out+='<span class="meta-prefix">Suite:</span><span class="suite-name">'+esc(t.suiteName)+'</span>';
|
|
655
|
+
out+='</div>';}
|
|
656
|
+
out+='</div>';
|
|
657
|
+
out+='<span class="test-duration">'+fmtDur(t.duration)+'</span>';
|
|
658
|
+
out+='</div>';
|
|
659
|
+
|
|
660
|
+
// Tab bar
|
|
661
|
+
var hasScreenshot=t.artifacts&&t.artifacts.screenshot;
|
|
662
|
+
var hasVideo=t.artifacts&&t.artifacts.video;
|
|
663
|
+
var hasNetworkReqs=t.networkRequests&&t.networkRequests.length>0;
|
|
664
|
+
var hasNetworkStats=!!networkStats;
|
|
665
|
+
|
|
666
|
+
out+='<div class="tab-bar">';
|
|
667
|
+
out+='<button class="tab-btn active" data-tab="details" onclick="switchTab(\\''+id+'\\',\\'details\\')">Test Details</button>';
|
|
668
|
+
out+='<button class="tab-btn" data-tab="network" onclick="switchTab(\\''+id+'\\',\\'network\\')">Network Logs</button>';
|
|
669
|
+
out+='<button class="tab-btn" data-tab="video" onclick="switchTab(\\''+id+'\\',\\'video\\')">Video</button>';
|
|
670
|
+
out+='<button class="tab-btn" data-tab="screenshots" onclick="switchTab(\\''+id+'\\',\\'screenshots\\')">Screenshots</button>';
|
|
671
|
+
out+='</div>';
|
|
672
|
+
|
|
673
|
+
// Tab: Test Details
|
|
674
|
+
out+='<div class="tab-panel active" id="'+id+'-details">';
|
|
675
|
+
if((t.status==='failed'||t.status==='flaky')&&t.failure){
|
|
676
|
+
out+='<div class="failure-details show">';
|
|
677
|
+
out+='<div class="failure-message">'+esc(stripAnsi(t.failure.message))+'</div>';
|
|
678
|
+
if(t.failure.code){
|
|
679
|
+
out+=renderCodeSnippet(t.failure.code,t.failure.line);
|
|
680
|
+
}
|
|
681
|
+
if(t.failure.line!==null){
|
|
682
|
+
out+='<div style="padding:4px 12px;font-size:11px;color:var(--text-muted);background:var(--bg-secondary)">Line '+t.failure.line+'</div>';
|
|
683
|
+
}
|
|
684
|
+
if(t.failure.stack){
|
|
685
|
+
var sid='stack-'+Math.random().toString(36).substr(2,9);
|
|
686
|
+
out+='<button class="stack-toggle" onclick="toggleStack(\\''+sid+'\\')">Show stack trace</button>';
|
|
687
|
+
out+='<div class="stack-trace" id="'+sid+'">'+esc(stripAnsi(t.failure.stack))+'</div>';
|
|
408
688
|
}
|
|
409
689
|
out+='</div>';
|
|
410
|
-
|
|
690
|
+
} else if(t.status==='failed'&&!t.failure){
|
|
691
|
+
out+='<div style="margin-top:4px;font-size:12px;color:#9ca3af;font-style:italic">No diagnostic information available</div>';
|
|
692
|
+
} else {
|
|
693
|
+
out+='<div class="tab-empty-state">Test passed \u2014 no diagnostic details</div>';
|
|
411
694
|
}
|
|
695
|
+
out+='</div>';
|
|
412
696
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
697
|
+
// Tab: Network Logs
|
|
698
|
+
out+='<div class="tab-panel" id="'+id+'-network">';
|
|
699
|
+
out+=renderNetworkLogs(t,networkStats);
|
|
700
|
+
out+='</div>';
|
|
701
|
+
|
|
702
|
+
// Tab: Video
|
|
703
|
+
out+='<div class="tab-panel" id="'+id+'-video">';
|
|
704
|
+
if(hasVideo){
|
|
705
|
+
out+='<div class="artifact-video-inline">';
|
|
706
|
+
out+='<video class="artifact-video-player" controls preload="metadata" src="'+esc(t.artifacts.video)+'"></video>';
|
|
421
707
|
out+='</div>';
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
708
|
+
} else {
|
|
709
|
+
out+='<div class="tab-empty-state">No video captured</div>';
|
|
710
|
+
}
|
|
711
|
+
out+='</div>';
|
|
712
|
+
|
|
713
|
+
// Tab: Screenshots
|
|
714
|
+
out+='<div class="tab-panel" id="'+id+'-screenshots">';
|
|
715
|
+
if(hasScreenshot){
|
|
716
|
+
out+='<div class="artifact-screenshot-wrap">';
|
|
717
|
+
out+='<img class="artifact-thumbnail" src="'+esc(t.artifacts.screenshot)+'" loading="lazy" alt="Screenshot" onclick="openLightbox(this.src)">';
|
|
718
|
+
out+='<span class="artifact-label">Click to enlarge</span>';
|
|
719
|
+
out+='</div>';
|
|
720
|
+
} else {
|
|
721
|
+
out+='<div class="tab-empty-state">No screenshot captured</div>';
|
|
722
|
+
}
|
|
723
|
+
out+='</div>';
|
|
724
|
+
|
|
725
|
+
out+='</div>';
|
|
726
|
+
return out;
|
|
727
|
+
}
|
|
728
|
+
`;
|
|
729
|
+
|
|
730
|
+
// src/html-js-network.ts
|
|
731
|
+
var JS_NETWORK = `
|
|
732
|
+
function fmtBodyForEditor(body,contentType){
|
|
733
|
+
if(!body)return body;
|
|
734
|
+
if(contentType&&(contentType.indexOf('json')>=0)){
|
|
735
|
+
try{return JSON.stringify(JSON.parse(body),null,2)}catch(e){}
|
|
736
|
+
}
|
|
737
|
+
return body;
|
|
738
|
+
}
|
|
739
|
+
function renderCodeEditor(body,contentType,editorId){
|
|
740
|
+
if(!body)return '';
|
|
741
|
+
var formatted=fmtBodyForEditor(body,contentType);
|
|
742
|
+
var lines=formatted.split('\\n');
|
|
743
|
+
var out='<div class="code-editor" id="'+editorId+'">';
|
|
744
|
+
out+='<div class="code-editor-toolbar">';
|
|
745
|
+
out+='<span class="code-editor-lang">'+(contentType?esc(contentType.split(';')[0]):'text')+'</span>';
|
|
746
|
+
out+='<button class="code-editor-copy" onclick="copyEditorContent(\\''+editorId+'\\')">Copy</button>';
|
|
747
|
+
out+='</div>';
|
|
748
|
+
out+='<div class="code-editor-body">';
|
|
749
|
+
out+='<div class="code-editor-lines">';
|
|
750
|
+
for(var i=0;i<lines.length;i++){
|
|
751
|
+
out+='<div class="code-editor-line-num">'+(i+1)+'</div>';
|
|
752
|
+
}
|
|
753
|
+
out+='</div>';
|
|
754
|
+
out+='<pre class="code-editor-content">'+esc(formatted)+'</pre>';
|
|
755
|
+
out+='</div></div>';
|
|
756
|
+
return out;
|
|
757
|
+
}
|
|
758
|
+
function renderNetworkLogs(t,networkStats){
|
|
759
|
+
if(t.networkRequests&&t.networkRequests.length>0){
|
|
760
|
+
var reqs=t.networkRequests;
|
|
761
|
+
var failed=reqs.filter(function(r){return r.statusCode===0||r.statusCode>=400}).length;
|
|
762
|
+
var out='<div class="network-log">';
|
|
763
|
+
out+='<div class="network-log-summary">';
|
|
764
|
+
out+='<span class="net-log-count">'+reqs.length+' request'+(reqs.length>1?'s':'')+'</span>';
|
|
765
|
+
if(failed>0)out+='<span class="net-log-failed">'+failed+' failed</span>';
|
|
766
|
+
out+='</div>';
|
|
767
|
+
for(var i=0;i<reqs.length;i++){
|
|
768
|
+
var r=reqs[i];
|
|
769
|
+
var nid='net-'+Math.random().toString(36).substr(2,9);
|
|
770
|
+
var statusCls='net-status-'+Math.floor(r.statusCode/100)+'xx';
|
|
771
|
+
if(r.statusCode===0)statusCls='net-status-0';
|
|
772
|
+
var isFailed=r.statusCode===0||r.statusCode>=400;
|
|
773
|
+
out+='<div class="network-entry'+(isFailed?' network-entry--failed':'')+'">';
|
|
774
|
+
out+='<div class="network-entry-row" onclick="toggleNetworkEntry(\\''+nid+'\\')">';
|
|
775
|
+
out+='<span class="net-status-badge '+statusCls+'">'+(r.statusCode||'ERR')+'</span>';
|
|
776
|
+
out+='<span class="net-method">'+esc(r.method)+'</span>';
|
|
777
|
+
out+='<span class="net-url" title="'+esc(r.url)+'">'+esc(r.url)+'</span>';
|
|
778
|
+
out+='<span class="net-time">'+fmtDur(r.responseTimeMs)+'</span>';
|
|
779
|
+
out+='<svg class="net-chevron" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>';
|
|
429
780
|
out+='</div>';
|
|
781
|
+
out+='<div class="network-entry-details" id="'+nid+'">';
|
|
782
|
+
if(r.error){
|
|
783
|
+
out+='<div class="net-error-msg">'+esc(r.error)+'</div>';
|
|
784
|
+
}
|
|
785
|
+
// Request Headers
|
|
786
|
+
if(r.requestHeaders){
|
|
787
|
+
out+='<div class="net-section-title">Request Headers</div>';
|
|
788
|
+
out+='<table class="net-headers-table">';
|
|
789
|
+
var rkeys=Object.keys(r.requestHeaders);
|
|
790
|
+
for(var j=0;j<rkeys.length;j++){
|
|
791
|
+
out+='<tr><td class="net-header-key">'+esc(rkeys[j])+'</td><td class="net-header-val">'+esc(r.requestHeaders[rkeys[j]])+'</td></tr>';
|
|
792
|
+
}
|
|
793
|
+
out+='</table>';
|
|
794
|
+
}
|
|
795
|
+
// Request Body
|
|
796
|
+
out+='<div class="net-section-title">Request Body</div>';
|
|
797
|
+
if(r.requestBody){
|
|
798
|
+
var reqEdId='req-body-'+nid;
|
|
799
|
+
var reqCt='text/plain';
|
|
800
|
+
if(r.requestHeaders){var rctKey=Object.keys(r.requestHeaders).filter(function(k){return k.toLowerCase()==='content-type'})[0];if(rctKey)reqCt=r.requestHeaders[rctKey]}
|
|
801
|
+
out+=renderCodeEditor(r.requestBody,reqCt,reqEdId);
|
|
802
|
+
if(r.requestBodyTruncated)out+='<div class="net-truncated-note">Truncated \u2014 body exceeds 10 KB</div>';
|
|
803
|
+
} else {
|
|
804
|
+
out+='<div class="net-empty-note">No request body</div>';
|
|
805
|
+
}
|
|
806
|
+
// Response Headers
|
|
807
|
+
if(r.responseHeaders){
|
|
808
|
+
out+='<div class="net-section-title">Response Headers</div>';
|
|
809
|
+
out+='<table class="net-headers-table">';
|
|
810
|
+
var hkeys=Object.keys(r.responseHeaders);
|
|
811
|
+
for(var j=0;j<hkeys.length;j++){
|
|
812
|
+
out+='<tr><td class="net-header-key">'+esc(hkeys[j])+'</td><td class="net-header-val">'+esc(r.responseHeaders[hkeys[j]])+'</td></tr>';
|
|
813
|
+
}
|
|
814
|
+
out+='</table>';
|
|
815
|
+
}
|
|
816
|
+
// Response Body
|
|
817
|
+
out+='<div class="net-section-title">Response Body</div>';
|
|
818
|
+
if(r.isBinary){
|
|
819
|
+
out+='<div class="net-binary-note">[Binary data'+(r.responseSize?' \u2014 '+fmtBytes(r.responseSize):'')+']</div>';
|
|
820
|
+
} else if(r.responseBody){
|
|
821
|
+
var respEdId='resp-body-'+nid;
|
|
822
|
+
out+=renderCodeEditor(r.responseBody,r.contentType,respEdId);
|
|
823
|
+
if(r.responseBodyTruncated)out+='<div class="net-truncated-note">Truncated \u2014 body exceeds 10 KB</div>';
|
|
824
|
+
} else {
|
|
825
|
+
out+='<div class="net-empty-note">No response body</div>';
|
|
826
|
+
}
|
|
827
|
+
out+='</div></div>';
|
|
430
828
|
}
|
|
431
829
|
out+='</div>';
|
|
432
830
|
return out;
|
|
433
831
|
}
|
|
832
|
+
if(networkStats){
|
|
833
|
+
return renderNetwork(networkStats);
|
|
834
|
+
}
|
|
835
|
+
return '<div class="tab-empty-state">No network logs captured</div>';
|
|
836
|
+
}
|
|
837
|
+
`;
|
|
434
838
|
|
|
435
|
-
|
|
436
|
-
|
|
839
|
+
// src/html-js-interactions.ts
|
|
840
|
+
var JS_INTERACTIONS = `
|
|
437
841
|
function toggleEntry(el){el.closest('.timeline-entry').classList.toggle('expanded')}
|
|
438
842
|
function toggleFail(id){document.getElementById(id).classList.toggle('show')}
|
|
439
843
|
function toggleStack(id){document.getElementById(id).classList.toggle('show')}
|
|
844
|
+
function openLightbox(src){var o=document.createElement('div');o.className='lightbox-overlay';
|
|
845
|
+
o.onclick=function(){closeLightbox()};o.innerHTML='<img src="'+src.replace(/"/g,'"')+'" alt="Screenshot">';
|
|
846
|
+
var b=document.createElement('button');b.className='lightbox-close';b.innerHTML='×';
|
|
847
|
+
b.onclick=function(e){e.stopPropagation();closeLightbox()};
|
|
848
|
+
document.body.appendChild(o);document.body.appendChild(b);
|
|
849
|
+
document.addEventListener('keydown',lightboxEsc)}
|
|
850
|
+
function closeLightbox(){var o=document.querySelector('.lightbox-overlay');if(o)o.remove();
|
|
851
|
+
var b=document.querySelector('.lightbox-close');if(b)b.remove();
|
|
852
|
+
document.removeEventListener('keydown',lightboxEsc)}
|
|
853
|
+
function lightboxEsc(e){if(e.key==='Escape')closeLightbox()}
|
|
854
|
+
function toggleVideo(id){var el=document.getElementById(id);if(!el)return;
|
|
855
|
+
var isShown=el.classList.toggle('show');
|
|
856
|
+
var btn=el.previousElementSibling;
|
|
857
|
+
if(btn)btn.textContent=isShown?'Hide video':'Show video';
|
|
858
|
+
if(!isShown){var v=el.querySelector('video');if(v)v.pause()}}
|
|
859
|
+
function switchTab(testId,tabName){var card=document.getElementById(testId);if(!card)return;
|
|
860
|
+
var panels=card.querySelectorAll('.tab-panel');for(var i=0;i<panels.length;i++)panels[i].classList.remove('active');
|
|
861
|
+
var btns=card.querySelectorAll('.tab-btn');for(var i=0;i<btns.length;i++)btns[i].classList.remove('active');
|
|
862
|
+
var target=document.getElementById(testId+'-'+tabName);if(target)target.classList.add('active');
|
|
863
|
+
var clicked=card.querySelector('.tab-btn[data-tab="'+tabName+'"]');if(clicked)clicked.classList.add('active')}
|
|
864
|
+
function toggleNetworkEntry(id){var el=document.getElementById(id);if(!el)return;
|
|
865
|
+
el.classList.toggle('show');
|
|
866
|
+
var row=el.previousElementSibling;
|
|
867
|
+
if(row)row.classList.toggle('expanded')}
|
|
868
|
+
function copyEditorContent(editorId){var el=document.getElementById(editorId);if(!el)return;
|
|
869
|
+
var pre=el.querySelector('.code-editor-content');if(!pre)return;
|
|
870
|
+
var text=pre.textContent||'';
|
|
871
|
+
navigator.clipboard.writeText(text).then(function(){
|
|
872
|
+
var btn=el.querySelector('.code-editor-copy');if(!btn)return;
|
|
873
|
+
btn.textContent='Copied!';btn.classList.add('copied');
|
|
874
|
+
setTimeout(function(){btn.textContent='Copy';btn.classList.remove('copied')},1500)
|
|
875
|
+
}).catch(function(){})}
|
|
876
|
+
function initTheme(){
|
|
877
|
+
var stored=localStorage.getItem('testrelic-theme');
|
|
878
|
+
var theme=stored||(window.matchMedia&&window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light');
|
|
879
|
+
document.documentElement.setAttribute('data-theme',theme);
|
|
880
|
+
updateThemeIcon(theme)}
|
|
881
|
+
function toggleTheme(){
|
|
882
|
+
var current=document.documentElement.getAttribute('data-theme')||'light';
|
|
883
|
+
var next=current==='dark'?'light':'dark';
|
|
884
|
+
document.documentElement.setAttribute('data-theme',next);
|
|
885
|
+
localStorage.setItem('testrelic-theme',next);
|
|
886
|
+
updateThemeIcon(next)}
|
|
887
|
+
function updateThemeIcon(theme){
|
|
888
|
+
var light=document.querySelector('.theme-icon-light');
|
|
889
|
+
var dark=document.querySelector('.theme-icon-dark');
|
|
890
|
+
if(light)light.style.display=theme==='dark'?'none':'block';
|
|
891
|
+
if(dark)dark.style.display=theme==='dark'?'block':'none'}
|
|
892
|
+
`;
|
|
893
|
+
|
|
894
|
+
// src/html-js-filters.ts
|
|
895
|
+
var JS_FILTERS = `
|
|
896
|
+
var _filterState={status:{},type:{},specFile:{}};
|
|
897
|
+
var _totalTests=0;
|
|
898
|
+
var _originalSummary=null;
|
|
899
|
+
|
|
900
|
+
function renderFilterBar(data){
|
|
901
|
+
var statusCounts={},typeCounts={},specCounts={};
|
|
902
|
+
data.timeline.forEach(function(entry){
|
|
903
|
+
entry.tests.forEach(function(t){
|
|
904
|
+
statusCounts[t.status]=(statusCounts[t.status]||0)+1;
|
|
905
|
+
var tp=t.testType||'unknown';
|
|
906
|
+
typeCounts[tp]=(typeCounts[tp]||0)+1;
|
|
907
|
+
var fp=t.filePath||entry.specFile||'';
|
|
908
|
+
if(fp)specCounts[fp]=(specCounts[fp]||0)+1;
|
|
909
|
+
});
|
|
910
|
+
});
|
|
911
|
+
var out='<div class="filter-bar" id="filter-bar">';
|
|
912
|
+
|
|
913
|
+
// Status chips
|
|
914
|
+
out+='<div class="filter-section">';
|
|
915
|
+
out+='<span class="filter-section-label">Status</span>';
|
|
916
|
+
var statuses=['passed','failed','flaky','skipped','timedout'];
|
|
917
|
+
var statusLabels={passed:'Passed',failed:'Failed',flaky:'Flaky',skipped:'Skipped',timedout:'Timed Out'};
|
|
918
|
+
for(var i=0;i<statuses.length;i++){
|
|
919
|
+
var s=statuses[i];var cnt=statusCounts[s]||0;
|
|
920
|
+
out+='<button class="filter-chip filter-chip--status'+(cnt===0?' filter-chip--dimmed':'')+'" data-dimension="status" data-value="'+s+'">';
|
|
921
|
+
out+=statusLabels[s]+' <span class="filter-chip-count">('+cnt+')</span></button>';
|
|
922
|
+
}
|
|
923
|
+
out+='</div>';
|
|
924
|
+
|
|
925
|
+
// Type chips (only types present in data)
|
|
926
|
+
var types=Object.keys(typeCounts);
|
|
927
|
+
if(types.length>0){
|
|
928
|
+
out+='<div class="filter-section">';
|
|
929
|
+
out+='<span class="filter-section-label">Type</span>';
|
|
930
|
+
for(var i=0;i<types.length;i++){
|
|
931
|
+
var t=types[i];var cnt=typeCounts[t]||0;
|
|
932
|
+
out+='<button class="filter-chip filter-chip--type'+(cnt===0?' filter-chip--dimmed':'')+'" data-dimension="type" data-value="'+esc(t)+'">';
|
|
933
|
+
out+=esc(t)+' <span class="filter-chip-count">('+cnt+')</span></button>';
|
|
934
|
+
}
|
|
935
|
+
out+='</div>';
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
// Spec file chips (only if multiple files)
|
|
939
|
+
var specs=Object.keys(specCounts).sort();
|
|
940
|
+
if(specs.length>1){
|
|
941
|
+
out+='<div class="filter-section">';
|
|
942
|
+
out+='<span class="filter-section-label">File</span>';
|
|
943
|
+
for(var i=0;i<specs.length;i++){
|
|
944
|
+
var sp=specs[i];var cnt=specCounts[sp]||0;
|
|
945
|
+
var short=sp.split('/').pop()||sp;
|
|
946
|
+
out+='<button class="filter-chip filter-chip--file'+(cnt===0?' filter-chip--dimmed':'')+'" data-dimension="specFile" data-value="'+esc(sp)+'" title="'+esc(sp)+'">';
|
|
947
|
+
out+=esc(short)+' <span class="filter-chip-count">('+cnt+')</span></button>';
|
|
948
|
+
}
|
|
949
|
+
out+='</div>';
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
// Actions row
|
|
953
|
+
out+='<div class="filter-actions">';
|
|
954
|
+
out+='<button class="filter-clear" id="filter-clear" onclick="clearAllFilters()" style="display:none">Clear all</button>';
|
|
955
|
+
out+='<span class="filter-indicator" id="filter-indicator" style="display:none">';
|
|
956
|
+
out+='Showing <span id="filter-shown">0</span> of <span id="filter-total">0</span> tests</span>';
|
|
957
|
+
out+='</div>';
|
|
958
|
+
out+='</div>';
|
|
959
|
+
return out;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
function initFilters(data){
|
|
963
|
+
_filterState={status:{},type:{},specFile:{}};
|
|
964
|
+
// Count from actual test cards in DOM to match filter chip counts
|
|
965
|
+
var cards=document.querySelectorAll('.test-card');
|
|
966
|
+
var byStatus={passed:0,failed:0,flaky:0,skipped:0,timedout:0};
|
|
967
|
+
for(var i=0;i<cards.length;i++){
|
|
968
|
+
var st=cards[i].getAttribute('data-status')||'';
|
|
969
|
+
if(byStatus[st]!==undefined)byStatus[st]++;
|
|
970
|
+
}
|
|
971
|
+
_totalTests=cards.length;
|
|
972
|
+
_originalSummary={total:cards.length,passed:byStatus.passed,
|
|
973
|
+
failed:byStatus.failed,flaky:byStatus.flaky,
|
|
974
|
+
skipped:byStatus.skipped,timedout:byStatus.timedout};
|
|
975
|
+
// Update summary cards to match actual test card counts
|
|
976
|
+
_updateCard('card-total',_originalSummary.total);
|
|
977
|
+
_updateCard('card-passed',_originalSummary.passed);
|
|
978
|
+
_updateCard('card-failed',_originalSummary.failed);
|
|
979
|
+
_updateCard('card-flaky',_originalSummary.flaky);
|
|
980
|
+
_updateCard('card-skipped',_originalSummary.skipped);
|
|
981
|
+
_updateCard('card-timedout',_originalSummary.timedout);
|
|
982
|
+
var el=document.getElementById('filter-total');
|
|
983
|
+
if(el)el.textContent=''+_totalTests;
|
|
984
|
+
var chips=document.querySelectorAll('.filter-chip');
|
|
985
|
+
for(var i=0;i<chips.length;i++){
|
|
986
|
+
(function(chip){
|
|
987
|
+
chip.addEventListener('click',function(){
|
|
988
|
+
var dim=chip.getAttribute('data-dimension');
|
|
989
|
+
var val=chip.getAttribute('data-value');
|
|
990
|
+
toggleFilter(dim,val);
|
|
991
|
+
});
|
|
992
|
+
})(chips[i]);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
function toggleFilter(dim,val){
|
|
997
|
+
if(!_filterState[dim])_filterState[dim]={};
|
|
998
|
+
if(_filterState[dim][val]){
|
|
999
|
+
delete _filterState[dim][val];
|
|
1000
|
+
}else{
|
|
1001
|
+
_filterState[dim][val]=true;
|
|
1002
|
+
}
|
|
1003
|
+
var chips=document.querySelectorAll('.filter-chip[data-dimension="'+dim+'"]');
|
|
1004
|
+
for(var i=0;i<chips.length;i++){
|
|
1005
|
+
var cv=chips[i].getAttribute('data-value');
|
|
1006
|
+
if(cv===val)chips[i].classList.toggle('filter-chip--active');
|
|
1007
|
+
}
|
|
1008
|
+
applyFilters();
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
function clearAllFilters(){
|
|
1012
|
+
_filterState={status:{},type:{},specFile:{}};
|
|
1013
|
+
var active=document.querySelectorAll('.filter-chip--active');
|
|
1014
|
+
for(var i=0;i<active.length;i++)active[i].classList.remove('filter-chip--active');
|
|
1015
|
+
applyFilters();
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
function applyFilters(){
|
|
1019
|
+
var hasStatus=Object.keys(_filterState.status).length>0;
|
|
1020
|
+
var hasType=Object.keys(_filterState.type).length>0;
|
|
1021
|
+
var hasSpec=Object.keys(_filterState.specFile).length>0;
|
|
1022
|
+
var hasAny=hasStatus||hasType||hasSpec;
|
|
1023
|
+
|
|
1024
|
+
var cards=document.querySelectorAll('.test-card');
|
|
1025
|
+
var visibleCount=0;
|
|
1026
|
+
var byStatus={passed:0,failed:0,flaky:0,skipped:0,timedout:0};
|
|
1027
|
+
|
|
1028
|
+
for(var i=0;i<cards.length;i++){
|
|
1029
|
+
var card=cards[i];
|
|
1030
|
+
var st=card.getAttribute('data-status')||'';
|
|
1031
|
+
var tp=card.getAttribute('data-type')||'';
|
|
1032
|
+
var sp=card.getAttribute('data-spec')||'';
|
|
1033
|
+
var match=true;
|
|
1034
|
+
if(hasStatus&&!_filterState.status[st])match=false;
|
|
1035
|
+
if(hasType&&!_filterState.type[tp])match=false;
|
|
1036
|
+
if(hasSpec&&!_filterState.specFile[sp])match=false;
|
|
1037
|
+
if(match){
|
|
1038
|
+
card.classList.remove('filter-hidden');
|
|
1039
|
+
visibleCount++;
|
|
1040
|
+
if(byStatus[st]!==undefined)byStatus[st]++;
|
|
1041
|
+
}else{
|
|
1042
|
+
card.classList.add('filter-hidden');
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
// Timeline entries: hide if no visible test cards inside
|
|
1047
|
+
var entries=document.querySelectorAll('.timeline-entry');
|
|
1048
|
+
for(var i=0;i<entries.length;i++){
|
|
1049
|
+
var entry=entries[i];
|
|
1050
|
+
var visCards=entry.querySelectorAll('.test-card:not(.filter-hidden)');
|
|
1051
|
+
if(hasAny&&visCards.length===0){
|
|
1052
|
+
entry.classList.add('filter-hidden');
|
|
1053
|
+
}else{
|
|
1054
|
+
entry.classList.remove('filter-hidden');
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// Clear all button
|
|
1059
|
+
var clearBtn=document.getElementById('filter-clear');
|
|
1060
|
+
if(clearBtn)clearBtn.style.display=hasAny?'':'none';
|
|
1061
|
+
|
|
1062
|
+
// Indicator
|
|
1063
|
+
var indicator=document.getElementById('filter-indicator');
|
|
1064
|
+
if(indicator)indicator.style.display=hasAny?'':'none';
|
|
1065
|
+
var shown=document.getElementById('filter-shown');
|
|
1066
|
+
if(shown)shown.textContent=''+visibleCount;
|
|
1067
|
+
|
|
1068
|
+
// Summary card updates
|
|
1069
|
+
if(hasAny){
|
|
1070
|
+
_updateCard('card-total',visibleCount);
|
|
1071
|
+
_updateCard('card-passed',byStatus.passed);
|
|
1072
|
+
_updateCard('card-failed',byStatus.failed);
|
|
1073
|
+
_updateCard('card-flaky',byStatus.flaky);
|
|
1074
|
+
_updateCard('card-skipped',byStatus.skipped);
|
|
1075
|
+
_updateCard('card-timedout',byStatus.timedout);
|
|
1076
|
+
}else if(_originalSummary){
|
|
1077
|
+
_updateCard('card-total',_originalSummary.total);
|
|
1078
|
+
_updateCard('card-passed',_originalSummary.passed);
|
|
1079
|
+
_updateCard('card-failed',_originalSummary.failed);
|
|
1080
|
+
_updateCard('card-flaky',_originalSummary.flaky);
|
|
1081
|
+
_updateCard('card-skipped',_originalSummary.skipped);
|
|
1082
|
+
_updateCard('card-timedout',_originalSummary.timedout);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
// Empty state
|
|
1086
|
+
var emptyEl=document.getElementById('filter-empty');
|
|
1087
|
+
var timeline=document.getElementById('timeline');
|
|
1088
|
+
if(hasAny&&visibleCount===0){
|
|
1089
|
+
if(emptyEl)emptyEl.style.display='';
|
|
1090
|
+
if(timeline)timeline.style.display='none';
|
|
1091
|
+
}else{
|
|
1092
|
+
if(emptyEl)emptyEl.style.display='none';
|
|
1093
|
+
if(timeline)timeline.style.display='';
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
function _updateCard(cls,val){
|
|
1098
|
+
var el=document.querySelector('.'+cls+' .count');
|
|
1099
|
+
if(el)el.textContent=''+val;
|
|
1100
|
+
}
|
|
440
1101
|
`;
|
|
1102
|
+
|
|
1103
|
+
// src/html-template.ts
|
|
441
1104
|
function renderHtmlDocument(reportJson) {
|
|
442
|
-
const jsWithLogo =
|
|
1105
|
+
const jsWithLogo = JS_RENDER.replace(/__LOGO_SVG__/g, LOGO_SVG.replace(/'/g, "\\'").replace(/\n/g, ""));
|
|
1106
|
+
const safeJson = reportJson.replace(/<\//g, "<\\/");
|
|
443
1107
|
return `<!-- TestRelic Report \u2014 self-contained, no external dependencies -->
|
|
444
1108
|
<!DOCTYPE html>
|
|
445
|
-
<html lang="en">
|
|
1109
|
+
<html lang="en" data-theme="">
|
|
446
1110
|
<head>
|
|
447
1111
|
<meta charset="UTF-8">
|
|
448
1112
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
449
|
-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; img-src data
|
|
1113
|
+
<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';">
|
|
450
1114
|
<title>TestRelic Report</title>
|
|
451
1115
|
<style>${CSS}</style>
|
|
452
1116
|
</head>
|
|
453
1117
|
<body>
|
|
1118
|
+
<script>!function(){var t=localStorage.getItem('testrelic-theme')||(window.matchMedia&&window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light');document.documentElement.setAttribute('data-theme',t)}()</script>
|
|
454
1119
|
<div class="container" id="app"></div>
|
|
455
|
-
<script id="report-data" type="application/json">${
|
|
456
|
-
<script>${jsWithLogo}
|
|
1120
|
+
<script id="report-data" type="application/json">${safeJson}</script>
|
|
1121
|
+
<script>${jsWithLogo}
|
|
1122
|
+
${JS_TABS}
|
|
1123
|
+
${JS_NETWORK}
|
|
1124
|
+
${JS_FILTERS}
|
|
1125
|
+
${JS_INTERACTIONS}</script>
|
|
457
1126
|
</body>
|
|
458
1127
|
</html>`;
|
|
459
1128
|
}
|
|
@@ -509,7 +1178,108 @@ function writeHtmlReport(report, config) {
|
|
|
509
1178
|
}
|
|
510
1179
|
}
|
|
511
1180
|
|
|
1181
|
+
// src/artifact-manager.ts
|
|
1182
|
+
import { mkdirSync as mkdirSync2, copyFileSync, existsSync } from "fs";
|
|
1183
|
+
import { join, extname } from "path";
|
|
1184
|
+
function sanitizeFolderName(title) {
|
|
1185
|
+
let name = title.replace(/[^a-zA-Z0-9\-_ ]/g, "-").replace(/\s+/g, "-").replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "");
|
|
1186
|
+
if (name.length > 100) {
|
|
1187
|
+
name = name.substring(0, 100).replace(/-+$/, "");
|
|
1188
|
+
}
|
|
1189
|
+
return name || "unnamed-test";
|
|
1190
|
+
}
|
|
1191
|
+
function copyArtifacts(attachments, testTitle, retryCount, outputDir) {
|
|
1192
|
+
const screenshot = attachments.find(
|
|
1193
|
+
(a) => a.name === "screenshot" && a.path
|
|
1194
|
+
);
|
|
1195
|
+
const video = attachments.find(
|
|
1196
|
+
(a) => a.name === "video" && a.path
|
|
1197
|
+
);
|
|
1198
|
+
if (!screenshot && !video) {
|
|
1199
|
+
return null;
|
|
1200
|
+
}
|
|
1201
|
+
let folderName = sanitizeFolderName(testTitle);
|
|
1202
|
+
if (retryCount > 0) {
|
|
1203
|
+
folderName += `--retry-${retryCount}`;
|
|
1204
|
+
}
|
|
1205
|
+
const artifactDir = join(outputDir, "artifacts", folderName);
|
|
1206
|
+
const result = {};
|
|
1207
|
+
try {
|
|
1208
|
+
mkdirSync2(artifactDir, { recursive: true });
|
|
1209
|
+
} catch {
|
|
1210
|
+
return null;
|
|
1211
|
+
}
|
|
1212
|
+
if (screenshot?.path) {
|
|
1213
|
+
try {
|
|
1214
|
+
if (existsSync(screenshot.path)) {
|
|
1215
|
+
const ext = extname(screenshot.path) || ".png";
|
|
1216
|
+
const destName = `screenshot${ext}`;
|
|
1217
|
+
copyFileSync(screenshot.path, join(artifactDir, destName));
|
|
1218
|
+
result.screenshot = `artifacts/${folderName}/${destName}`;
|
|
1219
|
+
}
|
|
1220
|
+
} catch {
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
if (video?.path) {
|
|
1224
|
+
try {
|
|
1225
|
+
if (existsSync(video.path)) {
|
|
1226
|
+
const ext = extname(video.path) || ".webm";
|
|
1227
|
+
const destName = `video${ext}`;
|
|
1228
|
+
copyFileSync(video.path, join(artifactDir, destName));
|
|
1229
|
+
result.video = `artifacts/${folderName}/${destName}`;
|
|
1230
|
+
}
|
|
1231
|
+
} catch {
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
if (!result.screenshot && !result.video) {
|
|
1235
|
+
return null;
|
|
1236
|
+
}
|
|
1237
|
+
return result;
|
|
1238
|
+
}
|
|
1239
|
+
|
|
512
1240
|
// src/reporter.ts
|
|
1241
|
+
function mapPlaywrightStatus(status) {
|
|
1242
|
+
switch (status) {
|
|
1243
|
+
case "passed":
|
|
1244
|
+
return "passed";
|
|
1245
|
+
case "failed":
|
|
1246
|
+
return "failed";
|
|
1247
|
+
case "timedOut":
|
|
1248
|
+
return "timedout";
|
|
1249
|
+
case "skipped":
|
|
1250
|
+
return "skipped";
|
|
1251
|
+
case "interrupted":
|
|
1252
|
+
return "failed";
|
|
1253
|
+
default:
|
|
1254
|
+
return "failed";
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
function generateTestId(filePath, suiteName, title) {
|
|
1258
|
+
const input = `${filePath}::${suiteName}::${title}`;
|
|
1259
|
+
return createHash("sha256").update(input).digest("hex").substring(0, 16);
|
|
1260
|
+
}
|
|
1261
|
+
function getSuiteName(titlePath) {
|
|
1262
|
+
if (titlePath.length <= 4) return "";
|
|
1263
|
+
return titlePath[titlePath.length - 2];
|
|
1264
|
+
}
|
|
1265
|
+
function getRetryStatus(results) {
|
|
1266
|
+
const passedIndex = results.findIndex((r) => r.status === "passed");
|
|
1267
|
+
return passedIndex > 0 ? `passed on retry ${passedIndex}` : null;
|
|
1268
|
+
}
|
|
1269
|
+
function getTestType(tags, filePath) {
|
|
1270
|
+
const typeOrder = ["e2e", "api", "unit"];
|
|
1271
|
+
for (const type of typeOrder) {
|
|
1272
|
+
if (tags.some((tag) => tag === `@${type}` || tag === type)) {
|
|
1273
|
+
return type;
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
for (const type of typeOrder) {
|
|
1277
|
+
if (filePath.includes(`/${type}/`)) {
|
|
1278
|
+
return type;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
return "unknown";
|
|
1282
|
+
}
|
|
513
1283
|
var TestRelicReporter = class {
|
|
514
1284
|
constructor(options) {
|
|
515
1285
|
this.rootDir = "";
|
|
@@ -533,12 +1303,11 @@ var TestRelicReporter = class {
|
|
|
533
1303
|
let status;
|
|
534
1304
|
if (outcome === "flaky") {
|
|
535
1305
|
status = "flaky";
|
|
536
|
-
} else if (
|
|
537
|
-
status = "
|
|
1306
|
+
} else if (outcome === "skipped") {
|
|
1307
|
+
status = "skipped";
|
|
538
1308
|
} else {
|
|
539
|
-
status =
|
|
1309
|
+
status = mapPlaywrightStatus(lastResult.status);
|
|
540
1310
|
}
|
|
541
|
-
if (outcome === "skipped") return;
|
|
542
1311
|
const startedAt = lastResult.startTime.toISOString();
|
|
543
1312
|
const completedAt = new Date(lastResult.startTime.getTime() + lastResult.duration).toISOString();
|
|
544
1313
|
const tags = test.tags ? [...test.tags] : test.annotations.filter((a) => a.type === "tag").map((a) => a.description ?? "");
|
|
@@ -549,6 +1318,16 @@ var TestRelicReporter = class {
|
|
|
549
1318
|
return null;
|
|
550
1319
|
}
|
|
551
1320
|
}).filter((n) => n !== null);
|
|
1321
|
+
let networkRequests = null;
|
|
1322
|
+
const networkReqAnnotation = test.annotations.find(
|
|
1323
|
+
(a) => a.type === "__testrelic_network_requests" && a.description
|
|
1324
|
+
);
|
|
1325
|
+
if (networkReqAnnotation) {
|
|
1326
|
+
try {
|
|
1327
|
+
networkRequests = JSON.parse(networkReqAnnotation.description);
|
|
1328
|
+
} catch {
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
552
1331
|
let failure = null;
|
|
553
1332
|
if (status === "failed" || status === "flaky") {
|
|
554
1333
|
const errors = status === "flaky" ? test.results.find((r) => r.status !== "passed")?.errors ?? [] : lastResult.errors;
|
|
@@ -575,9 +1354,24 @@ var TestRelicReporter = class {
|
|
|
575
1354
|
}
|
|
576
1355
|
const titlePath = test.titlePath().filter(Boolean);
|
|
577
1356
|
const specFile = relative(this.rootDir || ".", test.location.file);
|
|
1357
|
+
const suiteName = getSuiteName(titlePath);
|
|
1358
|
+
const title = titlePath.join(" > ");
|
|
1359
|
+
const filePath = specFile;
|
|
1360
|
+
const testId = generateTestId(filePath, suiteName, title);
|
|
1361
|
+
const testType = getTestType(tags, filePath);
|
|
1362
|
+
const isFlaky = outcome === "flaky";
|
|
1363
|
+
const retryStatus = getRetryStatus(test.results);
|
|
1364
|
+
const expectedStatus = mapPlaywrightStatus(test.expectedStatus);
|
|
1365
|
+
const actualStatus = mapPlaywrightStatus(lastResult.status);
|
|
1366
|
+
let artifacts = null;
|
|
1367
|
+
if (this.config.includeArtifacts && status !== "skipped" && lastResult.attachments) {
|
|
1368
|
+
const outputDir = dirname2(this.config.outputPath);
|
|
1369
|
+
const lastTitle = titlePath[titlePath.length - 1] ?? test.title;
|
|
1370
|
+
artifacts = copyArtifacts(lastResult.attachments, lastTitle, lastResult.retry, outputDir);
|
|
1371
|
+
}
|
|
578
1372
|
this.collectedTests.push({
|
|
579
1373
|
titlePath,
|
|
580
|
-
title
|
|
1374
|
+
title,
|
|
581
1375
|
status,
|
|
582
1376
|
duration: lastResult.duration,
|
|
583
1377
|
startedAt,
|
|
@@ -586,7 +1380,17 @@ var TestRelicReporter = class {
|
|
|
586
1380
|
tags,
|
|
587
1381
|
failure,
|
|
588
1382
|
specFile,
|
|
589
|
-
navigations
|
|
1383
|
+
navigations,
|
|
1384
|
+
testId,
|
|
1385
|
+
filePath,
|
|
1386
|
+
suiteName,
|
|
1387
|
+
testType,
|
|
1388
|
+
isFlaky,
|
|
1389
|
+
retryStatus,
|
|
1390
|
+
expectedStatus,
|
|
1391
|
+
actualStatus,
|
|
1392
|
+
artifacts,
|
|
1393
|
+
networkRequests
|
|
590
1394
|
});
|
|
591
1395
|
} catch {
|
|
592
1396
|
}
|
|
@@ -666,6 +1470,7 @@ var TestRelicReporter = class {
|
|
|
666
1470
|
let failed = 0;
|
|
667
1471
|
let flaky = 0;
|
|
668
1472
|
let skipped = 0;
|
|
1473
|
+
let timedout = 0;
|
|
669
1474
|
for (const test of this.collectedTests) {
|
|
670
1475
|
switch (test.status) {
|
|
671
1476
|
case "passed":
|
|
@@ -677,6 +1482,12 @@ var TestRelicReporter = class {
|
|
|
677
1482
|
case "flaky":
|
|
678
1483
|
flaky++;
|
|
679
1484
|
break;
|
|
1485
|
+
case "skipped":
|
|
1486
|
+
skipped++;
|
|
1487
|
+
break;
|
|
1488
|
+
case "timedout":
|
|
1489
|
+
timedout++;
|
|
1490
|
+
break;
|
|
680
1491
|
}
|
|
681
1492
|
}
|
|
682
1493
|
return {
|
|
@@ -684,7 +1495,8 @@ var TestRelicReporter = class {
|
|
|
684
1495
|
passed,
|
|
685
1496
|
failed,
|
|
686
1497
|
flaky,
|
|
687
|
-
skipped
|
|
1498
|
+
skipped,
|
|
1499
|
+
timedout
|
|
688
1500
|
};
|
|
689
1501
|
}
|
|
690
1502
|
toTestResult(test) {
|
|
@@ -696,7 +1508,17 @@ var TestRelicReporter = class {
|
|
|
696
1508
|
completedAt: test.completedAt,
|
|
697
1509
|
retryCount: test.retryCount,
|
|
698
1510
|
tags: test.tags,
|
|
699
|
-
failure: test.failure
|
|
1511
|
+
failure: test.failure,
|
|
1512
|
+
testId: test.testId,
|
|
1513
|
+
filePath: test.filePath,
|
|
1514
|
+
suiteName: test.suiteName,
|
|
1515
|
+
testType: test.testType,
|
|
1516
|
+
isFlaky: test.isFlaky,
|
|
1517
|
+
retryStatus: test.retryStatus,
|
|
1518
|
+
expectedStatus: test.expectedStatus,
|
|
1519
|
+
actualStatus: test.actualStatus,
|
|
1520
|
+
artifacts: test.artifacts,
|
|
1521
|
+
networkRequests: test.networkRequests
|
|
700
1522
|
};
|
|
701
1523
|
}
|
|
702
1524
|
writeReport(report) {
|
|
@@ -704,7 +1526,7 @@ var TestRelicReporter = class {
|
|
|
704
1526
|
const json = JSON.stringify(report, null, 2);
|
|
705
1527
|
const outputPath = this.config.outputPath;
|
|
706
1528
|
const dir = dirname2(outputPath);
|
|
707
|
-
|
|
1529
|
+
mkdirSync3(dir, { recursive: true });
|
|
708
1530
|
const tmpPath = outputPath + ".tmp";
|
|
709
1531
|
writeFileSync2(tmpPath, json, "utf-8");
|
|
710
1532
|
renameSync2(tmpPath, outputPath);
|