executable-stories-react 0.2.1 → 0.4.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.d.cts CHANGED
@@ -1,4 +1,226 @@
1
- import { StoryReport } from 'executable-stories-core';
1
+ /**
2
+ * OTel span types for trace waterfall rendering.
3
+ *
4
+ * Structurally compatible with autotel's SerializedSpan
5
+ * and raw OTel nanosecond formats. No import dependency on autotel.
6
+ */
7
+ type OtelAttributeValue = string | number | boolean | string[] | number[] | boolean[];
8
+ interface OtelSpan {
9
+ spanId: string;
10
+ parentSpanId?: string;
11
+ name: string;
12
+ /** Preferred: epoch-based milliseconds (from autotel's SerializedSpan) */
13
+ startTimeMs?: number;
14
+ durationMs?: number;
15
+ /** Compatibility: raw OTel nanosecond timestamps */
16
+ startTimeUnixNano?: number;
17
+ endTimeUnixNano?: number;
18
+ status: "ok" | "error" | "unset";
19
+ statusMessage?: string;
20
+ attributes?: Record<string, OtelAttributeValue>;
21
+ }
22
+
23
+ /** Phase tracks when the doc entry was added */
24
+ type DocPhase = "static" | "runtime";
25
+
26
+ /**
27
+ * StoryReport — public, frozen contract for UI renderers.
28
+ *
29
+ * Distinct from internal TestRunResult. Pre-grouped feature → scenario tree,
30
+ * with pre-computed summaries at every level. Adapter concerns (rawStatus,
31
+ * projectName, titlePath) are stripped at the toStoryReport boundary.
32
+ *
33
+ * Versioning: semver-style "<major>.<minor>". Additive-only within a major.
34
+ * Source of truth: schemas/story-report-v1.json. Types here must stay in sync.
35
+ */
36
+
37
+ type StoryReportSchemaVersion = `1.${number}`;
38
+ type TestStatus = "passed" | "failed" | "skipped" | "pending";
39
+ type StepKeyword = "Given" | "When" | "Then" | "And" | "But";
40
+ type StepMode = "normal" | "skip" | "only" | "todo" | "fails" | "concurrent";
41
+ interface ReportSummary {
42
+ total: number;
43
+ passed: number;
44
+ failed: number;
45
+ skipped: number;
46
+ pending: number;
47
+ durationMs: number;
48
+ }
49
+ interface ReportTicket {
50
+ id: string;
51
+ url?: string;
52
+ }
53
+ interface ReportAttachment {
54
+ name: string;
55
+ mediaType: string;
56
+ body: string;
57
+ contentEncoding: "BASE64" | "IDENTITY";
58
+ }
59
+ interface ReportCIInfo {
60
+ name: string;
61
+ url?: string;
62
+ buildNumber?: string;
63
+ branch?: string;
64
+ commitSha?: string;
65
+ prNumber?: string;
66
+ }
67
+ interface ReportCoverageSummary {
68
+ linesPct?: number;
69
+ branchesPct?: number;
70
+ functionsPct?: number;
71
+ statementsPct?: number;
72
+ }
73
+ type ReportDocEntry = ReportDocNote | ReportDocTag | ReportDocKv | ReportDocCode | ReportDocTable | ReportDocLink | ReportDocSection | ReportDocMermaid | ReportDocScreenshot | ReportDocVideo | ReportDocHtml | ReportDocCustom;
74
+ interface ReportDocNote {
75
+ kind: "note";
76
+ text: string;
77
+ phase: DocPhase;
78
+ children?: ReportDocEntry[];
79
+ }
80
+ interface ReportDocTag {
81
+ kind: "tag";
82
+ names: string[];
83
+ phase: DocPhase;
84
+ children?: ReportDocEntry[];
85
+ }
86
+ interface ReportDocKv {
87
+ kind: "kv";
88
+ label: string;
89
+ value: unknown;
90
+ phase: DocPhase;
91
+ children?: ReportDocEntry[];
92
+ }
93
+ interface ReportDocCode {
94
+ kind: "code";
95
+ label: string;
96
+ content: string;
97
+ lang?: string;
98
+ phase: DocPhase;
99
+ children?: ReportDocEntry[];
100
+ }
101
+ interface ReportDocTable {
102
+ kind: "table";
103
+ label: string;
104
+ columns: string[];
105
+ rows: string[][];
106
+ phase: DocPhase;
107
+ children?: ReportDocEntry[];
108
+ }
109
+ interface ReportDocLink {
110
+ kind: "link";
111
+ label: string;
112
+ url: string;
113
+ phase: DocPhase;
114
+ children?: ReportDocEntry[];
115
+ }
116
+ interface ReportDocSection {
117
+ kind: "section";
118
+ title: string;
119
+ markdown: string;
120
+ phase: DocPhase;
121
+ children?: ReportDocEntry[];
122
+ }
123
+ interface ReportDocMermaid {
124
+ kind: "mermaid";
125
+ code: string;
126
+ title?: string;
127
+ phase: DocPhase;
128
+ children?: ReportDocEntry[];
129
+ }
130
+ interface ReportDocScreenshot {
131
+ kind: "screenshot";
132
+ path: string;
133
+ alt?: string;
134
+ phase: DocPhase;
135
+ children?: ReportDocEntry[];
136
+ }
137
+ interface ReportDocVideo {
138
+ kind: "video";
139
+ path: string;
140
+ caption?: string;
141
+ poster?: string;
142
+ phase: DocPhase;
143
+ children?: ReportDocEntry[];
144
+ }
145
+ interface ReportDocHtml {
146
+ kind: "html";
147
+ /** Local HTML file path (exactly one of path/url/content) */
148
+ path?: string;
149
+ /** Remote URL rendered via iframe src (exactly one of path/url/content) */
150
+ url?: string;
151
+ /** Inline HTML content rendered via iframe srcdoc (exactly one of path/url/content) */
152
+ content?: string;
153
+ title?: string;
154
+ /** Iframe height: number → px, string passed through (e.g. "60vh"). Default 400px. */
155
+ height?: number | string;
156
+ phase: DocPhase;
157
+ children?: ReportDocEntry[];
158
+ }
159
+ interface ReportDocCustom {
160
+ kind: "custom";
161
+ type: string;
162
+ data: unknown;
163
+ phase: DocPhase;
164
+ children?: ReportDocEntry[];
165
+ }
166
+ interface ReportStep {
167
+ id: string;
168
+ index: number;
169
+ keyword: StepKeyword;
170
+ text: string;
171
+ status: TestStatus;
172
+ durationMs: number;
173
+ errorMessage?: string;
174
+ mode?: StepMode;
175
+ docEntries: ReportDocEntry[];
176
+ }
177
+ interface ReportScenario {
178
+ id: string;
179
+ title: string;
180
+ status: TestStatus;
181
+ /**
182
+ * True for scenarios authored with the framework's todo modifier
183
+ * (e.g. `it.todo`): specified behavior with no implementation yet.
184
+ * Canonical status stays "pending"; this flags why.
185
+ */
186
+ planned?: boolean;
187
+ durationMs: number;
188
+ tags: string[];
189
+ tickets?: ReportTicket[];
190
+ /** Product-code paths/globs this scenario exercises (project-root-relative). */
191
+ covers?: string[];
192
+ sourceLine?: number;
193
+ errorMessage?: string;
194
+ errorStack?: string;
195
+ retry: number;
196
+ retries: number;
197
+ docEntries: ReportDocEntry[];
198
+ steps: ReportStep[];
199
+ attachments: ReportAttachment[];
200
+ /** OTel spans for the trace waterfall (carried through from the run). */
201
+ otelSpans?: OtelSpan[];
202
+ }
203
+ interface ReportFeature {
204
+ id: string;
205
+ title: string;
206
+ sourceFile: string;
207
+ summary: ReportSummary;
208
+ scenarios: ReportScenario[];
209
+ }
210
+ interface StoryReport {
211
+ schemaVersion: StoryReportSchemaVersion;
212
+ runId: string;
213
+ startedAtMs: number;
214
+ finishedAtMs: number;
215
+ durationMs: number;
216
+ projectRoot: string;
217
+ packageVersion?: string;
218
+ gitSha?: string;
219
+ ci?: ReportCIInfo;
220
+ coverage?: ReportCoverageSummary;
221
+ summary: ReportSummary;
222
+ features: ReportFeature[];
223
+ }
2
224
 
