testit-js-commons 3.2.8 → 3.2.9

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.
@@ -11,9 +11,7 @@ export declare class AutotestsService extends BaseService implements IAutotestSe
11
11
  constructor(config: AdapterConfig);
12
12
  createAutotest(autotest: AutotestPost): Promise<void>;
13
13
  updateAutotest(autotest: AutotestPost): Promise<void>;
14
- private loadPassedAutotest;
15
- private loadFailedAutotest;
16
- loadAutotest(autotest: AutotestPost, isPassed: boolean): Promise<void>;
14
+ loadAutotest(autotest: AutotestPost, status: string): Promise<void>;
17
15
  linkToWorkItems(internalId: string, workItemIds: Array<string>): Promise<void>;
18
16
  unlinkToWorkItem(internalId: string, workItemId: string): Promise<void>;
19
17
  getWorkItemsLinkedToAutoTest(internalId: string): Promise<Array<WorkItemIdentifierModel>>;
@@ -13,6 +13,7 @@ exports.AutotestsService = void 0;
13
13
  const testit_api_client_1 = require("testit-api-client");
14
14
  const common_1 = require("../../common");
15
15
  const utils_1 = require("../../common/utils");
16
+ const autotests_type_1 = require("./autotests.type");
16
17
  const autotests_converter_1 = require("./autotests.converter");
17
18
  const autotests_handler_1 = require("./autotests.handler");
18
19
  const autotestApiKey = testit_api_client_1.AutoTestsApiApiKeys["Bearer or PrivateToken"];
@@ -49,24 +50,31 @@ class AutotestsService extends common_1.BaseService {
49
50
  .catch((err) => (0, autotests_handler_1.handleHttpError)(err, `Failed update autotest "${autotestPost.name}"`));
50
51
  });
51
52
  }
52
- loadPassedAutotest(autotest) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- const originAutotest = yield this.getAutotestByExternalId(autotest.externalId);
55
- !originAutotest ? yield this.createAutotest(autotest) : yield this.updateAutotest(autotest);
56
- });
57
- }
58
- loadFailedAutotest(autotest) {
53
+ loadAutotest(autotest, status) {
59
54
  return __awaiter(this, void 0, void 0, function* () {
60
55
  var _a, _b;
61
56
  const originAutotest = yield this.getAutotestByExternalId(autotest.externalId);
62
- !originAutotest
63
- ? yield this.createAutotest(autotest)
64
- : 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 }));
65
- });
66
- }
67
- loadAutotest(autotest, isPassed) {
68
- return __awaiter(this, void 0, void 0, function* () {
69
- isPassed ? yield this.loadPassedAutotest(autotest) : yield this.loadFailedAutotest(autotest);
57
+ if (!originAutotest) {
58
+ yield this.createAutotest(autotest);
59
+ return;
60
+ }
61
+ switch (status) {
62
+ case autotests_type_1.Status.PASSED:
63
+ yield this.updateAutotest(autotest);
64
+ return;
65
+ case autotests_type_1.Status.FAILED:
66
+ 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 }));
67
+ return;
68
+ case autotests_type_1.Status.SKIPPED:
69
+ if (originAutotest.name != undefined && originAutotest.externalId != undefined) {
70
+ yield this.updateAutotest(Object.assign(Object.assign({}, originAutotest), { externalId: originAutotest.externalId, name: originAutotest.name }));
71
+ return;
72
+ }
73
+ console.log(`Cannot update skipped autotest ${autotest.name} without name or externalId`);
74
+ return;
75
+ default:
76
+ console.log(`Cannot update autotest ${autotest.name} with unknown status ${status}`);
77
+ }
70
78
  });
71
79
  }
72
80
  linkToWorkItems(internalId, workItemIds) {
@@ -1,9 +1,14 @@
1
1
  import { WorkItemIdentifierModel } from "testit-api-client";
2
2
  import { Label, Link, ShortStep } from "../../common";
3
+ export declare enum Status {
4
+ PASSED = "Passed",
5
+ FAILED = "Failed",
6
+ SKIPPED = "Skipped"
7
+ }
3
8
  export interface IAutotestService {
4
9
  createAutotest(autotest: AutotestPost): Promise<void>;
5
10
  updateAutotest(autotest: AutotestPost): Promise<void>;
6
- loadAutotest(autotest: AutotestPost, isPassed: boolean): Promise<void>;
11
+ loadAutotest(autotest: AutotestPost, status: string): Promise<void>;
7
12
  linkToWorkItems(internalId: string, workItemIds: Array<string>): Promise<void>;
8
13
  unlinkToWorkItem(internalId: string, workItemId: string): Promise<void>;
9
14
  getWorkItemsLinkedToAutoTest(internalId: string): Promise<Array<WorkItemIdentifierModel>>;
@@ -1,2 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Status = void 0;
4
+ var Status;
5
+ (function (Status) {
6
+ Status["PASSED"] = "Passed";
7
+ Status["FAILED"] = "Failed";
8
+ Status["SKIPPED"] = "Skipped";
9
+ })(Status || (exports.Status = Status = {}));
@@ -9,7 +9,7 @@ export declare class BaseStrategy implements IStrategy {
9
9
  protected constructor(config: AdapterConfig);
10
10
  setup(): Promise<void>;
11
11
  teardown(): Promise<void>;
12
- loadAutotest(autotest: AutotestPost, isPassed: boolean): Promise<void>;
12
+ loadAutotest(autotest: AutotestPost, status: string): Promise<void>;
13
13
  private updateTestLinkToWorkItems;
14
14
  loadTestRun(autotests: AutotestResult[]): Promise<void>;
15
15
  }
@@ -29,9 +29,9 @@ class BaseStrategy {
29
29
  yield this.client.testRuns.completeTestRun(testRunId);
30
30
  });
31
31
  }
32
- loadAutotest(autotest, isPassed) {
32
+ loadAutotest(autotest, status) {
33
33
  return __awaiter(this, void 0, void 0, function* () {
34
- yield this.client.autoTests.loadAutotest(autotest, isPassed);
34
+ yield this.client.autoTests.loadAutotest(autotest, status);
35
35
  if (Array.isArray(autotest.workItemIds)) {
36
36
  yield this.updateTestLinkToWorkItems(autotest.externalId, autotest.workItemIds);
37
37
  }
@@ -4,6 +4,6 @@ export interface IStrategy {
4
4
  readonly testsInRun?: Promise<AutotestResultGet[] | undefined>;
5
5
  setup(): Promise<void>;
6
6
  teardown(): Promise<void>;
7
- loadAutotest(autotest: AutotestPost, isPassed: boolean): Promise<void>;
7
+ loadAutotest(autotest: AutotestPost, status: string): Promise<void>;
8
8
  loadTestRun(autotests: AutotestResult[]): Promise<void>;
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testit-js-commons",
3
- "version": "3.2.8",
3
+ "version": "3.2.9",
4
4
  "description": "JavaScript commons for Test IT",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",