qase-javascript-commons 2.0.0-beta.4 → 2.0.0-beta.6
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/changelog.md +46 -0
- package/dist/config/config-validation-schema.js +8 -0
- package/dist/env/env-enum.d.ts +4 -2
- package/dist/env/env-enum.js +2 -0
- package/dist/env/env-to-config.js +2 -0
- package/dist/env/env-type.d.ts +2 -0
- package/dist/env/env-validation-schema.js +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/models/index.d.ts +1 -1
- package/dist/models/test-result.d.ts +11 -1
- package/dist/options/options-type.d.ts +1 -0
- package/dist/qase.js +7 -3
- package/dist/reporters/abstract-reporter.d.ts +15 -0
- package/dist/reporters/abstract-reporter.js +12 -1
- package/dist/reporters/testops-reporter.d.ts +34 -1
- package/dist/reporters/testops-reporter.js +107 -13
- package/dist/utils/mimeTypes.d.ts +5 -0
- package/dist/utils/mimeTypes.js +41 -0
- package/package.json +6 -3
package/changelog.md
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
+
# qase-javascript-commons@2.0.0-beta.6
|
|
2
|
+
|
|
3
|
+
## What's new
|
|
4
|
+
|
|
5
|
+
### Select the API version to use for reporting
|
|
6
|
+
|
|
7
|
+
Qase TestOps API has two endpoints for reporting test results:
|
|
8
|
+
|
|
9
|
+
- Version 1, stable and used my most test reporters.
|
|
10
|
+
https://developers.qase.io/reference/create-result-bulk
|
|
11
|
+
- Version 2, currently in beta access, and currently supported only
|
|
12
|
+
in the `playwright-qase-reporter`.
|
|
13
|
+
https://developers.qase.io/v2.0/reference/create-results-v2
|
|
14
|
+
|
|
15
|
+
This commit introduces a way to select the API version to use.
|
|
16
|
+
It enables using all new features of v2 JS reporters with the stable v1 API,
|
|
17
|
+
and elso experimenting with the new v2 API.
|
|
18
|
+
|
|
19
|
+
**Warning**: v2 API is still in beta.
|
|
20
|
+
If you want to try the v2 JS reporters, you don't have to enable the new API.
|
|
21
|
+
|
|
22
|
+
To enable using API v2, set an environment variable before running the tests:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
QASE_TESTOPS_API_V2=true
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Support adding test suite description to a test report.
|
|
29
|
+
|
|
30
|
+
Test reporters can now test suite description to test results.
|
|
31
|
+
Such description can be collected from test's location and attributes
|
|
32
|
+
or explicitly declared in the test.
|
|
33
|
+
|
|
34
|
+
Add new data models:
|
|
35
|
+
- Relation
|
|
36
|
+
- Suite
|
|
37
|
+
- SuiteData
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# qase-javascript-commons@2.0.0-beta.5
|
|
41
|
+
|
|
42
|
+
## What's new
|
|
43
|
+
|
|
44
|
+
* Update the config of reporters. Added `captureLogs` field. If it is set to `true`, the reporter will capture logs from the test framework.
|
|
45
|
+
* Added `getMimeType` function to the commons package. It returns the MIME type of the file by its extension.
|
|
46
|
+
|
|
1
47
|
# qase-javascript-commons@2.0.0-beta.4
|
|
2
48
|
|
|
3
49
|
## What's new
|
|
@@ -27,6 +27,10 @@ exports.configValidationSchema = {
|
|
|
27
27
|
type: ['string', 'number'],
|
|
28
28
|
nullable: true,
|
|
29
29
|
},
|
|
30
|
+
captureLogs: {
|
|
31
|
+
type: 'boolean',
|
|
32
|
+
nullable: true,
|
|
33
|
+
},
|
|
30
34
|
testops: {
|
|
31
35
|
type: 'object',
|
|
32
36
|
nullable: true,
|
|
@@ -111,6 +115,10 @@ exports.configValidationSchema = {
|
|
|
111
115
|
type: 'boolean',
|
|
112
116
|
nullable: true,
|
|
113
117
|
},
|
|
118
|
+
useV2: {
|
|
119
|
+
type: 'boolean',
|
|
120
|
+
nullable: true,
|
|
121
|
+
},
|
|
114
122
|
},
|
|
115
123
|
},
|
|
116
124
|
report: {
|
package/dist/env/env-enum.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export declare enum EnvEnum {
|
|
|
5
5
|
mode = "QASE_MODE",
|
|
6
6
|
fallback = "QASE_FALLBACK",
|
|
7
7
|
debug = "QASE_DEBUG",
|
|
8
|
-
environment = "QASE_ENVIRONMENT"
|
|
8
|
+
environment = "QASE_ENVIRONMENT",
|
|
9
|
+
captureLogs = "QASE_CAPTURE_LOGS"
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* @enum {string}
|
|
@@ -14,7 +15,8 @@ export declare enum EnvTestOpsEnum {
|
|
|
14
15
|
project = "QASE_TESTOPS_PROJECT",
|
|
15
16
|
uploadAttachments = "QASE_TESTOPS_UPLOAD_ATTACHMENTS",
|
|
16
17
|
chunk = "QASE_TESTOPS_CHUNK",
|
|
17
|
-
defect = "QASE_TESTOPS_DEFECT"
|
|
18
|
+
defect = "QASE_TESTOPS_DEFECT",
|
|
19
|
+
useV2 = "QASE_TESTOPS_API_V2"
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* @enum {string}
|
package/dist/env/env-enum.js
CHANGED
|
@@ -10,6 +10,7 @@ var EnvEnum;
|
|
|
10
10
|
EnvEnum["fallback"] = "QASE_FALLBACK";
|
|
11
11
|
EnvEnum["debug"] = "QASE_DEBUG";
|
|
12
12
|
EnvEnum["environment"] = "QASE_ENVIRONMENT";
|
|
13
|
+
EnvEnum["captureLogs"] = "QASE_CAPTURE_LOGS";
|
|
13
14
|
})(EnvEnum || (exports.EnvEnum = EnvEnum = {}));
|
|
14
15
|
/**
|
|
15
16
|
* @enum {string}
|
|
@@ -20,6 +21,7 @@ var EnvTestOpsEnum;
|
|
|
20
21
|
EnvTestOpsEnum["uploadAttachments"] = "QASE_TESTOPS_UPLOAD_ATTACHMENTS";
|
|
21
22
|
EnvTestOpsEnum["chunk"] = "QASE_TESTOPS_CHUNK";
|
|
22
23
|
EnvTestOpsEnum["defect"] = "QASE_TESTOPS_DEFECT";
|
|
24
|
+
EnvTestOpsEnum["useV2"] = "QASE_TESTOPS_API_V2";
|
|
23
25
|
})(EnvTestOpsEnum || (exports.EnvTestOpsEnum = EnvTestOpsEnum = {}));
|
|
24
26
|
/**
|
|
25
27
|
* @enum {string}
|
|
@@ -11,6 +11,7 @@ const envToConfig = (env) => ({
|
|
|
11
11
|
mode: env[env_enum_1.EnvEnum.mode],
|
|
12
12
|
debug: env[env_enum_1.EnvEnum.debug],
|
|
13
13
|
environment: env[env_enum_1.EnvEnum.environment],
|
|
14
|
+
captureLogs: env[env_enum_1.EnvEnum.captureLogs],
|
|
14
15
|
testops: {
|
|
15
16
|
project: env[env_enum_1.EnvTestOpsEnum.project],
|
|
16
17
|
uploadAttachments: env[env_enum_1.EnvTestOpsEnum.uploadAttachments],
|
|
@@ -29,6 +30,7 @@ const envToConfig = (env) => ({
|
|
|
29
30
|
},
|
|
30
31
|
chunk: env[env_enum_1.EnvTestOpsEnum.chunk],
|
|
31
32
|
defect: env[env_enum_1.EnvTestOpsEnum.defect],
|
|
33
|
+
useV2: env[env_enum_1.EnvTestOpsEnum.useV2],
|
|
32
34
|
},
|
|
33
35
|
report: {
|
|
34
36
|
connections: {
|
package/dist/env/env-type.d.ts
CHANGED
|
@@ -6,10 +6,12 @@ export type EnvType = {
|
|
|
6
6
|
[EnvEnum.fallback]?: `${ModeEnum}`;
|
|
7
7
|
[EnvEnum.debug]?: boolean;
|
|
8
8
|
[EnvEnum.environment]?: string | number;
|
|
9
|
+
[EnvEnum.captureLogs]?: boolean;
|
|
9
10
|
[EnvTestOpsEnum.project]?: string;
|
|
10
11
|
[EnvTestOpsEnum.uploadAttachments]?: boolean;
|
|
11
12
|
[EnvTestOpsEnum.chunk]?: number;
|
|
12
13
|
[EnvTestOpsEnum.defect]?: boolean;
|
|
14
|
+
[EnvTestOpsEnum.useV2]?: boolean;
|
|
13
15
|
[EnvApiEnum.token]?: string;
|
|
14
16
|
[EnvApiEnum.baseUrl]?: string;
|
|
15
17
|
[EnvRunEnum.id]?: number;
|
|
@@ -28,6 +28,10 @@ exports.envValidationSchema = {
|
|
|
28
28
|
type: ['string', 'number'],
|
|
29
29
|
nullable: true,
|
|
30
30
|
},
|
|
31
|
+
[env_enum_1.EnvEnum.captureLogs]: {
|
|
32
|
+
type: 'boolean',
|
|
33
|
+
nullable: true,
|
|
34
|
+
},
|
|
31
35
|
[env_enum_1.EnvTestOpsEnum.project]: {
|
|
32
36
|
type: 'string',
|
|
33
37
|
nullable: true,
|
|
@@ -44,6 +48,10 @@ exports.envValidationSchema = {
|
|
|
44
48
|
type: 'boolean',
|
|
45
49
|
nullable: true,
|
|
46
50
|
},
|
|
51
|
+
[env_enum_1.EnvTestOpsEnum.useV2]: {
|
|
52
|
+
type: 'boolean',
|
|
53
|
+
nullable: true,
|
|
54
|
+
},
|
|
47
55
|
[env_enum_1.EnvApiEnum.token]: {
|
|
48
56
|
type: 'string',
|
|
49
57
|
nullable: true,
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/models/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type TestResultType } from './test-result';
|
|
1
|
+
export { type TestResultType, Relation, Suite, SuiteData } from './test-result';
|
|
2
2
|
export { TestExecution, TestStatusEnum } from './test-execution';
|
|
3
3
|
export { type TestStepType } from './test-step';
|
|
4
4
|
export { StepStatusEnum } from './step-execution';
|
|
@@ -13,7 +13,17 @@ export type TestResultType = {
|
|
|
13
13
|
steps: TestStepType[];
|
|
14
14
|
params: Record<string, string>;
|
|
15
15
|
author: string | null;
|
|
16
|
-
relations:
|
|
16
|
+
relations: Relation | null;
|
|
17
17
|
muted: boolean;
|
|
18
18
|
message: string | null;
|
|
19
19
|
};
|
|
20
|
+
export type Relation = {
|
|
21
|
+
suite?: Suite;
|
|
22
|
+
};
|
|
23
|
+
export type Suite = {
|
|
24
|
+
data: SuiteData[];
|
|
25
|
+
};
|
|
26
|
+
export type SuiteData = {
|
|
27
|
+
title: string;
|
|
28
|
+
public_id: number | null;
|
|
29
|
+
};
|
|
@@ -21,6 +21,7 @@ export type OptionsType = {
|
|
|
21
21
|
reporterName: string;
|
|
22
22
|
mode?: `${ModeEnum}` | undefined;
|
|
23
23
|
fallback?: `${ModeEnum}` | undefined;
|
|
24
|
+
captureLogs?: boolean | undefined;
|
|
24
25
|
debug?: boolean | undefined;
|
|
25
26
|
environment?: string | number | undefined;
|
|
26
27
|
testops?: (RecursivePartial<TestOpsOptionsType> & AdditionalTestOpsOptionsType) | undefined;
|
package/dist/qase.js
CHANGED
|
@@ -71,7 +71,7 @@ class QaseReporter extends reporters_1.AbstractReporter {
|
|
|
71
71
|
constructor(options, logger) {
|
|
72
72
|
const env = (0, env_1.envToConfig)((0, env_schema_1.default)({ schema: env_1.envValidationSchema }));
|
|
73
73
|
const composedOptions = (0, options_1.composeOptions)(options, env);
|
|
74
|
-
super({ debug: composedOptions.debug }, logger);
|
|
74
|
+
super({ debug: composedOptions.debug, captureLogs: composedOptions.captureLogs }, logger);
|
|
75
75
|
/**
|
|
76
76
|
* @type {boolean}
|
|
77
77
|
* @private
|
|
@@ -233,13 +233,17 @@ class QaseReporter extends reporters_1.AbstractReporter {
|
|
|
233
233
|
},
|
|
234
234
|
plan,
|
|
235
235
|
chunk,
|
|
236
|
-
|
|
236
|
+
debug: commonOptions.debug,
|
|
237
|
+
captureLogs: commonOptions.captureLogs,
|
|
237
238
|
}, apiClient, logger, typeof environment === 'number' ? environment : undefined);
|
|
238
239
|
}
|
|
239
240
|
case options_1.ModeEnum.report: {
|
|
240
241
|
const localOptions = report.connections?.[writer_1.DriverEnum.local];
|
|
241
242
|
const writer = new writer_1.FsWriter(localOptions);
|
|
242
|
-
return new reporters_1.ReportReporter(
|
|
243
|
+
return new reporters_1.ReportReporter({
|
|
244
|
+
debug: commonOptions.debug,
|
|
245
|
+
captureLogs: commonOptions.captureLogs,
|
|
246
|
+
}, writer, logger, typeof environment === 'number' ? environment.toString() : environment, testops.run?.id);
|
|
243
247
|
}
|
|
244
248
|
case options_1.ModeEnum.off:
|
|
245
249
|
throw new disabled_exception_1.DisabledException();
|
|
@@ -6,12 +6,14 @@ export interface LoggerInterface {
|
|
|
6
6
|
}
|
|
7
7
|
export interface ReporterOptionsType {
|
|
8
8
|
debug?: boolean | undefined;
|
|
9
|
+
captureLogs?: boolean | undefined;
|
|
9
10
|
}
|
|
10
11
|
export interface ReporterInterface {
|
|
11
12
|
addTestResult(result: TestResultType): void;
|
|
12
13
|
publish(): Promise<void>;
|
|
13
14
|
getTestResults(): TestResultType[];
|
|
14
15
|
setTestResults(results: TestResultType[]): void;
|
|
16
|
+
isCaptureLogs(): boolean;
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* @abstract
|
|
@@ -25,6 +27,15 @@ export declare abstract class AbstractReporter implements ReporterInterface {
|
|
|
25
27
|
* @private
|
|
26
28
|
*/
|
|
27
29
|
private readonly debug;
|
|
30
|
+
/**
|
|
31
|
+
* @type {boolean | undefined}
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
private readonly captureLogs;
|
|
35
|
+
/**
|
|
36
|
+
* @type {TestResultType[]}
|
|
37
|
+
* @protected
|
|
38
|
+
*/
|
|
28
39
|
protected results: TestResultType[];
|
|
29
40
|
/**
|
|
30
41
|
* @returns {Promise<void>}
|
|
@@ -40,6 +51,10 @@ export declare abstract class AbstractReporter implements ReporterInterface {
|
|
|
40
51
|
* @returns {TestResultType[]}
|
|
41
52
|
*/
|
|
42
53
|
getTestResults(): TestResultType[];
|
|
54
|
+
/**
|
|
55
|
+
* @returns {boolean}
|
|
56
|
+
*/
|
|
57
|
+
isCaptureLogs(): boolean;
|
|
43
58
|
/**
|
|
44
59
|
* @param {TestResultType} result
|
|
45
60
|
*/
|
|
@@ -21,9 +21,14 @@ class AbstractReporter {
|
|
|
21
21
|
*/
|
|
22
22
|
constructor(options, logger = console) {
|
|
23
23
|
this.logger = logger;
|
|
24
|
+
/**
|
|
25
|
+
* @type {TestResultType[]}
|
|
26
|
+
* @protected
|
|
27
|
+
*/
|
|
24
28
|
this.results = [];
|
|
25
|
-
const { debug } = options ?? {};
|
|
29
|
+
const { debug, captureLogs } = options ?? {};
|
|
26
30
|
this.debug = debug;
|
|
31
|
+
this.captureLogs = captureLogs;
|
|
27
32
|
}
|
|
28
33
|
/**
|
|
29
34
|
* @returns {TestResultType[]}
|
|
@@ -31,6 +36,12 @@ class AbstractReporter {
|
|
|
31
36
|
getTestResults() {
|
|
32
37
|
return this.results;
|
|
33
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* @returns {boolean}
|
|
41
|
+
*/
|
|
42
|
+
isCaptureLogs() {
|
|
43
|
+
return this.captureLogs ?? false;
|
|
44
|
+
}
|
|
34
45
|
/**
|
|
35
46
|
* @param {TestResultType} result
|
|
36
47
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QaseApiInterface, ResultStepStatus } from 'qaseio';
|
|
1
|
+
import { QaseApiInterface, ResultStepStatus, TestStepResultCreateStatusEnum } from 'qaseio';
|
|
2
2
|
import { AbstractReporter, LoggerInterface, ReporterOptionsType } from './abstract-reporter';
|
|
3
3
|
import { StepStatusEnum, TestStatusEnum } from '../models';
|
|
4
4
|
export type TestOpsRunType = {
|
|
@@ -17,6 +17,7 @@ export type TestOpsOptionsType = {
|
|
|
17
17
|
plan: TestOpsPlanType;
|
|
18
18
|
chunk?: number | undefined;
|
|
19
19
|
defect?: boolean | undefined;
|
|
20
|
+
useV2?: boolean | undefined;
|
|
20
21
|
};
|
|
21
22
|
/**
|
|
22
23
|
* @class TestOpsReporter
|
|
@@ -32,6 +33,10 @@ export declare class TestOpsReporter extends AbstractReporter {
|
|
|
32
33
|
* @type {Record<StepStatusEnum, ResultStepStatus>}
|
|
33
34
|
*/
|
|
34
35
|
static stepStatusMap: Record<StepStatusEnum, ResultStepStatus>;
|
|
36
|
+
/**
|
|
37
|
+
* @type {Record<StepStatusEnum, ResultStepStatus>}
|
|
38
|
+
*/
|
|
39
|
+
static stepStatusMapV1: Record<StepStatusEnum, TestStepResultCreateStatusEnum>;
|
|
35
40
|
/**
|
|
36
41
|
* @type {string}
|
|
37
42
|
* @private
|
|
@@ -62,6 +67,16 @@ export declare class TestOpsReporter extends AbstractReporter {
|
|
|
62
67
|
* @private
|
|
63
68
|
*/
|
|
64
69
|
private readonly chunk;
|
|
70
|
+
/**
|
|
71
|
+
* @type {boolean | undefined}
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
private readonly useV2;
|
|
75
|
+
/**
|
|
76
|
+
* @type {boolean | undefined}
|
|
77
|
+
* @private
|
|
78
|
+
*/
|
|
79
|
+
private readonly defect;
|
|
65
80
|
/**
|
|
66
81
|
* @param {ReporterOptionsType & TestOpsOptionsType} options
|
|
67
82
|
* @param {QaseApiInterface} api
|
|
@@ -79,18 +94,36 @@ export declare class TestOpsReporter extends AbstractReporter {
|
|
|
79
94
|
* @private
|
|
80
95
|
*/
|
|
81
96
|
private transformTestResult;
|
|
97
|
+
/**
|
|
98
|
+
* @param {TestResultType} result
|
|
99
|
+
* @returns Promise<ResultCreate>
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
private transformTestResultV1;
|
|
82
103
|
/**
|
|
83
104
|
* @returns {ResultExecution}
|
|
84
105
|
* @private
|
|
85
106
|
* @param {TestExecution} exec
|
|
86
107
|
*/
|
|
87
108
|
private getExecution;
|
|
109
|
+
/**
|
|
110
|
+
* @param {Relation | null} relation
|
|
111
|
+
* @returns {ResultRelations}
|
|
112
|
+
* @private
|
|
113
|
+
*/
|
|
114
|
+
private getRelation;
|
|
88
115
|
/**
|
|
89
116
|
* @param {TestStepType[]} steps
|
|
90
117
|
* @returns Promise<ResultStep[]>
|
|
91
118
|
* @private
|
|
92
119
|
*/
|
|
93
120
|
private transformSteps;
|
|
121
|
+
/**
|
|
122
|
+
* @param {TestStepType[]} steps
|
|
123
|
+
* @returns Promise<TestStepResultCreate[]>
|
|
124
|
+
* @private
|
|
125
|
+
*/
|
|
126
|
+
private transformStepsV1;
|
|
94
127
|
/**
|
|
95
128
|
* @param {number} runId
|
|
96
129
|
* @returns {Promise<void>}
|
|
@@ -33,6 +33,8 @@ class TestOpsReporter extends abstract_reporter_1.AbstractReporter {
|
|
|
33
33
|
this.run = { complete: true, ...run };
|
|
34
34
|
this.environment = environment;
|
|
35
35
|
this.chunk = options.chunk ?? defaultChunkSize;
|
|
36
|
+
this.useV2 = options.useV2 ?? false;
|
|
37
|
+
this.defect = options.defect ?? false;
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
40
|
* @returns {Promise<void>}
|
|
@@ -54,15 +56,29 @@ class TestOpsReporter extends abstract_reporter_1.AbstractReporter {
|
|
|
54
56
|
this.log('No test cases were matched. Ensure that your tests are declared correctly.');
|
|
55
57
|
return;
|
|
56
58
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
59
|
+
if (this.useV2) {
|
|
60
|
+
const results = [];
|
|
61
|
+
for (const result of this.results) {
|
|
62
|
+
const resultCreateV2 = await this.transformTestResult(result);
|
|
63
|
+
results.push(resultCreateV2);
|
|
64
|
+
}
|
|
65
|
+
for (let i = 0; i < results.length; i += this.chunk) {
|
|
66
|
+
await this.api.result.createResultsV2(this.projectCode, runId, {
|
|
67
|
+
results: results.slice(i, i + this.chunk),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
61
70
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
71
|
+
else {
|
|
72
|
+
const results = [];
|
|
73
|
+
for (const result of this.results) {
|
|
74
|
+
const resultCreate = await this.transformTestResultV1(result);
|
|
75
|
+
results.push(resultCreate);
|
|
76
|
+
}
|
|
77
|
+
for (let i = 0; i < results.length; i += this.chunk) {
|
|
78
|
+
await this.api.results.createResultBulk(this.projectCode, runId, {
|
|
79
|
+
results: results.slice(i, i + this.chunk),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
66
82
|
}
|
|
67
83
|
this.log((0, chalk_1.default) `{green ${this.results.length} result(s) sent to Qase}`);
|
|
68
84
|
if (!this.run.complete) {
|
|
@@ -93,14 +109,41 @@ class TestOpsReporter extends abstract_reporter_1.AbstractReporter {
|
|
|
93
109
|
attachments: attachments,
|
|
94
110
|
steps: steps,
|
|
95
111
|
params: result.params,
|
|
96
|
-
relations:
|
|
97
|
-
// suite: {
|
|
98
|
-
// data: result.suiteTitle ? this.getSuites(result.suiteTitle) : [],
|
|
99
|
-
// },
|
|
100
|
-
},
|
|
112
|
+
relations: this.getRelation(result.relations),
|
|
101
113
|
message: result.message,
|
|
102
114
|
};
|
|
103
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* @param {TestResultType} result
|
|
118
|
+
* @returns Promise<ResultCreate>
|
|
119
|
+
* @private
|
|
120
|
+
*/
|
|
121
|
+
async transformTestResultV1(result) {
|
|
122
|
+
const attachments = await this.uploadAttachments(result.attachments);
|
|
123
|
+
const steps = await this.transformStepsV1(result.steps);
|
|
124
|
+
const resultCreate = {
|
|
125
|
+
attachments: attachments,
|
|
126
|
+
comment: result.message,
|
|
127
|
+
defect: this.defect,
|
|
128
|
+
param: result.params,
|
|
129
|
+
stacktrace: result.execution.stacktrace,
|
|
130
|
+
start_time: result.execution.start_time ? result.execution.start_time | 0 : null,
|
|
131
|
+
status: result.execution.status,
|
|
132
|
+
steps: steps,
|
|
133
|
+
time: result.execution.end_time,
|
|
134
|
+
time_ms: result.execution.duration,
|
|
135
|
+
};
|
|
136
|
+
const id = Array.isArray(result.testops_id) ? null : result.testops_id;
|
|
137
|
+
if (id) {
|
|
138
|
+
resultCreate.case_id = id;
|
|
139
|
+
return resultCreate;
|
|
140
|
+
}
|
|
141
|
+
resultCreate.case = {
|
|
142
|
+
title: result.title,
|
|
143
|
+
suite_title: result.relations?.suite ? result.relations?.suite?.data.map((suite) => suite.title).join('\t') : null,
|
|
144
|
+
};
|
|
145
|
+
return resultCreate;
|
|
146
|
+
}
|
|
104
147
|
/**
|
|
105
148
|
* @returns {ResultExecution}
|
|
106
149
|
* @private
|
|
@@ -116,6 +159,28 @@ class TestOpsReporter extends abstract_reporter_1.AbstractReporter {
|
|
|
116
159
|
thread: exec.thread,
|
|
117
160
|
};
|
|
118
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* @param {Relation | null} relation
|
|
164
|
+
* @returns {ResultRelations}
|
|
165
|
+
* @private
|
|
166
|
+
*/
|
|
167
|
+
getRelation(relation) {
|
|
168
|
+
if (!relation || !relation.suite) {
|
|
169
|
+
return {};
|
|
170
|
+
}
|
|
171
|
+
const suiteData = [];
|
|
172
|
+
for (const data of relation.suite.data) {
|
|
173
|
+
suiteData.push({
|
|
174
|
+
public_id: null,
|
|
175
|
+
title: data.title,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
suite: {
|
|
180
|
+
data: suiteData,
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|
|
119
184
|
/**
|
|
120
185
|
* @param {TestStepType[]} steps
|
|
121
186
|
* @returns Promise<ResultStep[]>
|
|
@@ -141,6 +206,27 @@ class TestOpsReporter extends abstract_reporter_1.AbstractReporter {
|
|
|
141
206
|
}
|
|
142
207
|
return resultsSteps;
|
|
143
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* @param {TestStepType[]} steps
|
|
211
|
+
* @returns Promise<TestStepResultCreate[]>
|
|
212
|
+
* @private
|
|
213
|
+
*/
|
|
214
|
+
async transformStepsV1(steps) {
|
|
215
|
+
const resultsSteps = [];
|
|
216
|
+
for (const step of steps) {
|
|
217
|
+
const attachmentHashes = await this.uploadAttachments(step.attachments);
|
|
218
|
+
const resultStep = {
|
|
219
|
+
status: TestOpsReporter.stepStatusMapV1[step.execution.status],
|
|
220
|
+
action: step.data.action,
|
|
221
|
+
attachments: attachmentHashes,
|
|
222
|
+
};
|
|
223
|
+
if (step.steps.length > 0) {
|
|
224
|
+
resultStep.steps = await this.transformStepsV1(step.steps);
|
|
225
|
+
}
|
|
226
|
+
resultsSteps.push(resultStep);
|
|
227
|
+
}
|
|
228
|
+
return resultsSteps;
|
|
229
|
+
}
|
|
144
230
|
/**
|
|
145
231
|
* @param {number} runId
|
|
146
232
|
* @returns {Promise<void>}
|
|
@@ -235,3 +321,11 @@ TestOpsReporter.stepStatusMap = {
|
|
|
235
321
|
[models_1.StepStatusEnum.failed]: qaseio_1.ResultStepStatus.FAILED,
|
|
236
322
|
[models_1.StepStatusEnum.blocked]: qaseio_1.ResultStepStatus.BLOCKED,
|
|
237
323
|
};
|
|
324
|
+
/**
|
|
325
|
+
* @type {Record<StepStatusEnum, ResultStepStatus>}
|
|
326
|
+
*/
|
|
327
|
+
TestOpsReporter.stepStatusMapV1 = {
|
|
328
|
+
[models_1.StepStatusEnum.passed]: qaseio_1.TestStepResultCreateStatusEnum.PASSED,
|
|
329
|
+
[models_1.StepStatusEnum.failed]: qaseio_1.TestStepResultCreateStatusEnum.FAILED,
|
|
330
|
+
[models_1.StepStatusEnum.blocked]: qaseio_1.TestStepResultCreateStatusEnum.BLOCKED,
|
|
331
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.getMimeTypes = void 0;
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const mime = __importStar(require("mime-types"));
|
|
29
|
+
/**
|
|
30
|
+
* Get mime type of the file
|
|
31
|
+
* @param {string} filePath
|
|
32
|
+
*/
|
|
33
|
+
function getMimeTypes(filePath) {
|
|
34
|
+
const fileName = path.basename(filePath);
|
|
35
|
+
const mimeType = mime.contentType(fileName);
|
|
36
|
+
if (!mimeType && typeof mimeType !== 'string') {
|
|
37
|
+
return 'application/octet-stream';
|
|
38
|
+
}
|
|
39
|
+
return mimeType;
|
|
40
|
+
}
|
|
41
|
+
exports.getMimeTypes = getMimeTypes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qase-javascript-commons",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.6",
|
|
4
4
|
"description": "Qase JS Reporters",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -26,15 +26,16 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"ajv": "^8.12.0",
|
|
28
28
|
"chalk": "^4.1.2",
|
|
29
|
+
"child-process-ext": "^3.0.2",
|
|
29
30
|
"env-schema": "^5.2.0",
|
|
30
31
|
"form-data": "^4.0.0",
|
|
31
32
|
"lodash.get": "^4.4.2",
|
|
32
33
|
"lodash.merge": "^4.6.2",
|
|
33
34
|
"lodash.mergewith": "^4.6.2",
|
|
35
|
+
"mime-types": "^2.1.33",
|
|
34
36
|
"qaseio": "^2.1.0-beta.1",
|
|
35
37
|
"strip-ansi": "^6.0.1",
|
|
36
|
-
"uuid": "^9.0.0"
|
|
37
|
-
"child-process-ext": "^3.0.2"
|
|
38
|
+
"uuid": "^9.0.0"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@jest/globals": "^29.5.0",
|
|
@@ -42,6 +43,8 @@
|
|
|
42
43
|
"@types/lodash.get": "^4.4.7",
|
|
43
44
|
"@types/lodash.merge": "^4.6.7",
|
|
44
45
|
"@types/lodash.mergewith": "^4.6.7",
|
|
46
|
+
"@types/mime-types": "^2.1.4",
|
|
47
|
+
"@types/node": "^20.12.5",
|
|
45
48
|
"@types/uuid": "^9.0.1",
|
|
46
49
|
"axios": "^0.21.4",
|
|
47
50
|
"jest": "^29.5.0",
|