Skip to content

Commit 3f75880

Browse files
committed
SDK-1884: fixed scanner started twice.
1 parent 02ea36a commit 3f75880

File tree

1 file changed

+22
-1
lines changed
  • bin/accessibility-automation/cypress

1 file changed

+22
-1
lines changed

bin/accessibility-automation/cypress/index.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ new Promise(async (resolve, reject) => {
2121
const isHttpOrHttps = /^(http|https):$/.test(win.location.protocol);
2222
if (!isHttpOrHttps) {
2323
resolve();
24+
return;
2425
}
2526

2627
function findAccessibilityAutomationElement() {
@@ -38,9 +39,11 @@ new Promise(async (resolve, reject) => {
3839
"Accessibility Automation Scanner is not ready on the page."
3940
)
4041
);
42+
return;
4143
} else if (findAccessibilityAutomationElement()) {
4244
clearInterval(intervalID);
4345
resolve("Scanner set");
46+
return;
4447
} else {
4548
count += 1;
4649
}
@@ -52,6 +55,7 @@ new Promise(async (resolve, reject) => {
5255
function onScanComplete() {
5356
win.removeEventListener("A11Y_SCAN_FINISHED", onScanComplete);
5457
resolve();
58+
return;
5559
}
5660

5761
win.addEventListener("A11Y_SCAN_FINISHED", onScanComplete);
@@ -66,6 +70,7 @@ new Promise(async (resolve, reject) => {
6670
.then(startScan)
6771
.catch(async (err) => {
6872
resolve("Scanner is not ready on the page after multiple retries. performscan");
73+
return;
6974
});
7075
}
7176
})
@@ -75,6 +80,7 @@ new Promise((resolve) => {
7580
const isHttpOrHttps = /^(http|https):$/.test(window.location.protocol);
7681
if (!isHttpOrHttps) {
7782
resolve();
83+
return;
7884
}
7985

8086
function findAccessibilityAutomationElement() {
@@ -92,9 +98,11 @@ new Promise((resolve) => {
9298
"Accessibility Automation Scanner is not ready on the page."
9399
)
94100
);
101+
return;
95102
} else if (findAccessibilityAutomationElement()) {
96103
clearInterval(intervalID);
97104
resolve("Scanner set");
105+
return;
98106
} else {
99107
count += 1;
100108
}
@@ -106,6 +114,7 @@ new Promise((resolve) => {
106114
function onReceiveSummary(event) {
107115
win.removeEventListener("A11Y_RESULTS_SUMMARY", onReceiveSummary);
108116
resolve(event.detail);
117+
return;
109118
}
110119

111120
win.addEventListener("A11Y_RESULTS_SUMMARY", onReceiveSummary);
@@ -120,6 +129,7 @@ new Promise((resolve) => {
120129
.then(getSummary)
121130
.catch((err) => {
122131
resolve();
132+
return;
123133
});
124134
}
125135
})
@@ -129,6 +139,7 @@ new Promise((resolve) => {
129139
const isHttpOrHttps = /^(http|https):$/.test(window.location.protocol);
130140
if (!isHttpOrHttps) {
131141
resolve();
142+
return;
132143
}
133144

134145
function findAccessibilityAutomationElement() {
@@ -146,9 +157,11 @@ new Promise((resolve) => {
146157
"Accessibility Automation Scanner is not ready on the page."
147158
)
148159
);
160+
return;
149161
} else if (findAccessibilityAutomationElement()) {
150162
clearInterval(intervalID);
151163
resolve("Scanner set");
164+
return;
152165
} else {
153166
count += 1;
154167
}
@@ -160,6 +173,7 @@ new Promise((resolve) => {
160173
function onReceivedResult(event) {
161174
win.removeEventListener("A11Y_RESULTS_RESPONSE", onReceivedResult);
162175
resolve(event.detail);
176+
return;
163177
}
164178

165179
win.addEventListener("A11Y_RESULTS_RESPONSE", onReceivedResult);
@@ -174,6 +188,7 @@ new Promise((resolve) => {
174188
.then(getResults)
175189
.catch((err) => {
176190
resolve();
191+
return;
177192
});
178193
}
179194
});
@@ -184,6 +199,7 @@ new Promise( (resolve, reject) => {
184199
const isHttpOrHttps = /^(http|https):$/.test(win.location.protocol);
185200
if (!isHttpOrHttps) {
186201
resolve("Unable to save accessibility results, Invalid URL.");
202+
return;
187203
}
188204

189205
function findAccessibilityAutomationElement() {
@@ -201,9 +217,11 @@ new Promise( (resolve, reject) => {
201217
"Accessibility Automation Scanner is not ready on the page."
202218
)
203219
);
220+
return;
204221
} else if (findAccessibilityAutomationElement()) {
205222
clearInterval(intervalID);
206223
resolve("Scanner set");
224+
return;
207225
} else {
208226
count += 1;
209227
}
@@ -214,6 +232,7 @@ new Promise( (resolve, reject) => {
214232
function saveResults() {
215233
function onResultsSaved(event) {
216234
resolve();
235+
return;
217236
}
218237
win.addEventListener("A11Y_RESULTS_SAVED", onResultsSaved);
219238
const e = new CustomEvent("A11Y_SAVE_RESULTS", {
@@ -229,11 +248,13 @@ new Promise( (resolve, reject) => {
229248
.then(saveResults)
230249
.catch(async (err) => {
231250
resolve("Scanner is not ready on the page after multiple retries. after run");
251+
return;
232252
});
233253
}
234254
} catch(error) {
235255
browserStackLog(`Error in saving results with error: ${error.message}`);
236-
resolve()
256+
resolve();
257+
return;
237258
}
238259

239260
})

0 commit comments

Comments
 (0)