@allurereport/reader 3.16.0 → 3.17.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.
@@ -17,6 +17,13 @@ const xmlParser = new XMLParser({
17
17
  isArray: (tagName, jPath) => arrayTags.has(jPath.toString()),
18
18
  });
19
19
  const readerId = "allure2";
20
+ const historyMetadataKeys = {
21
+ "history.json": "allure2_history",
22
+ "history-trend.json": "allure2_history_trend",
23
+ "duration-trend.json": "allure2_duration_trend",
24
+ "retry-trend.json": "allure2_retry_trend",
25
+ "categories-trend.json": "allure2_categories_trend",
26
+ };
20
27
  const isAllure2AttachmentFileName = (fileName) => {
21
28
  const attachmentIdx = fileName.lastIndexOf("-attachment");
22
29
  if (attachmentIdx === -1) {
@@ -30,6 +37,10 @@ const matchesAllure2File = (fileName) => {
30
37
  return true;
31
38
  if (fileName.endsWith("-check.json"))
32
39
  return true;
40
+ if (fileName.endsWith("-perf.json"))
41
+ return true;
42
+ if (fileName === "performance.json")
43
+ return true;
33
44
  if (fileName.endsWith("-container.json"))
34
45
  return true;
35
46
  if (fileName.endsWith("-globals.json"))
@@ -44,6 +55,8 @@ const matchesAllure2File = (fileName) => {
44
55
  return true;
45
56
  if (fileName === "environment.xml")
46
57
  return true;
58
+ if (fileName in historyMetadataKeys)
59
+ return true;
47
60
  return false;
48
61
  };
49
62
  export const allure2 = {
@@ -63,6 +76,20 @@ export const allure2 = {
63
76
  return false;
64
77
  }
65
78
  }
79
+ if (originalFileName.endsWith("-perf.json") || originalFileName === "performance.json") {
80
+ try {
81
+ const results = await data.asJson();
82
+ if (!Array.isArray(results)) {
83
+ return false;
84
+ }
85
+ await visitor.visitMetrics(results, { readerId, metadata: { originalFileName } });
86
+ return true;
87
+ }
88
+ catch (e) {
89
+ console.error("error parsing", originalFileName, e);
90
+ return false;
91
+ }
92
+ }
66
93
  if (originalFileName.endsWith("-result.json")) {
67
94
  try {
68
95
  const parsed = await data.asJson();
@@ -90,6 +117,20 @@ export const allure2 = {
90
117
  }
91
118
  return true;
92
119
  }
120
+ const historyMetadataKey = historyMetadataKeys[originalFileName];
121
+ if (historyMetadataKey) {
122
+ try {
123
+ const parsed = await data.asJson();
124
+ if (parsed && (isStringAnyRecord(parsed) || isStringAnyRecordArray(parsed))) {
125
+ await visitor.visitMetadata({ [historyMetadataKey]: parsed }, { readerId });
126
+ }
127
+ return true;
128
+ }
129
+ catch (e) {
130
+ console.error("error parsing", originalFileName, e);
131
+ return false;
132
+ }
133
+ }
93
134
  if (originalFileName === "executor.json") {
94
135
  try {
95
136
  const parsed = await data.asJson();
@@ -156,6 +197,8 @@ export const allure2 = {
156
197
  readerId: () => readerId,
157
198
  };
158
199
  const processTestResult = async (visitor, result, originalFileName) => {
200
+ const links = result?.links?.filter(notNull) ?? [];
201
+ const topLevelAttachmentCount = result?.attachments?.filter(notNull).length ?? 0;
159
202
  const dest = {
160
203
  uuid: ensureString(result.uuid),
161
204
  titlePath: result?.titlePath?.length ? result.titlePath : [],
@@ -180,10 +223,17 @@ const processTestResult = async (visitor, result, originalFileName) => {
180
223
  ...(result?.steps?.filter(notNull)?.map(convertStep) ?? []),
181
224
  ...(result?.attachments?.filter(notNull)?.map(convertAttachment) ?? []),
182
225
  ],
183
- links: result?.links?.filter(notNull)?.map(convertLink),
226
+ links: links.map(convertLink),
184
227
  labels: result.labels?.filter(notNull)?.map(convertLabel),
185
228
  };
186
- await visitor.visitTestResult(dest, { readerId, metadata: { originalFileName } });
229
+ await visitor.visitTestResult(dest, {
230
+ readerId,
231
+ metadata: {
232
+ originalFileName,
233
+ allure2_links: links,
234
+ allure2_top_level_attachment_count: topLevelAttachmentCount,
235
+ },
236
+ });
187
237
  };
188
238
  const processCheckResult = async (visitor, result, originalFileName) => {
189
239
  const tags = Array.isArray(result.tags) ? result.tags.map((tag) => ensureString(tag)).filter(notNull) : [];
@@ -275,7 +325,12 @@ const processFixtures = async (visitor, fixtures, type, children) => {
275
325
  if (fixtures) {
276
326
  for (const fixture of fixtures) {
277
327
  const dist = convertFixture(type, children, fixture);
278
- await visitor.visitTestFixtureResult(dist, { readerId });
328
+ await visitor.visitTestFixtureResult(dist, {
329
+ readerId,
330
+ metadata: {
331
+ allure2_top_level_attachment_count: fixture?.attachments?.filter(notNull).length ?? 0,
332
+ },
333
+ });
279
334
  }
280
335
  }
281
336
  };
@@ -287,11 +342,19 @@ const processTestResultContainer = async (visitor, result) => {
287
342
  };
288
343
  const processGlobals = async (visitor, globals) => {
289
344
  const { attachments = [], errors = [] } = globals;
345
+ const normalizedAttachments = Array.isArray(attachments) ? attachments : [];
346
+ const normalizedErrors = isStringAnyRecordArray(errors) ? errors : [];
347
+ const attachmentTimestamps = Object.fromEntries(normalizedAttachments
348
+ .filter((attachment) => typeof attachment.timestamp === "number" && typeof attachment.source === "string")
349
+ .map((attachment) => [attachment.source, attachment.timestamp]));
350
+ const errorTimestamps = normalizedErrors.map((error) => ensureInt(error.timestamp));
351
+ await visitor.visitMetadata({
352
+ allure2_global_attachment_timestamps: attachmentTimestamps,
353
+ allure2_global_error_timestamps: errorTimestamps,
354
+ }, { readerId });
290
355
  await visitor.visitGlobals({
291
- attachments: Array.isArray(attachments)
292
- ? attachments.map((attachment) => convertGlobalAttachment(attachment))
293
- : [],
294
- errors: isStringAnyRecordArray(errors) ? errors.map((error) => convertGlobalError(error)) : [],
356
+ attachments: normalizedAttachments.map((attachment) => convertGlobalAttachment(attachment)),
357
+ errors: normalizedErrors.map((error) => convertGlobalError(error)),
295
358
  }, { readerId });
296
359
  };
297
360
  const convertCheckStatus = (status) => {
@@ -5,6 +5,7 @@ export interface Attachment {
5
5
  }
6
6
  export interface GlobalAttachment extends Attachment {
7
7
  environment?: string;
8
+ timestamp?: number;
8
9
  }
9
10
  export declare enum Status {
10
11
  FAILED = "failed",
@@ -50,6 +51,7 @@ export interface StatusDetails {
50
51
  }
51
52
  export interface GlobalStatusDetails extends StatusDetails {
52
53
  environment?: string;
54
+ timestamp?: number;
53
55
  }
54
56
  interface ExecutableItem {
55
57
  name?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/reader",
3
- "version": "3.16.0",
3
+ "version": "3.17.0",
4
4
  "description": "Collection of utilities which helps to process different kind of test results as Allure Results",
5
5
  "keywords": [
6
6
  "allure",
@@ -26,9 +26,9 @@
26
26
  "lint:fix": "oxlint --import-plugin --fix src test features stories"
27
27
  },
28
28
  "dependencies": {
29
- "@allurereport/core-api": "3.16.0",
30
- "@allurereport/plugin-api": "3.16.0",
31
- "@allurereport/reader-api": "3.16.0",
29
+ "@allurereport/core-api": "3.17.0",
30
+ "@allurereport/plugin-api": "3.17.0",
31
+ "@allurereport/reader-api": "3.17.0",
32
32
  "fast-xml-parser": "^5.7.0"
33
33
  },
34
34
  "devDependencies": {