testit-js-commons 3.4.3 → 3.4.5

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.
@@ -18,11 +18,11 @@ export interface EnvironmentOptions {
18
18
  TMS_CONFIGURATION_ID: string;
19
19
  TMS_TEST_RUN_ID: string;
20
20
  TMS_TEST_RUN_NAME: string;
21
- TMS_ADAPTER_MODE: AdapterMode;
21
+ TMS_ADAPTER_MODE: string;
22
22
  TMS_CONFIG_FILE: string;
23
- TMS_AUTOMATIC_CREATION_TEST_CASES: boolean;
24
- TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES: boolean;
25
- TMS_CERT_VALIDATION: boolean;
23
+ TMS_AUTOMATIC_CREATION_TEST_CASES: string;
24
+ TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES: string;
25
+ TMS_CERT_VALIDATION: string;
26
26
  }
27
27
  export interface ProcessEnvOptions {
28
28
  TMS_URL?: string;
@@ -31,11 +31,11 @@ export interface ProcessEnvOptions {
31
31
  TMS_CONFIGURATION_ID?: string;
32
32
  TMS_TEST_RUN_ID?: string;
33
33
  TMS_TEST_RUN_NAME?: string;
34
- TMS_ADAPTER_MODE?: AdapterMode;
34
+ TMS_ADAPTER_MODE?: string;
35
35
  TMS_CONFIG_FILE?: string;
36
- TMS_AUTOMATIC_CREATION_TEST_CASES?: boolean;
37
- TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES?: boolean;
38
- TMS_CERT_VALIDATION?: boolean;
36
+ TMS_AUTOMATIC_CREATION_TEST_CASES?: string;
37
+ TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES?: string;
38
+ TMS_CERT_VALIDATION?: string;
39
39
  }
40
40
  export interface AdapterConfig {
41
41
  url: string;
@@ -68,11 +68,11 @@ class ConfigComposer {
68
68
  testRunId: this.resolveAllProperties(file.testRunId, env === null || env === void 0 ? void 0 : env.TMS_TEST_RUN_ID, base === null || base === void 0 ? void 0 : base.testRunId),
69
69
  testRunName: this.resolveAllProperties(file.testRunName, env === null || env === void 0 ? void 0 : env.TMS_TEST_RUN_NAME, base === null || base === void 0 ? void 0 : base.testRunName) == "" ? undefined : this.resolveAllProperties(file.testRunName, env === null || env === void 0 ? void 0 : env.TMS_TEST_RUN_NAME, base === null || base === void 0 ? void 0 : base.testRunName),
70
70
  privateToken: this.resolveAllProperties(file.privateToken, env === null || env === void 0 ? void 0 : env.TMS_PRIVATE_TOKEN, base === null || base === void 0 ? void 0 : base.privateToken),
71
- adapterMode: (_c = (_b = (_a = base === null || base === void 0 ? void 0 : base.adapterMode) !== null && _a !== void 0 ? _a : env === null || env === void 0 ? void 0 : env.TMS_ADAPTER_MODE) !== null && _b !== void 0 ? _b : file === null || file === void 0 ? void 0 : file.adapterMode) !== null && _c !== void 0 ? _c : 0,
71
+ adapterMode: (_c = (_b = (_a = base === null || base === void 0 ? void 0 : base.adapterMode) !== null && _a !== void 0 ? _a : stringToAdapterMode(env === null || env === void 0 ? void 0 : env.TMS_ADAPTER_MODE)) !== null && _b !== void 0 ? _b : file === null || file === void 0 ? void 0 : file.adapterMode) !== null && _c !== void 0 ? _c : 0,
72
72
  configurationId: this.resolveAllProperties(file.configurationId, env === null || env === void 0 ? void 0 : env.TMS_CONFIGURATION_ID, base === null || base === void 0 ? void 0 : base.configurationId),
73
- automaticCreationTestCases: (_f = (_e = (_d = file.automaticCreationTestCases) !== null && _d !== void 0 ? _d : env === null || env === void 0 ? void 0 : env.TMS_AUTOMATIC_CREATION_TEST_CASES) !== null && _e !== void 0 ? _e : base === null || base === void 0 ? void 0 : base.automaticCreationTestCases) !== null && _f !== void 0 ? _f : false,
74
- automaticUpdationLinksToTestCases: (_j = (_h = (_g = file.automaticUpdationLinksToTestCases) !== null && _g !== void 0 ? _g : env === null || env === void 0 ? void 0 : env.TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES) !== null && _h !== void 0 ? _h : base === null || base === void 0 ? void 0 : base.automaticUpdationLinksToTestCases) !== null && _j !== void 0 ? _j : false,
75
- certValidation: (_m = (_l = (_k = file.certValidation) !== null && _k !== void 0 ? _k : env === null || env === void 0 ? void 0 : env.TMS_CERT_VALIDATION) !== null && _l !== void 0 ? _l : base === null || base === void 0 ? void 0 : base.certValidation) !== null && _m !== void 0 ? _m : true
73
+ automaticCreationTestCases: (_f = (_e = (_d = file.automaticCreationTestCases) !== null && _d !== void 0 ? _d : stringToBoolean(env === null || env === void 0 ? void 0 : env.TMS_AUTOMATIC_CREATION_TEST_CASES)) !== null && _e !== void 0 ? _e : base === null || base === void 0 ? void 0 : base.automaticCreationTestCases) !== null && _f !== void 0 ? _f : false,
74
+ automaticUpdationLinksToTestCases: (_j = (_h = (_g = file.automaticUpdationLinksToTestCases) !== null && _g !== void 0 ? _g : stringToBoolean(env === null || env === void 0 ? void 0 : env.TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES)) !== null && _h !== void 0 ? _h : base === null || base === void 0 ? void 0 : base.automaticUpdationLinksToTestCases) !== null && _j !== void 0 ? _j : false,
75
+ certValidation: (_m = (_l = (_k = file.certValidation) !== null && _k !== void 0 ? _k : stringToBoolean(env === null || env === void 0 ? void 0 : env.TMS_CERT_VALIDATION)) !== null && _l !== void 0 ? _l : base === null || base === void 0 ? void 0 : base.certValidation) !== null && _m !== void 0 ? _m : true
76
76
  };
77
77
  }
78
78
  merge(env, base) {
@@ -83,11 +83,11 @@ class ConfigComposer {
83
83
  testRunId: this.resolveProperties(env === null || env === void 0 ? void 0 : env.TMS_TEST_RUN_ID, base === null || base === void 0 ? void 0 : base.testRunId),
84
84
  testRunName: this.resolveProperties(env === null || env === void 0 ? void 0 : env.TMS_TEST_RUN_NAME, base === null || base === void 0 ? void 0 : base.testRunName) == "" ? undefined : this.resolveProperties(env === null || env === void 0 ? void 0 : env.TMS_TEST_RUN_NAME, base === null || base === void 0 ? void 0 : base.testRunName),
85
85
  privateToken: this.resolveProperties(env === null || env === void 0 ? void 0 : env.TMS_PRIVATE_TOKEN, base === null || base === void 0 ? void 0 : base.privateToken),
86
- adapterMode: (_b = (_a = base === null || base === void 0 ? void 0 : base.adapterMode) !== null && _a !== void 0 ? _a : env === null || env === void 0 ? void 0 : env.TMS_ADAPTER_MODE) !== null && _b !== void 0 ? _b : 0,
86
+ adapterMode: (_b = (_a = base === null || base === void 0 ? void 0 : base.adapterMode) !== null && _a !== void 0 ? _a : stringToAdapterMode(env === null || env === void 0 ? void 0 : env.TMS_ADAPTER_MODE)) !== null && _b !== void 0 ? _b : 0,
87
87
  configurationId: this.resolveProperties(env === null || env === void 0 ? void 0 : env.TMS_CONFIGURATION_ID, base === null || base === void 0 ? void 0 : base.configurationId),
88
- automaticCreationTestCases: (_d = (_c = env === null || env === void 0 ? void 0 : env.TMS_AUTOMATIC_CREATION_TEST_CASES) !== null && _c !== void 0 ? _c : base === null || base === void 0 ? void 0 : base.automaticCreationTestCases) !== null && _d !== void 0 ? _d : false,
89
- automaticUpdationLinksToTestCases: (_f = (_e = env === null || env === void 0 ? void 0 : env.TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES) !== null && _e !== void 0 ? _e : base === null || base === void 0 ? void 0 : base.automaticUpdationLinksToTestCases) !== null && _f !== void 0 ? _f : false,
90
- certValidation: (_h = (_g = env === null || env === void 0 ? void 0 : env.TMS_CERT_VALIDATION) !== null && _g !== void 0 ? _g : base === null || base === void 0 ? void 0 : base.certValidation) !== null && _h !== void 0 ? _h : true
88
+ automaticCreationTestCases: (_d = (_c = stringToBoolean(env === null || env === void 0 ? void 0 : env.TMS_AUTOMATIC_CREATION_TEST_CASES)) !== null && _c !== void 0 ? _c : base === null || base === void 0 ? void 0 : base.automaticCreationTestCases) !== null && _d !== void 0 ? _d : false,
89
+ automaticUpdationLinksToTestCases: (_f = (_e = stringToBoolean(env === null || env === void 0 ? void 0 : env.TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES)) !== null && _e !== void 0 ? _e : base === null || base === void 0 ? void 0 : base.automaticUpdationLinksToTestCases) !== null && _f !== void 0 ? _f : false,
90
+ certValidation: (_h = (_g = stringToBoolean(env === null || env === void 0 ? void 0 : env.TMS_CERT_VALIDATION)) !== null && _g !== void 0 ? _g : base === null || base === void 0 ? void 0 : base.certValidation) !== null && _h !== void 0 ? _h : true
91
91
  };
92
92
  }
93
93
  mergeEnv(dotEnv, processEnv) {
@@ -175,10 +175,10 @@ function parseProcessEnvConfig() {
175
175
  TMS_CONFIGURATION_ID: process.env.TMS_CONFIGURATION_ID,
176
176
  TMS_TEST_RUN_ID: process.env.TMS_TEST_RUN_ID,
177
177
  TMS_TEST_RUN_NAME: process.env.TMS_TEST_RUN_NAME,
178
- TMS_ADAPTER_MODE: process.env.TMS_ADAPTER_MODE ? stringToAdapterMode(process.env.TMS_ADAPTER_MODE) : undefined,
179
- TMS_CERT_VALIDATION: process.env.TMS_CERT_VALIDATION ? stringToBoolean(process.env.TMS_CERT_VALIDATION) : undefined,
180
- TMS_AUTOMATIC_CREATION_TEST_CASES: process.env.TMS_AUTOMATIC_CREATION_TEST_CASES ? stringToBoolean(process.env.TMS_AUTOMATIC_CREATION_TEST_CASES) : undefined,
181
- TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES: process.env.TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES ? stringToBoolean(process.env.TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES) : undefined,
178
+ TMS_ADAPTER_MODE: process.env.TMS_ADAPTER_MODE,
179
+ TMS_CERT_VALIDATION: process.env.TMS_CERT_VALIDATION,
180
+ TMS_AUTOMATIC_CREATION_TEST_CASES: process.env.TMS_AUTOMATIC_CREATION_TEST_CASES,
181
+ TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES: process.env.TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES,
182
182
  TMS_CONFIG_FILE: process.env.TMS_PRIVATE_TOKEN,
183
183
  };
184
184
  }
@@ -195,5 +195,12 @@ function stringToAdapterMode(str) {
195
195
  }
196
196
  }
