testit-adapter-codecept 1.1.7 → 2.0.0
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/.prettierrc +9 -0
- package/README.md +8 -13
- package/build/bootstrap.js +13 -18
- package/build/builders/index.d.ts +2 -0
- package/build/builders/index.js +7 -0
- package/build/builders/run.builder.d.ts +9 -0
- package/build/builders/run.builder.js +53 -0
- package/build/{services/tests.builder.d.ts → builders/test.builder.d.ts} +3 -4
- package/build/{services/tests.builder.js → builders/test.builder.js} +12 -28
- package/build/common/classes/index.d.ts +2 -0
- package/build/common/classes/index.js +7 -0
- package/build/common/classes/logger.class.d.ts +2 -2
- package/build/common/classes/logger.class.js +6 -1
- package/build/common/types/index.d.ts +1 -0
- package/build/common/types/index.js +2 -0
- package/build/common/utils/index.d.ts +5 -0
- package/build/common/utils/index.js +21 -0
- package/build/common/{functions/is-passed.function.d.ts → utils/is-passed.util.d.ts} +1 -1
- package/build/common/{functions/is-passed.function.js → utils/is-passed.util.js} +1 -1
- package/build/common/{functions/use-hash.function.d.ts → utils/use-hash.util.d.ts} +1 -1
- package/build/common/{functions/use-hash.function.js → utils/use-hash.util.js} +3 -3
- package/build/helper.d.ts +4 -4
- package/build/helper.js +7 -5
- package/build/strategies/base.strategy.d.ts +17 -0
- package/build/strategies/base.strategy.js +40 -0
- package/build/strategies/default.strategy.d.ts +14 -0
- package/build/strategies/{default-strategy.class.js → default.strategy.js} +13 -11
- package/build/strategies/index.d.ts +5 -0
- package/build/strategies/index.js +13 -0
- package/build/strategies/partial.strategy.d.ts +18 -0
- package/build/strategies/partial.strategy.js +77 -0
- package/build/strategies/scratch.strategy.d.ts +16 -0
- package/build/strategies/scratch.strategy.js +46 -0
- package/build/strategies/strategy.factory.d.ts +4 -5
- package/build/strategies/strategy.factory.js +6 -6
- package/build/types/codecept.type.d.ts +1 -1
- package/build/types/index.d.ts +3 -0
- package/build/types/index.js +19 -0
- package/build/types/origin.type.d.ts +6 -28
- package/build/types/strategy.type.d.ts +3 -3
- package/package.json +5 -15
- package/build/common/__tests/box.class.spec.d.ts +0 -1
- package/build/common/__tests/box.class.spec.js +0 -15
- package/build/common/__tests/test.utils.d.ts +0 -4
- package/build/common/__tests/test.utils.js +0 -71
- package/build/common/classes/config.class.d.ts +0 -6
- package/build/common/classes/config.class.js +0 -67
- package/build/common/classes/outcome.factory.d.ts +0 -7
- package/build/common/classes/outcome.factory.js +0 -19
- package/build/common/functions/to-iso-string.function.d.ts +0 -1
- package/build/common/functions/to-iso-string.function.js +0 -10
- package/build/http/default-http-client.class.d.ts +0 -22
- package/build/http/default-http-client.class.js +0 -123
- package/build/http/http-client.errors.d.ts +0 -7
- package/build/http/http-client.errors.js +0 -18
- package/build/jest.config.d.ts +0 -7
- package/build/jest.config.js +0 -12
- package/build/services/__tests/attachments.class.spec.d.ts +0 -1
- package/build/services/__tests/attachments.class.spec.js +0 -23
- package/build/services/__tests/runs.builder.spec.d.ts +0 -1
- package/build/services/__tests/runs.builder.spec.js +0 -79
- package/build/services/__tests/tests.builder.spec.d.ts +0 -1
- package/build/services/__tests/tests.builder.spec.js +0 -32
- package/build/services/attachments.service.d.ts +0 -11
- package/build/services/attachments.service.js +0 -28
- package/build/services/runs.builder.d.ts +0 -10
- package/build/services/runs.builder.js +0 -65
- package/build/strategies/base-strategy.class.d.ts +0 -24
- package/build/strategies/base-strategy.class.js +0 -66
- package/build/strategies/default-strategy.class.d.ts +0 -16
- package/build/strategies/partial-startegy.class.d.ts +0 -20
- package/build/strategies/partial-startegy.class.js +0 -72
- package/build/strategies/scratch-strategy.class.d.ts +0 -18
- package/build/strategies/scratch-strategy.class.js +0 -49
- /package/build/common/{functions/compose.function.d.ts → utils/compose.util.d.ts} +0 -0
- /package/build/common/{functions/compose.function.js → utils/compose.util.js} +0 -0
- /package/build/common/{functions/hash.function.d.ts → utils/hash.util.d.ts} +0 -0
- /package/build/common/{functions/hash.function.js → utils/hash.util.js} +0 -0
- /package/build/common/{functions/humanize.function.d.ts → utils/humanize.util.d.ts} +0 -0
- /package/build/common/{functions/humanize.function.js → utils/humanize.util.js} +0 -0
|
@@ -1,123 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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/jest.config.d.ts
DELETED
package/build/jest.config.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const runs_builder_1 = require("../runs.builder");
|
|
4
|
-
const test_utils_1 = require("../../common/__tests/test.utils");
|
|
5
|
-
describe('Runs builder', () => {
|
|
6
|
-
const test = (0, test_utils_1.getDefaultTest)();
|
|
7
|
-
const config = (0, test_utils_1.getDefaultConfig)();
|
|
8
|
-
const attachments = [{ id: '96g6d4bg-20g0-25e8-b17e-a1a34a7adf2f' }];
|
|
9
|
-
const metadata = {
|
|
10
|
-
links: [{ title: 'Google', url: 'https://google.com', type: 'Related' }],
|
|
11
|
-
message: 'Error'
|
|
12
|
-
};
|
|
13
|
-
const builder = new runs_builder_1.RunsBuilder(config);
|
|
14
|
-
it('Should build test run', () => {
|
|
15
|
-
const run = builder.build(test, metadata, attachments);
|
|
16
|
-
expect(run)
|
|
17
|
-
.toEqual({
|
|
18
|
-
autotestExternalId: 5730363800838031,
|
|
19
|
-
completeOn: '1970-01-01T01:33:54.474Z',
|
|
20
|
-
configurationId: '1c33c90c-f34c-427b-81f6-1458f5g9c072',
|
|
21
|
-
duration: 240,
|
|
22
|
-
attachments: [
|
|
23
|
-
{
|
|
24
|
-
id: '96g6d4bg-20g0-25e8-b17e-a1a34a7adf2f'
|
|
25
|
-
}
|
|
26
|
-
],
|
|
27
|
-
links: [
|
|
28
|
-
{
|
|
29
|
-
title: 'Google',
|
|
30
|
-
url: 'https://google.com',
|
|
31
|
-
type: 'Related'
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
message: 'Error',
|
|
35
|
-
parameters: {},
|
|
36
|
-
outcome: 'Passed',
|
|
37
|
-
startedOn: '1970-01-01T01:33:54.234Z',
|
|
38
|
-
setupResults: [
|
|
39
|
-
{
|
|
40
|
-
completedOn: '1970-01-01T01:33:54.274Z',
|
|
41
|
-
description: '',
|
|
42
|
-
duration: 40,
|
|
43
|
-
outcome: 'Passed',
|
|
44
|
-
startedOn: '1970-01-01T01:33:54.234Z',
|
|
45
|
-
title: 'Step Before'
|
|
46
|
-
}
|
|
47
|
-
],
|
|
48
|
-
stepResults: [
|
|
49
|
-
{
|
|
50
|
-
completedOn: '1970-01-01T01:33:54.274Z',
|
|
51
|
-
description: '',
|
|
52
|
-
duration: 40,
|
|
53
|
-
outcome: 'Passed',
|
|
54
|
-
startedOn: '1970-01-01T01:33:54.234Z',
|
|
55
|
-
title: 'Step 1'
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
completedOn: '1970-01-01T01:33:54.434Z',
|
|
59
|
-
description: '',
|
|
60
|
-
duration: 200,
|
|
61
|
-
outcome: 'Passed',
|
|
62
|
-
startedOn: '1970-01-01T01:33:54.234Z',
|
|
63
|
-
title: 'Step 2'
|
|
64
|
-
}
|
|
65
|
-
],
|
|
66
|
-
teardownResults: [
|
|
67
|
-
{
|
|
68
|
-
completedOn: '1970-01-01T01:33:54.274Z',
|
|
69
|
-
description: '',
|
|
70
|
-
duration: 40,
|
|
71
|
-
outcome: 'Passed',
|
|
72
|
-
startedOn: '1970-01-01T01:33:54.234Z',
|
|
73
|
-
title: 'Step After'
|
|
74
|
-
}
|
|
75
|
-
],
|
|
76
|
-
traces: ''
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tests_builder_1 = require("../tests.builder");
|
|
4
|
-
const test_utils_1 = require("../../common/__tests/test.utils");
|
|
5
|
-
describe('Tests builder', () => {
|
|
6
|
-
const test = (0, test_utils_1.getDefaultTest)();
|
|
7
|
-
const config = (0, test_utils_1.getDefaultConfig)();
|
|
8
|
-
const builder = new tests_builder_1.TestsBuilder(config);
|
|
9
|
-
it('Should build test', () => {
|
|
10
|
-
const data = builder.build(test);
|
|
11
|
-
expect(data)
|
|
12
|
-
.toEqual({
|
|
13
|
-
title: 'Test',
|
|
14
|
-
description: '',
|
|
15
|
-
externalId: 5730363800838031,
|
|
16
|
-
labels: [],
|
|
17
|
-
links: [],
|
|
18
|
-
name: 'Test',
|
|
19
|
-
projectId: '96g6d4bg-20g0-25e8-b17e-a1a34a7adf2f',
|
|
20
|
-
setup: [
|
|
21
|
-
{ description: '', title: 'Step Before' }
|
|
22
|
-
],
|
|
23
|
-
steps: [
|
|
24
|
-
{ title: 'Step 1', description: "" },
|
|
25
|
-
{ title: 'Step 2', description: "" }
|
|
26
|
-
],
|
|
27
|
-
teardown: [
|
|
28
|
-
{ description: '', title: 'Step After' }
|
|
29
|
-
],
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DefaultHttpClient } from '../http/default-http-client.class';
|
|
2
|
-
export declare class AttachmentsService {
|
|
3
|
-
private readonly http;
|
|
4
|
-
constructor(http: DefaultHttpClient);
|
|
5
|
-
attach(paths: string[]): Promise<{
|
|
6
|
-
id: string;
|
|
7
|
-
}[]>;
|
|
8
|
-
attachTextLikeFile(text: string, name?: string): Promise<{
|
|
9
|
-
id: string;
|
|
10
|
-
}>;
|
|
11
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AttachmentsService = void 0;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
const hash_function_1 = require("../common/functions/hash.function");
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
class AttachmentsService {
|
|
8
|
-
constructor(http) {
|
|
9
|
-
this.http = http;
|
|
10
|
-
}
|
|
11
|
-
async attach(paths) {
|
|
12
|
-
return Promise.all(paths
|
|
13
|
-
.map(path => this.http.loadAttachment(path)
|
|
14
|
-
.then(attachment => attachment && { id: attachment.id })));
|
|
15
|
-
}
|
|
16
|
-
async attachTextLikeFile(text, name) {
|
|
17
|
-
if (!name) {
|
|
18
|
-
name = (0, hash_function_1.hash)(text) + '-attachment.txt';
|
|
19
|
-
}
|
|
20
|
-
const attachmentPath = (0, path_1.join)(__dirname, name);
|
|
21
|
-
(0, fs_1.writeFileSync)(attachmentPath, text.toString(), {
|
|
22
|
-
flag: 'w',
|
|
23
|
-
});
|
|
24
|
-
return await this.http.loadAttachment(attachmentPath)
|
|
25
|
-
.then(attachment => attachment && { id: attachment.id });
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.AttachmentsService = AttachmentsService;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AttachmentPut, AutotestResultsForTestRun } from 'testit-api-client';
|
|
2
|
-
import { Codecept } from '../types/codecept.type';
|
|
3
|
-
import { Origin } from '../types/origin.type';
|
|
4
|
-
export declare class RunsBuilder {
|
|
5
|
-
private readonly config;
|
|
6
|
-
constructor(config: Origin.Config);
|
|
7
|
-
build(test: Codecept.Test<Origin.TestConfig>, metadata: Origin.TestMetadata, attachments: AttachmentPut[]): AutotestResultsForTestRun;
|
|
8
|
-
private buildManySteps;
|
|
9
|
-
private reduceAfterOrBeforeSuites;
|
|
10
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RunsBuilder = void 0;
|
|
4
|
-
const outcome_factory_1 = require("../common/classes/outcome.factory");
|
|
5
|
-
const humanize_function_1 = require("../common/functions/humanize.function");
|
|
6
|
-
const to_iso_string_function_1 = require("../common/functions/to-iso-string.function");
|
|
7
|
-
const use_hash_function_1 = require("../common/functions/use-hash.function");
|
|
8
|
-
class RunsBuilder {
|
|
9
|
-
constructor(config) {
|
|
10
|
-
this.config = config;
|
|
11
|
-
}
|
|
12
|
-
build(test, metadata, attachments) {
|
|
13
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
const { _beforeEach, _afterEach, _afterAll, _beforeAll } = test.parent;
|
|
16
|
-
const parameters = ((_b = (_a = test === null || test === void 0 ? void 0 : test.inject) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.toString)
|
|
17
|
-
? JSON.parse((_d = (_c = test === null || test === void 0 ? void 0 : test.inject) === null || _c === void 0 ? void 0 : _c.current) === null || _d === void 0 ? void 0 : _d.toString())
|
|
18
|
-
: {};
|
|
19
|
-
const teardownResults = [
|
|
20
|
-
...this.reduceAfterOrBeforeSuites(_afterEach),
|
|
21
|
-
...this.reduceAfterOrBeforeSuites(_afterAll)
|
|
22
|
-
];
|
|
23
|
-
const setupResults = [
|
|
24
|
-
...this.reduceAfterOrBeforeSuites(_beforeEach),
|
|
25
|
-
...this.reduceAfterOrBeforeSuites(_beforeAll)
|
|
26
|
-
];
|
|
27
|
-
return {
|
|
28
|
-
configurationId: this.config.configurationId,
|
|
29
|
-
autotestExternalId: (_e = (0, use_hash_function_1.useDefaultHash)(test)) !== null && _e !== void 0 ? _e : (0, use_hash_function_1.useCompositeHash)(test),
|
|
30
|
-
links: (_f = metadata === null || metadata === void 0 ? void 0 : metadata.links) !== null && _f !== void 0 ? _f : [],
|
|
31
|
-
startedOn: (0, to_iso_string_function_1.safetyUseISOString)(test.startedAt),
|
|
32
|
-
duration: test.duration,
|
|
33
|
-
attachments,
|
|
34
|
-
parameters,
|
|
35
|
-
traces: typeof ((_g = test === null || test === void 0 ? void 0 : test.err) === null || _g === void 0 ? void 0 : _g.cliMessage) === "function" ? test.err.cliMessage() : (_h = test === null || test === void 0 ? void 0 : test.err) === null || _h === void 0 ? void 0 : _h.stack,
|
|
36
|
-
teardownResults,
|
|
37
|
-
setupResults,
|
|
38
|
-
completedOn: (0, to_iso_string_function_1.safetyUseISOString)((test === null || test === void 0 ? void 0 : test.startedAt) + (test === null || test === void 0 ? void 0 : test.duration)),
|
|
39
|
-
message: (_j = metadata === null || metadata === void 0 ? void 0 : metadata.message) !== null && _j !== void 0 ? _j : null,
|
|
40
|
-
outcome: outcome_factory_1.OutcomeFactory.create(test.state),
|
|
41
|
-
stepResults: !outcome_factory_1.OutcomeFactory.isSkipped(test.state) ? this.buildManySteps(test.steps) : null
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
buildManySteps(steps) {
|
|
45
|
-
return steps === null || steps === void 0 ? void 0 : steps.map(step => ({
|
|
46
|
-
title: `${step.name} ${(0, humanize_function_1.humanize)(step.args).join(',')}`.trim(),
|
|
47
|
-
outcome: outcome_factory_1.OutcomeFactory.create(step.status),
|
|
48
|
-
description: '',
|
|
49
|
-
startedOn: (0, to_iso_string_function_1.safetyUseISOString)(step.startedAt),
|
|
50
|
-
duration: step.duration,
|
|
51
|
-
completedOn: (0, to_iso_string_function_1.safetyUseISOString)((step === null || step === void 0 ? void 0 : step.startedAt) + (step === null || step === void 0 ? void 0 : step.duration))
|
|
52
|
-
}));
|
|
53
|
-
}
|
|
54
|
-
reduceAfterOrBeforeSuites(suite) {
|
|
55
|
-
return suite
|
|
56
|
-
.reduce((array, suite) => {
|
|
57
|
-
var _a;
|
|
58
|
-
return [
|
|
59
|
-
...array,
|
|
60
|
-
...this.buildManySteps((_a = suite === null || suite === void 0 ? void 0 : suite.steps) !== null && _a !== void 0 ? _a : [])
|
|
61
|
-
];
|
|
62
|
-
}, []);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.RunsBuilder = RunsBuilder;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/// <reference types="codeceptjs" />
|
|
2
|
-
import { AutotestPost } from 'testit-api-client';
|
|
3
|
-
import { Box } from '../common/classes/box.class';
|
|
4
|
-
import { Logger } from '../common/classes/logger.class';
|
|
5
|
-
import { DefaultHttpClient } from '../http/default-http-client.class';
|
|
6
|
-
import { RunsBuilder } from '../services/runs.builder';
|
|
7
|
-
import { TestsBuilder } from '../services/tests.builder';
|
|
8
|
-
import { Codecept } from '../types/codecept.type';
|
|
9
|
-
import { Origin } from '../types/origin.type';
|
|
10
|
-
export declare abstract class BaseStrategy {
|
|
11
|
-
protected readonly http: DefaultHttpClient;
|
|
12
|
-
protected readonly logger: Logger;
|
|
13
|
-
protected readonly config: Origin.Config;
|
|
14
|
-
protected readonly testsBuilder: TestsBuilder;
|
|
15
|
-
protected readonly runsBuilder: RunsBuilder;
|
|
16
|
-
protected readonly box: Box<Origin.TestMetadata>;
|
|
17
|
-
protected constructor(http: DefaultHttpClient, logger: Logger, config: Origin.Config);
|
|
18
|
-
collect(id: string, metadata: Origin.TestMetadata): void;
|
|
19
|
-
connectToTest(id: string, test: Codecept.Test): Promise<void>;
|
|
20
|
-
beforeTest(test: Mocha.Test): Promise<any>;
|
|
21
|
-
createOrUpdateTests(suite: any): Promise<void>;
|
|
22
|
-
protected createTestInOriginSystem(testToOriginSystem: AutotestPost, test: Codecept.Test): Promise<void>;
|
|
23
|
-
protected updateTestInOriginSystem(fromOriginSystem: AutotestPost, testToOriginSystem: AutotestPost, test: Codecept.Test): Promise<void>;
|
|
24
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseStrategy = void 0;
|
|
4
|
-
const box_class_1 = require("../common/classes/box.class");
|
|
5
|
-
const is_passed_function_1 = require("../common/functions/is-passed.function");
|
|
6
|
-
const use_hash_function_1 = require("../common/functions/use-hash.function");
|
|
7
|
-
const runs_builder_1 = require("../services/runs.builder");
|
|
8
|
-
const tests_builder_1 = require("../services/tests.builder");
|
|
9
|
-
class BaseStrategy {
|
|
10
|
-
constructor(http, logger, config) {
|
|
11
|
-
this.http = http;
|
|
12
|
-
this.logger = logger;
|
|
13
|
-
this.config = config;
|
|
14
|
-
this.testsBuilder = new tests_builder_1.TestsBuilder(this.config);
|
|
15
|
-
this.runsBuilder = new runs_builder_1.RunsBuilder(this.config);
|
|
16
|
-
this.box = new box_class_1.Box();
|
|
17
|
-
}
|
|
18
|
-
collect(id, metadata) {
|
|
19
|
-
this.box.collectWithMerge(id, metadata);
|
|
20
|
-
}
|
|
21
|
-
async connectToTest(id, test) {
|
|
22
|
-
var _a;
|
|
23
|
-
const config = (0, use_hash_function_1.useConfig)(test);
|
|
24
|
-
const ids = (_a = config === null || config === void 0 ? void 0 : config.workitemIds) !== null && _a !== void 0 ? _a : [];
|
|
25
|
-
await this.http.linkToWorkItem(id, ids);
|
|
26
|
-
}
|
|
27
|
-
beforeTest(test) {
|
|
28
|
-
return Promise.resolve();
|
|
29
|
-
}
|
|
30
|
-
async createOrUpdateTests(suite) {
|
|
31
|
-
var _a;
|
|
32
|
-
for (const test of suite.tests) {
|
|
33
|
-
const testToOriginSystem = this.testsBuilder.build(test);
|
|
34
|
-
const fromOriginSystem = await this.http.hasInSystem((_a = (0, use_hash_function_1.useDefaultHash)(test)) !== null && _a !== void 0 ? _a : (0, use_hash_function_1.useCompositeHash)(test));
|
|
35
|
-
!fromOriginSystem
|
|
36
|
-
? await this.createTestInOriginSystem(testToOriginSystem, test)
|
|
37
|
-
: await this.updateTestInOriginSystem(fromOriginSystem, testToOriginSystem, test);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async createTestInOriginSystem(testToOriginSystem, test) {
|
|
41
|
-
testToOriginSystem.shouldCreateWorkItem = this.config.automaticCreationTestCases;
|
|
42
|
-
const response = await this.http.create(testToOriginSystem);
|
|
43
|
-
if (!response) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
this.logger.log(`Test - ${response.name} created in remote system`);
|
|
47
|
-
await this.connectToTest(response.id, test);
|
|
48
|
-
}
|
|
49
|
-
async updateTestInOriginSystem(fromOriginSystem, testToOriginSystem, test) {
|
|
50
|
-
var _a;
|
|
51
|
-
const hasPassedState = (0, is_passed_function_1.isPassed)(test);
|
|
52
|
-
const config = (0, use_hash_function_1.useConfig)(test);
|
|
53
|
-
if (hasPassedState) {
|
|
54
|
-
await this.http.update(testToOriginSystem);
|
|
55
|
-
await this.connectToTest(fromOriginSystem.id, test);
|
|
56
|
-
}
|
|
57
|
-
if (!hasPassedState) {
|
|
58
|
-
await this.http.update({
|
|
59
|
-
...fromOriginSystem,
|
|
60
|
-
links: (_a = config === null || config === void 0 ? void 0 : config.links) !== null && _a !== void 0 ? _a : []
|
|
61
|
-
});
|
|
62
|
-
this.logger.log(`Test - ${fromOriginSystem.name} updated in remote system`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.BaseStrategy = BaseStrategy;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Logger } from '../common/classes/logger.class';
|
|
2
|
-
import { DefaultHttpClient } from '../http/default-http-client.class';
|
|
3
|
-
import { Strategy } from '../types/strategy.type';
|
|
4
|
-
import { Origin } from '../types/origin.type';
|
|
5
|
-
import { BaseStrategy } from './base-strategy.class';
|
|
6
|
-
export declare class DefaultStrategy extends BaseStrategy implements Strategy {
|
|
7
|
-
protected readonly http: DefaultHttpClient;
|
|
8
|
-
protected readonly logger: Logger;
|
|
9
|
-
protected readonly config: Origin.Config;
|
|
10
|
-
private readonly attachments;
|
|
11
|
-
constructor(http: DefaultHttpClient, logger: Logger, config: Origin.Config);
|
|
12
|
-
bootstrap(): Promise<void>;
|
|
13
|
-
teardown(): Promise<void>;
|
|
14
|
-
transferTestsToSystem(suite: any): Promise<void>;
|
|
15
|
-
transferRunsToSystem(suite: any): Promise<void>;
|
|
16
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="codeceptjs" />
|
|
2
|
-
import { Logger } from '../common/classes/logger.class';
|
|
3
|
-
import { DefaultHttpClient } from '../http/default-http-client.class';
|
|
4
|
-
import { Codecept } from '../types/codecept.type';
|
|
5
|
-
import { Strategy } from '../types/strategy.type';
|
|
6
|
-
import { Origin } from '../types/origin.type';
|
|
7
|
-
import { BaseStrategy } from './base-strategy.class';
|
|
8
|
-
export declare class PartialStrategy extends BaseStrategy implements Strategy {
|
|
9
|
-
protected readonly http: DefaultHttpClient;
|
|
10
|
-
protected readonly logger: Logger;
|
|
11
|
-
protected readonly config: Origin.Config;
|
|
12
|
-
private readonly attachments;
|
|
13
|
-
private readonly testsInRun;
|
|
14
|
-
constructor(http: DefaultHttpClient, logger: Logger, config: Origin.Config);
|
|
15
|
-
bootstrap(): Promise<void>;
|
|
16
|
-
teardown(): Promise<void>;
|
|
17
|
-
beforeTest(test: Codecept.Test): Promise<void>;
|
|
18
|
-
transferRunsToSystem(suite: any): Promise<void>;
|
|
19
|
-
transferTestsToSystem(suite: Mocha.Suite): Promise<void>;
|
|
20
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PartialStrategy = void 0;
|
|
4
|
-
const use_hash_function_1 = require("../common/functions/use-hash.function");
|
|
5
|
-
const attachments_service_1 = require("../services/attachments.service");
|
|
6
|
-
const base_strategy_class_1 = require("./base-strategy.class");
|
|
7
|
-
class PartialStrategy extends base_strategy_class_1.BaseStrategy {
|
|
8
|
-
constructor(http, logger, config) {
|
|
9
|
-
super(http, logger, config);
|
|
10
|
-
this.http = http;
|
|
11
|
-
this.logger = logger;
|
|
12
|
-
this.config = config;
|
|
13
|
-
this.attachments = new attachments_service_1.AttachmentsService(this.http);
|
|
14
|
-
this.testsInRun = this.http.getTestsIdsByRunId(this.config.testRunId);
|
|
15
|
-
}
|
|
16
|
-
async bootstrap() {
|
|
17
|
-
await this.http.startRunIfNeeded(this.config.testRunId);
|
|
18
|
-
}
|
|
19
|
-
async teardown() {
|
|
20
|
-
await this.http.completeRunIfNeeded(this.config.testRunId);
|
|
21
|
-
}
|
|
22
|
-
async beforeTest(test) {
|
|
23
|
-
var _a;
|
|
24
|
-
const tests = await this.testsInRun;
|
|
25
|
-
const hash = (_a = (0, use_hash_function_1.useDefaultHash)(test)) !== null && _a !== void 0 ? _a : (0, use_hash_function_1.useCompositeHash)(test);
|
|
26
|
-
if (!tests.includes(hash.toString())) {
|
|
27
|
-
test.run = () => test.skip();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async transferRunsToSystem(suite) {
|
|
31
|
-
const tests = await this.testsInRun;
|
|
32
|
-
const data = await Promise.all(suite.tests
|
|
33
|
-
.filter(test => {
|
|
34
|
-
var _a;
|
|
35
|
-
const hash = (_a = (0, use_hash_function_1.useDefaultHash)(test)) !== null && _a !== void 0 ? _a : (0, use_hash_function_1.useCompositeHash)(test);
|
|
36
|
-
return tests.includes(hash.toString());
|
|
37
|
-
})
|
|
38
|
-
.map(async (test) => {
|
|
39
|
-
var _a, _b, _c;
|
|
40
|
-
const config = this.box.get(test.id);
|
|
41
|
-
const screenshot = (_a = test.artifacts) === null || _a === void 0 ? void 0 : _a.screenshot;
|
|
42
|
-
const clientUrls = (_b = config === null || config === void 0 ? void 0 : config.attachments) !== null && _b !== void 0 ? _b : [];
|
|
43
|
-
if (screenshot) {
|
|
44
|
-
clientUrls.push(screenshot);
|
|
45
|
-
}
|
|
46
|
-
const attachments = await this.attachments.attach(clientUrls);
|
|
47
|
-
if (config === null || config === void 0 ? void 0 : config.text) {
|
|
48
|
-
const attach = await this.attachments
|
|
49
|
-
.attachTextLikeFile(config.text.content, (_c = config.text) === null || _c === void 0 ? void 0 : _c.name);
|
|
50
|
-
attachments.push(attach);
|
|
51
|
-
}
|
|
52
|
-
return this.runsBuilder.build(test, config, attachments);
|
|
53
|
-
}));
|
|
54
|
-
if (data.length) {
|
|
55
|
-
await this.http.updateManyRuns(data);
|
|
56
|
-
this.logger.log(`Test run - ${this.config.testRunId} transferred to remote system`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async transferTestsToSystem(suite) {
|
|
60
|
-
const tests = await this.testsInRun;
|
|
61
|
-
const suiteWithNeededTests = {
|
|
62
|
-
...suite,
|
|
63
|
-
tests: suite.tests.filter((test) => {
|
|
64
|
-
var _a;
|
|
65
|
-
const hash = (_a = (0, use_hash_function_1.useDefaultHash)(test)) !== null && _a !== void 0 ? _a : (0, use_hash_function_1.useCompositeHash)(test);
|
|
66
|
-
return tests.includes(hash.toString());
|
|
67
|
-
})
|
|
68
|
-
};
|
|
69
|
-
await this.createOrUpdateTests(suiteWithNeededTests);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.PartialStrategy = PartialStrategy;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/// <reference types="codeceptjs" />
|
|
2
|
-
import { Logger } from '../common/classes/logger.class';
|
|
3
|
-
import { DefaultHttpClient } from '../http/default-http-client.class';
|
|
4
|
-
import { Strategy } from '../types/strategy.type';
|
|
5
|
-
import { Origin } from '../types/origin.type';
|
|
6
|
-
import { BaseStrategy } from './base-strategy.class';
|
|
7
|
-
export declare class ScratchStrategy extends BaseStrategy implements Strategy {
|
|
8
|
-
protected readonly http: DefaultHttpClient;
|
|
9
|
-
protected readonly logger: Logger;
|
|
10
|
-
protected readonly config: Origin.Config;
|
|
11
|
-
private readonly attachments;
|
|
12
|
-
private run;
|
|
13
|
-
constructor(http: DefaultHttpClient, logger: Logger, config: Origin.Config);
|
|
14
|
-
bootstrap(): Promise<void>;
|
|
15
|
-
teardown(): Promise<void>;
|
|
16
|
-
transferTestsToSystem(suite: Mocha.Suite): Promise<void>;
|
|
17
|
-
transferRunsToSystem(suite: any): Promise<void>;
|
|
18
|
-
}
|