testit-js-commons 3.2.2-TMS-5.3 → 3.2.3-TMS-CLOUD
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/services/attachments/attachments.service.d.ts +1 -0
- package/lib/services/attachments/attachments.service.js +7 -2
- package/lib/services/autotests/autotests.service.d.ts +1 -0
- package/lib/services/autotests/autotests.service.js +11 -6
- package/lib/services/testruns/testruns.service.d.ts +1 -0
- package/lib/services/testruns/testruns.service.js +9 -5
- package/package.json +2 -2
|
@@ -6,6 +6,7 @@ import { Buffer } from "buffer";
|
|
|
6
6
|
export declare class AttachmentsService extends BaseService implements IAttachmentsService {
|
|
7
7
|
protected readonly config: AdapterConfig;
|
|
8
8
|
protected _client: AttachmentsApi;
|
|
9
|
+
private _options;
|
|
9
10
|
constructor(config: AdapterConfig);
|
|
10
11
|
uploadTextAttachment(content: string | Buffer, filename?: string): Promise<Attachment[]>;
|
|
11
12
|
uploadAttachments(paths: string[]): Promise<Attachment[]>;
|
|
@@ -21,6 +21,10 @@ class AttachmentsService extends base_service_1.BaseService {
|
|
|
21
21
|
this.config = config;
|
|
22
22
|
this._client = new testit_api_client_1.AttachmentsApi(config.url);
|
|
23
23
|
this._client.setApiKey(apiKey, `PrivateToken ${config.privateToken}`);
|
|
24
|
+
this._options = {
|
|
25
|
+
headers: {},
|
|
26
|
+
rejectUnauthorized: config.certValidation,
|
|
27
|
+
};
|
|
24
28
|
}
|
|
25
29
|
uploadTextAttachment(content, filename) {
|
|
26
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -28,7 +32,7 @@ class AttachmentsService extends base_service_1.BaseService {
|
|
|
28
32
|
value: typeof content === "string" ? buffer_1.Buffer.from(content, "utf-8") : content,
|
|
29
33
|
options: { filename: filename !== null && filename !== void 0 ? filename : common_1.Utils.generateFileName() },
|
|
30
34
|
};
|
|
31
|
-
return yield this._client.apiV2AttachmentsPost(request).then(({ body }) => [{ id: body.id }]);
|
|
35
|
+
return yield this._client.apiV2AttachmentsPost(request, this._options).then(({ body }) => [{ id: body.id }]);
|
|
32
36
|
});
|
|
33
37
|
}
|
|
34
38
|
uploadAttachments(paths) {
|
|
@@ -36,6 +40,7 @@ class AttachmentsService extends base_service_1.BaseService {
|
|
|
36
40
|
return yield Promise.all(paths.map((path) => {
|
|
37
41
|
const extension = common_1.Utils.getExtName(path);
|
|
38
42
|
const headers = {};
|
|
43
|
+
const rejectUnauthorized = this._options.rejectUnauthorized;
|
|
39
44
|
if (extension.search("txt") >= 0) {
|
|
40
45
|
headers["Content-Type"] = "text/plain";
|
|
41
46
|
}
|
|
@@ -43,7 +48,7 @@ class AttachmentsService extends base_service_1.BaseService {
|
|
|
43
48
|
headers["Content-Type"] = "image";
|
|
44
49
|
}
|
|
45
50
|
return this._client
|
|
46
|
-
.apiV2AttachmentsPost(common_1.Utils.readStream(path), { headers })
|
|
51
|
+
.apiV2AttachmentsPost(common_1.Utils.readStream(path), { headers, rejectUnauthorized })
|
|
47
52
|
.then(({ body }) => ({ id: body.id }));
|
|
48
53
|
}));
|
|
49
54
|
});
|
|
@@ -9,6 +9,7 @@ export declare class AutotestsService extends BaseService implements IAutotestSe
|
|
|
9
9
|
protected _converter: IAutotestConverter;
|
|
10
10
|
private MAX_TRIES;
|
|
11
11
|
private WAITING_TIME;
|
|
12
|
+
private _options;
|
|
12
13
|
constructor(config: AdapterConfig);
|
|
13
14
|
createAutotest(autotest: AutotestPost): Promise<void>;
|
|
14
15
|
updateAutotest(autotest: AutotestPost): Promise<void>;
|
|
@@ -24,12 +24,16 @@ class AutotestsService extends base_service_1.BaseService {
|
|
|
24
24
|
this._client = new testit_api_client_1.AutoTestsApi(config.url);
|
|
25
25
|
this._client.setApiKey(autotestApiKey, `PrivateToken ${config.privateToken}`);
|
|
26
26
|
this._converter = new autotests_converter_1.AutotestConverter(config);
|
|
27
|
+
this._options = {
|
|
28
|
+
headers: {},
|
|
29
|
+
rejectUnauthorized: config.certValidation,
|
|
30
|
+
};
|
|
27
31
|
}
|
|
28
32
|
createAutotest(autotest) {
|
|
29
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
34
|
const autotestPost = this._converter.toOriginAutotest(autotest);
|
|
31
35
|
return yield this._client
|
|
32
|
-
.createAutoTest(autotestPost)
|
|
36
|
+
.createAutoTest(autotestPost, this._options)
|
|
33
37
|
.then(() => console.log(`Create autotest "${autotest.name}".`))
|
|
34
38
|
.catch((err) => (0, autotests_handler_1.handleHttpError)(err, `Failed create autotest "${autotestPost.name}"`));
|
|
35
39
|
});
|
|
@@ -38,7 +42,7 @@ class AutotestsService extends base_service_1.BaseService {
|
|
|
38
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
43
|
const autotestPost = this._converter.toOriginAutotest(autotest);
|
|
40
44
|
yield this._client
|
|
41
|
-
.updateAutoTest(autotestPost)
|
|
45
|
+
.updateAutoTest(autotestPost, this._options)
|
|
42
46
|
.then(() => console.log(`Update autotest "${autotest.name}".`))
|
|
43
47
|
.catch((err) => (0, autotests_handler_1.handleHttpError)(err, `Failed update autotest "${autotestPost.name}"`));
|
|
44
48
|
});
|
|
@@ -68,7 +72,7 @@ class AutotestsService extends base_service_1.BaseService {
|
|
|
68
72
|
const promises = workItemIds.map((workItemId) => __awaiter(this, void 0, void 0, function* () {
|
|
69
73
|
for (var attempts = 0; attempts < this.MAX_TRIES; attempts++) {
|
|
70
74
|
try {
|
|
71
|
-
yield this._client.linkAutoTestToWorkItem(internalId, { id: workItemId });
|
|
75
|
+
yield this._client.linkAutoTestToWorkItem(internalId, { id: workItemId }, this._options);
|
|
72
76
|
console.log(`Link autotest ${internalId} to workitem ${workItemId} is successfully`);
|
|
73
77
|
return;
|
|
74
78
|
}
|
|
@@ -85,7 +89,7 @@ class AutotestsService extends base_service_1.BaseService {
|
|
|
85
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
90
|
for (var attempts = 0; attempts < this.MAX_TRIES; attempts++) {
|
|
87
91
|
try {
|
|
88
|
-
yield this._client.deleteAutoTestLinkFromWorkItem(internalId, workItemId);
|
|
92
|
+
yield this._client.deleteAutoTestLinkFromWorkItem(internalId, workItemId, this._options);
|
|
89
93
|
console.log(`Unlink autotest ${internalId} from workitem ${workItemId} is successfully`);
|
|
90
94
|
return;
|
|
91
95
|
}
|
|
@@ -98,7 +102,8 @@ class AutotestsService extends base_service_1.BaseService {
|
|
|
98
102
|
}
|
|
99
103
|
getWorkItemsLinkedToAutoTest(internalId) {
|
|
100
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
return yield this._client.getWorkItemsLinkedToAutoTest(internalId
|
|
105
|
+
return yield this._client.getWorkItemsLinkedToAutoTest(internalId, undefined, undefined, this._options)
|
|
106
|
+
.then((res) => res.body)
|
|
102
107
|
.catch((e) => {
|
|
103
108
|
console.log(`Cannot get linked workitems to autotest ${internalId}: ${e}`);
|
|
104
109
|
return [];
|
|
@@ -121,7 +126,7 @@ class AutotestsService extends base_service_1.BaseService {
|
|
|
121
126
|
filter: filterModel,
|
|
122
127
|
includes: includesModel
|
|
123
128
|
};
|
|
124
|
-
return yield this._client.apiV2AutoTestsSearchPost(undefined, undefined, undefined, undefined, undefined, requestModel)
|
|
129
|
+
return yield this._client.apiV2AutoTestsSearchPost(undefined, undefined, undefined, undefined, undefined, requestModel, this._options)
|
|
125
130
|
.then(({ body }) => body[0])
|
|
126
131
|
.then((autotest) => {
|
|
127
132
|
return autotest ? this._converter.toLocalAutotest(autotest) : null;
|
|
@@ -7,6 +7,7 @@ export declare class TestRunsService extends BaseService implements ITestRunsSer
|
|
|
7
7
|
protected readonly config: AdapterConfig;
|
|
8
8
|
protected _client: TestRunsApi;
|
|
9
9
|
protected _converter: ITestRunConverter;
|
|
10
|
+
private _options;
|
|
10
11
|
constructor(config: AdapterConfig);
|
|
11
12
|
createTestRun(): Promise<TestRunId>;
|
|
12
13
|
startTestRun(testRunId: TestRunId): Promise<void>;
|
|
@@ -22,6 +22,10 @@ class TestRunsService extends base_service_1.BaseService {
|
|
|
22
22
|
this._client = new testit_api_client_1.TestRunsApi(config.url);
|
|
23
23
|
this._converter = new testruns_converter_1.TestRunConverter(config);
|
|
24
24
|
this._client.setApiKey(testRunsApiKey, `PrivateToken ${config.privateToken}`);
|
|
25
|
+
this._options = {
|
|
26
|
+
headers: {},
|
|
27
|
+
rejectUnauthorized: config.certValidation,
|
|
28
|
+
};
|
|
25
29
|
}
|
|
26
30
|
createTestRun() {
|
|
27
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -29,7 +33,7 @@ class TestRunsService extends base_service_1.BaseService {
|
|
|
29
33
|
.createEmpty({
|
|
30
34
|
projectId: this.config.projectId,
|
|
31
35
|
name: this.config.testRunName,
|
|
32
|
-
})
|
|
36
|
+
}, this._options)
|
|
33
37
|
.then(({ body }) => body.id);
|
|
34
38
|
});
|
|
35
39
|
}
|
|
@@ -38,7 +42,7 @@ class TestRunsService extends base_service_1.BaseService {
|
|
|
38
42
|
try {
|
|
39
43
|
const testRun = yield this.getTestRun(testRunId);
|
|
40
44
|
if (testRun.stateName !== "Completed" && testRun.stateName !== "InProgress") {
|
|
41
|
-
yield this._client.startTestRun(testRunId);
|
|
45
|
+
yield this._client.startTestRun(testRunId, this._options);
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
catch (err) {
|
|
@@ -51,7 +55,7 @@ class TestRunsService extends base_service_1.BaseService {
|
|
|
51
55
|
try {
|
|
52
56
|
const testRun = yield this.getTestRun(testRunId);
|
|
53
57
|
if (testRun.stateName === "InProgress") {
|
|
54
|
-
yield this._client.completeTestRun(testRunId);
|
|
58
|
+
yield this._client.completeTestRun(testRunId, this._options);
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
catch (err) {
|
|
@@ -63,7 +67,7 @@ class TestRunsService extends base_service_1.BaseService {
|
|
|
63
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
68
|
const autotestResults = autotests.map((test) => this._converter.toOriginAutotestResult(test));
|
|
65
69
|
for (const autotestResult of autotestResults) {
|
|
66
|
-
yield this._client.setAutoTestResultsForTestRun(testRunId, [autotestResult]);
|
|
70
|
+
yield this._client.setAutoTestResultsForTestRun(testRunId, [autotestResult], this._options);
|
|
67
71
|
}
|
|
68
72
|
});
|
|
69
73
|
}
|
|
@@ -77,7 +81,7 @@ class TestRunsService extends base_service_1.BaseService {
|
|
|
77
81
|
getTestRun(testRunId) {
|
|
78
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
83
|
return yield this._client
|
|
80
|
-
.getTestRunById(testRunId)
|
|
84
|
+
.getTestRunById(testRunId, this._options)
|
|
81
85
|
.then(({ body }) => body)
|
|
82
86
|
.then((run) => this._converter.toLocalTestRun(run));
|
|
83
87
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testit-js-commons",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.3-TMS-CLOUD",
|
|
4
4
|
"description": "JavaScript commons for Test IT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"dotenv": "^16.0.3",
|
|
28
|
-
"testit-api-client": "6.0.
|
|
28
|
+
"testit-api-client": "6.0.2-TMS-5.3"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"lib"
|