@storybook/addon-vitest 11.0.0-beta.3 → 11.0.0-beta.4
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/_node-chunks/chunk-FKKCPNLJ.js +39 -0
- package/dist/_node-chunks/{chunk-VLJFF3YI.js → chunk-G4HWSAOC.js} +0 -12
- package/dist/_node-chunks/{chunk-O6RHQ7RZ.js → chunk-MTTYIP6M.js} +1 -12
- package/dist/_node-chunks/{chunk-VM3B6QLG.js → chunk-PQZIOGBY.js} +1 -11
- package/dist/_node-chunks/{chunk-YXGVPF7B.js → chunk-QKPKKS4R.js} +1 -12
- package/dist/_node-chunks/{chunk-DFLNMLNU.js → chunk-VDP2ZJQR.js} +1 -12
- package/dist/_node-chunks/{chunk-3QQTREGV.js → chunk-WQDAJN3N.js} +0 -12
- package/dist/_node-chunks/{vitest.config.4.template-QCDTOEPV.js → vitest.config.4.template-3K4YNNG3.js} +1 -12
- package/dist/constants.js +2 -13
- package/dist/node/coverage-reporter.js +1 -12
- package/dist/node/vitest.js +6 -55
- package/dist/postinstall.js +6 -17
- package/dist/preset.js +306 -227
- package/dist/vitest-plugin/global-setup.js +1 -12
- package/dist/vitest-plugin/index.js +5 -16
- package/package.json +4 -4
- package/dist/_node-chunks/chunk-6MW37GZ6.js +0 -56
package/dist/preset.js
CHANGED
|
@@ -1,29 +1,19 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_dvfyhpwr65v from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_dvfyhpwr65v from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_dvfyhpwr65v from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_dvfyhpwr65v.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_dvfyhpwr65v.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_dvfyhpwr65v.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
1
|
import {
|
|
13
2
|
errorToErrorLike,
|
|
14
|
-
globalThis_,
|
|
15
3
|
log,
|
|
16
4
|
noop
|
|
17
|
-
} from "./_node-chunks/chunk-
|
|
5
|
+
} from "./_node-chunks/chunk-FKKCPNLJ.js";
|
|
18
6
|
import {
|
|
19
7
|
require_picocolors
|
|
20
|
-
} from "./_node-chunks/chunk-
|
|
8
|
+
} from "./_node-chunks/chunk-MTTYIP6M.js";
|
|
21
9
|
import {
|
|
22
10
|
require_dist
|
|
23
|
-
} from "./_node-chunks/chunk-
|
|
11
|
+
} from "./_node-chunks/chunk-QKPKKS4R.js";
|
|
24
12
|
import {
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
isAbsolute,
|
|
14
|
+
normalize,
|
|
15
|
+
relative
|
|
16
|
+
} from "./_node-chunks/chunk-VDP2ZJQR.js";
|
|
27
17
|
import {
|
|
28
18
|
ADDON_ID2 as ADDON_ID,
|
|
29
19
|
COVERAGE_DIRECTORY,
|
|
@@ -35,10 +25,10 @@ import {
|
|
|
35
25
|
TRIGGER_TEST_RUN_REQUEST,
|
|
36
26
|
TRIGGER_TEST_RUN_RESPONSE,
|
|
37
27
|
storeOptions
|
|
38
|
-
} from "./_node-chunks/chunk-
|
|
28
|
+
} from "./_node-chunks/chunk-G4HWSAOC.js";
|
|
39
29
|
import {
|
|
40
30
|
__toESM
|
|
41
|
-
} from "./_node-chunks/chunk-
|
|
31
|
+
} from "./_node-chunks/chunk-PQZIOGBY.js";
|
|
42
32
|
|
|
43
33
|
// src/preset.ts
|
|
44
34
|
var import_picocolors = __toESM(require_picocolors(), 1), import_ts_dedent = __toESM(require_dist(), 1);
|
|
@@ -58,132 +48,6 @@ import {
|
|
|
58
48
|
|
|
59
49
|
// ../../core/src/shared/utils/module.ts
|
|
60
50
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
61
|
-
|
|
62
|
-
// ../../../node_modules/exsolve/dist/index.mjs
|
|
63
|
-
import assert from "node:assert";
|
|
64
|
-
import v8 from "node:v8";
|
|
65
|
-
import { format, inspect } from "node:util";
|
|
66
|
-
var own$1 = {}.hasOwnProperty, classRegExp = /^([A-Z][a-z\d]*)+$/, kTypes = /* @__PURE__ */ new Set([
|
|
67
|
-
"string",
|
|
68
|
-
"function",
|
|
69
|
-
"number",
|
|
70
|
-
"object",
|
|
71
|
-
"Function",
|
|
72
|
-
"Object",
|
|
73
|
-
"boolean",
|
|
74
|
-
"bigint",
|
|
75
|
-
"symbol"
|
|
76
|
-
]), messages = /* @__PURE__ */ new Map(), nodeInternalPrefix = "__node_internal_", userStackTraceLimit;
|
|
77
|
-
function formatList(array2, type = "and") {
|
|
78
|
-
return array2.length < 3 ? array2.join(` ${type} `) : `${array2.slice(0, -1).join(", ")}, ${type} ${array2.at(-1)}`;
|
|
79
|
-
}
|
|
80
|
-
function createError(sym, value, constructor) {
|
|
81
|
-
return messages.set(sym, value), makeNodeErrorWithCode(constructor, sym);
|
|
82
|
-
}
|
|
83
|
-
function makeNodeErrorWithCode(Base, key) {
|
|
84
|
-
return function(...parameters) {
|
|
85
|
-
let limit = Error.stackTraceLimit;
|
|
86
|
-
isErrorStackTraceLimitWritable() && (Error.stackTraceLimit = 0);
|
|
87
|
-
let error = new Base();
|
|
88
|
-
isErrorStackTraceLimitWritable() && (Error.stackTraceLimit = limit);
|
|
89
|
-
let message = getMessage(key, parameters, error);
|
|
90
|
-
return Object.defineProperties(error, {
|
|
91
|
-
message: {
|
|
92
|
-
value: message,
|
|
93
|
-
enumerable: !1,
|
|
94
|
-
writable: !0,
|
|
95
|
-
configurable: !0
|
|
96
|
-
},
|
|
97
|
-
toString: {
|
|
98
|
-
value() {
|
|
99
|
-
return `${this.name} [${key}]: ${this.message}`;
|
|
100
|
-
},
|
|
101
|
-
enumerable: !1,
|
|
102
|
-
writable: !0,
|
|
103
|
-
configurable: !0
|
|
104
|
-
}
|
|
105
|
-
}), captureLargerStackTrace(error), error.code = key, error;
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function isErrorStackTraceLimitWritable() {
|
|
109
|
-
try {
|
|
110
|
-
if (v8.startupSnapshot.isBuildingSnapshot()) return !1;
|
|
111
|
-
} catch {
|
|
112
|
-
}
|
|
113
|
-
let desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
|
|
114
|
-
return desc === void 0 ? Object.isExtensible(Error) : own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
|
|
115
|
-
}
|
|
116
|
-
function hideStackFrames(wrappedFunction) {
|
|
117
|
-
let hidden = nodeInternalPrefix + wrappedFunction.name;
|
|
118
|
-
return Object.defineProperty(wrappedFunction, "name", { value: hidden }), wrappedFunction;
|
|
119
|
-
}
|
|
120
|
-
var captureLargerStackTrace = hideStackFrames(function(error) {
|
|
121
|
-
let stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
|
|
122
|
-
return stackTraceLimitIsWritable && (userStackTraceLimit = Error.stackTraceLimit, Error.stackTraceLimit = Number.POSITIVE_INFINITY), Error.captureStackTrace(error), stackTraceLimitIsWritable && (Error.stackTraceLimit = userStackTraceLimit), error;
|
|
123
|
-
});
|
|
124
|
-
function getMessage(key, parameters, self) {
|
|
125
|
-
let message = messages.get(key);
|
|
126
|
-
if (assert.ok(message !== void 0, "expected `message` to be found"), typeof message == "function")
|
|
127
|
-
return assert.ok(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`), Reflect.apply(message, self, parameters);
|
|
128
|
-
let regex = /%[dfijoOs]/g, expectedLength = 0;
|
|
129
|
-
for (; regex.exec(message) !== null; ) expectedLength++;
|
|
130
|
-
return assert.ok(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`), parameters.length === 0 ? message : (parameters.unshift(message), Reflect.apply(format, null, parameters));
|
|
131
|
-
}
|
|
132
|
-
function determineSpecificType(value) {
|
|
133
|
-
if (value == null) return String(value);
|
|
134
|
-
if (typeof value == "function" && value.name) return `function ${value.name}`;
|
|
135
|
-
if (typeof value == "object")
|
|
136
|
-
return value.constructor && value.constructor.name ? `an instance of ${value.constructor.name}` : `${inspect(value, { depth: -1 })}`;
|
|
137
|
-
let inspected = inspect(value, { colors: !1 });
|
|
138
|
-
return inspected.length > 28 && (inspected = `${inspected.slice(0, 25)}...`), `type ${typeof value} (${inspected})`;
|
|
139
|
-
}
|
|
140
|
-
var ERR_INVALID_ARG_TYPE = createError("ERR_INVALID_ARG_TYPE", (name, expected, actual) => {
|
|
141
|
-
assert.ok(typeof name == "string", "'name' must be a string"), Array.isArray(expected) || (expected = [expected]);
|
|
142
|
-
let message = "The ";
|
|
143
|
-
if (name.endsWith(" argument")) message += `${name} `;
|
|
144
|
-
else {
|
|
145
|
-
let type = name.includes(".") ? "property" : "argument";
|
|
146
|
-
message += `"${name}" ${type} `;
|
|
147
|
-
}
|
|
148
|
-
message += "must be ";
|
|
149
|
-
let types = [], instances = [], other = [];
|
|
150
|
-
for (let value of expected)
|
|
151
|
-
assert.ok(typeof value == "string", "All expected entries have to be of type string"), kTypes.has(value) ? types.push(value.toLowerCase()) : classRegExp.exec(value) === null ? (assert.ok(value !== "object", 'The value "object" should be written as "Object"'), other.push(value)) : instances.push(value);
|
|
152
|
-
if (instances.length > 0) {
|
|
153
|
-
let pos = types.indexOf("object");
|
|
154
|
-
pos !== -1 && (types.slice(pos, 1), instances.push("Object"));
|
|
155
|
-
}
|
|
156
|
-
return types.length > 0 && (message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(types, "or")}`, (instances.length > 0 || other.length > 0) && (message += " or ")), instances.length > 0 && (message += `an instance of ${formatList(instances, "or")}`, other.length > 0 && (message += " or ")), other.length > 0 && (other.length > 1 ? message += `one of ${formatList(other, "or")}` : (other[0]?.toLowerCase() !== other[0] && (message += "an "), message += `${other[0]}`)), message += `. Received ${determineSpecificType(actual)}`, message;
|
|
157
|
-
}, TypeError), ERR_INVALID_MODULE_SPECIFIER = createError(
|
|
158
|
-
"ERR_INVALID_MODULE_SPECIFIER",
|
|
159
|
-
/**
|
|
160
|
-
* @param {string} request
|
|
161
|
-
* @param {string} reason
|
|
162
|
-
* @param {string} [base]
|
|
163
|
-
*/
|
|
164
|
-
(request, reason, base) => `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`,
|
|
165
|
-
TypeError
|
|
166
|
-
), ERR_INVALID_PACKAGE_CONFIG = createError("ERR_INVALID_PACKAGE_CONFIG", (path$1, base, message) => `Invalid package config ${path$1}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`, Error), ERR_INVALID_PACKAGE_TARGET = createError("ERR_INVALID_PACKAGE_TARGET", (packagePath, key, target, isImport = !1, base) => {
|
|
167
|
-
let relatedError = typeof target == "string" && !isImport && target.length > 0 && !target.startsWith("./");
|
|
168
|
-
return key === "." ? (assert.ok(isImport === !1), `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`) : `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(target)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
|
|
169
|
-
}, Error), ERR_MODULE_NOT_FOUND = createError("ERR_MODULE_NOT_FOUND", (path$1, base, exactUrl = !1) => `Cannot find ${exactUrl ? "module" : "package"} '${path$1}' imported from ${base}`, Error), ERR_NETWORK_IMPORT_DISALLOWED = createError("ERR_NETWORK_IMPORT_DISALLOWED", "import of '%s' by %s is not supported: %s", Error), ERR_PACKAGE_IMPORT_NOT_DEFINED = createError("ERR_PACKAGE_IMPORT_NOT_DEFINED", (specifier, packagePath, base) => `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath || ""}package.json` : ""} imported from ${base}`, TypeError), ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
|
|
170
|
-
"ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
171
|
-
/**
|
|
172
|
-
* @param {string} packagePath
|
|
173
|
-
* @param {string} subpath
|
|
174
|
-
* @param {string} [base]
|
|
175
|
-
*/
|
|
176
|
-
(packagePath, subpath, base) => subpath === "." ? `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}` : `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`,
|
|
177
|
-
Error
|
|
178
|
-
), ERR_UNSUPPORTED_DIR_IMPORT = createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported resolving ES modules imported from %s", Error), ERR_UNSUPPORTED_RESOLVE_REQUEST = createError("ERR_UNSUPPORTED_RESOLVE_REQUEST", 'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.', TypeError), ERR_UNKNOWN_FILE_EXTENSION = createError("ERR_UNKNOWN_FILE_EXTENSION", (extension, path$1) => `Unknown file extension "${extension}" for ${path$1}`, TypeError), ERR_INVALID_ARG_VALUE = createError("ERR_INVALID_ARG_VALUE", (name, value, reason = "is invalid") => {
|
|
179
|
-
let inspected = inspect(value);
|
|
180
|
-
return inspected.length > 128 && (inspected = `${inspected.slice(0, 128)}...`), `The ${name.includes(".") ? "property" : "argument"} '${name}' ${reason}. Received ${inspected}`;
|
|
181
|
-
}, TypeError), hasOwnProperty$1 = {}.hasOwnProperty;
|
|
182
|
-
var hasOwnProperty = {}.hasOwnProperty;
|
|
183
|
-
var RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace], own = {}.hasOwnProperty;
|
|
184
|
-
var isWindows = process.platform === "win32", globalCache = globalThis.__EXSOLVE_CACHE__ ||= /* @__PURE__ */ new Map();
|
|
185
|
-
|
|
186
|
-
// ../../core/src/shared/utils/module.ts
|
|
187
51
|
var importMetaResolve = (...args) => typeof import.meta.resolve != "function" && process.env.VITEST === "true" ? (console.warn(
|
|
188
52
|
"importMetaResolve from within Storybook is being used in a Vitest test, but it shouldn't be. Please report this at https://github.com/storybookjs/storybook/issues/new?template=bug_report.yml"
|
|
189
53
|
), pathToFileURL(args[0]).href) : import.meta.resolve(...args);
|
|
@@ -228,8 +92,8 @@ var MAX_START_TIME = 3e4, vitestModulePath = fileURLToPath2(importMetaResolve("@
|
|
|
228
92
|
);
|
|
229
93
|
})), !processExitHandled) {
|
|
230
94
|
processExitHandled = !0;
|
|
231
|
-
let exit = (
|
|
232
|
-
killChild(), process.exit(
|
|
95
|
+
let exit = (code2 = 0) => {
|
|
96
|
+
killChild(), process.exit(code2);
|
|
233
97
|
};
|
|
234
98
|
process.on("exit", exit), process.on("SIGINT", () => exit(0)), process.on("SIGTERM", () => exit(0));
|
|
235
99
|
}
|
|
@@ -237,7 +101,7 @@ var MAX_START_TIME = 3e4, vitestModulePath = fileURLToPath2(importMetaResolve("@
|
|
|
237
101
|
let storyIndexGenerator = await options.presets.apply("storyIndexGenerator"), previewAnnotations = await getPreviewAnnotations(options);
|
|
238
102
|
if (bootGeneration !== generation)
|
|
239
103
|
throw crashAlreadyReported;
|
|
240
|
-
await new Promise((
|
|
104
|
+
await new Promise((resolve, reject) => {
|
|
241
105
|
child = executeNodeCommand({
|
|
242
106
|
scriptPath: vitestModulePath,
|
|
243
107
|
options: {
|
|
@@ -256,12 +120,12 @@ var MAX_START_TIME = 3e4, vitestModulePath = fileURLToPath2(importMetaResolve("@
|
|
|
256
120
|
}
|
|
257
121
|
}), sentStoryIndex = void 0, stderr = [];
|
|
258
122
|
let spawnedChild = child;
|
|
259
|
-
spawnedChild.on("exit", (
|
|
123
|
+
spawnedChild.on("exit", (code2, signal) => {
|
|
260
124
|
child === spawnedChild && store.send({
|
|
261
125
|
type: "FATAL_ERROR",
|
|
262
126
|
payload: {
|
|
263
127
|
message: "The test runner process exited unexpectedly",
|
|
264
|
-
error: { message: signal ? `Killed by ${signal}` : `Exited with code ${
|
|
128
|
+
error: { message: signal ? `Killed by ${signal}` : `Exited with code ${code2}` }
|
|
265
129
|
}
|
|
266
130
|
}), reject(crashAlreadyReported);
|
|
267
131
|
}), child.stdout?.on("data", log), child.stderr?.on("data", (data) => {
|
|
@@ -275,7 +139,7 @@ var MAX_START_TIME = 3e4, vitestModulePath = fileURLToPath2(importMetaResolve("@
|
|
|
275
139
|
let { type, args } = eventQueue.shift();
|
|
276
140
|
child?.send({ type, args, from: "server" });
|
|
277
141
|
}
|
|
278
|
-
|
|
142
|
+
resolve();
|
|
279
143
|
}
|
|
280
144
|
}, reject) : event.type === "uncaught-error" ? (store.send({
|
|
281
145
|
type: "FATAL_ERROR",
|
|
@@ -358,6 +222,11 @@ import {
|
|
|
358
222
|
experimental_getTestProviderStore
|
|
359
223
|
} from "storybook/internal/core-server";
|
|
360
224
|
|
|
225
|
+
// ../../../node_modules/es-toolkit/dist/_internal/globalThis.mjs
|
|
226
|
+
var globalThis_ = typeof globalThis == "object" && globalThis || typeof window == "object" && window || typeof self == "object" && self || typeof global == "object" && global || /* @__PURE__ */ (function() {
|
|
227
|
+
return this;
|
|
228
|
+
})();
|
|
229
|
+
|
|
361
230
|
// ../../../node_modules/es-toolkit/dist/predicate/isBuffer.mjs
|
|
362
231
|
function isBuffer(x) {
|
|
363
232
|
return typeof globalThis_.Buffer < "u" && globalThis_.Buffer.isBuffer(x);
|
|
@@ -644,6 +513,7 @@ var store$4, DEFAULT_CONFIG = {
|
|
|
644
513
|
abortEarly: void 0,
|
|
645
514
|
abortPipeEarly: void 0
|
|
646
515
|
};
|
|
516
|
+
// @__NO_SIDE_EFFECTS__
|
|
647
517
|
function getGlobalConfig(config$1) {
|
|
648
518
|
return !config$1 && !store$4 ? DEFAULT_CONFIG : {
|
|
649
519
|
lang: config$1?.lang ?? store$4?.lang,
|
|
@@ -653,23 +523,27 @@ function getGlobalConfig(config$1) {
|
|
|
653
523
|
};
|
|
654
524
|
}
|
|
655
525
|
var store$3;
|
|
526
|
+
// @__NO_SIDE_EFFECTS__
|
|
656
527
|
function getGlobalMessage(lang) {
|
|
657
528
|
return store$3?.get(lang);
|
|
658
529
|
}
|
|
659
530
|
var store$2;
|
|
531
|
+
// @__NO_SIDE_EFFECTS__
|
|
660
532
|
function getSchemaMessage(lang) {
|
|
661
533
|
return store$2?.get(lang);
|
|
662
534
|
}
|
|
663
535
|
var store$1;
|
|
536
|
+
// @__NO_SIDE_EFFECTS__
|
|
664
537
|
function getSpecificMessage(reference, lang) {
|
|
665
538
|
return store$1?.get(reference)?.get(lang);
|
|
666
539
|
}
|
|
540
|
+
// @__NO_SIDE_EFFECTS__
|
|
667
541
|
function _stringify(input) {
|
|
668
542
|
let type = typeof input;
|
|
669
543
|
return type === "string" ? `"${input}"` : type === "number" || type === "bigint" || type === "boolean" ? `${input}` : type === "object" || type === "function" ? (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null" : type;
|
|
670
544
|
}
|
|
671
545
|
function _addIssue(context, label, dataset, config$1, other) {
|
|
672
|
-
let input = other && "input" in other ? other.input : dataset.value, expected = other?.expected ?? context.expects ?? null, received = other?.received ?? _stringify(input), issue = {
|
|
546
|
+
let input = other && "input" in other ? other.input : dataset.value, expected = other?.expected ?? context.expects ?? null, received = other?.received ?? /* @__PURE__ */ _stringify(input), issue = {
|
|
673
547
|
kind: context.kind,
|
|
674
548
|
type: context.type,
|
|
675
549
|
input,
|
|
@@ -682,28 +556,32 @@ function _addIssue(context, label, dataset, config$1, other) {
|
|
|
682
556
|
lang: config$1.lang,
|
|
683
557
|
abortEarly: config$1.abortEarly,
|
|
684
558
|
abortPipeEarly: config$1.abortPipeEarly
|
|
685
|
-
}, isSchema = context.kind === "schema", message$1 = other?.message ?? context.message ?? getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? getSchemaMessage(issue.lang) : null) ?? config$1.message ?? getGlobalMessage(issue.lang);
|
|
559
|
+
}, isSchema = context.kind === "schema", message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
|
|
686
560
|
message$1 !== void 0 && (issue.message = typeof message$1 == "function" ? message$1(issue) : message$1), isSchema && (dataset.typed = !1), dataset.issues ? dataset.issues.push(issue) : dataset.issues = [issue];
|
|
687
561
|
}
|
|
688
562
|
var _standardCache = /* @__PURE__ */ new WeakMap();
|
|
563
|
+
// @__NO_SIDE_EFFECTS__
|
|
689
564
|
function _getStandardProps(context) {
|
|
690
565
|
let cached = _standardCache.get(context);
|
|
691
566
|
return cached || (cached = {
|
|
692
567
|
version: 1,
|
|
693
568
|
vendor: "valibot",
|
|
694
569
|
validate(value$1) {
|
|
695
|
-
return context["~run"]({ value: value$1 }, getGlobalConfig());
|
|
570
|
+
return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig());
|
|
696
571
|
}
|
|
697
572
|
}, _standardCache.set(context, cached)), cached;
|
|
698
573
|
}
|
|
574
|
+
// @__NO_SIDE_EFFECTS__
|
|
699
575
|
function _isValidObjectKey(object$1, key) {
|
|
700
576
|
return Object.prototype.hasOwnProperty.call(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
|
|
701
577
|
}
|
|
578
|
+
// @__NO_SIDE_EFFECTS__
|
|
702
579
|
function _joinExpects(values$1, separator) {
|
|
703
580
|
let list = [...new Set(values$1)];
|
|
704
581
|
return list.length > 1 ? `(${list.join(` ${separator} `)})` : list[0] ?? "never";
|
|
705
582
|
}
|
|
706
583
|
var EMOJI_REGEX = new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$", "u");
|
|
584
|
+
// @__NO_SIDE_EFFECTS__
|
|
707
585
|
function description(description_) {
|
|
708
586
|
return {
|
|
709
587
|
kind: "metadata",
|
|
@@ -712,13 +590,31 @@ function description(description_) {
|
|
|
712
590
|
description: description_
|
|
713
591
|
};
|
|
714
592
|
}
|
|
593
|
+
// @__NO_SIDE_EFFECTS__
|
|
594
|
+
function minLength(requirement, message$1) {
|
|
595
|
+
return {
|
|
596
|
+
kind: "validation",
|
|
597
|
+
type: "min_length",
|
|
598
|
+
reference: minLength,
|
|
599
|
+
async: !1,
|
|
600
|
+
expects: `>=${requirement}`,
|
|
601
|
+
requirement,
|
|
602
|
+
message: message$1,
|
|
603
|
+
"~run"(dataset, config$1) {
|
|
604
|
+
return dataset.typed && dataset.value.length < this.requirement && _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` }), dataset;
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
}
|
|
715
608
|
var ABORT_EARLY_CONFIG = { abortEarly: !0 };
|
|
609
|
+
// @__NO_SIDE_EFFECTS__
|
|
716
610
|
function getFallback(schema, dataset, config$1) {
|
|
717
611
|
return typeof schema.fallback == "function" ? schema.fallback(dataset, config$1) : schema.fallback;
|
|
718
612
|
}
|
|
613
|
+
// @__NO_SIDE_EFFECTS__
|
|
719
614
|
function getDefault(schema, dataset, config$1) {
|
|
720
615
|
return typeof schema.default == "function" ? schema.default(dataset, config$1) : schema.default;
|
|
721
616
|
}
|
|
617
|
+
// @__NO_SIDE_EFFECTS__
|
|
722
618
|
function any() {
|
|
723
619
|
return {
|
|
724
620
|
kind: "schema",
|
|
@@ -727,13 +623,14 @@ function any() {
|
|
|
727
623
|
expects: "any",
|
|
728
624
|
async: !1,
|
|
729
625
|
get "~standard"() {
|
|
730
|
-
return _getStandardProps(this);
|
|
626
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
731
627
|
},
|
|
732
628
|
"~run"(dataset) {
|
|
733
629
|
return dataset.typed = !0, dataset;
|
|
734
630
|
}
|
|
735
631
|
};
|
|
736
632
|
}
|
|
633
|
+
// @__NO_SIDE_EFFECTS__
|
|
737
634
|
function array(item, message$1) {
|
|
738
635
|
return {
|
|
739
636
|
kind: "schema",
|
|
@@ -744,7 +641,7 @@ function array(item, message$1) {
|
|
|
744
641
|
item,
|
|
745
642
|
message: message$1,
|
|
746
643
|
get "~standard"() {
|
|
747
|
-
return _getStandardProps(this);
|
|
644
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
748
645
|
},
|
|
749
646
|
"~run"(dataset, config$1) {
|
|
750
647
|
let input = dataset.value;
|
|
@@ -774,6 +671,7 @@ function array(item, message$1) {
|
|
|
774
671
|
}
|
|
775
672
|
};
|
|
776
673
|
}
|
|
674
|
+
// @__NO_SIDE_EFFECTS__
|
|
777
675
|
function boolean(message$1) {
|
|
778
676
|
return {
|
|
779
677
|
kind: "schema",
|
|
@@ -783,13 +681,14 @@ function boolean(message$1) {
|
|
|
783
681
|
async: !1,
|
|
784
682
|
message: message$1,
|
|
785
683
|
get "~standard"() {
|
|
786
|
-
return _getStandardProps(this);
|
|
684
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
787
685
|
},
|
|
788
686
|
"~run"(dataset, config$1) {
|
|
789
687
|
return typeof dataset.value == "boolean" ? dataset.typed = !0 : _addIssue(this, "type", dataset, config$1), dataset;
|
|
790
688
|
}
|
|
791
689
|
};
|
|
792
690
|
}
|
|
691
|
+
// @__NO_SIDE_EFFECTS__
|
|
793
692
|
function lazy(getter) {
|
|
794
693
|
return {
|
|
795
694
|
kind: "schema",
|
|
@@ -799,30 +698,32 @@ function lazy(getter) {
|
|
|
799
698
|
async: !1,
|
|
800
699
|
getter,
|
|
801
700
|
get "~standard"() {
|
|
802
|
-
return _getStandardProps(this);
|
|
701
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
803
702
|
},
|
|
804
703
|
"~run"(dataset, config$1) {
|
|
805
704
|
return this.getter(dataset.value)["~run"](dataset, config$1);
|
|
806
705
|
}
|
|
807
706
|
};
|
|
808
707
|
}
|
|
708
|
+
// @__NO_SIDE_EFFECTS__
|
|
809
709
|
function literal(literal_, message$1) {
|
|
810
710
|
return {
|
|
811
711
|
kind: "schema",
|
|
812
712
|
type: "literal",
|
|
813
713
|
reference: literal,
|
|
814
|
-
expects: _stringify(literal_),
|
|
714
|
+
expects: /* @__PURE__ */ _stringify(literal_),
|
|
815
715
|
async: !1,
|
|
816
716
|
literal: literal_,
|
|
817
717
|
message: message$1,
|
|
818
718
|
get "~standard"() {
|
|
819
|
-
return _getStandardProps(this);
|
|
719
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
820
720
|
},
|
|
821
721
|
"~run"(dataset, config$1) {
|
|
822
722
|
return dataset.value === this.literal ? dataset.typed = !0 : _addIssue(this, "type", dataset, config$1), dataset;
|
|
823
723
|
}
|
|
824
724
|
};
|
|
825
725
|
}
|
|
726
|
+
// @__NO_SIDE_EFFECTS__
|
|
826
727
|
function looseObject(entries$1, message$1) {
|
|
827
728
|
return {
|
|
828
729
|
kind: "schema",
|
|
@@ -833,7 +734,7 @@ function looseObject(entries$1, message$1) {
|
|
|
833
734
|
entries: entries$1,
|
|
834
735
|
message: message$1,
|
|
835
736
|
get "~standard"() {
|
|
836
|
-
return _getStandardProps(this);
|
|
737
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
837
738
|
},
|
|
838
739
|
"~run"(dataset, config$1) {
|
|
839
740
|
let input = dataset.value;
|
|
@@ -842,7 +743,7 @@ function looseObject(entries$1, message$1) {
|
|
|
842
743
|
for (let key in this.entries) {
|
|
843
744
|
let valueSchema = this.entries[key];
|
|
844
745
|
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
845
|
-
let value$1 = key in input ? input[key] : getDefault(valueSchema), valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
|
|
746
|
+
let value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema), valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
|
|
846
747
|
if (valueDataset.issues) {
|
|
847
748
|
let pathItem = {
|
|
848
749
|
type: "object",
|
|
@@ -859,7 +760,7 @@ function looseObject(entries$1, message$1) {
|
|
|
859
760
|
}
|
|
860
761
|
}
|
|
861
762
|
valueDataset.typed || (dataset.typed = !1), dataset.value[key] = valueDataset.value;
|
|
862
|
-
} else if (valueSchema.fallback !== void 0) dataset.value[key] = getFallback(valueSchema);
|
|
763
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
863
764
|
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish" && (_addIssue(this, "key", dataset, config$1, {
|
|
864
765
|
input: void 0,
|
|
865
766
|
expected: `"${key}"`,
|
|
@@ -874,12 +775,13 @@ function looseObject(entries$1, message$1) {
|
|
|
874
775
|
break;
|
|
875
776
|
}
|
|
876
777
|
if (!dataset.issues || !config$1.abortEarly)
|
|
877
|
-
for (let key in input) _isValidObjectKey(input, key) && !(key in this.entries) && (dataset.value[key] = input[key]);
|
|
778
|
+
for (let key in input) /* @__PURE__ */ _isValidObjectKey(input, key) && !(key in this.entries) && (dataset.value[key] = input[key]);
|
|
878
779
|
} else _addIssue(this, "type", dataset, config$1);
|
|
879
780
|
return dataset;
|
|
880
781
|
}
|
|
881
782
|
};
|
|
882
783
|
}
|
|
784
|
+
// @__NO_SIDE_EFFECTS__
|
|
883
785
|
function number(message$1) {
|
|
884
786
|
return {
|
|
885
787
|
kind: "schema",
|
|
@@ -889,13 +791,14 @@ function number(message$1) {
|
|
|
889
791
|
async: !1,
|
|
890
792
|
message: message$1,
|
|
891
793
|
get "~standard"() {
|
|
892
|
-
return _getStandardProps(this);
|
|
794
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
893
795
|
},
|
|
894
796
|
"~run"(dataset, config$1) {
|
|
895
797
|
return typeof dataset.value == "number" && !isNaN(dataset.value) ? dataset.typed = !0 : _addIssue(this, "type", dataset, config$1), dataset;
|
|
896
798
|
}
|
|
897
799
|
};
|
|
898
800
|
}
|
|
801
|
+
// @__NO_SIDE_EFFECTS__
|
|
899
802
|
function object(entries$1, message$1) {
|
|
900
803
|
return {
|
|
901
804
|
kind: "schema",
|
|
@@ -906,7 +809,7 @@ function object(entries$1, message$1) {
|
|
|
906
809
|
entries: entries$1,
|
|
907
810
|
message: message$1,
|
|
908
811
|
get "~standard"() {
|
|
909
|
-
return _getStandardProps(this);
|
|
812
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
910
813
|
},
|
|
911
814
|
"~run"(dataset, config$1) {
|
|
912
815
|
let input = dataset.value;
|
|
@@ -915,7 +818,7 @@ function object(entries$1, message$1) {
|
|
|
915
818
|
for (let key in this.entries) {
|
|
916
819
|
let valueSchema = this.entries[key];
|
|
917
820
|
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
918
|
-
let value$1 = key in input ? input[key] : getDefault(valueSchema), valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
|
|
821
|
+
let value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema), valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
|
|
919
822
|
if (valueDataset.issues) {
|
|
920
823
|
let pathItem = {
|
|
921
824
|
type: "object",
|
|
@@ -932,7 +835,7 @@ function object(entries$1, message$1) {
|
|
|
932
835
|
}
|
|
933
836
|
}
|
|
934
837
|
valueDataset.typed || (dataset.typed = !1), dataset.value[key] = valueDataset.value;
|
|
935
|
-
} else if (valueSchema.fallback !== void 0) dataset.value[key] = getFallback(valueSchema);
|
|
838
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
936
839
|
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish" && (_addIssue(this, "key", dataset, config$1, {
|
|
937
840
|
input: void 0,
|
|
938
841
|
expected: `"${key}"`,
|
|
@@ -951,6 +854,7 @@ function object(entries$1, message$1) {
|
|
|
951
854
|
}
|
|
952
855
|
};
|
|
953
856
|
}
|
|
857
|
+
// @__NO_SIDE_EFFECTS__
|
|
954
858
|
function optional(wrapped, default_) {
|
|
955
859
|
return {
|
|
956
860
|
kind: "schema",
|
|
@@ -961,13 +865,14 @@ function optional(wrapped, default_) {
|
|
|
961
865
|
wrapped,
|
|
962
866
|
default: default_,
|
|
963
867
|
get "~standard"() {
|
|
964
|
-
return _getStandardProps(this);
|
|
868
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
965
869
|
},
|
|
966
870
|
"~run"(dataset, config$1) {
|
|
967
|
-
return dataset.value === void 0 && (this.default !== void 0 && (dataset.value = getDefault(this, dataset, config$1)), dataset.value === void 0) ? (dataset.typed = !0, dataset) : this.wrapped["~run"](dataset, config$1);
|
|
871
|
+
return dataset.value === void 0 && (this.default !== void 0 && (dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1)), dataset.value === void 0) ? (dataset.typed = !0, dataset) : this.wrapped["~run"](dataset, config$1);
|
|
968
872
|
}
|
|
969
873
|
};
|
|
970
874
|
}
|
|
875
|
+
// @__NO_SIDE_EFFECTS__
|
|
971
876
|
function record(key, value$1, message$1) {
|
|
972
877
|
return {
|
|
973
878
|
kind: "schema",
|
|
@@ -979,13 +884,13 @@ function record(key, value$1, message$1) {
|
|
|
979
884
|
value: value$1,
|
|
980
885
|
message: message$1,
|
|
981
886
|
get "~standard"() {
|
|
982
|
-
return _getStandardProps(this);
|
|
887
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
983
888
|
},
|
|
984
889
|
"~run"(dataset, config$1) {
|
|
985
890
|
let input = dataset.value;
|
|
986
891
|
if (input && typeof input == "object") {
|
|
987
892
|
dataset.typed = !0, dataset.value = {};
|
|
988
|
-
for (let entryKey in input) if (_isValidObjectKey(input, entryKey)) {
|
|
893
|
+
for (let entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
|
|
989
894
|
let entryValue = input[entryKey], keyDataset = this.key["~run"]({ value: entryKey }, config$1);
|
|
990
895
|
if (keyDataset.issues) {
|
|
991
896
|
let pathItem = {
|
|
@@ -1025,6 +930,7 @@ function record(key, value$1, message$1) {
|
|
|
1025
930
|
}
|
|
1026
931
|
};
|
|
1027
932
|
}
|
|
933
|
+
// @__NO_SIDE_EFFECTS__
|
|
1028
934
|
function strictObject(entries$1, message$1) {
|
|
1029
935
|
return {
|
|
1030
936
|
kind: "schema",
|
|
@@ -1035,7 +941,7 @@ function strictObject(entries$1, message$1) {
|
|
|
1035
941
|
entries: entries$1,
|
|
1036
942
|
message: message$1,
|
|
1037
943
|
get "~standard"() {
|
|
1038
|
-
return _getStandardProps(this);
|
|
944
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1039
945
|
},
|
|
1040
946
|
"~run"(dataset, config$1) {
|
|
1041
947
|
let input = dataset.value;
|
|
@@ -1044,7 +950,7 @@ function strictObject(entries$1, message$1) {
|
|
|
1044
950
|
for (let key in this.entries) {
|
|
1045
951
|
let valueSchema = this.entries[key];
|
|
1046
952
|
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
1047
|
-
let value$1 = key in input ? input[key] : getDefault(valueSchema), valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
|
|
953
|
+
let value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema), valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
|
|
1048
954
|
if (valueDataset.issues) {
|
|
1049
955
|
let pathItem = {
|
|
1050
956
|
type: "object",
|
|
@@ -1061,7 +967,7 @@ function strictObject(entries$1, message$1) {
|
|
|
1061
967
|
}
|
|
1062
968
|
}
|
|
1063
969
|
valueDataset.typed || (dataset.typed = !1), dataset.value[key] = valueDataset.value;
|
|
1064
|
-
} else if (valueSchema.fallback !== void 0) dataset.value[key] = getFallback(valueSchema);
|
|
970
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
1065
971
|
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish" && (_addIssue(this, "key", dataset, config$1, {
|
|
1066
972
|
input: void 0,
|
|
1067
973
|
expected: `"${key}"`,
|
|
@@ -1096,6 +1002,7 @@ function strictObject(entries$1, message$1) {
|
|
|
1096
1002
|
}
|
|
1097
1003
|
};
|
|
1098
1004
|
}
|
|
1005
|
+
// @__NO_SIDE_EFFECTS__
|
|
1099
1006
|
function string(message$1) {
|
|
1100
1007
|
return {
|
|
1101
1008
|
kind: "schema",
|
|
@@ -1105,30 +1012,32 @@ function string(message$1) {
|
|
|
1105
1012
|
async: !1,
|
|
1106
1013
|
message: message$1,
|
|
1107
1014
|
get "~standard"() {
|
|
1108
|
-
return _getStandardProps(this);
|
|
1015
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1109
1016
|
},
|
|
1110
1017
|
"~run"(dataset, config$1) {
|
|
1111
1018
|
return typeof dataset.value == "string" ? dataset.typed = !0 : _addIssue(this, "type", dataset, config$1), dataset;
|
|
1112
1019
|
}
|
|
1113
1020
|
};
|
|
1114
1021
|
}
|
|
1022
|
+
// @__NO_SIDE_EFFECTS__
|
|
1115
1023
|
function _subIssues(datasets) {
|
|
1116
1024
|
let issues;
|
|
1117
1025
|
if (datasets) for (let dataset of datasets) if (issues) for (let issue of dataset.issues) issues.push(issue);
|
|
1118
1026
|
else issues = dataset.issues;
|
|
1119
1027
|
return issues;
|
|
1120
1028
|
}
|
|
1029
|
+
// @__NO_SIDE_EFFECTS__
|
|
1121
1030
|
function union(options, message$1) {
|
|
1122
1031
|
return {
|
|
1123
1032
|
kind: "schema",
|
|
1124
1033
|
type: "union",
|
|
1125
1034
|
reference: union,
|
|
1126
|
-
expects: _joinExpects(options.map((option) => option.expects), "|"),
|
|
1035
|
+
expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
|
|
1127
1036
|
async: !1,
|
|
1128
1037
|
options,
|
|
1129
1038
|
message: message$1,
|
|
1130
1039
|
get "~standard"() {
|
|
1131
|
-
return _getStandardProps(this);
|
|
1040
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1132
1041
|
},
|
|
1133
1042
|
"~run"(dataset, config$1) {
|
|
1134
1043
|
let validDataset, typedDatasets, untypedDatasets;
|
|
@@ -1144,15 +1053,16 @@ function union(options, message$1) {
|
|
|
1144
1053
|
if (validDataset) return validDataset;
|
|
1145
1054
|
if (typedDatasets) {
|
|
1146
1055
|
if (typedDatasets.length === 1) return typedDatasets[0];
|
|
1147
|
-
_addIssue(this, "type", dataset, config$1, { issues: _subIssues(typedDatasets) }), dataset.typed = !0;
|
|
1056
|
+
_addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) }), dataset.typed = !0;
|
|
1148
1057
|
} else {
|
|
1149
1058
|
if (untypedDatasets?.length === 1) return untypedDatasets[0];
|
|
1150
|
-
_addIssue(this, "type", dataset, config$1, { issues: _subIssues(untypedDatasets) });
|
|
1059
|
+
_addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
|
|
1151
1060
|
}
|
|
1152
1061
|
return dataset;
|
|
1153
1062
|
}
|
|
1154
1063
|
};
|
|
1155
1064
|
}
|
|
1065
|
+
// @__NO_SIDE_EFFECTS__
|
|
1156
1066
|
function variant(key, options, message$1) {
|
|
1157
1067
|
return {
|
|
1158
1068
|
kind: "schema",
|
|
@@ -1164,7 +1074,7 @@ function variant(key, options, message$1) {
|
|
|
1164
1074
|
options,
|
|
1165
1075
|
message: message$1,
|
|
1166
1076
|
get "~standard"() {
|
|
1167
|
-
return _getStandardProps(this);
|
|
1077
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1168
1078
|
},
|
|
1169
1079
|
"~run"(dataset, config$1) {
|
|
1170
1080
|
let input = dataset.value;
|
|
@@ -1196,7 +1106,7 @@ function variant(key, options, message$1) {
|
|
|
1196
1106
|
if (parseOptions(this, /* @__PURE__ */ new Set([this.key])), outputDataset) return outputDataset;
|
|
1197
1107
|
_addIssue(this, "type", dataset, config$1, {
|
|
1198
1108
|
input: input[invalidDiscriminatorKey],
|
|
1199
|
-
expected: _joinExpects(expectedDiscriminators, "|"),
|
|
1109
|
+
expected: /* @__PURE__ */ _joinExpects(expectedDiscriminators, "|"),
|
|
1200
1110
|
path: [{
|
|
1201
1111
|
type: "object",
|
|
1202
1112
|
origin: "value",
|
|
@@ -1210,12 +1120,13 @@ function variant(key, options, message$1) {
|
|
|
1210
1120
|
}
|
|
1211
1121
|
};
|
|
1212
1122
|
}
|
|
1123
|
+
// @__NO_SIDE_EFFECTS__
|
|
1213
1124
|
function pipe(...pipe$1) {
|
|
1214
1125
|
return {
|
|
1215
1126
|
...pipe$1[0],
|
|
1216
1127
|
pipe: pipe$1,
|
|
1217
1128
|
get "~standard"() {
|
|
1218
|
-
return _getStandardProps(this);
|
|
1129
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1219
1130
|
},
|
|
1220
1131
|
"~run"(dataset, config$1) {
|
|
1221
1132
|
for (let item of pipe$1) if (item.kind !== "metadata") {
|
|
@@ -1236,7 +1147,8 @@ import {
|
|
|
1236
1147
|
} from "storybook/internal/core-server";
|
|
1237
1148
|
import {
|
|
1238
1149
|
defineToolset,
|
|
1239
|
-
getSkillCommand
|
|
1150
|
+
getSkillCommand,
|
|
1151
|
+
getToolset
|
|
1240
1152
|
} from "storybook/open-service";
|
|
1241
1153
|
|
|
1242
1154
|
// src/node/toolset/format.ts
|
|
@@ -1384,15 +1296,74 @@ var FAILURE_LABELS = {
|
|
|
1384
1296
|
a11yChecks: (count) => `${pluralize(count, "accessibility check")} failed`,
|
|
1385
1297
|
unhandledErrors: (count) => pluralize(count, "unhandled error")
|
|
1386
1298
|
};
|
|
1387
|
-
function
|
|
1388
|
-
|
|
1299
|
+
function displayPath(file) {
|
|
1300
|
+
if (!isAbsolute(file))
|
|
1301
|
+
return file;
|
|
1302
|
+
let fromCwd = relative(process.cwd(), file);
|
|
1303
|
+
return fromCwd.startsWith("..") ? file : fromCwd;
|
|
1304
|
+
}
|
|
1305
|
+
function code(value) {
|
|
1306
|
+
return `\`${value}\``;
|
|
1307
|
+
}
|
|
1308
|
+
function sinceRef({ since }) {
|
|
1309
|
+
return since === void 0 ? "" : ` since ${code(since)}`;
|
|
1310
|
+
}
|
|
1311
|
+
function formatChangedConfigFiles(changed) {
|
|
1312
|
+
return [
|
|
1313
|
+
...changed?.pendingFiles.length ? [
|
|
1314
|
+
`Change detection has not caught up with these changed files yet, so their stories may be missing: ${changed.pendingFiles.map(code).join(", ")}. Run this again in a moment.`
|
|
1315
|
+
] : [],
|
|
1316
|
+
...changed?.changedConfigFiles.length ? [
|
|
1317
|
+
`Changed files in the Storybook config directory, which can affect every story: ${changed.changedConfigFiles.map(code).join(", ")}.`
|
|
1318
|
+
] : []
|
|
1319
|
+
];
|
|
1320
|
+
}
|
|
1321
|
+
function formatSelection(selection) {
|
|
1322
|
+
let parts = [];
|
|
1323
|
+
if (selection.files) {
|
|
1324
|
+
let { filters, storyFileCount } = selection.files;
|
|
1325
|
+
parts.push(
|
|
1326
|
+
`${pluralize(storyFileCount, "story file")} ${storyFileCount === 1 ? "matches" : "match"} ${filters.map((filter) => code(displayPath(filter))).join(", ")}`
|
|
1327
|
+
);
|
|
1328
|
+
}
|
|
1329
|
+
selection.changed && parts.push(
|
|
1330
|
+
`${pluralize(selection.changed.storyCount, "changed story", "changed stories")}${sinceRef(selection.changed)}`
|
|
1331
|
+
);
|
|
1332
|
+
let selected = selection.storyCount;
|
|
1333
|
+
if (!(parts.length === 0 || selected === void 0))
|
|
1334
|
+
return `${parts.join("; ")}: selected ${pluralize(selected, "story", "stories")}.`;
|
|
1335
|
+
}
|
|
1336
|
+
var A11Y_GUIDANCE = "Accessibility violations: fix only what your change caused, and report the rest. For visual ones such as color contrast, ask before changing the design.";
|
|
1337
|
+
function formatResultSection(result, {
|
|
1338
|
+
a11y,
|
|
1339
|
+
a11yEnabled,
|
|
1340
|
+
selection,
|
|
1341
|
+
notFound = []
|
|
1342
|
+
}) {
|
|
1343
|
+
let failures = countTestRunFailures(result, a11y), testFailureParts = Object.keys(FAILURE_LABELS).filter((key) => failures[key] > 0).map((key) => FAILURE_LABELS[key](failures[key])), failureParts = [
|
|
1344
|
+
...notFound.length > 0 ? [`${pluralize(notFound.length, "argument")} not used`] : [],
|
|
1345
|
+
...testFailureParts
|
|
1346
|
+
], passed = result.componentTestCount.success, verdict = failureParts.length > 0 ? `Failed: ${failureParts.join(", ")}${passed > 0 && testFailureParts.length === 0 ? `; ${pluralize(passed, "component test")} passed` : ""}.` : passed === 0 ? "No component tests ran." : `Passed: ${pluralize(passed, "component test")} passed.`;
|
|
1389
1347
|
return `## Result
|
|
1390
1348
|
|
|
1391
|
-
${
|
|
1392
|
-
|
|
1349
|
+
${[
|
|
1350
|
+
...[selection && formatSelection(selection)].filter((line) => !!line),
|
|
1351
|
+
...formatChangedConfigFiles(selection?.changed),
|
|
1352
|
+
...notFound,
|
|
1353
|
+
verdict,
|
|
1354
|
+
formatA11yResult(result, { a11y, a11yEnabled }),
|
|
1355
|
+
...a11y && countA11yViolations(getA11yReports(result)) > 0 ? [A11Y_GUIDANCE] : []
|
|
1356
|
+
].join(`
|
|
1357
|
+
`)}`;
|
|
1393
1358
|
}
|
|
1394
|
-
function formatCompletedRun(result, {
|
|
1395
|
-
|
|
1359
|
+
function formatCompletedRun(result, {
|
|
1360
|
+
a11y,
|
|
1361
|
+
a11yEnabled,
|
|
1362
|
+
selection,
|
|
1363
|
+
notFound,
|
|
1364
|
+
ctx
|
|
1365
|
+
}) {
|
|
1366
|
+
let { origin } = ctx, sections = [], a11yFailingStoryIds = new Set(
|
|
1396
1367
|
a11y ? result.a11yStatuses.filter(isFailing).map((status) => status.storyId) : []
|
|
1397
1368
|
), passingStories = result.componentTestStatuses.filter(
|
|
1398
1369
|
(status) => isPassing(status) && !a11yFailingStoryIds.has(status.storyId)
|
|
@@ -1405,22 +1376,46 @@ function formatCompletedRun(result, { a11y, a11yEnabled, origin }) {
|
|
|
1405
1376
|
let a11ySection = formatA11yReportsSection({ a11yReports, origin });
|
|
1406
1377
|
a11ySection && sections.push(a11ySection);
|
|
1407
1378
|
}
|
|
1408
|
-
return result.unhandledErrors.length > 0 && sections.push(formatUnhandledErrorsSection(result.unhandledErrors)), sections.push(formatResultSection(result, { a11y, a11yEnabled })), sections.join(`
|
|
1379
|
+
return result.unhandledErrors.length > 0 && sections.push(formatUnhandledErrorsSection(result.unhandledErrors)), sections.push(formatResultSection(result, { a11y, a11yEnabled, selection, notFound })), sections.join(`
|
|
1409
1380
|
|
|
1410
1381
|
`);
|
|
1411
1382
|
}
|
|
1383
|
+
function argument(ctx, cli, mcp) {
|
|
1384
|
+
return code(ctx.transport === "cli" ? cli : mcp);
|
|
1385
|
+
}
|
|
1386
|
+
function formatNoStories({ notFoundMessages, selection }, ctx) {
|
|
1387
|
+
if (notFoundMessages.length > 0)
|
|
1388
|
+
return `No stories found matching the provided input.
|
|
1389
|
+
|
|
1390
|
+
${notFoundMessages.join(`
|
|
1391
|
+
`)}`;
|
|
1392
|
+
if (selection?.files?.storyFileCount === 0)
|
|
1393
|
+
return `No story files found for ${selection.files.filters.map((filter) => code(displayPath(filter))).join(", ")}, so no tests ran.`;
|
|
1394
|
+
if (selection?.changed) {
|
|
1395
|
+
let what = `${selection.changed.storyCount > 0 ? "None of the selected stories changed" : "No stories changed"}${sinceRef(selection.changed)}`, more = [
|
|
1396
|
+
...selection.changed.since === void 0 ? [`a ref (${argument(ctx, "--changed main", 'changed: "main"')})`] : [],
|
|
1397
|
+
...selection.files ? [] : ["story files"]
|
|
1398
|
+
];
|
|
1399
|
+
return [
|
|
1400
|
+
`${what}, so no tests ran.`,
|
|
1401
|
+
...formatChangedConfigFiles(selection.changed),
|
|
1402
|
+
...more.length > 0 ? [`To test more, pass ${more.join(" or ")}.`] : []
|
|
1403
|
+
].join(`
|
|
1404
|
+
`);
|
|
1405
|
+
}
|
|
1406
|
+
return selection?.files && selection.inputStoryCount ? "None of the given story IDs is in the matched story files, so no tests ran." : "No stories were given, so no tests ran.";
|
|
1407
|
+
}
|
|
1412
1408
|
function formatTestRun(data, ctx, { a11yEnabled }) {
|
|
1413
1409
|
switch (data.status) {
|
|
1414
1410
|
case "no-stories":
|
|
1415
|
-
return data
|
|
1416
|
-
|
|
1417
|
-
${data.notFoundMessages.join(`
|
|
1418
|
-
`)}`;
|
|
1411
|
+
return formatNoStories(data, ctx);
|
|
1419
1412
|
case "completed":
|
|
1420
1413
|
return formatCompletedRun(data.result, {
|
|
1421
1414
|
a11y: data.a11y,
|
|
1422
1415
|
a11yEnabled,
|
|
1423
|
-
|
|
1416
|
+
selection: data.selection,
|
|
1417
|
+
notFound: data.notFoundMessages,
|
|
1418
|
+
ctx
|
|
1424
1419
|
});
|
|
1425
1420
|
case "error":
|
|
1426
1421
|
return `Error: ${data.error.message}`;
|
|
@@ -1433,6 +1428,7 @@ ${data.notFoundMessages.join(`
|
|
|
1433
1428
|
|
|
1434
1429
|
// src/node/toolset/run.ts
|
|
1435
1430
|
import {
|
|
1431
|
+
filterStoryFiles,
|
|
1436
1432
|
findStoryIds
|
|
1437
1433
|
} from "storybook/internal/core-server";
|
|
1438
1434
|
import { OpenServiceTestRunTimeoutError } from "storybook/internal/server-errors";
|
|
@@ -1440,8 +1436,8 @@ var DEFAULT_TEST_RUN_TIMEOUT_MS = 1800 * 1e3;
|
|
|
1440
1436
|
function createAsyncQueue() {
|
|
1441
1437
|
let tail = Promise.resolve();
|
|
1442
1438
|
async function wait() {
|
|
1443
|
-
let done, gate = new Promise((
|
|
1444
|
-
done =
|
|
1439
|
+
let done, gate = new Promise((resolve) => {
|
|
1440
|
+
done = resolve;
|
|
1445
1441
|
}), previousTail = tail;
|
|
1446
1442
|
return tail = previousTail.then(
|
|
1447
1443
|
() => gate,
|
|
@@ -1460,7 +1456,7 @@ function triggerTestRun({
|
|
|
1460
1456
|
actor,
|
|
1461
1457
|
timeoutMs = DEFAULT_TEST_RUN_TIMEOUT_MS
|
|
1462
1458
|
}) {
|
|
1463
|
-
return new Promise((
|
|
1459
|
+
return new Promise((resolve, reject) => {
|
|
1464
1460
|
let requestId = `osa-test-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, settled = !1, timeoutId, cleanup = () => {
|
|
1465
1461
|
timeoutId !== void 0 && (clearTimeout(timeoutId), timeoutId = void 0), channel.off(responseEvent, handleResponse);
|
|
1466
1462
|
}, settle = (callback) => {
|
|
@@ -1471,7 +1467,7 @@ function triggerTestRun({
|
|
|
1471
1467
|
case "completed":
|
|
1472
1468
|
case "error":
|
|
1473
1469
|
case "cancelled":
|
|
1474
|
-
settle(() =>
|
|
1470
|
+
settle(() => resolve(payload));
|
|
1475
1471
|
break;
|
|
1476
1472
|
default: {
|
|
1477
1473
|
let _exhaustive = payload.status;
|
|
@@ -1498,23 +1494,47 @@ async function runStoryTests({
|
|
|
1498
1494
|
channel,
|
|
1499
1495
|
getIndex,
|
|
1500
1496
|
stories,
|
|
1497
|
+
files,
|
|
1498
|
+
changed,
|
|
1499
|
+
getChangedStories: getChangedStories2,
|
|
1501
1500
|
a11y = !0,
|
|
1502
1501
|
actor = "core/test",
|
|
1503
1502
|
requestEvent = TRIGGER_TEST_RUN_REQUEST,
|
|
1504
1503
|
responseEvent = TRIGGER_TEST_RUN_RESPONSE,
|
|
1505
1504
|
timeoutMs = DEFAULT_TEST_RUN_TIMEOUT_MS
|
|
1506
1505
|
}) {
|
|
1507
|
-
let storyIds;
|
|
1508
|
-
if (stories) {
|
|
1509
|
-
let
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
if (
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1506
|
+
let storyIds, selection, notFoundMessages = [], filters = files?.length ? files : void 0;
|
|
1507
|
+
if (stories || filters || changed) {
|
|
1508
|
+
let since = typeof changed == "string" ? changed : void 0, changedStories = changed ? await getChangedStories2(since) : void 0, index = await getIndex(), candidates, narrow = (ids) => {
|
|
1509
|
+
candidates = new Set(candidates ? ids.filter((id) => candidates.has(id)) : ids);
|
|
1510
|
+
};
|
|
1511
|
+
if (selection = {}, filters) {
|
|
1512
|
+
let matched = filterStoryFiles({ index, filters });
|
|
1513
|
+
selection.files = { filters, storyFileCount: matched.storyFiles.length }, matched.storyFiles.length === 0 && !changed && notFoundMessages.push(
|
|
1514
|
+
`No story files found for ${filters.map((file) => `\`${displayPath(file)}\``).join(", ")}.`
|
|
1515
|
+
), narrow(matched.storyIds);
|
|
1516
|
+
}
|
|
1517
|
+
if (changedStories) {
|
|
1518
|
+
let { storyIds: changedIds, changedConfigFiles, pendingFiles } = changedStories;
|
|
1519
|
+
selection.changed = {
|
|
1520
|
+
storyCount: changedIds.length,
|
|
1521
|
+
changedConfigFiles,
|
|
1522
|
+
pendingFiles,
|
|
1523
|
+
...since === void 0 ? {} : { since }
|
|
1524
|
+
}, narrow(changedIds);
|
|
1525
|
+
}
|
|
1526
|
+
if (stories) {
|
|
1527
|
+
selection.inputStoryCount = stories.length;
|
|
1528
|
+
let resolved = findStoryIds(index, stories);
|
|
1529
|
+
notFoundMessages.push(
|
|
1530
|
+
...resolved.filter((story) => !("entry" in story)).map((story) => story.errorMessage)
|
|
1531
|
+
), narrow(
|
|
1532
|
+
resolved.filter((story) => "entry" in story).map((story) => story.entry.id)
|
|
1533
|
+
);
|
|
1534
|
+
}
|
|
1535
|
+
if (candidates?.size === 0)
|
|
1536
|
+
return { status: "no-stories", notFoundMessages, selection };
|
|
1537
|
+
storyIds = candidates ? [...candidates] : void 0, selection.storyCount = storyIds?.length;
|
|
1518
1538
|
}
|
|
1519
1539
|
let response;
|
|
1520
1540
|
try {
|
|
@@ -1537,7 +1557,12 @@ async function runStoryTests({
|
|
|
1537
1557
|
}
|
|
1538
1558
|
switch (response.status) {
|
|
1539
1559
|
case "completed":
|
|
1540
|
-
return response.result ? {
|
|
1560
|
+
return response.result ? {
|
|
1561
|
+
status: "completed",
|
|
1562
|
+
result: response.result,
|
|
1563
|
+
...selection ? { selection } : {},
|
|
1564
|
+
...notFoundMessages.length > 0 ? { notFoundMessages } : {}
|
|
1565
|
+
} : {
|
|
1541
1566
|
status: "error",
|
|
1542
1567
|
error: { message: "Test run completed but no result was returned" }
|
|
1543
1568
|
};
|
|
@@ -1603,15 +1628,37 @@ var errorLikeSchema = object({
|
|
|
1603
1628
|
percentage: number()
|
|
1604
1629
|
})
|
|
1605
1630
|
)
|
|
1631
|
+
}), selectionSchema = object({
|
|
1632
|
+
files: optional(object({ filters: array(string()), storyFileCount: number() })),
|
|
1633
|
+
changed: optional(
|
|
1634
|
+
object({
|
|
1635
|
+
/** How many stories `stories changed` listed. */
|
|
1636
|
+
storyCount: number(),
|
|
1637
|
+
/** The git ref the changes are listed since, when one was passed. */
|
|
1638
|
+
since: optional(string()),
|
|
1639
|
+
/** Changed files in the Storybook config directory, which can affect every story. */
|
|
1640
|
+
changedConfigFiles: array(string()),
|
|
1641
|
+
/** Changed files change detection has not caught up with yet. */
|
|
1642
|
+
pendingFiles: array(string())
|
|
1643
|
+
})
|
|
1644
|
+
),
|
|
1645
|
+
/** How many story ids `stories` gave. */
|
|
1646
|
+
inputStoryCount: optional(number()),
|
|
1647
|
+
/** Stories the run was asked for. */
|
|
1648
|
+
storyCount: optional(number())
|
|
1606
1649
|
}), testRunOutputSchema = variant("status", [
|
|
1607
1650
|
object({
|
|
1608
1651
|
status: literal("no-stories"),
|
|
1609
|
-
/**
|
|
1610
|
-
notFoundMessages: array(string())
|
|
1652
|
+
/** Why the selection is empty when that is a mistake; empty when nothing was affected. */
|
|
1653
|
+
notFoundMessages: array(string()),
|
|
1654
|
+
selection: optional(selectionSchema)
|
|
1611
1655
|
}),
|
|
1612
1656
|
object({
|
|
1613
1657
|
status: literal("completed"),
|
|
1614
|
-
result: testRunResultSchema
|
|
1658
|
+
result: testRunResultSchema,
|
|
1659
|
+
selection: optional(selectionSchema),
|
|
1660
|
+
/** Story ids that matched nothing. The rest ran, but they fail the call. */
|
|
1661
|
+
notFoundMessages: optional(array(string()))
|
|
1615
1662
|
}),
|
|
1616
1663
|
object({
|
|
1617
1664
|
status: literal("error"),
|
|
@@ -1628,12 +1675,25 @@ var errorLikeSchema = object({
|
|
|
1628
1675
|
pipe(
|
|
1629
1676
|
storyInputArraySchema,
|
|
1630
1677
|
description(
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1678
|
+
"Stories to test for focused feedback. Omit this field, `files` and `changed` to run tests for all available stories.\nPrefer running tests for specific stories while developing to get faster feedback.\nPrefer { storyId } when you don't already have story file context, since this avoids filesystem discovery.\nUse { storyId } when IDs were discovered from documentation tools.\nUse { absoluteStoryPath + exportName } only when you're currently working in a story file and already know those values."
|
|
1679
|
+
)
|
|
1680
|
+
)
|
|
1681
|
+
),
|
|
1682
|
+
files: optional(
|
|
1683
|
+
pipe(
|
|
1684
|
+
// An empty entry, as from an unset variable, would match every story file.
|
|
1685
|
+
array(pipe(string(), minLength(1))),
|
|
1686
|
+
description(
|
|
1687
|
+
"Story files to test: each entry selects the story files whose path contains it (case-insensitive), or that an absolute path or directory points to. Only story files match; to test the stories that depend on a changed component, use `changed`."
|
|
1688
|
+
)
|
|
1689
|
+
)
|
|
1690
|
+
),
|
|
1691
|
+
changed: optional(
|
|
1692
|
+
pipe(
|
|
1693
|
+
// An empty ref, as from an unset variable in CI, must not read as "not changed".
|
|
1694
|
+
union([boolean(), pipe(string(), minLength(1))]),
|
|
1695
|
+
description(
|
|
1696
|
+
"Test the changed stories, exactly as the stories changed tool lists them: new and modified stories, and the stories that depend on changed files. true for the uncommitted changes, or a git ref (a branch, tag or commit) for what this branch committed since it forked from that ref, plus the uncommitted changes. Combined with files or stories, only the stories that match both run."
|
|
1637
1697
|
)
|
|
1638
1698
|
)
|
|
1639
1699
|
),
|
|
@@ -1652,19 +1712,21 @@ function describeRun(a11yEnabled, ctx) {
|
|
|
1652
1712
|
return `Run story tests.${skill ? `
|
|
1653
1713
|
First run ${skill} once and follow it: it has the rules for running the tests and fixing what fails.` : ""}
|
|
1654
1714
|
Run them after editing anything that changes how the UI looks \u2014 components, stories, styles, CSS, themes, colors, or design tokens \u2014 shell-level substitutes like typecheck, lint, or package.json test scripts do not replace this.
|
|
1655
|
-
|
|
1656
|
-
|
|
1715
|
+
Use changed for focused runs on what you changed (faster while iterating), or files for specific story files,
|
|
1716
|
+
and leave all of them out to run every story.
|
|
1657
1717
|
Use this continuously to monitor test results as you work on your UI components and stories.
|
|
1658
1718
|
Results will include passing/failing status` + (a11yEnabled ? `, and accessibility violation reports.
|
|
1659
1719
|
For visual/design accessibility violations (for example color contrast), ask the user before changing styles.` : ".");
|
|
1660
1720
|
}
|
|
1661
1721
|
function runTelemetry(data, input) {
|
|
1662
|
-
let inputStoryCount = input.stories?.length ?? 0;
|
|
1722
|
+
let inputStoryCount = input.stories?.length ?? 0, inputFileCount = input.files?.length ?? 0, changed = input.changed ? { changed: !0 } : {};
|
|
1663
1723
|
if (data.status === "no-stories")
|
|
1664
1724
|
return {
|
|
1665
1725
|
payload: {
|
|
1666
1726
|
runA11y: data.a11y,
|
|
1667
1727
|
inputStoryCount,
|
|
1728
|
+
inputFileCount,
|
|
1729
|
+
...changed,
|
|
1668
1730
|
matchedStoryCount: 0,
|
|
1669
1731
|
passingStoryCount: 0,
|
|
1670
1732
|
failingStoryCount: 0,
|
|
@@ -1677,7 +1739,9 @@ function runTelemetry(data, input) {
|
|
|
1677
1739
|
payload: {
|
|
1678
1740
|
runA11y: data.a11y,
|
|
1679
1741
|
inputStoryCount,
|
|
1680
|
-
|
|
1742
|
+
inputFileCount,
|
|
1743
|
+
...changed,
|
|
1744
|
+
// The stories the run was asked for; a full run falls back to the input count.
|
|
1681
1745
|
matchedStoryCount: data.result.storyIds?.length ?? inputStoryCount,
|
|
1682
1746
|
...summarizeTestRun(data.result, data.a11y)
|
|
1683
1747
|
}
|
|
@@ -1689,13 +1753,24 @@ function isFailedRun(data) {
|
|
|
1689
1753
|
case "cancelled":
|
|
1690
1754
|
return !0;
|
|
1691
1755
|
case "completed":
|
|
1692
|
-
return Object.values(countTestRunFailures(data.result, data.a11y)).some((count) => count > 0);
|
|
1756
|
+
return Object.values(countTestRunFailures(data.result, data.a11y)).some((count) => count > 0) || (data.notFoundMessages?.length ?? 0) > 0;
|
|
1693
1757
|
case "no-stories":
|
|
1694
|
-
return
|
|
1758
|
+
return data.notFoundMessages.length > 0;
|
|
1695
1759
|
default:
|
|
1696
1760
|
return data;
|
|
1697
1761
|
}
|
|
1698
1762
|
}
|
|
1763
|
+
async function getChangedStories(ctx, since) {
|
|
1764
|
+
let { data } = await getToolset("stories").methods.changed.handler(
|
|
1765
|
+
since === void 0 ? {} : { since },
|
|
1766
|
+
ctx
|
|
1767
|
+
);
|
|
1768
|
+
return {
|
|
1769
|
+
storyIds: data.stories.map((story) => story.storyId),
|
|
1770
|
+
changedConfigFiles: data.changedConfigFiles,
|
|
1771
|
+
pendingFiles: [...data.unindexedStoryFiles, ...data.pendingFiles]
|
|
1772
|
+
};
|
|
1773
|
+
}
|
|
1699
1774
|
function createTestToolset({
|
|
1700
1775
|
channel,
|
|
1701
1776
|
storyIndex,
|
|
@@ -1708,6 +1783,7 @@ function createTestToolset({
|
|
|
1708
1783
|
methods: {
|
|
1709
1784
|
run: {
|
|
1710
1785
|
input: runInputSchema,
|
|
1786
|
+
positional: "files",
|
|
1711
1787
|
title: "Run Storybook tests",
|
|
1712
1788
|
description: (ctx) => describeRun(a11yEnabled, ctx),
|
|
1713
1789
|
handler: async (input, ctx) => {
|
|
@@ -1717,6 +1793,9 @@ function createTestToolset({
|
|
|
1717
1793
|
channel,
|
|
1718
1794
|
getIndex: storyIndex.getIndex,
|
|
1719
1795
|
stories: input.stories,
|
|
1796
|
+
files: input.files,
|
|
1797
|
+
changed: input.changed,
|
|
1798
|
+
getChangedStories: (since) => getChangedStories(ctx, since),
|
|
1720
1799
|
a11y: input.a11y
|
|
1721
1800
|
}), a11y: input.a11y }, markdown = formatTestRun(data, ctx, { a11yEnabled }), telemetry2 = runTelemetry(data, input);
|
|
1722
1801
|
return isFailedRun(data) ? { ok: !1, data, markdown, telemetry: telemetry2 } : { ok: !0, data, markdown, telemetry: telemetry2 };
|