@storybook/addon-vitest 0.0.0-pr-32717-sha-b8c5e103 → 0.0.0-pr-32795-sha-2df3d620

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/manager.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  ADDON_ID,
3
3
  ADDON_ID2,
4
+ ADDON_TEST_CHANNEL,
4
5
  DOCUMENTATION_FATAL_ERROR_LINK,
5
6
  FULL_RUN_TRIGGERS,
6
7
  PANEL_ID,
@@ -9,10 +10,7 @@ import {
9
10
  STATUS_TYPE_ID_COMPONENT_TEST,
10
11
  TEST_PROVIDER_ID,
11
12
  storeOptions
12
- } from "./_browser-chunks/chunk-RPDOPHZX.js";
13
- import {
14
- __name
15
- } from "./_browser-chunks/chunk-JK72E6FR.js";
13
+ } from "./_browser-chunks/chunk-OAEB4TPN.js";
16
14
 
17
15
  // src/manager.tsx
18
16
  import React5, { useState as useState3 } from "react";
@@ -27,10 +25,7 @@ import {
27
25
  var store = experimental_UniversalStore.create({
28
26
  ...storeOptions,
29
27
  leader: globalThis.CONFIG_TYPE === "PRODUCTION"
30
- });
31
- var componentTestStatusStore = experimental_getStatusStore(STATUS_TYPE_ID_COMPONENT_TEST);
32
- var a11yStatusStore = experimental_getStatusStore(STATUS_TYPE_ID_A11Y);
33
- var testProviderStore = experimental_getTestProviderStore(ADDON_ID2);
28
+ }), componentTestStatusStore = experimental_getStatusStore(STATUS_TYPE_ID_COMPONENT_TEST), a11yStatusStore = experimental_getStatusStore(STATUS_TYPE_ID_A11Y), testProviderStore = experimental_getTestProviderStore(ADDON_ID2);
34
29
 
35
30
  // src/manager.tsx
36
31
  import { addons as addons2 } from "storybook/manager-api";
@@ -46,58 +41,44 @@ var ModalBar = styled.div({
46
41
  justifyContent: "space-between",
47
42
  alignItems: "center",
48
43
  padding: "6px 6px 6px 20px"
49
- });
50
- var ModalActionBar = styled.div({
44
+ }), ModalActionBar = styled.div({
51
45
  display: "flex",
52
46
  justifyContent: "space-between",
53
47
  alignItems: "center"
54
- });
55
- var ModalTitle = styled(Modal.Title)(({ theme: { typography } }) => ({
48
+ }), ModalTitle = styled(Modal.Title)(({ theme: { typography } }) => ({
56
49
  fontSize: typography.size.s2,
57
50
  fontWeight: typography.weight.bold
58
- }));
59
- var ModalStackTrace = styled.pre(({ theme }) => ({
51
+ })), ModalStackTrace = styled.pre(({ theme }) => ({
60
52
  whiteSpace: "pre-wrap",
61
53
  wordWrap: "break-word",
62
54
  overflow: "auto",
63
55
  maxHeight: "60vh",
64
56
  margin: 0,
65
- padding: `20px`,
57
+ padding: "20px",
66
58
  fontFamily: theme.typography.fonts.mono,
67
59
  fontSize: "12px",
68
60
  borderTop: `1px solid ${theme.appBorderColor}`,
69
61
  borderRadius: 0
70
- }));
71
- var TroubleshootLink = styled.a(({ theme }) => ({
62
+ })), TroubleshootLink = styled.a(({ theme }) => ({
72
63
  color: theme.color.defaultText
73
- }));
74
- var GlobalErrorContext = React.createContext({
75
- isModalOpen: false,
64
+ })), GlobalErrorContext = React.createContext({
65
+ isModalOpen: !1,
76
66
  setModalOpen: void 0
77
67
  });
78
68
  function ErrorCause({ error }) {
79
- if (!error) {
80
- return null;
81
- }
82
- return React.createElement("div", null, React.createElement("h4", null, "Caused by: ", error.name || "Error", ": ", error.message), error.stack && React.createElement("pre", null, error.stack), error.cause && React.createElement(ErrorCause, { error: error.cause }));
69
+ return error ? React.createElement("div", null, React.createElement("h4", null, "Caused by: ", error.name || "Error", ": ", error.message), error.stack && React.createElement("pre", null, error.stack), error.cause && React.createElement(ErrorCause, { error: error.cause })) : null;
83
70
  }
