@allurereport/core-api 3.0.0-beta.8 → 3.0.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/aggregate.d.ts +9 -1
- package/dist/ci.d.ts +25 -0
- package/dist/ci.js +12 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +1 -0
- package/dist/constants.d.ts +4 -2
- package/dist/constants.js +2 -0
- package/dist/environment.d.ts +10 -0
- package/dist/history.d.ts +11 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/dist/model.d.ts +21 -0
- package/dist/static.d.ts +12 -0
- package/dist/static.js +55 -0
- package/dist/utils/environment.d.ts +5 -0
- package/dist/utils/environment.js +12 -0
- package/dist/utils/history.d.ts +3 -0
- package/dist/utils/history.js +22 -0
- package/dist/utils/status.d.ts +4 -0
- package/dist/utils/status.js +13 -0
- package/dist/utils/strings.d.ts +1 -0
- package/dist/utils/strings.js +6 -0
- package/package.json +9 -4
package/dist/aggregate.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type DiffStatistic = {
|
|
2
|
+
regressed?: number;
|
|
3
|
+
fixed?: number;
|
|
4
|
+
malfunctioned?: number;
|
|
5
|
+
new?: number;
|
|
6
|
+
};
|
|
7
|
+
export type Statistic = DiffStatistic & {
|
|
2
8
|
failed?: number;
|
|
3
9
|
broken?: number;
|
|
4
10
|
passed?: number;
|
|
5
11
|
skipped?: number;
|
|
6
12
|
unknown?: number;
|
|
7
13
|
total: number;
|
|
14
|
+
retries?: number;
|
|
15
|
+
flaky?: number;
|
|
8
16
|
};
|
package/dist/ci.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare enum CiType {
|
|
2
|
+
Amazon = "amazon",
|
|
3
|
+
Azure = "azure",
|
|
4
|
+
Bitbucket = "bitbucket",
|
|
5
|
+
Circle = "circle",
|
|
6
|
+
Drone = "drone",
|
|
7
|
+
Github = "github",
|
|
8
|
+
Gitlab = "gitlab",
|
|
9
|
+
Jenkins = "jenkins",
|
|
10
|
+
Local = "local"
|
|
11
|
+
}
|
|
12
|
+
export interface CiDescriptor {
|
|
13
|
+
type: CiType;
|
|
14
|
+
detected: boolean;
|
|
15
|
+
repoName: string;
|
|
16
|
+
jobUid: string;
|
|
17
|
+
jobUrl: string;
|
|
18
|
+
jobName: string;
|
|
19
|
+
jobRunUid: string;
|
|
20
|
+
jobRunUrl: string;
|
|
21
|
+
jobRunName: string;
|
|
22
|
+
jobRunBranch: string;
|
|
23
|
+
pullRequestName: string;
|
|
24
|
+
pullRequestUrl: string;
|
|
25
|
+
}
|
package/dist/ci.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var CiType;
|
|
2
|
+
(function (CiType) {
|
|
3
|
+
CiType["Amazon"] = "amazon";
|
|
4
|
+
CiType["Azure"] = "azure";
|
|
5
|
+
CiType["Bitbucket"] = "bitbucket";
|
|
6
|
+
CiType["Circle"] = "circle";
|
|
7
|
+
CiType["Drone"] = "drone";
|
|
8
|
+
CiType["Github"] = "github";
|
|
9
|
+
CiType["Gitlab"] = "gitlab";
|
|
10
|
+
CiType["Jenkins"] = "jenkins";
|
|
11
|
+
CiType["Local"] = "local";
|
|
12
|
+
})(CiType || (CiType = {}));
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type DefaultLabelsConfig = Record<string, string | string[]>;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Statistic } from "./aggregate.js";
|
|
2
|
-
import type { TestStatus } from "./model.js";
|
|
3
|
-
export declare const statusesList: TestStatus[];
|
|
2
|
+
import type { SeverityLevel, TestStatus } from "./model.js";
|
|
3
|
+
export declare const statusesList: readonly TestStatus[];
|
|
4
|
+
export declare const severityLevels: readonly SeverityLevel[];
|
|
5
|
+
export declare const severityLabelName = "severity";
|
|
4
6
|
export declare const unsuccessfulStatuses: Set<TestStatus>;
|
|
5
7
|
export declare const successfulStatuses: Set<TestStatus>;
|
|
6
8
|
export declare const includedInSuccessRate: Set<TestStatus>;
|
package/dist/constants.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export const statusesList = ["failed", "broken", "passed", "skipped", "unknown"];
|
|
2
|
+
export const severityLevels = ["blocker", "critical", "normal", "minor", "trivial"];
|
|
3
|
+
export const severityLabelName = "severity";
|
|
2
4
|
export const unsuccessfulStatuses = new Set(["failed", "broken"]);
|
|
3
5
|
export const successfulStatuses = new Set(["passed"]);
|
|
4
6
|
export const includedInSuccessRate = new Set([...unsuccessfulStatuses, ...successfulStatuses]);
|
package/dist/environment.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
+
import type { TestLabel } from "./metadata.js";
|
|
1
2
|
export interface EnvironmentItem {
|
|
2
3
|
name: string;
|
|
3
4
|
values: string[];
|
|
4
5
|
}
|
|
6
|
+
export type ReportVariables = Record<string, string>;
|
|
7
|
+
export type EnvironmentMatcherPayload = {
|
|
8
|
+
labels: TestLabel[];
|
|
9
|
+
};
|
|
10
|
+
export type EnvironmentDescriptor = {
|
|
11
|
+
variables?: ReportVariables;
|
|
12
|
+
matcher: (payload: EnvironmentMatcherPayload) => boolean;
|
|
13
|
+
};
|
|
14
|
+
export type EnvironmentsConfig = Record<string, EnvironmentDescriptor>;
|
package/dist/history.d.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
import type { TestLabel } from "./metadata.js";
|
|
1
2
|
import type { TestError, TestStatus } from "./model.js";
|
|
2
3
|
export interface HistoryTestResult {
|
|
3
4
|
id: string;
|
|
4
5
|
name: string;
|
|
5
6
|
fullName?: string;
|
|
7
|
+
environment?: string;
|
|
6
8
|
status: TestStatus;
|
|
7
9
|
error?: TestError;
|
|
8
10
|
start?: number;
|
|
9
11
|
stop?: number;
|
|
10
12
|
duration?: number;
|
|
13
|
+
labels?: TestLabel[];
|
|
14
|
+
url: string;
|
|
15
|
+
historyId?: string;
|
|
16
|
+
reportLinks?: any[];
|
|
11
17
|
}
|
|
12
18
|
export interface HistoryDataPoint {
|
|
13
19
|
uuid: string;
|
|
@@ -16,4 +22,9 @@ export interface HistoryDataPoint {
|
|
|
16
22
|
knownTestCaseIds: string[];
|
|
17
23
|
testResults: Record<string, HistoryTestResult>;
|
|
18
24
|
metrics: Record<string, number>;
|
|
25
|
+
url: string;
|
|
26
|
+
}
|
|
27
|
+
export interface AllureHistory {
|
|
28
|
+
readHistory(branch?: string): Promise<HistoryDataPoint[]>;
|
|
29
|
+
appendHistory(history: HistoryDataPoint, branch?: string): Promise<void>;
|
|
19
30
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type * from "./aggregate.js";
|
|
2
2
|
export * from "./constants.js";
|
|
3
|
+
export * from "./ci.js";
|
|
3
4
|
export type * from "./environment.js";
|
|
4
5
|
export type * from "./history.js";
|
|
5
6
|
export type * from "./known.js";
|
|
@@ -7,6 +8,8 @@ export type * from "./metadata.js";
|
|
|
7
8
|
export type * from "./model.js";
|
|
8
9
|
export type * from "./testCase.js";
|
|
9
10
|
export type * from "./testPlan.js";
|
|
11
|
+
export type * from "./config.js";
|
|
12
|
+
export * from "./static.js";
|
|
10
13
|
export * from "./utils/step.js";
|
|
11
14
|
export type * from "./utils/tree.js";
|
|
12
15
|
export * from "./utils/time.js";
|
|
@@ -14,3 +17,7 @@ export * from "./utils/comparator.js";
|
|
|
14
17
|
export * from "./utils/predicate.js";
|
|
15
18
|
export * from "./utils/label.js";
|
|
16
19
|
export * from "./utils/testplan.js";
|
|
20
|
+
export * from "./utils/status.js";
|
|
21
|
+
export * from "./utils/environment.js";
|
|
22
|
+
export * from "./utils/history.js";
|
|
23
|
+
export * from "./utils/strings.js";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
export * from "./constants.js";
|
|
2
|
+
export * from "./ci.js";
|
|
3
|
+
export * from "./static.js";
|
|
2
4
|
export * from "./utils/step.js";
|
|
3
5
|
export * from "./utils/time.js";
|
|
4
6
|
export * from "./utils/comparator.js";
|
|
5
7
|
export * from "./utils/predicate.js";
|
|
6
8
|
export * from "./utils/label.js";
|
|
7
9
|
export * from "./utils/testplan.js";
|
|
10
|
+
export * from "./utils/status.js";
|
|
11
|
+
export * from "./utils/environment.js";
|
|
12
|
+
export * from "./utils/history.js";
|
|
13
|
+
export * from "./utils/strings.js";
|
package/dist/model.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { TestLabel, TestLink, TestParameter } from "./metadata.js";
|
|
2
2
|
import type { TestCase } from "./testCase.js";
|
|
3
3
|
export type TestStatus = "failed" | "broken" | "passed" | "skipped" | "unknown";
|
|
4
|
+
export type TestStatusTransition = "regressed" | "fixed" | "malfunctioned" | "new";
|
|
5
|
+
export type SeverityLevel = "blocker" | "critical" | "normal" | "minor" | "trivial";
|
|
4
6
|
export interface SourceMetadata {
|
|
5
7
|
readerId: string;
|
|
6
8
|
metadata: {
|
|
@@ -19,6 +21,7 @@ export interface TestResult {
|
|
|
19
21
|
status: TestStatus;
|
|
20
22
|
error?: TestError;
|
|
21
23
|
testCase?: TestCase;
|
|
24
|
+
environment?: string;
|
|
22
25
|
fullName?: string;
|
|
23
26
|
historyId?: string;
|
|
24
27
|
description?: string;
|
|
@@ -33,6 +36,7 @@ export interface TestResult {
|
|
|
33
36
|
flaky: boolean;
|
|
34
37
|
muted: boolean;
|
|
35
38
|
known: boolean;
|
|
39
|
+
transition?: TestStatusTransition;
|
|
36
40
|
hidden: boolean;
|
|
37
41
|
hostId?: string;
|
|
38
42
|
threadId?: string;
|
|
@@ -43,6 +47,15 @@ export interface TestResult {
|
|
|
43
47
|
sourceMetadata: SourceMetadata;
|
|
44
48
|
runSelector?: string;
|
|
45
49
|
retries?: TestResult[];
|
|
50
|
+
categories?: any;
|
|
51
|
+
titlePath?: string[];
|
|
52
|
+
}
|
|
53
|
+
export interface TestEnvGroup {
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
fullName?: string;
|
|
57
|
+
status: TestStatus;
|
|
58
|
+
testResultsByEnv: Record<string, string>;
|
|
46
59
|
}
|
|
47
60
|
export interface TestFixtureResult {
|
|
48
61
|
id: string;
|
|
@@ -67,7 +80,11 @@ export interface DefaultTestStepResult {
|
|
|
67
80
|
stop?: number;
|
|
68
81
|
duration?: number;
|
|
69
82
|
steps: TestStepResult[];
|
|
83
|
+
stepId?: string;
|
|
70
84
|
type: "step";
|
|
85
|
+
message?: string;
|
|
86
|
+
trace?: string;
|
|
87
|
+
hasSimilarErrorInSubSteps?: boolean;
|
|
71
88
|
}
|
|
72
89
|
export interface AttachmentLinkFile {
|
|
73
90
|
id: string;
|
|
@@ -97,3 +114,7 @@ export interface AttachmentTestStepResult {
|
|
|
97
114
|
link: AttachmentLinkExpected | AttachmentLinkLinked | AttachmentLinkInvalid;
|
|
98
115
|
type: "attachment";
|
|
99
116
|
}
|
|
117
|
+
export interface RepoData {
|
|
118
|
+
name: string;
|
|
119
|
+
branch: string;
|
|
120
|
+
}
|
package/dist/static.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const createScriptTag: (src: string, options?: {
|
|
2
|
+
async?: false;
|
|
3
|
+
defer?: false;
|
|
4
|
+
}) => string;
|
|
5
|
+
export declare const createStylesLinkTag: (src: string) => string;
|
|
6
|
+
export declare const createFontLinkTag: (src: string) => string;
|
|
7
|
+
export declare const createFaviconLinkTag: (src: string) => string;
|
|
8
|
+
export declare const createBaseUrlScript: () => string;
|
|
9
|
+
export declare const createReportDataScript: (reportFiles?: {
|
|
10
|
+
name: string;
|
|
11
|
+
value: string;
|
|
12
|
+
}[]) => string;
|
package/dist/static.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export const createScriptTag = (src, options) => {
|
|
2
|
+
return `<script ${options?.async ? "async" : ""} ${options?.defer ? "defer" : ""} src="${src}"></script>`;
|
|
3
|
+
};
|
|
4
|
+
export const createStylesLinkTag = (src) => {
|
|
5
|
+
return `<link rel="stylesheet" type="text/css" href="${src}">`;
|
|
6
|
+
};
|
|
7
|
+
export const createFontLinkTag = (src) => {
|
|
8
|
+
return `<link rel="preload" href="${src}" as="font" type="font/woff" crossorigin /> `;
|
|
9
|
+
};
|
|
10
|
+
export const createFaviconLinkTag = (src) => {
|
|
11
|
+
return `<link rel="icon" href="${src}">`;
|
|
12
|
+
};
|
|
13
|
+
export const createBaseUrlScript = () => {
|
|
14
|
+
return `
|
|
15
|
+
<script>
|
|
16
|
+
const { origin, pathname } = window.location;
|
|
17
|
+
const url = new URL(pathname, origin);
|
|
18
|
+
const baseEl = document.createElement("base");
|
|
19
|
+
|
|
20
|
+
baseEl.href = url.toString();
|
|
21
|
+
|
|
22
|
+
window.document.head.appendChild(baseEl);
|
|
23
|
+
</script>
|
|
24
|
+
`;
|
|
25
|
+
};
|
|
26
|
+
export const createReportDataScript = (reportFiles = []) => {
|
|
27
|
+
if (!reportFiles?.length) {
|
|
28
|
+
return `
|
|
29
|
+
<script async>
|
|
30
|
+
window.allureReportDataReady = true;
|
|
31
|
+
</script>
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
const reportFilesDeclaration = reportFiles.map(({ name, value }) => `d('${name}','${value}')`).join(",");
|
|
35
|
+
return `
|
|
36
|
+
<script async>
|
|
37
|
+
window.allureReportDataReady = false;
|
|
38
|
+
window.allureReportData = window.allureReportData || {};
|
|
39
|
+
|
|
40
|
+
function d(name, value){
|
|
41
|
+
return new Promise(function (resolve) {
|
|
42
|
+
window.allureReportData[name] = value;
|
|
43
|
+
|
|
44
|
+
return resolve(true);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
<script defer>
|
|
49
|
+
Promise.allSettled([${reportFilesDeclaration}])
|
|
50
|
+
.then(function(){
|
|
51
|
+
window.allureReportDataReady = true;
|
|
52
|
+
})
|
|
53
|
+
</script>
|
|
54
|
+
`;
|
|
55
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { EnvironmentsConfig } from "../environment.js";
|
|
2
|
+
import type { TestEnvGroup, TestResult } from "../model.js";
|
|
3
|
+
export declare const DEFAULT_ENVIRONMENT = "default";
|
|
4
|
+
export declare const matchEnvironment: (envConfig: EnvironmentsConfig, tr: Pick<TestResult, "labels">) => string;
|
|
5
|
+
export declare const getRealEnvsCount: (group: TestEnvGroup) => number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const DEFAULT_ENVIRONMENT = "default";
|
|
2
|
+
export const matchEnvironment = (envConfig, tr) => {
|
|
3
|
+
return (Object.entries(envConfig).find(([, { matcher }]) => matcher({ labels: tr.labels }))?.[0] ?? DEFAULT_ENVIRONMENT);
|
|
4
|
+
};
|
|
5
|
+
export const getRealEnvsCount = (group) => {
|
|
6
|
+
const { testResultsByEnv = {} } = group ?? {};
|
|
7
|
+
const envsCount = Object.keys(testResultsByEnv).length ?? 0;
|
|
8
|
+
if (envsCount <= 1 && DEFAULT_ENVIRONMENT in testResultsByEnv) {
|
|
9
|
+
return 0;
|
|
10
|
+
}
|
|
11
|
+
return envsCount;
|
|
12
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const htrsByTr = (hdps, tr) => {
|
|
2
|
+
if (!tr?.historyId) {
|
|
3
|
+
return [];
|
|
4
|
+
}
|
|
5
|
+
return hdps.reduce((acc, dp) => {
|
|
6
|
+
const htr = dp.testResults[tr.historyId];
|
|
7
|
+
if (htr) {
|
|
8
|
+
if (dp.url) {
|
|
9
|
+
const url = new URL(dp.url);
|
|
10
|
+
url.hash = tr.id;
|
|
11
|
+
acc.push({
|
|
12
|
+
...htr,
|
|
13
|
+
url: url.toString(),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
acc.push(htr);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return acc;
|
|
21
|
+
}, []);
|
|
22
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TestStatus } from "../model.js";
|
|
2
|
+
export declare const StatusByPriority: TestStatus[];
|
|
3
|
+
export declare const statusToPriority: (status: TestStatus | undefined) => number;
|
|
4
|
+
export declare const getWorstStatus: (items: TestStatus[]) => TestStatus | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const StatusByPriority = ["failed", "broken", "passed", "skipped", "unknown"];
|
|
2
|
+
export const statusToPriority = (status) => {
|
|
3
|
+
if (!status) {
|
|
4
|
+
return -1;
|
|
5
|
+
}
|
|
6
|
+
return StatusByPriority.indexOf(status);
|
|
7
|
+
};
|
|
8
|
+
export const getWorstStatus = (items) => {
|
|
9
|
+
if (items.length === 0) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return items.sort((a, b) => statusToPriority(a) - statusToPriority(b))[0];
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const capitalize: <T extends string>(str: T) => Capitalize<T> | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/core-api",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Allure Core API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure"
|
|
@@ -25,14 +25,19 @@
|
|
|
25
25
|
"eslint:format": "eslint --fix ./src/**/*.{js,jsx,ts,tsx}",
|
|
26
26
|
"test": "rimraf ./out && vitest run"
|
|
27
27
|
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"d3-shape": "^3.2.0"
|
|
30
|
+
},
|
|
28
31
|
"devDependencies": {
|
|
29
32
|
"@stylistic/eslint-plugin": "^2.6.1",
|
|
33
|
+
"@types/d3-shape": "^3.1.6",
|
|
30
34
|
"@types/eslint": "^8.56.11",
|
|
31
35
|
"@types/node": "^20.17.9",
|
|
32
36
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
33
37
|
"@typescript-eslint/parser": "^8.0.0",
|
|
34
|
-
"@vitest/runner": "^2.1.
|
|
35
|
-
"
|
|
38
|
+
"@vitest/runner": "^2.1.9",
|
|
39
|
+
"@vitest/snapshot": "^2.1.9",
|
|
40
|
+
"allure-vitest": "^3.3.3",
|
|
36
41
|
"eslint": "^8.57.0",
|
|
37
42
|
"eslint-config-prettier": "^9.1.0",
|
|
38
43
|
"eslint-plugin-import": "^2.29.1",
|
|
@@ -42,6 +47,6 @@
|
|
|
42
47
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
43
48
|
"rimraf": "^6.0.1",
|
|
44
49
|
"typescript": "^5.6.3",
|
|
45
|
-
"vitest": "^2.1.
|
|
50
|
+
"vitest": "^2.1.9"
|
|
46
51
|
}
|
|
47
52
|
}
|