froth-webdriverio-framework 4.0.38 → 4.0.40
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.
|
@@ -113,7 +113,7 @@ async function update_CICDRUNID_ReportUrl(frothUrl, token, id) {
|
|
|
113
113
|
try {
|
|
114
114
|
console.log("URL" + url)
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
// formData.append('id', BUFFER.getItem("FROTH_EXECUTION_ID"))
|
|
117
117
|
formData.append('updated_through_bot', true)
|
|
118
118
|
formData.append('run_id', process.env.CICD_RUN_ID)
|
|
119
119
|
|
|
@@ -152,19 +152,18 @@ async function update_CICDRUNID_ReportUrl(frothUrl, token, id) {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
155
|
-
|
|
156
|
-
console.log("
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
try {
|
|
156
|
+
console.log("in update execution details UPDATE_EXECUTION: " + BUFFER.getItem("UPDATE_EXECUTION"))
|
|
157
|
+
if (BUFFER.getItem("FROTH_UPDATE_EXECUTION") === 'TRUE') {
|
|
158
|
+
console.log("Execution already updated.")
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
const url = `${frothUrl}/api/test-execution-update/${id}/`;
|
|
162
|
+
const formData = new FormData();
|
|
159
163
|
|
|
160
|
-
const url = `${frothUrl}/api/test-execution-update/${id}/`;
|
|
161
|
-
const formData = new FormData();
|
|
162
|
-
try {
|
|
163
164
|
console.log("URL" + url)
|
|
164
|
-
|
|
165
|
-
//formData.append('id', BUFFER.getItem("FROTH_EXECUTION_ID"))
|
|
165
|
+
console.log("Execution details :" + resultdetails.excution_status + " == " + resultdetails.excution_time + " == " + resultdetails.comments)
|
|
166
166
|
formData.append('updated_through_bot', true)
|
|
167
|
-
// formData.append('run_id', process.env.CICD_RUN_ID)
|
|
168
167
|
|
|
169
168
|
if (resultdetails.excution_status === null) {
|
|
170
169
|
console.log("Execution status is null")
|
|
@@ -197,7 +196,7 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
197
196
|
|
|
198
197
|
if (response.ok) {
|
|
199
198
|
const data = await response.json();
|
|
200
|
-
BUFFER.setItem("
|
|
199
|
+
BUFFER.setItem("FROTH_UPDATE_EXECUTION", 'TRUE')
|
|
201
200
|
} else if (response.status === 401) { // Unauthorized, token expired
|
|
202
201
|
console.log("Unauthorized, token expired" + response.status)
|
|
203
202
|
} else {
|
|
@@ -206,12 +205,13 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
206
205
|
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
207
206
|
}
|
|
208
207
|
|
|
209
|
-
} catch (error) {
|
|
210
|
-
console.error('Error fetching data:', error);
|
|
211
208
|
|
|
212
209
|
}
|
|
213
|
-
|
|
210
|
+
} catch (error) {
|
|
211
|
+
console.error('Error in updateExecuitonDetails :', error);
|
|
212
|
+
|
|
214
213
|
}
|
|
214
|
+
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
|
|
@@ -244,20 +244,13 @@ async function updateScriptExecutionStatus(frothUrl, token, scriptid, script_pla
|
|
|
244
244
|
// console.log("data is :"+data)
|
|
245
245
|
|
|
246
246
|
} else if (response.status === 401) { // Unauthorized, token expired
|
|
247
|
-
|
|
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);
|
|
247
|
+
|
|
251
248
|
console.log("Unauthorized, token expired" + response.status)
|
|
252
249
|
|
|
253
250
|
} else {
|
|
254
251
|
const errorText = await response.text();
|
|
255
252
|
console.error(`error in updating the status into DB ${response.status}`);
|
|
256
|
-
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
257
253
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
254
|
} catch (error) {
|
|
262
255
|
console.error('Error updating data for script status:', error);
|
|
263
256
|
|
|
@@ -219,7 +219,6 @@ const commonconfig = {
|
|
|
219
219
|
console.log('====> All tests are completed.' + result);
|
|
220
220
|
BUFFER.setItem("RESULT_DATA", result);
|
|
221
221
|
console.log("====> Result data :" + BUFFER.getItem("RESULT_DATA"))
|
|
222
|
-
/// const resultdetails = {}
|
|
223
222
|
resultdetails.excution_status = BUFFER.getItem("RESULT_DATA") == 0 ? 'PASSED' : 'FAILED'
|
|
224
223
|
console.log("====> Total Duration taken for the suite:" + BUFFER.getItem("FROTH_TOTAL_DURATION"));
|
|
225
224
|
console.log("====> Execution Status from results" + resultdetails.excution_status);
|
|
@@ -236,9 +235,7 @@ const commonconfig = {
|
|
|
236
235
|
});
|
|
237
236
|
|
|
238
237
|
}
|
|
239
|
-
|
|
240
|
-
await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"), resultdetails)
|
|
241
|
-
|
|
238
|
+
|
|
242
239
|
},
|
|
243
240
|
|
|
244
241
|
afterSession: async function (config, capabilities, specs) {
|
|
@@ -247,12 +244,7 @@ const commonconfig = {
|
|
|
247
244
|
// console.log("Capabilities:", capabilities);
|
|
248
245
|
console.log("Specs:", specs);
|
|
249
246
|
//console.log("Config:", config);
|
|
250
|
-
|
|
251
|
-
let totalDuration = endtime - starttime;
|
|
252
|
-
console.log("====> Total Duration in after session based on start time and end time:" + totalDuration);
|
|
253
|
-
if (process.env.PLATFORM === 'browserstack')
|
|
254
|
-
await getBSSessionDetails(process.env.BS_SESSION_TYPE, process.env.BROWSERSTACK_USERNAME, process.env.BROWSERSTACK_ACCESS_KEY);
|
|
255
|
-
|
|
247
|
+
|
|
256
248
|
process.on('uncaughtException', (err) => {
|
|
257
249
|
console.error("Uncaught Exception:", err);
|
|
258
250
|
resultdetails.comments.push(`Execution failed with exit code: ${err}`);
|
|
@@ -264,13 +256,6 @@ const commonconfig = {
|
|
|
264
256
|
resultdetails.comments.push(`Execution failed with exit code: ${reason}`);
|
|
265
257
|
});
|
|
266
258
|
|
|
267
|
-
resultdetails.excution_status = BUFFER.getItem("RESULT_DATA") == 0 ? 'PASSED' : 'FAILED'
|
|
268
|
-
console.log("====> Total Duration calculation:" + BUFFER.getItem("FROTH_TOTAL_DURATION") === 0 ? await convertTimetoHHMMSS(totalDuration) : await secondsToTime(BUFFER.getItem("FROTH_TOTAL_DURATION")));
|
|
269
|
-
resultdetails.excution_time = BUFFER.getItem("FROTH_TOTAL_DURATION") === 0 ? await convertTimetoHHMMSS(totalDuration) : await secondsToTime(BUFFER.getItem("FROTH_TOTAL_DURATION"))
|
|
270
|
-
await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"), resultdetails)
|
|
271
|
-
BUFFER.clear();
|
|
272
|
-
|
|
273
|
-
|
|
274
259
|
// Perform any cleanup or post-test actions here
|
|
275
260
|
},
|
|
276
261
|
|
|
@@ -284,9 +269,20 @@ const commonconfig = {
|
|
|
284
269
|
console.log('Skipped:', results.skipped);
|
|
285
270
|
console.log('Execution Time:', results.duration);
|
|
286
271
|
console.log('Exit Code:', exitCode);
|
|
287
|
-
console.log('==== ALL TESTS ARE COMPLETED ====');
|
|
288
|
-
|
|
289
272
|
|
|
273
|
+
endtime = new Date().getTime();
|
|
274
|
+
let totalDuration = endtime - starttime;
|
|
275
|
+
console.log("====> Total Duration in after session based on start time and end time:" + totalDuration);
|
|
276
|
+
|
|
277
|
+
resultdetails.excution_status = BUFFER.getItem("RESULT_DATA") == 0 ? 'PASSED' : 'FAILED'
|
|
278
|
+
console.log("====> Total Duration calculation:" + BUFFER.getItem("FROTH_TOTAL_DURATION") === null || BUFFER.getItem("FROTH_TOTAL_DURATION") === 0 || BUFFER.getItem("FROTH_TOTAL_DURATION") === undefined
|
|
279
|
+
? await convertTimetoHHMMSS(totalDuration) : await secondsToTime(BUFFER.getItem("FROTH_TOTAL_DURATION")));
|
|
280
|
+
resultdetails.excution_time = BUFFER.getItem("FROTH_TOTAL_DURATION") === null || BUFFER.getItem("FROTH_TOTAL_DURATION") === 0 || BUFFER.getItem("FROTH_TOTAL_DURATION") === undefined ? await convertTimetoHHMMSS(totalDuration) : await secondsToTime(BUFFER.getItem("FROTH_TOTAL_DURATION"))
|
|
281
|
+
|
|
282
|
+
await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"), resultdetails)
|
|
283
|
+
BUFFER.clear();
|
|
284
|
+
|
|
285
|
+
console.log('==== ALL TESTS ARE COMPLETED ====');
|
|
290
286
|
return exitCode;
|
|
291
287
|
}
|
|
292
288
|
|
package/package.json
CHANGED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
const RandExp = require('randexp');
|
|
2
|
-
|
|
3
|
-
async function RNDNUMBER(min, max) {
|
|
4
|
-
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
async function RNDFLOAT() {
|
|
8
|
-
return Math.random();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async function RNDINT() {
|
|
12
|
-
return Math.floor(Math.random() * 100000); // You can choose any large multiplier for bigger ranges
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async function RNDNUMBER(length) {
|
|
16
|
-
if (length <= 0) return null; // Handle invalid length
|
|
17
|
-
|
|
18
|
-
const min = Math.pow(10, length - 1); // Minimum value for the given length
|
|
19
|
-
const max = Math.pow(10, length) - 1; // Maximum value for the given length
|
|
20
|
-
|
|
21
|
-
return Math.floor(Math.random() * (max - min + 1)) + min; // Generate the random number
|
|
22
|
-
}
|
|
23
|
-
async function RANDOMTEXT(length) {
|
|
24
|
-
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
25
|
-
let result = '';
|
|
26
|
-
for (let i = 0; i < length; i++) {
|
|
27
|
-
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async function RNDALPHANUM(length) {
|
|
33
|
-
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
34
|
-
let result = '';
|
|
35
|
-
for (let i = 0; i < length; i++) {
|
|
36
|
-
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
37
|
-
}
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async function RNDDECIMAL(min, max, decimalPlaces) {
|
|
42
|
-
let randomNum = Math.random() * (max - min) + min; // Generates a number between min and max
|
|
43
|
-
return parseFloat(randomNum.toFixed(decimalPlaces));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async function RNDDECIMAL(decimalPlaces) {
|
|
47
|
-
let randomNum = Math.random(); // Generates a number between 0 and 1
|
|
48
|
-
return parseFloat(randomNum.toFixed(decimalPlaces));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async function RNDREGEX(regex) {
|
|
52
|
-
return new RandExp(regex).gen();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
module.exports = {
|
|
56
|
-
RNDNUMBER,
|
|
57
|
-
RNDFLOAT,
|
|
58
|
-
RNDINT,
|
|
59
|
-
RANDOMTEXT,
|
|
60
|
-
RNDALPHANUM,
|
|
61
|
-
RNDDECIMAL,
|
|
62
|
-
RNDREGEX
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// console.log(RNDNUMBER(1, 100));
|
|
66
|
-
// console.log(RNDFLOAT());
|
|
67
|
-
// console.log(RNDINT());
|
|
68
|
-
// console.log(RANDOMTEXT(10));
|
|
69
|
-
// console.log(RNDALPHANUM(10));
|
|
70
|
-
// console.log(RNDDECIMAL(100, 10000, 4));
|
|
71
|
-
// console.log(RNDDECIMAL(2));
|
|
72
|
-
// console.log(RNDREGEX(/[a-z]{4}\d{4}/));
|
package/rnd/testwebhook.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const express = require('express');
|
|
2
|
-
const app = express();
|
|
3
|
-
|
|
4
|
-
// Middleware to parse JSON payloads
|
|
5
|
-
app.use(express.json());
|
|
6
|
-
|
|
7
|
-
// Define the webhook path (match the path used in smee or GitHub webhook)
|
|
8
|
-
app.post('/webhook', (request, response) => {
|
|
9
|
-
// Respond early so GitHub doesn't time out
|
|
10
|
-
response.status(202).send('Accepted');
|
|
11
|
-
|
|
12
|
-
// Get event type from header
|
|
13
|
-
const githubEvent = request.headers['x-github-event'];
|
|
14
|
-
console.log(`Received event: ${githubEvent}`);
|
|
15
|
-
|
|
16
|
-
const data = request.body;
|
|
17
|
-
|
|
18
|
-
// Handle specific GitHub events
|
|
19
|
-
if (githubEvent === 'issues') {
|
|
20
|
-
const action = data.action;
|
|
21
|
-
console.log(`Received action: ${action}`);
|
|
22
|
-
|
|
23
|
-
if (action === 'opened') {
|
|
24
|
-
console.log(`An issue was opened with this title: ${data.issue.title}`);
|
|
25
|
-
} else if (action === 'closed') {
|
|
26
|
-
console.log(`An issue was closed by ${data.issue.user.login}`);
|
|
27
|
-
} else {
|
|
28
|
-
console.log(`Unhandled action for the issue event: ${action}`);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
} else if (githubEvent === 'ping') {
|
|
32
|
-
console.log('GitHub sent the ping event');
|
|
33
|
-
|
|
34
|
-
} else {
|
|
35
|
-
// For all other events
|
|
36
|
-
console.log(`Unhandled event: ${githubEvent}`);
|
|
37
|
-
console.log(`Payload: ${JSON.stringify(data, null, 2)}`);
|
|
38
|
-
|
|
39
|
-
if (data.action) {
|
|
40
|
-
console.log(`Received action: ${data.action}`);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (data.workflow_run) {
|
|
44
|
-
console.log(`Workflow run ID: ${data.workflow_run.id}`);
|
|
45
|
-
console.log(`Workflow name: ${data.workflow_run.name}`);
|
|
46
|
-
console.log(`Status: ${data.workflow_run.status}`);
|
|
47
|
-
console.log(`Conclusion: ${data.workflow_run.conclusion}`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// Start server on port 3000
|
|
53
|
-
const port = 3000;
|
|
54
|
-
app.listen(port, () => {
|
|
55
|
-
console.log(`Server is running on port ${port}`);
|
|
56
|
-
});
|