@storybook/addon-vitest 0.0.0-pr-32795-sha-81cf1f23 → 0.0.0-pr-32717-sha-f340a68b

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