3
225
  /**
4
226
  * Result<T> — explicit success/error type matching the cookbook convention.
@@ -24,6 +246,20 @@ interface ReportParseError {
24
246
  }
25
247
  type ReportParseErrorCode = "INVALID_INPUT" | "SCHEMA_VERSION_MISMATCH" | "VALIDATION_FAILED";
26
248
 
249
+ type ScenarioRunStatus = "passed" | "failed" | "skipped" | "pending";
250
+ /** One historical run of a scenario, oldest → newest in a history array. */
251
+ interface ScenarioRunEvent {
252
+ /** Epoch ms the run started. */
253
+ timestamp: number;
254
+ status: ScenarioRunStatus;
255
+ runId?: string;
256
+ durationMs?: number;
257
+ commitSha?: string;
258
+ branch?: string;
259
+ }
260
+ /** Recent run events keyed by ReportScenario.id. */
261
+ type ScenarioHistoryMap = Record<string, ScenarioRunEvent[]>;
262
+
27
263
  /**
28
264
  * Server-only entry: render a StoryReport to a standalone HTML document string.
29
265
  *
@@ -61,6 +297,18 @@ interface RenderReportToHtmlOptions {
61
297
  * no-JS fallback.
62
298
  */
63
299
  islandScript?: string;
300
+ /**
301
+ * Days before the interactive report flags itself as stale ("Last verified
302
+ * N days ago" warning banner). 0 disables the warning. Default 7.
303
+ */
304
+ staleAfterDays?: number;
305
+ /**
306
+ * Recent run events per scenario id (joined from the CLI's --history-file
307
+ * store). Embedded as JSON next to the report data; the interactive island
308
+ * renders a run-over-run timeline strip on each scenario card. Ignored for
309
+ * static (non-island) output.
310
+ */
311
+ scenarioHistory?: ScenarioHistoryMap;
64
312
  }
