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