197
197
  function stringToBoolean(str) {
198
- return ((str === null || str === void 0 ? void 0 : str.toLowerCase()) === "true");
198
+ switch (str === null || str === void 0 ? void 0 : str.toLowerCase()) {
199
+ case "true":
200
+ return true;
201
+ case "false":
202
+ return false;
203
+ default:
204
+ return undefined;
205
+ }
199
206
  }
@@ -52,6 +52,8 @@ class TestRunConverter extends common_1.BaseConverter {
52
52
  description: (_c = testRun.description) !== null && _c !== void 0 ? _c : undefined,
53
53
  launchSource: (_d = testRun.launchSource) !== null && _d !== void 0 ? _d : undefined,
54
54
  stateName: this.toLocalState(testRun.stateName),
55
+ attachments: testRun.attachments,
56
+ links: testRun.links,
55
57
  };
56
58
  }
57
59
  }
@@ -8,8 +8,9 @@ export declare class TestRunsService extends BaseService implements ITestRunsSer
8
8
  protected _converter: ITestRunConverter;
9
9
  constructor(config: AdapterConfig);
10
10
  createTestRun(): Promise<TestRunId>;
11
+ getTestRun(testRunId: TestRunId): Promise<TestRunGet>;
12
+ updateTestRun(testRun: TestRunGet): Promise<void>;
11
13
  startTestRun(testRunId: TestRunId): Promise<void>;
