@checkly/playwright-core 1.42.12 → 1.42.13

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.
Files changed (89) hide show
  1. package/lib/checkly/sWatcher.js +150 -0
  2. package/lib/cli/cli.js +62 -0
  3. package/lib/client/channelOwner.js +1 -1
  4. package/lib/client/fetch.js +9 -5
  5. package/lib/common/debugLogger.js +91 -0
  6. package/lib/generated/consoleApiSource.js +2 -1
  7. package/lib/generated/injectedScriptSource.js +2 -1
  8. package/lib/generated/recorderSource.js +2 -1
  9. package/lib/generated/utilityScriptSource.js +2 -1
  10. package/lib/vite/recorder/assets/codeMirrorModule-XkYKvQWL.js +15585 -0
  11. package/lib/vite/recorder/assets/codeMirrorModule-svF_VrcJ.css +344 -0
  12. package/lib/vite/recorder/assets/index-Sgxgm22s.css +2455 -0
  13. package/lib/vite/recorder/assets/index-g7JXfYxX.js +10429 -0
  14. package/lib/vite/recorder/index.html +2 -2
  15. package/lib/vite/traceViewer/assets/{codeMirrorModule-Vg1kIqMp.js → codeMirrorModule-0bpaqixv.js} +10 -10
  16. package/lib/vite/traceViewer/assets/codeMirrorModule-5nkjDDU_.js +15578 -0
  17. package/lib/vite/traceViewer/assets/codeMirrorModule-75b0ca4f.js +24 -0
  18. package/lib/vite/traceViewer/assets/codeMirrorModule-RVP_AMUu.js +15585 -0
  19. package/lib/vite/{recorder/assets/codeMirrorModule-I9ks4y7D.js → traceViewer/assets/codeMirrorModule-c1454a2e.js} +10 -10
  20. package/lib/vite/traceViewer/assets/codeMirrorModule-cc2329e4.js +15593 -0
  21. package/lib/vite/traceViewer/assets/codeMirrorModule-d725feea.js +15586 -0
  22. package/lib/vite/traceViewer/assets/{codeMirrorModule-wLpsbIhd.js → codeMirrorModule-e5a15eec.js} +13 -13
  23. package/lib/vite/traceViewer/assets/codeMirrorModule-kT-uS7F4.js +15592 -0
  24. package/lib/vite/traceViewer/assets/codeMirrorModule-rcsC5no8.js +15592 -0
  25. package/lib/vite/traceViewer/assets/codeMirrorModule-yboVpgC0.js +15592 -0
  26. package/lib/vite/traceViewer/assets/codeMirrorModule-ytMY1awF.js +15585 -0
  27. package/lib/vite/traceViewer/assets/wsPort-1-6TL4lc.js +18540 -0
  28. package/lib/vite/traceViewer/assets/wsPort-54626118.js +18361 -0
  29. package/lib/vite/traceViewer/assets/wsPort-98e00a94.js +64 -0
  30. package/lib/vite/traceViewer/assets/wsPort-CAXygIGt.js +18540 -0
  31. package/lib/vite/traceViewer/assets/wsPort-KEbz4l8i.js +18540 -0
  32. package/lib/vite/traceViewer/assets/{wsPort-RIoVGhlT.js → wsPort-_JBDEilC.js} +2 -2
  33. package/lib/vite/traceViewer/assets/wsPort-a88a6a12.js +18361 -0
  34. package/lib/vite/traceViewer/assets/wsPort-cb764cde.js +64 -0
  35. package/lib/vite/traceViewer/assets/wsPort-ee2830d7.js +64 -0
  36. package/lib/vite/traceViewer/assets/wsPort-lTlmZhJd.js +18564 -0
  37. package/lib/vite/traceViewer/assets/wsPort-xpIMLVfx.js +18540 -0
  38. package/lib/vite/traceViewer/assets/wsPort-yM58htfg.js +18360 -0
  39. package/lib/vite/traceViewer/assets/xtermModule-443332e6.js +9 -0
  40. package/lib/vite/traceViewer/assets/xtermModule-60687b6b.js +6410 -0
  41. package/lib/vite/traceViewer/codeMirrorModule.5d0f417c.css +1 -0
  42. package/lib/vite/traceViewer/codeMirrorModule.eb494ea9.css +344 -0
  43. package/lib/vite/traceViewer/codicon.79f233d0.ttf +0 -0
  44. package/lib/vite/traceViewer/index.1a1fe659.css +1 -0
  45. package/lib/vite/traceViewer/index.4a8ee36e.js +2 -0
  46. package/lib/vite/traceViewer/index.55e65778.js +181 -0
  47. package/lib/vite/traceViewer/index.5nqVcfiC.js +180 -0
  48. package/lib/vite/traceViewer/index.742fd3e5.js +181 -0
  49. package/lib/vite/traceViewer/index.76e9f312.css +124 -0
  50. package/lib/vite/traceViewer/index.UNF4A0jZ.js +180 -0
  51. package/lib/vite/traceViewer/index.ZUjC4zt1.js +180 -0
  52. package/lib/vite/traceViewer/index.a265fbdb.js +2 -0
  53. package/lib/vite/traceViewer/index.decad628.js +2 -0
  54. package/lib/vite/traceViewer/index.html +4 -4
  55. package/lib/vite/traceViewer/index.ici1bqta.js +180 -0
  56. package/lib/vite/traceViewer/index.mxOcKqpu.js +180 -0
  57. package/lib/vite/traceViewer/{index.-_8-eHEE.js → index.u51inEcm.js} +1 -1
  58. package/lib/vite/traceViewer/index.zXVxM5ps.js +180 -0
  59. package/lib/vite/traceViewer/sw.bundle.js +7403 -4
  60. package/lib/vite/traceViewer/uiMode.08ab2d90.js +4 -0
  61. package/lib/vite/traceViewer/uiMode.0d0d667b.js +4 -0
  62. package/lib/vite/traceViewer/uiMode.216233d5.js +1484 -0
  63. package/lib/vite/traceViewer/uiMode.2c31018f.css +1324 -0
  64. package/lib/vite/traceViewer/uiMode.468b0309.js +4 -0
  65. package/lib/vite/traceViewer/uiMode.67C8Ij-c.js +1490 -0
  66. package/lib/vite/traceViewer/uiMode.8b41a49d.css +1 -0
  67. package/lib/vite/traceViewer/uiMode.F_k6a2aC.js +1488 -0
  68. package/lib/vite/traceViewer/{uiMode.9CwNsWc6.js → uiMode.Fb0bNA4H.js} +1 -1
  69. package/lib/vite/traceViewer/uiMode.NjZAwD_B.js +1485 -0
  70. package/lib/vite/traceViewer/uiMode.YQRCZjm8.js +1485 -0
  71. package/lib/vite/traceViewer/uiMode.b2068d00.js +1484 -0
  72. package/lib/vite/traceViewer/uiMode.e-PLonGl.js +1490 -0
  73. package/lib/vite/traceViewer/uiMode.fEEgOxJh.js +1490 -0
  74. package/lib/vite/traceViewer/uiMode.html +4 -4
  75. package/lib/vite/traceViewer/uiMode.kvEeWpo2.js +1490 -0
  76. package/lib/vite/traceViewer/uiMode.ljHA9Ynz.js +1490 -0
  77. package/lib/vite/traceViewer/uiMode.ybQP_6Xr.js +10 -0
  78. package/lib/vite/traceViewer/wsPort.997c92cf.css +3513 -0
  79. package/lib/vite/traceViewer/wsPort.9c9a6767.css +1 -0
  80. package/lib/vite/traceViewer/wsPort.Oa05jfrO.css +3513 -0
  81. package/lib/vite/traceViewer/xtermModule.125f4259.css +191 -0
  82. package/lib/vite/traceViewer/xtermModule.6428296b.css +32 -0
  83. package/package.json +1 -1
  84. package/lib/vite/recorder/assets/codeMirrorModule-Hs9-1ZG4.css +0 -1
  85. package/lib/vite/recorder/assets/index-ljsTwXtJ.css +0 -1
  86. package/lib/vite/recorder/assets/index-yg8ypzl6.js +0 -47
  87. package/lib/vite/traceViewer/assets/wsPort-f2dAQL4I.js +0 -69
  88. package/lib/vite/traceViewer/index.qOFdH9Ja.js +0 -2
  89. package/lib/vite/traceViewer/uiMode.iNIhieBM.js +0 -10
