froth-webdriverio-framework 4.0.36 → 4.0.38
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.
|
@@ -38,7 +38,9 @@ async function getExecuitonDetails(frothUrl, token, id) {
|
|
|
38
38
|
// const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
39
39
|
// Retry the request with the new token
|
|
40
40
|
// return getExecuitonDetails(frothUrl, newToken, id);
|
|
41
|
-
console.log("Unauthorized, token expired" + response.status)
|
|
41
|
+
// console.log("Unauthorized, token expired" + response.status)
|
|
42
|
+
console.error("Unauthorized, token expired" + response.status);
|
|
43
|
+
|
|
42
44
|
} else {
|
|
43
45
|
const errorText = await response.text();
|
|
44
46
|
console.error(`Data fetch failed response in getExecuitonDetails: ${response.status}`);
|
|
@@ -103,8 +105,7 @@ async function getExecuitonScriptDetails(frothUrl, token, execution_id, script_i
|
|
|
103
105
|
|
|
104
106
|
}
|
|
105
107
|
|
|
106
|
-
async function
|
|
107
|
-
// if (id != 0) {
|
|
108
|
+
async function update_CICDRUNID_ReportUrl(frothUrl, token, id) {
|
|
108
109
|
|
|
109
110
|
|
|
110
111
|
const url = `${frothUrl}/api/test-execution-update/${id}/`;
|
|
@@ -112,26 +113,17 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
112
113
|
try {
|
|
113
114
|
console.log("URL" + url)
|
|
114
115
|
|
|
115
|
-
|
|
116
|
-
formData.append('excution_status', resultdetails.excution_status);
|
|
117
|
-
}
|
|
118
|
-
if (resultdetails.excution_time != null) {
|
|
119
|
-
formData.append('excution_time', resultdetails.excution_time);
|
|
120
|
-
}
|
|
121
|
-
formData.append('id', BUFFER.getItem("FROTH_EXECUTION_ID"))
|
|
122
|
-
if (BUFFER.getItem("REPORT_URL") != null)
|
|
123
|
-
formData.append('report_url', BUFFER.getItem("REPORT_URL"))
|
|
124
|
-
|
|
116
|
+
// formData.append('id', BUFFER.getItem("FROTH_EXECUTION_ID"))
|
|
125
117
|
formData.append('updated_through_bot', true)
|
|
126
118
|
formData.append('run_id', process.env.CICD_RUN_ID)
|
|
127
|
-
if (resultdetails.comments != null)
|
|
128
|
-
formData.append('comments', resultdetails.comments.join('<br>'))
|
|
129
|
-
|
|
130
|
-
// formData.append('comments', JSON.stringify(resultdetails.comments))
|
|
131
|
-
|
|
132
|
-
console.log("Report URL:" + BUFFER.getItem("REPORT_URL"))
|
|
133
119
|
|
|
134
120
|
|
|
121
|
+
if (BUFFER.getItem("REPORT_URL") === null)
|
|
122
|
+
console.log("Report URL is null")
|
|
123
|
+
else {
|
|
124
|
+
console.log("Report URL:" + BUFFER.getItem("REPORT_URL"))
|
|
125
|
+
formData.append('report_url', BUFFER.getItem("REPORT_URL"))
|
|
126
|
+
}
|
|
135
127
|
|
|
136
128
|
const response = await fetch(url, {
|
|
137
129
|
method: 'PUT',
|
|
@@ -144,33 +136,137 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
144
136
|
|
|
145
137
|
if (response.ok) {
|
|
146
138
|
const data = await response.json();
|
|
147
|
-
// console.log("data is :"+data)
|
|
148
|
-
|
|
149
139
|
} else if (response.status === 401) { // Unauthorized, token expired
|
|
150
|
-
// Call login function to obtain a new token
|
|
151
|
-
// const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
152
|
-
// // Retry the request with the new token
|
|
153
|
-
// return updateExecuitonDetails(frothUrl, newToken, id, resultdetails);
|
|
154
140
|
console.log("Unauthorized, token expired" + response.status)
|
|
155
|
-
|
|
156
141
|
} else {
|
|
157
142
|
const errorText = await response.text();
|
|
158
143
|
console.error(`error in updating the status into DB ${response.status}`);
|
|
159
|
-
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
160
144
|
}
|
|
161
145
|
|
|
162
|
-
|
|
163
|
-
|
|
164
146
|
} catch (error) {
|
|
165
147
|
console.error('Error fetching data:', error);
|
|
166
148
|
|
|
167
149
|
}
|
|
168
|
-
|
|
169
|
-
// console.error('Error fetching data: Invalid ID');
|
|
170
|
-
// }
|
|
150
|
+
|
|
171
151
|
|
|
172
152
|
}
|
|
173
153
|
|
|
154
|
+
async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
155
|
+
if (BUFFER.getItem("UPDATE_EXECUTION") === 'TRUE') {
|
|
156
|
+
console.log("Execution already updated.")
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
|
|
160
|
+
const url = `${frothUrl}/api/test-execution-update/${id}/`;
|
|
161
|
+
const formData = new FormData();
|
|
162
|
+
try {
|
|
163
|
+
console.log("URL" + url)
|
|
164
|
+
|
|
165
|
+
//formData.append('id', BUFFER.getItem("FROTH_EXECUTION_ID"))
|
|
166
|
+
formData.append('updated_through_bot', true)
|
|
167
|
+
// formData.append('run_id', process.env.CICD_RUN_ID)
|
|
168
|
+
|
|
169
|
+
if (resultdetails.excution_status === null) {
|
|
170
|
+
console.log("Execution status is null")
|
|
171
|
+
} else
|
|
172
|
+
formData.append('excution_status', resultdetails.excution_status);
|
|
173
|
+
|
|
174
|
+
if (resultdetails.excution_time === null || resultdetails.excution_time === "NaN:NaN:NaN") {
|
|
175
|
+
console.log("Execution time is null")
|
|
176
|
+
} else
|
|
177
|
+
formData.append('excution_time', resultdetails.excution_time);
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
if (resultdetails.comments === null)
|
|
181
|
+
console.log("Comments is null")
|
|
182
|
+
else if (resultdetails.comments.length === 0)
|
|
183
|
+
console.log("Comments is empty")
|
|
184
|
+
else
|
|
185
|
+
formData.append('comments', resultdetails.comments.join('<br>'))
|
|
186
|
+
|
|
187
|
+
// formData.append('comments', JSON.stringify(resultdetails.comments))
|
|
188
|
+
|
|
189
|
+
const response = await fetch(url, {
|
|
190
|
+
method: 'PUT',
|
|
191
|
+
headers: {
|
|
192
|
+
'Authorization': `Bearer ${token}`
|
|
193
|
+
},
|
|
194
|
+
body: formData
|
|
195
|
+
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
if (response.ok) {
|
|
199
|
+
const data = await response.json();
|
|
200
|
+
BUFFER.setItem("UPDATE_EXECUTION", 'TRUE')
|
|
201
|
+
} else if (response.status === 401) { // Unauthorized, token expired
|
|
202
|
+
console.log("Unauthorized, token expired" + response.status)
|
|
203
|
+
} else {
|
|
204
|
+
const errorText = await response.text();
|
|
205
|
+
console.error(`error in updating the status into DB ${response.status}`);
|
|
206
|
+
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
} catch (error) {
|
|
210
|
+
console.error('Error fetching data:', error);
|
|
211
|
+
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
async function updateScriptExecutionStatus(frothUrl, token, scriptid, script_platform, status) {
|
|
219
|
+
|
|
220
|
+
if (scriptid != 0) {
|
|
221
|
+
try {
|
|
222
|
+
console.log("script platform is " + script_platform)
|
|
223
|
+
const id = await getExecuitonScriptDetails(frothUrl, token, BUFFER.getItem("FROTH_EXECUTION_ID"), scriptid, script_platform)
|
|
224
|
+
console.log("ID is :" + id)
|
|
225
|
+
const url = `${frothUrl}/api/script-status-percentage/${id}/`;
|
|
226
|
+
const formData = new FormData();
|
|
227
|
+
|
|
228
|
+
console.log("URL" + url)
|
|
229
|
+
// formData.append('execution_id', BUFFER.getItem("EXECUTION_ID"))
|
|
230
|
+
formData.append('script_status', status)
|
|
231
|
+
formData.append('updated_through_bot', true)
|
|
232
|
+
|
|
233
|
+
const response = await fetch(url, {
|
|
234
|
+
method: 'PUT',
|
|
235
|
+
headers: {
|
|
236
|
+
'Authorization': `Bearer ${token}`
|
|
237
|
+
},
|
|
238
|
+
body: formData
|
|
239
|
+
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
if (response.ok) {
|
|
243
|
+
const data = await response.json();
|
|
244
|
+
// console.log("data is :"+data)
|
|
245
|
+
|
|
246
|
+
} else if (response.status === 401) { // Unauthorized, token expired
|
|
247
|
+
// Call login function to obtain a new token
|
|
248
|
+
// const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
249
|
+
// // Retry the request with the new token
|
|
250
|
+
// return updateScriptExecutionStatus(frothUrl, newToken, scriptid, script_platform, status);
|
|
251
|
+
console.log("Unauthorized, token expired" + response.status)
|
|
252
|
+
|
|
253
|
+
} else {
|
|
254
|
+
const errorText = await response.text();
|
|
255
|
+
console.error(`error in updating the status into DB ${response.status}`);
|
|
256
|
+
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
} catch (error) {
|
|
262
|
+
console.error('Error updating data for script status:', error);
|
|
263
|
+
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
console.error('Else: Error updating data for script status: Invalid ID');
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
}
|
|
174
270
|
async function updateScriptExecutionStatus(frothUrl, token, scriptid, script_platform, status) {
|
|
175
271
|
|
|
176
272
|
if (scriptid != 0) {
|
|
@@ -253,5 +349,5 @@ async function updateScriptExecutionStatus(frothUrl, token, scriptid, script_pla
|
|
|
253
349
|
// }
|
|
254
350
|
|
|
255
351
|
// main();
|
|
256
|
-
module.exports = { getExecuitonDetails, updateExecuitonDetails, updateScriptExecutionStatus };
|
|
352
|
+
module.exports = { getExecuitonDetails, updateExecuitonDetails, updateScriptExecutionStatus, update_CICDRUNID_ReportUrl };
|
|
257
353
|
|
|
@@ -54,11 +54,11 @@ function main() {
|
|
|
54
54
|
iat: currentTimestamp, // Issued at
|
|
55
55
|
exp: currentTimestamp + 200, // Expiry time: 30 seconds from issuance
|
|
56
56
|
user_agent: {
|
|
57
|
-
id: "
|
|
57
|
+
id: "janga.reddy@ytl.com"
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
console.log('JWT signed token:', generateJWTToken(payload));
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
main()
|
|
64
64
|
module.exports = { generateJWTToken}
|
|
@@ -126,7 +126,8 @@ const commonconfig = {
|
|
|
126
126
|
|
|
127
127
|
|
|
128
128
|
// const resultdetails = {};
|
|
129
|
-
await exeDetails.
|
|
129
|
+
await exeDetails.update_CICDRUNID_ReportUrl(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"))
|
|
130
|
+
BUFFER.setItem("UPDATE_EXECUTION", 'FALSE')
|
|
130
131
|
|
|
131
132
|
} catch (e) {
|
|
132
133
|
console.log("Error in beforeSuite:", e);
|
|
@@ -142,9 +143,7 @@ const commonconfig = {
|
|
|
142
143
|
|
|
143
144
|
console.log('==== BEFORE TEST HOOK ====');
|
|
144
145
|
console.log(`====> Test Started '${test.title}'`);
|
|
145
|
-
|
|
146
|
-
// console.log("File Name:", test.file);
|
|
147
|
-
|
|
146
|
+
|
|
148
147
|
},
|
|
149
148
|
|
|
150
149
|
|
|
@@ -171,21 +170,7 @@ const commonconfig = {
|
|
|
171
170
|
let scriptresult = "NOT RUN";
|
|
172
171
|
// Default assumption: test passed (unless soft assertion failed)
|
|
173
172
|
let finalPassed = passed;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
// Check soft assertion failures
|
|
177
|
-
// const softErrors = browser.testErrors || [];
|
|
178
|
-
// if (softErrors.length > 0) {
|
|
179
|
-
// finalPassed = false; // Override status
|
|
180
|
-
// const softErrorMessage = `Soft assertion errors: ${softErrors.join('<br>')}`;
|
|
181
|
-
// console.log('====> Soft Assertion Failures Detected:\n' + softErrorMessage);
|
|
182
|
-
|
|
183
|
-
// // Log in resultdetails
|
|
184
|
-
// resultdetails.comments.push(`${test.title} - failed: ${softErrorMessage}`);
|
|
185
|
-
// global.__SOFT_FAIL__ = true;
|
|
186
|
-
// // Overwrite the error param so your logic can pick it up
|
|
187
|
-
// combinedError = new Error(softErrorMessage);
|
|
188
|
-
// }
|
|
173
|
+
|
|
189
174
|
if (passed) {
|
|
190
175
|
scriptresult = "PASSED"
|
|
191
176
|
resultdetails.comments.push(`${test.title} - passed`);
|
|
@@ -211,10 +196,7 @@ const commonconfig = {
|
|
|
211
196
|
jwtScript.scriptId,
|
|
212
197
|
jwtScript.platform.toLowerCase(),
|
|
213
198
|
scriptresult)
|
|
214
|
-
|
|
215
|
-
// if (softErrors.length > 0) {
|
|
216
|
-
// throw combinedError; // 👈 this is what forces the test to fail in WDIO
|
|
217
|
-
// }
|
|
199
|
+
|
|
218
200
|
|
|
219
201
|
},
|
|
220
202
|
/**
|
|
@@ -303,10 +285,7 @@ const commonconfig = {
|
|
|
303
285
|
console.log('Execution Time:', results.duration);
|
|
304
286
|
console.log('Exit Code:', exitCode);
|
|
305
287
|
console.log('==== ALL TESTS ARE COMPLETED ====');
|
|
306
|
-
|
|
307
|
-
// console.log('❌ One or more tests failed due to soft assertion.');
|
|
308
|
-
// process.exit(1); // ✅ Force failure
|
|
309
|
-
// }
|
|
288
|
+
|
|
310
289
|
|
|
311
290
|
return exitCode;
|
|
312
291
|
}
|
|
@@ -333,6 +312,7 @@ async function convertTimetoHHMMSS(time) {
|
|
|
333
312
|
const formattedTime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
|
|
334
313
|
|
|
335
314
|
console.log("Time:" + hours + ':' + minutes + ':' + seconds);
|
|
315
|
+
|
|
336
316
|
return formattedTime;
|
|
337
317
|
}
|
|
338
318
|
|
package/package.json
CHANGED
package/config/commonconfig.js
DELETED
|
File without changes
|