12
14
  completeTestRun(testRunId: TestRunId): Promise<void>;
13
15
  loadAutotests(testRunId: string, autotests: Array<AutotestResult>): Promise<void>;
14
- getTestRun(testRunId: TestRunId): Promise<TestRunGet>;
15
16
  }
@@ -38,6 +38,22 @@ class TestRunsService extends common_1.BaseService {
38
38
  .then(({ body }) => body.id);
39
39
  });
40
40
  }
41
+ getTestRun(testRunId) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ return yield this._client
44
+ .getTestRunById(testRunId)
45
+ .then(({ body }) => body)
46
+ .then((run) => this._converter.toLocalTestRun(run));
47
+ });
48
+ }
49
+ updateTestRun(testRun) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ yield this._client
52
+ .updateEmpty(testRun)
53
+ .then(({ body }) => body)
54
+ .then((run) => this._converter.toLocalTestRun(run));
55
+ });
56
+ }
41
57
  startTestRun(testRunId) {
42
58
  return __awaiter(this, void 0, void 0, function* () {
43
59
  try {
@@ -73,13 +89,5 @@ class TestRunsService extends common_1.BaseService {
73
89
  }
74
90
  });
75
91
  }
76
- getTestRun(testRunId) {
77
- return __awaiter(this, void 0, void 0, function* () {
78
- return yield this._client
79
- .getTestRunById(testRunId)
80
- .then(({ body }) => body)
81
- .then((run) => this._converter.toLocalTestRun(run));
82
- });
83
- }
84
92
  }