@@ -0,0 +1,1490 @@
1
+ import { u as useMeasure, r as reactExports, d as currentTheme, _ as __vitePreload, e as addThemeListener, f as removeThemeListener, j as jsxRuntimeExports, R as React, g as useSetting, c as connect, s as settings, S as SplitView, h as Toolbar, T as ToolbarButton, t as toggleTheme, m as msToString, i as testStatusIcon, k as idForAction, W as Workbench, M as MultiTraceModel, l as TreeView, a as applyTheme, b as reactDomExports } from "./assets/wsPort-1-6TL4lc.js";
2
+ class StringInternPool {
3
+ constructor() {
4
+ this._stringCache = /* @__PURE__ */ new Map();
5
+ }
6
+ internString(s) {
7
+ let result = this._stringCache.get(s);
8
+ if (!result) {
9
+ this._stringCache.set(s, s);
10
+ result = s;
11
+ }
12
+ return result;
13
+ }
14
+ }
15
+ var define_process_env_default = {};
16
+ class TeleReporterReceiver {
17
+ constructor(pathSeparator2, reporter, reuseTestCases, reportConfig) {
18
+ this._tests = /* @__PURE__ */ new Map();
19
+ this._listOnly = false;
20
+ this._clearPreviousResultsWhenTestBegins = false;
21
+ this._stringPool = new StringInternPool();
22
+ this._rootSuite = new TeleSuite("", "root");
23
+ this._pathSeparator = pathSeparator2;
24
+ this._reporter = reporter;
25
+ this._reuseTestCases = reuseTestCases;
26
+ this._reportConfig = reportConfig;
27
+ }
28
+ dispatch(message) {
29
+ const { method, params } = message;
30
+ if (method === "onConfigure") {
31
+ this._onConfigure(params.config);
32
+ return;
33
+ }
34
+ if (method === "onProject") {
35
+ this._onProject(params.project);
36
+ return;
37
+ }
38
+ if (method === "onBegin") {
39
+ this._onBegin();
40
+ return;
41
+ }
42
+ if (method === "onTestBegin") {
43
+ this._onTestBegin(params.testId, params.result);
44
+ return;
45
+ }
46
+ if (method === "onTestEnd") {
47
+ this._onTestEnd(params.test, params.result);
48
+ return;
49
+ }
50
+ if (method === "onStepBegin") {
51
+ this._onStepBegin(params.testId, params.resultId, params.step);
52
+ return;
53
+ }
54
+ if (method === "onStepEnd") {
55
+ this._onStepEnd(params.testId, params.resultId, params.step);
56
+ return;
57
+ }
58
+ if (method === "onError") {
59
+ this._onError(params.error);
60
+ return;
61
+ }
62
+ if (method === "onStdIO") {
63
+ this._onStdIO(params.type, params.testId, params.resultId, params.data, params.isBase64);
64
+ return;
65
+ }
66
+ if (method === "onEnd")
67
+ return this._onEnd(params.result);
68
+ if (method === "onExit")
69
+ return this._onExit();
70
+ }
71
+ _setClearPreviousResultsWhenTestBegins() {
72
+ this._clearPreviousResultsWhenTestBegins = true;
73
+ }
74
+ _onConfigure(config) {
75
+ var _a, _b;
76
+ this._rootDir = config.rootDir;
77
+ this._listOnly = config.listOnly;
78
+ this._config = this._parseConfig(config);
79
+ (_b = (_a = this._reporter).onConfigure) == null ? void 0 : _b.call(_a, this._config);
80
+ }
81
+ _onProject(project) {
82
+ let projectSuite = this._rootSuite.suites.find((suite) => suite.project().__projectId === project.id);
83
+ if (!projectSuite) {
84
+ projectSuite = new TeleSuite(project.name, "project");
85
+ this._rootSuite.suites.push(projectSuite);
86
+ projectSuite.parent = this._rootSuite;
87
+ }
88
+ projectSuite._project = this._parseProject(project);
89
+ this._mergeSuitesInto(project.suites, projectSuite);
90
+ if (this._listOnly) {
91
+ const testIds = /* @__PURE__ */ new Set();
92
+ const collectIds = (suite) => {
93
+ suite.tests.map((t) => t.testId).forEach((testId) => testIds.add(testId));
94
+ suite.suites.forEach(collectIds);
95
+ };
96
+ project.suites.forEach(collectIds);
97
+ const filterTests = (suite) => {
98
+ suite.tests = suite.tests.filter((t) => testIds.has(t.id));
99
+ suite.suites.forEach(filterTests);
100
+ };
101
+ filterTests(projectSuite);
102
+ }
103
+ }
104
+ _onBegin() {
105
+ var _a, _b;
106
+ (_b = (_a = this._reporter).onBegin) == null ? void 0 : _b.call(_a, this._rootSuite);
107
+ }
108
+ _onTestBegin(testId, payload) {
109
+ var _a, _b;
110
+ const test = this._tests.get(testId);
111
+ if (this._clearPreviousResultsWhenTestBegins)
112
+ test._clearResults();
113
+ const testResult = test._createTestResult(payload.id);
114
+ testResult.retry = payload.retry;
115
+ testResult.workerIndex = payload.workerIndex;
116
+ testResult.parallelIndex = payload.parallelIndex;
117
+ testResult.setStartTimeNumber(payload.startTime);
118
+ testResult.statusEx = "running";
119
+ (_b = (_a = this._reporter).onTestBegin) == null ? void 0 : _b.call(_a, test, testResult);
120
+ }
121
+ _onTestEnd(testEndPayload, payload) {
122
+ var _a, _b, _c;
123
+ const test = this._tests.get(testEndPayload.testId);
124
+ test.timeout = testEndPayload.timeout;
125
+ test.expectedStatus = testEndPayload.expectedStatus;
126
+ test.annotations = testEndPayload.annotations;
127
+ const result = test.resultsMap.get(payload.id);
128
+ result.duration = payload.duration;
129
+ result.status = payload.status;
130
+ result.statusEx = payload.status;
131
+ result.errors = payload.errors;
132
+ result.error = (_a = result.errors) == null ? void 0 : _a[0];
133
+ result.attachments = this._parseAttachments(payload.attachments);
134
+ (_c = (_b = this._reporter).onTestEnd) == null ? void 0 : _c.call(_b, test, result);
135
+ result.stepMap = /* @__PURE__ */ new Map();
136
+ }
137
+ _onStepBegin(testId, resultId, payload) {
138
+ var _a, _b;
139
+ const test = this._tests.get(testId);
140
+ const result = test.resultsMap.get(resultId);
141
+ const parentStep = payload.parentStepId ? result.stepMap.get(payload.parentStepId) : void 0;
142
+ const location = this._absoluteLocation(payload.location);
143
+ const step = new TeleTestStep(payload, parentStep, location);
144
+ if (parentStep)
145
+ parentStep.steps.push(step);
146
+ else
147
+ result.steps.push(step);
148
+ result.stepMap.set(payload.id, step);
149
+ (_b = (_a = this._reporter).onStepBegin) == null ? void 0 : _b.call(_a, test, result, step);
150
+ }
151
+ _onStepEnd(testId, resultId, payload) {
152
+ var _a, _b;
153
+ const test = this._tests.get(testId);
154
+ const result = test.resultsMap.get(resultId);
155
+ const step = result.stepMap.get(payload.id);
156
+ step.duration = payload.duration;
157
+ step.error = payload.error;
158
+ (_b = (_a = this._reporter).onStepEnd) == null ? void 0 : _b.call(_a, test, result, step);
159
+ }
160
+ _onError(error) {
161
+ var _a, _b;
162
+ (_b = (_a = this._reporter).onError) == null ? void 0 : _b.call(_a, error);
163
+ }
164
+ _onStdIO(type, testId, resultId, data, isBase64) {
165
+ var _a, _b, _c, _d;
166
+ const chunk = isBase64 ? globalThis.Buffer ? Buffer.from(data, "base64") : atob(data) : data;
167
+ const test = testId ? this._tests.get(testId) : void 0;
168
+ const result = test && resultId ? test.resultsMap.get(resultId) : void 0;
169
+ if (type === "stdout") {
170
+ result == null ? void 0 : result.stdout.push(chunk);
171
+ (_b = (_a = this._reporter).onStdOut) == null ? void 0 : _b.call(_a, chunk, test, result);
172
+ } else {
173
+ result == null ? void 0 : result.stderr.push(chunk);
174
+ (_d = (_c = this._reporter).onStdErr) == null ? void 0 : _d.call(_c, chunk, test, result);
175
+ }
176
+ }
177
+ async _onEnd(result) {
178
+ var _a, _b;
179
+ await ((_b = (_a = this._reporter).onEnd) == null ? void 0 : _b.call(_a, {
180
+ status: result.status,
181
+ startTime: new Date(result.startTime),
182
+ duration: result.duration
183
+ }));
184
+ }
185
+ _onExit() {
186
+ var _a, _b;
187
+ this._stringPool = new StringInternPool();
188
+ return (_b = (_a = this._reporter).onExit) == null ? void 0 : _b.call(_a);
189
+ }
190
+ _parseConfig(config) {
191
+ const result = { ...baseFullConfig, ...config };
192
+ if (this._reportConfig) {
193
+ result.configFile = this._reportConfig.configFile;
194
+ result.reportSlowTests = this._reportConfig.reportSlowTests;
195
+ result.quiet = this._reportConfig.quiet;
196
+ result.reporter = [...this._reportConfig.reporter];
197
+ }
198
+ return result;
199
+ }
200
+ _parseProject(project) {
201
+ return {
202
+ __projectId: project.id,
203
+ metadata: project.metadata,
204
+ name: project.name,
205
+ outputDir: this._absolutePath(project.outputDir),
206
+ repeatEach: project.repeatEach,
207
+ retries: project.retries,
208
+ testDir: this._absolutePath(project.testDir),
209
+ testIgnore: parseRegexPatterns(project.testIgnore),
210
+ testMatch: parseRegexPatterns(project.testMatch),
211
+ timeout: project.timeout,
212
+ grep: parseRegexPatterns(project.grep),
213
+ grepInvert: parseRegexPatterns(project.grepInvert),
214
+ dependencies: project.dependencies,
215
+ teardown: project.teardown,
216
+ snapshotDir: this._absolutePath(project.snapshotDir),
217
+ use: {}
218
+ };
219
+ }
220
+ _parseAttachments(attachments) {
221
+ return attachments.map((a) => {
222
+ return {
223
+ ...a,
224
+ body: a.base64 && globalThis.Buffer ? Buffer.from(a.base64, "base64") : void 0
225
+ };
226
+ });
227
+ }
228
+ _mergeSuitesInto(jsonSuites, parent) {
229
+ for (const jsonSuite of jsonSuites) {
230
+ let targetSuite = parent.suites.find((s) => s.title === jsonSuite.title);
231
+ if (!targetSuite) {
232
+ targetSuite = new TeleSuite(jsonSuite.title, jsonSuite.type);
233
+ targetSuite.parent = parent;
234
+ parent.suites.push(targetSuite);
235
+ }
236
+ targetSuite.location = this._absoluteLocation(jsonSuite.location);
237
+ targetSuite._fileId = jsonSuite.fileId;
238
+ targetSuite._parallelMode = jsonSuite.parallelMode;
239
+ this._mergeSuitesInto(jsonSuite.suites, targetSuite);
240
+ this._mergeTestsInto(jsonSuite.tests, targetSuite);
241
+ }
242
+ }
243
+ _mergeTestsInto(jsonTests, parent) {
244
+ for (const jsonTest of jsonTests) {
245
+ let targetTest = this._reuseTestCases ? parent.tests.find((s) => s.title === jsonTest.title) : void 0;
246
+ if (!targetTest) {
247
+ targetTest = new TeleTestCase(jsonTest.testId, jsonTest.title, this._absoluteLocation(jsonTest.location));
248
+ targetTest.parent = parent;
249
+ parent.tests.push(targetTest);
250
+ this._tests.set(targetTest.id, targetTest);
251
+ }
252
+ this._updateTest(jsonTest, targetTest);
253
+ }
254
+ }
255
+ _updateTest(payload, test) {
256
+ test.id = payload.testId;
257
+ test.location = this._absoluteLocation(payload.location);
258
+ test.retries = payload.retries;
259
+ test.tags = payload.tags ?? [];
260
+ return test;
261
+ }
262
+ _absoluteLocation(location) {
263
+ if (!location)
264
+ return location;
265
+ return {
266
+ ...location,
267
+ file: this._absolutePath(location.file)
268
+ };
269
+ }
270
+ _absolutePath(relativePath) {
271
+ if (!relativePath)
272
+ return relativePath;
273
+ return this._stringPool.internString(this._rootDir + this._pathSeparator + relativePath);
274
+ }
275
+ }
276
+ class TeleSuite {
277
+ constructor(title, type) {
278
+ this._requireFile = "";
279
+ this.suites = [];
280
+ this.tests = [];
281
+ this._parallelMode = "none";
282
+ this.title = title;
283
+ this._type = type;
284
+ }
285
+ allTests() {
286
+ const result = [];
287
+ const visit = (suite) => {
288
+ for (const entry of [...suite.suites, ...suite.tests]) {
289
+ if (entry instanceof TeleSuite)
290
+ visit(entry);
291
+ else
292
+ result.push(entry);
293
+ }
294
+ };
295
+ visit(this);
296
+ return result;
297
+ }
298
+ titlePath() {
299
+ const titlePath = this.parent ? this.parent.titlePath() : [];
300
+ if (this.title || this._type !== "describe")
301
+ titlePath.push(this.title);
302
+ return titlePath;
303
+ }
304
+ project() {
305
+ var _a;
306
+ return this._project ?? ((_a = this.parent) == null ? void 0 : _a.project());
307
+ }
308
+ }
309
+ class TeleTestCase {
310
+ constructor(id, title, location) {
311
+ this.fn = () => {
312
+ };
313
+ this.results = [];
314
+ this.expectedStatus = "passed";
315
+ this.timeout = 0;
316
+ this.annotations = [];
317
+ this.retries = 0;
318
+ this.tags = [];
319
+ this.repeatEachIndex = 0;
320
+ this.resultsMap = /* @__PURE__ */ new Map();
321
+ this.id = id;
322
+ this.title = title;
323
+ this.location = location;
324
+ }
325
+ titlePath() {
326
+ const titlePath = this.parent ? this.parent.titlePath() : [];
327
+ titlePath.push(this.title);
328
+ return titlePath;
329
+ }
330
+ outcome() {
331
+ var _a, _b;
332
+ const results = [...this.results];
333
+ while (((_a = results[0]) == null ? void 0 : _a.status) === "skipped" || ((_b = results[0]) == null ? void 0 : _b.status) === "interrupted")
334
+ results.shift();
335
+ if (!results.length)
336
+ return "skipped";
337
+ const failures = results.filter((result) => result.status !== "skipped" && result.status !== "interrupted" && result.status !== this.expectedStatus);
338
+ if (!failures.length)
339
+ return "expected";
340
+ if (failures.length === results.length)
341
+ return "unexpected";
342
+ return "flaky";
343
+ }
344
+ ok() {
345
+ const status = this.outcome();
346
+ return status === "expected" || status === "flaky" || status === "skipped";
347
+ }
348
+ _clearResults() {
349
+ this.results = [];
350
+ this.resultsMap.clear();
351
+ }
352
+ _createTestResult(id) {
353
+ const result = new TeleTestResult(this.results.length);
354
+ this.results.push(result);
355
+ this.resultsMap.set(id, result);
356
+ return result;
357
+ }
358
+ }
359
+ class TeleTestStep {
360
+ constructor(payload, parentStep, location) {
361
+ this.duration = -1;
362
+ this.steps = [];
363
+ this._startTime = 0;
364
+ this.title = payload.title;
365
+ this.category = payload.category;
366
+ this.location = location;
367
+ this.parent = parentStep;
368
+ this._startTime = payload.startTime;
369
+ }
370
+ titlePath() {
371
+ var _a;
372
+ const parentPath = ((_a = this.parent) == null ? void 0 : _a.titlePath()) || [];
373
+ return [...parentPath, this.title];
374
+ }
375
+ get startTime() {
376
+ return new Date(this._startTime);
377
+ }
378
+ set startTime(value) {
379
+ this._startTime = +value;
380
+ }
381
+ }
382
+ class TeleTestResult {
383
+ constructor(retry) {
384
+ this.parallelIndex = -1;
385
+ this.workerIndex = -1;
386
+ this.duration = -1;
387
+ this.stdout = [];
388
+ this.stderr = [];
389
+ this.attachments = [];
390
+ this.status = "skipped";
391
+ this.steps = [];
392
+ this.errors = [];
393
+ this.stepMap = /* @__PURE__ */ new Map();
394
+ this.statusEx = "scheduled";
395
+ this._startTime = 0;
396
+ this.retry = retry;
397
+ }
398
+ setStartTimeNumber(startTime) {
399
+ this._startTime = startTime;
400
+ }
401
+ get startTime() {
402
+ return new Date(this._startTime);
403
+ }
404
+ set startTime(value) {
405
+ this._startTime = +value;
406
+ }
407
+ }
408
+ const baseFullConfig = {
409
+ forbidOnly: false,
410
+ fullyParallel: false,
411
+ globalSetup: null,
412
+ globalTeardown: null,
413
+ globalTimeout: 0,
414
+ grep: /.*/,
415
+ grepInvert: null,
416
+ maxFailures: 0,
417
+ metadata: {},
418
+ preserveOutput: "always",
419
+ projects: [],
420
+ reporter: [[define_process_env_default.CI ? "dot" : "list"]],
421
+ reportSlowTests: { max: 5, threshold: 15e3 },
422
+ configFile: "",
423
+ rootDir: "",
424
+ quiet: false,
425
+ shard: null,
426
+ updateSnapshots: "missing",
427
+ version: "",
428
+ workers: 0,
429
+ webServer: null
430
+ };
431
+ function parseRegexPatterns(patterns) {
432
+ return patterns.map((p) => {
433
+ if (p.s)
434
+ return p.s;
435
+ return new RegExp(p.r.source, p.r.flags);
436
+ });
437
+ }
438
+ const XtermWrapper = ({
439
+ source
440
+ }) => {
441
+ const [measure, xtermElement] = useMeasure();
442
+ const [theme, setTheme] = reactExports.useState(currentTheme());
443
+ const [modulePromise] = reactExports.useState(__vitePreload(() => import("./assets/xtermModule-_6TC5FYT.js"), true ? __vite__mapDeps([0,1]) : void 0, import.meta.url).then((m) => m.default));
444
+ const terminal = reactExports.useRef(null);
445
+ reactExports.useEffect(() => {
446
+ addThemeListener(setTheme);
447
+ return () => removeThemeListener(setTheme);
448
+ }, []);
449
+ reactExports.useEffect(() => {
450
+ const oldSourceWrite = source.write;
451
+ const oldSourceClear = source.clear;
452
+ (async () => {
453
+ const { Terminal, FitAddon } = await modulePromise;
454
+ const element = xtermElement.current;
455
+ if (!element)
456
+ return;
457
+ const terminalTheme = theme === "dark-mode" ? darkTheme : lightTheme;
458
+ if (terminal.current && terminal.current.terminal.options.theme === terminalTheme)
459
+ return;
460
+ if (terminal.current)
461
+ element.textContent = "";
462
+ const newTerminal = new Terminal({
463
+ convertEol: true,
464
+ fontSize: 13,
465
+ scrollback: 1e4,
466
+ fontFamily: "var(--vscode-editor-font-family)",
467
+ theme: terminalTheme
468
+ });
469
+ const fitAddon = new FitAddon();
470
+ newTerminal.loadAddon(fitAddon);
471
+ for (const p of source.pending)
472
+ newTerminal.write(p);
473
+ source.write = (data) => {
474
+ source.pending.push(data);
475
+ newTerminal.write(data);
476
+ };
477
+ source.clear = () => {
478
+ source.pending = [];
479
+ newTerminal.clear();
480
+ };
481
+ newTerminal.open(element);
482
+ fitAddon.fit();
483
+ terminal.current = { terminal: newTerminal, fitAddon };
484
+ })();
485
+ return () => {
486
+ source.clear = oldSourceClear;
487
+ source.write = oldSourceWrite;
488
+ };
489
+ }, [modulePromise, terminal, xtermElement, source, theme]);
490
+ reactExports.useEffect(() => {
491
+ setTimeout(() => {
492
+ if (!terminal.current)
493
+ return;
494
+ terminal.current.fitAddon.fit();
495
+ source.resize(terminal.current.terminal.cols, terminal.current.terminal.rows);
496
+ }, 250);
497
+ }, [measure, source]);
498
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-testid": "output", className: "xterm-wrapper", style: { flex: "auto" }, ref: xtermElement });
499
+ };
500
+ const lightTheme = {
501
+ foreground: "#383a42",
502
+ background: "#fafafa",
503
+ cursor: "#383a42",
504
+ black: "#000000",
505
+ red: "#e45649",
506
+ green: "#50a14f",
507
+ yellow: "#c18401",
508
+ blue: "#4078f2",
509
+ magenta: "#a626a4",
510
+ cyan: "#0184bc",
511
+ white: "#a0a0a0",
512
+ brightBlack: "#000000",
513
+ brightRed: "#e06c75",
514
+ brightGreen: "#98c379",
515
+ brightYellow: "#d19a66",
516
+ brightBlue: "#4078f2",
517
+ brightMagenta: "#a626a4",
518
+ brightCyan: "#0184bc",
519
+ brightWhite: "#383a42",
520
+ selectionBackground: "#d7d7d7",
521
+ selectionForeground: "#383a42"
522
+ };
523
+ const darkTheme = {
524
+ foreground: "#f8f8f2",
525
+ background: "#1e1e1e",
526
+ cursor: "#f8f8f0",
527
+ black: "#000000",
528
+ red: "#ff5555",
529
+ green: "#50fa7b",
530
+ yellow: "#f1fa8c",
531
+ blue: "#bd93f9",
532
+ magenta: "#ff79c6",
533
+ cyan: "#8be9fd",
534
+ white: "#bfbfbf",
535
+ brightBlack: "#4d4d4d",
536
+ brightRed: "#ff6e6e",
537
+ brightGreen: "#69ff94",
538
+ brightYellow: "#ffffa5",
539
+ brightBlue: "#d6acff",
540
+ brightMagenta: "#ff92df",
541
+ brightCyan: "#a4ffff",
542
+ brightWhite: "#e6e6e6",
543
+ selectionBackground: "#44475a",
544
+ selectionForeground: "#f8f8f2"
545
+ };
546
+ const Expandable = ({ title, children, setExpanded, expanded, expandOnTitleClick }) => {
547
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "expandable" + (expanded ? " expanded" : ""), children: [
548
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "expandable-title", onClick: () => expandOnTitleClick && setExpanded(!expanded), children: [
549
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
550
+ "div",
551
+ {
552
+ className: "codicon codicon-" + (expanded ? "chevron-down" : "chevron-right"),
553
+ style: { cursor: "pointer", color: "var(--vscode-foreground)", marginLeft: "5px" },
554
+ onClick: () => !expandOnTitleClick && setExpanded(!expanded)
555
+ }
556
+ ),
557
+ title
558
+ ] }),
559
+ expanded && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { marginLeft: 25 }, children })
560
+ ] });
561
+ };
562
+ function artifactsFolderName(workerIndex) {
563
+ return `.playwright-artifacts-${workerIndex}`;
564
+ }
565
+ let updateRootSuite = () => {
566
+ };
567
+ let runWatchedTests = (fileNames) => {
568
+ };
569
+ let xtermSize = { cols: 80, rows: 24 };
570
+ let sendMessage = async () => {
571
+ };
572
+ const xtermDataSource = {
573
+ pending: [],
574
+ clear: () => {
575
+ },
576
+ write: (data) => xtermDataSource.pending.push(data),
577
+ resize: (cols, rows) => {
578
+ xtermSize = { cols, rows };
579
+ sendMessageNoReply("resizeTerminal", { cols, rows });
580
+ }
581
+ };
582
+ const UIModeView = ({}) => {
583
+ var _a;
584
+ const [filterText, setFilterText] = React.useState("");
585
+ const [isShowingOutput, setIsShowingOutput] = React.useState(false);
586
+ const [statusFilters, setStatusFilters] = React.useState(/* @__PURE__ */ new Map([
587
+ ["passed", false],
588
+ ["failed", false],
589
+ ["skipped", false]
590
+ ]));
591
+ const [projectFilters, setProjectFilters] = React.useState(/* @__PURE__ */ new Map());
592
+ const [testModel, setTestModel] = React.useState({ config: void 0, rootSuite: void 0, loadErrors: [] });
593
+ const [progress, setProgress] = React.useState();
594
+ const [selectedItem, setSelectedItem] = React.useState({});
595
+ const [visibleTestIds, setVisibleTestIds] = React.useState(/* @__PURE__ */ new Set());
596
+ const [isLoading, setIsLoading] = React.useState(false);
597
+ const [runningState, setRunningState] = React.useState();
598
+ const [watchAll, setWatchAll] = useSetting("watch-all", false);
599
+ const [watchedTreeIds, setWatchedTreeIds] = React.useState({ value: /* @__PURE__ */ new Set() });
600
+ const runTestPromiseChain = React.useRef(Promise.resolve());
601
+ const runTestBacklog = React.useRef(/* @__PURE__ */ new Set());
602
+ const [collapseAllCount, setCollapseAllCount] = React.useState(0);
603
+ const [isDisconnected, setIsDisconnected] = React.useState(false);
604
+ const [hasBrowsers, setHasBrowsers] = React.useState(true);
605
+ const inputRef = React.useRef(null);
606
+ const reloadTests = React.useCallback(() => {
607
+ setIsLoading(true);
608
+ setWatchedTreeIds({ value: /* @__PURE__ */ new Set() });
609
+ updateRootSuite(baseFullConfig, new TeleSuite("", "root"), [], void 0);
610
+ refreshRootSuite(true).then(async () => {
611
+ setIsLoading(false);
612
+ const { hasBrowsers: hasBrowsers2 } = await sendMessage("checkBrowsers");
613
+ setHasBrowsers(hasBrowsers2);
614
+ });
615
+ }, []);
616
+ React.useEffect(() => {
617
+ var _a2;
618
+ (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
619
+ setIsLoading(true);
620
+ connect({ onEvent: dispatchEvent, onClose: () => setIsDisconnected(true) }).then((send) => {
621
+ sendMessage = async (method, params) => {
622
+ const logForTest = window.__logForTest;
623
+ logForTest == null ? void 0 : logForTest({ method, params });
624
+ await send(method, params);
625
+ };
626
+ reloadTests();
627
+ });
628
+ }, [reloadTests]);
629
+ updateRootSuite = React.useCallback((config, rootSuite, loadErrors, newProgress) => {
630
+ const selectedProjects = config.configFile ? settings.getObject(config.configFile + ":projects", void 0) : void 0;
631
+ for (const projectName of projectFilters.keys()) {
632
+ if (!rootSuite.suites.find((s) => s.title === projectName))
633
+ projectFilters.delete(projectName);
634
+ }
635
+ for (const projectSuite of rootSuite.suites) {
636
+ if (!projectFilters.has(projectSuite.title))
637
+ projectFilters.set(projectSuite.title, !!(selectedProjects == null ? void 0 : selectedProjects.includes(projectSuite.title)));
638
+ }
639
+ if (!selectedProjects && projectFilters.size && ![...projectFilters.values()].includes(true))
640
+ projectFilters.set(projectFilters.entries().next().value[0], true);
641
+ setTestModel({ config, rootSuite, loadErrors });
642
+ setProjectFilters(new Map(projectFilters));
643
+ if (runningState && newProgress)
644
+ setProgress(newProgress);
645
+ else if (!newProgress)
646
+ setProgress(void 0);
647
+ }, [projectFilters, runningState]);
648
+ const runTests = React.useCallback((mode, testIds) => {
649
+ if (mode === "bounce-if-busy" && runningState)
650
+ return;
651
+ runTestBacklog.current = /* @__PURE__ */ new Set([...runTestBacklog.current, ...testIds]);
652
+ runTestPromiseChain.current = runTestPromiseChain.current.then(async () => {
653
+ var _a2, _b, _c;
654
+ const testIds2 = runTestBacklog.current;
655
+ runTestBacklog.current = /* @__PURE__ */ new Set();
656
+ if (!testIds2.size)
657
+ return;
658
+ {
659
+ for (const test of ((_a2 = testModel.rootSuite) == null ? void 0 : _a2.allTests()) || []) {
660
+ if (testIds2.has(test.id)) {
661
+ test._clearResults();
662
+ test._createTestResult("pending");
663
+ }
664
+ }
665
+ setTestModel({ ...testModel });
666
+ }
667
+ const time = " [" + (/* @__PURE__ */ new Date()).toLocaleTimeString() + "]";
668
+ xtermDataSource.write("\x1B[2m—".repeat(Math.max(0, xtermSize.cols - time.length)) + time + "\x1B[22m");
669
+ setProgress({ total: 0, passed: 0, failed: 0, skipped: 0 });
670
+ setRunningState({ testIds: testIds2 });
671
+ await sendMessage("run", { testIds: [...testIds2], projects: [...projectFilters].filter(([_, v]) => v).map(([p]) => p) });
672
+ for (const test of ((_b = testModel.rootSuite) == null ? void 0 : _b.allTests()) || []) {
673
+ if (((_c = test.results[0]) == null ? void 0 : _c.duration) === -1)
674
+ test._clearResults();
675
+ }
676
+ setTestModel({ ...testModel });
677
+ setRunningState(void 0);
678
+ });
679
+ }, [projectFilters, runningState, testModel]);
680
+ const isRunningTest = !!runningState;
681
+ const dialogRef = React.useRef(null);
682
+ const openInstallDialog = React.useCallback((e) => {
683
+ var _a2;
684
+ e.preventDefault();
685
+ e.stopPropagation();
686
+ (_a2 = dialogRef.current) == null ? void 0 : _a2.showModal();
687
+ }, []);
688
+ const closeInstallDialog = React.useCallback((e) => {
689
+ var _a2;
690
+ e.preventDefault();
691
+ e.stopPropagation();
692
+ (_a2 = dialogRef.current) == null ? void 0 : _a2.close();
693
+ }, []);
694
+ const installBrowsers = React.useCallback((e) => {
695
+ closeInstallDialog(e);
696
+ setIsShowingOutput(true);
697
+ sendMessage("installBrowsers").then(async () => {
698
+ setIsShowingOutput(false);
699
+ const { hasBrowsers: hasBrowsers2 } = await sendMessage("checkBrowsers");
700
+ setHasBrowsers(hasBrowsers2);
701
+ });
702
+ }, [closeInstallDialog]);
703
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "vbox ui-mode", children: [
704
+ !hasBrowsers && /* @__PURE__ */ jsxRuntimeExports.jsxs("dialog", { ref: dialogRef, children: [
705
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "title", children: [
706
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "codicon codicon-lightbulb" }),
707
+ "Install browsers"
708
+ ] }),
709
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "body", children: [
710
+ "Playwright did not find installed browsers.",
711
+ /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
712
+ "Would you like to run `playwright install`?",
713
+ /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
714
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "button", onClick: installBrowsers, children: "Install" }),
715
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "button secondary", onClick: closeInstallDialog, children: "Dismiss" })
716
+ ] })
717
+ ] }),
718
+ isDisconnected && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "disconnected", children: [
719
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "title", children: "UI Mode disconnected" }),
720
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
721
+ /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: "#", onClick: () => window.location.href = "/", children: "Reload the page" }),
722
+ " to reconnect"
723
+ ] })
724
+ ] }),
725
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(SplitView, { sidebarSize: 250, minSidebarSize: 150, orientation: "horizontal", sidebarIsFirst: true, settingName: "testListSidebar", children: [
726
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "vbox", children: [
727
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "vbox" + (isShowingOutput ? "" : " hidden"), children: [
728
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Toolbar, { children: [
729
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "section-title", style: { flex: "none" }, children: "Output" }),
730
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ToolbarButton, { icon: "circle-slash", title: "Clear output", onClick: () => xtermDataSource.clear() }),
731
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "spacer" }),
732
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ToolbarButton, { icon: "close", title: "Close", onClick: () => setIsShowingOutput(false) })
733
+ ] }),
734
+ /* @__PURE__ */ jsxRuntimeExports.jsx(XtermWrapper, { source: xtermDataSource })
735
+ ] }),
736
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "vbox" + (isShowingOutput ? " hidden" : ""), children: /* @__PURE__ */ jsxRuntimeExports.jsx(TraceView, { item: selectedItem, rootDir: (_a = testModel.config) == null ? void 0 : _a.rootDir }) })
737
+ ] }),
738
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "vbox ui-mode-sidebar", children: [
739
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Toolbar, { noShadow: true, noMinHeight: true, children: [
740
+ /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: "playwright-logo.svg", alt: "Playwright logo" }),
741
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "section-title", children: "Playwright" }),
742
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ToolbarButton, { icon: "color-mode", title: "Toggle color mode", onClick: () => toggleTheme() }),
743
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ToolbarButton, { icon: "refresh", title: "Reload", onClick: () => reloadTests(), disabled: isRunningTest || isLoading }),
744
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ToolbarButton, { icon: "terminal", title: "Toggle output", toggled: isShowingOutput, onClick: () => {
745
+ setIsShowingOutput(!isShowingOutput);
746
+ } }),
747
+ !hasBrowsers && /* @__PURE__ */ jsxRuntimeExports.jsx(ToolbarButton, { icon: "lightbulb-autofix", style: { color: "var(--vscode-list-warningForeground)" }, title: "Playwright browsers are missing", onClick: openInstallDialog })
748
+ ] }),
749
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
750
+ FiltersView,
751
+ {
752
+ filterText,
753
+ setFilterText,
754
+ statusFilters,
755
+ setStatusFilters,
756
+ projectFilters,
757
+ setProjectFilters,
758
+ testModel,
759
+ runTests: () => runTests("bounce-if-busy", visibleTestIds)
760
+ }
761
+ ),
762
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Toolbar, { noMinHeight: true, children: [
763
+ !isRunningTest && !progress && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "section-title", children: "Tests" }),
764
+ !isRunningTest && progress && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-testid": "status-line", className: "status-line", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
765
+ progress.passed,
766
+ "/",
767
+ progress.total,
768
+ " passed (",
769
+ progress.passed / progress.total * 100 | 0,
770
+ "%)"
771
+ ] }) }),
772
+ isRunningTest && progress && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-testid": "status-line", className: "status-line", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
773
+ "Running ",
774
+ progress.passed,
775
+ "/",
776
+ runningState.testIds.size,
777
+ " passed (",
778
+ progress.passed / runningState.testIds.size * 100 | 0,
779
+ "%)"
780
+ ] }) }),
781
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ToolbarButton, { icon: "play", title: "Run all", onClick: () => runTests("bounce-if-busy", visibleTestIds), disabled: isRunningTest || isLoading }),
782
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ToolbarButton, { icon: "debug-stop", title: "Stop", onClick: () => sendMessageNoReply("stop"), disabled: !isRunningTest || isLoading }),
783
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ToolbarButton, { icon: "eye", title: "Watch all", toggled: watchAll, onClick: () => {
784
+ setWatchedTreeIds({ value: /* @__PURE__ */ new Set() });
785
+ setWatchAll(!watchAll);
786
+ } }),
787
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ToolbarButton, { icon: "collapse-all", title: "Collapse all", onClick: () => {
788
+ setCollapseAllCount(collapseAllCount + 1);
789
+ } })
790
+ ] }),
791
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
792
+ TestList,
793
+ {
794
+ statusFilters,
795
+ projectFilters,
796
+ filterText,
797
+ testModel,
798
+ runningState,
799
+ runTests,
800
+ onItemSelected: setSelectedItem,
801
+ setVisibleTestIds,
802
+ watchAll,
803
+ watchedTreeIds,
804
+ setWatchedTreeIds,
805
+ isLoading,
806
+ requestedCollapseAllCount: collapseAllCount
807
+ }
808
+ )
809
+ ] })
810
+ ] })
811
+ ] });
812
+ };
813
+ const FiltersView = ({ filterText, setFilterText, statusFilters, setStatusFilters, projectFilters, setProjectFilters, testModel, runTests }) => {
814
+ const [expanded, setExpanded] = React.useState(false);
815
+ const inputRef = React.useRef(null);
816
+ React.useEffect(() => {
817
+ var _a;
818
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
819
+ }, []);
820
+ const statusLine = [...statusFilters.entries()].filter(([_, v]) => v).map(([s]) => s).join(" ") || "all";
821
+ const projectsLine = [...projectFilters.entries()].filter(([_, v]) => v).map(([p]) => p).join(" ") || "all";
822
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "filters", children: [
823
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
824
+ Expandable,
825
+ {
826
+ expanded,
827
+ setExpanded,
828
+ title: /* @__PURE__ */ jsxRuntimeExports.jsx(
829
+ "input",
830
+ {
831
+ ref: inputRef,
832
+ type: "search",
833
+ placeholder: "Filter (e.g. text, @tag)",
834
+ spellCheck: false,
835
+ value: filterText,
836
+ onChange: (e) => {
837
+ setFilterText(e.target.value);
838
+ },
839
+ onKeyDown: (e) => {
840
+ if (e.key === "Enter")
841
+ runTests();
842
+ }
843
+ }
844
+ )
845
+ }
846
+ ),
847
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "filter-summary", title: "Status: " + statusLine + "\nProjects: " + projectsLine, onClick: () => setExpanded(!expanded), children: [
848
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "filter-label", children: "Status:" }),
849
+ " ",
850
+ statusLine,
851
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "filter-label", children: "Projects:" }),
852
+ " ",
853
+ projectsLine
854
+ ] }),
855
+ expanded && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "hbox", style: { marginLeft: 14, maxHeight: 200, overflowY: "auto" }, children: [
856
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "filter-list", children: [...statusFilters.entries()].map(([status, value]) => {
857
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "filter-entry", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { children: [
858
+ /* @__PURE__ */ jsxRuntimeExports.jsx("input", { type: "checkbox", checked: value, onClick: () => {
859
+ const copy = new Map(statusFilters);
860
+ copy.set(status, !copy.get(status));
861
+ setStatusFilters(copy);
862
+ } }),
863
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: status })
864
+ ] }) });
865
+ }) }),
866
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "filter-list", children: [...projectFilters.entries()].map(([projectName, value]) => {
867
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "filter-entry", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { children: [
868
+ /* @__PURE__ */ jsxRuntimeExports.jsx("input", { type: "checkbox", checked: value, onClick: () => {
869
+ var _a;
870
+ const copy = new Map(projectFilters);
871
+ copy.set(projectName, !copy.get(projectName));
872
+ setProjectFilters(copy);
873
+ const configFile = (_a = testModel == null ? void 0 : testModel.config) == null ? void 0 : _a.configFile;
874
+ if (configFile)
875
+ settings.setObject(configFile + ":projects", [...copy.entries()].filter(([_, v]) => v).map(([k]) => k));
876
+ } }),
877
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: projectName || "untitled" })
878
+ ] }) });
879
+ }) })
880
+ ] })
881
+ ] });
882
+ };
883
+ const TestTreeView = TreeView;
884
+ const TestList = ({ statusFilters, projectFilters, filterText, testModel, runTests, runningState, watchAll, watchedTreeIds, setWatchedTreeIds, isLoading, onItemSelected, setVisibleTestIds, requestedCollapseAllCount }) => {
885
+ const [treeState, setTreeState] = React.useState({ expandedItems: /* @__PURE__ */ new Map() });
886
+ const [selectedTreeItemId, setSelectedTreeItemId] = React.useState();
887
+ const [collapseAllCount, setCollapseAllCount] = React.useState(requestedCollapseAllCount);
888
+ const { rootItem, treeItemMap, fileNames } = React.useMemo(() => {
889
+ let rootItem2 = createTree(testModel.rootSuite, testModel.loadErrors, projectFilters);
890
+ filterTree(rootItem2, filterText, statusFilters, runningState == null ? void 0 : runningState.testIds);
891
+ sortAndPropagateStatus(rootItem2);
892
+ rootItem2 = shortenRoot(rootItem2);
893
+ hideOnlyTests(rootItem2);
894
+ const treeItemMap2 = /* @__PURE__ */ new Map();
895
+ const visibleTestIds = /* @__PURE__ */ new Set();
896
+ const fileNames2 = /* @__PURE__ */ new Set();
897
+ const visit = (treeItem) => {
898
+ if (treeItem.kind === "group" && treeItem.location.file)
899
+ fileNames2.add(treeItem.location.file);
900
+ if (treeItem.kind === "case")
901
+ treeItem.tests.forEach((t) => visibleTestIds.add(t.id));
902
+ treeItem.children.forEach(visit);
903
+ treeItemMap2.set(treeItem.id, treeItem);
904
+ };
905
+ visit(rootItem2);
906
+ setVisibleTestIds(visibleTestIds);
907
+ return { rootItem: rootItem2, treeItemMap: treeItemMap2, fileNames: fileNames2 };
908
+ }, [filterText, testModel, statusFilters, projectFilters, setVisibleTestIds, runningState]);
909
+ React.useEffect(() => {
910
+ if (collapseAllCount !== requestedCollapseAllCount) {
911
+ treeState.expandedItems.clear();
912
+ for (const item of treeItemMap.keys())
913
+ treeState.expandedItems.set(item, false);
914
+ setCollapseAllCount(requestedCollapseAllCount);
915
+ setSelectedTreeItemId(void 0);
916
+ setTreeState({ ...treeState });
917
+ return;
918
+ }
919
+ if (!runningState || runningState.itemSelectedByUser)
920
+ return;
921
+ let selectedTreeItem2;
922
+ const visit = (treeItem) => {
923
+ var _a;
924
+ treeItem.children.forEach(visit);
925
+ if (selectedTreeItem2)
926
+ return;
927
+ if (treeItem.status === "failed") {
928
+ if (treeItem.kind === "test" && runningState.testIds.has(treeItem.test.id))
929
+ selectedTreeItem2 = treeItem;
930
+ else if (treeItem.kind === "case" && runningState.testIds.has((_a = treeItem.tests[0]) == null ? void 0 : _a.id))
931
+ selectedTreeItem2 = treeItem;
932
+ }
933
+ };
934
+ visit(rootItem);
935
+ if (selectedTreeItem2)
936
+ setSelectedTreeItemId(selectedTreeItem2.id);
937
+ }, [runningState, setSelectedTreeItemId, rootItem, collapseAllCount, setCollapseAllCount, requestedCollapseAllCount, treeState, setTreeState, treeItemMap]);
938
+ const { selectedTreeItem } = React.useMemo(() => {
939
+ const selectedTreeItem2 = selectedTreeItemId ? treeItemMap.get(selectedTreeItemId) : void 0;
940
+ let testFile;
941
+ if (selectedTreeItem2) {
942
+ testFile = {
943
+ file: selectedTreeItem2.location.file,
944
+ line: selectedTreeItem2.location.line,
945
+ source: {
946
+ errors: testModel.loadErrors.filter((e) => {
947
+ var _a;
948
+ return ((_a = e.location) == null ? void 0 : _a.file) === selectedTreeItem2.location.file;
949
+ }).map((e) => ({ line: e.location.line, message: e.message })),
950
+ content: void 0
951
+ }
952
+ };
953
+ }
954
+ let selectedTest;
955
+ if ((selectedTreeItem2 == null ? void 0 : selectedTreeItem2.kind) === "test")
956
+ selectedTest = selectedTreeItem2.test;
957
+ else if ((selectedTreeItem2 == null ? void 0 : selectedTreeItem2.kind) === "case" && selectedTreeItem2.tests.length === 1)
958
+ selectedTest = selectedTreeItem2.tests[0];
959
+ onItemSelected({ treeItem: selectedTreeItem2, testCase: selectedTest, testFile });
960
+ return { selectedTreeItem: selectedTreeItem2 };
961
+ }, [onItemSelected, selectedTreeItemId, testModel, treeItemMap]);
962
+ React.useEffect(() => {
963
+ if (isLoading)
964
+ return;
965
+ if (watchAll) {
966
+ sendMessageNoReply("watch", { fileNames: [...fileNames] });
967
+ } else {
968
+ const fileNames2 = /* @__PURE__ */ new Set();
969
+ for (const itemId of watchedTreeIds.value) {
970
+ const treeItem = treeItemMap.get(itemId);
971
+ const fileName = treeItem == null ? void 0 : treeItem.location.file;
972
+ if (fileName)
973
+ fileNames2.add(fileName);
974
+ }
975
+ sendMessageNoReply("watch", { fileNames: [...fileNames2] });
976
+ }
977
+ }, [isLoading, rootItem, fileNames, watchAll, watchedTreeIds, treeItemMap]);
978
+ const runTreeItem = (treeItem) => {
979
+ setSelectedTreeItemId(treeItem.id);
980
+ runTests("bounce-if-busy", collectTestIds(treeItem));
981
+ };
982
+ runWatchedTests = (changedTestFiles) => {
983
+ const testIds = [];
984
+ const set = new Set(changedTestFiles);
985
+ if (watchAll) {
986
+ const visit = (treeItem) => {
987
+ const fileName = treeItem.location.file;
988
+ if (fileName && set.has(fileName))
989
+ testIds.push(...collectTestIds(treeItem));
990
+ if (treeItem.kind === "group" && treeItem.subKind === "folder")
991
+ treeItem.children.forEach(visit);
992
+ };
993
+ visit(rootItem);
994
+ } else {
995
+ for (const treeId of watchedTreeIds.value) {
996
+ const treeItem = treeItemMap.get(treeId);
997
+ const fileName = treeItem == null ? void 0 : treeItem.location.file;
998
+ if (fileName && set.has(fileName))
999
+ testIds.push(...collectTestIds(treeItem));
1000
+ }
1001
+ }
1002
+ runTests("queue-if-busy", new Set(testIds));
1003
+ };
1004
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
1005
+ TestTreeView,
1006
+ {
1007
+ name: "tests",
1008
+ treeState,
1009
+ setTreeState,
1010
+ rootItem,
1011
+ dataTestId: "test-tree",
1012
+ render: (treeItem) => {
1013
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "hbox ui-mode-list-item", children: [
1014
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ui-mode-list-item-title", title: treeItem.title, children: treeItem.title }),
1015
+ !!treeItem.duration && treeItem.status !== "skipped" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ui-mode-list-item-time", children: msToString(treeItem.duration) }),
1016
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Toolbar, { noMinHeight: true, noShadow: true, children: [
1017
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ToolbarButton, { icon: "play", title: "Run", onClick: () => runTreeItem(treeItem), disabled: !!runningState }),
1018
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ToolbarButton, { icon: "go-to-file", title: "Open in VS Code", onClick: () => sendMessageNoReply("open", { location: locationToOpen(treeItem) }), style: treeItem.kind === "group" && treeItem.subKind === "folder" ? { visibility: "hidden" } : {} }),
1019
+ !watchAll && /* @__PURE__ */ jsxRuntimeExports.jsx(ToolbarButton, { icon: "eye", title: "Watch", onClick: () => {
1020
+ if (watchedTreeIds.value.has(treeItem.id))
1021
+ watchedTreeIds.value.delete(treeItem.id);
1022
+ else
1023
+ watchedTreeIds.value.add(treeItem.id);
1024
+ setWatchedTreeIds({ ...watchedTreeIds });
1025
+ }, toggled: watchedTreeIds.value.has(treeItem.id) })
1026
+ ] })
1027
+ ] });
1028
+ },
1029
+ icon: (treeItem) => testStatusIcon(treeItem.status),
1030
+ selectedItem: selectedTreeItem,
1031
+ onAccepted: runTreeItem,
1032
+ onSelected: (treeItem) => {
1033
+ if (runningState)
1034
+ runningState.itemSelectedByUser = true;
1035
+ setSelectedTreeItemId(treeItem.id);
1036
+ },
1037
+ isError: (treeItem) => treeItem.kind === "group" ? treeItem.hasLoadErrors : false,
1038
+ autoExpandDepth: filterText ? 5 : 1,
1039
+ noItemsMessage: isLoading ? "Loading…" : "No tests"
1040
+ }
1041
+ );
1042
+ };
1043
+ const TraceView = ({ item, rootDir }) => {
1044
+ var _a;
1045
+ const [model, setModel] = React.useState();
1046
+ const [counter, setCounter] = React.useState(0);
1047
+ const pollTimer = React.useRef(null);
1048
+ const { outputDir } = React.useMemo(() => {
1049
+ const outputDir2 = item.testCase ? outputDirForTestCase(item.testCase) : void 0;
1050
+ return { outputDir: outputDir2 };
1051
+ }, [item]);
1052
+ const [selectedActionId, setSelectedActionId] = React.useState();
1053
+ const onSelectionChanged = React.useCallback((action) => setSelectedActionId(idForAction(action)), [setSelectedActionId]);
1054
+ const initialSelection = selectedActionId ? model == null ? void 0 : model.model.actions.find((a) => idForAction(a) === selectedActionId) : void 0;
1055
+ React.useEffect(() => {
1056
+ var _a2, _b;
1057
+ if (pollTimer.current)
1058
+ clearTimeout(pollTimer.current);
1059
+ const result = (_a2 = item.testCase) == null ? void 0 : _a2.results[0];
1060
+ if (!result) {
1061
+ setModel(void 0);
1062
+ return;
1063
+ }
1064
+ const attachment = result && result.duration >= 0 && result.attachments.find((a) => a.name === "trace");
1065
+ if (attachment && attachment.path) {
1066
+ loadSingleTraceFile(attachment.path).then((model2) => setModel({ model: model2, isLive: false }));
1067
+ return;
1068
+ }
1069
+ if (!outputDir) {
1070
+ setModel(void 0);
1071
+ return;
1072
+ }
1073
+ const traceLocation = `${outputDir}/${artifactsFolderName(result.workerIndex)}/traces/${(_b = item.testCase) == null ? void 0 : _b.id}.json`;
1074
+ pollTimer.current = setTimeout(async () => {
1075
+ try {
1076
+ const model2 = await loadSingleTraceFile(traceLocation);
1077
+ setModel({ model: model2, isLive: true });
1078
+ } catch {
1079
+ setModel(void 0);
1080
+ } finally {
1081
+ setCounter(counter + 1);
1082
+ }
1083
+ }, 500);
1084
+ return () => {
1085
+ if (pollTimer.current)
1086
+ clearTimeout(pollTimer.current);
1087
+ };
1088
+ }, [outputDir, item, setModel, counter, setCounter]);
1089
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
1090
+ Workbench,
1091
+ {
1092
+ model: model == null ? void 0 : model.model,
1093
+ hideStackFrames: true,
1094
+ showSourcesFirst: true,
1095
+ rootDir,
1096
+ initialSelection,
1097
+ onSelectionChanged,
1098
+ fallbackLocation: item.testFile,
1099
+ isLive: model == null ? void 0 : model.isLive,
1100
+ status: (_a = item.treeItem) == null ? void 0 : _a.status
1101
+ },
1102
+ "workbench"
1103
+ );
1104
+ };
1105
+ let receiver;
1106
+ let lastRunReceiver;
1107
+ let lastRunTestCount;
1108
+ let throttleTimer;
1109
+ let throttleData;
1110
+ const throttledAction = () => {
1111
+ clearTimeout(throttleTimer);
1112
+ throttleTimer = void 0;
1113
+ updateRootSuite(throttleData.config, throttleData.rootSuite, throttleData.loadErrors, throttleData.progress);
1114
+ };
1115
+ const throttleUpdateRootSuite = (config, rootSuite, loadErrors, progress, immediate = false) => {
1116
+ throttleData = { config, rootSuite, loadErrors, progress };
1117
+ if (immediate)
1118
+ throttledAction();
1119
+ else if (!throttleTimer)
1120
+ throttleTimer = setTimeout(throttledAction, 250);
1121
+ };
1122
+ const refreshRootSuite = (eraseResults) => {
1123
+ if (!eraseResults)
1124
+ return sendMessage("list", {});
1125
+ let rootSuite;
1126
+ const loadErrors = [];
1127
+ const progress = {
1128
+ total: 0,
1129
+ passed: 0,
1130
+ failed: 0,
1131
+ skipped: 0
1132
+ };
1133
+ let config;
1134
+ receiver = new TeleReporterReceiver(pathSeparator, {
1135
+ version: () => "v2",
1136
+ onConfigure: (c) => {
1137
+ config = c;
1138
+ lastRunReceiver = new TeleReporterReceiver(pathSeparator, {
1139
+ onBegin: (suite) => {
1140
+ lastRunTestCount = suite.allTests().length;
1141
+ lastRunReceiver = void 0;
1142
+ }
1143
+ }, false);
1144
+ },
1145
+ onBegin: (suite) => {
1146
+ if (!rootSuite)
1147
+ rootSuite = suite;
1148
+ progress.total = lastRunTestCount;
1149
+ progress.passed = 0;
1150
+ progress.failed = 0;
1151
+ progress.skipped = 0;
1152
+ throttleUpdateRootSuite(config, rootSuite, loadErrors, progress, true);
1153
+ },
1154
+ onEnd: () => {
1155
+ throttleUpdateRootSuite(config, rootSuite, loadErrors, progress, true);
1156
+ },
1157
+ onTestBegin: () => {
1158
+ throttleUpdateRootSuite(config, rootSuite, loadErrors, progress);
1159
+ },
1160
+ onTestEnd: (test) => {
1161
+ if (test.outcome() === "skipped")
1162
+ ++progress.skipped;
1163
+ else if (test.outcome() === "unexpected")
1164
+ ++progress.failed;
1165
+ else
1166
+ ++progress.passed;
1167
+ throttleUpdateRootSuite(config, rootSuite, loadErrors, progress);
1168
+ },
1169
+ onError: (error) => {
1170
+ xtermDataSource.write((error.stack || error.value || "") + "\n");
1171
+ loadErrors.push(error);
1172
+ throttleUpdateRootSuite(config, rootSuite ?? new TeleSuite("", "root"), loadErrors, progress);
1173
+ },
1174
+ printsToStdio: () => {
1175
+ return false;
1176
+ },
1177
+ onStdOut: () => {
1178
+ },
1179
+ onStdErr: () => {
1180
+ },
1181
+ onExit: () => {
1182
+ },
1183
+ onStepBegin: () => {
1184
+ },
1185
+ onStepEnd: () => {
1186
+ }
1187
+ }, true);
1188
+ receiver._setClearPreviousResultsWhenTestBegins();
1189
+ return sendMessage("list", {});
1190
+ };
1191
+ const sendMessageNoReply = (method, params) => {
1192
+ if (window._overrideProtocolForTest) {
1193
+ window._overrideProtocolForTest({ method, params }).catch(() => {
1194
+ });
1195
+ return;
1196
+ }
1197
+ sendMessage(method, params).catch((e) => {
1198
+ console.error(e);
1199
+ });
1200
+ };
1201
+ const dispatchEvent = (method, params) => {
1202
+ var _a, _b;
1203
+ if (method === "listChanged") {
1204
+ refreshRootSuite(false).catch(() => {
1205
+ });
1206
+ return;
1207
+ }
1208
+ if (method === "testFilesChanged") {
1209
+ runWatchedTests(params.testFileNames);
1210
+ return;
1211
+ }
1212
+ if (method === "stdio") {
1213
+ if (params.buffer) {
1214
+ const data = atob(params.buffer);
1215
+ xtermDataSource.write(data);
1216
+ } else {
1217
+ xtermDataSource.write(params.text);
1218
+ }
1219
+ return;
1220
+ }
1221
+ (_a = lastRunReceiver == null ? void 0 : lastRunReceiver.dispatch({ method, params })) == null ? void 0 : _a.catch(() => {
1222
+ });
1223
+ (_b = receiver == null ? void 0 : receiver.dispatch({ method, params })) == null ? void 0 : _b.catch(() => {
1224
+ });
1225
+ };
1226
+ const outputDirForTestCase = (testCase) => {
1227
+ var _a;
1228
+ for (let suite = testCase.parent; suite; suite = suite.parent) {
1229
+ if (suite.project())
1230
+ return (_a = suite.project()) == null ? void 0 : _a.outputDir;
1231
+ }
1232
+ return void 0;
1233
+ };
1234
+ const locationToOpen = (treeItem) => {
1235
+ if (!treeItem)
1236
+ return;
1237
+ return treeItem.location.file + ":" + treeItem.location.line;
1238
+ };
1239
+ const collectTestIds = (treeItem) => {
1240
+ const testIds = /* @__PURE__ */ new Set();
1241
+ if (!treeItem)
1242
+ return testIds;
1243
+ const visit = (treeItem2) => {
1244
+ var _a;
1245
+ if (treeItem2.kind === "case")
1246
+ treeItem2.tests.map((t) => t.id).forEach((id) => testIds.add(id));
1247
+ else if (treeItem2.kind === "test")
1248
+ testIds.add(treeItem2.id);
1249
+ else
1250
+ (_a = treeItem2.children) == null ? void 0 : _a.forEach(visit);
1251
+ };
1252
+ visit(treeItem);
1253
+ return testIds;
1254
+ };
1255
+ function getFileItem(rootItem, filePath, isFile, fileItems) {
1256
+ if (filePath.length === 0)
1257
+ return rootItem;
1258
+ const fileName = filePath.join(pathSeparator);
1259
+ const existingFileItem = fileItems.get(fileName);
1260
+ if (existingFileItem)
1261
+ return existingFileItem;
1262
+ const parentFileItem = getFileItem(rootItem, filePath.slice(0, filePath.length - 1), false, fileItems);
1263
+ const fileItem = {
1264
+ kind: "group",
1265
+ subKind: isFile ? "file" : "folder",
1266
+ id: fileName,
1267
+ title: filePath[filePath.length - 1],
1268
+ location: { file: fileName, line: 0, column: 0 },
1269
+ duration: 0,
1270
+ parent: parentFileItem,
1271
+ children: [],
1272
+ status: "none",
1273
+ hasLoadErrors: false
1274
+ };
1275
+ parentFileItem.children.push(fileItem);
1276
+ fileItems.set(fileName, fileItem);
1277
+ return fileItem;
1278
+ }
1279
+ function createTree(rootSuite, loadErrors, projectFilters) {
1280
+ const filterProjects = [...projectFilters.values()].some(Boolean);
1281
+ const rootItem = {
1282
+ kind: "group",
1283
+ subKind: "folder",
1284
+ id: "root",
1285
+ title: "",
1286
+ location: { file: "", line: 0, column: 0 },
1287
+ duration: 0,
1288
+ parent: void 0,
1289
+ children: [],
1290
+ status: "none",
1291
+ hasLoadErrors: false
1292
+ };
1293
+ const visitSuite = (projectName, parentSuite, parentGroup) => {
1294
+ for (const suite of parentSuite.suites) {
1295
+ const title = suite.title || "<anonymous>";
1296
+ let group = parentGroup.children.find((item) => item.kind === "group" && item.title === title);
1297
+ if (!group) {
1298
+ group = {
1299
+ kind: "group",
1300
+ subKind: "describe",
1301
+ id: "suite:" + parentSuite.titlePath().join("") + "" + title,
1302
+ // account for anonymous suites
1303
+ title,
1304
+ location: suite.location,
1305
+ duration: 0,
1306
+ parent: parentGroup,
1307
+ children: [],
1308
+ status: "none",
1309
+ hasLoadErrors: false
1310
+ };
1311
+ parentGroup.children.push(group);
1312
+ }
1313
+ visitSuite(projectName, suite, group);
1314
+ }
1315
+ for (const test of parentSuite.tests) {
1316
+ const title = test.title;
1317
+ let testCaseItem = parentGroup.children.find((t) => t.kind !== "group" && t.title === title);
1318
+ if (!testCaseItem) {
1319
+ testCaseItem = {
1320
+ kind: "case",
1321
+ id: "test:" + test.titlePath().join(""),
1322
+ title,
1323
+ parent: parentGroup,
1324
+ children: [],
1325
+ tests: [],
1326
+ location: test.location,
1327
+ duration: 0,
1328
+ status: "none"
1329
+ };
1330
+ parentGroup.children.push(testCaseItem);
1331
+ }
1332
+ const result = test.results[0];
1333
+ let status = "none";
1334
+ if ((result == null ? void 0 : result.statusEx) === "scheduled")
1335
+ status = "scheduled";
1336
+ else if ((result == null ? void 0 : result.statusEx) === "running")
1337
+ status = "running";
1338
+ else if ((result == null ? void 0 : result.status) === "skipped")
1339
+ status = "skipped";
1340
+ else if ((result == null ? void 0 : result.status) === "interrupted")
1341
+ status = "none";
1342
+ else if (result && test.outcome() !== "expected")
1343
+ status = "failed";
1344
+ else if (result && test.outcome() === "expected")
1345
+ status = "passed";
1346
+ testCaseItem.tests.push(test);
1347
+ testCaseItem.children.push({
1348
+ kind: "test",
1349
+ id: test.id,
1350
+ title: projectName,
1351
+ location: test.location,
1352
+ test,
1353
+ parent: testCaseItem,
1354
+ children: [],
1355
+ status,
1356
+ duration: test.results.length ? Math.max(0, test.results[0].duration) : 0,
1357
+ project: projectName
1358
+ });
1359
+ testCaseItem.duration = testCaseItem.children.reduce((a, b) => a + b.duration, 0);
1360
+ }
1361
+ };
1362
+ const fileMap = /* @__PURE__ */ new Map();
1363
+ for (const projectSuite of (rootSuite == null ? void 0 : rootSuite.suites) || []) {
1364
+ if (filterProjects && !projectFilters.get(projectSuite.title))
1365
+ continue;
1366
+ for (const fileSuite of projectSuite.suites) {
1367
+ const fileItem = getFileItem(rootItem, fileSuite.location.file.split(pathSeparator), true, fileMap);
1368
+ visitSuite(projectSuite.title, fileSuite, fileItem);
1369
+ }
1370
+ }
1371
+ for (const loadError of loadErrors) {
1372
+ if (!loadError.location)
1373
+ continue;
1374
+ const fileItem = getFileItem(rootItem, loadError.location.file.split(pathSeparator), true, fileMap);
1375
+ fileItem.hasLoadErrors = true;
1376
+ }
1377
+ return rootItem;
1378
+ }
1379
+ function filterTree(rootItem, filterText, statusFilters, runningTestIds) {
1380
+ const tokens = filterText.trim().toLowerCase().split(" ");
1381
+ const filtersStatuses = [...statusFilters.values()].some(Boolean);
1382
+ const filter = (testCase) => {
1383
+ const title = testCase.tests[0].titlePath().join(" ").toLowerCase();
1384
+ if (!tokens.every((token) => title.includes(token)) && !testCase.tests.some((t) => runningTestIds == null ? void 0 : runningTestIds.has(t.id)))
1385
+ return false;
1386
+ testCase.children = testCase.children.filter((test) => {
1387
+ return !filtersStatuses || (runningTestIds == null ? void 0 : runningTestIds.has(test.test.id)) || statusFilters.get(test.status);
1388
+ });
1389
+ testCase.tests = testCase.children.map((c) => c.test);
1390
+ return !!testCase.children.length;
1391
+ };
1392
+ const visit = (treeItem) => {
1393
+ const newChildren = [];
1394
+ for (const child of treeItem.children) {
1395
+ if (child.kind === "case") {
1396
+ if (filter(child))
1397
+ newChildren.push(child);
1398
+ } else {
1399
+ visit(child);
1400
+ if (child.children.length || child.hasLoadErrors)
1401
+ newChildren.push(child);
1402
+ }
1403
+ }
1404
+ treeItem.children = newChildren;
1405
+ };
1406
+ visit(rootItem);
1407
+ }
1408
+ function sortAndPropagateStatus(treeItem) {
1409
+ for (const child of treeItem.children)
1410
+ sortAndPropagateStatus(child);
1411
+ if (treeItem.kind === "group") {
1412
+ treeItem.children.sort((a, b) => {
1413
+ const fc = a.location.file.localeCompare(b.location.file);
1414
+ return fc || a.location.line - b.location.line;
1415
+ });
1416
+ }
1417
+ let allPassed = treeItem.children.length > 0;
1418
+ let allSkipped = treeItem.children.length > 0;
1419
+ let hasFailed = false;
1420
+ let hasRunning = false;
1421
+ let hasScheduled = false;
1422
+ for (const child of treeItem.children) {
1423
+ allSkipped = allSkipped && child.status === "skipped";
1424
+ allPassed = allPassed && (child.status === "passed" || child.status === "skipped");
1425
+ hasFailed = hasFailed || child.status === "failed";
1426
+ hasRunning = hasRunning || child.status === "running";
1427
+ hasScheduled = hasScheduled || child.status === "scheduled";
1428
+ }
1429
+ if (hasRunning)
1430
+ treeItem.status = "running";
1431
+ else if (hasScheduled)
1432
+ treeItem.status = "scheduled";
1433
+ else if (hasFailed)
1434
+ treeItem.status = "failed";
1435
+ else if (allSkipped)
1436
+ treeItem.status = "skipped";
1437
+ else if (allPassed)
1438
+ treeItem.status = "passed";
1439
+ }
1440
+ function shortenRoot(rootItem) {
1441
+ let shortRoot = rootItem;
1442
+ while (shortRoot.children.length === 1 && shortRoot.children[0].kind === "group" && shortRoot.children[0].subKind === "folder")
1443
+ shortRoot = shortRoot.children[0];
1444
+ shortRoot.location = rootItem.location;
1445
+ return shortRoot;
1446
+ }
1447
+ function hideOnlyTests(rootItem) {
1448
+ const visit = (treeItem) => {
1449
+ if (treeItem.kind === "case" && treeItem.children.length === 1)
1450
+ treeItem.children = [];
1451
+ else
1452
+ treeItem.children.forEach(visit);
1453
+ };
1454
+ visit(rootItem);
1455
+ }
1456
+ async function loadSingleTraceFile(url) {
1457
+ const params = new URLSearchParams();
1458
+ params.set("trace", url);
1459
+ const response = await fetch(`contexts?${params.toString()}`);
1460
+ const contextEntries = await response.json();
1461
+ return new MultiTraceModel(contextEntries);
1462
+ }
1463
+ const pathSeparator = navigator.userAgent.toLowerCase().includes("windows") ? "\\" : "/";
1464
+ (async () => {
1465
+ applyTheme();
1466
+ if (window.location.protocol !== "file:") {
1467
+ if (window.location.href.includes("isUnderTest=true"))
1468
+ await new Promise((f) => setTimeout(f, 1e3));
1469
+ if (!navigator.serviceWorker)
1470
+ throw new Error(`Service workers are not supported.
1471
+ Make sure to serve the website (${window.location}) via HTTPS or localhost.`);
1472
+ navigator.serviceWorker.register("sw.bundle.js");
1473
+ if (!navigator.serviceWorker.controller) {
1474
+ await new Promise((f) => {
1475
+ navigator.serviceWorker.oncontrollerchange = () => f();
1476
+ });
1477
+ }
1478
+ setInterval(function() {
1479
+ fetch("ping");
1480
+ }, 1e4);
1481
+ }
1482
+ reactDomExports.render(/* @__PURE__ */ jsxRuntimeExports.jsx(UIModeView, {}), document.querySelector("#root"));
1483
+ })();
1484
+ function __vite__mapDeps(indexes) {
1485
+ if (!__vite__mapDeps.viteFileDeps) {
1486
+ __vite__mapDeps.viteFileDeps = ["./assets/xtermModule-_6TC5FYT.js","./xtermModule.OKEVRlkP.css"]
1487
+ }
1488
+ return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
1489
+ }
1490
+ //# sourceMappingURL=uiMode.fEEgOxJh.js.map