84
- __name(ErrorCause, "ErrorCause");
85
71
  function GlobalErrorModal({ onRerun, storeState }) {
86
- const api = useStorybookApi();
87
- const { isModalOpen, setModalOpen } = useContext(GlobalErrorContext);
88
- const troubleshootURL = api.getDocsUrl({
72
+ let api = useStorybookApi(), { isModalOpen, setModalOpen } = useContext(GlobalErrorContext), troubleshootURL = api.getDocsUrl({
89
73
  subpath: DOCUMENTATION_FATAL_ERROR_LINK,
90
- versioned: true,
91
- renderer: true
92
- });
93
- const {
74
+ versioned: !0,
75
+ renderer: !0
76
+ }), {
94
77
  fatalError,
95
78
  currentRun: { unhandledErrors }
96
- } = storeState;
97
- const content = fatalError ? React.createElement(React.Fragment, null, React.createElement("p", null, fatalError.error.name || "Error"), fatalError.message && React.createElement("p", null, fatalError.message), fatalError.error.message && React.createElement("p", null, fatalError.error.message), fatalError.error.stack && React.createElement("p", null, fatalError.error.stack), fatalError.error.cause && React.createElement(ErrorCause, { error: fatalError.error.cause })) : unhandledErrors.length > 0 ? React.createElement("ol", null, unhandledErrors.map((error) => React.createElement("li", { key: error.name + error.message }, React.createElement("p", null, error.name, ": ", error.message), error.VITEST_TEST_PATH && React.createElement("p", null, 'This error originated in "', React.createElement("b", null, error.VITEST_TEST_PATH), `". It doesn't mean the error was thrown inside the file itself, but while it was running.`), error.VITEST_TEST_NAME && React.createElement(React.Fragment, null, React.createElement("p", null, `The latest test that might've caused the error is "`, React.createElement("b", null, error.VITEST_TEST_NAME), '". It might mean one of the following:'), React.createElement("ul", null, React.createElement("li", null, "The error was thrown, while Vitest was running this test."), React.createElement("li", null, "If the error occurred after the test had been completed, this was the last documented test before it was thrown."))), error.stacks && React.createElement(React.Fragment, null, React.createElement("p", null, React.createElement("b", null, "Stacks:")), React.createElement("ul", null, error.stacks.map((stack) => React.createElement("li", { key: stack.file + stack.line + stack.column }, stack.file, ":", stack.line, ":", stack.column, " - ", stack.method || "unknown method")))), error.stack && React.createElement("p", null, error.stack), error.cause ? React.createElement(ErrorCause, { error: error.cause }) : null))) : null;
98
- return React.createElement(Modal, { ariaLabel: "Storybook Tests error details", onOpenChange: setModalOpen, open: isModalOpen }, React.createElement(ModalBar, null, React.createElement(ModalTitle, null, "Storybook Tests error details"), React.createElement(ModalActionBar, null, React.createElement(Button, { onClick: onRerun, variant: "ghost", ariaLabel: false }, React.createElement(SyncIcon, null), "Rerun"), React.createElement(Button, { variant: "ghost", ariaLabel: false, asChild: true }, React.createElement("a", { target: "_blank", href: troubleshootURL, rel: "noreferrer" }, "Troubleshoot")), React.createElement(Modal.Close, null))), React.createElement(ModalStackTrace, null, content, React.createElement("br", null), React.createElement("br", null), "Troubleshoot:", " ", React.createElement(TroubleshootLink, { target: "_blank", href: troubleshootURL }, troubleshootURL)));
79
+ } = storeState, content = fatalError ? React.createElement(React.Fragment, null, React.createElement("p", null, fatalError.error.name || "Error"), fatalError.message && React.createElement("p", null, fatalError.message), fatalError.error.message && React.createElement("p", null, fatalError.error.message), fatalError.error.stack && React.createElement("p", null, fatalError.error.stack), fatalError.error.cause && React.createElement(ErrorCause, { error: fatalError.error.cause })) : unhandledErrors.length > 0 ? React.createElement("ol", null, unhandledErrors.map((error) => React.createElement("li", { key: error.name + error.message }, React.createElement("p", null, error.name, ": ", error.message), error.VITEST_TEST_PATH && React.createElement("p", null, 'This error originated in "', React.createElement("b", null, error.VITEST_TEST_PATH), `". It doesn't mean the error was thrown inside the file itself, but while it was running.`), error.VITEST_TEST_NAME && React.createElement(React.Fragment, null, React.createElement("p", null, `The latest test that might've caused the error is "`, React.createElement("b", null, error.VITEST_TEST_NAME), '". It might mean one of the following:'), React.createElement("ul", null, React.createElement("li", null, "The error was thrown, while Vitest was running this test."), React.createElement("li", null, "If the error occurred after the test had been completed, this was the last documented test before it was thrown."))), error.stacks && React.createElement(React.Fragment, null, React.createElement("p", null, React.createElement("b", null, "Stacks:")), React.createElement("ul", null, error.stacks.map((stack) => React.createElement("li", { key: stack.file + stack.line + stack.column }, stack.file, ":", stack.line, ":", stack.column, " - ", stack.method || "unknown method")))), error.stack && React.createElement("p", null, error.stack), error.cause ? React.createElement(ErrorCause, { error: error.cause }) : null))) : null;
80
+ return React.createElement(Modal, { ariaLabel: "Storybook Tests error details", onOpenChange: setModalOpen, open: isModalOpen }, React.createElement(ModalBar, null, React.createElement(ModalTitle, null, "Storybook Tests error details"), React.createElement(ModalActionBar, null, React.createElement(Button, { onClick: onRerun, variant: "ghost", ariaLabel: !1 }, React.createElement(SyncIcon, null), "Rerun"), React.createElement(Button, { variant: "ghost", ariaLabel: !1, asChild: !0 }, React.createElement("a", { target: "_blank", href: troubleshootURL, rel: "noreferrer" }, "Troubleshoot")), React.createElement(Modal.Close, null))), React.createElement(ModalStackTrace, null, content, React.createElement("br", null), React.createElement("br", null), "Troubleshoot:", " ", React.createElement(TroubleshootLink, { target: "_blank", href: troubleshootURL }, troubleshootURL)));
99
81
  }
100
- __name(GlobalErrorModal, "GlobalErrorModal");
101
82
 
102
83
  // src/components/SidebarContextMenu.tsx
103
84
  import React4 from "react";
@@ -107,172 +88,103 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
107
88
 
108
89
  // ../../node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
109
90
  function isPlainObject(value) {
110
- if (!value || typeof value !== "object") {
111
- return false;
112
- }
113
- const proto = Object.getPrototypeOf(value);
114
- const hasObjectPrototype = proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null;
115
- if (!hasObjectPrototype) {
116
- return false;
117
- }
118
- return Object.prototype.toString.call(value) === "[object Object]";
91
+ if (!value || typeof value != "object")
92
+ return !1;
93
+ let proto = Object.getPrototypeOf(value);
94
+ return proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null ? Object.prototype.toString.call(value) === "[object Object]" : !1;
119
95
  }
120
- __name(isPlainObject, "isPlainObject");
121
96
 
122
97
  // ../../node_modules/es-toolkit/dist/compat/_internal/getSymbols.mjs
123
98
  function getSymbols(object) {
124
99
  return Object.getOwnPropertySymbols(object).filter((symbol) => Object.prototype.propertyIsEnumerable.call(object, symbol));
125
100
  }
126
- __name(getSymbols, "getSymbols");
127
101
 
128
102
  // ../../node_modules/es-toolkit/dist/compat/_internal/getTag.mjs
129
103
  function getTag(value) {
130
- if (value == null) {
131
- return value === void 0 ? "[object Undefined]" : "[object Null]";
132
- }
133
- return Object.prototype.toString.call(value);
104
+ return value == null ? value === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(value);
134
105
  }
135
- __name(getTag, "getTag");
136
106
 
137
107
  // ../../node_modules/es-toolkit/dist/compat/_internal/tags.mjs
