@allurereport/core-api 3.20.0 → 3.21.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.
@@ -12,6 +12,7 @@ export type Statistic = DiffStatistic & {
12
12
  unknown?: number;
13
13
  total: number;
14
14
  retries?: number;
15
+ retriesStatusChange?: number;
15
16
  flaky?: number;
16
17
  resolutions?: {
17
18
  issues?: number;
@@ -84,6 +84,7 @@ export type CategoryNodeItem = {
84
84
  value?: string;
85
85
  retryHash?: string;
86
86
  retriesCount?: number;
87
+ retriesStatusChange?: boolean;
87
88
  transition?: TestStatusTransition;
88
89
  tooltips?: Record<string, string>;
89
90
  statistic?: Statistic;
package/dist/history.d.ts CHANGED
@@ -6,6 +6,7 @@ export interface HistoryTestResult {
6
6
  fullName?: string;
7
7
  environment?: string;
8
8
  status: TestStatus;
9
+ retries?: TestStatus[];
9
10
  error?: TestError;
10
11
  start?: number;
11
12
  stop?: number;
package/dist/static.d.ts CHANGED
@@ -11,6 +11,11 @@ export declare const appLoaderStyles = "\n <style>\n .allure-app-loader {\n
11
11
  export declare const createAppLoaderMarkup: () => string;
12
12
  export declare const createBaseUrlScript: () => string;
13
13
  export declare const stringifyForInlineScript: (value: unknown) => string;
14
+ export declare const reportDataScriptPlaceholder = "<!-- allure-report-data -->";
15
+ export declare const injectReportDataScript: (html: string, reportFiles?: {
16
+ name: string;
17
+ value: string;
18
+ }[]) => Buffer;
14
19
  export declare const createReportDataScript: (reportFiles?: {
15
20
  name: string;
16
21
  value: string;
package/dist/static.js CHANGED
@@ -90,6 +90,58 @@ export const stringifyForInlineScript = (value) => {
90
90
  .replaceAll("\u2028", "\\u2028")
91
91
  .replaceAll("\u2029", "\\u2029");
92
92
  };
93
+ export const reportDataScriptPlaceholder = "<!-- allure-report-data -->";
94
+ const createReportDataScriptChunks = (reportFiles = []) => {
95
+ if (!reportFiles.length) {
96
+ return [
97
+ Buffer.from(`
98
+ <script async>
99
+ window.allureReportDataReady = true;
100
+ </script>
101
+ `),
102
+ ];
103
+ }
104
+ const chunks = [
105
+ Buffer.from(`
106
+ <script async>
107
+ window.allureReportDataReady = false;
108
+ window.allureReportData = window.allureReportData || {};
109
+
110
+ function d(name, value){
111
+ return new Promise(function (resolve) {
112
+ window.allureReportData[name] = value;
113
+
114
+ return resolve(true);
115
+ });
116
+ }
117
+ </script>
118
+ <script defer>
119
+ Promise.allSettled([`),
120
+ ];
121
+ reportFiles.forEach(({ name, value }, index) => {
122
+ chunks.push(Buffer.from(`${index === 0 ? "" : ","}d(${stringifyForInlineScript(name)},${stringifyForInlineScript(value)})`));
123
+ });
124
+ chunks.push(Buffer.from(`])
125
+ .then(function(){
126
+ window.allureReportDataReady = true;
127
+ })
128
+ </script>
129
+ `));
130
+ return chunks;
131
+ };
132
+ export const injectReportDataScript = (html, reportFiles = []) => {
133
+ const placeholderIndex = html.indexOf(reportDataScriptPlaceholder);
134
+ if (placeholderIndex === -1) {
135
+ throw new Error("Report data script placeholder is missing from the HTML template");
136
+ }
137
+ const prefix = html.slice(0, placeholderIndex);
138
+ const suffix = html.slice(placeholderIndex + reportDataScriptPlaceholder.length);
139
+ return Buffer.concat([
140
+ Buffer.from(prefix, "utf8"),
141
+ ...createReportDataScriptChunks(reportFiles),
142
+ Buffer.from(suffix, "utf8"),
143
+ ]);
144
+ };
93
145
  export const createReportDataScript = (reportFiles = []) => {
94
146
  if (!reportFiles?.length) {
95
147
  return `
@@ -99,7 +151,7 @@ export const createReportDataScript = (reportFiles = []) => {
99
151
  `;
100
152
  }
101
153
  const reportFilesDeclaration = reportFiles
102
- .map(({ name, value }) => `d(${JSON.stringify(name)},${JSON.stringify(value)})`)
154
+ .map(({ name, value }) => `d(${stringifyForInlineScript(name)},${stringifyForInlineScript(value)})`)
103
155
  .join(",");
104
156
  return `
105
157
  <script async>
@@ -1,4 +1,5 @@
1
- import type { TestStatus } from "../model.js";
1
+ import type { TestResult, TestStatus } from "../model.js";
2
2
  export declare const StatusByPriority: TestStatus[];
3
3
  export declare const statusToPriority: (status: TestStatus | undefined) => number;
4
4
  export declare const getWorstStatus: (items: TestStatus[]) => TestStatus | undefined;
5
+ export declare const hasRetriesStatusChange: (current: Pick<TestResult, "status">, retries: readonly Pick<TestResult, "status">[]) => boolean;
@@ -1,3 +1,4 @@
1
+ const retryStatusChangeStatuses = new Set(["failed", "broken", "passed"]);
1
2
  export const StatusByPriority = ["failed", "broken", "passed", "skipped", "unknown"];
2
3
  export const statusToPriority = (status) => {
3
4
  if (!status) {
@@ -11,3 +12,5 @@ export const getWorstStatus = (items) => {
11
12
  }
12
13
  return items.sort((a, b) => statusToPriority(a) - statusToPriority(b))[0];
13
14
  };
15
+ export const hasRetriesStatusChange = (current, retries) => retryStatusChangeStatuses.has(current.status) &&
16
+ retries.some(({ status }) => retryStatusChangeStatuses.has(status) && status !== current.status);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/core-api",
3
- "version": "3.20.0",
3
+ "version": "3.21.0",
4
4
  "description": "Allure Core API",
5
5
  "keywords": [
6
6
  "allure"
@@ -22,6 +22,7 @@
22
22
  "build": "run clean && tsc --project ./tsconfig.json",
23
23
  "clean": "rimraf ./dist",
24
24
  "test": "rimraf ./out && vitest run",
25
+ "test:unit": "yarn test",
25
26
  "lint": "oxlint --import-plugin src test features stories",
26
27
  "lint:fix": "oxlint --import-plugin --fix src test features stories"
27
28
  },
@@ -29,8 +30,10 @@
29
30
  "d3-shape": "^3.2.0"
30
31
  },
31
32
  "devDependencies": {
33
+ "@allurereport/test-config": "3.21.0",
32
34
  "@types/d3-shape": "^3.1.8",
33
35
  "@types/node": "^20",
36
+ "@vitest/coverage-istanbul": "^4.1.0",
34
37
  "@vitest/runner": "^2",
35
38
  "@vitest/snapshot": "^5.0.1",
36
39
  "allure-js-commons": "^3",