65
313
  /**
66
314
  * Render a StoryReport (or a parse Result) to a complete, self-contained HTML
@@ -69,4 +317,4 @@ interface RenderReportToHtmlOptions {
69
317
  */
70
318
  declare function renderReportToHtml(report: StoryReport | Result<StoryReport>, options?: RenderReportToHtmlOptions): string;
71
319
 
72
- export { type RenderReportToHtmlOptions, renderReportToHtml };
320
+ export { type RenderReportToHtmlOptions, type ScenarioHistoryMap, type ScenarioRunEvent, renderReportToHtml };
package/dist/ssr.d.ts CHANGED
@@ -1,4 +1,226 @@
1
- import { StoryReport } from 'executable-stories-core';
1
+ /**
2
+ * OTel span types for trace waterfall rendering.
3
+ *
4
+ * Structurally compatible with autotel's SerializedSpan
5
+ * and raw OTel nanosecond formats. No import dependency on autotel.
6
+ */
7
+ type OtelAttributeValue = string | number | boolean | string[] | number[] | boolean[];
8
+ interface OtelSpan {
9
+ spanId: string;
10
+ parentSpanId?: string;
11
+ name: string;
12
+ /** Preferred: epoch-based milliseconds (from autotel's SerializedSpan) */
13
+ startTimeMs?: number;
14
+ durationMs?: number;
15
+ /** Compatibility: raw OTel nanosecond timestamps */
16
+ startTimeUnixNano?: number;
17
+ endTimeUnixNano?: number;
18
+ status: "ok" | "error" | "unset";
19
+ statusMessage?: string;
20
+ attributes?: Record<string, OtelAttributeValue>;
21
+ }
22
+
23
+ /** Phase tracks when the doc entry was added */
24
+ type DocPhase = "static" | "runtime";
25
+
26
+ /**
27
+ * StoryReport — public, frozen contract for UI renderers.
28
+ *
29
+ * Distinct from internal TestRunResult. Pre-grouped feature → scenario tree,
30
+ * with pre-computed summaries at every level. Adapter concerns (rawStatus,
31
+ * projectName, titlePath) are stripped at the toStoryReport boundary.
32
+ *
33
+ * Versioning: semver-style "<major>.<minor>". Additive-only within a major.
34
+ * Source of truth: schemas/story-report-v1.json. Types here must stay in sync.
35
+ */
36
+
37
+ type StoryReportSchemaVersion = `1.${number}`;
38
+ type TestStatus = "passed" | "failed" | "skipped" | "pending";
39
+ type StepKeyword = "Given" | "When" | "Then" | "And" | "But";
40
+ type StepMode = "normal" | "skip" | "only" | "todo" | "fails" | "concurrent";
41
+ interface ReportSummary {
42
+ total: number;
43
+ passed: number;
44
+ failed: number;
45
+ skipped: number;
46
+ pending: number;
47
+ durationMs: number;
48
+ }
49
+ interface ReportTicket {
50
+ id: string;
51
+ url?: string;
52
+ }
53
+ interface ReportAttachment {
54
+ name: string;
55
+ mediaType: string;
56
+ body: string;
57
+ contentEncoding: "BASE64" | "IDENTITY";
58
+ }
59
+ interface ReportCIInfo {
60
+ name: string;
61
+ url?: string;
62
+ buildNumber?: string;
63
+ branch?: string;
64
+ commitSha?: string;
65
+ prNumber?: string;
66
+ }
67
+ interface ReportCoverageSummary {
68
+ linesPct?: number;
69
+ branchesPct?: number;
70
+ functionsPct?: number;
71
+ statementsPct?: number;
72
+ }
73
+ type ReportDocEntry = ReportDocNote | ReportDocTag | ReportDocKv | ReportDocCode | ReportDocTable | ReportDocLink | ReportDocSection | ReportDocMermaid | ReportDocScreenshot | ReportDocVideo | ReportDocHtml | ReportDocCustom;
74
+ interface ReportDocNote {
75
+ kind: "note";
76
+ text: string;
77
+ phase: DocPhase;
78
+ children?: ReportDocEntry[];
79
+ }
80
+ interface ReportDocTag {
81
+ kind: "tag";
82
+ names: string[];
83
+ phase: DocPhase;
84
+ children?: ReportDocEntry[];
85
+ }
86
+ interface ReportDocKv {
87
+ kind: "kv";
88
+ label: string;
89
+ value: unknown;
90
+ phase: DocPhase;
91
+ children?: ReportDocEntry[];
92
+ }
93
+ interface ReportDocCode {
94
+ kind: "code";
95
+ label: string;
96
+ content: string;
97
+ lang?: string;
98
+ phase: DocPhase;
99
+ children?: ReportDocEntry[];
100
+ }
101
+ interface ReportDocTable {
102
+ kind: "table";
103
+ label: string;
104
+ columns: string[];
105
+ rows: string[][];
106
+ phase: DocPhase;
107
+ children?: ReportDocEntry[];
108
+ }
109
+ interface ReportDocLink {
110
+ kind: "link";
111
+ label: string;
112
+ url: string;
113
+ phase: DocPhase;
114
+ children?: ReportDocEntry[];
115
+ }
116
+ interface ReportDocSection {
117
+ kind: "section";
118
+ title: string;
119
+ markdown: string;
120
+ phase: DocPhase;
121
+ children?: ReportDocEntry[];
122
+ }
123
+ interface ReportDocMermaid {
124
+ kind: "mermaid";
125
+ code: string;
126
+ title?: string;
127
+ phase: DocPhase;
128
+ children?: ReportDocEntry[];
129
+ }
130
+ interface ReportDocScreenshot {
131
+ kind: "screenshot";
132
+ path: string;
133
+ alt?: string;
134
+ phase: DocPhase;
135
+ children?: ReportDocEntry[];
136
+ }
137
+ interface ReportDocVideo {
138
+ kind: "video";
139
+ path: string;
140
+ caption?: string;
141
+ poster?: string;
142
+ phase: DocPhase;
143
+ children?: ReportDocEntry[];
144
+ }
145
+ interface ReportDocHtml {
146
+ kind: "html";
147
+ /** Local HTML file path (exactly one of path/url/content) */
148
+ path?: string;
149
+ /** Remote URL rendered via iframe src (exactly one of path/url/content) */
150
+ url?: string;
151
+ /** Inline HTML content rendered via iframe srcdoc (exactly one of path/url/content) */
152
+ content?: string;
153
+ title?: string;
154
+ /** Iframe height: number → px, string passed through (e.g. "60vh"). Default 400px. */
155
+ height?: number | string;
156
+ phase: DocPhase;
157
+ children?: ReportDocEntry[];
158
+ }
159
+ interface ReportDocCustom {
160
+ kind: "custom";
161
+ type: string;
162
+ data: unknown;
163
+ phase: DocPhase;
164
+ children?: ReportDocEntry[];
165
+ }
166
+ interface ReportStep {
167
+ id: string;
168
+ index: number;
169
+ keyword: StepKeyword;
170
+ text: string;
171
+ status: TestStatus;
172
+ durationMs: number;
173
+ errorMessage?: string;
174
+ mode?: StepMode;
175
+ docEntries: ReportDocEntry[];
176
+ }
177
+ interface ReportScenario {
178
+ id: string;
179
+ title: string;
180
+ status: TestStatus;
181
+ /**
182
+ * True for scenarios authored with the framework's todo modifier
183
+ * (e.g. `it.todo`): specified behavior with no implementation yet.
184
+ * Canonical status stays "pending"; this flags why.
185
+ */
186
+ planned?: boolean;
187
+ durationMs: number;
188
+ tags: string[];
189
+ tickets?: ReportTicket[];
190
+ /** Product-code paths/globs this scenario exercises (project-root-relative). */
191
+ covers?: string[];
192
+ sourceLine?: number;
193
+ errorMessage?: string;
194
+ errorStack?: string;
195
+ retry: number;
196
+ retries: number;
197
+ docEntries: ReportDocEntry[];
198
+ steps: ReportStep[];
199
+ attachments: ReportAttachment[];
200
+ /** OTel spans for the trace waterfall (carried through from the run). */
201
+ otelSpans?: OtelSpan[];
202
+ }
203
+ interface ReportFeature {
204
+ id: string;
205
+ title: string;
206
+ sourceFile: string;
207
+ summary: ReportSummary;
208
+ scenarios: ReportScenario[];
209
+ }
210
+ interface StoryReport {
211
+ schemaVersion: StoryReportSchemaVersion;
212
+ runId: string;
213
+ startedAtMs: number;
214
+ finishedAtMs: number;
215
+ durationMs: number;
216
+ projectRoot: string;
217
+ packageVersion?: string;
218
+ gitSha?: string;
219
+ ci?: ReportCIInfo;
220
+ coverage?: ReportCoverageSummary;
221
+ summary: ReportSummary;
222
+ features: ReportFeature[];
223
+ }
2
224
 