138
- var regexpTag = "[object RegExp]";
139
- var stringTag = "[object String]";
140
- var numberTag = "[object Number]";
141
- var booleanTag = "[object Boolean]";
142
- var argumentsTag = "[object Arguments]";
143
- var symbolTag = "[object Symbol]";
144
- var dateTag = "[object Date]";
145
- var mapTag = "[object Map]";
146
- var setTag = "[object Set]";
147
- var arrayTag = "[object Array]";
148
- var functionTag = "[object Function]";
149
- var arrayBufferTag = "[object ArrayBuffer]";
150
- var objectTag = "[object Object]";
151
- var errorTag = "[object Error]";
152
- var dataViewTag = "[object DataView]";
153
- var uint8ArrayTag = "[object Uint8Array]";
154
- var uint8ClampedArrayTag = "[object Uint8ClampedArray]";
155
- var uint16ArrayTag = "[object Uint16Array]";
156
- var uint32ArrayTag = "[object Uint32Array]";
157
- var bigUint64ArrayTag = "[object BigUint64Array]";
158
- var int8ArrayTag = "[object Int8Array]";
159
- var int16ArrayTag = "[object Int16Array]";
160
- var int32ArrayTag = "[object Int32Array]";
161
- var bigInt64ArrayTag = "[object BigInt64Array]";
162
- var float32ArrayTag = "[object Float32Array]";
163
- var float64ArrayTag = "[object Float64Array]";
108
+ var regexpTag = "[object RegExp]", stringTag = "[object String]", numberTag = "[object Number]", booleanTag = "[object Boolean]", argumentsTag = "[object Arguments]", symbolTag = "[object Symbol]", dateTag = "[object Date]", mapTag = "[object Map]", setTag = "[object Set]", arrayTag = "[object Array]", functionTag = "[object Function]", arrayBufferTag = "[object ArrayBuffer]", objectTag = "[object Object]", errorTag = "[object Error]", dataViewTag = "[object DataView]", uint8ArrayTag = "[object Uint8Array]", uint8ClampedArrayTag = "[object Uint8ClampedArray]", uint16ArrayTag = "[object Uint16Array]", uint32ArrayTag = "[object Uint32Array]", bigUint64ArrayTag = "[object BigUint64Array]", int8ArrayTag = "[object Int8Array]", int16ArrayTag = "[object Int16Array]", int32ArrayTag = "[object Int32Array]", bigInt64ArrayTag = "[object BigInt64Array]", float32ArrayTag = "[object Float32Array]", float64ArrayTag = "[object Float64Array]";
164
109
 
165
110
  // ../../node_modules/es-toolkit/dist/compat/util/eq.mjs
166
111
  function eq(value, other) {
167
112
  return value === other || Number.isNaN(value) && Number.isNaN(other);
168
113
  }
169
- __name(eq, "eq");
170
114
 
171
115
  // ../../node_modules/es-toolkit/dist/predicate/isEqualWith.mjs
172
116
  function isEqualWith(a, b, areValuesEqual) {
173
117
  return isEqualWithImpl(a, b, void 0, void 0, void 0, void 0, areValuesEqual);
174
118
  }
175
- __name(isEqualWith, "isEqualWith");
176
119
  function isEqualWithImpl(a, b, property, aParent, bParent, stack, areValuesEqual) {
177
- const result = areValuesEqual(a, b, property, aParent, bParent, stack);
178
- if (result !== void 0) {
120
+ let result = areValuesEqual(a, b, property, aParent, bParent, stack);
121
+ if (result !== void 0)
179
122
  return result;
180
- }
181
- if (typeof a === typeof b) {
123
+ if (typeof a == typeof b)
182
124
  switch (typeof a) {
183
125
  case "bigint":
184
126
  case "string":
185
127
  case "boolean":
186
128
  case "symbol":
187
- case "undefined": {
129
+ case "undefined":
188
130
  return a === b;
189
- }
190
- case "number": {
131
+ case "number":
191
132
  return a === b || Object.is(a, b);
192
- }
193
- case "function": {
133
+ case "function":
194
134
  return a === b;
195
- }
196
- case "object": {
135
+ case "object":
197
136
  return areObjectsEqual(a, b, stack, areValuesEqual);
198
- }
199
137
  }
200
- }
201
138
  return areObjectsEqual(a, b, stack, areValuesEqual);
202
139
  }
