@allurereport/plugin-api 3.21.0 → 3.22.1
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/README.md +4 -0
- package/dist/plugin.d.ts +5 -0
- package/dist/report.d.ts +12 -3
- package/dist/singleFileAssets.d.ts +3 -0
- package/dist/singleFileAssets.js +89 -0
- package/dist/staticAssets.d.ts +1 -0
- package/dist/staticAssets.js +1 -0
- package/dist/utils/report.d.ts +11 -0
- package/dist/utils/report.js +40 -0
- package/package.json +20 -10
package/README.md
CHANGED
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
|
|
17
17
|
The interfaces in the package describe the entities used for building Allure Plugins.
|
|
18
18
|
|
|
19
|
+
## Internal report utilities
|
|
20
|
+
|
|
21
|
+
The `@allurereport/plugin-api/internal/report` subpath is reserved for Allure's bundled report generators and frontends. It is not part of the supported plugin API and may change without a major version bump. Third-party plugins should use the documented API entry points.
|
|
22
|
+
|
|
19
23
|
## Install
|
|
20
24
|
|
|
21
25
|
Use your favorite package manager to install the package:
|
package/dist/plugin.d.ts
CHANGED
|
@@ -42,9 +42,14 @@ export interface TestResultRegistry {
|
|
|
42
42
|
export type SummaryCheckResult = Pick<AllureCheckResult, "id" | "name" | "status">;
|
|
43
43
|
export type { GlobalAttachmentLink } from "@allurereport/core-api";
|
|
44
44
|
export interface PluginSummary {
|
|
45
|
+
published?: boolean;
|
|
45
46
|
href?: string;
|
|
46
47
|
remoteHref?: string;
|
|
47
48
|
jobHref?: string;
|
|
49
|
+
ciRunName?: string;
|
|
50
|
+
ciRunHref?: string;
|
|
51
|
+
commitSha?: string;
|
|
52
|
+
commitHref?: string;
|
|
48
53
|
pullRequestHref?: string;
|
|
49
54
|
name: string;
|
|
50
55
|
stats: Statistic;
|
package/dist/report.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AttachmentTestStepResult, CiDescriptor, DefaultTreeGroup, HistoryTestResult, ResolutionCategory, ResolutionIssue, TestFixtureResult, TestResult, TestStatus, TestStepResult, TreeData, WithChildren } from "@allurereport/core-api";
|
|
1
|
+
import type { AttachmentTestStepResult, CiDescriptor, DefaultTreeGroup, HistoryTestResult, MutedResolutionState, ResolutionCategory, ResolutionIssue, TestFixtureResult, TestResult, TestStatus, TestStepResult, TreeData, WithChildren } from "@allurereport/core-api";
|
|
2
2
|
import type { QualityGateValidationResult } from "./qualityGate.js";
|
|
3
3
|
export type Layout = "base" | "split";
|
|
4
4
|
export type StepTreeExpansion = "collapsed" | "expand_failed_only" | "expanded";
|
|
@@ -17,6 +17,10 @@ export type ReportExecutorInfo = {
|
|
|
17
17
|
reportName?: string;
|
|
18
18
|
reportUrl?: string;
|
|
19
19
|
};
|
|
20
|
+
export type ReportGitInfo = {
|
|
21
|
+
commit: string;
|
|
22
|
+
branch?: string;
|
|
23
|
+
};
|
|
20
24
|
export type ReportOptions = {
|
|
21
25
|
id?: string;
|
|
22
26
|
allureVersion: string;
|
|
@@ -32,6 +36,7 @@ export type ReportOptions = {
|
|
|
32
36
|
sections?: string[];
|
|
33
37
|
cacheKey?: string;
|
|
34
38
|
ci?: CiDescriptor;
|
|
39
|
+
git?: ReportGitInfo;
|
|
35
40
|
executor?: ReportExecutorInfo;
|
|
36
41
|
runSummary?: ReportRunSummary;
|
|
37
42
|
runSummaryByEnv?: Record<string, ReportRunSummary>;
|
|
@@ -60,7 +65,7 @@ export interface ReportCategory {
|
|
|
60
65
|
matchedStatuses?: TestStatus[];
|
|
61
66
|
flaky?: boolean;
|
|
62
67
|
}
|
|
63
|
-
export type ReportTestResult = Omit<TestResult, "runSelector" | "sourceMetadata" | "expectedResult" | "
|
|
68
|
+
export type ReportTestResult = Omit<TestResult, "runSelector" | "sourceMetadata" | "expectedResult" | "precondition" | "steps" | "categories" | "environment"> & {
|
|
64
69
|
isRetry: boolean;
|
|
65
70
|
setup: ReportFixtureResult[];
|
|
66
71
|
teardown: ReportFixtureResult[];
|
|
@@ -78,13 +83,14 @@ export type ReportTestResult = Omit<TestResult, "runSelector" | "sourceMetadata"
|
|
|
78
83
|
categories?: ReportCategory[];
|
|
79
84
|
environment?: string | "default";
|
|
80
85
|
resolutionIssue?: ResolutionIssue;
|
|
86
|
+
resolutionState?: MutedResolutionState;
|
|
81
87
|
tooltips?: Record<string, string>;
|
|
82
88
|
time?: Record<string, string[]>;
|
|
83
89
|
extra?: {
|
|
84
90
|
severity: string;
|
|
85
91
|
};
|
|
86
92
|
};
|
|
87
|
-
export type ReportTreeLeaf = Pick<ReportTestResult, "duration" | "name" | "start" | "status" | "groupOrder" | "flaky" | "transition" | "retry" | "retriesCount" | "retriesStatusChange" | "resolution"> & {
|
|
93
|
+
export type ReportTreeLeaf = Pick<ReportTestResult, "duration" | "name" | "start" | "status" | "groupOrder" | "flaky" | "transition" | "retry" | "retriesCount" | "retriesStatusChange" | "resolution" | "resolutionExpiresAt"> & {
|
|
88
94
|
nodeId: string;
|
|
89
95
|
id?: string;
|
|
90
96
|
transitionTooltip?: string;
|
|
@@ -93,6 +99,7 @@ export type ReportTreeLeaf = Pick<ReportTestResult, "duration" | "name" | "start
|
|
|
93
99
|
categories?: string[];
|
|
94
100
|
severity?: string;
|
|
95
101
|
resolutionStatus?: ResolutionCategory | "none";
|
|
102
|
+
resolutionState?: MutedResolutionState;
|
|
96
103
|
parameters?: string[];
|
|
97
104
|
};
|
|
98
105
|
export type ReportTreeGroup = WithChildren & DefaultTreeGroup & {
|
|
@@ -126,6 +133,8 @@ export type ReportResolutionGroup = {
|
|
|
126
133
|
resolution: ResolutionCategory;
|
|
127
134
|
name: string;
|
|
128
135
|
comment?: string;
|
|
136
|
+
expiresAt?: string;
|
|
137
|
+
resolutionState?: MutedResolutionState;
|
|
129
138
|
issue?: ResolutionIssue;
|
|
130
139
|
testResults: ReportResolutionTestResult[];
|
|
131
140
|
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { gzipSync } from "node:zlib";
|
|
2
|
+
import { stringifyForInlineScript } from "@allurereport/core-api";
|
|
3
|
+
const embeddedAssetsElementId = "allure-single-file-assets";
|
|
4
|
+
export const createSingleFileScripts = (files, mainJs, { compress = true } = {}) => {
|
|
5
|
+
const encodedScripts = Object.fromEntries([...files]
|
|
6
|
+
.filter(([fileName]) => fileName.endsWith(".js"))
|
|
7
|
+
.map(([fileName, content]) => [
|
|
8
|
+
fileName,
|
|
9
|
+
(compress ? gzipSync(content, { level: 9 }) : content).toString("base64"),
|
|
10
|
+
]));
|
|
11
|
+
const licenses = Object.fromEntries([...files]
|
|
12
|
+
.filter(([fileName]) => fileName.endsWith(".LICENSE.txt"))
|
|
13
|
+
.map(([fileName, content]) => [fileName, content.toString("utf8")]));
|
|
14
|
+
if (!encodedScripts[mainJs]) {
|
|
15
|
+
throw new Error(`The report static assets do not contain the main script: ${mainJs}`);
|
|
16
|
+
}
|
|
17
|
+
return `
|
|
18
|
+
<script id="allure-single-file-licenses" type="application/json">${stringifyForInlineScript(licenses)}</script>
|
|
19
|
+
<script id="${embeddedAssetsElementId}" type="application/json">${stringifyForInlineScript(encodedScripts)}</script>
|
|
20
|
+
<script>
|
|
21
|
+
(function () {
|
|
22
|
+
const assetsElement = document.getElementById(${stringifyForInlineScript(embeddedAssetsElementId)});
|
|
23
|
+
const assets = JSON.parse(assetsElement.textContent || "{}");
|
|
24
|
+
const appendChild = document.head.appendChild;
|
|
25
|
+
|
|
26
|
+
assetsElement.remove();
|
|
27
|
+
|
|
28
|
+
function embeddedAssetName(script) {
|
|
29
|
+
const source = script.getAttribute("src");
|
|
30
|
+
|
|
31
|
+
if (!source) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const path = source.split(/[?#]/, 1)[0];
|
|
36
|
+
|
|
37
|
+
return path.slice(path.lastIndexOf("/") + 1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function decodeAsset(encoded) {
|
|
41
|
+
const binary = atob(encoded);
|
|
42
|
+
const bytes = new Uint8Array(binary.length);
|
|
43
|
+
|
|
44
|
+
for (let index = 0; index < binary.length; index++) {
|
|
45
|
+
bytes[index] = binary.charCodeAt(index);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
${compress
|
|
49
|
+
? `const stream = new Response(bytes).body.pipeThrough(new DecompressionStream("gzip"));
|
|
50
|
+
return new Response(stream).text();`
|
|
51
|
+
: "return new Response(bytes).text();"}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
document.head.appendChild = function (node) {
|
|
55
|
+
if (node.tagName !== "SCRIPT") {
|
|
56
|
+
return appendChild.call(this, node);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const fileName = embeddedAssetName(node);
|
|
60
|
+
const encoded = fileName && Object.hasOwn(assets, fileName) ? assets[fileName] : undefined;
|
|
61
|
+
|
|
62
|
+
if (!encoded) {
|
|
63
|
+
return appendChild.call(this, node);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
void decodeAsset(encoded)
|
|
67
|
+
.then(function (source) {
|
|
68
|
+
node.removeAttribute("src");
|
|
69
|
+
node.text = source;
|
|
70
|
+
delete assets[fileName];
|
|
71
|
+
appendChild.call(document.head, node);
|
|
72
|
+
node.dispatchEvent(new Event("load"));
|
|
73
|
+
})
|
|
74
|
+
.catch(function (error) {
|
|
75
|
+
console.error("Failed to load embedded report asset " + fileName, error);
|
|
76
|
+
node.dispatchEvent(new Event("error"));
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return node;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const mainScript = document.createElement("script");
|
|
83
|
+
|
|
84
|
+
mainScript.src = ${stringifyForInlineScript(mainJs)};
|
|
85
|
+
document.head.appendChild(mainScript);
|
|
86
|
+
})();
|
|
87
|
+
</script>
|
|
88
|
+
`;
|
|
89
|
+
};
|
package/dist/staticAssets.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export type ReportStaticAssets = {
|
|
|
7
7
|
export declare const readReportStaticAssets: (archive: string | URL) => Promise<ReportStaticAssets>;
|
|
8
8
|
export declare const getReportStaticAsset: (assets: ReportStaticAssets, fileName: string) => Buffer;
|
|
9
9
|
export declare const copyReportStaticAssets: (assets: ReportStaticAssets, reportFiles: ReportFiles) => Promise<void>;
|
|
10
|
+
export { createSingleFileScripts } from "./singleFileAssets.js";
|
package/dist/staticAssets.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type HistoryDataPoint, type TestFixtureResult, type TestStepResult } from "@allurereport/core-api";
|
|
2
|
+
import type { ReportFixtureResult, ReportTestStepResult } from "../report.js";
|
|
3
|
+
import type { AllureStore } from "../store.js";
|
|
4
|
+
export declare const HISTORY_DATA_POINT_LIMIT = 6;
|
|
5
|
+
export declare const writeConcurrently: <T>(items: readonly T[], write: (item: T) => Promise<void>, concurrency?: number) => Promise<void>;
|
|
6
|
+
export declare const mapConcurrently: <T, R>(items: readonly T[], map: (item: T) => Promise<R>, concurrency?: number) => Promise<R[]>;
|
|
7
|
+
export declare const convertTestStepResult: (tsr: TestStepResult) => ReportTestStepResult;
|
|
8
|
+
export declare const convertFixtureResult: (fr: TestFixtureResult) => ReportFixtureResult;
|
|
9
|
+
export declare const generateHistoryDataPoints: (writer: {
|
|
10
|
+
writeData: (fileName: string, data: HistoryDataPoint) => Promise<void>;
|
|
11
|
+
}, store: Pick<AllureStore, "allHistoryDataPoints">) => Promise<void>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isStep, redactParameters, } from "@allurereport/core-api";
|
|
2
|
+
export const HISTORY_DATA_POINT_LIMIT = 6;
|
|
3
|
+
export const writeConcurrently = async (items, write, concurrency = 64) => {
|
|
4
|
+
for (let i = 0; i < items.length; i += concurrency) {
|
|
5
|
+
await Promise.all(items.slice(i, i + concurrency).map(write));
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
export const mapConcurrently = async (items, map, concurrency = 8) => {
|
|
9
|
+
const results = [];
|
|
10
|
+
for (let i = 0; i < items.length; i += concurrency) {
|
|
11
|
+
results.push(...(await Promise.all(items.slice(i, i + concurrency).map(map))));
|
|
12
|
+
}
|
|
13
|
+
return results;
|
|
14
|
+
};
|
|
15
|
+
export const convertTestStepResult = (tsr) => {
|
|
16
|
+
if (isStep(tsr)) {
|
|
17
|
+
return {
|
|
18
|
+
...tsr,
|
|
19
|
+
parameters: redactParameters(tsr.parameters),
|
|
20
|
+
steps: (tsr.steps ?? []).map(convertTestStepResult),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return tsr;
|
|
24
|
+
};
|
|
25
|
+
export const convertFixtureResult = (fr) => {
|
|
26
|
+
return {
|
|
27
|
+
id: fr.id,
|
|
28
|
+
type: fr.type,
|
|
29
|
+
name: fr.name,
|
|
30
|
+
status: fr.status,
|
|
31
|
+
steps: fr.steps.map(convertTestStepResult),
|
|
32
|
+
duration: fr.duration,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export const generateHistoryDataPoints = async (writer, store) => {
|
|
36
|
+
const allHistoryPoints = await store.allHistoryDataPoints();
|
|
37
|
+
for (const historyPoint of allHistoryPoints.slice(0, HISTORY_DATA_POINT_LIMIT)) {
|
|
38
|
+
await writer.writeData(`history/${historyPoint.uuid}.json`, historyPoint);
|
|
39
|
+
}
|
|
40
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/plugin-api",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.22.1",
|
|
4
4
|
"description": "Allure Plugin API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure"
|
|
@@ -17,33 +17,43 @@
|
|
|
17
17
|
"main": "./dist/index.js",
|
|
18
18
|
"module": "./dist/index.js",
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
|
+
"typesVersions": {
|
|
21
|
+
"*": {
|
|
22
|
+
"internal/report": [
|
|
23
|
+
"dist/utils/report.d.ts"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
20
27
|
"exports": {
|
|
21
28
|
".": "./dist/index.js",
|
|
22
|
-
"./static-assets": "./dist/staticAssets.js"
|
|
29
|
+
"./static-assets": "./dist/staticAssets.js",
|
|
30
|
+
"./internal/report": "./dist/utils/report.js"
|
|
23
31
|
},
|
|
24
32
|
"scripts": {
|
|
25
33
|
"build": "run clean && tsc --project ./tsconfig.json",
|
|
26
34
|
"clean": "rimraf ./dist",
|
|
27
|
-
"test": "rimraf
|
|
35
|
+
"test": "rimraf out && vp test run",
|
|
28
36
|
"test:unit": "yarn test",
|
|
29
|
-
"lint": "
|
|
30
|
-
"lint:fix": "
|
|
37
|
+
"lint": "vp lint --import-plugin src test features stories",
|
|
38
|
+
"lint:fix": "vp lint --import-plugin --fix src test features stories"
|
|
31
39
|
},
|
|
32
40
|
"dependencies": {
|
|
33
|
-
"@allurereport/core-api": "3.
|
|
41
|
+
"@allurereport/core-api": "3.22.1",
|
|
34
42
|
"tar-stream": "3.1.7"
|
|
35
43
|
},
|
|
36
44
|
"devDependencies": {
|
|
37
|
-
"@allurereport/
|
|
45
|
+
"@allurereport/common-config": "3.22.1",
|
|
38
46
|
"@types/node": "^20",
|
|
39
47
|
"@types/tar-stream": "^3.1.4",
|
|
40
|
-
"@vitest/coverage-istanbul": "
|
|
48
|
+
"@vitest/coverage-istanbul": "5.0.4",
|
|
41
49
|
"@vitest/runner": "^2",
|
|
42
|
-
"@vitest/snapshot": "
|
|
50
|
+
"@vitest/snapshot": "5.0.4",
|
|
43
51
|
"allure-js-commons": "^3",
|
|
44
52
|
"allure-vitest": "^3",
|
|
45
53
|
"rimraf": "^6",
|
|
46
54
|
"typescript": "^5",
|
|
47
|
-
"
|
|
55
|
+
"vite": "@voidzero-dev/vite-plus-core@1.2.0",
|
|
56
|
+
"vite-plus": "1.2.0",
|
|
57
|
+
"vitest": "5.0.4"
|
|
48
58
|
}
|
|
49
59
|
}
|