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.
@@ -633,6 +633,23 @@ function ReportStepItem({
633
633
  children: step.errorMessage
634
634
  }
635
635
  ) : null,
636
+ step.expected !== void 0 || step.actual !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
637
+ "dl",
638
+ {
639
+ "data-slot": "step-comparison",
640
+ className: "mt-1.5 ml-6 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 font-mono text-xs",
641
+ children: [
642
+ step.expected !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
643
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("dt", { className: "text-muted-foreground", children: "Expected" }),
644
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("dd", { className: "overflow-x-auto whitespace-pre-wrap text-pass", children: step.expected })
645
+ ] }) : null,
646
+ step.actual !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
647
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("dt", { className: "text-muted-foreground", children: "Actual" }),
648
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("dd", { className: "overflow-x-auto whitespace-pre-wrap text-fail", children: step.actual })
649
+ ] }) : null
650
+ ]
651
+ }
652
+ ) : null,
636
653
  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
637
654
  ]
638
655
  }
@@ -757,42 +774,76 @@ function StateCardView({ card }) {
757
774
 
758
775
  // src/components/ReportAttachments.tsx
759
776
  var import_jsx_runtime21 = require("react/jsx-runtime");
777
+ function attachmentText(att) {
778
+ if (att.contentEncoding !== "BASE64") return att.body;
779
+ try {
780
+ return new TextDecoder().decode(Uint8Array.from(atob(att.body), (c) => c.charCodeAt(0)));
781
+ } catch {
782
+ return void 0;
783
+ }
784
+ }
785
+ function preview(att) {
786
+ const type = att.mediaType.split(";")[0].trim().toLowerCase();
787
+ const text = attachmentText(att);
788
+ if (text === void 0) return null;
789
+ if (type === "text/plain") {
790
+ 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 });
791
+ }
792
+ if (type === "text/markdown") {
793
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
794
+ "div",
795
+ {
796
+ className: "es-doc-prose prose prose-sm max-w-none rounded-md border border-border p-3",
797
+ dangerouslySetInnerHTML: { __html: safeMarkdownHtml(text) }
798
+ }
799
+ );
800
+ }
801
+ if (type === "text/html") {
802
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DocHtml, { entry: { kind: "html", content: text, title: att.name, phase: "runtime" } });
803
+ }
804
+ return null;
805
+ }
760
806
  function ReportAttachments({ attachments }) {
761
807
  if (attachments.length === 0) return null;
762
808
  return (
763
809
  // role="group" (not a labelled <section>) so multiple scenarios' attachment
764
810
  // blocks don't create duplicate "Attachments" region landmarks.
765
811
  /* @__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) => {
766
- const dataUri = att.contentEncoding === "BASE64" ? `data:${att.mediaType};base64,${att.body}` : `data:${att.mediaType},${encodeURIComponent(att.body)}`;
767
- const isImage = att.mediaType.startsWith("image/");
812
+ const dataUri = att.external ? void 0 : att.contentEncoding === "BASE64" ? `data:${att.mediaType};base64,${att.body}` : `data:${att.mediaType},${encodeURIComponent(att.body)}`;
813
+ const href = dataUri ?? (0, import_url.safeUrl)(att.body);
814
+ const imageSrc = dataUri ?? (0, import_url.safeImageUrl)(att.body);
815
+ const isImage = att.mediaType.startsWith("image/") && imageSrc !== void 0;
768
816
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("figure", { className: "m-0", children: isImage ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
769
817
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
770
818
  "img",
771
819
  {
772
- src: dataUri,
820
+ src: imageSrc,
773
821
  alt: att.name,
774
822
  loading: "lazy",
775
823
  className: "max-w-full rounded-md border border-border"
776
824
  }
777
825
  ),
778
826
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("figcaption", { className: "mt-1 text-xs text-muted-foreground", children: att.name })
779
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
780
- "a",
781
- {
782
- href: dataUri,
783
- download: att.name,
784
- className: "text-xs text-link underline underline-offset-2",
785
- children: [
786
- att.name,
787
- " ",
788
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "text-muted-foreground", children: [
789
- "(",
790
- att.mediaType,
791
- ")"
792
- ] })
793
- ]
794
- }
795
- ) }, `${att.name}-${i}`);
827
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
828
+ att.external ? null : preview(att),
829
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
830
+ "a",
831
+ {
832
+ href,
833
+ download: att.name,
834
+ className: "text-xs text-link underline underline-offset-2",
835
+ children: [
836
+ att.name,
837
+ " ",
838
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "text-muted-foreground", children: [
839
+ "(",
840
+ att.mediaType,
841
+ ")"
842
+ ] })
843
+ ]
844
+ }
845
+ )
846
+ ] }) }, `${att.name}-${i}`);
796
847
  }) })
797
848
  );
798
849
  }