testit-api-client 1.0.5 → 1.0.7
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/LICENSE.md +1 -1
- package/dist/client.d.ts +1 -0
- package/dist/client.js +26 -18
- package/dist/index.js +5 -1
- package/dist/types/autotest.d.ts +1 -0
- package/dist/types/autotestResults.d.ts +1 -1
- package/dist/types/capabilities.d.ts +1 -1
- package/dist/types/client.d.ts +2 -2
- package/dist/types/config.d.ts +1 -0
- package/dist/types/index.js +5 -1
- package/dist/types/link.d.ts +1 -1
- package/dist/types/outcome.d.ts +1 -1
- package/dist/types/parameters.d.ts +1 -1
- package/dist/types/properties.d.ts +1 -1
- package/dist/types/testResult.d.ts +1 -1
- package/dist/types/testRun.d.ts +1 -1
- package/dist/validation.js +1 -0
- package/package.json +52 -52
- /package/{README.MD → README.md} +0 -0
package/LICENSE.md
CHANGED
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
same "printed page" as the copyright notice for easier
|
|
188
188
|
identification within third-party archives.
|
|
189
189
|
|
|
190
|
-
Copyright
|
|
190
|
+
Copyright 2022 TestGear
|
|
191
191
|
|
|
192
192
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
193
|
you may not use this file except in compliance with the License.
|
package/dist/client.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare class Client implements IClient {
|
|
|
10
10
|
updateAutotest(autotest: AutotestPut): Promise<void>;
|
|
11
11
|
linkToWorkItem(autotestId: string, workItem: WorkItemId): Promise<void>;
|
|
12
12
|
getTestRun(testRunId: string): TestRunGet;
|
|
13
|
+
getTestRunById(testRunId: string): Promise<TestRunGet>;
|
|
13
14
|
createTestRun(testRun: TestRunPost): Promise<TestRunGet>;
|
|
14
15
|
startTestRun(testRunId: string): Promise<void>;
|
|
15
16
|
loadTestRunResults(testRunId: string, results: AutotestResultsForTestRun[]): Promise<string[]>;
|
package/dist/client.js
CHANGED
|
@@ -22,7 +22,7 @@ const form_data_1 = __importDefault(require("form-data"));
|
|
|
22
22
|
const path_1 = require("path");
|
|
23
23
|
const validation_1 = require("./validation");
|
|
24
24
|
// TODO: implement via the base client
|
|
25
|
-
|
|
25
|
+
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
|
|
26
26
|
class Client {
|
|
27
27
|
constructor(config) {
|
|
28
28
|
const { configFile } = config, restConfig = __rest(config, ["configFile"]);
|
|
@@ -32,7 +32,7 @@ class Client {
|
|
|
32
32
|
}
|
|
33
33
|
finalConfig = Client.mergeConfig(finalConfig, this.readEnvConfig());
|
|
34
34
|
finalConfig = Client.mergeConfig(finalConfig, this.readCliConfig());
|
|
35
|
-
this.config = (0, validation_1.validateConfig)(
|
|
35
|
+
this.config = (0, validation_1.validateConfig)(config);
|
|
36
36
|
const baseURL = new URL('/api/v2', this.config.url).toString();
|
|
37
37
|
this.axios = axios_1.default.create({
|
|
38
38
|
baseURL,
|
|
@@ -48,7 +48,7 @@ class Client {
|
|
|
48
48
|
await axios_1.default.get(new URL('version.json', this.config.url).toString());
|
|
49
49
|
}
|
|
50
50
|
catch (err) {
|
|
51
|
-
throw new Error('Cannot connect to
|
|
51
|
+
throw new Error('Cannot connect to TMS');
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
// TODO: add query object
|
|
@@ -87,6 +87,11 @@ class Client {
|
|
|
87
87
|
this.request.send(null);
|
|
88
88
|
return JSON.parse(this.request.responseText);
|
|
89
89
|
}
|
|
90
|
+
async getTestRunById(testRunId) {
|
|
91
|
+
return this.axios
|
|
92
|
+
.get(`/testRuns/${testRunId}`)
|
|
93
|
+
.then((res) => res.data);
|
|
94
|
+
}
|
|
90
95
|
async createTestRun(testRun) {
|
|
91
96
|
return this.axios
|
|
92
97
|
.post('/testRuns', testRun)
|
|
@@ -118,28 +123,30 @@ class Client {
|
|
|
118
123
|
readCliConfig() {
|
|
119
124
|
const args = (0, minimist_1.default)(process.argv.slice(2));
|
|
120
125
|
let config = {};
|
|
121
|
-
if (args['
|
|
122
|
-
config = this.readConfigFile(args['
|
|
126
|
+
if (args['tmsConfig']) {
|
|
127
|
+
config = this.readConfigFile(args['tmsConfig']);
|
|
123
128
|
}
|
|
124
129
|
return Client.mergeConfig(config, {
|
|
125
|
-
url: args['
|
|
126
|
-
privateToken: args['
|
|
127
|
-
projectId: args['
|
|
128
|
-
configurationId: args['
|
|
129
|
-
testRunId: args['
|
|
130
|
+
url: args['tmsUrl'],
|
|
131
|
+
privateToken: args['tmsPrivateToken'],
|
|
132
|
+
projectId: args['tmsProjectId'],
|
|
133
|
+
configurationId: args['tmsConfigurationId'],
|
|
134
|
+
testRunId: args['tmsTestRunId'],
|
|
135
|
+
automaticCreationTestCases: args['tmsAutomaticCreationTestCases'],
|
|
130
136
|
});
|
|
131
137
|
}
|
|
132
138
|
readEnvConfig() {
|
|
133
139
|
let config = {};
|
|
134
|
-
if (process.env['
|
|
135
|
-
config = this.readConfigFile(process.env['
|
|
140
|
+
if (process.env['TMS_CONFIG_FILE']) {
|
|
141
|
+
config = this.readConfigFile(process.env['TMS_CONFIG_FILE']);
|
|
136
142
|
}
|
|
137
143
|
return Client.mergeConfig(config, {
|
|
138
|
-
url: process.env['
|
|
139
|
-
privateToken: process.env['
|
|
140
|
-
projectId: process.env['
|
|
141
|
-
configurationId: process.env['
|
|
142
|
-
testRunId: process.env['
|
|
144
|
+
url: process.env['TMS_URL'],
|
|
145
|
+
privateToken: process.env['TMS_PRIVATE_TOKEN'],
|
|
146
|
+
projectId: process.env['TMS_PROJECT_ID'],
|
|
147
|
+
configurationId: process.env['TMS_CONFIGURATION_ID'],
|
|
148
|
+
testRunId: process.env['TMS_TEST_RUN_ID'],
|
|
149
|
+
automaticCreationTestCases: process.env['TMS_CREATION_TEST_CASES'] === 'true',
|
|
143
150
|
});
|
|
144
151
|
}
|
|
145
152
|
readConfigFile(path) {
|
|
@@ -153,13 +160,14 @@ class Client {
|
|
|
153
160
|
return config;
|
|
154
161
|
}
|
|
155
162
|
static mergeConfig(oldConfig, newConfig) {
|
|
156
|
-
var _a, _b, _c, _d, _e;
|
|
163
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
157
164
|
return {
|
|
158
165
|
url: (_a = newConfig.url) !== null && _a !== void 0 ? _a : oldConfig.url,
|
|
159
166
|
privateToken: (_b = newConfig.privateToken) !== null && _b !== void 0 ? _b : oldConfig.privateToken,
|
|
160
167
|
projectId: (_c = newConfig.projectId) !== null && _c !== void 0 ? _c : oldConfig.projectId,
|
|
161
168
|
configurationId: (_d = newConfig.configurationId) !== null && _d !== void 0 ? _d : oldConfig.configurationId,
|
|
162
169
|
testRunId: (_e = newConfig.testRunId) !== null && _e !== void 0 ? _e : oldConfig.testRunId,
|
|
170
|
+
automaticCreationTestCases: (_g = (_f = newConfig.automaticCreationTestCases) !== null && _f !== void 0 ? _f : oldConfig.automaticCreationTestCases) !== null && _g !== void 0 ? _g : false,
|
|
163
171
|
};
|
|
164
172
|
}
|
|
165
173
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/types/autotest.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Capabilities = Record<string, string>;
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Attachment, Autotest, AutotestPost, AutotestPut, AutotestQuery, AutotestResultsForTestRun,
|
|
1
|
+
import { Attachment, Autotest, AutotestPost, AutotestPut, AutotestQuery, AutotestResultsForTestRun, TestRunGet, TestRunPost, WorkItemId } from '.';
|
|
2
2
|
export interface IClient {
|
|
3
3
|
checkConnection(): Promise<void>;
|
|
4
4
|
getAutotest(query: AutotestQuery): Promise<Autotest[]>;
|
|
@@ -6,10 +6,10 @@ export interface IClient {
|
|
|
6
6
|
updateAutotest(autotest: AutotestPut): Promise<void>;
|
|
7
7
|
linkToWorkItem(autotestId: string, workItem: WorkItemId): Promise<void>;
|
|
8
8
|
getTestRun(testRunId: string): TestRunGet;
|
|
9
|
+
getTestRunById(testRunId: string): Promise<TestRunGet>;
|
|
9
10
|
createTestRun(testRun: TestRunPost): Promise<TestRunGet>;
|
|
10
11
|
startTestRun(testRunId: string): Promise<void>;
|
|
11
12
|
loadTestRunResults(testRunId: string, results: AutotestResultsForTestRun[]): Promise<string[]>;
|
|
12
13
|
completeTestRun(testRunId: string): Promise<void>;
|
|
13
|
-
getConfig(): ClientConfig;
|
|
14
14
|
loadAttachment(fileName: string): Promise<Attachment>;
|
|
15
15
|
}
|
package/dist/types/config.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/types/link.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type LinkType = 'Related' | 'BlockedBy' | 'Defect' | 'Issue' | 'Requirement' | 'Repository';
|
|
2
2
|
export interface LinkPost {
|
|
3
3
|
title?: string;
|
|
4
4
|
url: string;
|
package/dist/types/outcome.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type OutcomeType = 'Passed' | 'Failed' | 'Pending' | 'Blocked' | 'Skipped';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Parameters = Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Properties = Record<string, string>;
|
package/dist/types/testRun.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TestResultGet } from './testResult';
|
|
2
|
-
export
|
|
2
|
+
export type TestRunStateType = 'NotStarted' | 'InProgress' | 'Stopped' | 'Completed';
|
|
3
3
|
export interface TestRunPost {
|
|
4
4
|
projectId: string;
|
|
5
5
|
name?: string;
|
package/dist/validation.js
CHANGED
|
@@ -8,6 +8,7 @@ const configSchema = zod_1.z.object({
|
|
|
8
8
|
projectId: zod_1.z.string().uuid(),
|
|
9
9
|
url: zod_1.z.string().url(),
|
|
10
10
|
testRunId: zod_1.z.string().uuid().optional(),
|
|
11
|
+
automaticCreationTestCases: zod_1.z.boolean().optional(),
|
|
11
12
|
});
|
|
12
13
|
function validateConfig(config) {
|
|
13
14
|
return configSchema.parse(config);
|
package/package.json
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "testit-api-client",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Client provides methods for communication with
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "jest",
|
|
8
|
-
"build": "tsc",
|
|
9
|
-
"prebuild": "rimraf dist"
|
|
10
|
-
},
|
|
11
|
-
"keywords": [],
|
|
12
|
-
"author": "
|
|
13
|
-
"license": "Apache-2.0",
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
"@babel/core": "^7.15.8",
|
|
16
|
-
"@babel/preset-env": "^7.15.8",
|
|
17
|
-
"@babel/preset-typescript": "^7.15.0",
|
|
18
|
-
"@types/jest": "^27.0.2",
|
|
19
|
-
"@types/minimist": "^1.2.2",
|
|
20
|
-
"@types/node": "^16.10.2",
|
|
21
|
-
"@types/uuid": "^8.3.1",
|
|
22
|
-
"babel-jest": "^27.2.5",
|
|
23
|
-
"jest": "^27.2.5",
|
|
24
|
-
"rimraf": "^3.0.2",
|
|
25
|
-
"ts-node": "^10.2.1",
|
|
26
|
-
"typescript": "^4.5.5",
|
|
27
|
-
"uuid": "^8.3.2"
|
|
28
|
-
},
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"axios": "^0.22.0",
|
|
31
|
-
"form-data": "^4.0.0",
|
|
32
|
-
"minimist": "^1.2.5",
|
|
33
|
-
"querystring": "^0.2.1",
|
|
34
|
-
"zod": "^3.11.6",
|
|
35
|
-
"xmlhttprequest": "^1.8.0"
|
|
36
|
-
},
|
|
37
|
-
"files": [
|
|
38
|
-
"dist"
|
|
39
|
-
],
|
|
40
|
-
"bugs": {
|
|
41
|
-
"url": "https://github.com/testit-tms/api-client-js/issues"
|
|
42
|
-
},
|
|
43
|
-
"homepage": "https://github.com/testit-tms/api-client-js",
|
|
44
|
-
"repository": {
|
|
45
|
-
"type": "git",
|
|
46
|
-
"url": "git+https://github.com/testit-tms/api-client-js.git"
|
|
47
|
-
},
|
|
48
|
-
"types": "./dist\\index.d.ts",
|
|
49
|
-
"directories": {
|
|
50
|
-
"test": "test"
|
|
51
|
-
}
|
|
52
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "testit-api-client",
|
|
3
|
+
"version": "1.0.7",
|
|
4
|
+
"description": "Client provides methods for communication with TMS API.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "jest",
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prebuild": "rimraf dist"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "Integration team",
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@babel/core": "^7.15.8",
|
|
16
|
+
"@babel/preset-env": "^7.15.8",
|
|
17
|
+
"@babel/preset-typescript": "^7.15.0",
|
|
18
|
+
"@types/jest": "^27.0.2",
|
|
19
|
+
"@types/minimist": "^1.2.2",
|
|
20
|
+
"@types/node": "^16.10.2",
|
|
21
|
+
"@types/uuid": "^8.3.1",
|
|
22
|
+
"babel-jest": "^27.2.5",
|
|
23
|
+
"jest": "^27.2.5",
|
|
24
|
+
"rimraf": "^3.0.2",
|
|
25
|
+
"ts-node": "^10.2.1",
|
|
26
|
+
"typescript": "^4.5.5",
|
|
27
|
+
"uuid": "^8.3.2"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"axios": "^0.22.0",
|
|
31
|
+
"form-data": "^4.0.0",
|
|
32
|
+
"minimist": "^1.2.5",
|
|
33
|
+
"querystring": "^0.2.1",
|
|
34
|
+
"zod": "^3.11.6",
|
|
35
|
+
"xmlhttprequest": "^1.8.0"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/testit-tms/api-client-js/issues"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/testit-tms/api-client-js",
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/testit-tms/api-client-js.git"
|
|
47
|
+
},
|
|
48
|
+
"types": "./dist\\index.d.ts",
|
|
49
|
+
"directories": {
|
|
50
|
+
"test": "test"
|
|
51
|
+
}
|
|
52
|
+
}
|
/package/{README.MD → README.md}
RENAMED
|
File without changes
|