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.js CHANGED
@@ -659,7 +659,7 @@ function ReportDocEntries({ entries }) {
659
659
  }
660
660
 
661
661
  // src/components/ReportSteps.tsx
662
- import { jsx as jsx19, jsxs as jsxs11 } from "react/jsx-runtime";
662
+ import { Fragment as Fragment6, jsx as jsx19, jsxs as jsxs11 } from "react/jsx-runtime";
663
663
  var STEP_GLYPH = {
664
664
  passed: "\u2713",
665
665
  failed: "\u2717",
@@ -736,6 +736,23 @@ function ReportStepItem({
736
736
  children: step.errorMessage
737
737
  }
738
738
  ) : null,
739
+ step.expected !== void 0 || step.actual !== void 0 ? /* @__PURE__ */ jsxs11(
740
+ "dl",
741
+ {
742
+ "data-slot": "step-comparison",
743
+ className: "mt-1.5 ml-6 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 font-mono text-xs",
744
+ children: [
745
+ step.expected !== void 0 ? /* @__PURE__ */ jsxs11(Fragment6, { children: [
746
+ /* @__PURE__ */ jsx19("dt", { className: "text-muted-foreground", children: "Expected" }),
747
+ /* @__PURE__ */ jsx19("dd", { className: "overflow-x-auto whitespace-pre-wrap text-pass", children: step.expected })
748
+ ] }) : null,
749
+ step.actual !== void 0 ? /* @__PURE__ */ jsxs11(Fragment6, { children: [
750
+ /* @__PURE__ */ jsx19("dt", { className: "text-muted-foreground", children: "Actual" }),
751
+ /* @__PURE__ */ jsx19("dd", { className: "overflow-x-auto whitespace-pre-wrap text-fail", children: step.actual })
752
+ ] }) : null
753
+ ]
754
+ }
755
+ ) : null,
739
756
  step.docEntries.length > 0 ? /* @__PURE__ */ jsx19("div", { "data-es-docs": true, className: "mt-2 ml-6", children: /* @__PURE__ */ jsx19(ReportDocEntries, { entries: step.docEntries }) }) : null
740
757
  ]
741
758
  }
@@ -859,43 +876,77 @@ function StateCardView({ card }) {
859
876
  }
860
877
 
861
878
  // src/components/ReportAttachments.tsx
