engine-dependency 1.0.3 → 1.0.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.
@@ -26,7 +26,7 @@ class TestInformationService extends services_base_service.default {
26
26
 
27
27
  buildTestPayload(testInfo) {
28
28
  return {
29
- testTitle: testInfo.titlePath?.join(' > ') || testInfo.title,
29
+ testTitle: testInfo.title,
30
30
  testStatus: testInfo.status || testInfo.state,
31
31
  duration: testInfo.duration,
32
32
  testFile: testInfo.file,
@@ -52,6 +52,26 @@ class TestInformationService extends services_base_service.default {
52
52
  };
53
53
  }
54
54
 
55
+ buildLocalPayload(testInfo) {
56
+ return {
57
+ testTitle: testInfo.title,
58
+ testStatus: testInfo.status || testInfo.state,
59
+ duration: testInfo.duration,
60
+ testFile: testInfo.file,
61
+ testProject: process.env.PROJECT_NAME,
62
+ retries: testInfo.retries || testInfo.retries?.length || 0,
63
+ retry: testInfo.retry ?? 0,
64
+ tags: testInfo.tags || [],
65
+ environment: process.env.ENV,
66
+ testInfo: testInfo,
67
+ pipelineId: null,
68
+ commitSha: null,
69
+ branch: null,
70
+ runUrl: null,
71
+ provider: null
72
+ };
73
+ }
74
+
55
75
  async sendTestResult(testInfo) {
56
76
  if (!process.env.CI) return;
57
77
 
@@ -75,6 +95,29 @@ class TestInformationService extends services_base_service.default {
75
95
  console.log(`Error enviando resultado de test: ${error?.message || error}`);
76
96
  }
77
97
  }
98
+
99
+ async sendLocalTestResult(testInfo) {
100
+ try {
101
+
102
+ const token = await this.generateToken();
103
+ if (!token) {
104
+ console.log('No se pudo obtener el token, omitiendo envio de resultado de test');
105
+ return;
106
+ }
107
+
108
+ const payload = this.buildLocalPayload(testInfo);
109
+ const response = await this.sendPOSTRequest(
110
+ `${this.baseUrl}${this.testResultsEndpoint}`,
111
+ payload,
112
+ { Authorization: `Bearer ${token}` }
113
+ );
114
+
115
+ console.log(`Resultado de test enviado: ${testInfo.title} - ${testInfo.status}`);
116
+ return response?.data;
117
+ } catch (error) {
118
+ console.log(`Error enviando resultado de test: ${error?.message || error}`);
119
+ }
120
+ }
78
121
  }
79
122
 
80
123
  exports.TestInformationService = TestInformationService;
@@ -24,7 +24,7 @@ class TestInformationService extends BaseService {
24
24
 
25
25
  buildTestPayload(testInfo) {
26
26
  return {
27
- testTitle: testInfo.titlePath?.join(' > ') || testInfo.title,
27
+ testTitle: testInfo.title,
28
28
  testStatus: testInfo.status || testInfo.state,
29
29
  duration: testInfo.duration,
30
30
  testFile: testInfo.file,
@@ -50,6 +50,26 @@ class TestInformationService extends BaseService {
50
50
  };
51
51
  }
52
52
 
53
+ buildLocalPayload(testInfo) {
54
+ return {
55
+ testTitle: testInfo.title,
56
+ testStatus: testInfo.status || testInfo.state,
57
+ duration: testInfo.duration,
58
+ testFile: testInfo.file,
59
+ testProject: process.env.PROJECT_NAME,
60
+ retries: testInfo.retries || testInfo.retries?.length || 0,
61
+ retry: testInfo.retry ?? 0,
62
+ tags: testInfo.tags || [],
63
+ environment: process.env.ENV,
64
+ testInfo: testInfo,
65
+ pipelineId: null,
66
+ commitSha: null,
67
+ branch: null,
68
+ runUrl: null,
69
+ provider: null
70
+ };
71
+ }
72
+
53
73
  async sendTestResult(testInfo) {
54
74
  if (!process.env.CI) return;
55
75
 
@@ -73,6 +93,29 @@ class TestInformationService extends BaseService {
73
93
  console.log(`Error enviando resultado de test: ${error?.message || error}`);
74
94
  }
75
95
  }
96
+
97
+ async sendLocalTestResult(testInfo) {
98
+ try {
99
+
100
+ const token = await this.generateToken();
101
+ if (!token) {
102
+ console.log('No se pudo obtener el token, omitiendo envio de resultado de test');
103
+ return;
104
+ }
105
+
106
+ const payload = this.buildLocalPayload(testInfo);
107
+ const response = await this.sendPOSTRequest(
108
+ `${this.baseUrl}${this.testResultsEndpoint}`,
109
+ payload,
110
+ { Authorization: `Bearer ${token}` }
111
+ );
112
+
113
+ console.log(`Resultado de test enviado: ${testInfo.title} - ${testInfo.status}`);
114
+ return response?.data;
115
+ } catch (error) {
116
+ console.log(`Error enviando resultado de test: ${error?.message || error}`);
117
+ }
118
+ }
76
119
  }
77
120
 
78
121
  export { TestInformationService };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "engine-dependency",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Dependencia centralizada para envio de datos via API al servicio Data Engine",
5
5
  "type": "module",
6
6
  "main": "dist/cjs/index.cjs",