@midscene/web 0.2.2 → 0.2.3-beta-20240815085544.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/LICENSE +21 -0
  2. package/dist/es/index.js +395 -82
  3. package/dist/es/playwright-report.js +312 -2288
  4. package/dist/lib/index.js +374 -81
  5. package/dist/lib/playwright-report.js +311 -2280
  6. package/dist/script/htmlElement.js +9 -6
  7. package/dist/types/index.d.ts +14 -9
  8. package/package.json +3 -4
  9. package/dist/visualizer-report/index.html +0 -1
  10. package/dist/visualizer-report/modern.config.json +0 -196
  11. package/dist/visualizer-report/route.json +0 -36
  12. package/dist/visualizer-report/static/css/index.ce838015.css +0 -1
  13. package/dist/visualizer-report/static/css/index.ce838015.css.map +0 -1
  14. package/dist/visualizer-report/static/js/43.c54711bc.js +0 -6
  15. package/dist/visualizer-report/static/js/43.c54711bc.js.LICENSE.txt +0 -107
  16. package/dist/visualizer-report/static/js/43.c54711bc.js.map +0 -1
  17. package/dist/visualizer-report/static/js/async/16.8b96d0ce.js +0 -151
  18. package/dist/visualizer-report/static/js/async/16.8b96d0ce.js.map +0 -1
  19. package/dist/visualizer-report/static/js/async/212.b25a2c30.js +0 -157
  20. package/dist/visualizer-report/static/js/async/212.b25a2c30.js.map +0 -1
  21. package/dist/visualizer-report/static/js/async/353.78fcb703.js +0 -147
  22. package/dist/visualizer-report/static/js/async/353.78fcb703.js.map +0 -1
  23. package/dist/visualizer-report/static/js/async/399.84fa60a7.js +0 -248
  24. package/dist/visualizer-report/static/js/async/399.84fa60a7.js.map +0 -1
  25. package/dist/visualizer-report/static/js/async/453.782b249a.js +0 -41
  26. package/dist/visualizer-report/static/js/async/453.782b249a.js.map +0 -1
  27. package/dist/visualizer-report/static/js/async/544.ee973964.js +0 -1
  28. package/dist/visualizer-report/static/js/async/544.ee973964.js.map +0 -1
  29. package/dist/visualizer-report/static/js/async/983.ef821e39.js +0 -1
  30. package/dist/visualizer-report/static/js/index.013f8b6a.js +0 -1
  31. package/dist/visualizer-report/static/js/index.013f8b6a.js.map +0 -1
  32. package/dist/visualizer-report/static/js/lib-antd.583c9200.js +0 -141
  33. package/dist/visualizer-report/static/js/lib-antd.583c9200.js.map +0 -1
  34. package/dist/visualizer-report/static/js/lib-polyfill.3da3e38e.js +0 -1
  35. package/dist/visualizer-report/static/js/lib-polyfill.3da3e38e.js.map +0 -1
  36. package/dist/visualizer-report/static/js/lib-react.c011fc71.js +0 -2
  37. package/dist/visualizer-report/static/js/lib-react.c011fc71.js.LICENSE.txt +0 -39
  38. package/dist/visualizer-report/static/js/lib-react.c011fc71.js.map +0 -1
  39. package/dist/visualizer-report/static/js/lib-router.226970ff.js +0 -2
  40. package/dist/visualizer-report/static/js/lib-router.226970ff.js.LICENSE.txt +0 -32
  41. package/dist/visualizer-report/static/js/lib-router.226970ff.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-present Midscene.js
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/es/index.js CHANGED
@@ -1,7 +1,11 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
5
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
7
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
5
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
10
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
11
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -17,6 +21,320 @@ var __spreadValues = (a, b) => {
17
21
  return a;
18
22
  };