3
225
  /**
4
226
  * Result<T> — explicit success/error type matching the cookbook convention.
@@ -24,6 +246,20 @@ interface ReportParseError {
24
246
  }
25
247
  type ReportParseErrorCode = "INVALID_INPUT" | "SCHEMA_VERSION_MISMATCH" | "VALIDATION_FAILED";
26
248
 
249
+ type ScenarioRunStatus = "passed" | "failed" | "skipped" | "pending";
250
+ /** One historical run of a scenario, oldest → newest in a history array. */
251
+ interface ScenarioRunEvent {
252
+ /** Epoch ms the run started. */
253
+ timestamp: number;
254
+ status: ScenarioRunStatus;
255
+ runId?: string;
256
+ durationMs?: number;
257
+ commitSha?: string;
258
+ branch?: string;
259
+ }
260
+ /** Recent run events keyed by ReportScenario.id. */
261
+ type ScenarioHistoryMap = Record<string, ScenarioRunEvent[]>;
262
+
27
263
  /**
28
264
  * Server-only entry: render a StoryReport to a standalone HTML document string.
29
265
  *
@@ -61,6 +297,18 @@ interface RenderReportToHtmlOptions {
61
297
  * no-JS fallback.
62
298
  */
63
299
  islandScript?: string;
300
+ /**
301
+ * Days before the interactive report flags itself as stale ("Last verified
302
+ * N days ago" warning banner). 0 disables the warning. Default 7.
303
+ */
304
+ staleAfterDays?: number;
305
+ /**
306
+ * Recent run events per scenario id (joined from the CLI's --history-file
307
+ * store). Embedded as JSON next to the report data; the interactive island
308
+ * renders a run-over-run timeline strip on each scenario card. Ignored for
309
+ * static (non-island) output.
310
+ */
311
+ scenarioHistory?: ScenarioHistoryMap;
64
312
  }
65
313
  /**
66
314
  * Render a StoryReport (or a parse Result) to a complete, self-contained HTML
@@ -69,4 +317,4 @@ interface RenderReportToHtmlOptions {
69
317
  */
70
318
  declare function renderReportToHtml(report: StoryReport | Result<StoryReport>, options?: RenderReportToHtmlOptions): string;
71
319
 
72
- export { type RenderReportToHtmlOptions, renderReportToHtml };
320
+ export { type RenderReportToHtmlOptions, type ScenarioHistoryMap, type ScenarioRunEvent, renderReportToHtml };