862
- import { Fragment as Fragment6, jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
879
+ import { Fragment as Fragment7, jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
880
+ function attachmentText(att) {
881
+ if (att.contentEncoding !== "BASE64") return att.body;
882
+ try {
883
+ return new TextDecoder().decode(Uint8Array.from(atob(att.body), (c) => c.charCodeAt(0)));
884
+ } catch {
885
+ return void 0;
886
+ }
887
+ }
888
+ function preview(att) {
889
+ const type = att.mediaType.split(";")[0].trim().toLowerCase();
890
+ const text = attachmentText(att);
891
+ if (text === void 0) return null;
892
+ if (type === "text/plain") {
893
+ return /* @__PURE__ */ jsx21("pre", { className: "max-h-96 overflow-auto rounded-md border border-border bg-muted/40 p-3 text-xs whitespace-pre-wrap", children: text });
894
+ }
895
+ if (type === "text/markdown") {
896
+ return /* @__PURE__ */ jsx21(
897
+ "div",
898
+ {
899
+ className: "es-doc-prose prose prose-sm max-w-none rounded-md border border-border p-3",
900
+ dangerouslySetInnerHTML: { __html: safeMarkdownHtml(text) }
901
+ }
902
+ );
903
+ }
904
+ if (type === "text/html") {
905
+ return /* @__PURE__ */ jsx21(DocHtml, { entry: { kind: "html", content: text, title: att.name, phase: "runtime" } });
906
+ }
907
+ return null;
908
+ }
863
909
  function ReportAttachments({ attachments }) {
864
910
  if (attachments.length === 0) return null;
865
911
  return (
866
912
  // role="group" (not a labelled <section>) so multiple scenarios' attachment
867
913
  // blocks don't create duplicate "Attachments" region landmarks.
868
914
  /* @__PURE__ */ jsx21("div", { role: "group", "aria-label": "Attachments", className: "mt-3 flex flex-col gap-2", children: attachments.map((att, i) => {
869
- const dataUri = att.contentEncoding === "BASE64" ? `data:${att.mediaType};base64,${att.body}` : `data:${att.mediaType},${encodeURIComponent(att.body)}`;
870
- const isImage = att.mediaType.startsWith("image/");
871
- return /* @__PURE__ */ jsx21("figure", { className: "m-0", children: isImage ? /* @__PURE__ */ jsxs13(Fragment6, { children: [
915
+ const dataUri = att.external ? void 0 : att.contentEncoding === "BASE64" ? `data:${att.mediaType};base64,${att.body}` : `data:${att.mediaType},${encodeURIComponent(att.body)}`;
916
+ const href = dataUri ?? safeUrl(att.body);
917
+ const imageSrc = dataUri ?? safeImageUrl(att.body);
918
+ const isImage = att.mediaType.startsWith("image/") && imageSrc !== void 0;
919
+ return /* @__PURE__ */ jsx21("figure", { className: "m-0", children: isImage ? /* @__PURE__ */ jsxs13(Fragment7, { children: [
872
920
  /* @__PURE__ */ jsx21(
873
921
  "img",
874
922
  {
875
- src: dataUri,
923
+ src: imageSrc,
876
924
  alt: att.name,
877
925
  loading: "lazy",
878
926
  className: "max-w-full rounded-md border border-border"
879
927
  }
880
928
  ),
881
929
  /* @__PURE__ */ jsx21("figcaption", { className: "mt-1 text-xs text-muted-foreground", children: att.name })
882
- ] }) : /* @__PURE__ */ jsxs13(
883
- "a",
884
- {
885
- href: dataUri,
886
- download: att.name,
887
- className: "text-xs text-link underline underline-offset-2",
888
- children: [
889
- att.name,
890
- " ",
891
- /* @__PURE__ */ jsxs13("span", { className: "text-muted-foreground", children: [
892
- "(",
893
- att.mediaType,
894
- ")"
895
- ] })
896
- ]
897
- }
898
- ) }, `${att.name}-${i}`);
930
+ ] }) : /* @__PURE__ */ jsxs13(Fragment7, { children: [
931
+ att.external ? null : preview(att),
932
+ /* @__PURE__ */ jsxs13(
933
+ "a",
934
+ {
935
+ href,
936
+ download: att.name,
937
+ className: "text-xs text-link underline underline-offset-2",
938
+ children: [
939
+ att.name,
940
+ " ",
941
+ /* @__PURE__ */ jsxs13("span", { className: "text-muted-foreground", children: [
942
+ "(",
943
+ att.mediaType,
944
+ ")"
945
+ ] })
946
+ ]
947
+ }
948
+ )
949
+ ] }) }, `${att.name}-${i}`);
899
950
  }) })
900
951
  );
901
952
  }
@@ -1071,7 +1122,7 @@ function flakinessOf(entries) {
1071
1122
  }
1072
1123
 
1073
1124
  // src/components/ScenarioRunHistory.tsx
1074
- import { Fragment as Fragment7, jsx as jsx23, jsxs as jsxs15 } from "react/jsx-runtime";
1125
+ import { Fragment as Fragment8, jsx as jsx23, jsxs as jsxs15 } from "react/jsx-runtime";
1075
1126
  var MAX_DOTS = 10;
1076
1127
  var DOT_COLOR = {
1077
1128
  passed: "bg-pass",
@@ -1091,7 +1142,7 @@ function ScenarioRunHistory({ scenarioId }) {
1091
1142
  const recent = entries.slice(-MAX_DOTS);
1092
1143
  const flaky = flakinessOf(recent) === "flaky";
1093
1144
  const summary = flaky ? `${describeRunHistory(recent)} \xB7 Flaky` : describeRunHistory(recent);
1094
- return /* @__PURE__ */ jsxs15(Fragment7, { children: [
1145
+ return /* @__PURE__ */ jsxs15(Fragment8, { children: [
1095
1146
  flaky ? /* @__PURE__ */ jsx23(Badge, { variant: "pending", "aria-label": "Flaky: status flips between recent runs", title: summary, children: "Flaky" }) : null,
1096
1147
  /* @__PURE__ */ jsx23(
1097
1148
  "span",
@@ -1417,9 +1468,9 @@ function ReportScenario({ scenario, hideTitle = false }) {
1417
1468
  }
1418
1469
 
1419
1470
  // src/components/ReportScenarioList.tsx
1420
- import { Fragment as Fragment8, jsx as jsx27 } from "react/jsx-runtime";
1471
+ import { Fragment as Fragment9, jsx as jsx27 } from "react/jsx-runtime";
1421
1472
  function ReportScenarioList({ feature }) {
1422
- return /* @__PURE__ */ jsx27(Fragment8, { children: feature.scenarios.map((scenario) => /* @__PURE__ */ jsx27(ReportScenario, { scenario }, scenario.id)) });
1473
+ return /* @__PURE__ */ jsx27(Fragment9, { children: feature.scenarios.map((scenario) => /* @__PURE__ */ jsx27(ReportScenario, { scenario }, scenario.id)) });
1423
1474
  }
1424
1475
 
1425
1476
  // src/components/ReportFeatureIntro.tsx
@@ -1457,7 +1508,7 @@ function featureKindLabel(kind) {
1457
1508
  }
1458
1509
 
1459
1510
  // src/components/ReportFeature.tsx
1460
- import { Fragment as Fragment9, jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
1511
+ import { Fragment as Fragment10, jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
1461
1512
  function ReportFeature({ feature }) {
1462
1513
  const titleId = `${feature.id}-title`;
1463
1514
  const bodyId = `${feature.id}-body`;
@@ -1517,14 +1568,14 @@ function ReportFeature({ feature }) {
1517
1568
  s.failed,
1518
1569
  " failed"
1519
1570
  ] }),
1520
- s.skipped > 0 ? /* @__PURE__ */ jsxs20(Fragment9, { children: [
1571
+ s.skipped > 0 ? /* @__PURE__ */ jsxs20(Fragment10, { children: [
1521
1572
  /* @__PURE__ */ jsx29("span", { "aria-hidden": true, children: "\xB7" }),
1522
1573
  /* @__PURE__ */ jsxs20("span", { children: [
1523
1574
  s.skipped,
1524
1575
  " skipped"
1525
1576
  ] })
1526
1577
  ] }) : null,
1527
- s.pending > 0 ? /* @__PURE__ */ jsxs20(Fragment9, { children: [
1578
+ s.pending > 0 ? /* @__PURE__ */ jsxs20(Fragment10, { children: [
1528
1579
  /* @__PURE__ */ jsx29("span", { "aria-hidden": true, children: "\xB7" }),
1529
1580
  /* @__PURE__ */ jsxs20("span", { children: [
1530
1581
  s.pending,
@@ -1771,9 +1822,9 @@ function ReportSchemaError({ error }) {
1771
1822
  }
1772
1823
 
1773
1824
  // src/components/ReportShell.tsx
1774
- import { Fragment as Fragment10, jsx as jsx36, jsxs as jsxs24 } from "react/jsx-runtime";
1825
+ import { Fragment as Fragment11, jsx as jsx36, jsxs as jsxs24 } from "react/jsx-runtime";
1775
1826
  function ReportTitleBlock({ title }) {
1776
- return /* @__PURE__ */ jsxs24(Fragment10, { children: [
1827
+ return /* @__PURE__ */ jsxs24(Fragment11, { children: [
1777
1828
  /* @__PURE__ */ jsx36("h1", { children: title ?? "Story Report" }),
1778
1829
  /* @__PURE__ */ jsx36(ReportSummary, {}),
1779
1830
  /* @__PURE__ */ jsx36(ReportMeta, {})