19
23
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __commonJS = (cb, mod) => function __require() {
25
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
36
+ // If the importer is in node compatibility mode or this is not an ESM
37
+ // file that has been converted to a CommonJS file using a Babel-
38
+ // compatible transform (i.e. "__esModule" has not been set), then set
39
+ // "default" to the CommonJS "module.exports" for node compatibility.
40
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
41
+ mod
42
+ ));
43
+
44
+ // ../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.js
45
+ var require_dayjs_min = __commonJS({
46
+ "../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.js"(exports, module) {
47
+ "use strict";
48
+ !function(t, e) {
49
+ "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs = e();
50
+ }(exports, function() {
51
+ "use strict";
52
+ var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) {
53
+ var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
54
+ return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
55
+ } }, m = function(t2, e2, n2) {
56
+ var r2 = String(t2);
57
+ return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
58
+ }, v = { s: m, z: function(t2) {
59
+ var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
60
+ return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
61
+ }, m: function t2(e2, n2) {
62
+ if (e2.date() < n2.date())
63
+ return -t2(n2, e2);
64
+ var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, c), s2 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s2 ? -1 : 1), c);
65
+ return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
66
+ }, a: function(t2) {
67
+ return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
68
+ }, p: function(t2) {
69
+ return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
70
+ }, u: function(t2) {
71
+ return void 0 === t2;
72
+ } }, g = "en", D = {};
73
+ D[g] = M;
74
+ var p = "$isDayjsObject", S = function(t2) {
75
+ return t2 instanceof _ || !(!t2 || !t2[p]);
76
+ }, w = function t2(e2, n2, r2) {
77
+ var i2;
78
+ if (!e2)
79
+ return g;
80
+ if ("string" == typeof e2) {
81
+ var s2 = e2.toLowerCase();
82
+ D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
83
+ var u2 = e2.split("-");
84
+ if (!i2 && u2.length > 1)
85
+ return t2(u2[0]);
86
+ } else {
87
+ var a2 = e2.name;
88
+ D[a2] = e2, i2 = a2;
89
+ }
90
+ return !r2 && i2 && (g = i2), i2 || !r2 && g;
91
+ }, O = function(t2, e2) {
92
+ if (S(t2))
93
+ return t2.clone();
94
+ var n2 = "object" == typeof e2 ? e2 : {};
95
+ return n2.date = t2, n2.args = arguments, new _(n2);
96
+ }, b = v;
97
+ b.l = w, b.i = S, b.w = function(t2, e2) {
98
+ return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
99
+ };
100
+ var _ = function() {
101
+ function M2(t2) {
102
+ this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
103
+ }
104
+ var m2 = M2.prototype;
105
+ return m2.parse = function(t2) {
106
+ this.$d = function(t3) {
107
+ var e2 = t3.date, n2 = t3.utc;
108
+ if (null === e2)
109
+ return /* @__PURE__ */ new Date(NaN);
110
+ if (b.u(e2))
111
+ return /* @__PURE__ */ new Date();
112
+ if (e2 instanceof Date)
113
+ return new Date(e2);
114
+ if ("string" == typeof e2 && !/Z$/i.test(e2)) {
115
+ var r2 = e2.match($);
116
+ if (r2) {
117
+ var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
118
+ return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2);
119
+ }
120
+ }
121
+ return new Date(e2);
122
+ }(t2), this.init();
123
+ }, m2.init = function() {
124
+ var t2 = this.$d;
125
+ this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
126
+ }, m2.$utils = function() {
127
+ return b;
128
+ }, m2.isValid = function() {
129
+ return !(this.$d.toString() === l);
130
+ }, m2.isSame = function(t2, e2) {
131
+ var n2 = O(t2);
132
+ return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
133
+ }, m2.isAfter = function(t2, e2) {
134
+ return O(t2) < this.startOf(e2);
135
+ }, m2.isBefore = function(t2, e2) {
136
+ return this.endOf(e2) < O(t2);
137
+ }, m2.$g = function(t2, e2, n2) {
138
+ return b.u(t2) ? this[e2] : this.set(n2, t2);
139
+ }, m2.unix = function() {
140
+ return Math.floor(this.valueOf() / 1e3);
141
+ }, m2.valueOf = function() {
142
+ return this.$d.getTime();
143
+ }, m2.startOf = function(t2, e2) {
144
+ var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
145
+ var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
146
+ return r2 ? i2 : i2.endOf(a);
147
+ }, $2 = function(t3, e3) {
148
+ return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2);
149
+ }, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
150
+ switch (f2) {
151
+ case h:
152
+ return r2 ? l2(1, 0) : l2(31, 11);
153
+ case c:
154
+ return r2 ? l2(1, M3) : l2(0, M3 + 1);
155
+ case o:
156
+ var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
157
+ return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
158
+ case a:
159
+ case d:
160
+ return $2(v2 + "Hours", 0);
161
+ case u:
162
+ return $2(v2 + "Minutes", 1);
163
+ case s:
164
+ return $2(v2 + "Seconds", 2);
165
+ case i:
166
+ return $2(v2 + "Milliseconds", 3);
167
+ default:
168
+ return this.clone();
169
+ }
170
+ }, m2.endOf = function(t2) {
171
+ return this.startOf(t2, false);
172
+ }, m2.$set = function(t2, e2) {
173
+ var n2, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f2 + "Date", n2[d] = f2 + "Date", n2[c] = f2 + "Month", n2[h] = f2 + "FullYear", n2[u] = f2 + "Hours", n2[s] = f2 + "Minutes", n2[i] = f2 + "Seconds", n2[r] = f2 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2;
174
+ if (o2 === c || o2 === h) {
175
+ var y2 = this.clone().set(d, 1);
176
+ y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
177
+ } else
178
+ l2 && this.$d[l2]($2);
179
+ return this.init(), this;
180
+ }, m2.set = function(t2, e2) {
181
+ return this.clone().$set(t2, e2);
182
+ }, m2.get = function(t2) {
183
+ return this[b.p(t2)]();
184
+ }, m2.add = function(r2, f2) {
185
+ var d2, l2 = this;
186
+ r2 = Number(r2);
187
+ var $2 = b.p(f2), y2 = function(t2) {
188
+ var e2 = O(l2);
189
+ return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
190
+ };
191
+ if ($2 === c)
192
+ return this.set(c, this.$M + r2);
193
+ if ($2 === h)
194
+ return this.set(h, this.$y + r2);
195
+ if ($2 === a)
196
+ return y2(1);
197
+ if ($2 === o)
198
+ return y2(7);
199
+ var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
200
+ return b.w(m3, this);
201
+ }, m2.subtract = function(t2, e2) {
202
+ return this.add(-1 * t2, e2);
203
+ }, m2.format = function(t2) {
204
+ var e2 = this, n2 = this.$locale();
205
+ if (!this.isValid())
206
+ return n2.invalidDate || l;
207
+ var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f2 = n2.meridiem, h2 = function(t3, n3, i3, s3) {
208
+ return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
209
+ }, d2 = function(t3) {
210
+ return b.s(s2 % 12 || 12, t3, "0");
211
+ }, $2 = f2 || function(t3, e3, n3) {
212
+ var r3 = t3 < 12 ? "AM" : "PM";
213
+ return n3 ? r3.toLowerCase() : r3;
214
+ };
215
+ return r2.replace(y, function(t3, r3) {
216
+ return r3 || function(t4) {
217
+ switch (t4) {
218
+ case "YY":
219
+ return String(e2.$y).slice(-2);
220
+ case "YYYY":
221
+ return b.s(e2.$y, 4, "0");
222
+ case "M":
223
+ return a2 + 1;
224
+ case "MM":
225
+ return b.s(a2 + 1, 2, "0");
226
+ case "MMM":
227
+ return h2(n2.monthsShort, a2, c2, 3);
228
+ case "MMMM":
229
+ return h2(c2, a2);
230
+ case "D":
231
+ return e2.$D;
232
+ case "DD":
233
+ return b.s(e2.$D, 2, "0");
234
+ case "d":
235
+ return String(e2.$W);
236
+ case "dd":
237
+ return h2(n2.weekdaysMin, e2.$W, o2, 2);
238
+ case "ddd":
239
+ return h2(n2.weekdaysShort, e2.$W, o2, 3);
240
+ case "dddd":
241
+ return o2[e2.$W];
242
+ case "H":
243
+ return String(s2);
244
+ case "HH":
245
+ return b.s(s2, 2, "0");
246
+ case "h":
247
+ return d2(1);
248
+ case "hh":
249
+ return d2(2);
250
+ case "a":
251
+ return $2(s2, u2, true);
252
+ case "A":
253
+ return $2(s2, u2, false);
254
+ case "m":
255
+ return String(u2);
256
+ case "mm":
257
+ return b.s(u2, 2, "0");
258
+ case "s":
259
+ return String(e2.$s);
260
+ case "ss":
261
+ return b.s(e2.$s, 2, "0");
262
+ case "SSS":
263
+ return b.s(e2.$ms, 3, "0");
264
+ case "Z":
265
+ return i2;
266
+ }
267
+ return null;
268
+ }(t3) || i2.replace(":", "");
269
+ });
270
+ }, m2.utcOffset = function() {
271
+ return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
272
+ }, m2.diff = function(r2, d2, l2) {
273
+ var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
274
+ return b.m(y2, m3);
275
+ };
276
+ switch (M3) {
277
+ case h:
278
+ $2 = D2() / 12;
279
+ break;
280
+ case c:
281
+ $2 = D2();
282
+ break;
283
+ case f:
284
+ $2 = D2() / 3;
285
+ break;
286
+ case o:
287
+ $2 = (g2 - v2) / 6048e5;
288
+ break;
289
+ case a:
290
+ $2 = (g2 - v2) / 864e5;
291
+ break;
292
+ case u:
293
+ $2 = g2 / n;
294
+ break;
295
+ case s:
296
+ $2 = g2 / e;
297
+ break;
298
+ case i:
299
+ $2 = g2 / t;
300
+ break;
301
+ default:
302
+ $2 = g2;
303
+ }
304
+ return l2 ? $2 : b.a($2);
305
+ }, m2.daysInMonth = function() {
306
+ return this.endOf(c).$D;
307
+ }, m2.$locale = function() {
308
+ return D[this.$L];
309
+ }, m2.locale = function(t2, e2) {
310
+ if (!t2)
311
+ return this.$L;
312
+ var n2 = this.clone(), r2 = w(t2, e2, true);
313
+ return r2 && (n2.$L = r2), n2;
314
+ }, m2.clone = function() {
315
+ return b.w(this.$d, this);
316
+ }, m2.toDate = function() {
317
+ return new Date(this.valueOf());
318
+ }, m2.toJSON = function() {
319
+ return this.isValid() ? this.toISOString() : null;
320
+ }, m2.toISOString = function() {
321
+ return this.$d.toISOString();
322
+ }, m2.toString = function() {
323
+ return this.$d.toUTCString();
324
+ }, M2;
325
+ }(), k = _.prototype;
326
+ return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach(function(t2) {
327
+ k[t2[1]] = function(e2) {
328
+ return this.$g(e2, t2[0], t2[1]);
329
+ };
330
+ }), O.extend = function(t2, e2) {
331
+ return t2.$i || (t2(e2, _, O), t2.$i = true), O;
332
+ }, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
333
+ return O(1e3 * t2);
334
+ }, O.en = D[g], O.Ls = D, O.p = {}, O;
335
+ });
336
+ }
337
+ });
20
338
 
