@ -1,4 +1,4 @@
import { NightwatchBrowser , NightwatchCallbackResult } from 'nightwatch'
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events'
class VerifyContracts extends EventEmitter {
@ -13,7 +13,7 @@ class VerifyContracts extends EventEmitter {
}
}
function getCompiled Contracts ( browser : NightwatchBrowser , opts : { wait : number , version? : string } , callback : ( result : NightwatchCallbackResult < any > ) = > void ) {
function verify Contracts ( browser : NightwatchBrowser , compiledContractNames : string [ ] , opts : { wait : number , version? : string } , callback : VoidFunction ) {
browser
. clickLaunchIcon ( 'solidity' )
. pause ( opts . wait )
@ -29,43 +29,13 @@ function getCompiledContracts (browser: NightwatchBrowser, opts: { wait: number,
. assert . containsText ( '*[data-id="treeViewLicompiler/version"]' , ` version: \ n ${ opts . version } ` )
. modalFooterCancelClick ( )
. perform ( done )
} else done ( )
} )
. execute ( function ( ) {
const contracts = document . querySelectorAll ( '*[data-id="compiledContracts"] option' ) as NodeListOf < HTMLInputElement >
if ( ! contracts ) {
return null
} else {
const ret = [ ]
for ( let c = 0 ; c < contracts . length ; c ++ ) {
ret . push ( contracts [ c ] . value )
}
return ret
}
} , [ ] , function ( result ) {
callback ( result )
compiledContractNames . forEach ( ( name ) = > {
browser . waitForElementContainsText ( '[data-id="compiledContracts"]' , name , 60000 )
} )
}
function verifyContracts ( browser : NightwatchBrowser , compiledContractNames : string [ ] , opts : { wait : number , version? : string } , callback : VoidFunction ) {
getCompiledContracts ( browser , opts , ( result : NightwatchCallbackResult < any > ) = > {
if ( result . value ) {
for ( const contract in compiledContractNames ) {
console . log ( ' - ' + compiledContractNames [ contract ] , result . value )
if ( result . value . indexOf ( compiledContractNames [ contract ] ) === - 1 ) {
browser . assert . fail ( 'compiled contract ' + compiledContractNames + ' not found' , 'info about error' , '' )
browser . end ( )
return
}
}
} else {
browser . assert . fail ( 'compiled contract ' + compiledContractNames + ' not found - none found' , 'info about error' , '' )
browser . end ( )
}
console . log ( 'contracts all found ' + compiledContractNames )
done ( )
callback ( )
}
} )
}