froth-webdriverio-framework 1.0.80 → 1.0.82
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 -5
- package/api/getsuiteDetails.js +8 -3
- package/api/readTestdata.js +0 -1
- package/config/commonconfig.js +16 -5
- package/package.json +1 -1
|
@@ -20,14 +20,14 @@ async function getExecuitonDetails(frothUrl, token, id) {
|
|
|
20
20
|
});
|
|
21
21
|
if (response.ok) {
|
|
22
22
|
const data = await response.json();
|
|
23
|
-
|
|
23
|
+
// console.log(data)
|
|
24
24
|
jsondata.automation_suite_id = data.automation_suite_id;
|
|
25
25
|
jsondata.test_cycle_id = data.test_cycle_id;
|
|
26
26
|
if (data.testcycle_type === "Android" || data.testcycle_type === "Ios") {
|
|
27
27
|
jsondata.device_name = data.device_name
|
|
28
28
|
jsondata.version = data.version
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
// console.log("json data :" + JSON.stringify(jsondata));
|
|
31
31
|
|
|
32
32
|
return jsondata;
|
|
33
33
|
} else if (response.status === 401) { // Unauthorized, token expired
|
|
@@ -80,7 +80,7 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
80
80
|
|
|
81
81
|
if (response.ok) {
|
|
82
82
|
const data = await response.json();
|
|
83
|
-
|
|
83
|
+
// console.log("data is :"+data)
|
|
84
84
|
|
|
85
85
|
} else if (response.status === 401) { // Unauthorized, token expired
|
|
86
86
|
// Call login function to obtain a new token
|
|
@@ -90,7 +90,7 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
90
90
|
} else {
|
|
91
91
|
const errorText = await response.text();
|
|
92
92
|
console.error(`error in updating the status into DB ${response.status}`);
|
|
93
|
-
|
|
93
|
+
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
|
|
@@ -104,6 +104,54 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
}
|
|
107
|
+
|
|
108
|
+
async function updateScriptExecutionStatus(frothUrl, token, id, status) {
|
|
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)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
// formData.append('execution_id', BUFFER.getItem("EXECUTION_ID"))
|
|
117
|
+
formData.append('scrpit_status', status)
|
|
118
|
+
|
|
119
|
+
const response = await fetch(url, {
|
|
120
|
+
method: 'PUT',
|
|
121
|
+
headers: {
|
|
122
|
+
'Authorization': `Bearer ${token}`
|
|
123
|
+
},
|
|
124
|
+
body: formData
|
|
125
|
+
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
if (response.ok) {
|
|
129
|
+
const data = await response.json();
|
|
130
|
+
// console.log("data is :"+data)
|
|
131
|
+
|
|
132
|
+
} else if (response.status === 401) { // Unauthorized, token expired
|
|
133
|
+
// Call login function to obtain a new token
|
|
134
|
+
const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
135
|
+
// Retry the request with the new token
|
|
136
|
+
return updateScriptExecutionStatus(frothUrl, newToken, id, status);
|
|
137
|
+
} else {
|
|
138
|
+
const errorText = await response.text();
|
|
139
|
+
console.error(`error in updating the status into DB ${response.status}`);
|
|
140
|
+
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
} catch (error) {
|
|
146
|
+
console.error('Error updating data for script status:', error);
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
console.error('Else: Error updating data for script status: Invalid ID');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
|
|
107
155
|
//Execute the main function
|
|
108
156
|
|
|
109
157
|
//Main function to execute the API call
|
|
@@ -133,5 +181,5 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
133
181
|
// }
|
|
134
182
|
|
|
135
183
|
// main();
|
|
136
|
-
module.exports = { getExecuitonDetails, updateExecuitonDetails };
|
|
184
|
+
module.exports = { getExecuitonDetails, updateExecuitonDetails, updateScriptExecutionStatus };
|
|
137
185
|
|
package/api/getsuiteDetails.js
CHANGED
|
@@ -24,9 +24,14 @@ async function getSuiteDetails(frothUrl, token, id) {
|
|
|
24
24
|
jsondata.test_data_id = data.test_data_id;
|
|
25
25
|
jsondata.browser_stack_urls = data.browser_stack_urls;
|
|
26
26
|
jsondata.automation_script_id=data.automation_script_id;
|
|
27
|
-
console.log("automation_script_id:"+jsondata.automation_script_id)
|
|
28
|
-
jsondata.
|
|
29
|
-
|
|
27
|
+
console.log("automation_script_id:" + JSON.stringify(jsondata.automation_script_id))
|
|
28
|
+
const automationScripts = jsondata.automation_script_id.reduce((obj, item) => {
|
|
29
|
+
obj[item.automation_script_id] = item.automation_script_id;
|
|
30
|
+
BUFFER.setItem(item.automation_script_name, item.id);
|
|
31
|
+
return obj;
|
|
32
|
+
}, {});
|
|
33
|
+
jsondata.test_sequence = data.test_sequence;
|
|
34
|
+
console.log("automation_script_ details:" + JSON.stringify(BUFFER))
|
|
30
35
|
|
|
31
36
|
// console.log("json data :" + JSON.stringify(jsondata));
|
|
32
37
|
|
package/api/readTestdata.js
CHANGED
|
@@ -22,7 +22,6 @@ async function getDataById(frothUrl, token, id) {
|
|
|
22
22
|
const data = await response.json();
|
|
23
23
|
// Convert the key-value data to a JSON string
|
|
24
24
|
const jsonData = data.key_value_data;
|
|
25
|
-
console.log("testdata josn value "+JSON.stringify(jsonData))
|
|
26
25
|
// Convert the array into an object with keys as property names
|
|
27
26
|
const bufferdta = jsonData.reduce((obj, item) => {
|
|
28
27
|
obj[item.key] = item.value;
|
package/config/commonconfig.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const setAllDetails = require("./setallDatailinBuffer")
|
|
2
2
|
const { LocalStorage } = require('node-localstorage');
|
|
3
3
|
global.BUFFER = new LocalStorage('./storage');
|
|
4
|
+
|
|
4
5
|
const exeDetails = require("../api/getexecutionDetails")
|
|
5
6
|
const getBSSessionDetails = require("../api/browsersatckSessionInfo")
|
|
6
7
|
|
|
@@ -18,7 +19,6 @@ const commonconfig = {
|
|
|
18
19
|
// await setAllDetails.setIntegrationsDetails();
|
|
19
20
|
await setAllDetails.setSuiteDetails();
|
|
20
21
|
await setAllDetails.setTestDataDetails();
|
|
21
|
-
console.log("buffer in on prepare "+JSON.stringify(BUFFER))
|
|
22
22
|
// console.log(JSON.stringify(capabilities))
|
|
23
23
|
// console.log("ALL JSON DATA in env variable :" + JSON.stringify(process.env));
|
|
24
24
|
},
|
|
@@ -69,18 +69,30 @@ const commonconfig = {
|
|
|
69
69
|
* @param {boolean} result.passed true if test has passed, otherwise false
|
|
70
70
|
* @param {object} result.retries information about spec related retries, e.g. `{ attempts: 0, limit: 0 }`
|
|
71
71
|
*/
|
|
72
|
-
afterTest: function (test, context, { error, result, duration, passed, retries }) {
|
|
72
|
+
afterTest: async function (test, context, { error, result, duration, passed, retries }) {
|
|
73
73
|
console.log(`Test '${test.title}' finished.`);
|
|
74
74
|
console.log('Test file name:', test.file);
|
|
75
|
+
const fileName = path.basename(test.file);
|
|
76
|
+
console.log('Test File Name:', fileName);
|
|
75
77
|
// BUFFER.setItem("TOTAL_DURATION", Number(BUFFER.getItem("TOTAL_DURATION")) + duration)
|
|
76
78
|
console.log(`Duration: ${duration}ms`);
|
|
77
79
|
console.log(`Passed: ${passed}`);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
let scriptresult;
|
|
81
|
+
let scriptid = BUFFER.getItem(fileName)
|
|
82
|
+
|
|
83
|
+
if (passed) {
|
|
84
|
+
scriptresult = "PASSED"
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
scriptresult = "FAILED"
|
|
88
|
+
}
|
|
80
89
|
if (error) {
|
|
81
90
|
console.error(`Error: ${error.message}`);
|
|
91
|
+
scriptresult = "FAILED"
|
|
82
92
|
}
|
|
83
93
|
console.log('---------------------------------------');
|
|
94
|
+
await exeDetails.updateScriptExecutionStatus(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("LOGIN_TOKEN"), scriptid,scriptresult)
|
|
95
|
+
|
|
84
96
|
},
|
|
85
97
|
/**
|
|
86
98
|
* Hook that gets executed after the suite has ended (in Mocha/Jasmine only).
|
|
@@ -119,7 +131,6 @@ const commonconfig = {
|
|
|
119
131
|
console.log("Total Duration:" + BUFFER.getItem("TOTAL_DURATION"));
|
|
120
132
|
resultdetails.excution_time = await secondsToTime(BUFFER.getItem("TOTAL_DURATION"))
|
|
121
133
|
await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("LOGIN_TOKEN"), BUFFER.getItem("EXECUTION_ID"), resultdetails)
|
|
122
|
-
console.log("buffer data " + JSON.stringify(BUFFER))
|
|
123
134
|
BUFFER.clear();
|
|
124
135
|
// Perform any cleanup or post-test actions here
|
|
125
136
|
},
|