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
@@ -117,7 +117,7 @@ export function getCapsObject(caps) {
117117 try {
118118 let obj = JSON . parse ( cap . value ) ;
119119 return { [ cap . name ] : obj } ;
120- } catch ( ign ) { }
120+ } catch { }
121121 }
122122 return { [ cap . name ] : cap . value } ;
123123 } ) ,
@@ -141,7 +141,7 @@ export function showError(e, params = {methodName: null, secs: 5, url: null}) {
141141 } else if ( e . data ) {
142142 try {
143143 e . data = JSON . parse ( e . data ) ;
144- } catch ( ign ) { }
144+ } catch { }
145145 if ( e . data . value && e . data . value . message ) {
146146 errMessage = e . data . value . message ;
147147 } else {
@@ -156,8 +156,8 @@ export function showError(e, params = {methodName: null, secs: 5, url: null}) {
156156 }
157157 if (
158158 errMessage === 'ECONNREFUSED' ||
159- includes ( errMessage , 'Failed to fetch' ) ||
160- includes ( errMessage , 'The requested resource could not be found' )
159+ _ . includes ( errMessage , 'Failed to fetch' ) ||
160+ _ . includes ( errMessage , 'The requested resource could not be found' )
161161 ) {
162162 errMessage = i18n . t ( 'couldNotConnect' , { url} ) ;
163163 }
@@ -290,7 +290,7 @@ export function newSession(caps, attachSessId = null) {
290290 return false ;
291291 }
292292 https = false ;
293- if ( ! isPlainObject ( desiredCapabilities [ SAUCE_OPTIONS_CAP ] ) ) {
293+ if ( ! _ . isPlainObject ( desiredCapabilities [ SAUCE_OPTIONS_CAP ] ) ) {
294294 desiredCapabilities [ SAUCE_OPTIONS_CAP ] = { } ;
295295 }
296296 if ( ! desiredCapabilities [ SAUCE_OPTIONS_CAP ] . name ) {
@@ -302,7 +302,7 @@ export function newSession(caps, attachSessId = null) {
302302 let headspinUrl ;
303303 try {
304304 headspinUrl = new URL ( session . server . headspin . webDriverUrl ) ;
305- } catch ( ign ) {
305+ } catch {
306306 showError ( new Error ( `${ i18n . t ( 'Invalid URL:' ) } ${ session . server . headspin . webDriverUrl } ` ) ) ;
307307 return false ;
308308 }
@@ -353,15 +353,19 @@ export function newSession(caps, attachSessId = null) {
353353 desiredCapabilities [ 'lt:options' ] . source = 'appiumdesktop' ;
354354 desiredCapabilities [ 'lt:options' ] . isRealMobile = true ;
355355 if ( session . server . advanced . useProxy ) {
356- desiredCapabilities [ 'lt:options' ] . proxyUrl = isUndefined ( session . server . advanced . proxy )
356+ desiredCapabilities [ 'lt:options' ] . proxyUrl = _ . isUndefined (
357+ session . server . advanced . proxy ,
358+ )
357359 ? ''
358360 : session . server . advanced . proxy ;
359361 }
360362 } else {
361363 desiredCapabilities [ 'lambdatest:source' ] = 'appiumdesktop' ;
362364 desiredCapabilities [ 'lambdatest:isRealMobile' ] = true ;
363365 if ( session . server . advanced . useProxy ) {
364- desiredCapabilities [ 'lambdatest:proxyUrl' ] = isUndefined ( session . server . advanced . proxy )
366+ desiredCapabilities [ 'lambdatest:proxyUrl' ] = _ . isUndefined (
367+ session . server . advanced . proxy ,
368+ )
365369 ? ''
366370 : session . server . advanced . proxy ;
367371 }
@@ -447,7 +451,7 @@ export function newSession(caps, attachSessId = null) {
447451 let experitestUrl ;
448452 try {
449453 experitestUrl = new URL ( session . server . experitest . url ) ;
450- } catch ( ign ) {
454+ } catch {
451455 showError ( new Error ( `${ i18n . t ( 'Invalid URL:' ) } ${ session . server . experitest . url } ` ) ) ;
452456 return false ;
453457 }
@@ -489,7 +493,7 @@ export function newSession(caps, attachSessId = null) {
489493 let mobitruUrl ;
490494 try {
491495 mobitruUrl = new URL ( webDriverUrl ) ;
492- } catch ( ign ) {
496+ } catch {
493497 showError ( new Error ( `${ i18n . t ( 'Invalid URL:' ) } ${ webDriverUrl } ` ) ) ;
494498 return false ;
495499 }
@@ -549,13 +553,13 @@ export function newSession(caps, attachSessId = null) {
549553 // If a newCommandTimeout wasn't provided, set it to 60 * 60 so that sessions don't close on users in short term.
550554 // I saw sometimes infinit session timeout was not so good for cloud providers.
551555 // So, let me define this value as NEW_COMMAND_TIMEOUT_SEC by default.
552- if ( isUndefined ( desiredCapabilities [ CAPS_NEW_COMMAND ] ) ) {
556+ if ( _ . isUndefined ( desiredCapabilities [ CAPS_NEW_COMMAND ] ) ) {
553557 desiredCapabilities [ CAPS_NEW_COMMAND ] = NEW_COMMAND_TIMEOUT_SEC ;
554558 }
555559
556560 // If someone didn't specify connectHardwareKeyboard, set it to true by
557561 // default
558- if ( isUndefined ( desiredCapabilities [ CAPS_CONNECT_HARDWARE_KEYBOARD ] ) ) {
562+ if ( _ . isUndefined ( desiredCapabilities [ CAPS_CONNECT_HARDWARE_KEYBOARD ] ) ) {
559563 desiredCapabilities [ CAPS_CONNECT_HARDWARE_KEYBOARD ] = true ;
560564 }
561565
@@ -627,7 +631,7 @@ export function newSession(caps, attachSessId = null) {
627631 try {
628632 mode = APP_MODE . WEB_HYBRID ;
629633 await driver . navigateTo ( 'https://appium.io' ) ;
630- } catch ( ign ) { }
634+ } catch { }
631635 }
632636
633637 let mjpegScreenshotUrl =
@@ -861,7 +865,7 @@ export function setSavedServerParams() {
861865 if ( server ) {
862866 // if we have a cloud provider as a saved server, but for some reason the
863867 // cloud provider is no longer in the list, revert server type to remote
864- if ( values ( SERVER_TYPES ) . includes ( serverType ) && ! currentProviders . includes ( serverType ) ) {
868+ if ( _ . values ( SERVER_TYPES ) . includes ( serverType ) && ! currentProviders . includes ( serverType ) ) {
865869 serverType = SERVER_TYPES . REMOTE ;
866870 }
867871 dispatch ( { type : SET_SERVER , server, serverType} ) ;
@@ -978,7 +982,7 @@ async function fetchAllSessions(baseUrl, authToken) {
978982 try {
979983 const res = await fetchSessionInformation ( { url, authToken} ) ;
980984 return res . data . value ?? [ ] ;
981- } catch ( err ) {
985+ } catch {
982986 return [ ] ;
983987 }
984988 }
@@ -988,7 +992,7 @@ async function fetchAllSessions(baseUrl, authToken) {
988992 try {
989993 const res = await fetchSessionInformation ( { url, authToken} ) ;
990994 return formatSeleniumGridSessions ( res ) ;
991- } catch ( err ) {
995+ } catch {
992996 return [ ] ;
993997 }
994998 }
@@ -1048,7 +1052,7 @@ export function saveRawDesiredCaps() {
10481052 }
10491053
10501054 // Translate the caps JSON to array format
1051- let newCapsArray = toPairs ( newCaps ) . map ( ( [ name , value ] ) => ( {
1055+ let newCapsArray = _ . toPairs ( newCaps ) . map ( ( [ name , value ] ) => ( {
10521056 type : ( ( ) => {
10531057 let type = typeof value ;
10541058
@@ -1103,7 +1107,7 @@ export function stopAddCloudProvider() {
11031107export function addVisibleProvider ( provider ) {
11041108 return async ( dispatch , getState ) => {
11051109 let currentProviders = getState ( ) . session . visibleProviders ;
1106- const providers = union ( currentProviders , [ provider ] ) ;
1110+ const providers = _ . union ( currentProviders , [ provider ] ) ;
11071111 await setSetting ( VISIBLE_PROVIDERS , providers ) ;
11081112 dispatch ( { type : SET_PROVIDERS , providers} ) ;
11091113 } ;
@@ -1116,7 +1120,7 @@ export function removeVisibleProvider(provider) {
11161120 const action = changeServerType ( 'remote' ) ;
11171121 await action ( dispatch , getState ) ;
11181122 }
1119- const providers = without ( visibleProviders , provider ) ;
1123+ const providers = _ . without ( visibleProviders , provider ) ;
11201124 await setSetting ( VISIBLE_PROVIDERS , providers ) ;
11211125 dispatch ( { type : SET_PROVIDERS , providers} ) ;
11221126 } ;
@@ -1197,7 +1201,7 @@ export function initFromQueryString(loadNewSession) {
11971201 try {
11981202 const state = JSON . parse ( initialState ) ;
11991203 dispatch ( { type : SET_STATE_FROM_URL , state} ) ;
1200- } catch ( e ) {
1204+ } catch {
12011205 showError ( new Error ( 'Could not parse initial state from URL' ) , { secs : 0 } ) ;
12021206 }
12031207 }
0 commit comments