engine-dependency 1.0.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/dist/cjs/constants.cjs +28 -0
- package/dist/cjs/services/base.service.cjs +8 -0
- package/dist/cjs/services/test-information.service.cjs +62 -41
- package/dist/esm/constants.js +24 -0
- package/dist/esm/services/base.service.js +8 -0
- package/dist/esm/services/test-information.service.js +62 -41
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_ENDPOINTS = {
|
|
4
|
+
TEST_RESULTS: '/api/test-results'
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const ENV_VARS = {
|
|
8
|
+
BASE_URL: 'DATA_ENGINE_BASE_URL',
|
|
9
|
+
TOKEN_ENDPOINT: 'DATA_ENGINE_GENERATE_TOKEN',
|
|
10
|
+
SERVICE_ACCOUNT: 'DATA_ENGINE_SERVICE_ACCOUNT',
|
|
11
|
+
SERVICE_PASSWORD: 'DATA_ENGINE_SERVICE_PASSWORD',
|
|
12
|
+
PROJECT_NAME: 'PROJECT_NAME',
|
|
13
|
+
ENV: 'ENV',
|
|
14
|
+
BUILD_ID: 'BUILD_BUILDID',
|
|
15
|
+
SOURCE_VERSION: 'BUILD_SOURCEVERSION',
|
|
16
|
+
SOURCE_BRANCH: 'BUILD_SOURCEBRANCH',
|
|
17
|
+
// Azure DevOps specific vars
|
|
18
|
+
TEAM_FOUNDATION_COLLECTION_URI: 'SYSTEM_TEAMFOUNDATIONCOLLECTIONURI',
|
|
19
|
+
TEAM_PROJECT: 'SYSTEM_TEAMPROJECT'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const PROVIDERS = {
|
|
23
|
+
AZURE_DEVOPS: 'azure-devops'
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.DEFAULT_ENDPOINTS = DEFAULT_ENDPOINTS;
|
|
27
|
+
exports.ENV_VARS = ENV_VARS;
|
|
28
|
+
exports.PROVIDERS = PROVIDERS;
|
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
class BaseService {
|
|
6
|
+
/**
|
|
7
|
+
* Sends a POST request to the specified URL.
|
|
8
|
+
* @param {string} url - The endpoint URL.
|
|
9
|
+
* @param {object} body - The request body.
|
|
10
|
+
* @param {object} [headers={}] - Optional headers.
|
|
11
|
+
* @returns {Promise<{data: any, status: number}>} The response data and status code.
|
|
12
|
+
* @throws {Error} If the response is not ok.
|
|
13
|
+
*/
|
|
6
14
|
async sendPOSTRequest(url, body, headers = {}) {
|
|
7
15
|
const response = await fetch(url, {
|
|
8
16
|
method: 'POST',
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var services_base_service = require('./base.service.cjs');
|
|
4
|
+
var constants = require('../constants.cjs');
|
|
4
5
|
|
|
5
6
|
class TestInformationService extends services_base_service.default {
|
|
7
|
+
/**
|
|
8
|
+
* @param {object} config - Configuration object.
|
|
9
|
+
*/
|
|
6
10
|
constructor(config = {}) {
|
|
7
11
|
super();
|
|
8
|
-
this.baseUrl = config.baseUrl || process.env.
|
|
9
|
-
this.tokenEndpoint = config.tokenEndpoint || process.env.
|
|
10
|
-
this.testResultsEndpoint = config.testResultsEndpoint ||
|
|
11
|
-
this.serviceAccount = config.serviceAccount || process.env.
|
|
12
|
-
this.servicePassword = config.servicePassword || process.env.
|
|
12
|
+
this.baseUrl = config.baseUrl || process.env[constants.ENV_VARS.BASE_URL];
|
|
13
|
+
this.tokenEndpoint = config.tokenEndpoint || process.env[constants.ENV_VARS.TOKEN_ENDPOINT];
|
|
14
|
+
this.testResultsEndpoint = config.testResultsEndpoint || constants.DEFAULT_ENDPOINTS.TEST_RESULTS;
|
|
15
|
+
this.serviceAccount = config.serviceAccount || process.env[constants.ENV_VARS.SERVICE_ACCOUNT];
|
|
16
|
+
this.servicePassword = config.servicePassword || process.env[constants.ENV_VARS.SERVICE_PASSWORD];
|
|
13
17
|
}
|
|
14
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Generates an authentication token.
|
|
21
|
+
* @returns {Promise<string|undefined>} The token or undefined if failed.
|
|
22
|
+
*/
|
|
15
23
|
async generateToken() {
|
|
16
24
|
try {
|
|
17
25
|
const response = await this.sendPOSTRequest(`${this.baseUrl}${this.tokenEndpoint}`, {
|
|
@@ -20,21 +28,26 @@ class TestInformationService extends services_base_service.default {
|
|
|
20
28
|
});
|
|
21
29
|
return response.data.token;
|
|
22
30
|
} catch (error) {
|
|
23
|
-
console.
|
|
31
|
+
console.error(`Error generando token para test results: ${error?.message || error}`);
|
|
24
32
|
}
|
|
25
33
|
}
|
|
26
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Builds the payload for standard test results.
|
|
37
|
+
* @param {object} testInfo - The test information.
|
|
38
|
+
* @returns {object} The payload.
|
|
39
|
+
*/
|
|
27
40
|
buildTestPayload(testInfo) {
|
|
28
41
|
return {
|
|
29
42
|
testTitle: testInfo.title,
|
|
30
43
|
testStatus: testInfo.status || testInfo.state,
|
|
31
44
|
duration: testInfo.duration,
|
|
32
45
|
testFile: testInfo.file,
|
|
33
|
-
testProject: process.env.PROJECT_NAME,
|
|
46
|
+
testProject: process.env[constants.ENV_VARS.PROJECT_NAME],
|
|
34
47
|
retries: (testInfo.retries || testInfo.retries?.length) ?? 0,
|
|
35
48
|
retry: testInfo.retry ?? 0,
|
|
36
49
|
tags: testInfo.tags || [],
|
|
37
|
-
environment: process.env.ENV,
|
|
50
|
+
environment: process.env[constants.ENV_VARS.ENV],
|
|
38
51
|
testInfo: {
|
|
39
52
|
title: testInfo.title,
|
|
40
53
|
expectedStatus: testInfo.expectedStatus || null,
|
|
@@ -42,27 +55,32 @@ class TestInformationService extends services_base_service.default {
|
|
|
42
55
|
timeout: testInfo.timeout || testInfo.timedOut,
|
|
43
56
|
errors: testInfo.errors || testInfo.err || null
|
|
44
57
|
},
|
|
45
|
-
pipelineId: process.env.
|
|
46
|
-
commitSha: process.env.
|
|
47
|
-
branch: process.env.
|
|
48
|
-
runUrl: process.env.
|
|
49
|
-
? `${process.env.
|
|
58
|
+
pipelineId: process.env[constants.ENV_VARS.BUILD_ID] || null,
|
|
59
|
+
commitSha: process.env[constants.ENV_VARS.SOURCE_VERSION] || null,
|
|
60
|
+
branch: process.env[constants.ENV_VARS.SOURCE_BRANCH] || null,
|
|
61
|
+
runUrl: process.env[constants.ENV_VARS.BUILD_ID]
|
|
62
|
+
? `${process.env[constants.ENV_VARS.TEAM_FOUNDATION_COLLECTION_URI]}${process.env[constants.ENV_VARS.TEAM_PROJECT]}/_build/results?buildId=${process.env[constants.ENV_VARS.BUILD_ID]}`
|
|
50
63
|
: null,
|
|
51
|
-
provider: process.env.
|
|
64
|
+
provider: process.env[constants.ENV_VARS.BUILD_ID] ? constants.PROVIDERS.AZURE_DEVOPS : null
|
|
52
65
|
};
|
|
53
66
|
}
|
|
54
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Builds the payload for WDIO test results.
|
|
70
|
+
* @param {object} testInfo - The test information.
|
|
71
|
+
* @returns {object} The payload.
|
|
72
|
+
*/
|
|
55
73
|
buildTestPayloadForWDIO(testInfo) {
|
|
56
74
|
return {
|
|
57
75
|
testTitle: testInfo.title,
|
|
58
76
|
testStatus: testInfo.state,
|
|
59
77
|
duration: testInfo.duration,
|
|
60
78
|
testFile: testInfo.file,
|
|
61
|
-
testProject: process.env.PROJECT_NAME,
|
|
79
|
+
testProject: process.env[constants.ENV_VARS.PROJECT_NAME],
|
|
62
80
|
retries: testInfo.retries ?? 0,
|
|
63
81
|
retry: testInfo.retry ?? 0,
|
|
64
82
|
tags: testInfo.tags || [],
|
|
65
|
-
environment: process.env.ENV,
|
|
83
|
+
environment: process.env[constants.ENV_VARS.ENV],
|
|
66
84
|
testInfo: {},
|
|
67
85
|
pipelineId: "",
|
|
68
86
|
commitSha: "",
|
|
@@ -72,51 +90,54 @@ class TestInformationService extends services_base_service.default {
|
|
|
72
90
|
};
|
|
73
91
|
}
|
|
74
92
|
|
|
75
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Internal method to send test result.
|
|
95
|
+
* @param {object} payload - The payload to send.
|
|
96
|
+
* @param {string} testTitle - The title of the test for logging.
|
|
97
|
+
* @param {string} testStatus - The status of the test for logging.
|
|
98
|
+
* @returns {Promise<any>} The response data.
|
|
99
|
+
*/
|
|
100
|
+
async _sendResult(payload, testTitle, testStatus) {
|
|
76
101
|
if (!process.env.CI) return;
|
|
77
102
|
|
|
78
103
|
try {
|
|
79
104
|
const token = await this.generateToken();
|
|
80
105
|
if (!token) {
|
|
81
|
-
console.
|
|
106
|
+
console.error('No se pudo obtener el token, omitiendo envio de resultado de test');
|
|
82
107
|
return;
|
|
83
108
|
}
|
|
84
109
|
|
|
85
|
-
const payload = this.buildTestPayload(testInfo);
|
|
86
110
|
const response = await this.sendPOSTRequest(
|
|
87
111
|
`${this.baseUrl}${this.testResultsEndpoint}`,
|
|
88
112
|
payload,
|
|
89
113
|
{ Authorization: `Bearer ${token}` }
|
|
90
114
|
);
|
|
91
115
|
|
|
92
|
-
console.log(`Resultado de test enviado: ${
|
|
116
|
+
console.log(`Resultado de test enviado: ${testTitle} - ${testStatus}`);
|
|
93
117
|
return response?.data;
|
|
94
118
|
} catch (error) {
|
|
95
|
-
console.
|
|
119
|
+
console.error(`Error enviando resultado de test: ${error?.message || error}`);
|
|
96
120
|
}
|
|
97
121
|
}
|
|
98
122
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const payload = this.buildTestPayloadForWDIO(testInfo);
|
|
109
|
-
const response = await this.sendPOSTRequest(
|
|
110
|
-
`${this.baseUrl}${this.testResultsEndpoint}`,
|
|
111
|
-
payload,
|
|
112
|
-
{ Authorization: `Bearer ${token}` }
|
|
113
|
-
);
|
|
123
|
+
/**
|
|
124
|
+
* Sends the test result.
|
|
125
|
+
* @param {object} testInfo - The test information.
|
|
126
|
+
* @returns {Promise<any>} The response data.
|
|
127
|
+
*/
|
|
128
|
+
async sendTestResult(testInfo) {
|
|
129
|
+
const payload = this.buildTestPayload(testInfo);
|
|
130
|
+
return this._sendResult(payload, testInfo.title, testInfo.status || testInfo.state);
|
|
131
|
+
}
|
|
114
132
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Sends the WDIO test result.
|
|
135
|
+
* @param {object} testInfo - The test information.
|
|
136
|
+
* @returns {Promise<any>} The response data.
|
|
137
|
+
*/
|
|
138
|
+
async sendWDIOTestResult(testInfo) {
|
|
139
|
+
const payload = this.buildTestPayloadForWDIO(testInfo);
|
|
140
|
+
return this._sendResult(payload, testInfo.title, testInfo.state);
|
|
120
141
|
}
|
|
121
142
|
}
|
|
122
143
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const DEFAULT_ENDPOINTS = {
|
|
2
|
+
TEST_RESULTS: '/api/test-results'
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
const ENV_VARS = {
|
|
6
|
+
BASE_URL: 'DATA_ENGINE_BASE_URL',
|
|
7
|
+
TOKEN_ENDPOINT: 'DATA_ENGINE_GENERATE_TOKEN',
|
|
8
|
+
SERVICE_ACCOUNT: 'DATA_ENGINE_SERVICE_ACCOUNT',
|
|
9
|
+
SERVICE_PASSWORD: 'DATA_ENGINE_SERVICE_PASSWORD',
|
|
10
|
+
PROJECT_NAME: 'PROJECT_NAME',
|
|
11
|
+
ENV: 'ENV',
|
|
12
|
+
BUILD_ID: 'BUILD_BUILDID',
|
|
13
|
+
SOURCE_VERSION: 'BUILD_SOURCEVERSION',
|
|
14
|
+
SOURCE_BRANCH: 'BUILD_SOURCEBRANCH',
|
|
15
|
+
// Azure DevOps specific vars
|
|
16
|
+
TEAM_FOUNDATION_COLLECTION_URI: 'SYSTEM_TEAMFOUNDATIONCOLLECTIONURI',
|
|
17
|
+
TEAM_PROJECT: 'SYSTEM_TEAMPROJECT'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const PROVIDERS = {
|
|
21
|
+
AZURE_DEVOPS: 'azure-devops'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { DEFAULT_ENDPOINTS, ENV_VARS, PROVIDERS };
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
class BaseService {
|
|
2
|
+
/**
|
|
3
|
+
* Sends a POST request to the specified URL.
|
|
4
|
+
* @param {string} url - The endpoint URL.
|
|
5
|
+
* @param {object} body - The request body.
|
|
6
|
+
* @param {object} [headers={}] - Optional headers.
|
|
7
|
+
* @returns {Promise<{data: any, status: number}>} The response data and status code.
|
|
8
|
+
* @throws {Error} If the response is not ok.
|
|
9
|
+
*/
|
|
2
10
|
async sendPOSTRequest(url, body, headers = {}) {
|
|
3
11
|
const response = await fetch(url, {
|
|
4
12
|
method: 'POST',
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import BaseService from './base.service.js';
|
|
2
|
+
import { ENV_VARS, DEFAULT_ENDPOINTS, PROVIDERS } from '../constants.js';
|
|
2
3
|
|
|
3
4
|
class TestInformationService extends BaseService {
|
|
5
|
+
/**
|
|
6
|
+
* @param {object} config - Configuration object.
|
|
7
|
+
*/
|
|
4
8
|
constructor(config = {}) {
|
|
5
9
|
super();
|
|
6
|
-
this.baseUrl = config.baseUrl || process.env.
|
|
7
|
-
this.tokenEndpoint = config.tokenEndpoint || process.env.
|
|
8
|
-
this.testResultsEndpoint = config.testResultsEndpoint ||
|
|
9
|
-
this.serviceAccount = config.serviceAccount || process.env.
|
|
10
|
-
this.servicePassword = config.servicePassword || process.env.
|
|
10
|
+
this.baseUrl = config.baseUrl || process.env[ENV_VARS.BASE_URL];
|
|
11
|
+
this.tokenEndpoint = config.tokenEndpoint || process.env[ENV_VARS.TOKEN_ENDPOINT];
|
|
12
|
+
this.testResultsEndpoint = config.testResultsEndpoint || DEFAULT_ENDPOINTS.TEST_RESULTS;
|
|
13
|
+
this.serviceAccount = config.serviceAccount || process.env[ENV_VARS.SERVICE_ACCOUNT];
|
|
14
|
+
this.servicePassword = config.servicePassword || process.env[ENV_VARS.SERVICE_PASSWORD];
|
|
11
15
|
}
|
|
12
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Generates an authentication token.
|
|
19
|
+
* @returns {Promise<string|undefined>} The token or undefined if failed.
|
|
20
|
+
*/
|
|
13
21
|
async generateToken() {
|
|
14
22
|
try {
|
|
15
23
|
const response = await this.sendPOSTRequest(`${this.baseUrl}${this.tokenEndpoint}`, {
|
|
@@ -18,21 +26,26 @@ class TestInformationService extends BaseService {
|
|
|
18
26
|
});
|
|
19
27
|
return response.data.token;
|
|
20
28
|
} catch (error) {
|
|
21
|
-
console.
|
|
29
|
+
console.error(`Error generando token para test results: ${error?.message || error}`);
|
|
22
30
|
}
|
|
23
31
|
}
|
|
24
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Builds the payload for standard test results.
|
|
35
|
+
* @param {object} testInfo - The test information.
|
|
36
|
+
* @returns {object} The payload.
|
|
37
|
+
*/
|
|
25
38
|
buildTestPayload(testInfo) {
|
|
26
39
|
return {
|
|
27
40
|
testTitle: testInfo.title,
|
|
28
41
|
testStatus: testInfo.status || testInfo.state,
|
|
29
42
|
duration: testInfo.duration,
|
|
30
43
|
testFile: testInfo.file,
|
|
31
|
-
testProject: process.env.PROJECT_NAME,
|
|
44
|
+
testProject: process.env[ENV_VARS.PROJECT_NAME],
|
|
32
45
|
retries: (testInfo.retries || testInfo.retries?.length) ?? 0,
|
|
33
46
|
retry: testInfo.retry ?? 0,
|
|
34
47
|
tags: testInfo.tags || [],
|
|
35
|
-
environment: process.env.ENV,
|
|
48
|
+
environment: process.env[ENV_VARS.ENV],
|
|
36
49
|
testInfo: {
|
|
37
50
|
title: testInfo.title,
|
|
38
51
|
expectedStatus: testInfo.expectedStatus || null,
|
|
@@ -40,27 +53,32 @@ class TestInformationService extends BaseService {
|
|
|
40
53
|
timeout: testInfo.timeout || testInfo.timedOut,
|
|
41
54
|
errors: testInfo.errors || testInfo.err || null
|
|
42
55
|
},
|
|
43
|
-
pipelineId: process.env.
|
|
44
|
-
commitSha: process.env.
|
|
45
|
-
branch: process.env.
|
|
46
|
-
runUrl: process.env.
|
|
47
|
-
? `${process.env.
|
|
56
|
+
pipelineId: process.env[ENV_VARS.BUILD_ID] || null,
|
|
57
|
+
commitSha: process.env[ENV_VARS.SOURCE_VERSION] || null,
|
|
58
|
+
branch: process.env[ENV_VARS.SOURCE_BRANCH] || null,
|
|
59
|
+
runUrl: process.env[ENV_VARS.BUILD_ID]
|
|
60
|
+
? `${process.env[ENV_VARS.TEAM_FOUNDATION_COLLECTION_URI]}${process.env[ENV_VARS.TEAM_PROJECT]}/_build/results?buildId=${process.env[ENV_VARS.BUILD_ID]}`
|
|
48
61
|
: null,
|
|
49
|
-
provider: process.env.
|
|
62
|
+
provider: process.env[ENV_VARS.BUILD_ID] ? PROVIDERS.AZURE_DEVOPS : null
|
|
50
63
|
};
|
|
51
64
|
}
|
|
52
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Builds the payload for WDIO test results.
|
|
68
|
+
* @param {object} testInfo - The test information.
|
|
69
|
+
* @returns {object} The payload.
|
|
70
|
+
*/
|
|
53
71
|
buildTestPayloadForWDIO(testInfo) {
|
|
54
72
|
return {
|
|
55
73
|
testTitle: testInfo.title,
|
|
56
74
|
testStatus: testInfo.state,
|
|
57
75
|
duration: testInfo.duration,
|
|
58
76
|
testFile: testInfo.file,
|
|
59
|
-
testProject: process.env.PROJECT_NAME,
|
|
77
|
+
testProject: process.env[ENV_VARS.PROJECT_NAME],
|
|
60
78
|
retries: testInfo.retries ?? 0,
|
|
61
79
|
retry: testInfo.retry ?? 0,
|
|
62
80
|
tags: testInfo.tags || [],
|
|
63
|
-
environment: process.env.ENV,
|
|
81
|
+
environment: process.env[ENV_VARS.ENV],
|
|
64
82
|
testInfo: {},
|
|
65
83
|
pipelineId: "",
|
|
66
84
|
commitSha: "",
|
|
@@ -70,51 +88,54 @@ class TestInformationService extends BaseService {
|
|
|
70
88
|
};
|
|
71
89
|
}
|
|
72
90
|
|
|
73
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Internal method to send test result.
|
|
93
|
+
* @param {object} payload - The payload to send.
|
|
94
|
+
* @param {string} testTitle - The title of the test for logging.
|
|
95
|
+
* @param {string} testStatus - The status of the test for logging.
|
|
96
|
+
* @returns {Promise<any>} The response data.
|
|
97
|
+
*/
|
|
98
|
+
async _sendResult(payload, testTitle, testStatus) {
|
|
74
99
|
if (!process.env.CI) return;
|
|
75
100
|
|
|
76
101
|
try {
|
|
77
102
|
const token = await this.generateToken();
|
|
78
103
|
if (!token) {
|
|
79
|
-
console.
|
|
104
|
+
console.error('No se pudo obtener el token, omitiendo envio de resultado de test');
|
|
80
105
|
return;
|
|
81
106
|
}
|
|
82
107
|
|
|
83
|
-
const payload = this.buildTestPayload(testInfo);
|
|
84
108
|
const response = await this.sendPOSTRequest(
|
|
85
109
|
`${this.baseUrl}${this.testResultsEndpoint}`,
|
|
86
110
|
payload,
|
|
87
111
|
{ Authorization: `Bearer ${token}` }
|
|
88
112
|
);
|
|
89
113
|
|
|
90
|
-
console.log(`Resultado de test enviado: ${
|
|
114
|
+
console.log(`Resultado de test enviado: ${testTitle} - ${testStatus}`);
|
|
91
115
|
return response?.data;
|
|
92
116
|
} catch (error) {
|
|
93
|
-
console.
|
|
117
|
+
console.error(`Error enviando resultado de test: ${error?.message || error}`);
|
|
94
118
|
}
|
|
95
119
|
}
|
|
96
120
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const payload = this.buildTestPayloadForWDIO(testInfo);
|
|
107
|
-
const response = await this.sendPOSTRequest(
|
|
108
|
-
`${this.baseUrl}${this.testResultsEndpoint}`,
|
|
109
|
-
payload,
|
|
110
|
-
{ Authorization: `Bearer ${token}` }
|
|
111
|
-
);
|
|
121
|
+
/**
|
|
122
|
+
* Sends the test result.
|
|
123
|
+
* @param {object} testInfo - The test information.
|
|
124
|
+
* @returns {Promise<any>} The response data.
|
|
125
|
+
*/
|
|
126
|
+
async sendTestResult(testInfo) {
|
|
127
|
+
const payload = this.buildTestPayload(testInfo);
|
|
128
|
+
return this._sendResult(payload, testInfo.title, testInfo.status || testInfo.state);
|
|
129
|
+
}
|
|
112
130
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Sends the WDIO test result.
|
|
133
|
+
* @param {object} testInfo - The test information.
|
|
134
|
+
* @returns {Promise<any>} The response data.
|
|
135
|
+
*/
|
|
136
|
+
async sendWDIOTestResult(testInfo) {
|
|
137
|
+
const payload = this.buildTestPayloadForWDIO(testInfo);
|
|
138
|
+
return this._sendResult(payload, testInfo.title, testInfo.state);
|
|
118
139
|
}
|
|
119
140
|
}
|
|
120
141
|
|