executable-stories-react 0.18.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -824,6 +824,23 @@ function ReportStepItem({
824
824
  children: step.errorMessage
825
825
  }
826
826
  ) : null,
827
+ step.expected !== void 0 || step.actual !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
828
+ "dl",
829
+ {
830
+ "data-slot": "step-comparison",
831
+ className: "mt-1.5 ml-6 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 font-mono text-xs",
832
+ children: [
833
+ step.expected !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
834
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("dt", { className: "text-muted-foreground", children: "Expected" }),
835
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("dd", { className: "overflow-x-auto whitespace-pre-wrap text-pass", children: step.expected })
836
+ ] }) : null,
837
+ step.actual !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
838
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("dt", { className: "text-muted-foreground", children: "Actual" }),
839
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("dd", { className: "overflow-x-auto whitespace-pre-wrap text-fail", children: step.actual })
840
+ ] }) : null
841
+ ]
842
+ }
843
+ ) : null,
827
844
  step.docEntries.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { "data-es-docs": true, className: "mt-2 ml-6", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ReportDocEntries, { entries: step.docEntries }) }) : null
828
845
  ]
829
846
  }
@@ -948,42 +965,76 @@ function StateCardView({ card }) {
948
965
 
949
966
  // src/components/ReportAttachments.tsx
950
967
  var import_jsx_runtime21 = require("react/jsx-runtime");
968
+ function attachmentText(att) {
969
+ if (att.contentEncoding !== "BASE64") return att.body;
970
+ try {
971
+ return new TextDecoder().decode(Uint8Array.from(atob(att.body), (c) => c.charCodeAt(0)));
972
+ } catch {
973
+ return void 0;
974
+ }
975
+ }
976
+ function preview(att) {
977
+ const type = att.mediaType.split(";")[0].trim().toLowerCase();
978
+ const text = attachmentText(att);
979
+ if (text === void 0) return null;
980
+ if (type === "text/plain") {
981
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("pre", { className: "max-h-96 overflow-auto rounded-md border border-border bg-muted/40 p-3 text-xs whitespace-pre-wrap", children: text });
982
+ }
983
+ if (type === "text/markdown") {
984
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
985
+ "div",
986
+ {
987
+ className: "es-doc-prose prose prose-sm max-w-none rounded-md border border-border p-3",
988
+ dangerouslySetInnerHTML: { __html: safeMarkdownHtml(text) }
989
+ }
990
+ );
991
+ }
992
+ if (type === "text/html") {
993
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DocHtml, { entry: { kind: "html", content: text, title: att.name, phase: "runtime" } });
994
+ }
995
+ return null;
996
+ }
951
997
  function ReportAttachments({ attachments }) {
952
998
  if (attachments.length === 0) return null;
953
999
  return (
954
1000
  // role="group" (not a labelled <section>) so multiple scenarios' attachment
955
1001
  // blocks don't create duplicate "Attachments" region landmarks.
956
1002
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { role: "group", "aria-label": "Attachments", className: "mt-3 flex flex-col gap-2", children: attachments.map((att, i) => {
957
- const dataUri = att.contentEncoding === "BASE64" ? `data:${att.mediaType};base64,${att.body}` : `data:${att.mediaType},${encodeURIComponent(att.body)}`;
958
- const isImage = att.mediaType.startsWith("image/");
1003
+ const dataUri = att.external ? void 0 : att.contentEncoding === "BASE64" ? `data:${att.mediaType};base64,${att.body}` : `data:${att.mediaType},${encodeURIComponent(att.body)}`;
1004
+ const href = dataUri ?? (0, import_url.safeUrl)(att.body);
1005
+ const imageSrc = dataUri ?? (0, import_url.safeImageUrl)(att.body);
1006
+ const isImage = att.mediaType.startsWith("image/") && imageSrc !== void 0;
959
1007
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("figure", { className: "m-0", children: isImage ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
960
1008
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
961
1009
  "img",
962
1010
  {
963
- src: dataUri,
1011
+ src: imageSrc,
964
1012
  alt: att.name,
965
1013
  loading: "lazy",
966
1014
  className: "max-w-full rounded-md border border-border"
967
1015
  }
968
1016
  ),
969
1017
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("figcaption", { className: "mt-1 text-xs text-muted-foreground", children: att.name })
970
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
971
- "a",
972
- {
973
- href: dataUri,
974
- download: att.name,
975
- className: "text-xs text-link underline underline-offset-2",
976
- children: [
977
- att.name,
978
- " ",
979
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "text-muted-foreground", children: [
980
- "(",
981
- att.mediaType,
982
- ")"
983
- ] })
984
- ]
985
- }
986
- ) }, `${att.name}-${i}`);
1018
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
1019
+ att.external ? null : preview(att),
1020
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
1021
+ "a",
1022
+ {
1023
+ href,
1024
+ download: att.name,
1025
+ className: "text-xs text-link underline underline-offset-2",
1026
+ children: [
1027
+ att.name,
1028
+ " ",
1029
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "text-muted-foreground", children: [
1030
+ "(",
1031
+ att.mediaType,
1032
+ ")"
1033
+ ] })
1034
+ ]
1035
+ }
1036
+ )
1037
+ ] }) }, `${att.name}-${i}`);
987
1038
  }) })
988
1039
  );
989
1040
  }
@@ -2553,6 +2604,14 @@ var story_report_v1_default = {
2553
2604
  errorMessage: {
2554
2605
  type: "string"
2555
2606
  },
2607
+ expected: {
2608
+ type: "string",
2609
+ description: "Serialized expected value of the failed assertion. Present only when the host framework reports one."
2610
+ },
2611
+ actual: {
2612
+ type: "string",
2613
+ description: "Serialized actual (observed) value of the failed assertion. Present only when the host framework reports one."
2614
+ },
2556
2615
  mode: {
2557
2616
  $ref: "#/$defs/StepMode"
2558
2617
  },
@@ -2617,6 +2676,10 @@ var story_report_v1_default = {
2617
2676
  contentEncoding: {
2618
2677
  type: "string",
2619
2678
  enum: ["BASE64", "IDENTITY"]
2679
+ },
2680
+ external: {
2681
+ const: true,
2682
+ description: "body holds the file's path or URL (file missing or too large to embed)."
2620
2683
  }
2621
2684
  },
2622
2685
  required: ["name", "mediaType", "body", "contentEncoding"],