testit-js-commons 3.4.10 → 3.5.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/lib/common/base.converter.js +7 -0
- package/lib/common/base.service.js +13 -0
- package/lib/services/attachments/attachments.service.d.ts +2 -2
- package/lib/services/attachments/attachments.service.js +11 -17
- package/lib/services/autotests/autotests.converter.d.ts +3 -3
- package/lib/services/autotests/autotests.converter.js +8 -0
- package/lib/services/autotests/autotests.handler.d.ts +1 -1
- package/lib/services/autotests/autotests.handler.js +1 -7
- package/lib/services/autotests/autotests.service.d.ts +3 -3
- package/lib/services/autotests/autotests.service.js +17 -13
- package/lib/services/autotests/autotests.type.d.ts +1 -2
- package/lib/services/testresults/testresults.converter.js +12 -0
- package/lib/services/testresults/testresults.handler.d.ts +1 -1
- package/lib/services/testresults/testresults.handler.js +1 -7
- package/lib/services/testresults/testresults.service.d.ts +2 -2
- package/lib/services/testresults/testresults.service.js +11 -9
- package/lib/services/testruns/testruns.converter.js +7 -0
- package/lib/services/testruns/testruns.handler.d.ts +2 -2
- package/lib/services/testruns/testruns.handler.js +2 -11
- package/lib/services/testruns/testruns.service.d.ts +2 -2
- package/lib/services/testruns/testruns.service.js +14 -10
- package/package.json +2 -2
|
@@ -7,18 +7,23 @@ class BaseConverter {
|
|
|
7
7
|
this.config = config;
|
|
8
8
|
}
|
|
9
9
|
toOriginOutcome(outcome) {
|
|
10
|
+
// @ts-ignore
|
|
10
11
|
return testit_api_client_1.AvailableTestResultOutcome[outcome];
|
|
11
12
|
}
|
|
12
13
|
toLocalOutcome(outcome) {
|
|
14
|
+
// @ts-ignore
|
|
13
15
|
return testit_api_client_1.AvailableTestResultOutcome[outcome];
|
|
14
16
|
}
|
|
15
17
|
toOriginLinkType(linkType) {
|
|
18
|
+
// @ts-ignore
|
|
16
19
|
return testit_api_client_1.LinkType[linkType];
|
|
17
20
|
}
|
|
18
21
|
toLocalLinkType(linkType) {
|
|
22
|
+
// @ts-ignore
|
|
19
23
|
return testit_api_client_1.LinkType[linkType];
|
|
20
24
|
}
|
|
21
25
|
toOriginLink(link) {
|
|
26
|
+
// @ts-ignore
|
|
22
27
|
return Object.assign(Object.assign({}, link), { type: link.type ? this.toOriginLinkType(link.type) : undefined, hasInfo: true });
|
|
23
28
|
}
|
|
24
29
|
toLocalLink(link) {
|
|
@@ -35,11 +40,13 @@ class BaseConverter {
|
|
|
35
40
|
return {
|
|
36
41
|
title: step.title,
|
|
37
42
|
description: (_a = step.description) !== null && _a !== void 0 ? _a : undefined,
|
|
43
|
+
// @ts-ignore
|
|
38
44
|
steps: (_b = step.steps) === null || _b === void 0 ? void 0 : _b.map((step) => this.toLocalShortStep(step)),
|
|
39
45
|
};
|
|
40
46
|
}
|
|
41
47
|
toOriginStep(step) {
|
|
42
48
|
var _a;
|
|
49
|
+
// @ts-ignore
|
|
43
50
|
const model = {
|
|
44
51
|
title: step.title,
|
|
45
52
|
description: step.description,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.BaseService = void 0;
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
const testit_api_client_1 = __importDefault(require("testit-api-client"));
|
|
4
9
|
class BaseService {
|
|
5
10
|
constructor(config) {
|
|
6
11
|
this.config = config;
|
|
@@ -14,6 +19,14 @@ class BaseService {
|
|
|
14
19
|
throw new Error("Configuration id is not defined");
|
|
15
20
|
if (!config.projectId)
|
|
16
21
|
throw new Error("Project id is not defined");
|
|
22
|
+
var defaultClient = testit_api_client_1.default.ApiClient.instance;
|
|
23
|
+
defaultClient.basePath = config.url;
|
|
24
|
+
var auth = defaultClient.authentications['Bearer or PrivateToken'];
|
|
25
|
+
auth.apiKeyPrefix = "PrivateToken";
|
|
26
|
+
auth.apiKey = config.privateToken;
|
|
27
|
+
if (config.certValidation === false) {
|
|
28
|
+
defaultClient.rejectUnauthorized = config.certValidation;
|
|
29
|
+
}
|
|
17
30
|
}
|
|
18
31
|
}
|
|
19
32
|
exports.BaseService = BaseService;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TestitApiClient from "testit-api-client";
|
|
2
2
|
import { BaseService, AdapterConfig, Attachment } from "../../common";
|
|
3
3
|
import { IAttachmentsService } from "./attachments.type";
|
|
4
4
|
import { Buffer } from "buffer";
|
|
5
5
|
export declare class AttachmentsService extends BaseService implements IAttachmentsService {
|
|
6
6
|
protected readonly config: AdapterConfig;
|
|
7
|
-
protected _client: AttachmentsApi;
|
|
7
|
+
protected _client: TestitApiClient.AttachmentsApi;
|
|
8
8
|
constructor(config: AdapterConfig);
|
|
9
9
|
uploadTextAttachment(content: string | Buffer, filename?: string): Promise<Attachment[]>;
|
|
10
10
|
uploadAttachments(paths: string[]): Promise<Attachment[]>;
|
|
@@ -8,21 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.AttachmentsService = void 0;
|
|
13
|
-
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
const testit_api_client_1 = __importDefault(require("testit-api-client"));
|
|
14
18
|
const common_1 = require("../../common");
|
|
15
19
|
const buffer_1 = require("buffer");
|
|
16
|
-
const apiKey = testit_api_client_1.AttachmentsApiApiKeys["Bearer or PrivateToken"];
|
|
17
20
|
class AttachmentsService extends common_1.BaseService {
|
|
18
21
|
constructor(config) {
|
|
19
22
|
super(config);
|
|
20
23
|
this.config = config;
|
|
21
|
-
this._client = new testit_api_client_1.AttachmentsApi(
|
|
22
|
-
this._client.setApiKey(apiKey, `PrivateToken ${config.privateToken}`);
|
|
23
|
-
if (config.certValidation !== undefined) {
|
|
24
|
-
this._client.setRejectUnauthorized(config.certValidation);
|
|
25
|
-
}
|
|
24
|
+
this._client = new testit_api_client_1.default.AttachmentsApi();
|
|
26
25
|
}
|
|
27
26
|
uploadTextAttachment(content, filename) {
|
|
28
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -30,22 +29,17 @@ class AttachmentsService extends common_1.BaseService {
|
|
|
30
29
|
value: typeof content === "string" ? buffer_1.Buffer.from(content, "utf-8") : content,
|
|
31
30
|
options: { filename: filename !== null && filename !== void 0 ? filename : common_1.Utils.generateFileName() },
|
|
32
31
|
};
|
|
33
|
-
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
return yield this._client.apiV2AttachmentsPost({ file: request }).then(({ body }) => [{ id: body.id }]);
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
uploadAttachments(paths) {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
38
|
return yield Promise.all(paths.map((path) => {
|
|
39
|
-
const extension = common_1.Utils.getExtName(path);
|
|
40
|
-
const headers = {};
|
|
41
|
-
if (extension.search("txt") >= 0) {
|
|
42
|
-
headers["Content-Type"] = "text/plain";
|
|
43
|
-
}
|
|
44
|
-
if (extension.search(/jp[e?]g/) >= 0) {
|
|
45
|
-
headers["Content-Type"] = "image";
|
|
46
|
-
}
|
|
47
39
|
return this._client
|
|
48
|
-
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
.apiV2AttachmentsPost({ file: common_1.Utils.readStream(path) })
|
|
42
|
+
// @ts-ignore
|
|
49
43
|
.then(({ body }) => ({ id: body.id }));
|
|
50
44
|
}));
|
|
51
45
|
});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { AutoTestModelV2GetModel, AutoTestApiResult
|
|
1
|
+
import { AutoTestModelV2GetModel, AutoTestApiResult } from "testit-api-client";
|
|
2
2
|
import { BaseConverter, AdapterConfig } from "../../common";
|
|
3
3
|
import { AutotestGet, AutotestPost } from "./autotests.type";
|
|
4
4
|
export interface IAutotestConverter {
|
|
5
|
-
toOriginAutotest(autotest: AutotestPost):
|
|
5
|
+
toOriginAutotest(autotest: AutotestPost): any;
|
|
6
6
|
toLocalAutotest(autotest: AutoTestApiResult): AutotestGet;
|
|
7
7
|
toLocalAutotestByModel(autotest: AutoTestModelV2GetModel): AutotestGet;
|
|
8
8
|
}
|
|
9
9
|
export declare class AutotestConverter extends BaseConverter implements IAutotestConverter {
|
|
10
10
|
constructor(config: AdapterConfig);
|
|
11
|
-
toOriginAutotest(autotest: AutotestPost):
|
|
11
|
+
toOriginAutotest(autotest: AutotestPost): any;
|
|
12
12
|
toLocalAutotestByModel(autotest: AutoTestModelV2GetModel): AutotestGet;
|
|
13
13
|
toLocalAutotest(autotest: AutoTestApiResult): AutotestGet;
|
|
14
14
|
}
|
|
@@ -31,11 +31,15 @@ class AutotestConverter extends common_1.BaseConverter {
|
|
|
31
31
|
id: autotest.id,
|
|
32
32
|
name: (_a = autotest.name) !== null && _a !== void 0 ? _a : undefined,
|
|
33
33
|
externalId: (_b = autotest.externalId) !== null && _b !== void 0 ? _b : undefined,
|
|
34
|
+
// @ts-ignore
|
|
34
35
|
links: (_c = autotest.links) === null || _c === void 0 ? void 0 : _c.map((link) => this.toLocalLink(link)),
|
|
35
36
|
namespace: (_d = autotest.namespace) !== null && _d !== void 0 ? _d : undefined,
|
|
36
37
|
classname: (_e = autotest.classname) !== null && _e !== void 0 ? _e : undefined,
|
|
38
|
+
// @ts-ignore
|
|
37
39
|
steps: (_f = autotest.steps) === null || _f === void 0 ? void 0 : _f.map((step) => this.toLocalShortStep(step)),
|
|
40
|
+
// @ts-ignore
|
|
38
41
|
setup: (_g = autotest.setup) === null || _g === void 0 ? void 0 : _g.map((step) => this.toLocalShortStep(step)),
|
|
42
|
+
// @ts-ignore
|
|
39
43
|
teardown: (_h = autotest.teardown) === null || _h === void 0 ? void 0 : _h.map((step) => this.toLocalShortStep(step)),
|
|
40
44
|
labels: (_j = autotest.labels) !== null && _j !== void 0 ? _j : undefined,
|
|
41
45
|
};
|
|
@@ -46,11 +50,15 @@ class AutotestConverter extends common_1.BaseConverter {
|
|
|
46
50
|
id: autotest.id,
|
|
47
51
|
name: (_a = autotest.name) !== null && _a !== void 0 ? _a : undefined,
|
|
48
52
|
externalId: (_b = autotest.externalId) !== null && _b !== void 0 ? _b : undefined,
|
|
53
|
+
// @ts-ignore
|
|
49
54
|
links: (_c = autotest.links) === null || _c === void 0 ? void 0 : _c.map((link) => this.toLocalLink(link)),
|
|
50
55
|
namespace: (_d = autotest.namespace) !== null && _d !== void 0 ? _d : undefined,
|
|
51
56
|
classname: (_e = autotest.classname) !== null && _e !== void 0 ? _e : undefined,
|
|
57
|
+
// @ts-ignore
|
|
52
58
|
steps: (_f = autotest.steps) === null || _f === void 0 ? void 0 : _f.map((step) => this.toLocalShortStep(step)),
|
|
59
|
+
// @ts-ignore
|
|
53
60
|
setup: (_g = autotest.setup) === null || _g === void 0 ? void 0 : _g.map((step) => this.toLocalShortStep(step)),
|
|
61
|
+
// @ts-ignore
|
|
54
62
|
teardown: (_h = autotest.teardown) === null || _h === void 0 ? void 0 : _h.map((step) => this.toLocalShortStep(step)),
|
|
55
63
|
labels: (_j = autotest.labels) !== null && _j !== void 0 ? _j : undefined,
|
|
56
64
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function handleHttpError(err:
|
|
1
|
+
export declare function handleHttpError(err: any, message?: string): void;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleHttpError = handleHttpError;
|
|
4
|
-
const testit_api_client_1 = require("testit-api-client");
|
|
5
4
|
function handleHttpError(err, message = "") {
|
|
6
|
-
|
|
7
|
-
console.error(`HttpError ${err.statusCode}: ${message}. Error body: \n`, err.body);
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
console.log(message, err);
|
|
11
|
-
}
|
|
5
|
+
console.error(`HttpError ${err.statusCode}: ${message}. Error body: \n`, err.body);
|
|
12
6
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TestitApiClient from "testit-api-client";
|
|
2
2
|
import { BaseService, AdapterConfig } from "../../common";
|
|
3
3
|
import { AutotestGet, AutotestPost, type IAutotestService } from "./autotests.type";
|
|
4
4
|
import { type IAutotestConverter } from "./autotests.converter";
|
|
5
5
|
export declare class AutotestsService extends BaseService implements IAutotestService {
|
|
6
6
|
protected readonly config: AdapterConfig;
|
|
7
|
-
protected _client: AutoTestsApi;
|
|
7
|
+
protected _client: TestitApiClient.AutoTestsApi;
|
|
8
8
|
protected _converter: IAutotestConverter;
|
|
9
9
|
private MAX_TRIES;
|
|
10
10
|
private WAITING_TIME;
|
|
@@ -15,6 +15,6 @@ export declare class AutotestsService extends BaseService implements IAutotestSe
|
|
|
15
15
|
private updateAutotestFromFailed;
|
|
16
16
|
linkToWorkItems(internalId: string, workItemIds: Array<string>): Promise<void>;
|
|
17
17
|
unlinkToWorkItem(internalId: string, workItemId: string): Promise<void>;
|
|
18
|
-
getWorkItemsLinkedToAutoTest(internalId: string): Promise<Array<
|
|
18
|
+
getWorkItemsLinkedToAutoTest(internalId: string): Promise<Array<any>>;
|
|
19
19
|
getAutotestByExternalId(externalId: string): Promise<AutotestGet | null>;
|
|
20
20
|
}
|
|
@@ -8,25 +8,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.AutotestsService = void 0;
|
|
13
|
-
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
const testit_api_client_1 = __importDefault(require("testit-api-client"));
|
|
14
18
|
const common_1 = require("../../common");
|
|
15
19
|
const autotests_type_1 = require("./autotests.type");
|
|
16
20
|
const autotests_converter_1 = require("./autotests.converter");
|
|
17
21
|
const autotests_handler_1 = require("./autotests.handler");
|
|
18
|
-
const autotestApiKey = testit_api_client_1.AutoTestsApiApiKeys["Bearer or PrivateToken"];
|
|
19
22
|
class AutotestsService extends common_1.BaseService {
|
|
20
23
|
constructor(config) {
|
|
21
24
|
super(config);
|
|
22
25
|
this.config = config;
|
|
23
26
|
this.MAX_TRIES = 10;
|
|
24
27
|
this.WAITING_TIME = 100;
|
|
25
|
-
this._client = new testit_api_client_1.AutoTestsApi(
|
|
26
|
-
this._client.setApiKey(autotestApiKey, `PrivateToken ${config.privateToken}`);
|
|
27
|
-
if (config.certValidation !== undefined) {
|
|
28
|
-
this._client.setRejectUnauthorized(config.certValidation);
|
|
29
|
-
}
|
|
28
|
+
this._client = new testit_api_client_1.default.AutoTestsApi();
|
|
30
29
|
this._converter = new autotests_converter_1.AutotestConverter(config);
|
|
31
30
|
}
|
|
32
31
|
createAutotest(autotest) {
|
|
@@ -34,8 +33,9 @@ class AutotestsService extends common_1.BaseService {
|
|
|
34
33
|
const autotestPost = this._converter.toOriginAutotest(autotest);
|
|
35
34
|
(0, common_1.escapeHtmlInObject)(autotestPost);
|
|
36
35
|
return yield this._client
|
|
37
|
-
.createAutoTest(autotestPost)
|
|
36
|
+
.createAutoTest({ autoTestCreateApiModel: autotestPost })
|
|
38
37
|
.then(() => console.log(`Create autotest "${autotest.name}".`))
|
|
38
|
+
// @ts-ignore
|
|
39
39
|
.catch((err) => (0, autotests_handler_1.handleHttpError)(err, `Failed create autotest "${autotestPost.name}"`));
|
|
40
40
|
});
|
|
41
41
|
}
|
|
@@ -44,8 +44,9 @@ class AutotestsService extends common_1.BaseService {
|
|
|
44
44
|
const autotestPost = this._converter.toOriginAutotest(autotest);
|
|
45
45
|
(0, common_1.escapeHtmlInObject)(autotestPost);
|
|
46
46
|
yield this._client
|
|
47
|
-
.updateAutoTest(autotestPost)
|
|
47
|
+
.updateAutoTest({ autoTestUpdateApiModel: autotestPost })
|
|
48
48
|
.then(() => console.log(`Update autotest "${autotest.name}".`))
|
|
49
|
+
// @ts-ignore
|
|
49
50
|
.catch((err) => (0, autotests_handler_1.handleHttpError)(err, `Failed update autotest "${autotestPost.name}"`));
|
|
50
51
|
});
|
|
51
52
|
}
|
|
@@ -86,7 +87,7 @@ class AutotestsService extends common_1.BaseService {
|
|
|
86
87
|
const promises = workItemIds.map((workItemId) => __awaiter(this, void 0, void 0, function* () {
|
|
87
88
|
for (let attempts = 0; attempts < this.MAX_TRIES; attempts++) {
|
|
88
89
|
try {
|
|
89
|
-
yield this._client.linkAutoTestToWorkItem(internalId, { id: workItemId });
|
|
90
|
+
yield this._client.linkAutoTestToWorkItem(internalId, { workItemIdApiModel: { id: workItemId } });
|
|
90
91
|
console.log(`Link autotest ${internalId} to workitem ${workItemId} is successfully`);
|
|
91
92
|
return;
|
|
92
93
|
}
|
|
@@ -103,7 +104,7 @@ class AutotestsService extends common_1.BaseService {
|
|
|
103
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
105
|
for (let attempts = 0; attempts < this.MAX_TRIES; attempts++) {
|
|
105
106
|
try {
|
|
106
|
-
yield this._client.deleteAutoTestLinkFromWorkItem(internalId, workItemId);
|
|
107
|
+
yield this._client.deleteAutoTestLinkFromWorkItem(internalId, { workItemId: workItemId });
|
|
107
108
|
console.log(`Unlink autotest ${internalId} from workitem ${workItemId} is successfully`);
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
@@ -117,8 +118,10 @@ class AutotestsService extends common_1.BaseService {
|
|
|
117
118
|
getWorkItemsLinkedToAutoTest(internalId) {
|
|
118
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
119
120
|
return yield this._client
|
|
120
|
-
.getWorkItemsLinkedToAutoTest(internalId,
|
|
121
|
+
.getWorkItemsLinkedToAutoTest(internalId, {})
|
|
122
|
+
// @ts-ignore
|
|
121
123
|
.then((res) => res.body)
|
|
124
|
+
// @ts-ignore
|
|
122
125
|
.catch((e) => {
|
|
123
126
|
console.log(`Cannot get linked workitems to autotest ${internalId}: ${e}`);
|
|
124
127
|
return [];
|
|
@@ -142,7 +145,8 @@ class AutotestsService extends common_1.BaseService {
|
|
|
142
145
|
includes: includesModel,
|
|
143
146
|
};
|
|
144
147
|
return yield this._client
|
|
145
|
-
.apiV2AutoTestsSearchPost(
|
|
148
|
+
.apiV2AutoTestsSearchPost({ autoTestSearchApiModel: requestModel })
|
|
149
|
+
// @ts-ignore
|
|
146
150
|
.then(({ body }) => body[0])
|
|
147
151
|
.then((autotest) => {
|
|
148
152
|
return autotest ? this._converter.toLocalAutotest(autotest) : null;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { WorkItemIdentifierModel } from "testit-api-client";
|
|
2
1
|
import { Label, Link, ShortStep } from "../../common";
|
|
3
2
|
export declare enum Status {
|
|
4
3
|
PASSED = "Passed",
|
|
@@ -11,7 +10,7 @@ export interface IAutotestService {
|
|
|
11
10
|
loadAutotest(autotest: AutotestPost, status: string): Promise<void>;
|
|
12
11
|
linkToWorkItems(internalId: string, workItemIds: Array<string>): Promise<void>;
|
|
13
12
|
unlinkToWorkItem(internalId: string, workItemId: string): Promise<void>;
|
|
14
|
-
getWorkItemsLinkedToAutoTest(internalId: string): Promise<Array<
|
|
13
|
+
getWorkItemsLinkedToAutoTest(internalId: string): Promise<Array<any>>;
|
|
15
14
|
getAutotestByExternalId(externalId: string): Promise<AutotestGet | null>;
|
|
16
15
|
}
|
|
17
16
|
interface AutotestBase {
|
|
@@ -11,6 +11,18 @@ class TestResultsConverter extends common_1.BaseConverter {
|
|
|
11
11
|
testRunIds: [this.config.testRunId],
|
|
12
12
|
configurationIds: [this.config.configurationId],
|
|
13
13
|
statusCodes: ["InProgress"],
|
|
14
|
+
outcomes: undefined,
|
|
15
|
+
failureCategories: undefined,
|
|
16
|
+
namespace: undefined,
|
|
17
|
+
className: undefined,
|
|
18
|
+
autoTestGlobalIds: undefined,
|
|
19
|
+
name: undefined,
|
|
20
|
+
createdDate: undefined,
|
|
21
|
+
modifiedDate: undefined,
|
|
22
|
+
startedOn: undefined,
|
|
23
|
+
completedOn: undefined,
|
|
24
|
+
duration: undefined,
|
|
25
|
+
resultReasons: undefined
|
|
14
26
|
};
|
|
15
27
|
return model;
|
|
16
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function handleHttpError(err:
|
|
1
|
+
export declare function handleHttpError(err: any, message?: string): void;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleHttpError = handleHttpError;
|
|
4
|
-
const testit_api_client_1 = require("testit-api-client");
|
|
5
4
|
function handleHttpError(err, message = "") {
|
|
6
|
-
|
|
7
|
-
console.error(`HttpError ${err.statusCode}: ${message}. Error body: \n`, err.body);
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
console.log(message, err);
|
|
11
|
-
}
|
|
5
|
+
console.error(`HttpError ${err.statusCode}: ${message}. Error body: \n`, err.body);
|
|
12
6
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TestitApiClient from "testit-api-client";
|
|
2
2
|
import { AdapterConfig, BaseService } from "../../common";
|
|
3
3
|
import { ITestResultsConverter } from "./testresults.converter";
|
|
4
4
|
import { ITestResultsService } from "./testresults.type";
|
|
5
5
|
export declare class TestResultsService extends BaseService implements ITestResultsService {
|
|
6
6
|
protected readonly config: AdapterConfig;
|
|
7
|
-
protected _client: TestResultsApi;
|
|
7
|
+
protected _client: TestitApiClient.TestResultsApi;
|
|
8
8
|
protected _converter: ITestResultsConverter;
|
|
9
9
|
protected _testsLimit: number;
|
|
10
10
|
constructor(config: AdapterConfig);
|
|
@@ -8,24 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.TestResultsService = void 0;
|
|
13
|
-
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
const testit_api_client_1 = __importDefault(require("testit-api-client"));
|
|
14
18
|
const common_1 = require("../../common");
|
|
15
19
|
const testresults_handler_1 = require("./testresults.handler");
|
|
16
20
|
const testresults_converter_1 = require("./testresults.converter");
|
|
17
|
-
const testResultsApiKey = testit_api_client_1.TestResultsApiApiKeys["Bearer or PrivateToken"];
|
|
18
21
|
class TestResultsService extends common_1.BaseService {
|
|
19
22
|
constructor(config) {
|
|
20
23
|
super(config);
|
|
21
24
|
this.config = config;
|
|
22
25
|
this._testsLimit = 100;
|
|
23
|
-
this._client = new testit_api_client_1.TestResultsApi(
|
|
26
|
+
this._client = new testit_api_client_1.default.TestResultsApi();
|
|
24
27
|
this._converter = new testresults_converter_1.TestResultsConverter(config);
|
|
25
|
-
this._client.setApiKey(testResultsApiKey, `PrivateToken ${config.privateToken}`);
|
|
26
|
-
if (config.certValidation !== undefined) {
|
|
27
|
-
this._client.setRejectUnauthorized(config.certValidation);
|
|
28
|
-
}
|
|
29
28
|
}
|
|
30
29
|
getExternalIdsForRun() {
|
|
31
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -35,7 +34,8 @@ class TestResultsService extends common_1.BaseService {
|
|
|
35
34
|
while (true) {
|
|
36
35
|
const testResults = yield this.getTestResults(skip, model);
|
|
37
36
|
if (testResults.length != 0) {
|
|
38
|
-
externalIds = externalIds.concat(testResults.map((
|
|
37
|
+
externalIds = externalIds.concat(testResults.map((// @ts-ignore
|
|
38
|
+
result) => result.autotestExternalId).filter((id) => id !== undefined));
|
|
39
39
|
skip += this._testsLimit;
|
|
40
40
|
continue;
|
|
41
41
|
}
|
|
@@ -46,8 +46,10 @@ class TestResultsService extends common_1.BaseService {
|
|
|
46
46
|
getTestResults(skip, model) {
|
|
47
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
48
|
return yield this._client
|
|
49
|
-
.apiV2TestResultsSearchPost(skip, this._testsLimit,
|
|
49
|
+
.apiV2TestResultsSearchPost({ skip: skip, take: this._testsLimit, testResultsFilterApiModel: model })
|
|
50
|
+
// @ts-ignore
|
|
50
51
|
.then(({ body }) => body)
|
|
52
|
+
// @ts-ignore
|
|
51
53
|
.catch((err) => {
|
|
52
54
|
(0, testresults_handler_1.handleHttpError)(err);
|
|
53
55
|
return [];
|
|
@@ -10,9 +10,11 @@ class TestRunConverter extends common_1.BaseConverter {
|
|
|
10
10
|
this.autotestConverter = new autotests_1.AutotestConverter(config);
|
|
11
11
|
}
|
|
12
12
|
toLocalState(state) {
|
|
13
|
+
// @ts-ignore
|
|
13
14
|
return testit_api_client_1.TestRunState[state];
|
|
14
15
|
}
|
|
15
16
|
toOriginState(state) {
|
|
17
|
+
// @ts-ignore
|
|
16
18
|
return testit_api_client_1.TestRunState[state];
|
|
17
19
|
}
|
|
18
20
|
toOriginAutotestResult(autotest) {
|
|
@@ -30,6 +32,11 @@ class TestRunConverter extends common_1.BaseConverter {
|
|
|
30
32
|
traces: autotest.traces,
|
|
31
33
|
parameters: autotest.parameters,
|
|
32
34
|
properties: autotest.properties,
|
|
35
|
+
failureReasonNames: undefined,
|
|
36
|
+
outcome: undefined,
|
|
37
|
+
startedOn: undefined,
|
|
38
|
+
completedOn: undefined,
|
|
39
|
+
duration: undefined
|
|
33
40
|
};
|
|
34
41
|
if (autotest.duration !== undefined) {
|
|
35
42
|
model.duration = autotest.duration;
|
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TestRunErrorHandler = void 0;
|
|
4
|
-
const testit_api_client_1 = require("testit-api-client");
|
|
5
4
|
class TestRunErrorHandler {
|
|
6
5
|
static handleErrorStartTestRun(err) {
|
|
7
|
-
|
|
8
|
-
console.error(`Error ${err.statusCode}. Failed start test run in system.`, `Message: ${err.message}`);
|
|
9
|
-
}
|
|
10
|
-
else
|
|
11
|
-
throw err;
|
|
6
|
+
console.error(`Error ${err.statusCode}. Failed start test run in system.`, `Message: ${err.message}`);
|
|
12
7
|
}
|
|
13
8
|
static handleErrorCompletedTestRun(err) {
|
|
14
|
-
|
|
15
|
-
console.error(`Error ${err.statusCode}. Failed completed test run in system.`, `Message: ${err.message}`);
|
|
16
|
-
}
|
|
17
|
-
else
|
|
18
|
-
throw err;
|
|
9
|
+
console.error(`Error ${err.statusCode}. Failed completed test run in system.`, `Message: ${err.message}`);
|
|
19
10
|
}
|
|
20
11
|
}
|
|
21
12
|
exports.TestRunErrorHandler = TestRunErrorHandler;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TestitApiClient from "testit-api-client";
|
|
2
2
|
import { AdapterConfig, BaseService } from "../../common";
|
|
3
3
|
import { type ITestRunsService, TestRunId, AutotestResult, TestRunGet } from "./testruns.type";
|
|
4
4
|
import { type ITestRunConverter } from "./testruns.converter";
|
|
5
5
|
export declare class TestRunsService extends BaseService implements ITestRunsService {
|
|
6
6
|
protected readonly config: AdapterConfig;
|
|
7
|
-
protected _client: TestRunsApi;
|
|
7
|
+
protected _client: TestitApiClient.TestRunsApi;
|
|
8
8
|
protected _converter: ITestRunConverter;
|
|
9
9
|
constructor(config: AdapterConfig);
|
|
10
10
|
createTestRun(): Promise<TestRunId>;
|
|
@@ -8,24 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.TestRunsService = void 0;
|
|
13
|
-
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
const testit_api_client_1 = __importDefault(require("testit-api-client"));
|
|
14
18
|
const common_1 = require("../../common");
|
|
15
19
|
const utils_1 = require("../../common/utils");
|
|
16
20
|
const testruns_converter_1 = require("./testruns.converter");
|
|
17
21
|
const testruns_handler_1 = require("./testruns.handler");
|
|
18
|
-
const testRunsApiKey = testit_api_client_1.TestRunsApiApiKeys["Bearer or PrivateToken"];
|
|
19
22
|
class TestRunsService extends common_1.BaseService {
|
|
20
23
|
constructor(config) {
|
|
21
24
|
super(config);
|
|
22
25
|
this.config = config;
|
|
23
|
-
this._client = new testit_api_client_1.TestRunsApi(
|
|
26
|
+
this._client = new testit_api_client_1.default.TestRunsApi();
|
|
24
27
|
this._converter = new testruns_converter_1.TestRunConverter(config);
|
|
25
|
-
this._client.setApiKey(testRunsApiKey, `PrivateToken ${config.privateToken}`);
|
|
26
|
-
if (config.certValidation !== undefined) {
|
|
27
|
-
this._client.setRejectUnauthorized(config.certValidation);
|
|
28
|
-
}
|
|
29
28
|
}
|
|
30
29
|
createTestRun() {
|
|
31
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -34,7 +33,8 @@ class TestRunsService extends common_1.BaseService {
|
|
|
34
33
|
name: this.config.testRunName,
|
|
35
34
|
};
|
|
36
35
|
return yield this._client
|
|
37
|
-
.createEmpty((0, utils_1.escapeHtmlInObject)(createRequest))
|
|
36
|
+
.createEmpty({ createEmptyTestRunApiModel: (0, utils_1.escapeHtmlInObject)(createRequest) })
|
|
37
|
+
// @ts-ignore
|
|
38
38
|
.then(({ body }) => body.id);
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -42,15 +42,19 @@ class TestRunsService extends common_1.BaseService {
|
|
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
43
|
return yield this._client
|
|
44
44
|
.getTestRunById(testRunId)
|
|
45
|
+
// @ts-ignore
|
|
45
46
|
.then(({ body }) => body)
|
|
47
|
+
// @ts-ignore
|
|
46
48
|
.then((run) => this._converter.toLocalTestRun(run));
|
|
47
49
|
});
|
|
48
50
|
}
|
|
49
51
|
updateTestRun(testRun) {
|
|
50
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
53
|
yield this._client
|
|
52
|
-
.updateEmpty(testRun)
|
|
54
|
+
.updateEmpty({ updateEmptyTestRunApiModel: testRun })
|
|
55
|
+
// @ts-ignore
|
|
53
56
|
.then(({ body }) => body)
|
|
57
|
+
// @ts-ignore
|
|
54
58
|
.then((run) => this._converter.toLocalTestRun(run));
|
|
55
59
|
});
|
|
56
60
|
}
|
|
@@ -85,7 +89,7 @@ class TestRunsService extends common_1.BaseService {
|
|
|
85
89
|
const autotestResults = autotests.map((test) => this._converter.toOriginAutotestResult(test));
|
|
86
90
|
(0, utils_1.escapeHtmlInObjectArray)(autotestResults);
|
|
87
91
|
for (const autotestResult of autotestResults) {
|
|
88
|
-
yield this._client.setAutoTestResultsForTestRun(testRunId, [autotestResult]);
|
|
92
|
+
yield this._client.setAutoTestResultsForTestRun(testRunId, { autoTestResultsForTestRunModel: [autotestResult] });
|
|
89
93
|
}
|
|
90
94
|
});
|
|
91
95
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testit-js-commons",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "JavaScript commons for Test IT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"dotenv": "^16.0.3",
|
|
39
|
-
"testit-api-client": "
|
|
39
|
+
"testit-api-client": "7.0.0"
|
|
40
40
|
},
|
|
41
41
|
"files": [
|
|
42
42
|
"lib"
|