21
339
  // src/playwright/index.ts
22
340
  import { randomUUID } from "crypto";
@@ -25,7 +343,7 @@ import { randomUUID } from "crypto";
25
343
  import {
26
344
  groupedActionDumpFileExt,
27
345
  stringifyDumpData,
28
- writeDumpFile
346
+ writeLogFile
29
347
  } from "@midscene/core/utils";
30
348
 
31
349
  // src/common/tasks.ts
@@ -93,6 +411,7 @@ var TaskCache = class {
93
411
  };
94
412
 
95
413
  // src/common/utils.ts
414
+ var import_dayjs = __toESM(require_dayjs_min());
96
415
  import assert from "assert";
97
416
  import fs, { readFileSync } from "fs";
98
417
  import path from "path";
@@ -190,6 +509,13 @@ function findNearestPackageJson(dir) {
190
509
  }
191
510
  return findNearestPackageJson(parentDir);
192
511
  }
512
+ function reportFileName(tag = "web") {
513
+ const dateTimeInFileName = (0, import_dayjs.default)().format("YYYY-MM-DD_HH-mm-ss-SSS");
514
+ return `${tag}-${dateTimeInFileName}`;
515
+ }
516
+ function printReportMsg(filepath) {
517
+ console.log("Midscene - report file updated:", filepath);
518
+ }
193
519
 
