@allurereport/plugin-testops 3.3.1 → 3.4.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 +8 -7
- package/dist/client.d.ts +38 -11
- package/dist/client.js +318 -67
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/logger.d.ts +24 -0
- package/dist/logger.js +129 -0
- package/dist/model.d.ts +80 -4
- package/dist/plugin.d.ts +9 -9
- package/dist/plugin.js +329 -101
- package/dist/uploadCategory.d.ts +3 -0
- package/dist/uploadCategory.js +20 -0
- package/dist/utils/categories.d.ts +4 -0
- package/dist/utils/categories.js +82 -0
- package/dist/utils.d.ts +5 -2
- package/dist/utils.js +34 -1
- package/package.json +22 -33
package/dist/logger.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _Logger_instances, _Logger_level, _Logger_isLogLevel, _Logger_prefix;
|
|
7
|
+
import console from "node:console";
|
|
8
|
+
import { env } from "node:process";
|
|
9
|
+
import { inspect } from "node:util";
|
|
10
|
+
import ProgressBar from "progress";
|
|
11
|
+
import { blue, bold, cyan, dim, gray, red, yellow } from "yoctocolors";
|
|
12
|
+
const logLevelsPriority = {
|
|
13
|
+
silent: Number.MAX_SAFE_INTEGER,
|
|
14
|
+
verbose: 0,
|
|
15
|
+
debug: 1,
|
|
16
|
+
info: 2,
|
|
17
|
+
warn: 3,
|
|
18
|
+
error: 4,
|
|
19
|
+
};
|
|
20
|
+
function getLogLevelFromEnv() {
|
|
21
|
+
if (env.LOG_LEVEL) {
|
|
22
|
+
return env.LOG_LEVEL;
|
|
23
|
+
}
|
|
24
|
+
if (env.ALLURE_LOG_LEVEL) {
|
|
25
|
+
return env.ALLURE_LOG_LEVEL;
|
|
26
|
+
}
|
|
27
|
+
if (env.NODE_ENV === "development") {
|
|
28
|
+
return "debug";
|
|
29
|
+
}
|
|
30
|
+
return "info";
|
|
31
|
+
}
|
|
32
|
+
export class Logger {
|
|
33
|
+
constructor(name) {
|
|
34
|
+
_Logger_instances.add(this);
|
|
35
|
+
this.name = name;
|
|
36
|
+
_Logger_level.set(this, getLogLevelFromEnv());
|
|
37
|
+
_Logger_prefix.set(this, cyan(bold(`[${this.name}]:`)));
|
|
38
|
+
}
|
|
39
|
+
progressBarCounter(message, total) {
|
|
40
|
+
if (__classPrivateFieldGet(this, _Logger_instances, "m", _Logger_isLogLevel).call(this, "silent")) {
|
|
41
|
+
return {
|
|
42
|
+
tick: () => { },
|
|
43
|
+
update: () => { },
|
|
44
|
+
terminate: () => { },
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const progressBar = new ProgressBar(`${__classPrivateFieldGet(this, _Logger_prefix, "f")} ${blue(message)} [:bar] :current/:total`, {
|
|
48
|
+
total,
|
|
49
|
+
width: 20,
|
|
50
|
+
});
|
|
51
|
+
return progressBar;
|
|
52
|
+
}
|
|
53
|
+
progressBar(message) {
|
|
54
|
+
if (__classPrivateFieldGet(this, _Logger_instances, "m", _Logger_isLogLevel).call(this, "silent")) {
|
|
55
|
+
return {
|
|
56
|
+
update: () => { },
|
|
57
|
+
terminate: () => { },
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const progressBar = new ProgressBar(`${__classPrivateFieldGet(this, _Logger_prefix, "f")} ${blue(message)} [:bar] :percent`, {
|
|
61
|
+
total: 100,
|
|
62
|
+
width: 20,
|
|
63
|
+
});
|
|
64
|
+
return progressBar;
|
|
65
|
+
}
|
|
66
|
+
verbose(message) {
|
|
67
|
+
if (!__classPrivateFieldGet(this, _Logger_instances, "m", _Logger_isLogLevel).call(this, "verbose")) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (typeof message === "string") {
|
|
71
|
+
console.log(`${__classPrivateFieldGet(this, _Logger_prefix, "f")} ${dim(gray(message))}`);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
console.log(`${__classPrivateFieldGet(this, _Logger_prefix, "f")} ${dim(gray(JSON.stringify(message, null, 2)))}`);
|
|
75
|
+
}
|
|
76
|
+
debug(message) {
|
|
77
|
+
if (!__classPrivateFieldGet(this, _Logger_instances, "m", _Logger_isLogLevel).call(this, "debug")) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (typeof message === "string") {
|
|
81
|
+
console.debug(`${__classPrivateFieldGet(this, _Logger_prefix, "f")} ${gray(message)}`);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
console.debug(`${__classPrivateFieldGet(this, _Logger_prefix, "f")} ${gray(JSON.stringify(message, null, 2))}`);
|
|
85
|
+
}
|
|
86
|
+
newLine() {
|
|
87
|
+
console.log("\n");
|
|
88
|
+
}
|
|
89
|
+
info(message) {
|
|
90
|
+
if (!__classPrivateFieldGet(this, _Logger_instances, "m", _Logger_isLogLevel).call(this, "info")) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (typeof message === "string") {
|
|
94
|
+
console.info(`${__classPrivateFieldGet(this, _Logger_prefix, "f")} ${blue(message)}`);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
console.info(`${__classPrivateFieldGet(this, _Logger_prefix, "f")} ${blue(JSON.stringify(message, null, 2))}`);
|
|
98
|
+
}
|
|
99
|
+
warn(message) {
|
|
100
|
+
if (!__classPrivateFieldGet(this, _Logger_instances, "m", _Logger_isLogLevel).call(this, "warn")) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (typeof message === "string") {
|
|
104
|
+
console.warn(`${__classPrivateFieldGet(this, _Logger_prefix, "f")} ${yellow(message)}`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
console.warn(`${__classPrivateFieldGet(this, _Logger_prefix, "f")} ${yellow(JSON.stringify(message, null, 2))}`);
|
|
108
|
+
}
|
|
109
|
+
error(message) {
|
|
110
|
+
if (!__classPrivateFieldGet(this, _Logger_instances, "m", _Logger_isLogLevel).call(this, "error")) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (typeof message === "string") {
|
|
114
|
+
console.error(`${__classPrivateFieldGet(this, _Logger_prefix, "f")} ${red(message)}`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
console.error(`${__classPrivateFieldGet(this, _Logger_prefix, "f")} ${red(JSON.stringify(message, null, 2))}`);
|
|
118
|
+
}
|
|
119
|
+
inspect(value) {
|
|
120
|
+
if (!__classPrivateFieldGet(this, _Logger_instances, "m", _Logger_isLogLevel).call(this, "debug")) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
console.log(`${__classPrivateFieldGet(this, _Logger_prefix, "f")} inspect`);
|
|
124
|
+
inspect(value);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
_Logger_level = new WeakMap(), _Logger_prefix = new WeakMap(), _Logger_instances = new WeakSet(), _Logger_isLogLevel = function _Logger_isLogLevel(level) {
|
|
128
|
+
return logLevelsPriority[__classPrivateFieldGet(this, _Logger_level, "f")] <= logLevelsPriority[level];
|
|
129
|
+
};
|
package/dist/model.d.ts
CHANGED
|
@@ -1,15 +1,76 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { Readable } from "node:stream";
|
|
2
|
+
import type { AttachmentLink, TestFixtureResult, TestResult } from "@allurereport/core-api";
|
|
3
|
+
export type UploadCategoryGrouping = {
|
|
4
|
+
key: string;
|
|
5
|
+
value?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
};
|
|
9
|
+
export type UploadCategory = {
|
|
10
|
+
externalId: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
grouping?: UploadCategoryGrouping[];
|
|
13
|
+
expand?: boolean;
|
|
14
|
+
hide?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type TestResultWithCategories = Pick<TestResult, "status" | "labels" | "error" | "flaky" | "duration" | "transition" | "environment"> & {
|
|
17
|
+
categories?: {
|
|
18
|
+
id?: string;
|
|
19
|
+
name: string;
|
|
20
|
+
grouping?: UploadCategoryGrouping[];
|
|
21
|
+
hide?: boolean;
|
|
22
|
+
expand?: boolean;
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
export interface TestOpsPluginTestResult extends TestResult {
|
|
26
|
+
category?: UploadCategory & {
|
|
27
|
+
id?: number;
|
|
28
|
+
};
|
|
29
|
+
namedEnv?: {
|
|
30
|
+
id: number;
|
|
31
|
+
};
|
|
32
|
+
message?: string;
|
|
33
|
+
trace?: string;
|
|
34
|
+
uuid?: string;
|
|
35
|
+
}
|
|
36
|
+
export type LaunchCategoryBulkItem = {
|
|
37
|
+
externalId: string;
|
|
38
|
+
name: string;
|
|
39
|
+
expand?: boolean;
|
|
40
|
+
hide?: boolean;
|
|
41
|
+
};
|
|
42
|
+
export type LaunchCategoryBulkResult = {
|
|
43
|
+
id: number;
|
|
44
|
+
externalId: string;
|
|
45
|
+
};
|
|
46
|
+
export type TestOpsClientParams = {
|
|
47
|
+
baseUrl: string;
|
|
48
|
+
projectId: string;
|
|
49
|
+
accessToken: string;
|
|
50
|
+
limit?: number;
|
|
51
|
+
};
|
|
52
|
+
export type AttachmentForUpload = {
|
|
53
|
+
originalFileName: string;
|
|
54
|
+
contentType: string;
|
|
55
|
+
content: Buffer | Blob | ReadableStream | Readable;
|
|
56
|
+
};
|
|
57
|
+
export type FixtureResolver = (tr: TestResult) => Promise<TestOpsFixtureResult[]>;
|
|
58
|
+
export type AttachmentsResolver = (tr: TestResult) => Promise<AttachmentForUpload[] | AttachmentForUpload>;
|
|
59
|
+
export type TestOpsUploaderOptions = {
|
|
3
60
|
endpoint: string;
|
|
4
61
|
accessToken: string;
|
|
5
62
|
projectId: string;
|
|
6
63
|
launchName: string;
|
|
7
64
|
launchTags: string[];
|
|
65
|
+
autocloseLaunch?: boolean;
|
|
8
66
|
filter?: (testResult: TestResult) => boolean;
|
|
9
67
|
limit?: number;
|
|
10
68
|
};
|
|
69
|
+
export interface TestOpsFixtureResult extends Omit<TestFixtureResult, "type"> {
|
|
70
|
+
type: "BEFORE" | "AFTER";
|
|
71
|
+
}
|
|
11
72
|
export type TemplateManifest = Record<string, string>;
|
|
12
|
-
export type
|
|
73
|
+
export type TestOpsPluginOptions = TestOpsUploaderOptions;
|
|
13
74
|
export type TestOpsSession = {
|
|
14
75
|
id: number;
|
|
15
76
|
jobId: number;
|
|
@@ -30,6 +91,21 @@ export type TestOpsLaunch = {
|
|
|
30
91
|
createdDate: number;
|
|
31
92
|
lastModifiedDate: number;
|
|
32
93
|
};
|
|
33
|
-
export
|
|
94
|
+
export interface TestResultWithAttachments extends TestResult {
|
|
34
95
|
attachments: AttachmentLink[];
|
|
96
|
+
}
|
|
97
|
+
export type TestOpsNamedEnv = {
|
|
98
|
+
id: number;
|
|
99
|
+
name: string;
|
|
100
|
+
externalId: string;
|
|
101
|
+
jobRunId?: number;
|
|
102
|
+
launchId?: number;
|
|
103
|
+
};
|
|
104
|
+
export type TestOpsLaunchQualityGate = {
|
|
105
|
+
id: number;
|
|
106
|
+
launchId: number;
|
|
107
|
+
jobRunId?: number;
|
|
108
|
+
namedEnvId?: number;
|
|
109
|
+
name: string;
|
|
110
|
+
message?: string;
|
|
35
111
|
};
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { type AllureStore, type Plugin, type PluginContext
|
|
2
|
-
import type {
|
|
3
|
-
export declare class
|
|
1
|
+
import { type AllureStore, type Plugin, type PluginContext } from "@allurereport/plugin-api";
|
|
2
|
+
import type { TestOpsPluginOptions } from "./model.js";
|
|
3
|
+
export declare class TestOpsPlugin implements Plugin {
|
|
4
4
|
#private;
|
|
5
|
-
readonly options:
|
|
6
|
-
constructor(options:
|
|
5
|
+
readonly options: TestOpsPluginOptions;
|
|
6
|
+
constructor(options: TestOpsPluginOptions);
|
|
7
7
|
get ciMode(): boolean | undefined;
|
|
8
|
-
start(
|
|
9
|
-
update(
|
|
10
|
-
done(
|
|
11
|
-
info(context: PluginContext, store: AllureStore): Promise<PluginSummary | undefined>;
|
|
8
|
+
start(context: PluginContext, store: AllureStore): Promise<void>;
|
|
9
|
+
update(context: PluginContext, store: AllureStore): Promise<void>;
|
|
10
|
+
done(context: PluginContext, store: AllureStore): Promise<void>;
|
|
11
|
+
info(context: PluginContext, store: AllureStore): Promise<import("@allurereport/plugin-api").PluginSummary | undefined>;
|
|
12
12
|
}
|