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/ssr.cjs CHANGED
@@ -757,6 +757,23 @@ function ReportStepItem({
757
757
  children: step.errorMessage
758
758
  }
759
759
  ) : null,
760
+ step.expected !== void 0 || step.actual !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
761
+ "dl",
762
+ {
763
+ "data-slot": "step-comparison",
764
+ className: "mt-1.5 ml-6 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 font-mono text-xs",
765
+ children: [
766
+ step.expected !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
767
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("dt", { className: "text-muted-foreground", children: "Expected" }),
768
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("dd", { className: "overflow-x-auto whitespace-pre-wrap text-pass", children: step.expected })
769
+ ] }) : null,
770
+ step.actual !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
771
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("dt", { className: "text-muted-foreground", children: "Actual" }),
772
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("dd", { className: "overflow-x-auto whitespace-pre-wrap text-fail", children: step.actual })
773
+ ] }) : null
774
+ ]
775
+ }
776
+ ) : null,
760
777
  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
761
778
  ]
762
779
  }
@@ -881,42 +898,76 @@ function StateCardView({ card }) {
881
898
 
882
899
  // src/components/ReportAttachments.tsx
883
900
  var import_jsx_runtime21 = require("react/jsx-runtime");
901
+ function attachmentText(att) {
902
+ if (att.contentEncoding !== "BASE64") return att.body;
903
+ try {
904
+ return new TextDecoder().decode(Uint8Array.from(atob(att.body), (c) => c.charCodeAt(0)));
905
+ } catch {
906
+ return void 0;
907
+ }
908
+ }
909
+ function preview(att) {
910
+ const type = att.mediaType.split(";")[0].trim().toLowerCase();
911
+ const text = attachmentText(att);
912
+ if (text === void 0) return null;
913
+ if (type === "text/plain") {
914
+ 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 });
915
+ }
916
+ if (type === "text/markdown") {
917
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
918
+ "div",
919
+ {
920
+ className: "es-doc-prose prose prose-sm max-w-none rounded-md border border-border p-3",
921
+ dangerouslySetInnerHTML: { __html: safeMarkdownHtml(text) }
922
+ }
923
+ );
924
+ }
925
+ if (type === "text/html") {
926
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DocHtml, { entry: { kind: "html", content: text, title: att.name, phase: "runtime" } });
927
+ }
928
+ return null;
929
+ }
884
930
  function ReportAttachments({ attachments }) {
885
931
  if (attachments.length === 0) return null;
886
932
  return (
887
933
  // role="group" (not a labelled <section>) so multiple scenarios' attachment
888
934
  // blocks don't create duplicate "Attachments" region landmarks.
889
935
  /* @__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) => {
890
- const dataUri = att.contentEncoding === "BASE64" ? `data:${att.mediaType};base64,${att.body}` : `data:${att.mediaType},${encodeURIComponent(att.body)}`;
891
- const isImage = att.mediaType.startsWith("image/");
936
+ const dataUri = att.external ? void 0 : att.contentEncoding === "BASE64" ? `data:${att.mediaType};base64,${att.body}` : `data:${att.mediaType},${encodeURIComponent(att.body)}`;
937
+ const href = dataUri ?? (0, import_url.safeUrl)(att.body);
938
+ const imageSrc = dataUri ?? (0, import_url.safeImageUrl)(att.body);
939
+ const isImage = att.mediaType.startsWith("image/") && imageSrc !== void 0;
892
940
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("figure", { className: "m-0", children: isImage ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
893
941
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
894
942
  "img",
895
943
  {
896
- src: dataUri,
944
+ src: imageSrc,
897
945
  alt: att.name,
898
946
  loading: "lazy",
899
947
  className: "max-w-full rounded-md border border-border"
900
948
  }
901
949
  ),
902
950
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("figcaption", { className: "mt-1 text-xs text-muted-foreground", children: att.name })
903
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
904
- "a",
905
- {
906
- href: dataUri,
907
- download: att.name,
908
- className: "text-xs text-link underline underline-offset-2",
909
- children: [
910
- att.name,
911
- " ",
912
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "text-muted-foreground", children: [
913
- "(",
914
- att.mediaType,
915
- ")"
916
- ] })
917
- ]
918
- }
919
- ) }, `${att.name}-${i}`);
951
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
952
+ att.external ? null : preview(att),
953
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
954
+ "a",
955
+ {
956
+ href,
957
+ download: att.name,
958
+ className: "text-xs text-link underline underline-offset-2",
959
+ children: [
960
+ att.name,
961
+ " ",
962
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "text-muted-foreground", children: [
963
+ "(",
964
+ att.mediaType,
965
+ ")"
966
+ ] })
967
+ ]
968
+ }
969
+ )
970
+ ] }) }, `${att.name}-${i}`);
920
971
  }) })
921
972
  );
922
973
  }