froth-webdriverio-framework 1.0.83 → 1.0.85

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.
@@ -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
+
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, 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)
153
+ async function updateScriptExecutionStatus(frothUrl, token, scriptid, status) {
114
154
 
155
+ if (scriptid != 0) {
156
+ try {
157
+ 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
 
@@ -71,14 +71,13 @@ 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)
78
77
  console.log(`Duration: ${duration}ms`);
79
78
  console.log(`Passed: ${passed}`);
80
79
  let scriptresult;
81
- let scriptid = BUFFER.getItem(fileName)
80
+ let scriptid = BUFFER.getItem(fileName.replace(".js", ""))
82
81
 
83
82
  if (passed) {
84
83
  scriptresult = "PASSED"
@@ -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"), scriptid,scriptresult)
93
+ await exeDetails.updateScriptExecutionStatus(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("LOGIN_TOKEN"), scriptid, scriptresult)
95
94
 
96
95
  },
97
96
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "1.0.83",
3
+ "version": "1.0.85",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",