203
- __name(isEqualWithImpl, "isEqualWithImpl");
204
140
  function areObjectsEqual(a, b, stack, areValuesEqual) {
205
- if (Object.is(a, b)) {
206
- return true;
207
- }
208
- let aTag = getTag(a);
209
- let bTag = getTag(b);
210
- if (aTag === argumentsTag) {
211
- aTag = objectTag;
212
- }
213
- if (bTag === argumentsTag) {
214
- bTag = objectTag;
215
- }
216
- if (aTag !== bTag) {
217
- return false;
218
- }
141
+ if (Object.is(a, b))
142
+ return !0;
143
+ let aTag = getTag(a), bTag = getTag(b);
144
+ if (aTag === argumentsTag && (aTag = objectTag), bTag === argumentsTag && (bTag = objectTag), aTag !== bTag)
145
+ return !1;
219
146
  switch (aTag) {
220
147
  case stringTag:
221
148
  return a.toString() === b.toString();
222
149
  case numberTag: {
223
- const x = a.valueOf();
224
- const y = b.valueOf();
150
+ let x = a.valueOf(), y = b.valueOf();
225
151
  return eq(x, y);
226
152
  }
227
153
  case booleanTag:
228
154
  case dateTag:
229
155
  case symbolTag:
230
156
  return Object.is(a.valueOf(), b.valueOf());
231
- case regexpTag: {
157
+ case regexpTag:
232
158
  return a.source === b.source && a.flags === b.flags;
233
- }
234
- case functionTag: {
159
+ case functionTag:
235
160
  return a === b;
236
- }
237
161
  }
238
162
  stack = stack ?? /* @__PURE__ */ new Map();
239
- const aStack = stack.get(a);
240
- const bStack = stack.get(b);
241
- if (aStack != null && bStack != null) {
163
+ let aStack = stack.get(a), bStack = stack.get(b);
164
+ if (aStack != null && bStack != null)
242
165
  return aStack === b;
243
- }
244
- stack.set(a, b);
245
- stack.set(b, a);
166
+ stack.set(a, b), stack.set(b, a);
246
167
  try {
247
168
  switch (aTag) {
248
169
  case mapTag: {
249
- if (a.size !== b.size) {
250
- return false;
251
- }
252
- for (const [key, value] of a.entries()) {
253
- if (!b.has(key) || !isEqualWithImpl(value, b.get(key), key, a, b, stack, areValuesEqual)) {
254
- return false;
255
- }
256
- }
257
- return true;
170
+ if (a.size !== b.size)
171
+ return !1;
172
+ for (let [key, value] of a.entries())
173
+ if (!b.has(key) || !isEqualWithImpl(value, b.get(key), key, a, b, stack, areValuesEqual))
174
+ return !1;
175
+ return !0;
258
176
  }
259
177
  case setTag: {
260
- if (a.size !== b.size) {
261
- return false;
262
- }
263
- const aValues = Array.from(a.values());
264
- const bValues = Array.from(b.values());
178
+ if (a.size !== b.size)
179
+ return !1;
180
+ let aValues = Array.from(a.values()), bValues = Array.from(b.values());
265
181
  for (let i = 0; i < aValues.length; i++) {
266
- const aValue = aValues[i];
267
- const index = bValues.findIndex((bValue) => {
268
- return isEqualWithImpl(aValue, bValue, void 0, a, b, stack, areValuesEqual);
269
- });
270
- if (index === -1) {
271
- return false;
272
- }
182
+ let aValue = aValues[i], index = bValues.findIndex((bValue) => isEqualWithImpl(aValue, bValue, void 0, a, b, stack, areValuesEqual));
183
+ if (index === -1)
184
+ return !1;
273
185
  bValues.splice(index, 1);
274
186
  }
275
- return true;
187
+ return !0;
276
188
  }
277
189
  case arrayTag:
278
190
  case uint8ArrayTag:
@@ -286,78 +198,51 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
286
198
  case bigInt64ArrayTag:
287
199
  case float32ArrayTag:
288
200
  case float64ArrayTag: {
289
- if (typeof Buffer !== "undefined" && Buffer.isBuffer(a) !== Buffer.isBuffer(b)) {
290
- return false;
291
- }
292
- if (a.length !== b.length) {
293
- return false;
294
- }
295
- for (let i = 0; i < a.length; i++) {
296
- if (!isEqualWithImpl(a[i], b[i], i, a, b, stack, areValuesEqual)) {
297
- return false;
298
- }
299
- }
300
- return true;
201
+ if (typeof Buffer < "u" && Buffer.isBuffer(a) !== Buffer.isBuffer(b) || a.length !== b.length)
202
+ return !1;
203
+ for (let i = 0; i < a.length; i++)
204
+ if (!isEqualWithImpl(a[i], b[i], i, a, b, stack, areValuesEqual))
205
+ return !1;
206
+ return !0;
301
207
  }
302
- case arrayBufferTag: {
303
- if (a.byteLength !== b.byteLength) {
304
- return false;
305
- }
306
- return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
307
- }
308
- case dataViewTag: {
309
- if (a.byteLength !== b.byteLength || a.byteOffset !== b.byteOffset) {
310
- return false;
311
- }
312
- return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
313
- }
314
- case errorTag: {
208
+ case arrayBufferTag:
209
+ return a.byteLength !== b.byteLength ? !1 : areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
210
+ case dataViewTag:
211
+ return a.byteLength !== b.byteLength || a.byteOffset !== b.byteOffset ? !1 : areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
212
+ case errorTag:
315
213
  return a.name === b.name && a.message === b.message;
316
- }
317
214
  case objectTag: {
318
- const areEqualInstances = areObjectsEqual(a.constructor, b.constructor, stack, areValuesEqual) || isPlainObject(a) && isPlainObject(b);
319
- if (!areEqualInstances) {
320
- return false;
321
- }
322
- const aKeys = [...Object.keys(a), ...getSymbols(a)];
323
- const bKeys = [...Object.keys(b), ...getSymbols(b)];
324
- if (aKeys.length !== bKeys.length) {
325
- return false;
326
- }
215
+ if (!(areObjectsEqual(a.constructor, b.constructor, stack, areValuesEqual) || isPlainObject(a) && isPlainObject(b)))
216
+ return !1;
217
+ let aKeys = [...Object.keys(a), ...getSymbols(a)], bKeys = [...Object.keys(b), ...getSymbols(b)];
218
+ if (aKeys.length !== bKeys.length)
219
+ return !1;
327
220
  for (let i = 0; i < aKeys.length; i++) {
328
- const propKey = aKeys[i];
329
- const aProp = a[propKey];
330
- if (!Object.hasOwn(b, propKey)) {
331
- return false;
332
- }
333
- const bProp = b[propKey];
334
- if (!isEqualWithImpl(aProp, bProp, propKey, a, b, stack, areValuesEqual)) {
335
- return false;
336
- }
221
+ let propKey = aKeys[i], aProp = a[propKey];
222
+ if (!Object.hasOwn(b, propKey))
223
+ return !1;
224
+ let bProp = b[propKey];
225
+ if (!isEqualWithImpl(aProp, bProp, propKey, a, b, stack, areValuesEqual))
226
+ return !1;
337
227
  }
338
- return true;
339
- }
340
- default: {
341
- return false;
228
+ return !0;
342
229
  }
230
+ default:
231
+ return !1;
343
232
  }
344
233
  } finally {
345
- stack.delete(a);
346
- stack.delete(b);
234
+ stack.delete(a), stack.delete(b);
347
235
  }
348
236
  }
349
- __name(areObjectsEqual, "areObjectsEqual");
350
237
 
351
238
  // ../../node_modules/es-toolkit/dist/function/noop.mjs
352
239
  function noop() {
353
240
  }
354
- __name(noop, "noop");
355
241
 
356
242
  // ../../node_modules/es-toolkit/dist/predicate/isEqual.mjs
357
243
  function isEqual(a, b) {
358
244
  return isEqualWith(a, b, noop);
359
245
  }
360
- __name(isEqual, "isEqual");
361
246
 
362
247
  // src/use-test-provider-state.ts
