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