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