363
248
  import {
@@ -365,61 +250,42 @@ import {
365
250
  experimental_useTestProviderStore,
366
251
  experimental_useUniversalStore
367
252
  } from "storybook/manager-api";
368
- var statusValueToStoryIds = /* @__PURE__ */ __name((allStatuses, typeId, storyIds) => {
369
- const statusValueToStoryIdsMap = {
253
+ var statusValueToStoryIds = (allStatuses, typeId, storyIds) => {
254
+ let statusValueToStoryIdsMap = {
370
255
  "status-value:pending": [],
371
256
  "status-value:success": [],
372
257
  "status-value:error": [],
373
258
  "status-value:warning": [],
374
259
  "status-value:unknown": []
375
260
  };
376
- const stories = storyIds ? storyIds.map((storyId) => allStatuses[storyId]).filter(Boolean) : Object.values(allStatuses);
377
- stories.forEach((statusByTypeId) => {
378
- const status = statusByTypeId[typeId];
379
- if (!status) {
380
- return;
381
- }
382
- statusValueToStoryIdsMap[status.value].push(status.storyId);
383
- });
384
- return statusValueToStoryIdsMap;
385
- }, "statusValueToStoryIds");
386
- var useTestProvider = /* @__PURE__ */ __name((api, entryId) => {
387
- const testProviderState = experimental_useTestProviderStore((s) => s[ADDON_ID2]);
388
- const [storeState, setStoreState] = experimental_useUniversalStore(store);
389
- const [isSettingsUpdated, setIsSettingsUpdated] = useState(false);
390
- const settingsUpdatedTimeoutRef = useRef();
261
+ return (storyIds ? storyIds.map((storyId) => allStatuses[storyId]).filter(Boolean) : Object.values(allStatuses)).forEach((statusByTypeId) => {
262
+ let status = statusByTypeId[typeId];
263
+ status && statusValueToStoryIdsMap[status.value].push(status.storyId);
264
+ }), statusValueToStoryIdsMap;
265
+ }, useTestProvider = (api, entryId) => {
266
+ let testProviderState = experimental_useTestProviderStore((s) => s[ADDON_ID2]), [storeState, setStoreState] = experimental_useUniversalStore(store), [isSettingsUpdated, setIsSettingsUpdated] = useState(!1), settingsUpdatedTimeoutRef = useRef();
391
267
  useEffect(() => {
392
- const unsubscribe = store.onStateChange((state, previousState) => {
393
- if (!isEqual(state.config, previousState.config)) {
394
- testProviderStore.settingsChanged();
395
- setIsSettingsUpdated(true);
396
- clearTimeout(settingsUpdatedTimeoutRef.current);
397
- settingsUpdatedTimeoutRef.current = setTimeout(() => {
398
- setIsSettingsUpdated(false);
399
- }, 1e3);
400
- }
268
+ let unsubscribe = store.onStateChange((state, previousState) => {
269
+ isEqual(state.config, previousState.config) || (testProviderStore.settingsChanged(), setIsSettingsUpdated(!0), clearTimeout(settingsUpdatedTimeoutRef.current), settingsUpdatedTimeoutRef.current = setTimeout(() => {
270
+ setIsSettingsUpdated(!1);
271
+ }, 1e3));
401
272
  });
402
273
  return () => {
403
- unsubscribe();
404
- clearTimeout(settingsUpdatedTimeoutRef.current);
274
+ unsubscribe(), clearTimeout(settingsUpdatedTimeoutRef.current);
405
275
  };
406
276
  }, []);
407
- const storyIds = useMemo(
277
+ let storyIds = useMemo(
408
278
  () => entryId ? api.findAllLeafStoryIds(entryId) : void 0,
409
279
  [entryId, api]
410
- );
411
- const componentTestStatusSelector = useCallback(
280
+ ), componentTestStatusSelector = useCallback(
412
281
  (allStatuses) => statusValueToStoryIds(allStatuses, STATUS_TYPE_ID_COMPONENT_TEST, storyIds),
413
282
  [storyIds]
414
- );
415
- const componentTestStatusValueToStoryIds = experimental_useStatusStore(
283
+ ), componentTestStatusValueToStoryIds = experimental_useStatusStore(
416
284
  componentTestStatusSelector
417
- );
418
- const a11yStatusValueToStoryIdsSelector = useCallback(
285
+ ), a11yStatusValueToStoryIdsSelector = useCallback(
419
286
  (allStatuses) => statusValueToStoryIds(allStatuses, STATUS_TYPE_ID_A11Y, storyIds),
420
287
  [storyIds]
421
- );
422
- const a11yStatusValueToStoryIds = experimental_useStatusStore(a11yStatusValueToStoryIdsSelector);
288
+ ), a11yStatusValueToStoryIds = experimental_useStatusStore(a11yStatusValueToStoryIdsSelector);
423
289
  return {
424
290
  storeState,
425
291
  setStoreState,
@@ -428,7 +294,7 @@ var useTestProvider = /* @__PURE__ */ __name((api, entryId) => {
428
294
  a11yStatusValueToStoryIds,
429
295
  isSettingsUpdated
430
296
  };
431
- }, "useTestProvider");
297
+ };
432
298
 
433
299
  // src/components/TestProviderRender.tsx
434
300
  import React3 from "react";
@@ -450,33 +316,28 @@ import { styled as styled2 } from "storybook/theming";
450
316
 
451
317
  // src/components/RelativeTime.tsx
452
318
  import { useEffect as useEffect2, useState as useState2 } from "react";
453
- var RelativeTime = /* @__PURE__ */ __name(({ timestamp }) => {
454
- const [timeAgo, setTimeAgo] = useState2(null);
455
- useEffect2(() => {
319
+ var RelativeTime = ({ timestamp }) => {
320
+ let [timeAgo, setTimeAgo] = useState2(null);
321
+ if (useEffect2(() => {
456
322
  if (timestamp) {
457
323
  setTimeAgo(Date.now() - timestamp);
458
- const interval = setInterval(() => setTimeAgo(Date.now() - timestamp), 1e4);
324
+ let interval = setInterval(() => setTimeAgo(Date.now() - timestamp), 1e4);
459
325
  return () => clearInterval(interval);
460
326
  }
461
- }, [timestamp]);
462
- if (timeAgo === null) {
327
+ }, [timestamp]), timeAgo === null)
463
328
  return null;
464
- }
465
- const seconds = Math.round(timeAgo / 1e3);
466
- if (seconds < 60) {
467
- return `just now`;
468
- }
469
- const minutes = Math.floor(seconds / 60);
470
- if (minutes < 60) {
471
- return minutes === 1 ? `a minute ago` : `${minutes} minutes ago`;
472
- }
473
- const hours = Math.floor(minutes / 60);
474
- if (hours < 24) {
475
- return hours === 1 ? `an hour ago` : `${hours} hours ago`;
476
- }
477
- const days = Math.floor(hours / 24);
478
- return days === 1 ? `yesterday` : `${days} days ago`;
479
- }, "RelativeTime");
329
+ let seconds = Math.round(timeAgo / 1e3);
330
+ if (seconds < 60)
331
+ return "just now";
332
+ let minutes = Math.floor(seconds / 60);
333
+ if (minutes < 60)
334
+ return minutes === 1 ? "a minute ago" : `${minutes} minutes ago`;
335
+ let hours = Math.floor(minutes / 60);
336
+ if (hours < 24)
337
+ return hours === 1 ? "an hour ago" : `${hours} hours ago`;
338
+ let days = Math.floor(hours / 24);
339
+ return days === 1 ? "yesterday" : `${days} days ago`;
340
+ };
480
341
 
481
342
  // src/components/Description.tsx
482
343
  var Wrapper = styled2.div(({ theme }) => ({
@@ -485,8 +346,7 @@ var Wrapper = styled2.div(({ theme }) => ({
485
346
  textOverflow: "ellipsis",
486
347
  fontSize: theme.typography.size.s1,
487
348
  color: theme.textMutedColor
488
- }));
489
- var PositiveText = styled2.span(({ theme }) => ({
349
+ })), PositiveText = styled2.span(({ theme }) => ({
490
350
  color: theme.color.positiveText
491
351
  }));
492
352
  function Description({
@@ -496,29 +356,19 @@ function Description({
496
356
  isSettingsUpdated,
497
357
  ...props
498
358
  }) {
499
- const { setModalOpen } = React2.useContext(GlobalErrorContext);
500
- const { componentTestCount, totalTestCount, unhandledErrors, finishedAt } = storeState.currentRun;
501
- const finishedTestCount = componentTestCount.success + componentTestCount.error;
502
- let description = "Not run";
503
- if (!entryId && isSettingsUpdated) {
359
+ let { setModalOpen } = React2.useContext(GlobalErrorContext), { componentTestCount, totalTestCount, unhandledErrors, finishedAt } = storeState.currentRun, finishedTestCount = componentTestCount.success + componentTestCount.error, description = "Not run";
360
+ if (!entryId && isSettingsUpdated)
504
361
  description = React2.createElement(PositiveText, null, "Settings updated");
505
- } else if (testProviderState === "test-provider-state:running") {
362
+ else if (testProviderState === "test-provider-state:running")
506
363
  description = (finishedTestCount ?? 0) === 0 ? "Starting..." : `Testing... ${finishedTestCount}/${totalTestCount}`;
507
- } else if (!entryId && testProviderState === "test-provider-state:crashed") {
508
- description = setModalOpen ? React2.createElement(LinkComponent, { isButton: true, onClick: () => setModalOpen(true) }, "View full error") : "Crashed";
509
- } else if (!entryId && unhandledErrors.length > 0) {
510
- const unhandledErrorDescription = `View ${unhandledErrors.length} unhandled error${unhandledErrors?.length > 1 ? "s" : ""}`;
511
- description = setModalOpen ? React2.createElement(LinkComponent, { isButton: true, onClick: () => setModalOpen(true) }, unhandledErrorDescription) : unhandledErrorDescription;
512
- } else if (entryId && totalTestCount) {
513
- description = `Ran ${totalTestCount} ${totalTestCount === 1 ? "test" : "tests"}`;
514
- } else if (finishedAt) {
515
- description = React2.createElement(React2.Fragment, null, "Ran ", totalTestCount, " ", totalTestCount === 1 ? "test" : "tests", " ", React2.createElement(RelativeTime, { timestamp: finishedAt }));
516
- } else if (storeState.watching) {
517
- description = "Watching for file changes";
518
- }
364
+ else if (!entryId && testProviderState === "test-provider-state:crashed")
365
+ description = setModalOpen ? React2.createElement(LinkComponent, { isButton: !0, onClick: () => setModalOpen(!0) }, "View full error") : "Crashed";
366
+ else if (!entryId && unhandledErrors.length > 0) {
367
+ let unhandledErrorDescription = `View ${unhandledErrors.length} unhandled error${unhandledErrors?.length > 1 ? "s" : ""}`;
368
+ description = setModalOpen ? React2.createElement(LinkComponent, { isButton: !0, onClick: () => setModalOpen(!0) }, unhandledErrorDescription) : unhandledErrorDescription;
369
+ } else entryId && totalTestCount ? description = `Ran ${totalTestCount} ${totalTestCount === 1 ? "test" : "tests"}` : finishedAt ? description = React2.createElement(React2.Fragment, null, "Ran ", totalTestCount, " ", totalTestCount === 1 ? "test" : "tests", " ", React2.createElement(RelativeTime, { timestamp: finishedAt })) : storeState.watching && (description = "Watching for file changes");
519
370
  return React2.createElement(Wrapper, { ...props }, description);
520
371
  }
521
- __name(Description, "Description");
522
372
 
523
373
  // src/components/TestStatusIcon.tsx
524
374
  import { styled as styled3 } from "storybook/theming";
@@ -559,53 +409,38 @@ var TestStatusIcon = styled3.div(
559
409
  var Container = styled4.div({
560
410
  display: "flex",
561
411
  flexDirection: "column"
562
- });
563
- var Heading = styled4.div({
412
+ }), Heading = styled4.div({
564
413
  display: "flex",
565
414
  justifyContent: "space-between",
566
415
  padding: "8px 0",
567
416
  gap: 12
568
- });
569
- var Info = styled4.div({
417
+ }), Info = styled4.div({
570
418
  display: "flex",
571
419
  flexDirection: "column",
572
420
  marginLeft: 8,
573
421
  minWidth: 0
574
- });
575
- var Title = styled4.div(({ crashed, theme }) => ({
422
+ }), Title = styled4.div(({ crashed, theme }) => ({
576
423
  fontSize: theme.typography.size.s1,
577
424
  fontWeight: crashed ? "bold" : "normal",
578
425
  color: crashed ? theme.color.negativeText : theme.color.defaultText
579
- }));
580
- var Actions = styled4.div({
426
+ })), Actions = styled4.div({
581
427
  display: "flex",
582
428
  gap: 4
583
- });
584
- var Extras = styled4.div({
429
+ }), Extras = styled4.div({
585
430
  marginBottom: 2
586
- });
587
- var Muted = styled4.span(({ theme }) => ({
431
+ }), Muted = styled4.span(({ theme }) => ({
588
432
  color: theme.textMutedColor
589
- }));
590
- var Progress = styled4(ProgressSpinner)({
433
+ })), Progress = styled4(ProgressSpinner)({
591
434
  margin: 4
592
- });
593
- var Row = styled4.div({
435
+ }), Row = styled4.div({
594
436
  display: "flex",
595
437
  gap: 4
596
- });
597
- var StopIcon = styled4(StopAltIcon)({
438
+ }), StopIcon = styled4(StopAltIcon)({
598
439
  width: 10
599
- });
600
- var openPanel = /* @__PURE__ */ __name(({ api, panelId, entryId }) => {
601
- const story = entryId ? api.findAllLeafStoryIds(entryId)[0] : void 0;
602
- if (story) {
603
- api.selectStory(story);
604
- }
605
- api.setSelectedPanel(panelId);
606
- api.togglePanel(true);
607
- }, "openPanel");
608
- var TestProviderRender = /* @__PURE__ */ __name(({
440
+ }), openPanel = ({ api, panelId, entryId }) => {
441
+ let story = entryId ? api.findAllLeafStoryIds(entryId)[0] : void 0;
442
+ story && api.selectStory(story), api.setSelectedPanel(panelId), api.togglePanel(!0);
443
+ }, TestProviderRender = ({
609
444
  api,
610
445
  entry,
611
446
  testProviderState,
@@ -616,13 +451,7 @@ var TestProviderRender = /* @__PURE__ */ __name(({
616
451
  isSettingsUpdated,
617
452
  ...props
618
453
  }) => {
619
- const { config, watching, cancelling, currentRun, fatalError } = storeState;
620
- const finishedTestCount = currentRun.componentTestCount.success + currentRun.componentTestCount.error;
621
- const hasA11yAddon = addons.experimental_getRegisteredAddons().includes(ADDON_ID);
622
- const isRunning = testProviderState === "test-provider-state:running";
623
- const isStarting = isRunning && finishedTestCount === 0;
624
- const [componentTestStatusIcon, componentTestStatusLabel] = fatalError ? ["critical", "Component tests crashed"] : componentTestStatusValueToStoryIds["status-value:error"].length > 0 ? ["negative", "Component tests failed"] : isRunning ? ["unknown", "Testing in progress"] : componentTestStatusValueToStoryIds["status-value:success"].length > 0 ? ["positive", "Component tests passed"] : ["unknown", "Run tests to see results"];
625
- const [a11yStatusIcon, a11yStatusLabel] = fatalError ? ["critical", "Component tests crashed"] : a11yStatusValueToStoryIds["status-value:error"].length > 0 ? ["negative", "Accessibility tests failed"] : a11yStatusValueToStoryIds["status-value:warning"].length > 0 ? ["warning", "Accessibility tests failed"] : isRunning ? ["unknown", "Testing in progress"] : a11yStatusValueToStoryIds["status-value:success"].length > 0 ? ["positive", "Accessibility tests passed"] : ["unknown", "Run tests to see accessibility results"];
454
+ let { config, watching, cancelling, currentRun, fatalError } = storeState, finishedTestCount = currentRun.componentTestCount.success + currentRun.componentTestCount.error, hasA11yAddon = addons.experimental_getRegisteredAddons().includes(ADDON_ID), isRunning = testProviderState === "test-provider-state:running", isStarting = isRunning && finishedTestCount === 0, [componentTestStatusIcon, componentTestStatusLabel] = fatalError ? ["critical", "Component tests crashed"] : componentTestStatusValueToStoryIds["status-value:error"].length > 0 ? ["negative", "Component tests failed"] : isRunning ? ["unknown", "Testing in progress"] : componentTestStatusValueToStoryIds["status-value:success"].length > 0 ? ["positive", "Component tests passed"] : ["unknown", "Run tests to see results"], [a11yStatusIcon, a11yStatusLabel] = fatalError ? ["critical", "Component tests crashed"] : a11yStatusValueToStoryIds["status-value:error"].length > 0 ? ["negative", "Accessibility tests failed"] : a11yStatusValueToStoryIds["status-value:warning"].length > 0 ? ["warning", "Accessibility tests failed"] : isRunning ? ["unknown", "Testing in progress"] : a11yStatusValueToStoryIds["status-value:success"].length > 0 ? ["positive", "Accessibility tests passed"] : ["unknown", "Run tests to see accessibility results"];
626
455
  return React3.createElement(Container, { ...props }, React3.createElement(Heading, null, React3.createElement(Info, null, entry ? React3.createElement(Title, { id: "testing-module-title" }, "Run component tests") : React3.createElement(
627
456
  Title,
628
457
  {
@@ -685,10 +514,7 @@ var TestProviderRender = /* @__PURE__ */ __name(({
685
514
  variant: "ghost",
686
515
  onClick: () => {
687
516
  let storyIds;
688
- if (entry) {
689
- storyIds = entry.type === "story" ? [entry.id] : api.findAllLeafStoryIds(entry.id);
690
- }
691
- store.send({
517
+ entry && (storyIds = entry.type === "story" ? [entry.id] : api.findAllLeafStoryIds(entry.id)), store.send({
692
518
  type: "TRIGGER_RUN",
693
519
  payload: { storyIds, triggeredBy: entry?.type ?? "global" }
694
520
  });
@@ -700,7 +526,7 @@ var TestProviderRender = /* @__PURE__ */ __name(({
700
526
  {
701
527
  as: "label",
702
528
  title: "Interactions",
703
- icon: entry ? null : React3.createElement(Form.Checkbox, { checked: true, disabled: true })
529
+ icon: entry ? null : React3.createElement(Form.Checkbox, { checked: !0, disabled: !0 })
704
530
  }
705
531
  ), React3.createElement(
706
532
  Button2,
@@ -744,14 +570,14 @@ var TestProviderRender = /* @__PURE__ */ __name(({
744
570
  padding: "small",
745
571
  size: "medium",
746
572
  variant: "ghost",
747
- disabled: true,
748
- ariaLabel: watching ? `Coverage unavailable in watch mode` : `Coverage unavailable when running focused tests`
573
+ disabled: !0,
574
+ ariaLabel: watching ? "Coverage unavailable in watch mode" : "Coverage unavailable when running focused tests"
749
575
  },
750
576
  React3.createElement(InfoIcon, null)
751
577
  ) : currentRun.coverageSummary ? React3.createElement(
752
578
  Button2,
753
579
  {
754
- asChild: true,
580
+ asChild: !0,
755
581
  padding: "small",
756
582
  size: "medium",
757
583
  variant: "ghost",
@@ -775,7 +601,7 @@ var TestProviderRender = /* @__PURE__ */ __name(({
775
601
  padding: "small",
776
602
  size: "medium",
777
603
  variant: "ghost",
778
- disabled: true,
604
+ disabled: !0,
779
605
  ariaLabel: isRunning ? "Coverage unavailable, testing still in progress" : fatalError ? "Coverage unavailable, component tests crashed" : "Coverage unavailable, run tests first"
780
606
  },
781
607
  React3.createElement(
@@ -821,11 +647,11 @@ var TestProviderRender = /* @__PURE__ */ __name(({
821
647
  React3.createElement(TestStatusIcon, { status: a11yStatusIcon, isRunning }),
822
648
  a11yStatusValueToStoryIds["status-value:error"].length + a11yStatusValueToStoryIds["status-value:warning"].length || null
823
649
  ))));
824
- }, "TestProviderRender");
650
+ };
825
651
 
826
652
  // src/components/SidebarContextMenu.tsx
827
- var SidebarContextMenu = /* @__PURE__ */ __name(({ context, api }) => {
828
- const {
653
+ var SidebarContextMenu = ({ context, api }) => {
654
+ let {
829
655
  testProviderState,
830
656
  componentTestStatusValueToStoryIds,
831
657
  a11yStatusValueToStoryIds,
@@ -843,44 +669,39 @@ var SidebarContextMenu = /* @__PURE__ */ __name(({ context, api }) => {
843
669
  a11yStatusValueToStoryIds,
844
670
  storeState,
845
671
  setStoreState,
846
- isSettingsUpdated: false
672
+ isSettingsUpdated: !1
847
673
  }
848
674
  );
849
- }, "SidebarContextMenu");
675
+ };
850
676
 
851
677
  // src/manager.tsx
852
678
  addons2.register(ADDON_ID2, (api) => {
853
- const storybookBuilder = globalThis.STORYBOOK_BUILDER || "";
854
- if (storybookBuilder.includes("vite")) {
855
- const openPanel2 = /* @__PURE__ */ __name((panelId) => {
856
- api.setSelectedPanel(panelId);
857
- api.togglePanel(true);
858
- }, "openPanel");
679
+ if ((globalThis.STORYBOOK_BUILDER || "").includes("vite")) {
680
+ let openPanel2 = (panelId) => {
681
+ api.setSelectedPanel(panelId), api.togglePanel(!0);
682
+ };
859
683
  componentTestStatusStore.onSelect(() => {
860
684
  openPanel2(PANEL_ID);
861
- });
862
- a11yStatusStore.onSelect(() => {
685
+ }), a11yStatusStore.onSelect(() => {
863
686
  openPanel2(PANEL_ID2);
864
- });
865
- testProviderStore.onRunAll(() => {
687
+ }), testProviderStore.onRunAll(() => {
866
688
  store.send({
867
689
  type: "TRIGGER_RUN",
868
690
  payload: {
869
691
  triggeredBy: "run-all"
870
692
  }
871
693
  });
872
- });
873
- store.untilReady().then(() => {
694
+ }), store.untilReady().then(() => {
874
695
  store.setState((state) => ({
875
696
  ...state,
876
697
  indexUrl: new URL("index.json", window.location.href).toString()
877
- }));
878
- });
879
- addons2.add(TEST_PROVIDER_ID, {
698
+ })), store.subscribe("TEST_RUN_COMPLETED", ({ payload }) => {
699
+ api.emit(ADDON_TEST_CHANNEL, { type: "test-run-completed", payload });
700
+ });
701
+ }), addons2.add(TEST_PROVIDER_ID, {
880
702
  type: Addon_TypesEnum.experimental_TEST_PROVIDER,
881
- render: /* @__PURE__ */ __name(() => {
882
- const [isModalOpen, setModalOpen] = useState3(false);
883
- const {
703
+ render: () => {
704
+ let [isModalOpen, setModalOpen] = useState3(!1), {
884
705
  storeState,
885
706
  setStoreState,
886
707
  testProviderState,
@@ -904,8 +725,7 @@ addons2.register(ADDON_ID2, (api) => {
904
725
  {
905
726
  storeState,
906
727
  onRerun: () => {
907
- setModalOpen(false);
908
- store.send({
728
+ setModalOpen(!1), store.send({
909
729
  type: "TRIGGER_RUN",
910
730
  payload: {
911
731
  triggeredBy: "global"
@@ -914,16 +734,8 @@ addons2.register(ADDON_ID2, (api) => {
914
734
  }
915
735
  }
916
736
  ));
917
- }, "render"),
918
- sidebarContextMenu: /* @__PURE__ */ __name(({ context }) => {
919
- if (context.type === "docs") {
920
- return null;
921
- }
922
- if (context.type === "story" && !context.tags.includes("test")) {
923
- return null;
924
- }
925
- return React5.createElement(SidebarContextMenu, { context, api });
926
- }, "sidebarContextMenu")
737
+ },
738
+ sidebarContextMenu: ({ context }) => context.type === "docs" || context.type === "story" && !context.tags.includes("test") ? null : React5.createElement(SidebarContextMenu, { context, api })
927
739
  });
928
740
  }
929
741
  });