testit-js-commons 3.4.7 → 3.4.10
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.
|
@@ -12,6 +12,7 @@ export declare class AutotestsService extends BaseService implements IAutotestSe
|
|
|
12
12
|
createAutotest(autotest: AutotestPost): Promise<void>;
|
|
13
13
|
updateAutotest(autotest: AutotestPost): Promise<void>;
|
|
14
14
|
loadAutotest(autotest: AutotestPost, status: string): Promise<void>;
|
|
15
|
+
private updateAutotestFromFailed;
|
|
15
16
|
linkToWorkItems(internalId: string, workItemIds: Array<string>): Promise<void>;
|
|
16
17
|
unlinkToWorkItem(internalId: string, workItemId: string): Promise<void>;
|
|
17
18
|
getWorkItemsLinkedToAutoTest(internalId: string): Promise<Array<WorkItemIdentifierModel>>;
|
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.AutotestsService = void 0;
|
|
13
13
|
const testit_api_client_1 = require("testit-api-client");
|
|
14
14
|
const common_1 = require("../../common");
|
|
15
|
-
const utils_1 = require("../../common/utils");
|
|
16
15
|
const autotests_type_1 = require("./autotests.type");
|
|
17
16
|
const autotests_converter_1 = require("./autotests.converter");
|
|
18
17
|
const autotests_handler_1 = require("./autotests.handler");
|
|
@@ -33,7 +32,7 @@ class AutotestsService extends common_1.BaseService {
|
|
|
33
32
|
createAutotest(autotest) {
|
|
34
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
34
|
const autotestPost = this._converter.toOriginAutotest(autotest);
|
|
36
|
-
(0,
|
|
35
|
+
(0, common_1.escapeHtmlInObject)(autotestPost);
|
|
37
36
|
return yield this._client
|
|
38
37
|
.createAutoTest(autotestPost)
|
|
39
38
|
.then(() => console.log(`Create autotest "${autotest.name}".`))
|
|
@@ -43,7 +42,7 @@ class AutotestsService extends common_1.BaseService {
|
|
|
43
42
|
updateAutotest(autotest) {
|
|
44
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
44
|
const autotestPost = this._converter.toOriginAutotest(autotest);
|
|
46
|
-
(0,
|
|
45
|
+
(0, common_1.escapeHtmlInObject)(autotestPost);
|
|
47
46
|
yield this._client
|
|
48
47
|
.updateAutoTest(autotestPost)
|
|
49
48
|
.then(() => console.log(`Update autotest "${autotest.name}".`))
|
|
@@ -52,7 +51,6 @@ class AutotestsService extends common_1.BaseService {
|
|
|
52
51
|
}
|
|
53
52
|
loadAutotest(autotest, status) {
|
|
54
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
var _a, _b;
|
|
56
54
|
const originAutotest = yield this.getAutotestByExternalId(autotest.externalId);
|
|
57
55
|
if (!originAutotest) {
|
|
58
56
|
yield this.createAutotest(autotest);
|
|
@@ -63,11 +61,11 @@ class AutotestsService extends common_1.BaseService {
|
|
|
63
61
|
yield this.updateAutotest(autotest);
|
|
64
62
|
return;
|
|
65
63
|
case autotests_type_1.Status.FAILED:
|
|
66
|
-
yield this.
|
|
64
|
+
yield this.updateAutotestFromFailed(originAutotest, autotest);
|
|
67
65
|
return;
|
|
68
66
|
case autotests_type_1.Status.SKIPPED:
|
|
69
67
|
if (originAutotest.name != undefined && originAutotest.externalId != undefined) {
|
|
70
|
-
yield this.
|
|
68
|
+
yield this.updateAutotestFromFailed(originAutotest, autotest);
|
|
71
69
|
return;
|
|
72
70
|
}
|
|
73
71
|
console.log(`Cannot update skipped autotest ${autotest.name} without name or externalId`);
|
|
@@ -77,10 +75,16 @@ class AutotestsService extends common_1.BaseService {
|
|
|
77
75
|
}
|
|
78
76
|
});
|
|
79
77
|
}
|
|
78
|
+
updateAutotestFromFailed(originAutotest, autotest) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
yield this.updateAutotest(Object.assign(Object.assign({}, originAutotest), { externalId: (_a = originAutotest === null || originAutotest === void 0 ? void 0 : originAutotest.externalId) !== null && _a !== void 0 ? _a : autotest.externalId, name: (_b = originAutotest === null || originAutotest === void 0 ? void 0 : originAutotest.name) !== null && _b !== void 0 ? _b : autotest.name, links: autotest.links, externalKey: autotest.externalKey, steps: autotest.steps, setup: autotest.setup, teardown: autotest.teardown, title: autotest.title, description: autotest.description, namespace: autotest.namespace, classname: autotest.classname, labels: autotest.labels, workItemIds: autotest.workItemIds, isFlaky: autotest.isFlaky, shouldCreateWorkItem: autotest.shouldCreateWorkItem }));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
80
84
|
linkToWorkItems(internalId, workItemIds) {
|
|
81
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
86
|
const promises = workItemIds.map((workItemId) => __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
for (
|
|
87
|
+
for (let attempts = 0; attempts < this.MAX_TRIES; attempts++) {
|
|
84
88
|
try {
|
|
85
89
|
yield this._client.linkAutoTestToWorkItem(internalId, { id: workItemId });
|
|
86
90
|
console.log(`Link autotest ${internalId} to workitem ${workItemId} is successfully`);
|
|
@@ -88,7 +92,7 @@ class AutotestsService extends common_1.BaseService {
|
|
|
88
92
|
}
|
|
89
93
|
catch (e) {
|
|
90
94
|
console.log(`Cannot link autotest ${internalId} to work item ${workItemId}: ${e}`);
|
|
91
|
-
yield new Promise(f => setTimeout(f, this.WAITING_TIME));
|
|
95
|
+
yield new Promise((f) => setTimeout(f, this.WAITING_TIME));
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
98
|
}));
|
|
@@ -97,7 +101,7 @@ class AutotestsService extends common_1.BaseService {
|
|
|
97
101
|
}
|
|
98
102
|
unlinkToWorkItem(internalId, workItemId) {
|
|
99
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
for (
|
|
104
|
+
for (let attempts = 0; attempts < this.MAX_TRIES; attempts++) {
|
|
101
105
|
try {
|
|
102
106
|
yield this._client.deleteAutoTestLinkFromWorkItem(internalId, workItemId);
|
|
103
107
|
console.log(`Unlink autotest ${internalId} from workitem ${workItemId} is successfully`);
|
|
@@ -105,14 +109,15 @@ class AutotestsService extends common_1.BaseService {
|
|
|
105
109
|
}
|
|
106
110
|
catch (e) {
|
|
107
111
|
console.log(`Cannot unlink autotest ${internalId} to work item ${workItemId}: ${e}`);
|
|
108
|
-
yield new Promise(f => setTimeout(f, this.WAITING_TIME));
|
|
112
|
+
yield new Promise((f) => setTimeout(f, this.WAITING_TIME));
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
115
|
});
|
|
112
116
|
}
|
|
113
117
|
getWorkItemsLinkedToAutoTest(internalId) {
|
|
114
118
|
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
return yield this._client
|
|
119
|
+
return yield this._client
|
|
120
|
+
.getWorkItemsLinkedToAutoTest(internalId, undefined, undefined)
|
|
116
121
|
.then((res) => res.body)
|
|
117
122
|
.catch((e) => {
|
|
118
123
|
console.log(`Cannot get linked workitems to autotest ${internalId}: ${e}`);
|
|
@@ -130,13 +135,14 @@ class AutotestsService extends common_1.BaseService {
|
|
|
130
135
|
const includesModel = {
|
|
131
136
|
includeSteps: false,
|
|
132
137
|
includeLinks: false,
|
|
133
|
-
includeLabels: false
|
|
138
|
+
includeLabels: false,
|
|
134
139
|
};
|
|
135
140
|
const requestModel = {
|
|
136
141
|
filter: filterModel,
|
|
137
|
-
includes: includesModel
|
|
142
|
+
includes: includesModel,
|
|
138
143
|
};
|
|
139
|
-
return yield this._client
|
|
144
|
+
return yield this._client
|
|
145
|
+
.apiV2AutoTestsSearchPost(undefined, undefined, undefined, undefined, undefined, requestModel)
|
|
140
146
|
.then(({ body }) => body[0])
|
|
141
147
|
.then((autotest) => {
|
|
142
148
|
return autotest ? this._converter.toLocalAutotest(autotest) : null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testit-js-commons",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.10",
|
|
4
4
|
"description": "JavaScript commons for Test IT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"name": "Integration team",
|
|
18
18
|
"email": "integrations@testit.software"
|
|
19
19
|
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/testit-tms/adapters-js.git"
|
|
23
|
+
},
|
|
20
24
|
"license": "Apache-2.0",
|
|
21
25
|
"devDependencies": {
|
|
22
26
|
"@types/jest": "^27.5.2",
|