@allurereport/reader 3.0.0-beta.4 → 3.0.0-beta.5

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.
@@ -49,7 +49,7 @@ const parseRootElement = async (visitor, xml) => {
49
49
  return await parseTestSuite(visitor, testSuite);
50
50
  };
51
51
  const parseTestSuite = async (visitor, testSuite) => {
52
- const { name: testSuiteName, "test-cases": testCases } = testSuite;
52
+ const { "name": testSuiteName, "test-cases": testCases } = testSuite;
53
53
  if (!isStringAnyRecord(testCases)) {
54
54
  return false;
55
55
  }
@@ -1,4 +1,5 @@
1
1
  import { BufferResultFile } from "@allurereport/reader-api";
2
+ import * as console from "node:console";
2
3
  import { randomUUID } from "node:crypto";
3
4
  import { ensureArray, ensureInt, ensureString, isArray, isNonNullObject, isString } from "../utils.js";
4
5
  import { STEP_NAME_PLACEHOLDER, TEST_NAME_PLACEHOLDER } from "./model.js";
@@ -32,19 +33,21 @@ const allureStepMessages = {
32
33
  export const cucumberjson = {
33
34
  read: async (visitor, data) => {
34
35
  const originalFileName = data.getOriginalFileName();
35
- try {
36
- const parsed = await data.asJson();
37
- if (parsed) {
38
- let oneOrMoreFeaturesParsed = false;
39
- for (const feature of parsed) {
40
- oneOrMoreFeaturesParsed || (oneOrMoreFeaturesParsed = await processFeature(visitor, originalFileName, feature));
36
+ if (originalFileName.endsWith(".json")) {
37
+ try {
38
+ const parsed = await data.asJson();
39
+ if (parsed) {
40
+ let oneOrMoreFeaturesParsed = false;
41
+ for (const feature of parsed) {
42
+ oneOrMoreFeaturesParsed || (oneOrMoreFeaturesParsed = await processFeature(visitor, originalFileName, feature));
43
+ }
44
+ return oneOrMoreFeaturesParsed;
41
45
  }
42
- return oneOrMoreFeaturesParsed;
43
46
  }
44
- }
45
- catch (e) {
46
- console.error("error parsing", originalFileName, e);
47
- return false;
47
+ catch (e) {
48
+ console.error("error parsing", originalFileName, e);
49
+ return false;
50
+ }
48
51
  }
49
52
  return false;
50
53
  },
@@ -91,24 +94,42 @@ const preProcessOneStep = async (visitor, step) => {
91
94
  };
92
95
  };
93
96
  const processStepAttachments = async (visitor, step) => [
94
- await processStepDocStringAttachment(visitor, step),
95
- await processStepDataTableAttachment(visitor, step),
97
+ await processStepDocStringAttachment(visitor, step.doc_string),
98
+ await processStepDataTableAttachment(visitor, step.rows),
99
+ ...(await processCucumberJsStepArguments(visitor, step.arguments)),
96
100
  ...(await processStepEmbeddingAttachments(visitor, step)),
97
101
  ].filter((s) => typeof s !== "undefined");
98
- const processStepDocStringAttachment = async (visitor, { doc_string: docString }) => {
102
+ const processStepDocStringAttachment = async (visitor, docString) => {
99
103
  if (docString) {
100
- const { value, content_type: contentType } = docString;
101
- if (value && value.trim()) {
102
- return await visitBufferAttachment(visitor, "Description", Buffer.from(value), contentType || "text/markdown");
104
+ const { value, content, content_type: contentType } = docString;
105
+ const resolvedValue = ensureString(value ?? content);
106
+ if (resolvedValue && resolvedValue.trim()) {
107
+ return await visitBufferAttachment(visitor, "Description", Buffer.from(resolvedValue), ensureString(contentType) || "text/markdown");
103
108
  }
104
109
  }
105
110
  };
106
- const processStepDataTableAttachment = async (visitor, { rows }) => {
111
+ const processStepDataTableAttachment = async (visitor, rows) => {
107
112
  if (isArray(rows)) {
108
113
  const content = formatDataTable(rows);
109
114
  return await visitBufferAttachment(visitor, "Data", Buffer.from(content), "text/csv");
110
115
  }
111
116
  };
117
+ const processCucumberJsStepArguments = async (visitor, stepArguments) => {
118
+ const attachments = [];
119
+ if (isArray(stepArguments)) {
120
+ for (const stepArgument of stepArguments) {
121
+ if (isNonNullObject(stepArgument)) {
122
+ if ("content" in stepArgument) {
123
+ attachments.push(await processStepDocStringAttachment(visitor, stepArgument));
124
+ }
125
+ else if ("rows" in stepArgument) {
126
+ attachments.push(await processStepDataTableAttachment(visitor, stepArgument.rows));
127
+ }
128
+ }
129
+ }
130
+ }
131
+ return attachments;
132
+ };
112
133
  const processStepEmbeddingAttachments = async (visitor, { embeddings }) => {
113
134
  const attachments = [];
114
135
  const checkedEmbeddings = ensureArray(embeddings) ?? [];
@@ -32,11 +32,13 @@ export type CucumberStep = {
32
32
  output?: string[];
33
33
  result: CucumberStepResult;
34
34
  rows?: unknown;
35
+ arguments?: unknown;
35
36
  };
36
37
  export type CucumberDocString = {
37
38
  content_type?: string;
38
39
  line?: number;
39
40
  value?: string;
41
+ content?: string;
40
42
  };
41
43
  export type CucumberDatatableRow = {
42
44
  cells: unknown;
@@ -58,3 +60,6 @@ export type CucumberEmbedding = {
58
60
  mime_type: unknown;
59
61
  name?: unknown;
60
62
  };
63
+ export type CucumberJsStepArgument = CucumberDocString | {
64
+ rows: CucumberDatatableRow[];
65
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/reader",
3
- "version": "3.0.0-beta.4",
3
+ "version": "3.0.0-beta.5",
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
  "test": "vitest run"
27
27
  },
28
28
  "dependencies": {
29
- "@allurereport/core-api": "3.0.0-beta.4",
30
- "@allurereport/plugin-api": "3.0.0-beta.4",
31
- "@allurereport/reader-api": "3.0.0-beta.4",
29
+ "@allurereport/core-api": "3.0.0-beta.5",
30
+ "@allurereport/plugin-api": "3.0.0-beta.5",
31
+ "@allurereport/reader-api": "3.0.0-beta.5",
32
32
  "fast-xml-parser": "^4.5.0"
33
33
  },
34
34
  "devDependencies": {