85
93
  exports.TestRunsService = TestRunsService;
@@ -10,6 +10,15 @@ export interface TestRunGet {
10
10
  startedOn?: Date;
11
11
  completedOn?: Date;
12
12
  stateName: RunState;
13
+ attachments?: Array<Attachment>;
14
+ links?: Array<LinkGet>;
15
+ }
16
+ export interface LinkGet {
17
+ url: string;
18
+ id?: string | null;
19
+ title?: string | null;
20
+ description?: string | null;
21
+ hasInfo: boolean;
13
22
  }
14
23
  interface AutotestResultBase {
15
24
  links?: Array<Link>;
@@ -46,6 +55,7 @@ export interface AutotestResultGet extends AutotestResultBase {
46
55
  export interface ITestRunsService {
47
56
  createTestRun(): Promise<string>;
48
57
  getTestRun(testRunId: TestRunId): Promise<TestRunGet>;
58
+ updateTestRun(testRun: TestRunGet): Promise<void>;
49
59
  startTestRun(testRunId: TestRunId): Promise<void>;
50
60
  completeTestRun(testRunId: TestRunId): Promise<void>;
51
61
  loadAutotests(testRunId: string, autotests: Array<AutotestResult>): Promise<void>;
@@ -12,4 +12,5 @@ export declare class BaseStrategy implements IStrategy {
12
12
  loadAutotest(autotest: AutotestPost, status: string): Promise<void>;
13
13
  private updateTestLinkToWorkItems;
14
14
  loadTestRun(autotests: AutotestResult[]): Promise<void>;
15
+ protected updateTestRun(config: AdapterConfig): Promise<void>;
15
16
  }
@@ -65,5 +65,19 @@ class BaseStrategy {
65
65
  return yield this.client.testRuns.loadAutotests(testRunId, autotests);
66
66
  });
67
67
  }
68
+ updateTestRun(config) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ const testRunId = config.testRunId;
71
+ if (config.testRunName == undefined) {
72
+ return;
73
+ }
74
+ const testRun = yield this.client.testRuns.getTestRun(testRunId);
75
+ if (config.testRunName == testRun.name) {
76
+ return;
77
+ }
78
+ testRun.name = config.testRunName;
79
+ this.client.testRuns.updateTestRun(testRun);
80
+ });
81
+ }
68
82
  }
69
83
  exports.BaseStrategy = BaseStrategy;
@@ -7,6 +7,7 @@ class FirstStrategy extends base_strategy_1.BaseStrategy {
7
7
  super(config);
8
8
  if (!config.testRunId)
9
9
  throw new Error("testRunId is required when mode is 1");
10
+ this.updateTestRun(config);
10
11
  }
11
12
  }
12
13
  exports.FirstStrategy = FirstStrategy;
@@ -7,6 +7,7 @@ class ZeroStrategy extends base_strategy_1.BaseStrategy {
7
7
  super(config);
8
8
  if (!config.testRunId)
9
9
  throw new Error("testRunId is required when mode is 0");
10
+ this.updateTestRun(config);
10
11
  this.testsInRun = this.client.testResults.getExternalIdsForRun();
11
12
  }
12
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testit-js-commons",
3
- "version": "3.4.3",
3
+ "version": "3.4.5",
4
4
  "description": "JavaScript commons for Test IT",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",