froth-webdriverio-framework 5.0.14 → 5.0.16
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.
|
@@ -170,7 +170,6 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
170
170
|
} else
|
|
171
171
|
formData.append('excution_time', resultdetails.excution_time);
|
|
172
172
|
|
|
173
|
-
|
|
174
173
|
if (resultdetails.comments === null)
|
|
175
174
|
console.log("Comments is null")
|
|
176
175
|
else if (resultdetails.comments.length === 0)
|
|
@@ -178,6 +177,7 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
178
177
|
else
|
|
179
178
|
formData.append('comments', resultdetails.comments.join('<br>'))
|
|
180
179
|
|
|
180
|
+
|
|
181
181
|
// formData.append('comments', JSON.stringify(resultdetails.comments))
|
|
182
182
|
|
|
183
183
|
const response = await fetch(url, {
|
|
@@ -255,20 +255,20 @@ async function updateScriptExecutionStatus(frothUrl, token, scriptid, script_pla
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
}
|
|
258
|
-
async function
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
console.log("
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const url = `${frothUrl}/api/
|
|
258
|
+
async function updateReportUrl(frothUrl, token, id) {
|
|
259
|
+
try {
|
|
260
|
+
console.log("in update execution details UPDATE_EXECUTION: " + BUFFER.getItem("UPDATE_EXECUTION"))
|
|
261
|
+
if (BUFFER.getItem("FROTH_UPDATE_EXECUTION") === 'TRUE') {
|
|
262
|
+
console.log("Execution already updated.")
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
const url = `${frothUrl}/api/test-execution-update/${id}/`;
|
|
266
266
|
const formData = new FormData();
|
|
267
267
|
|
|
268
268
|
console.log("URL" + url)
|
|
269
|
-
// formData.append('execution_id', BUFFER.getItem("EXECUTION_ID"))
|
|
270
|
-
formData.append('script_status', status)
|
|
271
269
|
formData.append('updated_through_bot', true)
|
|
270
|
+
formData.append('report_url', `reports/${process.env.EXECUTION_ID}/test-report.html`)
|
|
271
|
+
|
|
272
272
|
|
|
273
273
|
const response = await fetch(url, {
|
|
274
274
|
method: 'PUT',
|
|
@@ -281,15 +281,9 @@ async function updateScriptExecutionStatus(frothUrl, token, scriptid, script_pla
|
|
|
281
281
|
|
|
282
282
|
if (response.ok) {
|
|
283
283
|
const data = await response.json();
|
|
284
|
-
|
|
285
|
-
|
|
284
|
+
BUFFER.setItem("FROTH_UPDATE_EXECUTION", 'TRUE')
|
|
286
285
|
} else if (response.status === 401) { // Unauthorized, token expired
|
|
287
|
-
// Call login function to obtain a new token
|
|
288
|
-
// const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
289
|
-
// // Retry the request with the new token
|
|
290
|
-
// return updateScriptExecutionStatus(frothUrl, newToken, scriptid, script_platform, status);
|
|
291
286
|
console.log("Unauthorized, token expired" + response.status)
|
|
292
|
-
|
|
293
287
|
} else {
|
|
294
288
|
const errorText = await response.text();
|
|
295
289
|
console.error(`error in updating the status into DB ${response.status}`);
|
|
@@ -297,13 +291,10 @@ async function updateScriptExecutionStatus(frothUrl, token, scriptid, script_pla
|
|
|
297
291
|
}
|
|
298
292
|
|
|
299
293
|
|
|
300
|
-
|
|
301
|
-
} catch (error) {
|
|
302
|
-
console.error('Error updating data for script status:', error);
|
|
303
|
-
|
|
304
294
|
}
|
|
305
|
-
}
|
|
306
|
-
console.error('
|
|
295
|
+
} catch (error) {
|
|
296
|
+
console.error('Error in update report url :', error);
|
|
297
|
+
|
|
307
298
|
}
|
|
308
299
|
|
|
309
300
|
}
|
|
@@ -337,5 +328,5 @@ async function updateScriptExecutionStatus(frothUrl, token, scriptid, script_pla
|
|
|
337
328
|
// }
|
|
338
329
|
|
|
339
330
|
// main();
|
|
340
|
-
module.exports = { getExecuitonDetails, updateExecuitonDetails, updateScriptExecutionStatus, update_CICDRUNID_ReportUrl };
|
|
331
|
+
module.exports = { getExecuitonDetails, updateExecuitonDetails, updateScriptExecutionStatus, update_CICDRUNID_ReportUrl, updateReportUrl};
|
|
341
332
|
|
|
@@ -9,7 +9,7 @@ const exeDetails = require("../froth_api_calls/getexecutionDetails")
|
|
|
9
9
|
const { fail } = require("assert");
|
|
10
10
|
const { error } = require('console');
|
|
11
11
|
const HTMLReportGenerator = require('wdio-json-html-reporter').HTMLReportGenerator;
|
|
12
|
-
|
|
12
|
+
global.Util=require('../froth_common_actions/Utils');
|
|
13
13
|
|
|
14
14
|
//const isBrowserStackEnabled = process.env.BROWSERSTACK;
|
|
15
15
|
let starttime;
|
|
@@ -46,6 +46,7 @@ const commonconfig = {
|
|
|
46
46
|
beforeSession: async function (config, capabilities, specs) {
|
|
47
47
|
try {
|
|
48
48
|
|
|
49
|
+
|
|
49
50
|
let syntaxFailed = false;
|
|
50
51
|
|
|
51
52
|
console.log('==== BEFORE SESSION HOOK ====');
|
|
@@ -391,6 +392,10 @@ const commonconfig = {
|
|
|
391
392
|
|
|
392
393
|
const reportGenerator = new HTMLReportGenerator(outputFilePath, historyFile);
|
|
393
394
|
await reportGenerator.convertJSONFolderToHTML(jsonFolder);
|
|
395
|
+
|
|
396
|
+
await exeDetails.updateReportUrl(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"))
|
|
397
|
+
|
|
398
|
+
|
|
394
399
|
// return exitCode;
|
|
395
400
|
}
|
|
396
401
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wdio-require-patch.js
|
|
3
|
+
* This script patches Node's require() so that any test file requiring
|
|
4
|
+
* '../B/froth_common_actions/Utils' automatically gets the correct global Util object.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const Module = require('module');
|
|
10
|
+
console.log('🔧 Applying wdio-require-patch.js...');
|
|
11
|
+
// --- 1️⃣ Locate the correct Utils.js dynamically ---
|
|
12
|
+
const possiblePaths = [
|
|
13
|
+
// Local project structure
|
|
14
|
+
path.resolve(__dirname, '../B/froth_common_actions/Utils.js'),
|
|
15
|
+
path.resolve(__dirname, '../node_modules/froth-webdriverio-framework/froth_common_actions/Utils.js'),
|
|
16
|
+
|
|
17
|
+
// Cloud structure (when framework is inside node_modules)
|
|
18
|
+
path.resolve(__dirname, './node_modules/froth-webdriverio-framework/froth_common_actions/Utils.js'),
|
|
19
|
+
|
|
20
|
+
// Fallback (when running inside another workspace)
|
|
21
|
+
path.resolve(process.cwd(), 'node_modules/froth-webdriverio-framework/froth_common_actions/Utils.js'),
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const utilsPath = possiblePaths.find(p => fs.existsSync(p));
|
|
25
|
+
|
|
26
|
+
if (!utilsPath) {
|
|
27
|
+
console.warn('⚠️ Could not find Utils.js in expected paths. Global.Util not set.');
|
|
28
|
+
} else {
|
|
29
|
+
global.Util = require(utilsPath);
|
|
30
|
+
console.log(`✅ Global Util loaded from: ${utilsPath}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// --- 2️⃣ Patch Node's require() so that any require of Utils returns global.Util ---
|
|
34
|
+
const originalRequire = Module.prototype.require;
|
|
35
|
+
|
|
36
|
+
Module.prototype.require = function (request) {
|
|
37
|
+
// Catch any variation of the Utils import
|
|
38
|
+
if (
|
|
39
|
+
request.includes('froth_common_actions/Utils') ||
|
|
40
|
+
request.endsWith('/Utils') ||
|
|
41
|
+
request.endsWith('/Utils.js')
|
|
42
|
+
) {
|
|
43
|
+
console.log(`⚡ Redirecting require('${request}') → global.Util`);
|
|
44
|
+
return global.Util;
|
|
45
|
+
}
|
|
46
|
+
return originalRequire.apply(this, arguments);
|
|
47
|
+
};
|