194
520
  // src/common/tasks.ts
195
521
  var PageTaskExecutor = class {
@@ -551,31 +877,49 @@ var PageTaskExecutor = class {
551
877
  var PageAgent = class {
552
878
  constructor(page, opts) {
553
879
  this.page = page;
554
- this.dumps = [
880
+ this.opts = Object.assign(
555
881
  {
556
- groupName: (opts == null ? void 0 : opts.taskFile) || "unnamed",
557
- executions: []
558
- }
559
- ];
560
- this.testId = (opts == null ? void 0 : opts.testId) || String(process.pid);
882
+ generateReport: true,
883
+ groupName: "Midscene Report",
884
+ groupDescription: ""
885
+ },
886
+ opts || {}
887
+ );
888
+ this.dump = {
889
+ groupName: this.opts.groupName,
890
+ groupDescription: this.opts.groupDescription,
891
+ executions: []
892
+ };
561
893
  this.taskExecutor = new PageTaskExecutor(this.page, {
562
894
  cache: (opts == null ? void 0 : opts.cache) || { aiTasks: [] }
563
895
  });
896
+ this.reportFileName = reportFileName((opts == null ? void 0 : opts.testId) || "web");
564
897
  }
565
- appendDump(execution) {
566
- const currentDump = this.dumps[0];
898
+ appendExecutionDump(execution) {
899
+ const currentDump = this.dump;
567
900
  currentDump.executions.push(execution);
568
901
  }
902
+ dumpDataString() {
903
+ this.dump.groupName = this.opts.groupName;
904
+ this.dump.groupDescription = this.opts.groupDescription;
905
+ return stringifyDumpData(this.dump);
906
+ }
569
907
  writeOutActionDumps() {
570
- this.dumpFile = writeDumpFile({
571
- fileName: `run-${this.testId}`,
908
+ const generateReport = this.opts.generateReport;
909
+ this.reportFile = writeLogFile({
910
+ fileName: this.reportFileName,
572
911
  fileExt: groupedActionDumpFileExt,
573
- fileContent: stringifyDumpData(this.dumps)
912
+ fileContent: this.dumpDataString(),
913
+ type: "dump",
914
+ generateReport
574
915
  });
916
+ if (generateReport) {
917
+ printReportMsg(this.reportFile);
918
+ }
575
919
  }
576
920
  async aiAction(taskPrompt) {
577
921
  const { executor } = await this.taskExecutor.action(taskPrompt);
578
- this.appendDump(executor.dump());
922
+ this.appendExecutionDump(executor.dump());
579
923
  this.writeOutActionDumps();
580
924
  if (executor.isInErrorState()) {
581
925
  const errorTask = executor.latestErrorTask();
@@ -585,7 +929,7 @@ ${errorTask == null ? void 0 : errorTask.errorStack}`);
585
929
  }
586
930
  async aiQuery(demand) {
587
931
  const { output, executor } = await this.taskExecutor.query(demand);
588
- this.appendDump(executor.dump());
932
+ this.appendExecutionDump(executor.dump());
589
933
  this.writeOutActionDumps();
590
934
  if (executor.isInErrorState()) {
591
935
  const errorTask = executor.latestErrorTask();
@@ -596,7 +940,7 @@ ${errorTask == null ? void 0 : errorTask.errorStack}`);
596
940
  }
597
941
  async aiAssert(assertion, msg) {
598
942
  const { output, executor } = await this.taskExecutor.assert(assertion);
599
- this.appendDump(executor.dump());
943
+ this.appendExecutionDump(executor.dump());
600
944
  this.writeOutActionDumps();
601
945
  if (!(output == null ? void 0 : output.pass)) {
602
946
  const errMsg = msg || `Assertion failed: ${assertion}`;
@@ -625,13 +969,13 @@ ${reasonMsg}`);
625
969
  import fs2 from "fs";
626
970
  import path2, { join } from "path";
627
971
  import {
628
- getDumpDirPath,
972
+ getLogDirByType,
629
973
  stringifyDumpData as stringifyDumpData2,
630
- writeDumpFile as writeDumpFile2
974
+ writeLogFile as writeLogFile2
631
975
  } from "@midscene/core/utils";
632
976
  function writeTestCache(taskFile, taskTitle, taskCacheJson) {
633
977
  const packageJson = getPkgInfo();
634
- writeDumpFile2({
978
+ writeLogFile2({
635
979
  fileName: `${taskFile}(${taskTitle})`,
636
980
  fileExt: "json",
637
981
  fileContent: stringifyDumpData2(
@@ -648,7 +992,7 @@ function writeTestCache(taskFile, taskTitle, taskCacheJson) {
648
992
  }
649
993
  function readTestCache(taskFile, taskTitle) {
650
994
  const cacheFile = join(
651
- getDumpDirPath("cache"),
995
+ getLogDirByType("cache"),
652
996
  `${taskFile}(${taskTitle}).json`
653
997
  );
654
998
  const pkgInfo = getPkgInfo();
@@ -702,32 +1046,47 @@ var groupAndCaseForTest = (testInfo) => {
702
1046
  return { taskFile, taskTitle };
703
1047
  };
704
1048
  var midsceneAgentKeyId = "_midsceneAgentId";
1049
+ var midsceneDumpAnnotationId = "MIDSCENE_DUMP_ANNOTATION";
705
1050
  var PlaywrightAiFixture = () => {
706
1051
  const pageAgentMap = {};
707
- const agentForPage = (page, opts) => {
1052
+ const agentForPage = (page, testInfo) => {
708
1053
  let idForPage = page[midsceneAgentKeyId];
709
1054
  if (!idForPage) {
710
1055
  idForPage = randomUUID();
711
1056
  page[midsceneAgentKeyId] = idForPage;
712
- const testCase = readTestCache(opts.taskFile, opts.taskTitle) || {
1057
+ const { testId } = testInfo;
1058
+ const { taskFile, taskTitle } = groupAndCaseForTest(testInfo);
1059
+ const testCase = readTestCache(taskFile, taskTitle) || {
713
1060
  aiTasks: []
714
1061
  };
715
1062
  pageAgentMap[idForPage] = new PageAgent(page, {
716
- testId: `${opts.testId}-${idForPage}`,
717
- taskFile: opts.taskFile,
718
- cache: testCase
1063
+ testId: `playwright-${testId}-${idForPage}`,
1064
+ groupName: taskTitle,
1065
+ groupDescription: taskFile,
1066
+ cache: testCase,
1067
+ generateReport: false
1068
+ // we will generate it in the reporter
719
1069
  });
720
1070
  }
721
1071
  return pageAgentMap[idForPage];
722
1072
  };
1073
+ const updateDumpAnnotation = (test, dump) => {
1074
+ const currentAnnotation = test.annotations.find((item) => {
1075
+ return item.type === midsceneDumpAnnotationId;
1076
+ });
1077
+ if (currentAnnotation) {
1078
+ currentAnnotation.description = dump;
1079
+ } else {
1080
+ test.annotations.push({
1081
+ type: midsceneDumpAnnotationId,
1082
+ description: dump
1083
+ });
1084
+ }
1085
+ };
723
1086
  return {
724
1087
  ai: async ({ page }, use, testInfo) => {
725
1088
  const { taskFile, taskTitle } = groupAndCaseForTest(testInfo);
726
- const agent = agentForPage(page, {
727
- testId: testInfo.testId,
728
- taskFile,
729
- taskTitle
730
- });
1089
+ const agent = agentForPage(page, testInfo);
731
1090
  await use(
732
1091
  async (taskPrompt, opts) => {
733
1092
  await page.waitForLoadState("networkidle");
@@ -738,79 +1097,33 @@ var PlaywrightAiFixture = () => {
738
1097
  );
739
1098
  const taskCacheJson = agent.taskExecutor.taskCache.generateTaskCache();
740
1099
  writeTestCache(taskFile, taskTitle, taskCacheJson);
741
- if (agent.dumpFile) {
742
- testInfo.annotations.push({
743
- type: "MIDSCENE_AI_ACTION",
744
- description: JSON.stringify({
745
- testId: testInfo.testId,
746
- dumpPath: agent.dumpFile
747
- })
748
- });
749
- }
1100
+ updateDumpAnnotation(testInfo, agent.dumpDataString());
750
1101
  },
751
1102
  aiAction: async ({ page }, use, testInfo) => {
752
1103
  const { taskFile, taskTitle } = groupAndCaseForTest(testInfo);
753
- const agent = agentForPage(page, {
754
- testId: testInfo.testId,
755
- taskFile,
756
- taskTitle
757
- });
1104
+ const agent = agentForPage(page, testInfo);
758
1105
  await use(async (taskPrompt) => {
759
1106
  await page.waitForLoadState("networkidle");
760
1107
  await agent.aiAction(taskPrompt);
761
1108
  });
762
- if (agent.dumpFile) {
763
- testInfo.annotations.push({
764
- type: "MIDSCENE_AI_ACTION",
765
- description: JSON.stringify({
766
- testId: testInfo.testId,
767
- dumpPath: agent.dumpFile
768
- })
769
- });
770
- }
1109
+ updateDumpAnnotation(testInfo, agent.dumpDataString());
771
1110
  },
772
1111
  aiQuery: async ({ page }, use, testInfo) => {
773
- const { taskFile, taskTitle } = groupAndCaseForTest(testInfo);
774
- const agent = agentForPage(page, {
775
- testId: testInfo.testId,
776
- taskFile,
777
- taskTitle
778
- });
1112
+ const agent = agentForPage(page, testInfo);
779
1113
  await use(async (demand) => {
780
1114
  await page.waitForLoadState("networkidle");
781
1115
  const result = await agent.aiQuery(demand);
782
1116
  return result;
783
1117
  });
784
- if (agent.dumpFile) {
785
- testInfo.annotations.push({
786
- type: "MIDSCENE_AI_ACTION",
787
- description: JSON.stringify({
788
- testId: testInfo.testId,
789
- dumpPath: agent.dumpFile
790
- })
791
- });
792
- }
1118
+ updateDumpAnnotation(testInfo, agent.dumpDataString());
793
1119
  },
794
1120
  aiAssert: async ({ page }, use, testInfo) => {
795
- const { taskFile, taskTitle } = groupAndCaseForTest(testInfo);
796
- const agent = agentForPage(page, {
797
- testId: testInfo.testId,
798
- taskFile,
799
- taskTitle
800
- });
1121
+ const agent = agentForPage(page, testInfo);
801
1122
  await use(async (assertion, errorMsg) => {
802
1123
  await page.waitForLoadState("networkidle");
803
1124
  await agent.aiAssert(assertion, errorMsg);
804
1125
  });
805
- if (agent.dumpFile) {
806
- testInfo.annotations.push({
807
- type: "MIDSCENE_AI_ACTION",
808
- description: JSON.stringify({
809
- testId: testInfo.testId,
810
- dumpPath: agent.dumpFile
811
- })
812
- });
813
- }
1126
+ updateDumpAnnotation(testInfo, agent.dumpDataString());
814
1127
  }
815
1128
  };
816
1129
  };