@storybook/addon-vitest 10.1.0-alpha.1 → 10.1.0-alpha.11
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/_browser-chunks/chunk-ULSHVN74.js +60 -0
- package/dist/_node-chunks/chunk-2WX72TIY.js +35 -0
- package/dist/_node-chunks/chunk-BEGZGAUW.js +1697 -0
- package/dist/_node-chunks/chunk-CHRIX3Z2.js +339 -0
- package/dist/_node-chunks/chunk-FCFZB5YS.js +45 -0
- package/dist/_node-chunks/chunk-FD2MOKYY.js +69 -0
- package/dist/_node-chunks/chunk-L7WYCUSW.js +138 -0
- package/dist/_node-chunks/chunk-TCQNKRGF.js +83 -0
- package/dist/_node-chunks/{chunk-RWZYDWYZ.js → chunk-XN666246.js} +15 -24
- package/dist/index.js +1 -5
- package/dist/manager.js +270 -490
- package/dist/node/coverage-reporter.js +319 -864
- package/dist/node/vitest.js +189 -454
- package/dist/postinstall.js +476 -1343
- package/dist/preset.js +150 -338
- package/dist/vitest-plugin/global-setup.js +50 -105
- package/dist/vitest-plugin/index.js +1160 -2377
- package/dist/vitest-plugin/setup-file.js +6 -12
- package/dist/vitest-plugin/test-utils.js +31 -71
- package/package.json +3 -3
- package/dist/_browser-chunks/chunk-CAYLRBRX.js +0 -77
- package/dist/_browser-chunks/chunk-JK72E6FR.js +0 -6
- package/dist/_node-chunks/chunk-4EEN4T72.js +0 -37
- package/dist/_node-chunks/chunk-5D5GEQQR.js +0 -104
- package/dist/_node-chunks/chunk-5KVXKVT6.js +0 -98
- package/dist/_node-chunks/chunk-CPO3S7HD.js +0 -481
- package/dist/_node-chunks/chunk-JLLEOCT6.js +0 -247
- package/dist/_node-chunks/chunk-SIWL37RV.js +0 -2574
- package/dist/_node-chunks/chunk-XYGEMTYA.js +0 -50
package/dist/manager.js
CHANGED
|
@@ -9,10 +9,7 @@ import {
|
|
|
9
9
|
STATUS_TYPE_ID_COMPONENT_TEST,
|
|
10
10
|
TEST_PROVIDER_ID,
|
|
11
11
|
storeOptions
|
|
12
|
-
} from "./_browser-chunks/chunk-
|
|
13
|
-
import {
|
|
14
|
-
__name
|
|
15
|
-
} from "./_browser-chunks/chunk-JK72E6FR.js";
|
|
12
|
+
} from "./_browser-chunks/chunk-ULSHVN74.js";
|
|
16
13
|
|
|
17
14
|
// src/manager.tsx
|
|
18
15
|
import React5, { useState as useState3 } from "react";
|
|
@@ -27,18 +24,15 @@ import {
|
|
|
27
24
|
var store = experimental_UniversalStore.create({
|
|
28
25
|
...storeOptions,
|
|
29
26
|
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);
|
|
27
|
+
}), componentTestStatusStore = experimental_getStatusStore(STATUS_TYPE_ID_COMPONENT_TEST), a11yStatusStore = experimental_getStatusStore(STATUS_TYPE_ID_A11Y), testProviderStore = experimental_getTestProviderStore(ADDON_ID2);
|
|
34
28
|
|
|
35
29
|
// src/manager.tsx
|
|
36
30
|
import { addons as addons2 } from "storybook/manager-api";
|
|
37
31
|
|
|
38
32
|
// src/components/GlobalErrorModal.tsx
|
|
39
33
|
import React, { useContext } from "react";
|
|
40
|
-
import { Button,
|
|
41
|
-
import {
|
|
34
|
+
import { Button, Modal } from "storybook/internal/components";
|
|
35
|
+
import { SyncIcon } from "@storybook/icons";
|
|
42
36
|
import { useStorybookApi } from "storybook/manager-api";
|
|
43
37
|
import { styled } from "storybook/theming";
|
|
44
38
|
var ModalBar = styled.div({
|
|
@@ -46,59 +40,44 @@ var ModalBar = styled.div({
|
|
|
46
40
|
justifyContent: "space-between",
|
|
47
41
|
alignItems: "center",
|
|
48
42
|
padding: "6px 6px 6px 20px"
|
|
49
|
-
})
|
|
50
|
-
var ModalActionBar = styled.div({
|
|
43
|
+
}), ModalActionBar = styled.div({
|
|
51
44
|
display: "flex",
|
|
52
45
|
justifyContent: "space-between",
|
|
53
46
|
alignItems: "center"
|
|
54
|
-
})
|
|
55
|
-
var ModalTitle = styled(Modal.Title)(({ theme: { typography } }) => ({
|
|
47
|
+
}), ModalTitle = styled(Modal.Title)(({ theme: { typography } }) => ({
|
|
56
48
|
fontSize: typography.size.s2,
|
|
57
49
|
fontWeight: typography.weight.bold
|
|
58
|
-
}))
|
|
59
|
-
var ModalStackTrace = styled.pre(({ theme }) => ({
|
|
50
|
+
})), ModalStackTrace = styled.pre(({ theme }) => ({
|
|
60
51
|
whiteSpace: "pre-wrap",
|
|
61
52
|
wordWrap: "break-word",
|
|
62
53
|
overflow: "auto",
|
|
63
54
|
maxHeight: "60vh",
|
|
64
55
|
margin: 0,
|
|
65
|
-
padding:
|
|
56
|
+
padding: "20px",
|
|
66
57
|
fontFamily: theme.typography.fonts.mono,
|
|
67
58
|
fontSize: "12px",
|
|
68
59
|
borderTop: `1px solid ${theme.appBorderColor}`,
|
|
69
60
|
borderRadius: 0
|
|
70
|
-
}))
|
|
71
|
-
var TroubleshootLink = styled.a(({ theme }) => ({
|
|
61
|
+
})), TroubleshootLink = styled.a(({ theme }) => ({
|
|
72
62
|
color: theme.color.defaultText
|
|
73
|
-
}))
|
|
74
|
-
|
|
75
|
-
isModalOpen: false,
|
|
63
|
+
})), GlobalErrorContext = React.createContext({
|
|
64
|
+
isModalOpen: !1,
|
|
76
65
|
setModalOpen: void 0
|
|
77
66
|
});
|
|
78
67
|
function ErrorCause({ error }) {
|
|
79
|
-
|
|
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 }));
|
|
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;
|
|
83
69
|
}
|
|
84
|
-
__name(ErrorCause, "ErrorCause");
|
|
85
70
|
function GlobalErrorModal({ onRerun, storeState }) {
|
|
86
|
-
|
|
87
|
-
const { isModalOpen, setModalOpen } = useContext(GlobalErrorContext);
|
|
88
|
-
const handleClose = /* @__PURE__ */ __name(() => setModalOpen?.(false), "handleClose");
|
|
89
|
-
const troubleshootURL = api.getDocsUrl({
|
|
71
|
+
let api = useStorybookApi(), { isModalOpen, setModalOpen } = useContext(GlobalErrorContext), troubleshootURL = api.getDocsUrl({
|
|
90
72
|
subpath: DOCUMENTATION_FATAL_ERROR_LINK,
|
|
91
|
-
versioned:
|
|
92
|
-
renderer:
|
|
93
|
-
})
|
|
94
|
-
const {
|
|
73
|
+
versioned: !0,
|
|
74
|
+
renderer: !0
|
|
75
|
+
}), {
|
|
95
76
|
fatalError,
|
|
96
77
|
currentRun: { unhandledErrors }
|
|
97
|
-
} = storeState;
|
|
98
|
-
|
|
99
|
-
return React.createElement(Modal, { onEscapeKeyDown: handleClose, onInteractOutside: handleClose, 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" }, React.createElement(SyncIcon, null), "Rerun"), React.createElement(Button, { variant: "ghost", asChild: true }, React.createElement("a", { target: "_blank", href: troubleshootURL, rel: "noreferrer" }, "Troubleshoot")), React.createElement(IconButton, { onClick: handleClose, "aria-label": "Close modal" }, React.createElement(CloseIcon, null)))), React.createElement(ModalStackTrace, null, content, React.createElement("br", null), React.createElement("br", null), "Troubleshoot:", " ", React.createElement(TroubleshootLink, { target: "_blank", href: troubleshootURL }, troubleshootURL)));
|
|
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)));
|
|
100
80
|
}
|
|
101
|
-
__name(GlobalErrorModal, "GlobalErrorModal");
|
|
102
81
|
|
|
103
82
|
// src/components/SidebarContextMenu.tsx
|
|
104
83
|
import React4 from "react";
|
|
@@ -108,172 +87,103 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
|
108
87
|
|
|
109
88
|
// ../../node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
|
|
110
89
|
function isPlainObject(value) {
|
|
111
|
-
if (!value || typeof value
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const hasObjectPrototype = proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null;
|
|
116
|
-
if (!hasObjectPrototype) {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
return Object.prototype.toString.call(value) === "[object Object]";
|
|
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;
|
|
120
94
|
}
|
|
121
|
-
__name(isPlainObject, "isPlainObject");
|
|
122
95
|
|
|
123
96
|
// ../../node_modules/es-toolkit/dist/compat/_internal/getSymbols.mjs
|
|
124
97
|
function getSymbols(object) {
|
|
125
98
|
return Object.getOwnPropertySymbols(object).filter((symbol) => Object.prototype.propertyIsEnumerable.call(object, symbol));
|
|
126
99
|
}
|
|
127
|
-
__name(getSymbols, "getSymbols");
|
|
128
100
|
|
|
129
101
|
// ../../node_modules/es-toolkit/dist/compat/_internal/getTag.mjs
|
|
130
102
|
function getTag(value) {
|
|
131
|
-
|
|
132
|
-
return value === void 0 ? "[object Undefined]" : "[object Null]";
|
|
133
|
-
}
|
|
134
|
-
return Object.prototype.toString.call(value);
|
|
103
|
+
return value == null ? value === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(value);
|
|
135
104
|
}
|
|
136
|
-
__name(getTag, "getTag");
|
|
137
105
|
|
|
138
106
|
// ../../node_modules/es-toolkit/dist/compat/_internal/tags.mjs
|
|
139
|
-
var regexpTag = "[object RegExp]";
|
|
140
|
-
var stringTag = "[object String]";
|
|
141
|
-
var numberTag = "[object Number]";
|
|
142
|
-
var booleanTag = "[object Boolean]";
|
|
143
|
-
var argumentsTag = "[object Arguments]";
|
|
144
|
-
var symbolTag = "[object Symbol]";
|
|
145
|
-
var dateTag = "[object Date]";
|
|
146
|
-
var mapTag = "[object Map]";
|
|
147
|
-
var setTag = "[object Set]";
|
|
148
|
-
var arrayTag = "[object Array]";
|
|
149
|
-
var functionTag = "[object Function]";
|
|
150
|
-
var arrayBufferTag = "[object ArrayBuffer]";
|
|
151
|
-
var objectTag = "[object Object]";
|
|
152
|
-
var errorTag = "[object Error]";
|
|
153
|
-
var dataViewTag = "[object DataView]";
|
|
154
|
-
var uint8ArrayTag = "[object Uint8Array]";
|
|
155
|
-
var uint8ClampedArrayTag = "[object Uint8ClampedArray]";
|
|
156
|
-
var uint16ArrayTag = "[object Uint16Array]";
|
|
157
|
-
var uint32ArrayTag = "[object Uint32Array]";
|
|
158
|
-
var bigUint64ArrayTag = "[object BigUint64Array]";
|
|
159
|
-
var int8ArrayTag = "[object Int8Array]";
|
|
160
|
-
var int16ArrayTag = "[object Int16Array]";
|
|
161
|
-
var int32ArrayTag = "[object Int32Array]";
|
|
162
|
-
var bigInt64ArrayTag = "[object BigInt64Array]";
|
|
163
|
-
var float32ArrayTag = "[object Float32Array]";
|
|
164
|
-
var float64ArrayTag = "[object Float64Array]";
|
|
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]";
|
|
165
108
|
|
|
166
109
|
// ../../node_modules/es-toolkit/dist/compat/util/eq.mjs
|
|
167
110
|
function eq(value, other) {
|
|
168
111
|
return value === other || Number.isNaN(value) && Number.isNaN(other);
|
|
169
112
|
}
|
|
170
|
-
__name(eq, "eq");
|
|
171
113
|
|
|
172
114
|
// ../../node_modules/es-toolkit/dist/predicate/isEqualWith.mjs
|
|
173
115
|
function isEqualWith(a, b, areValuesEqual) {
|
|
174
116
|
return isEqualWithImpl(a, b, void 0, void 0, void 0, void 0, areValuesEqual);
|
|
175
117
|
}
|
|
176
|
-
__name(isEqualWith, "isEqualWith");
|
|
177
118
|
function isEqualWithImpl(a, b, property, aParent, bParent, stack, areValuesEqual) {
|
|
178
|
-
|
|
179
|
-
if (result !== void 0)
|
|
119
|
+
let result = areValuesEqual(a, b, property, aParent, bParent, stack);
|
|
120
|
+
if (result !== void 0)
|
|
180
121
|
return result;
|
|
181
|
-
|
|
182
|
-
if (typeof a === typeof b) {
|
|
122
|
+
if (typeof a == typeof b)
|
|
183
123
|
switch (typeof a) {
|
|
184
124
|
case "bigint":
|
|
185
125
|
case "string":
|
|
186
126
|
case "boolean":
|
|
187
127
|
case "symbol":
|
|
188
|
-
case "undefined":
|
|
128
|
+
case "undefined":
|
|
189
129
|
return a === b;
|
|
190
|
-
|
|
191
|
-
case "number": {
|
|
130
|
+
case "number":
|
|
192
131
|
return a === b || Object.is(a, b);
|
|
193
|
-
|
|
194
|
-
case "function": {
|
|
132
|
+
case "function":
|
|
195
133
|
return a === b;
|
|
196
|
-
|
|
197
|
-
case "object": {
|
|
134
|
+
case "object":
|
|
198
135
|
return areObjectsEqual(a, b, stack, areValuesEqual);
|
|
199
|
-
}
|
|
200
136
|
}
|
|
201
|
-
}
|
|
202
137
|
return areObjectsEqual(a, b, stack, areValuesEqual);
|
|
203
138
|
}
|
|
204
|
-
__name(isEqualWithImpl, "isEqualWithImpl");
|
|
205
139
|
function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
206
|
-
if (Object.is(a, b))
|
|
207
|
-
return
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (aTag === argumentsTag) {
|
|
212
|
-
aTag = objectTag;
|
|
213
|
-
}
|
|
214
|
-
if (bTag === argumentsTag) {
|
|
215
|
-
bTag = objectTag;
|
|
216
|
-
}
|
|
217
|
-
if (aTag !== bTag) {
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
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;
|
|
220
145
|
switch (aTag) {
|
|
221
146
|
case stringTag:
|
|
222
147
|
return a.toString() === b.toString();
|
|
223
148
|
case numberTag: {
|
|
224
|
-
|
|
225
|
-
const y = b.valueOf();
|
|
149
|
+
let x = a.valueOf(), y = b.valueOf();
|
|
226
150
|
return eq(x, y);
|
|
227
151
|
}
|
|
228
152
|
case booleanTag:
|
|
229
153
|
case dateTag:
|
|
230
154
|
case symbolTag:
|
|
231
155
|
return Object.is(a.valueOf(), b.valueOf());
|
|
232
|
-
case regexpTag:
|
|
156
|
+
case regexpTag:
|
|
233
157
|
return a.source === b.source && a.flags === b.flags;
|
|
234
|
-
|
|
235
|
-
case functionTag: {
|
|
158
|
+
case functionTag:
|
|
236
159
|
return a === b;
|
|
237
|
-
}
|
|
238
160
|
}
|
|
239
161
|
stack = stack ?? /* @__PURE__ */ new Map();
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if (aStack != null && bStack != null) {
|
|
162
|
+
let aStack = stack.get(a), bStack = stack.get(b);
|
|
163
|
+
if (aStack != null && bStack != null)
|
|
243
164
|
return aStack === b;
|
|
244
|
-
|
|
245
|
-
stack.set(a, b);
|
|
246
|
-
stack.set(b, a);
|
|
165
|
+
stack.set(a, b), stack.set(b, a);
|
|
247
166
|
try {
|
|
248
167
|
switch (aTag) {
|
|
249
168
|
case mapTag: {
|
|
250
|
-
if (a.size !== b.size)
|
|
251
|
-
return
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
return true;
|
|
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;
|
|
259
175
|
}
|
|
260
176
|
case setTag: {
|
|
261
|
-
if (a.size !== b.size)
|
|
262
|
-
return
|
|
263
|
-
|
|
264
|
-
const aValues = Array.from(a.values());
|
|
265
|
-
const bValues = Array.from(b.values());
|
|
177
|
+
if (a.size !== b.size)
|
|
178
|
+
return !1;
|
|
179
|
+
let aValues = Array.from(a.values()), bValues = Array.from(b.values());
|
|
266
180
|
for (let i = 0; i < aValues.length; i++) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
return
|
|
270
|
-
});
|
|
271
|
-
if (index === -1) {
|
|
272
|
-
return false;
|
|
273
|
-
}
|
|
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;
|
|
274
184
|
bValues.splice(index, 1);
|
|
275
185
|
}
|
|
276
|
-
return
|
|
186
|
+
return !0;
|
|
277
187
|
}
|
|
278
188
|
case arrayTag:
|
|
279
189
|
case uint8ArrayTag:
|
|
@@ -287,78 +197,51 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
|
287
197
|
case bigInt64ArrayTag:
|
|
288
198
|
case float32ArrayTag:
|
|
289
199
|
case float64ArrayTag: {
|
|
290
|
-
if (typeof Buffer
|
|
291
|
-
return
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
for (let i = 0; i < a.length; i++) {
|
|
297
|
-
if (!isEqualWithImpl(a[i], b[i], i, a, b, stack, areValuesEqual)) {
|
|
298
|
-
return false;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
return true;
|
|
302
|
-
}
|
|
303
|
-
case arrayBufferTag: {
|
|
304
|
-
if (a.byteLength !== b.byteLength) {
|
|
305
|
-
return false;
|
|
306
|
-
}
|
|
307
|
-
return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
|
|
308
|
-
}
|
|
309
|
-
case dataViewTag: {
|
|
310
|
-
if (a.byteLength !== b.byteLength || a.byteOffset !== b.byteOffset) {
|
|
311
|
-
return false;
|
|
312
|
-
}
|
|
313
|
-
return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
|
|
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;
|
|
314
206
|
}
|
|
315
|
-
case
|
|
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:
|
|
316
212
|
return a.name === b.name && a.message === b.message;
|
|
317
|
-
}
|
|
318
213
|
case objectTag: {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const bKeys = [...Object.keys(b), ...getSymbols(b)];
|
|
325
|
-
if (aKeys.length !== bKeys.length) {
|
|
326
|
-
return false;
|
|
327
|
-
}
|
|
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;
|
|
328
219
|
for (let i = 0; i < aKeys.length; i++) {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
if (!isEqualWithImpl(aProp, bProp, propKey, a, b, stack, areValuesEqual)) {
|
|
336
|
-
return false;
|
|
337
|
-
}
|
|
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;
|
|
338
226
|
}
|
|
339
|
-
return
|
|
340
|
-
}
|
|
341
|
-
default: {
|
|
342
|
-
return false;
|
|
227
|
+
return !0;
|
|
343
228
|
}
|
|
229
|
+
default:
|
|
230
|
+
return !1;
|
|
344
231
|
}
|
|
345
232
|
} finally {
|
|
346
|
-
stack.delete(a);
|
|
347
|
-
stack.delete(b);
|
|
233
|
+
stack.delete(a), stack.delete(b);
|
|
348
234
|
}
|
|
349
235
|
}
|
|
350
|
-
__name(areObjectsEqual, "areObjectsEqual");
|
|
351
236
|
|
|
352
237
|
// ../../node_modules/es-toolkit/dist/function/noop.mjs
|
|
353
238
|
function noop() {
|
|
354
239
|
}
|
|
355
|
-
__name(noop, "noop");
|
|
356
240
|
|
|
357
241
|
// ../../node_modules/es-toolkit/dist/predicate/isEqual.mjs
|
|
358
242
|
function isEqual(a, b) {
|
|
359
243
|
return isEqualWith(a, b, noop);
|
|
360
244
|
}
|
|
361
|
-
__name(isEqual, "isEqual");
|
|
362
245
|
|
|
363
246
|
// src/use-test-provider-state.ts
|
|
364
247
|
import {
|
|
@@ -366,61 +249,42 @@ import {
|
|
|
366
249
|
experimental_useTestProviderStore,
|
|
367
250
|
experimental_useUniversalStore
|
|
368
251
|
} from "storybook/manager-api";
|
|
369
|
-
var statusValueToStoryIds =
|
|
370
|
-
|
|
252
|
+
var statusValueToStoryIds = (allStatuses, typeId, storyIds) => {
|
|
253
|
+
let statusValueToStoryIdsMap = {
|
|
371
254
|
"status-value:pending": [],
|
|
372
255
|
"status-value:success": [],
|
|
373
256
|
"status-value:error": [],
|
|
374
257
|
"status-value:warning": [],
|
|
375
258
|
"status-value:unknown": []
|
|
376
259
|
};
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
statusValueToStoryIdsMap[status.value].push(status.storyId);
|
|
384
|
-
});
|
|
385
|
-
return statusValueToStoryIdsMap;
|
|
386
|
-
}, "statusValueToStoryIds");
|
|
387
|
-
var useTestProvider = /* @__PURE__ */ __name((api, entryId) => {
|
|
388
|
-
const testProviderState = experimental_useTestProviderStore((s) => s[ADDON_ID2]);
|
|
389
|
-
const [storeState, setStoreState] = experimental_useUniversalStore(store);
|
|
390
|
-
const [isSettingsUpdated, setIsSettingsUpdated] = useState(false);
|
|
391
|
-
const settingsUpdatedTimeoutRef = useRef();
|
|
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();
|
|
392
266
|
useEffect(() => {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
clearTimeout(settingsUpdatedTimeoutRef.current);
|
|
398
|
-
settingsUpdatedTimeoutRef.current = setTimeout(() => {
|
|
399
|
-
setIsSettingsUpdated(false);
|
|
400
|
-
}, 1e3);
|
|
401
|
-
}
|
|
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));
|
|
402
271
|
});
|
|
403
272
|
return () => {
|
|
404
|
-
unsubscribe();
|
|
405
|
-
clearTimeout(settingsUpdatedTimeoutRef.current);
|
|
273
|
+
unsubscribe(), clearTimeout(settingsUpdatedTimeoutRef.current);
|
|
406
274
|
};
|
|
407
275
|
}, []);
|
|
408
|
-
|
|
276
|
+
let storyIds = useMemo(
|
|
409
277
|
() => entryId ? api.findAllLeafStoryIds(entryId) : void 0,
|
|
410
278
|
[entryId, api]
|
|
411
|
-
)
|
|
412
|
-
const componentTestStatusSelector = useCallback(
|
|
279
|
+
), componentTestStatusSelector = useCallback(
|
|
413
280
|
(allStatuses) => statusValueToStoryIds(allStatuses, STATUS_TYPE_ID_COMPONENT_TEST, storyIds),
|
|
414
281
|
[storyIds]
|
|
415
|
-
)
|
|
416
|
-
const componentTestStatusValueToStoryIds = experimental_useStatusStore(
|
|
282
|
+
), componentTestStatusValueToStoryIds = experimental_useStatusStore(
|
|
417
283
|
componentTestStatusSelector
|
|
418
|
-
)
|
|
419
|
-
const a11yStatusValueToStoryIdsSelector = useCallback(
|
|
284
|
+
), a11yStatusValueToStoryIdsSelector = useCallback(
|
|
420
285
|
(allStatuses) => statusValueToStoryIds(allStatuses, STATUS_TYPE_ID_A11Y, storyIds),
|
|
421
286
|
[storyIds]
|
|
422
|
-
);
|
|
423
|
-
const a11yStatusValueToStoryIds = experimental_useStatusStore(a11yStatusValueToStoryIdsSelector);
|
|
287
|
+
), a11yStatusValueToStoryIds = experimental_useStatusStore(a11yStatusValueToStoryIdsSelector);
|
|
424
288
|
return {
|
|
425
289
|
storeState,
|
|
426
290
|
setStoreState,
|
|
@@ -429,17 +293,16 @@ var useTestProvider = /* @__PURE__ */ __name((api, entryId) => {
|
|
|
429
293
|
a11yStatusValueToStoryIds,
|
|
430
294
|
isSettingsUpdated
|
|
431
295
|
};
|
|
432
|
-
}
|
|
296
|
+
};
|
|
433
297
|
|
|
434
298
|
// src/components/TestProviderRender.tsx
|
|
435
299
|
import React3 from "react";
|
|
436
300
|
import {
|
|
301
|
+
Button as Button2,
|
|
437
302
|
Form,
|
|
438
|
-
IconButton as IconButton2,
|
|
439
303
|
ListItem,
|
|
440
304
|
ProgressSpinner,
|
|
441
|
-
|
|
442
|
-
WithTooltip
|
|
305
|
+
ToggleButton
|
|
443
306
|
} from "storybook/internal/components";
|
|
444
307
|
import { EyeIcon, InfoIcon, PlayHollowIcon, StopAltIcon } from "@storybook/icons";
|
|
445
308
|
import { addons } from "storybook/manager-api";
|
|
@@ -452,33 +315,28 @@ import { styled as styled2 } from "storybook/theming";
|
|
|
452
315
|
|
|
453
316
|
// src/components/RelativeTime.tsx
|
|
454
317
|
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
455
|
-
var RelativeTime =
|
|
456
|
-
|
|
457
|
-
useEffect2(() => {
|
|
318
|
+
var RelativeTime = ({ timestamp }) => {
|
|
319
|
+
let [timeAgo, setTimeAgo] = useState2(null);
|
|
320
|
+
if (useEffect2(() => {
|
|
458
321
|
if (timestamp) {
|
|
459
322
|
setTimeAgo(Date.now() - timestamp);
|
|
460
|
-
|
|
323
|
+
let interval = setInterval(() => setTimeAgo(Date.now() - timestamp), 1e4);
|
|
461
324
|
return () => clearInterval(interval);
|
|
462
325
|
}
|
|
463
|
-
}, [timestamp])
|
|
464
|
-
if (timeAgo === null) {
|
|
326
|
+
}, [timestamp]), timeAgo === null)
|
|
465
327
|
return null;
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
}
|
|
479
|
-
const days = Math.floor(hours / 24);
|
|
480
|
-
return days === 1 ? `yesterday` : `${days} days ago`;
|
|
481
|
-
}, "RelativeTime");
|
|
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
|
+
};
|
|
482
340
|
|
|
483
341
|
// src/components/Description.tsx
|
|
484
342
|
var Wrapper = styled2.div(({ theme }) => ({
|
|
@@ -487,8 +345,7 @@ var Wrapper = styled2.div(({ theme }) => ({
|
|
|
487
345
|
textOverflow: "ellipsis",
|
|
488
346
|
fontSize: theme.typography.size.s1,
|
|
489
347
|
color: theme.textMutedColor
|
|
490
|
-
}))
|
|
491
|
-
var PositiveText = styled2.span(({ theme }) => ({
|
|
348
|
+
})), PositiveText = styled2.span(({ theme }) => ({
|
|
492
349
|
color: theme.color.positiveText
|
|
493
350
|
}));
|
|
494
351
|
function Description({
|
|
@@ -498,29 +355,19 @@ function Description({
|
|
|
498
355
|
isSettingsUpdated,
|
|
499
356
|
...props
|
|
500
357
|
}) {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
const finishedTestCount = componentTestCount.success + componentTestCount.error;
|
|
504
|
-
let description = "Not run";
|
|
505
|
-
if (!entryId && isSettingsUpdated) {
|
|
358
|
+
let { setModalOpen } = React2.useContext(GlobalErrorContext), { componentTestCount, totalTestCount, unhandledErrors, finishedAt } = storeState.currentRun, finishedTestCount = componentTestCount.success + componentTestCount.error, description = "Not run";
|
|
359
|
+
if (!entryId && isSettingsUpdated)
|
|
506
360
|
description = React2.createElement(PositiveText, null, "Settings updated");
|
|
507
|
-
|
|
361
|
+
else if (testProviderState === "test-provider-state:running")
|
|
508
362
|
description = (finishedTestCount ?? 0) === 0 ? "Starting..." : `Testing... ${finishedTestCount}/${totalTestCount}`;
|
|
509
|
-
|
|
510
|
-
description = setModalOpen ? React2.createElement(LinkComponent, { isButton:
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
description = setModalOpen ? React2.createElement(LinkComponent, { isButton:
|
|
514
|
-
} else
|
|
515
|
-
description = `Ran ${totalTestCount} ${totalTestCount === 1 ? "test" : "tests"}`;
|
|
516
|
-
} else if (finishedAt) {
|
|
517
|
-
description = React2.createElement(React2.Fragment, null, "Ran ", totalTestCount, " ", totalTestCount === 1 ? "test" : "tests", " ", React2.createElement(RelativeTime, { timestamp: finishedAt }));
|
|
518
|
-
} else if (storeState.watching) {
|
|
519
|
-
description = "Watching for file changes";
|
|
520
|
-
}
|
|
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");
|
|
521
369
|
return React2.createElement(Wrapper, { ...props }, description);
|
|
522
370
|
}
|
|
523
|
-
__name(Description, "Description");
|
|
524
371
|
|
|
525
372
|
// src/components/TestStatusIcon.tsx
|
|
526
373
|
import { styled as styled3 } from "storybook/theming";
|
|
@@ -552,8 +399,8 @@ var TestStatusIcon = styled3.div(
|
|
|
552
399
|
"--status-background": `${theme.color.defaultText}66`
|
|
553
400
|
},
|
|
554
401
|
({ status, theme }) => status === "unknown" && {
|
|
555
|
-
"--status-color": theme.
|
|
556
|
-
"--status-background": `${theme.
|
|
402
|
+
"--status-color": theme.textMutedColor,
|
|
403
|
+
"--status-background": `${theme.textMutedColor}66`
|
|
557
404
|
}
|
|
558
405
|
);
|
|
559
406
|
|
|
@@ -561,53 +408,38 @@ var TestStatusIcon = styled3.div(
|
|
|
561
408
|
var Container = styled4.div({
|
|
562
409
|
display: "flex",
|
|
563
410
|
flexDirection: "column"
|
|
564
|
-
})
|
|
565
|
-
var Heading = styled4.div({
|
|
411
|
+
}), Heading = styled4.div({
|
|
566
412
|
display: "flex",
|
|
567
413
|
justifyContent: "space-between",
|
|
568
414
|
padding: "8px 0",
|
|
569
415
|
gap: 12
|
|
570
|
-
})
|
|
571
|
-
var Info = styled4.div({
|
|
416
|
+
}), Info = styled4.div({
|
|
572
417
|
display: "flex",
|
|
573
418
|
flexDirection: "column",
|
|
574
419
|
marginLeft: 8,
|
|
575
420
|
minWidth: 0
|
|
576
|
-
})
|
|
577
|
-
var Title = styled4.div(({ crashed, theme }) => ({
|
|
421
|
+
}), Title = styled4.div(({ crashed, theme }) => ({
|
|
578
422
|
fontSize: theme.typography.size.s1,
|
|
579
423
|
fontWeight: crashed ? "bold" : "normal",
|
|
580
424
|
color: crashed ? theme.color.negativeText : theme.color.defaultText
|
|
581
|
-
}))
|
|
582
|
-
var Actions = styled4.div({
|
|
425
|
+
})), Actions = styled4.div({
|
|
583
426
|
display: "flex",
|
|
584
427
|
gap: 4
|
|
585
|
-
})
|
|
586
|
-
var Extras = styled4.div({
|
|
428
|
+
}), Extras = styled4.div({
|
|
587
429
|
marginBottom: 2
|
|
588
|
-
})
|
|
589
|
-
var Muted = styled4.span(({ theme }) => ({
|
|
430
|
+
}), Muted = styled4.span(({ theme }) => ({
|
|
590
431
|
color: theme.textMutedColor
|
|
591
|
-
}))
|
|
592
|
-
var Progress = styled4(ProgressSpinner)({
|
|
432
|
+
})), Progress = styled4(ProgressSpinner)({
|
|
593
433
|
margin: 4
|
|
594
|
-
})
|
|
595
|
-
var Row = styled4.div({
|
|
434
|
+
}), Row = styled4.div({
|
|
596
435
|
display: "flex",
|
|
597
436
|
gap: 4
|
|
598
|
-
})
|
|
599
|
-
var StopIcon = styled4(StopAltIcon)({
|
|
437
|
+
}), StopIcon = styled4(StopAltIcon)({
|
|
600
438
|
width: 10
|
|
601
|
-
})
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
api.selectStory(story);
|
|
606
|
-
}
|
|
607
|
-
api.setSelectedPanel(panelId);
|
|
608
|
-
api.togglePanel(true);
|
|
609
|
-
}, "openPanel");
|
|
610
|
-
var TestProviderRender = /* @__PURE__ */ __name(({
|
|
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 = ({
|
|
611
443
|
api,
|
|
612
444
|
entry,
|
|
613
445
|
testProviderState,
|
|
@@ -618,13 +450,7 @@ var TestProviderRender = /* @__PURE__ */ __name(({
|
|
|
618
450
|
isSettingsUpdated,
|
|
619
451
|
...props
|
|
620
452
|
}) => {
|
|
621
|
-
|
|
622
|
-
const finishedTestCount = currentRun.componentTestCount.success + currentRun.componentTestCount.error;
|
|
623
|
-
const hasA11yAddon = addons.experimental_getRegisteredAddons().includes(ADDON_ID);
|
|
624
|
-
const isRunning = testProviderState === "test-provider-state:running";
|
|
625
|
-
const isStarting = isRunning && finishedTestCount === 0;
|
|
626
|
-
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"];
|
|
627
|
-
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"];
|
|
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"];
|
|
628
454
|
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(
|
|
629
455
|
Title,
|
|
630
456
|
{
|
|
@@ -642,116 +468,84 @@ var TestProviderRender = /* @__PURE__ */ __name(({
|
|
|
642
468
|
isSettingsUpdated
|
|
643
469
|
}
|
|
644
470
|
)), React3.createElement(Actions, null, !entry && React3.createElement(
|
|
645
|
-
|
|
471
|
+
ToggleButton,
|
|
646
472
|
{
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
473
|
+
ariaLabel: isRunning ? "Watch mode (cannot toggle while running)" : "Watch mode",
|
|
474
|
+
tooltip: isRunning ? "Watch mode unavailable while running" : `Watch mode is ${watching ? "enabled" : "disabled"}`,
|
|
475
|
+
padding: "small",
|
|
476
|
+
size: "medium",
|
|
477
|
+
variant: "ghost",
|
|
478
|
+
pressed: watching,
|
|
479
|
+
onClick: () => store.send({
|
|
480
|
+
type: "TOGGLE_WATCHING",
|
|
481
|
+
payload: {
|
|
482
|
+
to: !watching
|
|
483
|
+
}
|
|
484
|
+
}),
|
|
485
|
+
disabled: isRunning
|
|
650
486
|
},
|
|
651
|
-
React3.createElement(
|
|
652
|
-
IconButton2,
|
|
653
|
-
{
|
|
654
|
-
"aria-label": `${watching ? "Disable" : "Enable"} watch mode`,
|
|
655
|
-
size: "medium",
|
|
656
|
-
active: watching,
|
|
657
|
-
onClick: () => store.send({
|
|
658
|
-
type: "TOGGLE_WATCHING",
|
|
659
|
-
payload: {
|
|
660
|
-
to: !watching
|
|
661
|
-
}
|
|
662
|
-
}),
|
|
663
|
-
disabled: isRunning
|
|
664
|
-
},
|
|
665
|
-
React3.createElement(EyeIcon, null)
|
|
666
|
-
)
|
|
487
|
+
React3.createElement(EyeIcon, null)
|
|
667
488
|
), isRunning ? React3.createElement(
|
|
668
|
-
|
|
489
|
+
Button2,
|
|
669
490
|
{
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
491
|
+
ariaLabel: cancelling ? "Stop test run (already stopping...)" : "Stop test run",
|
|
492
|
+
padding: "none",
|
|
493
|
+
size: "medium",
|
|
494
|
+
variant: "ghost",
|
|
495
|
+
onClick: () => store.send({
|
|
496
|
+
type: "CANCEL_RUN"
|
|
497
|
+
}),
|
|
498
|
+
disabled: cancelling || isStarting
|
|
673
499
|
},
|
|
674
500
|
React3.createElement(
|
|
675
|
-
|
|
501
|
+
Progress,
|
|
676
502
|
{
|
|
677
|
-
|
|
678
|
-
padding: "none",
|
|
679
|
-
size: "medium",
|
|
680
|
-
onClick: () => store.send({
|
|
681
|
-
type: "CANCEL_RUN"
|
|
682
|
-
}),
|
|
683
|
-
disabled: cancelling || isStarting
|
|
503
|
+
percentage: finishedTestCount && storeState.currentRun.totalTestCount ? finishedTestCount / storeState.currentRun.totalTestCount * 100 : void 0
|
|
684
504
|
},
|
|
685
|
-
React3.createElement(
|
|
686
|
-
Progress,
|
|
687
|
-
{
|
|
688
|
-
percentage: finishedTestCount && storeState.currentRun.totalTestCount ? finishedTestCount / storeState.currentRun.totalTestCount * 100 : void 0
|
|
689
|
-
},
|
|
690
|
-
React3.createElement(StopIcon, null)
|
|
691
|
-
)
|
|
505
|
+
React3.createElement(StopIcon, null)
|
|
692
506
|
)
|
|
693
507
|
) : React3.createElement(
|
|
694
|
-
|
|
508
|
+
Button2,
|
|
695
509
|
{
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
510
|
+
ariaLabel: "Start test run",
|
|
511
|
+
padding: "small",
|
|
512
|
+
size: "medium",
|
|
513
|
+
variant: "ghost",
|
|
514
|
+
onClick: () => {
|
|
515
|
+
let storyIds;
|
|
516
|
+
entry && (storyIds = entry.type === "story" ? [entry.id] : api.findAllLeafStoryIds(entry.id)), store.send({
|
|
517
|
+
type: "TRIGGER_RUN",
|
|
518
|
+
payload: { storyIds, triggeredBy: entry?.type ?? "global" }
|
|
519
|
+
});
|
|
520
|
+
}
|
|
699
521
|
},
|
|
700
|
-
React3.createElement(
|
|
701
|
-
IconButton2,
|
|
702
|
-
{
|
|
703
|
-
"aria-label": "Start test run",
|
|
704
|
-
size: "medium",
|
|
705
|
-
onClick: () => {
|
|
706
|
-
let storyIds;
|
|
707
|
-
if (entry) {
|
|
708
|
-
storyIds = entry.type === "story" ? [entry.id] : api.findAllLeafStoryIds(entry.id);
|
|
709
|
-
}
|
|
710
|
-
store.send({
|
|
711
|
-
type: "TRIGGER_RUN",
|
|
712
|
-
payload: { storyIds, triggeredBy: entry?.type ?? "global" }
|
|
713
|
-
});
|
|
714
|
-
}
|
|
715
|
-
},
|
|
716
|
-
React3.createElement(PlayHollowIcon, null)
|
|
717
|
-
)
|
|
522
|
+
React3.createElement(PlayHollowIcon, null)
|
|
718
523
|
))), React3.createElement(Extras, null, React3.createElement(Row, null, React3.createElement(
|
|
719
524
|
ListItem,
|
|
720
525
|
{
|
|
721
526
|
as: "label",
|
|
722
527
|
title: "Interactions",
|
|
723
|
-
icon: entry ? null : React3.createElement(Form.Checkbox, { checked:
|
|
528
|
+
icon: entry ? null : React3.createElement(Form.Checkbox, { checked: !0, disabled: !0 })
|
|
724
529
|
}
|
|
725
530
|
), React3.createElement(
|
|
726
|
-
|
|
531
|
+
Button2,
|
|
727
532
|
{
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
533
|
+
ariaLabel: `${componentTestStatusLabel}${componentTestStatusValueToStoryIds["status-value:error"].length + componentTestStatusValueToStoryIds["status-value:warning"].length > 0 ? ` (${componentTestStatusValueToStoryIds["status-value:error"].length + componentTestStatusValueToStoryIds["status-value:warning"].length} errors or warnings so far)` : ""}`,
|
|
534
|
+
tooltip: componentTestStatusLabel,
|
|
535
|
+
padding: "small",
|
|
536
|
+
size: "medium",
|
|
537
|
+
variant: "ghost",
|
|
538
|
+
disabled: componentTestStatusValueToStoryIds["status-value:error"].length === 0 && componentTestStatusValueToStoryIds["status-value:warning"].length === 0 && componentTestStatusValueToStoryIds["status-value:success"].length === 0,
|
|
539
|
+
onClick: () => {
|
|
540
|
+
openPanel({
|
|
541
|
+
api,
|
|
542
|
+
panelId: PANEL_ID,
|
|
543
|
+
entryId: componentTestStatusValueToStoryIds["status-value:error"][0] ?? componentTestStatusValueToStoryIds["status-value:warning"][0] ?? componentTestStatusValueToStoryIds["status-value:success"][0] ?? entry?.id
|
|
544
|
+
});
|
|
545
|
+
}
|
|
731
546
|
},
|
|
732
|
-
React3.createElement(
|
|
733
|
-
|
|
734
|
-
{
|
|
735
|
-
size: "medium",
|
|
736
|
-
disabled: componentTestStatusValueToStoryIds["status-value:error"].length === 0 && componentTestStatusValueToStoryIds["status-value:warning"].length === 0 && componentTestStatusValueToStoryIds["status-value:success"].length === 0,
|
|
737
|
-
onClick: () => {
|
|
738
|
-
openPanel({
|
|
739
|
-
api,
|
|
740
|
-
panelId: PANEL_ID,
|
|
741
|
-
entryId: componentTestStatusValueToStoryIds["status-value:error"][0] ?? componentTestStatusValueToStoryIds["status-value:warning"][0] ?? componentTestStatusValueToStoryIds["status-value:success"][0] ?? entry?.id
|
|
742
|
-
});
|
|
743
|
-
}
|
|
744
|
-
},
|
|
745
|
-
React3.createElement(
|
|
746
|
-
TestStatusIcon,
|
|
747
|
-
{
|
|
748
|
-
status: componentTestStatusIcon,
|
|
749
|
-
"aria-label": componentTestStatusLabel,
|
|
750
|
-
isRunning
|
|
751
|
-
}
|
|
752
|
-
),
|
|
753
|
-
componentTestStatusValueToStoryIds["status-value:error"].length + componentTestStatusValueToStoryIds["status-value:warning"].length || null
|
|
754
|
-
)
|
|
547
|
+
React3.createElement(TestStatusIcon, { status: componentTestStatusIcon, isRunning }),
|
|
548
|
+
componentTestStatusValueToStoryIds["status-value:error"].length + componentTestStatusValueToStoryIds["status-value:warning"].length || null
|
|
755
549
|
)), !entry && React3.createElement(Row, null, React3.createElement(
|
|
756
550
|
ListItem,
|
|
757
551
|
{
|
|
@@ -769,39 +563,53 @@ var TestProviderRender = /* @__PURE__ */ __name(({
|
|
|
769
563
|
}
|
|
770
564
|
)
|
|
771
565
|
}
|
|
772
|
-
), React3.createElement(
|
|
773
|
-
|
|
566
|
+
), watching || currentRun.triggeredBy && !FULL_RUN_TRIGGERS.includes(currentRun.triggeredBy) ? React3.createElement(
|
|
567
|
+
Button2,
|
|
774
568
|
{
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
569
|
+
padding: "small",
|
|
570
|
+
size: "medium",
|
|
571
|
+
variant: "ghost",
|
|
572
|
+
disabled: !0,
|
|
573
|
+
ariaLabel: watching ? "Coverage unavailable in watch mode" : "Coverage unavailable when running focused tests"
|
|
574
|
+
},
|
|
575
|
+
React3.createElement(InfoIcon, null)
|
|
576
|
+
) : currentRun.coverageSummary ? React3.createElement(
|
|
577
|
+
Button2,
|
|
578
|
+
{
|
|
579
|
+
asChild: !0,
|
|
580
|
+
padding: "small",
|
|
581
|
+
size: "medium",
|
|
582
|
+
variant: "ghost",
|
|
583
|
+
ariaLabel: (
|
|
584
|
+
// FIXME: I can't deduce from the original tooltip logic whether this use case
|
|
585
|
+
// is logically possible or not. It is a reachable conditional branch in the original code.
|
|
586
|
+
isRunning ? "Open coverage report (testing still in progress)" : `Open coverage report (${currentRun.coverageSummary.percentage}% coverage)`
|
|
782
587
|
)
|
|
783
588
|
},
|
|
784
|
-
|
|
785
|
-
InfoIcon,
|
|
786
|
-
{
|
|
787
|
-
"aria-label": watching ? `Coverage is unavailable in watch mode` : `Coverage is unavailable when running focused tests`
|
|
788
|
-
}
|
|
789
|
-
)) : currentRun.coverageSummary ? React3.createElement(IconButton2, { asChild: true, size: "medium" }, React3.createElement("a", { href: "/coverage/index.html", target: "_blank", "aria-label": "Open coverage report" }, React3.createElement(
|
|
589
|
+
React3.createElement("a", { href: "/coverage/index.html", target: "_blank" }, React3.createElement(
|
|
790
590
|
TestStatusIcon,
|
|
791
591
|
{
|
|
792
592
|
isRunning,
|
|
793
593
|
percentage: currentRun.coverageSummary.percentage,
|
|
794
|
-
status: currentRun.coverageSummary.status
|
|
795
|
-
"aria-label": `Coverage status: ${currentRun.coverageSummary.status}`
|
|
594
|
+
status: currentRun.coverageSummary.status
|
|
796
595
|
}
|
|
797
|
-
),
|
|
596
|
+
), currentRun.coverageSummary.percentage, "%")
|
|
597
|
+
) : React3.createElement(
|
|
598
|
+
Button2,
|
|
599
|
+
{
|
|
600
|
+
padding: "small",
|
|
601
|
+
size: "medium",
|
|
602
|
+
variant: "ghost",
|
|
603
|
+
disabled: !0,
|
|
604
|
+
ariaLabel: isRunning ? "Coverage unavailable, testing still in progress" : fatalError ? "Coverage unavailable, component tests crashed" : "Coverage unavailable, run tests first"
|
|
605
|
+
},
|
|
606
|
+
React3.createElement(
|
|
798
607
|
TestStatusIcon,
|
|
799
608
|
{
|
|
800
609
|
isRunning,
|
|
801
|
-
status: fatalError ? "critical" : "unknown"
|
|
802
|
-
"aria-label": "Coverage status: unknown"
|
|
610
|
+
status: fatalError ? "critical" : "unknown"
|
|
803
611
|
}
|
|
804
|
-
)
|
|
612
|
+
)
|
|
805
613
|
)), hasA11yAddon && React3.createElement(Row, null, React3.createElement(
|
|
806
614
|
ListItem,
|
|
807
615
|
{
|
|
@@ -820,41 +628,29 @@ var TestProviderRender = /* @__PURE__ */ __name(({
|
|
|
820
628
|
)
|
|
821
629
|
}
|
|
822
630
|
), React3.createElement(
|
|
823
|
-
|
|
631
|
+
Button2,
|
|
824
632
|
{
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
633
|
+
ariaLabel: a11yStatusLabel,
|
|
634
|
+
padding: "small",
|
|
635
|
+
size: "medium",
|
|
636
|
+
variant: "ghost",
|
|
637
|
+
disabled: a11yStatusValueToStoryIds["status-value:error"].length === 0 && a11yStatusValueToStoryIds["status-value:warning"].length === 0 && a11yStatusValueToStoryIds["status-value:success"].length === 0,
|
|
638
|
+
onClick: () => {
|
|
639
|
+
openPanel({
|
|
640
|
+
api,
|
|
641
|
+
entryId: a11yStatusValueToStoryIds["status-value:error"][0] ?? a11yStatusValueToStoryIds["status-value:warning"][0] ?? a11yStatusValueToStoryIds["status-value:success"][0] ?? entry?.id,
|
|
642
|
+
panelId: PANEL_ID2
|
|
643
|
+
});
|
|
644
|
+
}
|
|
828
645
|
},
|
|
829
|
-
React3.createElement(
|
|
830
|
-
|
|
831
|
-
{
|
|
832
|
-
size: "medium",
|
|
833
|
-
disabled: a11yStatusValueToStoryIds["status-value:error"].length === 0 && a11yStatusValueToStoryIds["status-value:warning"].length === 0 && a11yStatusValueToStoryIds["status-value:success"].length === 0,
|
|
834
|
-
onClick: () => {
|
|
835
|
-
openPanel({
|
|
836
|
-
api,
|
|
837
|
-
entryId: a11yStatusValueToStoryIds["status-value:error"][0] ?? a11yStatusValueToStoryIds["status-value:warning"][0] ?? a11yStatusValueToStoryIds["status-value:success"][0] ?? entry?.id,
|
|
838
|
-
panelId: PANEL_ID2
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
},
|
|
842
|
-
React3.createElement(
|
|
843
|
-
TestStatusIcon,
|
|
844
|
-
{
|
|
845
|
-
status: a11yStatusIcon,
|
|
846
|
-
"aria-label": a11yStatusLabel,
|
|
847
|
-
isRunning
|
|
848
|
-
}
|
|
849
|
-
),
|
|
850
|
-
a11yStatusValueToStoryIds["status-value:error"].length + a11yStatusValueToStoryIds["status-value:warning"].length || null
|
|
851
|
-
)
|
|
646
|
+
React3.createElement(TestStatusIcon, { status: a11yStatusIcon, isRunning }),
|
|
647
|
+
a11yStatusValueToStoryIds["status-value:error"].length + a11yStatusValueToStoryIds["status-value:warning"].length || null
|
|
852
648
|
))));
|
|
853
|
-
}
|
|
649
|
+
};
|
|
854
650
|
|
|
855
651
|
// src/components/SidebarContextMenu.tsx
|
|
856
|
-
var SidebarContextMenu =
|
|
857
|
-
|
|
652
|
+
var SidebarContextMenu = ({ context, api }) => {
|
|
653
|
+
let {
|
|
858
654
|
testProviderState,
|
|
859
655
|
componentTestStatusValueToStoryIds,
|
|
860
656
|
a11yStatusValueToStoryIds,
|
|
@@ -872,44 +668,37 @@ var SidebarContextMenu = /* @__PURE__ */ __name(({ context, api }) => {
|
|
|
872
668
|
a11yStatusValueToStoryIds,
|
|
873
669
|
storeState,
|
|
874
670
|
setStoreState,
|
|
875
|
-
isSettingsUpdated:
|
|
671
|
+
isSettingsUpdated: !1
|
|
876
672
|
}
|
|
877
673
|
);
|
|
878
|
-
}
|
|
674
|
+
};
|
|
879
675
|
|
|
880
676
|
// src/manager.tsx
|
|
881
677
|
addons2.register(ADDON_ID2, (api) => {
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
api.togglePanel(true);
|
|
887
|
-
}, "openPanel");
|
|
678
|
+
if ((globalThis.STORYBOOK_BUILDER || "").includes("vite")) {
|
|
679
|
+
let openPanel2 = (panelId) => {
|
|
680
|
+
api.setSelectedPanel(panelId), api.togglePanel(!0);
|
|
681
|
+
};
|
|
888
682
|
componentTestStatusStore.onSelect(() => {
|
|
889
683
|
openPanel2(PANEL_ID);
|
|
890
|
-
})
|
|
891
|
-
a11yStatusStore.onSelect(() => {
|
|
684
|
+
}), a11yStatusStore.onSelect(() => {
|
|
892
685
|
openPanel2(PANEL_ID2);
|
|
893
|
-
})
|
|
894
|
-
testProviderStore.onRunAll(() => {
|
|
686
|
+
}), testProviderStore.onRunAll(() => {
|
|
895
687
|
store.send({
|
|
896
688
|
type: "TRIGGER_RUN",
|
|
897
689
|
payload: {
|
|
898
690
|
triggeredBy: "run-all"
|
|
899
691
|
}
|
|
900
692
|
});
|
|
901
|
-
})
|
|
902
|
-
store.untilReady().then(() => {
|
|
693
|
+
}), store.untilReady().then(() => {
|
|
903
694
|
store.setState((state) => ({
|
|
904
695
|
...state,
|
|
905
696
|
indexUrl: new URL("index.json", window.location.href).toString()
|
|
906
697
|
}));
|
|
907
|
-
})
|
|
908
|
-
addons2.add(TEST_PROVIDER_ID, {
|
|
698
|
+
}), addons2.add(TEST_PROVIDER_ID, {
|
|
909
699
|
type: Addon_TypesEnum.experimental_TEST_PROVIDER,
|
|
910
|
-
render:
|
|
911
|
-
|
|
912
|
-
const {
|
|
700
|
+
render: () => {
|
|
701
|
+
let [isModalOpen, setModalOpen] = useState3(!1), {
|
|
913
702
|
storeState,
|
|
914
703
|
setStoreState,
|
|
915
704
|
testProviderState,
|
|
@@ -933,8 +722,7 @@ addons2.register(ADDON_ID2, (api) => {
|
|
|
933
722
|
{
|
|
934
723
|
storeState,
|
|
935
724
|
onRerun: () => {
|
|
936
|
-
setModalOpen(
|
|
937
|
-
store.send({
|
|
725
|
+
setModalOpen(!1), store.send({
|
|
938
726
|
type: "TRIGGER_RUN",
|
|
939
727
|
payload: {
|
|
940
728
|
triggeredBy: "global"
|
|
@@ -943,16 +731,8 @@ addons2.register(ADDON_ID2, (api) => {
|
|
|
943
731
|
}
|
|
944
732
|
}
|
|
945
733
|
));
|
|
946
|
-
},
|
|
947
|
-
sidebarContextMenu:
|
|
948
|
-
if (context.type === "docs") {
|
|
949
|
-
return null;
|
|
950
|
-
}
|
|
951
|
-
if (context.type === "story" && !context.tags.includes("test")) {
|
|
952
|
-
return null;
|
|
953
|
-
}
|
|
954
|
-
return React5.createElement(SidebarContextMenu, { context, api });
|
|
955
|
-
}, "sidebarContextMenu")
|
|
734
|
+
},
|
|
735
|
+
sidebarContextMenu: ({ context }) => context.type === "docs" || context.type === "story" && !context.tags.includes("test") ? null : React5.createElement(SidebarContextMenu, { context, api })
|
|
956
736
|
});
|
|
957
737
|
}
|
|
958
738
|
});
|