11import { notification } from 'antd' ;
2- import { includes , isPlainObject , isUndefined , toPairs , union , values , without } from 'lodash' ;
2+ import _ from 'lodash' ;
33import moment from 'moment' ;
44import { Web2Driver } from 'web2driver' ;
55
@@ -110,7 +110,7 @@ export function getCapsObject(caps) {
110110 try {
111111 let obj = JSON . parse ( cap . value ) ;
112112 return { [ cap . name ] : obj } ;
113- } catch ( ign ) { }
113+ } catch { }
114114 }
115115 return { [ cap . name ] : cap . value } ;
116116 } ) ,
@@ -134,7 +134,7 @@ export function showError(e, params = {methodName: null, secs: 5, url: null}) {
134134 } else if ( e . data ) {
135135 try {
136136 e . data = JSON . parse ( e . data ) ;
137- } catch ( ign ) { }
137+ } catch { }
138138 if ( e . data . value && e . data . value . message ) {
139139 errMessage = e . data . value . message ;
140140 } else {
@@ -149,8 +149,8 @@ export function showError(e, params = {methodName: null, secs: 5, url: null}) {
149149 }
150150 if (
151151 errMessage === 'ECONNREFUSED' ||
152- includes ( errMessage , 'Failed to fetch' ) ||
153- includes ( errMessage , 'The requested resource could not be found' )
152+ _ . includes ( errMessage , 'Failed to fetch' ) ||
153+ _ . includes ( errMessage , 'The requested resource could not be found' )
154154 ) {
155155 errMessage = i18n . t ( 'couldNotConnect' , { url} ) ;
156156 }
@@ -265,7 +265,7 @@ export function newSession(caps, attachSessId = null) {
265265 return false ;
266266 }
267267 https = false ;
268- if ( ! isPlainObject ( desiredCapabilities [ SAUCE_OPTIONS_CAP ] ) ) {
268+ if ( ! _ . isPlainObject ( desiredCapabilities [ SAUCE_OPTIONS_CAP ] ) ) {
269269 desiredCapabilities [ SAUCE_OPTIONS_CAP ] = { } ;
270270 }
271271 if ( ! desiredCapabilities [ SAUCE_OPTIONS_CAP ] . name ) {
@@ -277,7 +277,7 @@ export function newSession(caps, attachSessId = null) {
277277 let headspinUrl ;
278278 try {
279279 headspinUrl = new URL ( session . server . headspin . webDriverUrl ) ;
280- } catch ( ign ) {
280+ } catch {
281281 showError ( new Error ( `${ i18n . t ( 'Invalid URL:' ) } ${ session . server . headspin . webDriverUrl } ` ) ) ;
282282 return false ;
283283 }
@@ -328,15 +328,19 @@ export function newSession(caps, attachSessId = null) {
328328 desiredCapabilities [ 'lt:options' ] . source = 'appiumdesktop' ;
329329 desiredCapabilities [ 'lt:options' ] . isRealMobile = true ;
330330 if ( session . server . advanced . useProxy ) {
331- desiredCapabilities [ 'lt:options' ] . proxyUrl = isUndefined ( session . server . advanced . proxy )
331+ desiredCapabilities [ 'lt:options' ] . proxyUrl = _ . isUndefined (
332+ session . server . advanced . proxy ,
333+ )
332334 ? ''
333335 : session . server . advanced . proxy ;
334336 }
335337 } else {
336338 desiredCapabilities [ 'lambdatest:source' ] = 'appiumdesktop' ;
337339 desiredCapabilities [ 'lambdatest:isRealMobile' ] = true ;
338340 if ( session . server . advanced . useProxy ) {
339- desiredCapabilities [ 'lambdatest:proxyUrl' ] = isUndefined ( session . server . advanced . proxy )
341+ desiredCapabilities [ 'lambdatest:proxyUrl' ] = _ . isUndefined (
342+ session . server . advanced . proxy ,
343+ )
340344 ? ''
341345 : session . server . advanced . proxy ;
342346 }
@@ -422,7 +426,7 @@ export function newSession(caps, attachSessId = null) {
422426 let experitestUrl ;
423427 try {
424428 experitestUrl = new URL ( session . server . experitest . url ) ;
425- } catch ( ign ) {
429+ } catch {
426430 showError ( new Error ( `${ i18n . t ( 'Invalid URL:' ) } ${ session . server . experitest . url } ` ) ) ;
427431 return false ;
428432 }
@@ -464,7 +468,7 @@ export function newSession(caps, attachSessId = null) {
464468 let mobitruUrl ;
465469 try {
466470 mobitruUrl = new URL ( webDriverUrl ) ;
467- } catch ( ign ) {
471+ } catch {
468472 showError ( new Error ( `${ i18n . t ( 'Invalid URL:' ) } ${ webDriverUrl } ` ) ) ;
469473 return false ;
470474 }
@@ -524,13 +528,13 @@ export function newSession(caps, attachSessId = null) {
524528 // If a newCommandTimeout wasn't provided, set it to 60 * 60 so that sessions don't close on users in short term.
525529 // I saw sometimes infinit session timeout was not so good for cloud providers.
526530 // So, let me define this value as NEW_COMMAND_TIMEOUT_SEC by default.
527- if ( isUndefined ( desiredCapabilities [ CAPS_NEW_COMMAND ] ) ) {
531+ if ( _ . isUndefined ( desiredCapabilities [ CAPS_NEW_COMMAND ] ) ) {
528532 desiredCapabilities [ CAPS_NEW_COMMAND ] = NEW_COMMAND_TIMEOUT_SEC ;
529533 }
530534
531535 // If someone didn't specify connectHardwareKeyboard, set it to true by
532536 // default
533- if ( isUndefined ( desiredCapabilities [ CAPS_CONNECT_HARDWARE_KEYBOARD ] ) ) {
537+ if ( _ . isUndefined ( desiredCapabilities [ CAPS_CONNECT_HARDWARE_KEYBOARD ] ) ) {
534538 desiredCapabilities [ CAPS_CONNECT_HARDWARE_KEYBOARD ] = true ;
535539 }
536540
@@ -602,7 +606,7 @@ export function newSession(caps, attachSessId = null) {
602606 try {
603607 mode = APP_MODE . WEB_HYBRID ;
604608 await driver . navigateTo ( 'https://appium.io' ) ;
605- } catch ( ign ) { }
609+ } catch { }
606610 }
607611
608612 let mjpegScreenshotUrl =
@@ -836,7 +840,7 @@ export function setSavedServerParams() {
836840 if ( server ) {
837841 // if we have a cloud provider as a saved server, but for some reason the
838842 // cloud provider is no longer in the list, revert server type to remote
839- if ( values ( SERVER_TYPES ) . includes ( serverType ) && ! currentProviders . includes ( serverType ) ) {
843+ if ( _ . values ( SERVER_TYPES ) . includes ( serverType ) && ! currentProviders . includes ( serverType ) ) {
840844 serverType = SERVER_TYPES . REMOTE ;
841845 }
842846 dispatch ( { type : SET_SERVER , server, serverType} ) ;
@@ -953,7 +957,7 @@ async function fetchAllSessions(baseUrl, authToken) {
953957 try {
954958 const res = await fetchSessionInformation ( { url, authToken} ) ;
955959 return res . data . value ?? [ ] ;
956- } catch ( err ) {
960+ } catch {
957961 return [ ] ;
958962 }
959963 }
@@ -963,7 +967,7 @@ async function fetchAllSessions(baseUrl, authToken) {
963967 try {
964968 const res = await fetchSessionInformation ( { url, authToken} ) ;
965969 return formatSeleniumGridSessions ( res ) ;
966- } catch ( err ) {
970+ } catch {
967971 return [ ] ;
968972 }
969973 }
@@ -1023,7 +1027,7 @@ export function saveRawDesiredCaps() {
10231027 }
10241028
10251029 // Translate the caps JSON to array format
1026- let newCapsArray = toPairs ( newCaps ) . map ( ( [ name , value ] ) => ( {
1030+ let newCapsArray = _ . toPairs ( newCaps ) . map ( ( [ name , value ] ) => ( {
10271031 type : ( ( ) => {
10281032 let type = typeof value ;
10291033
@@ -1078,7 +1082,7 @@ export function stopAddCloudProvider() {
10781082export function addVisibleProvider ( provider ) {
10791083 return async ( dispatch , getState ) => {
10801084 let currentProviders = getState ( ) . session . visibleProviders ;
1081- const providers = union ( currentProviders , [ provider ] ) ;
1085+ const providers = _ . union ( currentProviders , [ provider ] ) ;
10821086 await setSetting ( VISIBLE_PROVIDERS , providers ) ;
10831087 dispatch ( { type : SET_PROVIDERS , providers} ) ;
10841088 } ;
@@ -1091,7 +1095,7 @@ export function removeVisibleProvider(provider) {
10911095 const action = changeServerType ( 'remote' ) ;
10921096 await action ( dispatch , getState ) ;
10931097 }
1094- const providers = without ( visibleProviders , provider ) ;
1098+ const providers = _ . without ( visibleProviders , provider ) ;
10951099 await setSetting ( VISIBLE_PROVIDERS , providers ) ;
10961100 dispatch ( { type : SET_PROVIDERS , providers} ) ;
10971101 } ;
@@ -1172,7 +1176,7 @@ export function initFromQueryString(loadNewSession) {
11721176 try {
11731177 const state = JSON . parse ( initialState ) ;
11741178 dispatch ( { type : SET_STATE_FROM_URL , state} ) ;
1175- } catch ( e ) {
1179+ } catch {
11761180 showError ( new Error ( 'Could not parse initial state from URL' ) , { secs : 0 } ) ;
11771181 }
11781182 }
0 commit comments