froth-webdriverio-framework 4.0.46 → 4.0.47

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.
@@ -16,7 +16,7 @@ console.log('===== common config===== ');
16
16
  const resultdetails = {
17
17
  comments: [],
18
18
  excution_status: null, // Pass/Fail
19
- excution_time: 0, // Execution time in milliseconds
19
+ excution_time: null, // Execution time in milliseconds
20
20
  };
21
21
  // Description: This file contains the common configuration for the webdriverio framework.
22
22
  const commonconfig = {
@@ -267,15 +267,23 @@ const commonconfig = {
267
267
  console.log("====> Total Duration in after session based on summing up the test execution times:" + duration_tests);
268
268
 
269
269
  resultdetails.excution_status = BUFFER.getItem("RESULT_DATA") == 0 ? 'PASSED' : 'FAILED'
270
+ const frothDuration = BUFFER.getItem("FROTH_TOTAL_DURATION");
271
+
272
+ if(await isInvalidDuration(frothDuration)){
273
+ console.log("inside froth duration");
274
+ if (await isInvalidDuration(duration_tests)) {
275
+ console.log("inside froth duration_tests");
270
276
 
271
- if(await isValidDuration(BUFFER.getItem("FROTH_TOTAL_DURATION")))
272
- if(await isValidDuration(duration_tests))
273
277
  resultdetails.excution_time = await convertTimetoHHMMSS(totalDuration);
274
- else
275
- resultdetails.excution_time = await secondsToTime(duration_tests)
276
- else
277
- resultdetails.excution_time = await secondsToTime(BUFFER.getItem("FROTH_TOTAL_DURATION"));
278
-
278
+ } else {
279
+ console.log("inside froth totalDuration");
280
+ resultdetails.excution_time = await millisecondsToTime(duration_tests);
281
+ }
282
+ } else {
283
+ console.log("inside froth duration else");
284
+ resultdetails.excution_time = await secondsToTime(frothDuration);
285
+ }
286
+
279
287
  console.log("====> Total Duration calculation:" +resultdetails.excution_time);
280
288
 
281
289
  await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"), resultdetails)
@@ -300,7 +308,7 @@ const commonconfig = {
300
308
  }
301
309
 
302
310
  };
303
- async function isValidDuration(val) {
311
+ async function isInvalidDuration(val) {
304
312
  console.log("val in isValidDuration:" + val);
305
313
  // Check if the value is null, 0, or undefined
306
314
  let isValid = val === null || val === 0 || val === undefined;
@@ -320,6 +328,29 @@ async function secondsToTime(secs) {
320
328
  console.log("Time:" + hours + ':' + minutes + ':' + seconds);
321
329
  return hours + ':' + minutes + ':' + seconds;
322
330
  }
331
+ async function millisecondsToTime(ms) {
332
+ console.log("ms in millisecondsToTime: " + ms);
333
+
334
+ // Ensure input is a number
335
+ ms = Number(ms);
336
+ if (isNaN(ms)) {
337
+ return '00:00:00';
338
+ }
339
+
340
+ let totalSeconds = Math.floor(ms / 1000);
341
+ let hours = Math.floor(totalSeconds / 3600);
342
+ let minutes = Math.floor((totalSeconds % 3600) / 60);
343
+ let seconds = totalSeconds % 60;
344
+
345
+ // Pad with leading zeros
346
+ hours = hours < 10 ? '0' + hours : hours;
347
+ minutes = minutes < 10 ? '0' + minutes : minutes;
348
+ seconds = seconds < 10 ? '0' + seconds : seconds;
349
+
350
+ const timeStr = `${hours}:${minutes}:${seconds}`;
351
+ console.log("Formatted time:", timeStr);
352
+ return timeStr;
353
+ }
323
354
 
324
355
  async function convertTimetoHHMMSS(time) {
325
356
  const seconds = Math.floor((time / 1000) % 60);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "4.0.46",
3
+ "version": "4.0.47",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",