twd-js 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/twd.es.js CHANGED
@@ -1,16 +1,16 @@
1
- import ue, { useState as I } from "react";
2
- const de = (e, n = 2e3, r = 50) => new Promise((s, o) => {
3
- const i = Date.now(), l = () => {
1
+ import pe, { useState as D } from "react";
2
+ const be = (e, n = 2e3, r = 50) => new Promise((s, i) => {
3
+ const a = Date.now(), c = () => {
4
4
  const u = e();
5
5
  if (u) return s(u);
6
- if (Date.now() - i > n) return o(new Error("Timeout waiting for element"));
7
- setTimeout(l, r);
6
+ if (Date.now() - a > n) return i(new Error("Timeout waiting for element"));
7
+ setTimeout(c, r);
8
8
  };
9
- l();
10
- }), E = [];
9
+ c();
10
+ }), v = [];
11
11
  let Y = [];
12
- const D = (e, n, r = {}) => {
13
- E.push({
12
+ const U = (e, n, r = {}) => {
13
+ v.push({
14
14
  name: e,
15
15
  fn: n,
16
16
  status: "idle",
@@ -18,11 +18,11 @@ const D = (e, n, r = {}) => {
18
18
  suite: [...Y],
19
19
  ...r
20
20
  });
21
- }, fe = (e) => {
21
+ }, me = (e) => {
22
22
  Y.push(e);
23
- }, pe = () => {
23
+ }, he = () => {
24
24
  Y.pop();
25
- }, b = (e, n, r, s) => {
25
+ }, m = (e, n, r, s) => {
26
26
  if (!e && !n)
27
27
  throw new Error(s);
28
28
  if (e && n)
@@ -31,7 +31,7 @@ const D = (e, n, r = {}) => {
31
31
  );
32
32
  return r;
33
33
  };
34
- function be(e) {
34
+ function xe(e) {
35
35
  if (!e.isConnected) return !1;
36
36
  let n = e;
37
37
  for (; n; ) {
@@ -42,41 +42,41 @@ function be(e) {
42
42
  }
43
43
  return !0;
44
44
  }
45
- const he = (e, n, ...r) => {
46
- const s = n.startsWith("not."), o = s ? n.slice(4) : n, i = (e.textContent || "").trim();
47
- switch (o) {
45
+ const ge = (e, n, ...r) => {
46
+ const s = n.startsWith("not."), i = s ? n.slice(4) : n, a = (e.textContent || "").trim();
47
+ switch (i) {
48
48
  // Content
49
49
  case "have.text":
50
- return b(
51
- i === r[0],
50
+ return m(
51
+ a === r[0],
52
52
  s,
53
53
  `Assertion passed: Text is exactly "${r[0]}"`,
54
- `Assertion failed: Expected text to be "${r[0]}", but got "${i}"`
54
+ `Assertion failed: Expected text to be "${r[0]}", but got "${a}"`
55
55
  );
56
56
  case "contain.text":
57
- return b(
58
- i.includes(r[0]),
57
+ return m(
58
+ a.includes(r[0]),
59
59
  s,
60
60
  `Assertion passed: Text contains "${r[0]}"`,
61
- `Assertion failed: Expected text to contain "${r[0]}", but got "${i}"`
61
+ `Assertion failed: Expected text to contain "${r[0]}", but got "${a}"`
62
62
  );
63
63
  case "be.empty":
64
- return b(
65
- i.length === 0,
64
+ return m(
65
+ a.length === 0,
66
66
  s,
67
67
  "Assertion passed: Text is empty",
68
- `Assertion failed: Expected text to be empty, but got "${i}"`
68
+ `Assertion failed: Expected text to be empty, but got "${a}"`
69
69
  );
70
70
  // Attributes
71
71
  case "have.attr":
72
- return b(
72
+ return m(
73
73
  e.getAttribute(r[0]) === r[1],
74
74
  s,
75
75
  `Assertion passed: Attribute "${r[0]}" is "${r[1]}"`,
76
76
  `Assertion failed: Expected attribute "${r[0]}" to be "${r[1]}", but got "${e.getAttribute(r[0])}"`
77
77
  );
78
78
  case "have.value":
79
- return b(
79
+ return m(
80
80
  e.value === r[0],
81
81
  s,
82
82
  `Assertion passed: Value is "${r[0]}"`,
@@ -84,35 +84,35 @@ const he = (e, n, ...r) => {
84
84
  );
85
85
  // State
86
86
  case "be.disabled":
87
- return b(
87
+ return m(
88
88
  e.disabled === !0,
89
89
  s,
90
90
  "Assertion passed: Element is disabled",
91
91
  "Assertion failed: Expected element to be disabled"
92
92
  );
93
93
  case "be.enabled":
94
- return b(
94
+ return m(
95
95
  e.disabled === !1,
96
96
  s,
97
97
  "Assertion passed: Element is enabled",
98
98
  "Assertion failed: Expected element to be enabled"
99
99
  );
100
100
  case "be.checked":
101
- return b(
101
+ return m(
102
102
  e.checked === !0,
103
103
  s,
104
104
  "Assertion passed: Element is checked",
105
105
  "Assertion failed: Expected element to be checked"
106
106
  );
107
107
  case "be.selected":
108
- return b(
108
+ return m(
109
109
  e.selected === !0,
110
110
  s,
111
111
  "Assertion passed: Element is selected",
112
112
  "Assertion failed: Expected element to be selected"
113
113
  );
114
114
  case "be.focused":
115
- return b(
115
+ return m(
116
116
  document.activeElement === e,
117
117
  s,
118
118
  "Assertion passed: Element is focused",
@@ -120,45 +120,48 @@ const he = (e, n, ...r) => {
120
120
  );
121
121
  // Visibility
122
122
  case "be.visible":
123
- return b(
124
- be(e),
123
+ return m(
124
+ xe(e),
125
125
  s,
126
126
  "Assertion passed: Element is visible",
127
127
  "Assertion failed: Expected element to be visible"
128
128
  );
129
129
  // Classes
130
130
  case "have.class":
131
- return b(
131
+ return m(
132
132
  e.classList.contains(r[0]),
133
133
  s,
134
134
  `Assertion passed: Element has class "${r[0]}"`,
135
135
  `Assertion failed: Expected element to have class "${r[0]}"`
136
136
  );
137
137
  default:
138
- throw new Error(`Unknown assertion: ${o}`);
138
+ throw new Error(`Unknown assertion: ${i}`);
139
139
  }
140
- }, y = (e) => {
141
- const n = E.find((r) => r.status === "running");
140
+ }, R = (e) => {
141
+ const n = v.find((r) => r.status === "running");
142
142
  n && n.logs?.push(e);
143
- }, A = [], me = (e, n) => {
144
- const r = A.findIndex((o) => o.alias === e), s = { alias: e, ...n, executed: !1 };
145
- r !== -1 ? A[r] = s : A.push(s);
146
- }, xe = async (e) => {
147
- const n = A.find((r) => r.alias === e && r.executed);
148
- if (!n)
149
- throw new Error(`No intercept rule found for ${e}`);
150
- return await new Promise((r) => setTimeout(r, 0)), n;
151
- }, ge = window.fetch;
152
- window.fetch = async (e, n) => {
153
- const r = n?.method?.toUpperCase() || "GET", s = typeof e == "string" ? e : e.toString(), o = A.find(
154
- (i) => i.method === r && (typeof i.url == "string" ? i.url === s : i.url.test(s))
155
- );
156
- return o ? (y(`🛡️ ${o.alias} → ${r} ${s}`), o.executed = !0, o.request = n?.body, new Response(JSON.stringify(o.response), {
157
- status: o.status || 200,
158
- headers: o.headers || { "Content-Type": "application/json" }
159
- })) : ge(e, n);
160
- };
161
- const we = (e, n) => {
143
+ }, E = [], C = {}, Z = 100, we = async () => {
144
+ "serviceWorker" in navigator && (await navigator.serviceWorker.register("/mock-sw.js?v=1"), navigator.serviceWorker.addEventListener("message", (e) => {
145
+ if (e.data?.type === "EXECUTED") {
146
+ const { alias: n, request: r } = e.data, s = E.find((i) => i.alias === n);
147
+ s && (s.executed = !0, s.request = r, C[n] && (C[n](s), delete C[n]));
148
+ }
149
+ }));
150
+ }, Q = (e) => new Promise((n) => setTimeout(n, e)), ve = async (e, n) => {
151
+ const r = { alias: e, ...n, executed: !1 }, s = E.findIndex((i) => i.alias === e);
152
+ s !== -1 ? E[s] = r : E.push(r), navigator.serviceWorker.controller?.postMessage({
153
+ type: "ADD_RULE",
154
+ rule: r
155
+ }), await Q(Z), await Promise.resolve();
156
+ }, Ee = async (e) => {
157
+ await Q(Z);
158
+ const n = E.find((r) => r.alias === e && r.executed);
159
+ return n ? Promise.resolve(n) : new Promise((r) => {
160
+ C[e] = r;
161
+ });
162
+ }, ye = () => E, ke = () => {
163
+ E.length = 0;
164
+ }, Re = (e, n) => {
162
165
  for (const r of n) {
163
166
  const s = r.charCodeAt(0);
164
167
  e.dispatchEvent(
@@ -205,18 +208,18 @@ const we = (e, n) => {
205
208
  );
206
209
  }
207
210
  return e;
208
- }, ye = (e, n) => {
211
+ }, Ae = (e, n) => {
209
212
  const r = e.startsWith("not.");
210
213
  switch (r ? e.slice(4) : e) {
211
214
  case "eq":
212
- return b(
215
+ return m(
213
216
  window.location.href === n,
214
217
  r,
215
218
  `Assertion passed: URL is ${n}`,
216
219
  `Assertion failed: Expected URL to be ${n}, but got ${window.location.href}`
217
220
  );
218
221
  case "contain.url":
219
- return b(
222
+ return m(
220
223
  window.location.href.includes(n),
221
224
  r,
222
225
  `Assertion passed: URL contains ${n}`,
@@ -225,54 +228,57 @@ const we = (e, n) => {
225
228
  default:
226
229
  throw new Error(`Unknown assertion: ${e}`);
227
230
  }
228
- }, Ee = () => ({
231
+ }, Te = () => ({
229
232
  location: window.location,
230
- should: ye
233
+ should: Ae
231
234
  });
232
235
  let j = null;
233
- const Ie = (e) => {
236
+ const qe = (e) => {
234
237
  j = e;
235
- }, Ye = (e, n) => {
236
- fe(e), n(), pe();
237
- }, De = (e, n) => {
238
- D(e, async () => {
238
+ }, Fe = (e, n) => {
239
+ me(e), n(), he();
240
+ }, ze = (e, n) => {
241
+ U(e, async () => {
239
242
  j && await j(), await n();
240
243
  });
241
- }, Ue = (e, n) => {
242
- D(e, async () => {
244
+ }, Be = (e, n) => {
245
+ U(e, async () => {
243
246
  j && await j(), await n();
244
247
  }, { only: !0 });
245
- }, Fe = (e, n) => {
246
- D(e, async () => {
248
+ }, Ve = (e, n) => {
249
+ U(e, async () => {
247
250
  }, { skip: !0 });
248
- }, ze = {
251
+ }, Je = {
249
252
  get: async (e) => {
250
- y(`Searching get("${e}")`);
251
- const n = await de(() => document.querySelector(e)), r = {
253
+ R(`Searching get("${e}")`);
254
+ const n = await be(() => document.querySelector(e)), r = {
252
255
  el: n,
253
256
  click: () => {
254
- y(`click(${e})`), n.click();
257
+ R(`click(${e})`), n.click();
255
258
  },
256
- type: (s) => (y(`type("${s}") into ${e}`), we(n, s)),
257
- should: (s, ...o) => {
258
- const i = he(n, s, ...o);
259
- return y(i), r;
259
+ type: (s) => (R(`type("${s}") into ${e}`), Re(n, s)),
260
+ should: (s, ...i) => {
261
+ const a = ge(n, s, ...i);
262
+ return R(a), r;
260
263
  },
261
264
  text: () => {
262
265
  const s = n.textContent || "";
263
- return y(`text(${e}) → "${s}"`), s;
266
+ return R(`text(${e}) → "${s}"`), s;
264
267
  }
265
268
  };
266
269
  return r;
267
270
  },
268
271
  visit: (e) => {
269
- y(`visit("${e}")`), window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate"));
272
+ R(`visit("${e}")`), window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate"));
270
273
  },
271
- url: Ee,
272
- mockRequest: me,
273
- waitFor: xe
274
+ url: Te,
275
+ mockRequest: ve,
276
+ waitForRequest: Ee,
277
+ initRequestMocking: we,
278
+ clearRequestMockRules: ke,
279
+ getRequestMockRules: ye
274
280
  };
275
- var _ = { exports: {} }, R = {};
281
+ var S = { exports: {} }, A = {};
276
282
  /**
277
283
  * @license React
278
284
  * react-jsx-runtime.production.js
@@ -282,27 +288,27 @@ var _ = { exports: {} }, R = {};
282
288
  * This source code is licensed under the MIT license found in the
283
289
  * LICENSE file in the root directory of this source tree.
284
290
  */
285
- var G;
286
- function ve() {
287
- if (G) return R;
288
- G = 1;
291
+ var X;
292
+ function je() {
293
+ if (X) return A;
294
+ X = 1;
289
295
  var e = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
290
- function r(s, o, i) {
291
- var l = null;
292
- if (i !== void 0 && (l = "" + i), o.key !== void 0 && (l = "" + o.key), "key" in o) {
293
- i = {};
294
- for (var u in o)
295
- u !== "key" && (i[u] = o[u]);
296
- } else i = o;
297
- return o = i.ref, {
296
+ function r(s, i, a) {
297
+ var c = null;
298
+ if (a !== void 0 && (c = "" + a), i.key !== void 0 && (c = "" + i.key), "key" in i) {
299
+ a = {};
300
+ for (var u in i)
301
+ u !== "key" && (a[u] = i[u]);
302
+ } else a = i;
303
+ return i = a.ref, {
298
304
  $$typeof: e,
299
305
  type: s,
300
- key: l,
301
- ref: o !== void 0 ? o : null,
302
- props: i
306
+ key: c,
307
+ ref: i !== void 0 ? i : null,
308
+ props: a
303
309
  };
304
310
  }
305
- return R.Fragment = n, R.jsx = r, R.jsxs = r, R;
311
+ return A.Fragment = n, A.jsx = r, A.jsxs = r, A;
306
312
  }
307
313
  var T = {};
308
314
  /**
@@ -314,47 +320,47 @@ var T = {};
314
320
  * This source code is licensed under the MIT license found in the
315
321
  * LICENSE file in the root directory of this source tree.
316
322
  */
317
- var X;
318
- function ke() {
319
- return X || (X = 1, process.env.NODE_ENV !== "production" && (function() {
323
+ var H;
324
+ function _e() {
325
+ return H || (H = 1, process.env.NODE_ENV !== "production" && (function() {
320
326
  function e(t) {
321
327
  if (t == null) return null;
322
328
  if (typeof t == "function")
323
- return t.$$typeof === ae ? null : t.displayName || t.name || null;
329
+ return t.$$typeof === ue ? null : t.displayName || t.name || null;
324
330
  if (typeof t == "string") return t;
325
331
  switch (t) {
326
- case C:
332
+ case O:
327
333
  return "Fragment";
328
- case Q:
334
+ case re:
329
335
  return "Profiler";
330
- case Z:
336
+ case te:
331
337
  return "StrictMode";
332
- case ne:
338
+ case ie:
333
339
  return "Suspense";
334
- case se:
340
+ case ae:
335
341
  return "SuspenseList";
336
- case ie:
342
+ case le:
337
343
  return "Activity";
338
344
  }
339
345
  if (typeof t == "object")
340
346
  switch (typeof t.tag == "number" && console.error(
341
347
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
342
348
  ), t.$$typeof) {
343
- case K:
349
+ case ee:
344
350
  return "Portal";
345
- case te:
351
+ case se:
346
352
  return (t.displayName || "Context") + ".Provider";
347
- case ee:
353
+ case ne:
348
354
  return (t._context.displayName || "Context") + ".Consumer";
349
- case re:
350
- var a = t.render;
351
- return t = t.displayName, t || (t = a.displayName || a.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
352
355
  case oe:
353
- return a = t.displayName || null, a !== null ? a : e(t.type) || "Memo";
354
- case F:
355
- a = t._payload, t = t._init;
356
+ var o = t.render;
357
+ return t = t.displayName, t || (t = o.displayName || o.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
358
+ case ce:
359
+ return o = t.displayName || null, o !== null ? o : e(t.type) || "Memo";
360
+ case q:
361
+ o = t._payload, t = t._init;
356
362
  try {
357
- return e(t(a));
363
+ return e(t(o));
358
364
  } catch {
359
365
  }
360
366
  }
@@ -366,50 +372,50 @@ function ke() {
366
372
  function r(t) {
367
373
  try {
368
374
  n(t);
369
- var a = !1;
375
+ var o = !1;
370
376
  } catch {
371
- a = !0;
377
+ o = !0;
372
378
  }
373
- if (a) {
374
- a = console;
375
- var d = a.error, f = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
379
+ if (o) {
380
+ o = console;
381
+ var d = o.error, f = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
376
382
  return d.call(
377
- a,
383
+ o,
378
384
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
379
385
  f
380
386
  ), n(t);
381
387
  }
382
388
  }
383
389
  function s(t) {
384
- if (t === C) return "<>";
385
- if (typeof t == "object" && t !== null && t.$$typeof === F)
390
+ if (t === O) return "<>";
391
+ if (typeof t == "object" && t !== null && t.$$typeof === q)
386
392
  return "<...>";
387
393
  try {
388
- var a = e(t);
389
- return a ? "<" + a + ">" : "<...>";
394
+ var o = e(t);
395
+ return o ? "<" + o + ">" : "<...>";
390
396
  } catch {
391
397
  return "<...>";
392
398
  }
393
399
  }
394
- function o() {
395
- var t = O.A;
400
+ function i() {
401
+ var t = P.A;
396
402
  return t === null ? null : t.getOwner();
397
403
  }
398
- function i() {
404
+ function a() {
399
405
  return Error("react-stack-top-frame");
400
406
  }
401
- function l(t) {
402
- if (z.call(t, "key")) {
403
- var a = Object.getOwnPropertyDescriptor(t, "key").get;
404
- if (a && a.isReactWarning) return !1;
407
+ function c(t) {
408
+ if (F.call(t, "key")) {
409
+ var o = Object.getOwnPropertyDescriptor(t, "key").get;
410
+ if (o && o.isReactWarning) return !1;
405
411
  }
406
412
  return t.key !== void 0;
407
413
  }
408
- function u(t, a) {
414
+ function u(t, o) {
409
415
  function d() {
410
- B || (B = !0, console.error(
416
+ z || (z = !0, console.error(
411
417
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
412
- a
418
+ o
413
419
  ));
414
420
  }
415
421
  d.isReactWarning = !0, Object.defineProperty(t, "key", {
@@ -417,22 +423,22 @@ function ke() {
417
423
  configurable: !0
418
424
  });
419
425
  }
420
- function h() {
426
+ function b() {
421
427
  var t = e(this.type);
422
- return M[t] || (M[t] = !0, console.error(
428
+ return B[t] || (B[t] = !0, console.error(
423
429
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
424
430
  )), t = this.props.ref, t !== void 0 ? t : null;
425
431
  }
426
- function x(t, a, d, f, w, g, N, L) {
432
+ function x(t, o, d, f, w, g, L, W) {
427
433
  return d = g.ref, t = {
428
- $$typeof: U,
434
+ $$typeof: M,
429
435
  type: t,
430
- key: a,
436
+ key: o,
431
437
  props: g,
432
438
  _owner: w
433
439
  }, (d !== void 0 ? d : null) !== null ? Object.defineProperty(t, "ref", {
434
440
  enumerable: !1,
435
- get: h
441
+ get: b
436
442
  }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
437
443
  configurable: !1,
438
444
  enumerable: !1,
@@ -447,33 +453,33 @@ function ke() {
447
453
  configurable: !1,
448
454
  enumerable: !1,
449
455
  writable: !0,
450
- value: N
456
+ value: L
451
457
  }), Object.defineProperty(t, "_debugTask", {
452
458
  configurable: !1,
453
459
  enumerable: !1,
454
460
  writable: !0,
455
- value: L
461
+ value: W
456
462
  }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
457
463
  }
458
- function m(t, a, d, f, w, g, N, L) {
459
- var p = a.children;
464
+ function h(t, o, d, f, w, g, L, W) {
465
+ var p = o.children;
460
466
  if (p !== void 0)
461
467
  if (f)
462
- if (ce(p)) {
468
+ if (de(p)) {
463
469
  for (f = 0; f < p.length; f++)
464
- v(p[f]);
470
+ y(p[f]);
465
471
  Object.freeze && Object.freeze(p);
466
472
  } else
467
473
  console.error(
468
474
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
469
475
  );
470
- else v(p);
471
- if (z.call(a, "key")) {
476
+ else y(p);
477
+ if (F.call(o, "key")) {
472
478
  p = e(t);
473
- var k = Object.keys(a).filter(function(le) {
474
- return le !== "key";
479
+ var k = Object.keys(o).filter(function(fe) {
480
+ return fe !== "key";
475
481
  });
476
- f = 0 < k.length ? "{key: someKey, " + k.join(": ..., ") + ": ...}" : "{key: someKey}", J[p + f] || (k = 0 < k.length ? "{" + k.join(": ..., ") + ": ...}" : "{}", console.error(
482
+ f = 0 < k.length ? "{key: someKey, " + k.join(": ..., ") + ": ...}" : "{key: someKey}", G[p + f] || (k = 0 < k.length ? "{" + k.join(": ..., ") + ": ...}" : "{}", console.error(
477
483
  `A props object containing a "key" prop is being spread into JSX:
478
484
  let props = %s;
479
485
  <%s {...props} />
@@ -484,13 +490,13 @@ React keys must be passed directly to JSX without using spread:
484
490
  p,
485
491
  k,
486
492
  p
487
- ), J[p + f] = !0);
493
+ ), G[p + f] = !0);
488
494
  }
489
- if (p = null, d !== void 0 && (r(d), p = "" + d), l(a) && (r(a.key), p = "" + a.key), "key" in a) {
495
+ if (p = null, d !== void 0 && (r(d), p = "" + d), c(o) && (r(o.key), p = "" + o.key), "key" in o) {
490
496
  d = {};
491
- for (var W in a)
492
- W !== "key" && (d[W] = a[W]);
493
- } else d = a;
497
+ for (var I in o)
498
+ I !== "key" && (d[I] = o[I]);
499
+ } else d = o;
494
500
  return p && u(
495
501
  d,
496
502
  typeof t == "function" ? t.displayName || t.name || "Unknown" : t
@@ -499,74 +505,74 @@ React keys must be passed directly to JSX without using spread:
499
505
  p,
500
506
  g,
501
507
  w,
502
- o(),
508
+ i(),
503
509
  d,
504
- N,
505
- L
510
+ L,
511
+ W
506
512
  );
507
513
  }
508
- function v(t) {
509
- typeof t == "object" && t !== null && t.$$typeof === U && t._store && (t._store.validated = 1);
514
+ function y(t) {
515
+ typeof t == "object" && t !== null && t.$$typeof === M && t._store && (t._store.validated = 1);
510
516
  }
511
- var S = ue, U = Symbol.for("react.transitional.element"), K = Symbol.for("react.portal"), C = Symbol.for("react.fragment"), Z = Symbol.for("react.strict_mode"), Q = Symbol.for("react.profiler"), ee = Symbol.for("react.consumer"), te = Symbol.for("react.context"), re = Symbol.for("react.forward_ref"), ne = Symbol.for("react.suspense"), se = Symbol.for("react.suspense_list"), oe = Symbol.for("react.memo"), F = Symbol.for("react.lazy"), ie = Symbol.for("react.activity"), ae = Symbol.for("react.client.reference"), O = S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, z = Object.prototype.hasOwnProperty, ce = Array.isArray, P = console.createTask ? console.createTask : function() {
517
+ var _ = pe, M = Symbol.for("react.transitional.element"), ee = Symbol.for("react.portal"), O = Symbol.for("react.fragment"), te = Symbol.for("react.strict_mode"), re = Symbol.for("react.profiler"), ne = Symbol.for("react.consumer"), se = Symbol.for("react.context"), oe = Symbol.for("react.forward_ref"), ie = Symbol.for("react.suspense"), ae = Symbol.for("react.suspense_list"), ce = Symbol.for("react.memo"), q = Symbol.for("react.lazy"), le = Symbol.for("react.activity"), ue = Symbol.for("react.client.reference"), P = _.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, F = Object.prototype.hasOwnProperty, de = Array.isArray, N = console.createTask ? console.createTask : function() {
512
518
  return null;
513
519
  };
514
- S = {
520
+ _ = {
515
521
  react_stack_bottom_frame: function(t) {
516
522
  return t();
517
523
  }
518
524
  };
519
- var B, M = {}, q = S.react_stack_bottom_frame.bind(
520
- S,
521
- i
522
- )(), V = P(s(i)), J = {};
523
- T.Fragment = C, T.jsx = function(t, a, d, f, w) {
524
- var g = 1e4 > O.recentlyCreatedOwnerStacks++;
525
- return m(
525
+ var z, B = {}, V = _.react_stack_bottom_frame.bind(
526
+ _,
527
+ a
528
+ )(), J = N(s(a)), G = {};
529
+ T.Fragment = O, T.jsx = function(t, o, d, f, w) {
530
+ var g = 1e4 > P.recentlyCreatedOwnerStacks++;
531
+ return h(
526
532
  t,
527
- a,
533
+ o,
528
534
  d,
529
535
  !1,
530
536
  f,
531
537
  w,
532
- g ? Error("react-stack-top-frame") : q,
533
- g ? P(s(t)) : V
538
+ g ? Error("react-stack-top-frame") : V,
539
+ g ? N(s(t)) : J
534
540
  );
535
- }, T.jsxs = function(t, a, d, f, w) {
536
- var g = 1e4 > O.recentlyCreatedOwnerStacks++;
537
- return m(
541
+ }, T.jsxs = function(t, o, d, f, w) {
542
+ var g = 1e4 > P.recentlyCreatedOwnerStacks++;
543
+ return h(
538
544
  t,
539
- a,
545
+ o,
540
546
  d,
541
547
  !0,
542
548
  f,
543
549
  w,
544
- g ? Error("react-stack-top-frame") : q,
545
- g ? P(s(t)) : V
550
+ g ? Error("react-stack-top-frame") : V,
551
+ g ? N(s(t)) : J
546
552
  );
547
553
  };
548
554
  })()), T;
549
555
  }
550
- var H;
551
- function Re() {
552
- return H || (H = 1, process.env.NODE_ENV === "production" ? _.exports = ve() : _.exports = ke()), _.exports;
556
+ var K;
557
+ function Se() {
558
+ return K || (K = 1, process.env.NODE_ENV === "production" ? S.exports = je() : S.exports = _e()), S.exports;
553
559
  }
554
- var c = Re();
555
- const Te = (e) => {
560
+ var l = Se();
561
+ const $e = (e) => {
556
562
  const n = { children: [] };
557
563
  for (const r of e) {
558
564
  let s = n;
559
- r.suite.forEach((o) => {
560
- let i = s.children.find(
561
- (l) => "name" in l && !l.status && l.name === o
565
+ r.suite.forEach((i) => {
566
+ let a = s.children.find(
567
+ (c) => "name" in c && !c.status && c.name === i
562
568
  );
563
- i || (i = { name: o, children: [] }, s.children.push(i)), s = i;
569
+ a || (a = { name: i, children: [] }, s.children.push(a)), s = a;
564
570
  }), s.children.push(r);
565
571
  }
566
572
  return n.children;
567
- }, Ae = {
573
+ }, Ce = {
568
574
  animation: "spin 1s linear infinite"
569
- }, je = () => /* @__PURE__ */ c.jsx(
575
+ }, Oe = () => /* @__PURE__ */ l.jsx(
570
576
  "svg",
571
577
  {
572
578
  xmlns: "http://www.w3.org/2000/svg",
@@ -579,8 +585,9 @@ const Te = (e) => {
579
585
  strokeLinecap: "round",
580
586
  strokeLinejoin: "round",
581
587
  className: "lucide lucide-loader-circle-icon lucide-loader-circle",
582
- style: Ae,
583
- children: /* @__PURE__ */ c.jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
588
+ style: Ce,
589
+ "data-testid": "loader-icon",
590
+ children: /* @__PURE__ */ l.jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
584
591
  }
585
592
  ), $ = typeof document < "u" ? document.createElement("style") : null;
586
593
  $ && !document.getElementById("loader-spin-keyframes") && ($.id = "loader-spin-keyframes", $.innerHTML = `
@@ -589,7 +596,7 @@ $ && !document.getElementById("loader-spin-keyframes") && ($.id = "loader-spin-k
589
596
  100% { transform: rotate(360deg); }
590
597
  }
591
598
  `, document.head.appendChild($));
592
- const Se = () => /* @__PURE__ */ c.jsx(
599
+ const Pe = () => /* @__PURE__ */ l.jsx(
593
600
  "svg",
594
601
  {
595
602
  xmlns: "http://www.w3.org/2000/svg",
@@ -602,9 +609,10 @@ const Se = () => /* @__PURE__ */ c.jsx(
602
609
  strokeLinecap: "round",
603
610
  strokeLinejoin: "round",
604
611
  className: "lucide lucide-play-icon lucide-play",
605
- children: /* @__PURE__ */ c.jsx("path", { d: "M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z" })
612
+ "data-testid": "play-icon",
613
+ children: /* @__PURE__ */ l.jsx("path", { d: "M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z" })
606
614
  }
607
- ), _e = (e) => {
615
+ ), Ne = (e) => {
608
616
  switch (e.status) {
609
617
  case "pass":
610
618
  return {
@@ -643,10 +651,10 @@ const Se = () => /* @__PURE__ */ c.jsx(
643
651
  }
644
652
  };
645
653
  }
646
- }, $e = (e) => e.startsWith("Assertion passed") ? { color: "#0d542b", fontWeight: "700" } : e.startsWith("Test failed") ? { color: "#fb2c36", fontWeight: "700" } : {}, Ce = ({ node: e, depth: n, idx: r, runTest: s }) => {
647
- const o = _e(e);
648
- return /* @__PURE__ */ c.jsxs("li", { style: { marginBottom: "4px", marginLeft: n * 6, ...o.container }, children: [
649
- /* @__PURE__ */ c.jsxs(
654
+ }, Le = (e) => e.startsWith("Assertion passed") ? { color: "#0d542b", fontWeight: "700" } : e.startsWith("Test failed") ? { color: "#fb2c36", fontWeight: "700" } : {}, We = ({ node: e, depth: n, idx: r, runTest: s }) => {
655
+ const i = Ne(e);
656
+ return /* @__PURE__ */ l.jsxs("li", { style: { marginBottom: "4px", marginLeft: n * 6, ...i.container }, "data-testid": `test-list-item-${r}`, children: [
657
+ /* @__PURE__ */ l.jsxs(
650
658
  "div",
651
659
  {
652
660
  style: {
@@ -655,17 +663,16 @@ const Se = () => /* @__PURE__ */ c.jsx(
655
663
  justifyContent: "space-between",
656
664
  padding: "4px 6px",
657
665
  borderRadius: "4px",
658
- ...o.item
666
+ ...i.item
659
667
  },
660
668
  children: [
661
- /* @__PURE__ */ c.jsxs("span", { style: { fontWeight: "500", color: "#374151", maxWidth: "220px" }, children: [
669
+ /* @__PURE__ */ l.jsxs("span", { style: { fontWeight: "500", color: "#374151", maxWidth: "220px" }, children: [
662
670
  e.name,
663
671
  " ",
664
- e.status,
665
- e.only && /* @__PURE__ */ c.jsx("span", { style: { color: "#2563eb" }, children: "(only)" }),
666
- e.skip && /* @__PURE__ */ c.jsx("span", { style: { color: "#6b7280" }, children: "(skipped)" })
672
+ e.only && /* @__PURE__ */ l.jsx("span", { style: { color: "#2563eb" }, "data-testid": `only-indicator-${r}`, children: " (only)" }),
673
+ e.skip && /* @__PURE__ */ l.jsx("span", { style: { color: "#6b7280" }, "data-testid": `skip-indicator-${r}`, children: " (skipped)" })
667
674
  ] }),
668
- /* @__PURE__ */ c.jsx(
675
+ /* @__PURE__ */ l.jsx(
669
676
  "button",
670
677
  {
671
678
  onClick: () => s(r),
@@ -685,13 +692,14 @@ const Se = () => /* @__PURE__ */ c.jsx(
685
692
  justifyContent: "center"
686
693
  },
687
694
  disabled: e.status === "running",
688
- children: e.status === "running" ? /* @__PURE__ */ c.jsx(je, {}) : /* @__PURE__ */ c.jsx(Se, {})
695
+ "data-testid": `run-test-button-${r}`,
696
+ children: e.status === "running" ? /* @__PURE__ */ l.jsx(Oe, {}) : /* @__PURE__ */ l.jsx(Pe, {})
689
697
  }
690
698
  )
691
699
  ]
692
700
  }
693
701
  ),
694
- e.logs && e.logs.length > 0 && /* @__PURE__ */ c.jsx(
702
+ e.logs && e.logs.length > 0 && /* @__PURE__ */ l.jsx(
695
703
  "ul",
696
704
  {
697
705
  style: {
@@ -704,23 +712,23 @@ const Se = () => /* @__PURE__ */ c.jsx(
704
712
  marginTop: "4px",
705
713
  textAlign: "left"
706
714
  },
707
- children: e.logs.map((i, l) => /* @__PURE__ */ c.jsx(
715
+ children: e.logs.map((a, c) => /* @__PURE__ */ l.jsx(
708
716
  "li",
709
717
  {
710
718
  style: {
711
719
  fontSize: "12px",
712
720
  padding: "4px 6px",
713
721
  borderBottom: "1px solid #d1d5db",
714
- ...$e(i)
722
+ ...Le(a)
715
723
  },
716
- children: i
724
+ children: a
717
725
  },
718
- l
726
+ c
719
727
  ))
720
728
  }
721
729
  )
722
730
  ] }, e.name);
723
- }, Oe = () => /* @__PURE__ */ c.jsx(
731
+ }, Ie = () => /* @__PURE__ */ l.jsx(
724
732
  "svg",
725
733
  {
726
734
  xmlns: "http://www.w3.org/2000/svg",
@@ -733,9 +741,10 @@ const Se = () => /* @__PURE__ */ c.jsx(
733
741
  strokeLinecap: "round",
734
742
  strokeLinejoin: "round",
735
743
  className: "lucide lucide-chevron-down-icon lucide-chevron-down",
736
- children: /* @__PURE__ */ c.jsx("path", { d: "m6 9 6 6 6-6" })
744
+ "data-testid": "chevron-down-icon",
745
+ children: /* @__PURE__ */ l.jsx("path", { d: "m6 9 6 6 6-6" })
737
746
  }
738
- ), Pe = () => /* @__PURE__ */ c.jsx(
747
+ ), De = () => /* @__PURE__ */ l.jsx(
739
748
  "svg",
740
749
  {
741
750
  xmlns: "http://www.w3.org/2000/svg",
@@ -748,15 +757,16 @@ const Se = () => /* @__PURE__ */ c.jsx(
748
757
  strokeLinecap: "round",
749
758
  strokeLinejoin: "round",
750
759
  className: "lucide lucide-chevron-right-icon lucide-chevron-right",
751
- children: /* @__PURE__ */ c.jsx("path", { d: "m9 18 6-6-6-6" })
760
+ "data-testid": "chevron-right-icon",
761
+ children: /* @__PURE__ */ l.jsx("path", { d: "m9 18 6-6-6-6" })
752
762
  }
753
- ), Ne = ({ runTest: e, tests: n }) => {
754
- const [r, s] = I({}), o = (l, u = 0) => {
755
- if ("status" in l)
756
- return /* @__PURE__ */ c.jsx(Ce, { node: l, depth: u, idx: n.indexOf(l), runTest: e }, l.name);
757
- const h = r[l.name];
758
- return /* @__PURE__ */ c.jsxs("li", { style: { marginBottom: "6px", marginLeft: u * 12, textAlign: "left" }, children: [
759
- /* @__PURE__ */ c.jsxs(
763
+ ), Ye = ({ runTest: e, tests: n }) => {
764
+ const [r, s] = D({}), i = (c, u = 0) => {
765
+ if ("status" in c)
766
+ return /* @__PURE__ */ l.jsx(We, { node: c, depth: u, idx: n.indexOf(c), runTest: e }, c.name);
767
+ const b = r[c.name];
768
+ return /* @__PURE__ */ l.jsxs("li", { style: { marginBottom: "6px", marginLeft: u * 12, textAlign: "left" }, children: [
769
+ /* @__PURE__ */ l.jsxs(
760
770
  "div",
761
771
  {
762
772
  style: {
@@ -768,19 +778,23 @@ const Se = () => /* @__PURE__ */ c.jsx(
768
778
  alignItems: "center",
769
779
  gap: "4px"
770
780
  },
771
- onClick: () => s((x) => ({ ...x, [l.name]: !x[l.name] })),
781
+ onClick: () => s((x) => ({ ...x, [c.name]: !x[c.name] })),
782
+ "data-testid": `test-group-${c.name}`,
783
+ tabIndex: 0,
784
+ role: "button",
785
+ "aria-expanded": !b,
772
786
  children: [
773
- l.name,
787
+ c.name,
774
788
  " ",
775
- h ? /* @__PURE__ */ c.jsx(Pe, {}) : /* @__PURE__ */ c.jsx(Oe, {})
789
+ b ? /* @__PURE__ */ l.jsx(De, {}) : /* @__PURE__ */ l.jsx(Ie, {})
776
790
  ]
777
791
  }
778
792
  ),
779
- !h && /* @__PURE__ */ c.jsx("ul", { style: { listStyle: "none", padding: 0 }, children: l.children.map((x) => o(x, u + 1)) })
780
- ] }, l.name);
781
- }, i = Te(n);
782
- return /* @__PURE__ */ c.jsx("ul", { style: { listStyle: "none", padding: 0, margin: 0 }, children: i.map((l) => o(l)) });
783
- }, Le = ({ setOpen: e }) => /* @__PURE__ */ c.jsx(
793
+ !b && /* @__PURE__ */ l.jsx("ul", { style: { listStyle: "none", padding: 0 }, children: c.children.map((x) => i(x, u + 1)) })
794
+ ] }, c.name);
795
+ }, a = $e(n);
796
+ return /* @__PURE__ */ l.jsx("ul", { style: { listStyle: "none", padding: 0, margin: 0 }, children: a.map((c) => i(c)) });
797
+ }, Ue = ({ setOpen: e }) => /* @__PURE__ */ l.jsx(
784
798
  "div",
785
799
  {
786
800
  style: {
@@ -797,34 +811,34 @@ const Se = () => /* @__PURE__ */ c.jsx(
797
811
  fontSize: "12px"
798
812
  },
799
813
  onClick: () => e(!0),
800
- children: "TWD"
814
+ children: "TWD"
801
815
  }
802
- ), Be = () => {
803
- const [e, n] = I(0), [r, s] = I(!0), o = async (l) => {
804
- const u = E[l];
816
+ ), Ge = () => {
817
+ const [e, n] = D(0), [r, s] = D(!0), i = async (c) => {
818
+ const u = v[c];
805
819
  u.logs = [];
806
- const h = console.log, x = console.error;
807
- if (console.log = (...m) => {
808
- u.logs?.push(m.map(String).join(" ")), h(...m), n((v) => v + 1);
809
- }, console.error = (...m) => {
810
- u.logs?.push(m.map(String).join(" ")), x(...m), n((v) => v + 1);
820
+ const b = console.log, x = console.error;
821
+ if (console.log = (...h) => {
822
+ u.logs?.push(h.map(String).join(" ")), b(...h), n((y) => y + 1);
823
+ }, console.error = (...h) => {
824
+ u.logs?.push(h.map(String).join(" ")), x(...h), n((y) => y + 1);
811
825
  }, u.status = "running", u.skip)
812
826
  u.status = "skip";
813
827
  else
814
828
  try {
815
829
  await u.fn(), u.status = "pass";
816
- } catch (m) {
817
- u.status = "fail", console.error("Test failed:", u.name, m);
830
+ } catch (h) {
831
+ u.status = "fail", console.error("Test failed:", u.name, h);
818
832
  }
819
- console.log = h, console.error = x, n((m) => m + 1);
820
- }, i = async () => {
821
- const l = E.filter((h) => h.only), u = l.length > 0 ? l : E;
822
- for (let h = 0; h < u.length; h++) {
823
- const x = E.indexOf(u[h]);
824
- await o(x);
833
+ console.log = b, console.error = x, n((h) => h + 1);
834
+ }, a = async () => {
835
+ const c = v.filter((b) => b.only), u = c.length > 0 ? c : v;
836
+ for (let b = 0; b < u.length; b++) {
837
+ const x = v.indexOf(u[b]);
838
+ await i(x);
825
839
  }
826
840
  };
827
- return r ? /* @__PURE__ */ c.jsxs(
841
+ return r ? /* @__PURE__ */ l.jsxs(
828
842
  "div",
829
843
  {
830
844
  style: {
@@ -842,8 +856,8 @@ const Se = () => /* @__PURE__ */ c.jsx(
842
856
  boxShadow: "2px 0 6px rgba(0,0,0,0.1)"
843
857
  },
844
858
  children: [
845
- /* @__PURE__ */ c.jsxs("div", { style: { display: "flex", justifyContent: "space-between", marginBottom: "14px", alignItems: "center" }, children: [
846
- /* @__PURE__ */ c.jsx(
859
+ /* @__PURE__ */ l.jsxs("div", { style: { display: "flex", justifyContent: "space-between", marginBottom: "14px", alignItems: "center" }, children: [
860
+ /* @__PURE__ */ l.jsx(
847
861
  "strong",
848
862
  {
849
863
  style: {
@@ -854,7 +868,7 @@ const Se = () => /* @__PURE__ */ c.jsx(
854
868
  children: "TWD Tests"
855
869
  }
856
870
  ),
857
- /* @__PURE__ */ c.jsx(
871
+ /* @__PURE__ */ l.jsx(
858
872
  "button",
859
873
  {
860
874
  style: {
@@ -868,10 +882,10 @@ const Se = () => /* @__PURE__ */ c.jsx(
868
882
  }
869
883
  )
870
884
  ] }),
871
- /* @__PURE__ */ c.jsx(
885
+ /* @__PURE__ */ l.jsx(
872
886
  "button",
873
887
  {
874
- onClick: i,
888
+ onClick: a,
875
889
  style: {
876
890
  background: "#3b82f6",
877
891
  color: "white",
@@ -884,17 +898,17 @@ const Se = () => /* @__PURE__ */ c.jsx(
884
898
  children: "Run All"
885
899
  }
886
900
  ),
887
- /* @__PURE__ */ c.jsx(Ne, { tests: E, runTest: o })
901
+ /* @__PURE__ */ l.jsx(Ye, { tests: v, runTest: i })
888
902
  ]
889
903
  }
890
- ) : /* @__PURE__ */ c.jsx(Le, { setOpen: s });
904
+ ) : /* @__PURE__ */ l.jsx(Ue, { setOpen: s });
891
905
  };
892
906
  export {
893
- Be as TWDSidebar,
894
- Ie as beforeEach,
895
- Ye as describe,
896
- De as it,
897
- Ue as itOnly,
898
- Fe as itSkip,
899
- ze as twd
907
+ Ge as TWDSidebar,
908
+ qe as beforeEach,
909
+ Fe as describe,
910
+ ze as it,
911
+ Be as itOnly,
912
+ Ve as itSkip,
913
+ Je as twd
900
914
  };