froth-webdriverio-framework 7.0.27 → 7.0.28
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.
|
@@ -1,75 +1,58 @@
|
|
|
1
|
+
// Function to get suite details using Bearer token
|
|
2
|
+
async function getSuiteDetails(frothUrl, token, suiteId) {
|
|
3
|
+
// Default response structure
|
|
4
|
+
const jsonData = {
|
|
5
|
+
automation_suite_id: 0,
|
|
6
|
+
automation_suite_name: "",
|
|
7
|
+
test_data_id: 0,
|
|
8
|
+
script_details: [],
|
|
9
|
+
test_sequence: null
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// Validate suite ID
|
|
13
|
+
if (!suiteId || suiteId === 0) {
|
|
14
|
+
console.error('Invalid suite ID or no suite linked to execution');
|
|
15
|
+
return jsonData;
|
|
16
|
+
}
|
|
1
17
|
|
|
2
|
-
|
|
3
|
-
// Function to get data from the API using the Bearer token
|
|
4
|
-
async function getSuiteDetails(frothUrl, token, id) {
|
|
5
|
-
let jsondata = {};
|
|
6
|
-
if (id != 0 || id != null || id != undefined) {
|
|
7
|
-
const url = `${frothUrl}/api/automationsuite-retrieve/${id}/`;
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
console.log("URL: " + url)
|
|
11
|
-
const response = await fetch(url, {
|
|
12
|
-
method: 'GET',
|
|
13
|
-
headers: {
|
|
14
|
-
'Authorization': `Bearer ${token}`,
|
|
15
|
-
'Content-Type': 'application/json'
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
if (response.ok) {
|
|
20
|
-
const data = await response.json();
|
|
21
|
-
// console.log(data)
|
|
22
|
-
jsondata.automation_suite_id = data.id == null ? 0 : data.id;
|
|
23
|
-
jsondata.automation_suite_name = data.automation_suite_name == null ? "" : data.automation_suite_name;
|
|
24
|
-
jsondata.test_data_id = data.test_data_id == null ? 0 : data.test_data_id;
|
|
25
|
-
jsondata.script_details = data.script_details == null ? [] : data.script_details;
|
|
26
|
-
jsondata.test_sequence = data.test_sequence;
|
|
27
|
-
|
|
28
|
-
console.log("json data :" + JSON.stringify(jsondata));
|
|
29
|
-
|
|
18
|
+
const url = `${frothUrl}/api/automationsuite-retrieve/${suiteId}/`;
|
|
30
19
|
|
|
20
|
+
try {
|
|
21
|
+
console.log("Fetching Suite Details URL:", url);
|
|
31
22
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const errorText = await response.text();
|
|
38
|
-
console.error(`Data fetch failed response in getSuiteDetails: ${response.status}`);
|
|
23
|
+
const response = await fetch(url, {
|
|
24
|
+
method: 'GET',
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: `Bearer ${token}`,
|
|
27
|
+
'Content-Type': 'application/json'
|
|
39
28
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (response.ok) {
|
|
32
|
+
const data = await response.json();
|
|
33
|
+
|
|
34
|
+
jsonData.automation_suite_id = data.id ?? 0;
|
|
35
|
+
jsonData.automation_suite_name = data.automation_suite_name ?? "";
|
|
36
|
+
jsonData.test_data_id = data.test_data_id ?? 0;
|
|
37
|
+
jsonData.script_details = data.script_details ?? [];
|
|
38
|
+
jsonData.test_sequence = data.test_sequence ?? null;
|
|
39
|
+
|
|
40
|
+
console.log("Suite JSON Data:", JSON.stringify(jsonData));
|
|
41
|
+
}
|
|
42
|
+
else if (response.status === 401) {
|
|
43
|
+
console.error("Unauthorized: Token expired or invalid (401)");
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const errorText = await response.text();
|
|
47
|
+
console.error(
|
|
48
|
+
`Failed to fetch suite details. Status: ${response.status}, Response: ${errorText}`
|
|
49
|
+
);
|
|
46
50
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
console.error('Error fetching data: Invalid ID or no suite id is linked to execution');
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error('Error while fetching suite details:', error);
|
|
50
53
|
}
|
|
51
|
-
return jsondata;
|
|
52
|
-
}
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// const frothUrl = "devapi.frothtestops.com";
|
|
57
|
-
// const username = "subhra.subudhi@roboticodigital.com";
|
|
58
|
-
// const password = "V2VsY29tZUAxMjM=";
|
|
59
|
-
|
|
60
|
-
// const token = await getLoginToken(frothUrl, username, password);
|
|
61
|
-
// if (!token) {
|
|
62
|
-
// throw new Error('Login failed, no token obtained');
|
|
63
|
-
// }
|
|
64
|
-
|
|
65
|
-
// const id = 147;
|
|
66
|
-
// const data = await getSuiteDetails(frothUrl, token, id);
|
|
67
|
-
// console.log("Retrieved JSON Data:", data);
|
|
68
|
-
// console.log(data.automation_script_id[0].automation_script_id)
|
|
69
|
-
// } catch (error) {
|
|
70
|
-
// console.error('Error in main function:', error);
|
|
71
|
-
// }
|
|
72
|
-
// }
|
|
55
|
+
return jsonData;
|
|
56
|
+
}
|
|
73
57
|
|
|
74
|
-
// main();
|
|
75
58
|
module.exports = getSuiteDetails;
|
|
@@ -104,7 +104,10 @@ const commonHooks = {
|
|
|
104
104
|
await setAllDetails.setSuiteDetails();
|
|
105
105
|
await setAllDetails.setTestDataDetails();
|
|
106
106
|
|
|
107
|
-
console.log('✅ All
|
|
107
|
+
console.log('✅ All Environment Variables:');
|
|
108
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
109
|
+
console.log(`${key} = ${value}`);
|
|
110
|
+
}
|
|
108
111
|
},
|
|
109
112
|
|
|
110
113
|
/* ========== BEFORE SESSION ========== */
|
|
@@ -153,9 +156,8 @@ const commonHooks = {
|
|
|
153
156
|
try {
|
|
154
157
|
const media = JSON.parse(process.env.MEDIA_FILES);
|
|
155
158
|
console.log('Total items:', media.length);
|
|
156
|
-
if (media.length > 0)
|
|
157
|
-
|
|
158
|
-
bsOpts.uploadMedia=JSON.parse(process.env.MEDIA_FILES)
|
|
159
|
+
if (media.length > 0) {
|
|
160
|
+
bsOpts.uploadMedia = JSON.parse(process.env.MEDIA_FILES)
|
|
159
161
|
bsOpts['browserstack.uploadMedia'] = JSON.parse(process.env.MEDIA_FILES);
|
|
160
162
|
}
|
|
161
163
|
} catch {
|