testit-adapter-codecept 1.1.3 → 1.1.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.
- package/README.md +180 -203
- package/build/bootstrap.d.ts +1 -1
- package/build/bootstrap.js +37 -34
- package/build/common/__tests/box.class.spec.d.ts +1 -1
- package/build/common/__tests/box.class.spec.js +15 -15
- package/build/common/__tests/test.utils.d.ts +4 -4
- package/build/common/__tests/test.utils.js +71 -71
- package/build/common/classes/box.class.d.ts +5 -5
- package/build/common/classes/box.class.js +18 -18
- package/build/common/classes/config.class.d.ts +6 -6
- package/build/common/classes/config.class.js +67 -67
- package/build/common/classes/logger.class.d.ts +9 -9
- package/build/common/classes/logger.class.js +28 -28
- package/build/common/classes/outcome.factory.d.ts +7 -7
- package/build/common/classes/outcome.factory.js +19 -19
- package/build/common/functions/compose.function.d.ts +1 -1
- package/build/common/functions/compose.function.js +5 -5
- package/build/common/functions/hash.function.d.ts +1 -1
- package/build/common/functions/hash.function.js +15 -15
- package/build/common/functions/humanize.function.d.ts +1 -1
- package/build/common/functions/humanize.function.js +7 -7
- package/build/common/functions/is-passed.function.d.ts +2 -2
- package/build/common/functions/is-passed.function.js +7 -7
- package/build/common/functions/to-iso-string.function.d.ts +1 -1
- package/build/common/functions/to-iso-string.function.js +10 -10
- package/build/common/functions/use-hash.function.d.ts +9 -9
- package/build/common/functions/use-hash.function.js +13 -13
- package/build/common/types/nullable.type.d.ts +1 -1
- package/build/common/types/nullable.type.js +2 -2
- package/build/helper.d.ts +9 -9
- package/build/helper.js +37 -37
- package/build/http/default-http-client.class.d.ts +22 -22
- package/build/http/default-http-client.class.js +123 -123
- package/build/http/http-client.errors.d.ts +7 -7
- package/build/http/http-client.errors.js +18 -18
- package/build/index.d.ts +2 -2
- package/build/index.js +18 -18
- package/build/jest.config.d.ts +7 -7
- package/build/jest.config.js +12 -12
- package/build/services/__tests/attachments.class.spec.d.ts +1 -1
- package/build/services/__tests/attachments.class.spec.js +23 -23
- package/build/services/__tests/runs.builder.spec.d.ts +1 -1
- package/build/services/__tests/runs.builder.spec.js +79 -79
- package/build/services/__tests/tests.builder.spec.d.ts +1 -1
- package/build/services/__tests/tests.builder.spec.js +32 -32
- package/build/services/attachments.service.d.ts +11 -11
- package/build/services/attachments.service.js +28 -28
- package/build/services/runs.builder.d.ts +10 -10
- package/build/services/runs.builder.js +65 -65
- package/build/services/tests.builder.d.ts +10 -10
- package/build/services/tests.builder.js +57 -57
- package/build/strategies/base-strategy.class.d.ts +24 -24
- package/build/strategies/base-strategy.class.js +66 -66
- package/build/strategies/default-strategy.class.d.ts +16 -16
- package/build/strategies/default-strategy.class.js +44 -44
- package/build/strategies/partial-startegy.class.d.ts +20 -20
- package/build/strategies/partial-startegy.class.js +72 -72
- package/build/strategies/scratch-strategy.class.d.ts +18 -18
- package/build/strategies/scratch-strategy.class.js +49 -49
- package/build/strategies/strategy.factory.d.ts +8 -8
- package/build/strategies/strategy.factory.js +21 -21
- package/build/types/codecept.type.d.ts +28 -27
- package/build/types/codecept.type.js +2 -2
- package/build/types/origin.type.d.ts +46 -46
- package/build/types/origin.type.js +2 -2
- package/build/types/strategy.type.d.ts +14 -10
- package/build/types/strategy.type.js +2 -2
- package/package.json +50 -46
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useConfig = exports.useCompositeHash = exports.useDefaultHash = exports.useCompositeKey = void 0;
|
|
4
|
-
const compose_function_1 = require("./compose.function");
|
|
5
|
-
const hash_function_1 = require("./hash.function");
|
|
6
|
-
const useCompositeKey = (test) => { var _a; return `${test.title}:${(_a = test.parent) === null || _a === void 0 ? void 0 : _a.title}`; };
|
|
7
|
-
exports.useCompositeKey = useCompositeKey;
|
|
8
|
-
const useDefaultHash = (test) => { var _a; return (_a = test === null || test === void 0 ? void 0 : test.opts) === null || _a === void 0 ? void 0 : _a.externalId; };
|
|
9
|
-
exports.useDefaultHash = useDefaultHash;
|
|
10
|
-
const useCompositeHash = (test) => (0, compose_function_1.compose)(hash_function_1.hash, exports.useCompositeKey)(test);
|
|
11
|
-
exports.useCompositeHash = useCompositeHash;
|
|
12
|
-
const useConfig = (test) => test.opts;
|
|
13
|
-
exports.useConfig = useConfig;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useConfig = exports.useCompositeHash = exports.useDefaultHash = exports.useCompositeKey = void 0;
|
|
4
|
+
const compose_function_1 = require("./compose.function");
|
|
5
|
+
const hash_function_1 = require("./hash.function");
|
|
6
|
+
const useCompositeKey = (test) => { var _a; return `${test.title}:${(_a = test.parent) === null || _a === void 0 ? void 0 : _a.title}`; };
|
|
7
|
+
exports.useCompositeKey = useCompositeKey;
|
|
8
|
+
const useDefaultHash = (test) => { var _a; return (_a = test === null || test === void 0 ? void 0 : test.opts) === null || _a === void 0 ? void 0 : _a.externalId; };
|
|
9
|
+
exports.useDefaultHash = useDefaultHash;
|
|
10
|
+
const useCompositeHash = (test) => (0, compose_function_1.compose)(hash_function_1.hash, exports.useCompositeKey)(test);
|
|
11
|
+
exports.useCompositeHash = useCompositeHash;
|
|
12
|
+
const useConfig = (test) => test.opts;
|
|
13
|
+
exports.useConfig = useConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type Nullable<T> = null | undefined | T;
|
|
1
|
+
export type Nullable<T> = null | undefined | T;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/build/helper.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { LinkPost, LinkType } from 'testit-api-client';
|
|
2
|
-
import { Nullable } from './common/types/nullable.type';
|
|
3
|
-
import { Origin } from './types/origin.type';
|
|
4
|
-
export declare class TestMetadataHelper extends Helper {
|
|
5
|
-
metadata: Nullable<Origin.TestMetadata>;
|
|
6
|
-
addMessage(message: string): void;
|
|
7
|
-
addAttachments(paths: string[] | string, name?: string): void;
|
|
8
|
-
addLinks(linksOrName: LinkPost[] | string, description?: string, type?: LinkType, url?: string): void;
|
|
9
|
-
}
|
|
1
|
+
import { LinkPost, LinkType } from 'testit-api-client';
|
|
2
|
+
import { Nullable } from './common/types/nullable.type';
|
|
3
|
+
import { Origin } from './types/origin.type';
|
|
4
|
+
export declare class TestMetadataHelper extends Helper {
|
|
5
|
+
metadata: Nullable<Origin.TestMetadata>;
|
|
6
|
+
addMessage(message: string): void;
|
|
7
|
+
addAttachments(paths: string[] | string, name?: string): void;
|
|
8
|
+
addLinks(linksOrName: LinkPost[] | string, description?: string, type?: LinkType, url?: string): void;
|
|
9
|
+
}
|
package/build/helper.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestMetadataHelper = void 0;
|
|
4
|
-
class TestMetadataHelper extends Helper {
|
|
5
|
-
constructor() {
|
|
6
|
-
super(...arguments);
|
|
7
|
-
this.metadata = {};
|
|
8
|
-
}
|
|
9
|
-
addMessage(message) {
|
|
10
|
-
this.metadata.message = message;
|
|
11
|
-
}
|
|
12
|
-
addAttachments(paths, name) {
|
|
13
|
-
if (Array.isArray(paths)) {
|
|
14
|
-
this.metadata.attachments = paths;
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
this.metadata.text = {
|
|
18
|
-
name,
|
|
19
|
-
content: paths
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
addLinks(linksOrName, description, type, url) {
|
|
23
|
-
if (typeof linksOrName !== 'string') {
|
|
24
|
-
this.metadata.links = linksOrName;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
this.metadata.links = [{
|
|
28
|
-
title: linksOrName,
|
|
29
|
-
url,
|
|
30
|
-
description,
|
|
31
|
-
type
|
|
32
|
-
}];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.TestMetadataHelper = TestMetadataHelper;
|
|
37
|
-
module.exports = TestMetadataHelper;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TestMetadataHelper = void 0;
|
|
4
|
+
class TestMetadataHelper extends Helper {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.metadata = {};
|
|
8
|
+
}
|
|
9
|
+
addMessage(message) {
|
|
10
|
+
this.metadata.message = message;
|
|
11
|
+
}
|
|
12
|
+
addAttachments(paths, name) {
|
|
13
|
+
if (Array.isArray(paths)) {
|
|
14
|
+
this.metadata.attachments = paths;
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
this.metadata.text = {
|
|
18
|
+
name,
|
|
19
|
+
content: paths
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
addLinks(linksOrName, description, type, url) {
|
|
23
|
+
if (typeof linksOrName !== 'string') {
|
|
24
|
+
this.metadata.links = linksOrName;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.metadata.links = [{
|
|
28
|
+
title: linksOrName,
|
|
29
|
+
url,
|
|
30
|
+
description,
|
|
31
|
+
type
|
|
32
|
+
}];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.TestMetadataHelper = TestMetadataHelper;
|
|
37
|
+
module.exports = TestMetadataHelper;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Attachment, Autotest, AutotestPost, AutotestPut, AutotestResultsForTestRun, Client, TestRunGet } from 'testit-api-client';
|
|
2
|
-
import { Logger } from '../common/classes/logger.class';
|
|
3
|
-
import { Origin } from '../types/origin.type';
|
|
4
|
-
export declare class DefaultHttpClient {
|
|
5
|
-
readonly config: Origin.Config;
|
|
6
|
-
private readonly logger;
|
|
7
|
-
readonly http: Client;
|
|
8
|
-
constructor(config: Origin.Config, logger: Logger);
|
|
9
|
-
hasInSystem(id: string): Promise<Autotest | null>;
|
|
10
|
-
create(test: AutotestPost): Promise<Autotest | void>;
|
|
11
|
-
loadAttachment(path: string): Promise<Attachment | void>;
|
|
12
|
-
update(test: AutotestPut): Promise<void>;
|
|
13
|
-
validate(): Promise<void>;
|
|
14
|
-
updateRuns(result: AutotestResultsForTestRun, run?: string): Promise<void>;
|
|
15
|
-
updateManyRuns(result: AutotestResultsForTestRun[], run?: string): Promise<void>;
|
|
16
|
-
createEmptyRun(name?: string): Promise<void | TestRunGet>;
|
|
17
|
-
linkToWorkItem(autotestId: string, ids: string[]): Promise<void>;
|
|
18
|
-
startRunIfNeeded(id: string): Promise<void>;
|
|
19
|
-
completeRunIfNeeded(id: string): Promise<void>;
|
|
20
|
-
getRun(id: string): Promise<TestRunGet>;
|
|
21
|
-
getTestsIdsByRunId(id: string): Promise<string[]>;
|
|
22
|
-
}
|
|
1
|
+
import { Attachment, Autotest, AutotestPost, AutotestPut, AutotestResultsForTestRun, Client, TestRunGet } from 'testit-api-client';
|
|
2
|
+
import { Logger } from '../common/classes/logger.class';
|
|
3
|
+
import { Origin } from '../types/origin.type';
|
|
4
|
+
export declare class DefaultHttpClient {
|
|
5
|
+
readonly config: Origin.Config;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
readonly http: Client;
|
|
8
|
+
constructor(config: Origin.Config, logger: Logger);
|
|
9
|
+
hasInSystem(id: string): Promise<Autotest | null>;
|
|
10
|
+
create(test: AutotestPost): Promise<Autotest | void>;
|
|
11
|
+
loadAttachment(path: string): Promise<Attachment | void>;
|
|
12
|
+
update(test: AutotestPut): Promise<void>;
|
|
13
|
+
validate(): Promise<void>;
|
|
14
|
+
updateRuns(result: AutotestResultsForTestRun, run?: string): Promise<void>;
|
|
15
|
+
updateManyRuns(result: AutotestResultsForTestRun[], run?: string): Promise<void>;
|
|
16
|
+
createEmptyRun(name?: string): Promise<void | TestRunGet>;
|
|
17
|
+
linkToWorkItem(autotestId: string, ids: string[]): Promise<void>;
|
|
18
|
+
startRunIfNeeded(id: string): Promise<void>;
|
|
19
|
+
completeRunIfNeeded(id: string): Promise<void>;
|
|
20
|
+
getRun(id: string): Promise<TestRunGet>;
|
|
21
|
+
getTestsIdsByRunId(id: string): Promise<string[]>;
|
|
22
|
+
}
|
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DefaultHttpClient = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const testit_api_client_1 = require("testit-api-client");
|
|
9
|
-
const http_client_errors_1 = require("./http-client.errors");
|
|
10
|
-
class DefaultHttpClient {
|
|
11
|
-
constructor(config, logger) {
|
|
12
|
-
this.config = config;
|
|
13
|
-
this.logger = logger;
|
|
14
|
-
if (!this.config) {
|
|
15
|
-
http_client_errors_1.HttpClientErrors.throwNotFoundHttpClientConfig();
|
|
16
|
-
}
|
|
17
|
-
try {
|
|
18
|
-
this.http = new testit_api_client_1.Client(this.config);
|
|
19
|
-
}
|
|
20
|
-
catch (e) {
|
|
21
|
-
this.logger.warn(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
hasInSystem(id) {
|
|
25
|
-
const query = { projectId: this.config.projectId, externalId: id };
|
|
26
|
-
return this.http
|
|
27
|
-
.getAutotest(query)
|
|
28
|
-
.then(([test]) => test);
|
|
29
|
-
}
|
|
30
|
-
create(test) {
|
|
31
|
-
return this.http.createAutotest(test)
|
|
32
|
-
.catch(error => {
|
|
33
|
-
this.logger.error(error);
|
|
34
|
-
http_client_errors_1.HttpClientErrors.throwErrorAfterTestCreate(test);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
loadAttachment(path) {
|
|
38
|
-
return this.http.loadAttachment(path)
|
|
39
|
-
.catch(error => {
|
|
40
|
-
this.logger.error(error);
|
|
41
|
-
http_client_errors_1.HttpClientErrors.throwNotUploadAttachments(path);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
update(test) {
|
|
45
|
-
return this.http.updateAutotest(test)
|
|
46
|
-
.catch(error => {
|
|
47
|
-
this.logger.error(error);
|
|
48
|
-
http_client_errors_1.HttpClientErrors.throwErrorAfterTestUpdate(test);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
async validate() {
|
|
52
|
-
try {
|
|
53
|
-
await this.http.checkConnection();
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
this.logger.error(e);
|
|
57
|
-
throw new Error();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
async updateRuns(result, run = this.config.testRunId) {
|
|
61
|
-
await this.http.loadTestRunResults(run, [result]);
|
|
62
|
-
}
|
|
63
|
-
async updateManyRuns(result, run = this.config.testRunId) {
|
|
64
|
-
await this.http.loadTestRunResults(run, result);
|
|
65
|
-
}
|
|
66
|
-
async createEmptyRun(name = '') {
|
|
67
|
-
return this.http
|
|
68
|
-
.createTestRun({ name, projectId: this.config.projectId })
|
|
69
|
-
.catch((error) => this.logger.error(error));
|
|
70
|
-
}
|
|
71
|
-
async linkToWorkItem(autotestId, ids) {
|
|
72
|
-
for (const id of ids) {
|
|
73
|
-
try {
|
|
74
|
-
await this.http.linkToWorkItem(autotestId, { id });
|
|
75
|
-
this.logger.log(`Test - ${autotestId} linked with WI - ${ids}`);
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
this.logger.error(error);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
async startRunIfNeeded(id) {
|
|
83
|
-
try {
|
|
84
|
-
const run = await this.getRun(id);
|
|
85
|
-
if (run.stateName !== 'Completed') {
|
|
86
|
-
await this.http.startTestRun(id);
|
|
87
|
-
this.logger.log(`Test run - ${run.id} started`);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
this.logger.error(error);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
async completeRunIfNeeded(id) {
|
|
95
|
-
try {
|
|
96
|
-
const run = await this.getRun(id);
|
|
97
|
-
if (run.stateName !== 'Completed') {
|
|
98
|
-
await this.http.completeTestRun(id);
|
|
99
|
-
this.logger.log(`Test run - ${run.id} completed`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
this.logger.error(e);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
getRun(id) {
|
|
107
|
-
const baseURL = new URL('/api/v2', this.config.url).toString();
|
|
108
|
-
const client = axios_1.default.create({
|
|
109
|
-
baseURL,
|
|
110
|
-
headers: {
|
|
111
|
-
Authorization: `PrivateToken ${this.config.privateToken}`
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
return client.get(`testRuns/${id}`).then(response => response.data);
|
|
115
|
-
}
|
|
116
|
-
async getTestsIdsByRunId(id) {
|
|
117
|
-
const run = await this.getRun(id);
|
|
118
|
-
return run.testResults
|
|
119
|
-
.filter(test => test.configurationId === this.config.configurationId)
|
|
120
|
-
.map(test => test.autoTest.externalId);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.DefaultHttpClient = DefaultHttpClient;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DefaultHttpClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const testit_api_client_1 = require("testit-api-client");
|
|
9
|
+
const http_client_errors_1 = require("./http-client.errors");
|
|
10
|
+
class DefaultHttpClient {
|
|
11
|
+
constructor(config, logger) {
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.logger = logger;
|
|
14
|
+
if (!this.config) {
|
|
15
|
+
http_client_errors_1.HttpClientErrors.throwNotFoundHttpClientConfig();
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
this.http = new testit_api_client_1.Client(this.config);
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
this.logger.warn(e);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
hasInSystem(id) {
|
|
25
|
+
const query = { projectId: this.config.projectId, externalId: id };
|
|
26
|
+
return this.http
|
|
27
|
+
.getAutotest(query)
|
|
28
|
+
.then(([test]) => test);
|
|
29
|
+
}
|
|
30
|
+
create(test) {
|
|
31
|
+
return this.http.createAutotest(test)
|
|
32
|
+
.catch(error => {
|
|
33
|
+
this.logger.error(error);
|
|
34
|
+
http_client_errors_1.HttpClientErrors.throwErrorAfterTestCreate(test);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
loadAttachment(path) {
|
|
38
|
+
return this.http.loadAttachment(path)
|
|
39
|
+
.catch(error => {
|
|
40
|
+
this.logger.error(error);
|
|
41
|
+
http_client_errors_1.HttpClientErrors.throwNotUploadAttachments(path);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
update(test) {
|
|
45
|
+
return this.http.updateAutotest(test)
|
|
46
|
+
.catch(error => {
|
|
47
|
+
this.logger.error(error);
|
|
48
|
+
http_client_errors_1.HttpClientErrors.throwErrorAfterTestUpdate(test);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async validate() {
|
|
52
|
+
try {
|
|
53
|
+
await this.http.checkConnection();
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
this.logger.error(e);
|
|
57
|
+
throw new Error();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async updateRuns(result, run = this.config.testRunId) {
|
|
61
|
+
await this.http.loadTestRunResults(run, [result]);
|
|
62
|
+
}
|
|
63
|
+
async updateManyRuns(result, run = this.config.testRunId) {
|
|
64
|
+
await this.http.loadTestRunResults(run, result);
|
|
65
|
+
}
|
|
66
|
+
async createEmptyRun(name = '') {
|
|
67
|
+
return this.http
|
|
68
|
+
.createTestRun({ name, projectId: this.config.projectId })
|
|
69
|
+
.catch((error) => this.logger.error(error));
|
|
70
|
+
}
|
|
71
|
+
async linkToWorkItem(autotestId, ids) {
|
|
72
|
+
for (const id of ids) {
|
|
73
|
+
try {
|
|
74
|
+
await this.http.linkToWorkItem(autotestId, { id });
|
|
75
|
+
this.logger.log(`Test - ${autotestId} linked with WI - ${ids}`);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
this.logger.error(error);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async startRunIfNeeded(id) {
|
|
83
|
+
try {
|
|
84
|
+
const run = await this.getRun(id);
|
|
85
|
+
if (run.stateName !== 'Completed') {
|
|
86
|
+
await this.http.startTestRun(id);
|
|
87
|
+
this.logger.log(`Test run - ${run.id} started`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
this.logger.error(error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async completeRunIfNeeded(id) {
|
|
95
|
+
try {
|
|
96
|
+
const run = await this.getRun(id);
|
|
97
|
+
if (run.stateName !== 'Completed') {
|
|
98
|
+
await this.http.completeTestRun(id);
|
|
99
|
+
this.logger.log(`Test run - ${run.id} completed`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (e) {
|
|
103
|
+
this.logger.error(e);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
getRun(id) {
|
|
107
|
+
const baseURL = new URL('/api/v2', this.config.url).toString();
|
|
108
|
+
const client = axios_1.default.create({
|
|
109
|
+
baseURL,
|
|
110
|
+
headers: {
|
|
111
|
+
Authorization: `PrivateToken ${this.config.privateToken}`
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return client.get(`testRuns/${id}`).then(response => response.data);
|
|
115
|
+
}
|
|
116
|
+
async getTestsIdsByRunId(id) {
|
|
117
|
+
const run = await this.getRun(id);
|
|
118
|
+
return run.testResults
|
|
119
|
+
.filter(test => test.configurationId === this.config.configurationId)
|
|
120
|
+
.map(test => test.autoTest.externalId);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.DefaultHttpClient = DefaultHttpClient;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AutotestPut } from 'testit-api-client';
|
|
2
|
-
export declare class HttpClientErrors {
|
|
3
|
-
static throwNotFoundHttpClientConfig(): void;
|
|
4
|
-
static throwErrorAfterTestUpdate(test: AutotestPut): void;
|
|
5
|
-
static throwErrorAfterTestCreate(test: AutotestPut): void;
|
|
6
|
-
static throwNotUploadAttachments(path: string): void;
|
|
7
|
-
}
|
|
1
|
+
import { AutotestPut } from 'testit-api-client';
|
|
2
|
+
export declare class HttpClientErrors {
|
|
3
|
+
static throwNotFoundHttpClientConfig(): void;
|
|
4
|
+
static throwErrorAfterTestUpdate(test: AutotestPut): void;
|
|
5
|
+
static throwErrorAfterTestCreate(test: AutotestPut): void;
|
|
6
|
+
static throwNotUploadAttachments(path: string): void;
|
|
7
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpClientErrors = void 0;
|
|
4
|
-
class HttpClientErrors {
|
|
5
|
-
static throwNotFoundHttpClientConfig() {
|
|
6
|
-
throw new Error('Http client config not found');
|
|
7
|
-
}
|
|
8
|
-
static throwErrorAfterTestUpdate(test) {
|
|
9
|
-
throw new Error(`An error occurred while updating the test - ${test.name}`);
|
|
10
|
-
}
|
|
11
|
-
static throwErrorAfterTestCreate(test) {
|
|
12
|
-
throw new Error(`an error occurred while creating the test - ${test.name}`);
|
|
13
|
-
}
|
|
14
|
-
static throwNotUploadAttachments(path) {
|
|
15
|
-
throw new Error(`when loading an attachment along the path - ${path}, an error occurred`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.HttpClientErrors = HttpClientErrors;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpClientErrors = void 0;
|
|
4
|
+
class HttpClientErrors {
|
|
5
|
+
static throwNotFoundHttpClientConfig() {
|
|
6
|
+
throw new Error('Http client config not found');
|
|
7
|
+
}
|
|
8
|
+
static throwErrorAfterTestUpdate(test) {
|
|
9
|
+
throw new Error(`An error occurred while updating the test - ${test.name}`);
|
|
10
|
+
}
|
|
11
|
+
static throwErrorAfterTestCreate(test) {
|
|
12
|
+
throw new Error(`an error occurred while creating the test - ${test.name}`);
|
|
13
|
+
}
|
|
14
|
+
static throwNotUploadAttachments(path) {
|
|
15
|
+
throw new Error(`when loading an attachment along the path - ${path}, an error occurred`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.HttpClientErrors = HttpClientErrors;
|
package/build/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './helper';
|
|
2
|
-
export * from './bootstrap';
|
|
1
|
+
export * from './helper';
|
|
2
|
+
export * from './bootstrap';
|
package/build/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./helper"), exports);
|
|
18
|
-
__exportStar(require("./bootstrap"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./helper"), exports);
|
|
18
|
+
__exportStar(require("./bootstrap"), exports);
|
package/build/jest.config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
clearMocks: boolean;
|
|
3
|
-
preset: string;
|
|
4
|
-
coverageProvider: string;
|
|
5
|
-
testPathIgnorePatterns: string[];
|
|
6
|
-
};
|
|
7
|
-
export default _default;
|
|
1
|
+
declare const _default: {
|
|
2
|
+
clearMocks: boolean;
|
|
3
|
+
preset: string;
|
|
4
|
+
coverageProvider: string;
|
|
5
|
+
testPathIgnorePatterns: string[];
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
package/build/jest.config.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* For a detailed explanation regarding each configuration property and type check, visit:
|
|
4
|
-
* https://jestjs.io/docs/configuration
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.default = {
|
|
8
|
-
clearMocks: true,
|
|
9
|
-
preset: 'ts-jest',
|
|
10
|
-
coverageProvider: "v8",
|
|
11
|
-
testPathIgnorePatterns: ["/node_modules/", "/build/"]
|
|
12
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* For a detailed explanation regarding each configuration property and type check, visit:
|
|
4
|
+
* https://jestjs.io/docs/configuration
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.default = {
|
|
8
|
+
clearMocks: true,
|
|
9
|
+
preset: 'ts-jest',
|
|
10
|
+
coverageProvider: "v8",
|
|
11
|
+
testPathIgnorePatterns: ["/node_modules/", "/build/"]
|
|
12
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const attachments_service_1 = require("../attachments.service");
|
|
4
|
-
describe('AttachmentsService service', () => {
|
|
5
|
-
const notCorrectDataToAttachments = ['4', '5'];
|
|
6
|
-
const http = {
|
|
7
|
-
loadAttachment(path) {
|
|
8
|
-
return !notCorrectDataToAttachments.includes(path)
|
|
9
|
-
? Promise.resolve({ id: path })
|
|
10
|
-
: Promise.reject();
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
const service = new attachments_service_1.AttachmentsService(http);
|
|
14
|
-
it('Should return array with ids loaded attachments', async () => {
|
|
15
|
-
const response = await service.attach(['1', '2', '3']);
|
|
16
|
-
expect(response)
|
|
17
|
-
.toEqual([
|
|
18
|
-
{ id: '1' },
|
|
19
|
-
{ id: '2' },
|
|
20
|
-
{ id: '3' }
|
|
21
|
-
]);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const attachments_service_1 = require("../attachments.service");
|
|
4
|
+
describe('AttachmentsService service', () => {
|
|
5
|
+
const notCorrectDataToAttachments = ['4', '5'];
|
|
6
|
+
const http = {
|
|
7
|
+
loadAttachment(path) {
|
|
8
|
+
return !notCorrectDataToAttachments.includes(path)
|
|
9
|
+
? Promise.resolve({ id: path })
|
|
10
|
+
: Promise.reject();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const service = new attachments_service_1.AttachmentsService(http);
|
|
14
|
+
it('Should return array with ids loaded attachments', async () => {
|
|
15
|
+
const response = await service.attach(['1', '2', '3']);
|
|
16
|
+
expect(response)
|
|
17
|
+
.toEqual([
|
|
18
|
+
{ id: '1' },
|
|
19
|
+
{ id: '2' },
|
|
20
|
+
{ id: '3' }
|
|
21
|
+
]);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|