froth-webdriverio-framework 1.0.84 → 1.0.86
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.
- package/api/getexecutionDetails.js +53 -7
- package/config/commonconfig.js +1 -2
- package/package.json +1 -1
|
@@ -53,8 +53,53 @@ async function getExecuitonDetails(frothUrl, token, id) {
|
|
|
53
53
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
async function getExecuitonScriptDetails(frothUrl, token, execution_id, script_id) {
|
|
57
|
+
let id;
|
|
58
|
+
const url = `https://${frothUrl}/api/execution-script-mapping/?execution_id=${execution_id}&automation_script_id=${script_id}`;
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
console.log("URL: " + url)
|
|
62
|
+
|
|
63
|
+
const response = await fetch(url, {
|
|
64
|
+
method: 'GET',
|
|
65
|
+
headers: {
|
|
66
|
+
'Authorization': `Bearer ${token}`,
|
|
67
|
+
'Content-Type': 'application/json'
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
if (response.ok) {
|
|
72
|
+
const data = await response.json();
|
|
73
|
+
console.log(data)
|
|
74
|
+
id = data[0].id;
|
|
75
|
+
console.log("ID is :" + id)
|
|
76
|
+
// console.log("json data :" + JSON.stringify(jsondata));
|
|
77
|
+
|
|
78
|
+
return id;
|
|
79
|
+
} else if (response.status === 401) { // Unauthorized, token expired
|
|
80
|
+
// Call login function to obtain a new token
|
|
81
|
+
const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
82
|
+
// Retry the request with the new token
|
|
83
|
+
return getExecuitonScriptDetails(frothUrl, newToken, execution_id, script_id);
|
|
84
|
+
} else {
|
|
85
|
+
const errorText = await response.text();
|
|
86
|
+
console.error(`Data fetch failed response: ${response.status}`);
|
|
87
|
+
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error('getExecuitonScriptDetails Error fetching data:', error);
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
56
99
|
async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
57
100
|
if (id != 0) {
|
|
101
|
+
|
|
102
|
+
|
|
58
103
|
const url = `https://${frothUrl}/api/test-execution-update/${id}/`;
|
|
59
104
|
const formData = new FormData();
|
|
60
105
|
try {
|
|
@@ -105,14 +150,15 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
105
150
|
|
|
106
151
|
}
|
|
107
152
|
|
|
108
|
-
async function updateScriptExecutionStatus(frothUrl, token,
|
|
109
|
-
if (id != 0) {
|
|
110
|
-
const url = `https://${frothUrl}/api/script-status-percentage/${id}/`;
|
|
111
|
-
const formData = new FormData();
|
|
112
|
-
try {
|
|
113
|
-
console.log("URL" + url)
|
|
153
|
+
async function updateScriptExecutionStatus(frothUrl, token, scriptid, status) {
|
|
114
154
|
|
|
155
|
+
if (scriptid != 0) {
|
|
156
|
+
try {
|
|
157
|
+
const id = await getExecuitonScriptDetails(frothUrl, token, BUFFER.getItem("EXECUTION_ID"), scriptid)
|
|
158
|
+
const url = `https://${frothUrl}/api/script-status-percentage/${id}/`;
|
|
159
|
+
const formData = new FormData();
|
|
115
160
|
|
|
161
|
+
console.log("URL" + url)
|
|
116
162
|
// formData.append('execution_id', BUFFER.getItem("EXECUTION_ID"))
|
|
117
163
|
formData.append('scrpit_status', status)
|
|
118
164
|
|
|
@@ -174,7 +220,7 @@ async function updateScriptExecutionStatus(frothUrl, token, id, status) {
|
|
|
174
220
|
// const duration = "31355ms"
|
|
175
221
|
// resultdetails.excution_status = resultdata === 'Pass' ? 'PASSED' : 'FAILED'
|
|
176
222
|
// //resultdetails.excution_time = convertMillisecondsToTime(duration)
|
|
177
|
-
// await
|
|
223
|
+
// await getExecuitonScriptDetails(frothUrl, token, 449, 130);
|
|
178
224
|
// } catch (error) {
|
|
179
225
|
// console.error('Error in main function:', error);
|
|
180
226
|
// }
|
package/config/commonconfig.js
CHANGED
|
@@ -71,7 +71,6 @@ const commonconfig = {
|
|
|
71
71
|
*/
|
|
72
72
|
afterTest: async function (test, context, { error, result, duration, passed, retries }) {
|
|
73
73
|
console.log(`Test '${test.title}' finished.`);
|
|
74
|
-
console.log('Test file name:', test.file);
|
|
75
74
|
const fileName = path.basename(test.file);
|
|
76
75
|
console.log('Test File Name:', fileName);
|
|
77
76
|
// BUFFER.setItem("TOTAL_DURATION", Number(BUFFER.getItem("TOTAL_DURATION")) + duration)
|
|
@@ -91,7 +90,7 @@ const commonconfig = {
|
|
|
91
90
|
scriptresult = "FAILED"
|
|
92
91
|
}
|
|
93
92
|
console.log('---------------------------------------');
|
|
94
|
-
await exeDetails.updateScriptExecutionStatus(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("LOGIN_TOKEN"),
|
|
93
|
+
await exeDetails.updateScriptExecutionStatus(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("LOGIN_TOKEN"), scriptid, scriptresult)
|
|
95
94
|
|
|
96
95
|
},
|
|
97
96
|
/**
|