executable-stories-react 0.1.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/README.md +238 -0
- package/dist/index.cjs +1021 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +202 -0
- package/dist/index.d.ts +202 -0
- package/dist/index.js +964 -0
- package/dist/index.js.map +1 -0
- package/dist/interactive.cjs +846 -0
- package/dist/interactive.cjs.map +1 -0
- package/dist/interactive.d.cts +116 -0
- package/dist/interactive.d.ts +116 -0
- package/dist/interactive.js +820 -0
- package/dist/interactive.js.map +1 -0
- package/dist/parse.cjs +495 -0
- package/dist/parse.cjs.map +1 -0
- package/dist/parse.d.cts +51 -0
- package/dist/parse.d.ts +51 -0
- package/dist/parse.js +464 -0
- package/dist/parse.js.map +1 -0
- package/dist/styles.css +244 -0
- package/package.json +84 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1021 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var src_exports = {};
|
|
23
|
+
__export(src_exports, {
|
|
24
|
+
DocCode: () => DocCode,
|
|
25
|
+
DocCustom: () => DocCustom,
|
|
26
|
+
DocEntry: () => DocEntry,
|
|
27
|
+
DocKv: () => DocKv,
|
|
28
|
+
DocLink: () => DocLink,
|
|
29
|
+
DocMermaid: () => DocMermaid,
|
|
30
|
+
DocNote: () => DocNote,
|
|
31
|
+
DocScreenshot: () => DocScreenshot,
|
|
32
|
+
DocSection: () => DocSection,
|
|
33
|
+
DocTable: () => DocTable,
|
|
34
|
+
DocTag: () => DocTag,
|
|
35
|
+
Report: () => Report,
|
|
36
|
+
ReportDocEntries: () => ReportDocEntries,
|
|
37
|
+
ReportEmpty: () => ReportEmpty,
|
|
38
|
+
ReportFeature: () => ReportFeature,
|
|
39
|
+
ReportFeatureList: () => ReportFeatureList,
|
|
40
|
+
ReportRoot: () => ReportRoot,
|
|
41
|
+
ReportScenario: () => ReportScenario,
|
|
42
|
+
ReportScenarioList: () => ReportScenarioList,
|
|
43
|
+
ReportSchemaError: () => ReportSchemaError,
|
|
44
|
+
ReportStepItem: () => ReportStepItem,
|
|
45
|
+
ReportSteps: () => ReportSteps,
|
|
46
|
+
ReportSummary: () => ReportSummary,
|
|
47
|
+
ReportSummaryView: () => ReportSummaryView,
|
|
48
|
+
STORY_REPORT_SCHEMA_MAJOR: () => STORY_REPORT_SCHEMA_MAJOR,
|
|
49
|
+
err: () => err,
|
|
50
|
+
ok: () => ok,
|
|
51
|
+
parseStoryReport: () => parseStoryReport,
|
|
52
|
+
storyReportSchema: () => storyReportSchema,
|
|
53
|
+
useBuiltinRenderers: () => useBuiltinRenderers,
|
|
54
|
+
useCustomRenderers: () => useCustomRenderers,
|
|
55
|
+
useReport: () => useReport
|
|
56
|
+
});
|
|
57
|
+
module.exports = __toCommonJS(src_exports);
|
|
58
|
+
|
|
59
|
+
// src/context/ReportRoot.tsx
|
|
60
|
+
var import_react2 = require("react");
|
|
61
|
+
|
|
62
|
+
// src/context/ReportContext.ts
|
|
63
|
+
var import_react = require("react");
|
|
64
|
+
var ReportContext = (0, import_react.createContext)(null);
|
|
65
|
+
|
|
66
|
+
// src/context/ReportRoot.tsx
|
|
67
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
68
|
+
var EMPTY_CUSTOM = {};
|
|
69
|
+
var EMPTY_RENDERERS = {};
|
|
70
|
+
function ReportRoot({
|
|
71
|
+
report,
|
|
72
|
+
customRenderers,
|
|
73
|
+
renderers,
|
|
74
|
+
children
|
|
75
|
+
}) {
|
|
76
|
+
const value = (0, import_react2.useMemo)(
|
|
77
|
+
() => ({
|
|
78
|
+
report,
|
|
79
|
+
customRenderers: customRenderers ?? EMPTY_CUSTOM,
|
|
80
|
+
renderers: renderers ?? EMPTY_RENDERERS
|
|
81
|
+
}),
|
|
82
|
+
[report, customRenderers, renderers]
|
|
83
|
+
);
|
|
84
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportContext.Provider, { value, children });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/hooks/useReport.ts
|
|
88
|
+
var import_react3 = require("react");
|
|
89
|
+
function useReport() {
|
|
90
|
+
const ctx = (0, import_react3.useContext)(ReportContext);
|
|
91
|
+
if (!ctx) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
"useReport must be used inside <ReportRoot> or <Report>. Wrap your tree with one of those."
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
return ctx.report;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/components/ReportSummary.tsx
|
|
100
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
101
|
+
function ReportSummary({ className }) {
|
|
102
|
+
const report = useReport();
|
|
103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
104
|
+
ReportSummaryView,
|
|
105
|
+
{
|
|
106
|
+
summary: report.summary,
|
|
107
|
+
...className !== void 0 && { className },
|
|
108
|
+
ariaLabel: "Run summary"
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
function ReportSummaryView({ summary, className, ariaLabel }) {
|
|
113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
114
|
+
"p",
|
|
115
|
+
{
|
|
116
|
+
className: ["es-report-summary", className].filter(Boolean).join(" "),
|
|
117
|
+
"aria-label": ariaLabel,
|
|
118
|
+
children: [
|
|
119
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
120
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: summary.total }),
|
|
121
|
+
" scenario",
|
|
122
|
+
summary.total === 1 ? "" : "s"
|
|
123
|
+
] }),
|
|
124
|
+
" \xB7 ",
|
|
125
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { "data-status": "passed", children: [
|
|
126
|
+
summary.passed,
|
|
127
|
+
" passed"
|
|
128
|
+
] }),
|
|
129
|
+
" \xB7 ",
|
|
130
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { "data-status": "failed", children: [
|
|
131
|
+
summary.failed,
|
|
132
|
+
" failed"
|
|
133
|
+
] }),
|
|
134
|
+
summary.skipped > 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
135
|
+
" \xB7 ",
|
|
136
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { "data-status": "skipped", children: [
|
|
137
|
+
summary.skipped,
|
|
138
|
+
" skipped"
|
|
139
|
+
] })
|
|
140
|
+
] }) : null,
|
|
141
|
+
summary.pending > 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
142
|
+
" \xB7 ",
|
|
143
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { "data-status": "pending", children: [
|
|
144
|
+
summary.pending,
|
|
145
|
+
" pending"
|
|
146
|
+
] })
|
|
147
|
+
] }) : null
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// src/components/doc/DocNote.tsx
|
|
154
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
155
|
+
function DocNote({ entry }) {
|
|
156
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "es-doc es-doc-note", children: entry.text });
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// src/components/doc/DocTag.tsx
|
|
160
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
161
|
+
function DocTag({ entry }) {
|
|
162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: "es-doc es-tags", "aria-label": "Tags", children: entry.names.map((n) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { children: n }, n)) });
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// src/components/doc/DocKv.tsx
|
|
166
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
167
|
+
function formatValue(value) {
|
|
168
|
+
if (value === null) return "null";
|
|
169
|
+
if (typeof value === "string") return value;
|
|
170
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
171
|
+
try {
|
|
172
|
+
return JSON.stringify(value);
|
|
173
|
+
} catch {
|
|
174
|
+
return String(value);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function DocKv({ entry }) {
|
|
178
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("dl", { className: "es-doc es-doc-kv", children: [
|
|
179
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dt", { children: entry.label }),
|
|
180
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dd", { children: formatValue(entry.value) })
|
|
181
|
+
] });
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// src/hooks/useRenderers.ts
|
|
185
|
+
var import_react4 = require("react");
|
|
186
|
+
var EMPTY_CUSTOM2 = {};
|
|
187
|
+
var EMPTY_RENDERERS2 = {};
|
|
188
|
+
function useCustomRenderers() {
|
|
189
|
+
const ctx = (0, import_react4.useContext)(ReportContext);
|
|
190
|
+
return ctx?.customRenderers ?? EMPTY_CUSTOM2;
|
|
191
|
+
}
|
|
192
|
+
function useBuiltinRenderers() {
|
|
193
|
+
const ctx = (0, import_react4.useContext)(ReportContext);
|
|
194
|
+
return ctx?.renderers ?? EMPTY_RENDERERS2;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// src/components/doc/DocCode.tsx
|
|
198
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
199
|
+
function DocCode({ entry }) {
|
|
200
|
+
const renderers = useBuiltinRenderers();
|
|
201
|
+
if (renderers.code) {
|
|
202
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: renderers.code(entry) });
|
|
203
|
+
}
|
|
204
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("figure", { className: "es-doc es-doc-code", children: [
|
|
205
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("figcaption", { children: entry.label }),
|
|
206
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("pre", { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("code", { className: entry.lang ? `language-${entry.lang}` : void 0, children: entry.content }) })
|
|
207
|
+
] });
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// src/components/doc/DocTable.tsx
|
|
211
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
212
|
+
function DocTable({ entry }) {
|
|
213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("figure", { className: "es-doc es-doc-table", children: [
|
|
214
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("figcaption", { children: entry.label }),
|
|
215
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("table", { children: [
|
|
216
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tr", { children: entry.columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("th", { scope: "col", children: c }, c)) }) }),
|
|
217
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tbody", { children: entry.rows.map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tr", { children: row.map((cell, j) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("td", { children: cell }, j)) }, i)) })
|
|
218
|
+
] })
|
|
219
|
+
] });
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// src/components/doc/DocLink.tsx
|
|
223
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
224
|
+
function DocLink({ entry }) {
|
|
225
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
226
|
+
"a",
|
|
227
|
+
{
|
|
228
|
+
className: "es-doc es-doc-link",
|
|
229
|
+
href: entry.url,
|
|
230
|
+
rel: "noreferrer noopener",
|
|
231
|
+
target: "_blank",
|
|
232
|
+
children: entry.label
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// src/components/doc/DocSection.tsx
|
|
238
|
+
var import_marked = require("marked");
|
|
239
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
240
|
+
function safeMarkdownHtml(markdown) {
|
|
241
|
+
const raw = import_marked.marked.parse(markdown, { async: false });
|
|
242
|
+
return raw.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, "").replace(/\son[a-z]+\s*=\s*"[^"]*"/gi, "").replace(/\son[a-z]+\s*=\s*'[^']*'/gi, "").replace(/\son[a-z]+\s*=\s*[^\s>]+/gi, "").replace(/(href|src)\s*=\s*"\s*javascript:[^"]*"/gi, '$1="#"').replace(/(href|src)\s*=\s*'\s*javascript:[^']*'/gi, "$1='#'");
|
|
243
|
+
}
|
|
244
|
+
function DocSection({ entry }) {
|
|
245
|
+
const renderers = useBuiltinRenderers();
|
|
246
|
+
if (renderers.section) {
|
|
247
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: renderers.section(entry) });
|
|
248
|
+
}
|
|
249
|
+
const html = safeMarkdownHtml(entry.markdown);
|
|
250
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("section", { className: "es-doc es-doc-section", "aria-label": entry.title, children: [
|
|
251
|
+
entry.title ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h4", { className: "es-doc-section-title", children: entry.title }) : null,
|
|
252
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
253
|
+
"div",
|
|
254
|
+
{
|
|
255
|
+
className: "es-doc-section-content",
|
|
256
|
+
dangerouslySetInnerHTML: { __html: html }
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
] });
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// src/components/doc/DocMermaid.tsx
|
|
263
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
264
|
+
function DocMermaid({ entry }) {
|
|
265
|
+
const renderers = useBuiltinRenderers();
|
|
266
|
+
if (renderers.mermaid) {
|
|
267
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: renderers.mermaid(entry) });
|
|
268
|
+
}
|
|
269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
270
|
+
"figure",
|
|
271
|
+
{
|
|
272
|
+
className: "es-doc es-doc-mermaid",
|
|
273
|
+
"aria-label": entry.title ?? "Diagram",
|
|
274
|
+
children: [
|
|
275
|
+
entry.title ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("figcaption", { children: entry.title }) : null,
|
|
276
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("pre", { "data-mermaid": true, children: entry.code })
|
|
277
|
+
]
|
|
278
|
+
}
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// src/components/doc/DocScreenshot.tsx
|
|
283
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
284
|
+
function DocScreenshot({ entry }) {
|
|
285
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("figure", { className: "es-doc es-doc-screenshot", children: [
|
|
286
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("img", { src: entry.path, alt: entry.alt ?? "", loading: "lazy" }),
|
|
287
|
+
entry.alt ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("figcaption", { children: entry.alt }) : null
|
|
288
|
+
] });
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// src/components/doc/DocCustom.tsx
|
|
292
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
293
|
+
function DocCustom({ entry }) {
|
|
294
|
+
const renderers = useCustomRenderers();
|
|
295
|
+
const renderer = renderers[entry.type];
|
|
296
|
+
if (renderer) {
|
|
297
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: renderer(entry) });
|
|
298
|
+
}
|
|
299
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "es-doc es-doc-custom", "data-type": entry.type, children: [
|
|
300
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "es-doc-custom-type", children: entry.type }),
|
|
301
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("pre", { children: safeStringify(entry.data) })
|
|
302
|
+
] });
|
|
303
|
+
}
|
|
304
|
+
function safeStringify(value) {
|
|
305
|
+
try {
|
|
306
|
+
return JSON.stringify(value, null, 2);
|
|
307
|
+
} catch {
|
|
308
|
+
return String(value);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// src/components/doc/DocEntry.tsx
|
|
313
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
314
|
+
function DocEntry({ entry }) {
|
|
315
|
+
switch (entry.kind) {
|
|
316
|
+
case "note":
|
|
317
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DocNote, { entry });
|
|
318
|
+
case "tag":
|
|
319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DocTag, { entry });
|
|
320
|
+
case "kv":
|
|
321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DocKv, { entry });
|
|
322
|
+
case "code":
|
|
323
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DocCode, { entry });
|
|
324
|
+
case "table":
|
|
325
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DocTable, { entry });
|
|
326
|
+
case "link":
|
|
327
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DocLink, { entry });
|
|
328
|
+
case "section":
|
|
329
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DocSection, { entry });
|
|
330
|
+
case "mermaid":
|
|
331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DocMermaid, { entry });
|
|
332
|
+
case "screenshot":
|
|
333
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DocScreenshot, { entry });
|
|
334
|
+
case "custom":
|
|
335
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DocCustom, { entry });
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// src/components/ReportDocEntries.tsx
|
|
340
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
341
|
+
function ReportDocEntries({ entries }) {
|
|
342
|
+
if (entries.length === 0) return null;
|
|
343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: entries.map((entry, i) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DocEntry, { entry }, i)) });
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// src/components/ReportSteps.tsx
|
|
347
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
348
|
+
function ReportSteps({ scenario }) {
|
|
349
|
+
if (scenario.steps.length === 0) return null;
|
|
350
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("ol", { className: "es-steps", children: scenario.steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ReportStepItem, { step }, step.id)) });
|
|
351
|
+
}
|
|
352
|
+
function ReportStepItem({ step }) {
|
|
353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
354
|
+
"li",
|
|
355
|
+
{
|
|
356
|
+
id: step.id,
|
|
357
|
+
className: `es-step es-step-${step.status}`,
|
|
358
|
+
"data-status": step.status,
|
|
359
|
+
children: [
|
|
360
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "es-step-keyword", children: step.keyword }),
|
|
361
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "es-step-text", children: step.text }),
|
|
362
|
+
step.errorMessage ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("pre", { className: "es-scenario-error", role: "alert", children: step.errorMessage }) : null,
|
|
363
|
+
step.docEntries.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "es-step-docs", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ReportDocEntries, { entries: step.docEntries }) }) : null
|
|
364
|
+
]
|
|
365
|
+
}
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// src/components/ReportScenario.tsx
|
|
370
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
371
|
+
var STATUS_LABEL = {
|
|
372
|
+
passed: "Passed",
|
|
373
|
+
failed: "Failed",
|
|
374
|
+
skipped: "Skipped",
|
|
375
|
+
pending: "Pending"
|
|
376
|
+
};
|
|
377
|
+
function ReportScenario({ scenario }) {
|
|
378
|
+
const titleId = `${scenario.id}-title`;
|
|
379
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
380
|
+
"article",
|
|
381
|
+
{
|
|
382
|
+
id: scenario.id,
|
|
383
|
+
className: `es-scenario es-status-${scenario.status}`,
|
|
384
|
+
"aria-labelledby": titleId,
|
|
385
|
+
"data-status": scenario.status,
|
|
386
|
+
children: [
|
|
387
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("h3", { id: titleId, className: "es-scenario-title", children: [
|
|
388
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: scenario.title }),
|
|
389
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "es-scenario-status", "aria-label": `Status: ${STATUS_LABEL[scenario.status]}`, children: STATUS_LABEL[scenario.status] })
|
|
390
|
+
] }),
|
|
391
|
+
scenario.tags.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("ul", { className: "es-tags", "aria-label": "Tags", children: scenario.tags.map((t) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("li", { children: t }, t)) }) : null,
|
|
392
|
+
scenario.errorMessage ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("pre", { className: "es-scenario-error", role: "alert", children: scenario.errorMessage }) : null,
|
|
393
|
+
scenario.docEntries.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "es-scenario-docs", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ReportDocEntries, { entries: scenario.docEntries }) }) : null,
|
|
394
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ReportSteps, { scenario })
|
|
395
|
+
]
|
|
396
|
+
}
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// src/components/ReportScenarioList.tsx
|
|
401
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
402
|
+
function ReportScenarioList({ feature }) {
|
|
403
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: feature.scenarios.map((scenario) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ReportScenario, { scenario }, scenario.id)) });
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// src/components/ReportFeature.tsx
|
|
407
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
408
|
+
function ReportFeature({ feature }) {
|
|
409
|
+
const titleId = `${feature.id}-title`;
|
|
410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
411
|
+
"section",
|
|
412
|
+
{
|
|
413
|
+
id: feature.id,
|
|
414
|
+
className: "es-feature",
|
|
415
|
+
"aria-labelledby": titleId,
|
|
416
|
+
children: [
|
|
417
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h2", { id: titleId, className: "es-feature-title", children: feature.title }),
|
|
418
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "es-feature-source", children: feature.sourceFile }),
|
|
419
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ReportSummaryView, { summary: feature.summary, className: "es-feature-summary" }),
|
|
420
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ReportScenarioList, { feature })
|
|
421
|
+
]
|
|
422
|
+
}
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// src/components/ReportFeatureList.tsx
|
|
427
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
428
|
+
function ReportFeatureList() {
|
|
429
|
+
const report = useReport();
|
|
430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: report.features.map((feature) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ReportFeature, { feature }, feature.id)) });
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// src/components/ReportEmpty.tsx
|
|
434
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
435
|
+
function ReportEmpty({ message }) {
|
|
436
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("section", { className: "es-empty", "aria-live": "polite", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { children: message ?? "No scenarios in this report." }) });
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// src/components/ReportSchemaError.tsx
|
|
440
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
441
|
+
function ReportSchemaError({ error }) {
|
|
442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("section", { className: "es-schema-error", role: "alert", "aria-live": "assertive", children: [
|
|
443
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("strong", { children: "Report could not be displayed." }) }),
|
|
444
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { children: error.message }),
|
|
445
|
+
error.code === "SCHEMA_VERSION_MISMATCH" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("p", { children: [
|
|
446
|
+
"The report bundle is newer than this version of ",
|
|
447
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("code", { children: "executable-stories-react" }),
|
|
448
|
+
". Upgrade the package, or regenerate the report with an older formatters CLI."
|
|
449
|
+
] }) : null,
|
|
450
|
+
error.issues && error.issues.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("details", { children: [
|
|
451
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("summary", { children: [
|
|
452
|
+
error.issues.length,
|
|
453
|
+
" validation issue",
|
|
454
|
+
error.issues.length === 1 ? "" : "s"
|
|
455
|
+
] }),
|
|
456
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("pre", { children: error.issues.slice(0, 20).map((i) => `${i.path}: ${i.message}`).join("\n") })
|
|
457
|
+
] }) : null
|
|
458
|
+
] });
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// src/components/Report.tsx
|
|
462
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
463
|
+
function isResult(value) {
|
|
464
|
+
return typeof value === "object" && value !== null && "ok" in value && typeof value.ok === "boolean";
|
|
465
|
+
}
|
|
466
|
+
function Report(props) {
|
|
467
|
+
const { report, customRenderers, renderers, className, title, dataTheme } = props;
|
|
468
|
+
if (isResult(report)) {
|
|
469
|
+
if (!report.ok) {
|
|
470
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
471
|
+
"main",
|
|
472
|
+
{
|
|
473
|
+
className: ["es-report", className].filter(Boolean).join(" "),
|
|
474
|
+
"aria-label": title ?? "Test report",
|
|
475
|
+
"data-theme": dataTheme,
|
|
476
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ReportSchemaError, { error: report.error })
|
|
477
|
+
}
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
481
|
+
ReportView,
|
|
482
|
+
{
|
|
483
|
+
report: report.data,
|
|
484
|
+
customRenderers,
|
|
485
|
+
renderers,
|
|
486
|
+
className,
|
|
487
|
+
title,
|
|
488
|
+
dataTheme
|
|
489
|
+
}
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
493
|
+
ReportView,
|
|
494
|
+
{
|
|
495
|
+
report,
|
|
496
|
+
customRenderers,
|
|
497
|
+
renderers,
|
|
498
|
+
className,
|
|
499
|
+
title,
|
|
500
|
+
dataTheme
|
|
501
|
+
}
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
function ReportView({
|
|
505
|
+
report,
|
|
506
|
+
customRenderers,
|
|
507
|
+
renderers,
|
|
508
|
+
className,
|
|
509
|
+
title,
|
|
510
|
+
dataTheme
|
|
511
|
+
}) {
|
|
512
|
+
const hasContent = report.features.length > 0;
|
|
513
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ReportRoot, { report, customRenderers, renderers, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
514
|
+
"main",
|
|
515
|
+
{
|
|
516
|
+
className: ["es-report", className].filter(Boolean).join(" "),
|
|
517
|
+
"aria-label": title ?? "Test report",
|
|
518
|
+
"data-theme": dataTheme,
|
|
519
|
+
children: [
|
|
520
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("header", { className: "es-report-header", children: [
|
|
521
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h1", { children: title ?? "Story Report" }),
|
|
522
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ReportSummary, {})
|
|
523
|
+
] }),
|
|
524
|
+
hasContent ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ReportFeatureList, {}) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ReportEmpty, {})
|
|
525
|
+
]
|
|
526
|
+
}
|
|
527
|
+
) });
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// src/result.ts
|
|
531
|
+
var ok = (data) => ({ ok: true, data });
|
|
532
|
+
var err = (error) => ({ ok: false, error });
|
|
533
|
+
|
|
534
|
+
// src/schema/story-report.schema.ts
|
|
535
|
+
var import_zod = require("zod");
|
|
536
|
+
|
|
537
|
+
// ../executable-stories-formatters/schemas/story-report-v1.json
|
|
538
|
+
var story_report_v1_default = {
|
|
539
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
540
|
+
$id: "https://executable-stories.dev/schemas/story-report-v1.schema.json",
|
|
541
|
+
title: "StoryReport",
|
|
542
|
+
description: "Pre-grouped, denormalized report shape consumed by UI renderers (React, Svelte, Vue, etc.). Stable public contract \u2014 additive-only within a major. Distinct from internal TestRunResult.",
|
|
543
|
+
type: "object",
|
|
544
|
+
$ref: "#/$defs/StoryReport",
|
|
545
|
+
$defs: {
|
|
546
|
+
StoryReport: {
|
|
547
|
+
type: "object",
|
|
548
|
+
description: "Top-level report containing all features, runtime metadata, and a pre-computed summary.",
|
|
549
|
+
properties: {
|
|
550
|
+
schemaVersion: {
|
|
551
|
+
type: "string",
|
|
552
|
+
pattern: "^1\\.[0-9]+$",
|
|
553
|
+
description: "Schema version as 'major.minor'. Major bumps are breaking; minors are additive-only. UI packages must accept any 1.x."
|
|
554
|
+
},
|
|
555
|
+
runId: {
|
|
556
|
+
type: "string",
|
|
557
|
+
minLength: 1,
|
|
558
|
+
description: "Unique deterministic identifier for this run."
|
|
559
|
+
},
|
|
560
|
+
startedAtMs: {
|
|
561
|
+
type: "number",
|
|
562
|
+
minimum: 0,
|
|
563
|
+
description: "Run start time as Unix epoch milliseconds."
|
|
564
|
+
},
|
|
565
|
+
finishedAtMs: {
|
|
566
|
+
type: "number",
|
|
567
|
+
minimum: 0,
|
|
568
|
+
description: "Run finish time as Unix epoch milliseconds."
|
|
569
|
+
},
|
|
570
|
+
durationMs: {
|
|
571
|
+
type: "number",
|
|
572
|
+
minimum: 0,
|
|
573
|
+
description: "Total run duration in milliseconds."
|
|
574
|
+
},
|
|
575
|
+
projectRoot: {
|
|
576
|
+
type: "string",
|
|
577
|
+
minLength: 1,
|
|
578
|
+
description: "Absolute path to the project root (for context only; relative paths in features.sourceFile are preferred)."
|
|
579
|
+
},
|
|
580
|
+
packageVersion: {
|
|
581
|
+
type: "string",
|
|
582
|
+
description: "Version of the package under test, if known."
|
|
583
|
+
},
|
|
584
|
+
gitSha: {
|
|
585
|
+
type: "string",
|
|
586
|
+
description: "Git commit SHA at the time of the run."
|
|
587
|
+
},
|
|
588
|
+
ci: {
|
|
589
|
+
$ref: "#/$defs/CIInfo"
|
|
590
|
+
},
|
|
591
|
+
coverage: {
|
|
592
|
+
$ref: "#/$defs/CoverageSummary"
|
|
593
|
+
},
|
|
594
|
+
summary: {
|
|
595
|
+
$ref: "#/$defs/Summary",
|
|
596
|
+
description: "Pre-computed counts across all features and scenarios."
|
|
597
|
+
},
|
|
598
|
+
features: {
|
|
599
|
+
type: "array",
|
|
600
|
+
items: { $ref: "#/$defs/Feature" },
|
|
601
|
+
description: "Features grouped by sourceFile, sorted by title."
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
required: ["schemaVersion", "runId", "startedAtMs", "finishedAtMs", "durationMs", "projectRoot", "summary", "features"],
|
|
605
|
+
additionalProperties: false
|
|
606
|
+
},
|
|
607
|
+
Summary: {
|
|
608
|
+
type: "object",
|
|
609
|
+
description: "Counts by status. Sums equal 'total'.",
|
|
610
|
+
properties: {
|
|
611
|
+
total: { type: "integer", minimum: 0 },
|
|
612
|
+
passed: { type: "integer", minimum: 0 },
|
|
613
|
+
failed: { type: "integer", minimum: 0 },
|
|
614
|
+
skipped: { type: "integer", minimum: 0 },
|
|
615
|
+
pending: { type: "integer", minimum: 0 },
|
|
616
|
+
durationMs: { type: "number", minimum: 0 }
|
|
617
|
+
},
|
|
618
|
+
required: ["total", "passed", "failed", "skipped", "pending", "durationMs"],
|
|
619
|
+
additionalProperties: false
|
|
620
|
+
},
|
|
621
|
+
Feature: {
|
|
622
|
+
type: "object",
|
|
623
|
+
description: "A group of scenarios from the same source file.",
|
|
624
|
+
properties: {
|
|
625
|
+
id: {
|
|
626
|
+
type: "string",
|
|
627
|
+
minLength: 1,
|
|
628
|
+
description: "Stable slug derived from the relative source path. Suitable for use as a deep-link anchor."
|
|
629
|
+
},
|
|
630
|
+
title: {
|
|
631
|
+
type: "string",
|
|
632
|
+
minLength: 1,
|
|
633
|
+
description: "Display title. Derived from describe block when present, otherwise the file basename."
|
|
634
|
+
},
|
|
635
|
+
sourceFile: {
|
|
636
|
+
type: "string",
|
|
637
|
+
minLength: 1,
|
|
638
|
+
description: "Source path, relative to projectRoot when possible."
|
|
639
|
+
},
|
|
640
|
+
summary: { $ref: "#/$defs/Summary" },
|
|
641
|
+
scenarios: {
|
|
642
|
+
type: "array",
|
|
643
|
+
items: { $ref: "#/$defs/Scenario" },
|
|
644
|
+
description: "Scenarios in this feature, in declaration order."
|
|
645
|
+
}
|
|
646
|
+
},
|
|
647
|
+
required: ["id", "title", "sourceFile", "summary", "scenarios"],
|
|
648
|
+
additionalProperties: false
|
|
649
|
+
},
|
|
650
|
+
Scenario: {
|
|
651
|
+
type: "object",
|
|
652
|
+
description: "A single scenario with its steps, story-level doc entries, and attachments.",
|
|
653
|
+
properties: {
|
|
654
|
+
id: {
|
|
655
|
+
type: "string",
|
|
656
|
+
minLength: 1,
|
|
657
|
+
description: "Stable identifier: '<feature.id>--<slug-of-title>'. Suitable for use as a deep-link anchor."
|
|
658
|
+
},
|
|
659
|
+
title: { type: "string", minLength: 1 },
|
|
660
|
+
status: { $ref: "#/$defs/TestStatus" },
|
|
661
|
+
durationMs: { type: "number", minimum: 0 },
|
|
662
|
+
tags: {
|
|
663
|
+
type: "array",
|
|
664
|
+
items: { type: "string" },
|
|
665
|
+
description: "Normalized tags, deduplicated, lowercased."
|
|
666
|
+
},
|
|
667
|
+
tickets: {
|
|
668
|
+
type: "array",
|
|
669
|
+
items: { $ref: "#/$defs/Ticket" }
|
|
670
|
+
},
|
|
671
|
+
sourceLine: { type: "integer", minimum: 1 },
|
|
672
|
+
errorMessage: { type: "string" },
|
|
673
|
+
errorStack: { type: "string" },
|
|
674
|
+
retry: { type: "integer", minimum: 0 },
|
|
675
|
+
retries: { type: "integer", minimum: 0 },
|
|
676
|
+
docEntries: {
|
|
677
|
+
type: "array",
|
|
678
|
+
items: { $ref: "#/$defs/DocEntry" },
|
|
679
|
+
description: "Story-level doc entries (rendered before steps)."
|
|
680
|
+
},
|
|
681
|
+
steps: {
|
|
682
|
+
type: "array",
|
|
683
|
+
items: { $ref: "#/$defs/Step" }
|
|
684
|
+
},
|
|
685
|
+
attachments: {
|
|
686
|
+
type: "array",
|
|
687
|
+
items: { $ref: "#/$defs/Attachment" }
|
|
688
|
+
}
|
|
689
|
+
},
|
|
690
|
+
required: ["id", "title", "status", "durationMs", "tags", "retry", "retries", "docEntries", "steps", "attachments"],
|
|
691
|
+
additionalProperties: false
|
|
692
|
+
},
|
|
693
|
+
Step: {
|
|
694
|
+
type: "object",
|
|
695
|
+
description: "A single BDD step.",
|
|
696
|
+
properties: {
|
|
697
|
+
id: { type: "string", minLength: 1 },
|
|
698
|
+
index: { type: "integer", minimum: 0 },
|
|
699
|
+
keyword: { $ref: "#/$defs/StepKeyword" },
|
|
700
|
+
text: { type: "string" },
|
|
701
|
+
status: { $ref: "#/$defs/TestStatus" },
|
|
702
|
+
durationMs: { type: "number", minimum: 0 },
|
|
703
|
+
errorMessage: { type: "string" },
|
|
704
|
+
mode: { $ref: "#/$defs/StepMode" },
|
|
705
|
+
docEntries: {
|
|
706
|
+
type: "array",
|
|
707
|
+
items: { $ref: "#/$defs/DocEntry" },
|
|
708
|
+
description: "Doc entries attached to this step."
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
required: ["id", "index", "keyword", "text", "status", "durationMs", "docEntries"],
|
|
712
|
+
additionalProperties: false
|
|
713
|
+
},
|
|
714
|
+
StepKeyword: {
|
|
715
|
+
type: "string",
|
|
716
|
+
enum: ["Given", "When", "Then", "And", "But"]
|
|
717
|
+
},
|
|
718
|
+
StepMode: {
|
|
719
|
+
type: "string",
|
|
720
|
+
enum: ["normal", "skip", "only", "todo", "fails", "concurrent"]
|
|
721
|
+
},
|
|
722
|
+
TestStatus: {
|
|
723
|
+
type: "string",
|
|
724
|
+
enum: ["passed", "failed", "skipped", "pending"]
|
|
725
|
+
},
|
|
726
|
+
Ticket: {
|
|
727
|
+
type: "object",
|
|
728
|
+
properties: {
|
|
729
|
+
id: { type: "string", minLength: 1 },
|
|
730
|
+
url: { type: "string" }
|
|
731
|
+
},
|
|
732
|
+
required: ["id"],
|
|
733
|
+
additionalProperties: false
|
|
734
|
+
},
|
|
735
|
+
Attachment: {
|
|
736
|
+
type: "object",
|
|
737
|
+
properties: {
|
|
738
|
+
name: { type: "string" },
|
|
739
|
+
mediaType: { type: "string", minLength: 1 },
|
|
740
|
+
body: { type: "string" },
|
|
741
|
+
contentEncoding: {
|
|
742
|
+
type: "string",
|
|
743
|
+
enum: ["BASE64", "IDENTITY"]
|
|
744
|
+
}
|
|
745
|
+
},
|
|
746
|
+
required: ["name", "mediaType", "body", "contentEncoding"],
|
|
747
|
+
additionalProperties: false
|
|
748
|
+
},
|
|
749
|
+
CIInfo: {
|
|
750
|
+
type: "object",
|
|
751
|
+
properties: {
|
|
752
|
+
name: { type: "string" },
|
|
753
|
+
url: { type: "string" },
|
|
754
|
+
buildNumber: { type: "string" },
|
|
755
|
+
branch: { type: "string" },
|
|
756
|
+
commitSha: { type: "string" },
|
|
757
|
+
prNumber: { type: "string" }
|
|
758
|
+
},
|
|
759
|
+
required: ["name"],
|
|
760
|
+
additionalProperties: false
|
|
761
|
+
},
|
|
762
|
+
CoverageSummary: {
|
|
763
|
+
type: "object",
|
|
764
|
+
properties: {
|
|
765
|
+
linesPct: { type: "number", minimum: 0, maximum: 100 },
|
|
766
|
+
branchesPct: { type: "number", minimum: 0, maximum: 100 },
|
|
767
|
+
functionsPct: { type: "number", minimum: 0, maximum: 100 },
|
|
768
|
+
statementsPct: { type: "number", minimum: 0, maximum: 100 }
|
|
769
|
+
},
|
|
770
|
+
additionalProperties: false
|
|
771
|
+
},
|
|
772
|
+
DocPhase: {
|
|
773
|
+
type: "string",
|
|
774
|
+
enum: ["static", "runtime"]
|
|
775
|
+
},
|
|
776
|
+
DocEntry: {
|
|
777
|
+
oneOf: [
|
|
778
|
+
{ $ref: "#/$defs/DocNote" },
|
|
779
|
+
{ $ref: "#/$defs/DocTag" },
|
|
780
|
+
{ $ref: "#/$defs/DocKv" },
|
|
781
|
+
{ $ref: "#/$defs/DocCode" },
|
|
782
|
+
{ $ref: "#/$defs/DocTable" },
|
|
783
|
+
{ $ref: "#/$defs/DocLink" },
|
|
784
|
+
{ $ref: "#/$defs/DocSection" },
|
|
785
|
+
{ $ref: "#/$defs/DocMermaid" },
|
|
786
|
+
{ $ref: "#/$defs/DocScreenshot" },
|
|
787
|
+
{ $ref: "#/$defs/DocCustom" }
|
|
788
|
+
]
|
|
789
|
+
},
|
|
790
|
+
DocNote: {
|
|
791
|
+
type: "object",
|
|
792
|
+
properties: {
|
|
793
|
+
kind: { const: "note" },
|
|
794
|
+
text: { type: "string" },
|
|
795
|
+
phase: { $ref: "#/$defs/DocPhase" },
|
|
796
|
+
children: {
|
|
797
|
+
type: "array",
|
|
798
|
+
items: { $ref: "#/$defs/DocEntry" }
|
|
799
|
+
}
|
|
800
|
+
},
|
|
801
|
+
required: ["kind", "text", "phase"],
|
|
802
|
+
additionalProperties: false
|
|
803
|
+
},
|
|
804
|
+
DocTag: {
|
|
805
|
+
type: "object",
|
|
806
|
+
properties: {
|
|
807
|
+
kind: { const: "tag" },
|
|
808
|
+
names: { type: "array", items: { type: "string" } },
|
|
809
|
+
phase: { $ref: "#/$defs/DocPhase" },
|
|
810
|
+
children: {
|
|
811
|
+
type: "array",
|
|
812
|
+
items: { $ref: "#/$defs/DocEntry" }
|
|
813
|
+
}
|
|
814
|
+
},
|
|
815
|
+
required: ["kind", "names", "phase"],
|
|
816
|
+
additionalProperties: false
|
|
817
|
+
},
|
|
818
|
+
DocKv: {
|
|
819
|
+
type: "object",
|
|
820
|
+
properties: {
|
|
821
|
+
kind: { const: "kv" },
|
|
822
|
+
label: { type: "string" },
|
|
823
|
+
value: {},
|
|
824
|
+
phase: { $ref: "#/$defs/DocPhase" },
|
|
825
|
+
children: {
|
|
826
|
+
type: "array",
|
|
827
|
+
items: { $ref: "#/$defs/DocEntry" }
|
|
828
|
+
}
|
|
829
|
+
},
|
|
830
|
+
required: ["kind", "label", "value", "phase"],
|
|
831
|
+
additionalProperties: false
|
|
832
|
+
},
|
|
833
|
+
DocCode: {
|
|
834
|
+
type: "object",
|
|
835
|
+
properties: {
|
|
836
|
+
kind: { const: "code" },
|
|
837
|
+
label: { type: "string" },
|
|
838
|
+
content: { type: "string" },
|
|
839
|
+
lang: { type: "string" },
|
|
840
|
+
phase: { $ref: "#/$defs/DocPhase" },
|
|
841
|
+
children: {
|
|
842
|
+
type: "array",
|
|
843
|
+
items: { $ref: "#/$defs/DocEntry" }
|
|
844
|
+
}
|
|
845
|
+
},
|
|
846
|
+
required: ["kind", "label", "content", "phase"],
|
|
847
|
+
additionalProperties: false
|
|
848
|
+
},
|
|
849
|
+
DocTable: {
|
|
850
|
+
type: "object",
|
|
851
|
+
properties: {
|
|
852
|
+
kind: { const: "table" },
|
|
853
|
+
label: { type: "string" },
|
|
854
|
+
columns: { type: "array", items: { type: "string" } },
|
|
855
|
+
rows: {
|
|
856
|
+
type: "array",
|
|
857
|
+
items: {
|
|
858
|
+
type: "array",
|
|
859
|
+
items: { type: "string" }
|
|
860
|
+
}
|
|
861
|
+
},
|
|
862
|
+
phase: { $ref: "#/$defs/DocPhase" },
|
|
863
|
+
children: {
|
|
864
|
+
type: "array",
|
|
865
|
+
items: { $ref: "#/$defs/DocEntry" }
|
|
866
|
+
}
|
|
867
|
+
},
|
|
868
|
+
required: ["kind", "label", "columns", "rows", "phase"],
|
|
869
|
+
additionalProperties: false
|
|
870
|
+
},
|
|
871
|
+
DocLink: {
|
|
872
|
+
type: "object",
|
|
873
|
+
properties: {
|
|
874
|
+
kind: { const: "link" },
|
|
875
|
+
label: { type: "string" },
|
|
876
|
+
url: { type: "string" },
|
|
877
|
+
phase: { $ref: "#/$defs/DocPhase" },
|
|
878
|
+
children: {
|
|
879
|
+
type: "array",
|
|
880
|
+
items: { $ref: "#/$defs/DocEntry" }
|
|
881
|
+
}
|
|
882
|
+
},
|
|
883
|
+
required: ["kind", "label", "url", "phase"],
|
|
884
|
+
additionalProperties: false
|
|
885
|
+
},
|
|
886
|
+
DocSection: {
|
|
887
|
+
type: "object",
|
|
888
|
+
properties: {
|
|
889
|
+
kind: { const: "section" },
|
|
890
|
+
title: { type: "string" },
|
|
891
|
+
markdown: { type: "string" },
|
|
892
|
+
phase: { $ref: "#/$defs/DocPhase" },
|
|
893
|
+
children: {
|
|
894
|
+
type: "array",
|
|
895
|
+
items: { $ref: "#/$defs/DocEntry" }
|
|
896
|
+
}
|
|
897
|
+
},
|
|
898
|
+
required: ["kind", "title", "markdown", "phase"],
|
|
899
|
+
additionalProperties: false
|
|
900
|
+
},
|
|
901
|
+
DocMermaid: {
|
|
902
|
+
type: "object",
|
|
903
|
+
properties: {
|
|
904
|
+
kind: { const: "mermaid" },
|
|
905
|
+
code: { type: "string" },
|
|
906
|
+
title: { type: "string" },
|
|
907
|
+
phase: { $ref: "#/$defs/DocPhase" },
|
|
908
|
+
children: {
|
|
909
|
+
type: "array",
|
|
910
|
+
items: { $ref: "#/$defs/DocEntry" }
|
|
911
|
+
}
|
|
912
|
+
},
|
|
913
|
+
required: ["kind", "code", "phase"],
|
|
914
|
+
additionalProperties: false
|
|
915
|
+
},
|
|
916
|
+
DocScreenshot: {
|
|
917
|
+
type: "object",
|
|
918
|
+
properties: {
|
|
919
|
+
kind: { const: "screenshot" },
|
|
920
|
+
path: { type: "string" },
|
|
921
|
+
alt: { type: "string" },
|
|
922
|
+
phase: { $ref: "#/$defs/DocPhase" },
|
|
923
|
+
children: {
|
|
924
|
+
type: "array",
|
|
925
|
+
items: { $ref: "#/$defs/DocEntry" }
|
|
926
|
+
}
|
|
927
|
+
},
|
|
928
|
+
required: ["kind", "path", "phase"],
|
|
929
|
+
additionalProperties: false
|
|
930
|
+
},
|
|
931
|
+
DocCustom: {
|
|
932
|
+
type: "object",
|
|
933
|
+
properties: {
|
|
934
|
+
kind: { const: "custom" },
|
|
935
|
+
type: { type: "string", minLength: 1 },
|
|
936
|
+
data: {},
|
|
937
|
+
phase: { $ref: "#/$defs/DocPhase" },
|
|
938
|
+
children: {
|
|
939
|
+
type: "array",
|
|
940
|
+
items: { $ref: "#/$defs/DocEntry" }
|
|
941
|
+
}
|
|
942
|
+
},
|
|
943
|
+
required: ["kind", "type", "data", "phase"],
|
|
944
|
+
additionalProperties: false
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
// src/schema/story-report.schema.ts
|
|
950
|
+
var compiled = import_zod.z.fromJSONSchema(story_report_v1_default);
|
|
951
|
+
var storyReportSchema = compiled;
|
|
952
|
+
var STORY_REPORT_SCHEMA_MAJOR = 1;
|
|
953
|
+
|
|
954
|
+
// src/schema/parse.ts
|
|
955
|
+
function parseStoryReport(input) {
|
|
956
|
+
if (input === null || typeof input !== "object") {
|
|
957
|
+
return err({
|
|
958
|
+
message: "Expected a StoryReport object.",
|
|
959
|
+
code: "INVALID_INPUT"
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
const versionRaw = input.schemaVersion;
|
|
963
|
+
if (typeof versionRaw === "string") {
|
|
964
|
+
const major = versionRaw.split(".")[0];
|
|
965
|
+
if (major !== String(STORY_REPORT_SCHEMA_MAJOR)) {
|
|
966
|
+
return err({
|
|
967
|
+
message: `Schema major ${major} is not supported by this version of executable-stories-react (expected ${STORY_REPORT_SCHEMA_MAJOR}.x). Upgrade the package.`,
|
|
968
|
+
code: "SCHEMA_VERSION_MISMATCH"
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
const parsed = storyReportSchema.safeParse(input);
|
|
973
|
+
if (parsed.success) {
|
|
974
|
+
return ok(parsed.data);
|
|
975
|
+
}
|
|
976
|
+
const issues = parsed.error.issues.map((i) => ({
|
|
977
|
+
path: i.path.join(".") || "/",
|
|
978
|
+
message: i.message
|
|
979
|
+
}));
|
|
980
|
+
return err({
|
|
981
|
+
message: `StoryReport failed validation (${issues.length} issue${issues.length === 1 ? "" : "s"}).`,
|
|
982
|
+
code: "VALIDATION_FAILED",
|
|
983
|
+
issues
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
987
|
+
0 && (module.exports = {
|
|
988
|
+
DocCode,
|
|
989
|
+
DocCustom,
|
|
990
|
+
DocEntry,
|
|
991
|
+
DocKv,
|
|
992
|
+
DocLink,
|
|
993
|
+
DocMermaid,
|
|
994
|
+
DocNote,
|
|
995
|
+
DocScreenshot,
|
|
996
|
+
DocSection,
|
|
997
|
+
DocTable,
|
|
998
|
+
DocTag,
|
|
999
|
+
Report,
|
|
1000
|
+
ReportDocEntries,
|
|
1001
|
+
ReportEmpty,
|
|
1002
|
+
ReportFeature,
|
|
1003
|
+
ReportFeatureList,
|
|
1004
|
+
ReportRoot,
|
|
1005
|
+
ReportScenario,
|
|
1006
|
+
ReportScenarioList,
|
|
1007
|
+
ReportSchemaError,
|
|
1008
|
+
ReportStepItem,
|
|
1009
|
+
ReportSteps,
|
|
1010
|
+
ReportSummary,
|
|
1011
|
+
ReportSummaryView,
|
|
1012
|
+
STORY_REPORT_SCHEMA_MAJOR,
|
|
1013
|
+
err,
|
|
1014
|
+
ok,
|
|
1015
|
+
parseStoryReport,
|
|
1016
|
+
storyReportSchema,
|
|
1017
|
+
useBuiltinRenderers,
|
|
1018
|
+
useCustomRenderers,
|
|
1019
|
+
useReport
|
|
1020
|
+
});
|
|
1021
|
+
//# sourceMappingURL=index.cjs.map
|