Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
63b07563
Commit
63b07563
authored
Jul 31, 2020
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added libraryDeployment tests
parent
61f5bd77
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
293 additions
and
19 deletions
+293
-19
createContract.ts
apps/remix-ide-e2e/src/commands/createContract.ts
+32
-0
getAddressAtPosition.ts
apps/remix-ide-e2e/src/commands/getAddressAtPosition.ts
+29
-0
getEditorValue.ts
apps/remix-ide-e2e/src/commands/getEditorValue.ts
+21
-0
getModalBody.ts
apps/remix-ide-e2e/src/commands/getModalBody.ts
+2
-2
selectContract.ts
apps/remix-ide-e2e/src/commands/selectContract.ts
+23
-0
testConstantFunction.ts
apps/remix-ide-e2e/src/commands/testConstantFunction.ts
+37
-0
verifyContracts.ts
apps/remix-ide-e2e/src/commands/verifyContracts.ts
+1
-1
editor.test.ts
apps/remix-ide-e2e/src/tests/editor.test.ts
+2
-3
fileExplorer.test.ts
apps/remix-ide-e2e/src/tests/fileExplorer.test.ts
+3
-3
fileManager_api.test.ts
apps/remix-ide-e2e/src/tests/fileManager_api.test.ts
+2
-3
generalSettings.test.ts
apps/remix-ide-e2e/src/tests/generalSettings.test.ts
+2
-3
gist.test.ts
apps/remix-ide-e2e/src/tests/gist.test.ts
+2
-2
libraryDeployment.test.ts
apps/remix-ide-e2e/src/tests/libraryDeployment.test.ts
+124
-0
index.d.ts
apps/remix-ide-e2e/src/types/index.d.ts
+13
-2
No files found.
apps/remix-ide-e2e/src/commands/createContract.ts
0 → 100644
View file @
63b07563
import
{
NightwatchBrowser
}
from
"nightwatch"
import
EventEmitter
from
"events"
class
CreateContract
extends
EventEmitter
{
command
(
this
:
NightwatchBrowser
,
inputParams
:
string
):
NightwatchBrowser
{
this
.
api
.
perform
((
done
)
=>
{
createContract
(
this
.
api
,
inputParams
,
()
=>
{
done
()
this
.
emit
(
'complete'
)
})
})
return
this
}
}
function
createContract
(
browser
:
NightwatchBrowser
,
inputParams
:
string
,
callback
:
VoidFunction
)
{
if
(
inputParams
)
{
browser
.
clickLaunchIcon
(
'settings'
).
clickLaunchIcon
(
'udapp'
)
.
setValue
(
'div[class^="contractActionsContainerSingle"] input'
,
inputParams
,
function
()
{
browser
.
click
(
'#runTabView button[class^="instanceButton"]'
).
pause
(
500
).
perform
(
function
()
{
callback
()
})
})
}
else
{
browser
.
clickLaunchIcon
(
'settings'
)
.
clickLaunchIcon
(
'udapp'
)
.
click
(
'#runTabView button[class^="instanceButton"]'
)
.
pause
(
500
)
.
perform
(
function
()
{
callback
()
})
}
}
module
.
exports
=
CreateContract
apps/remix-ide-e2e/src/commands/getAddressAtPosition.ts
0 → 100644
View file @
63b07563
import
{
NightwatchBrowser
}
from
"nightwatch"
import
EventEmitter
from
"events"
class
GetAddressAtPosition
extends
EventEmitter
{
command
(
this
:
NightwatchBrowser
,
index
:
number
,
cb
:
(
pos
:
string
)
=>
void
):
NightwatchBrowser
{
this
.
api
.
perform
((
done
)
=>
{
getAddressAtPosition
(
this
.
api
,
index
,
(
pos
)
=>
{
done
()
cb
(
pos
)
this
.
emit
(
'complete'
)
})
})
return
this
}
}
function
getAddressAtPosition
(
browser
:
NightwatchBrowser
,
index
:
number
,
callback
:
(
pos
:
string
)
=>
void
)
{
browser
.
waitForElementPresent
(
'*[data-shared="universalDappUiInstance"]'
)
.
execute
(
function
(
index
)
{
const
deployedContracts
=
document
.
querySelectorAll
(
'*[data-shared="universalDappUiInstance"]'
)
const
id
=
deployedContracts
[
index
].
getAttribute
(
'id'
)
return
id
.
replace
(
'instance'
,
''
)
},
[
index
],
function
(
result
)
{
typeof
result
.
value
===
'string'
&&
callback
(
result
.
value
)
})
}
module
.
exports
=
GetAddressAtPosition
apps/remix-ide-e2e/src/commands/getEditorValue.ts
0 → 100644
View file @
63b07563
import
{
NightwatchBrowser
}
from
"nightwatch"
import
EventEmitter
from
"events"
class
GetEditorValue
extends
EventEmitter
{
command
(
this
:
NightwatchBrowser
,
callback
:
(
content
:
string
)
=>
void
):
NightwatchBrowser
{
this
.
api
.
perform
((
client
,
done
)
=>
{
this
.
api
.
execute
(
function
()
{
const
elem
:
any
=
document
.
getElementById
(
'input'
)
elem
.
editor
.
getValue
()
},
[],
(
result
)
=>
{
done
()
callback
(
typeof
result
.
value
===
'string'
?
result
.
value
:
''
)
this
.
emit
(
'complete'
)
})
})
return
this
}
}
module
.
exports
=
GetEditorValue
apps/remix-ide-e2e/src/commands/getModalBody.ts
View file @
63b07563
...
@@ -2,11 +2,11 @@ import { NightwatchBrowser } from "nightwatch"
...
@@ -2,11 +2,11 @@ import { NightwatchBrowser } from "nightwatch"
import
EventEmitter
from
"events"
import
EventEmitter
from
"events"
class
GetModalBody
extends
EventEmitter
{
class
GetModalBody
extends
EventEmitter
{
command
(
this
:
NightwatchBrowser
,
callback
:
CallableFunction
)
{
command
(
this
:
NightwatchBrowser
,
callback
:
(
value
:
string
,
cb
:
VoidFunction
)
=>
void
)
{
this
.
api
.
waitForElementVisible
(
'.modal-body'
)
this
.
api
.
waitForElementVisible
(
'.modal-body'
)
.
getText
(
'.modal-body'
,
(
result
)
=>
{
.
getText
(
'.modal-body'
,
(
result
)
=>
{
console
.
log
(
result
)
console
.
log
(
result
)
callback
(
result
.
value
,
()
=>
{
typeof
result
.
value
===
'string'
&&
callback
(
result
.
value
,
()
=>
{
this
.
emit
(
'complete'
)
this
.
emit
(
'complete'
)
})
})
})
})
...
...
apps/remix-ide-e2e/src/commands/selectContract.ts
0 → 100644
View file @
63b07563
import
{
NightwatchBrowser
}
from
'nightwatch'
import
EventEmitter
from
"events"
class
SelectContract
extends
EventEmitter
{
command
(
this
:
NightwatchBrowser
,
contractName
:
string
):
NightwatchBrowser
{
this
.
api
.
perform
((
done
)
=>
{
selectContract
(
this
.
api
,
contractName
,
()
=>
{
done
()
this
.
emit
(
'complete'
)
})
})
return
this
}
}
function
selectContract
(
browser
:
NightwatchBrowser
,
contractName
:
string
,
callback
:
VoidFunction
)
{
browser
.
clickLaunchIcon
(
'settings'
).
clickLaunchIcon
(
'udapp'
)
.
setValue
(
'#runTabView select[class^="contractNames"]'
,
contractName
).
perform
(()
=>
{
callback
()
})
}
module
.
exports
=
SelectContract
apps/remix-ide-e2e/src/commands/testConstantFunction.ts
0 → 100644
View file @
63b07563
import
{
NightwatchBrowser
,
NightwatchTestConstantFunctionExpectedInput
}
from
"nightwatch"
import
EventEmitter
from
"events"
class
TestConstantFunction
extends
EventEmitter
{
command
(
this
:
NightwatchBrowser
,
address
:
string
,
fnFullName
:
string
,
expectedInput
:
NightwatchTestConstantFunctionExpectedInput
|
null
,
expectedOutput
:
string
):
NightwatchBrowser
{
console
.
log
(
'TestConstantFunction '
+
address
+
' fnFullName'
)
this
.
api
.
perform
((
done
)
=>
{
testConstantFunction
(
this
.
api
,
address
,
fnFullName
,
expectedInput
,
expectedOutput
,
()
=>
{
done
()
this
.
emit
(
'complete'
)
})
})
return
this
}
}
function
testConstantFunction
(
browser
:
NightwatchBrowser
,
address
:
string
,
fnFullName
:
string
,
expectedInput
:
NightwatchTestConstantFunctionExpectedInput
,
expectedOutput
:
string
,
cb
:
VoidFunction
)
{
browser
.
waitForElementPresent
(
'.instance button[title="'
+
fnFullName
+
'"]'
).
perform
(
function
(
client
,
done
)
{
client
.
execute
(
function
()
{
document
.
querySelector
(
'#runTabView'
).
scrollTop
=
document
.
querySelector
(
'#runTabView'
).
scrollHeight
},
[],
function
()
{
if
(
expectedInput
)
{
client
.
setValue
(
'#runTabView input[title="'
+
expectedInput
.
types
+
'"]'
,
expectedInput
.
values
)
}
done
()
})
})
.
click
(
'.instance button[title="'
+
fnFullName
+
'"]'
)
.
pause
(
1000
)
.
waitForElementPresent
(
'#instance'
+
address
+
' div[class^="contractActionsContainer"] div[class^="value"]'
)
.
scrollInto
(
'#instance'
+
address
+
' div[class^="contractActionsContainer"] div[class^="value"]'
)
.
assert
.
containsText
(
'#instance'
+
address
+
' div[class^="contractActionsContainer"] div[class^="value"]'
,
expectedOutput
).
perform
(()
=>
{
cb
()
})
}
module
.
exports
=
TestConstantFunction
apps/remix-ide-e2e/src/commands/verifyContracts.ts
View file @
63b07563
...
@@ -13,7 +13,7 @@ class VerifyContracts extends EventEmitter {
...
@@ -13,7 +13,7 @@ class VerifyContracts extends EventEmitter {
}
}
}
}
function
getCompiledContracts
(
browser
:
NightwatchBrowser
,
opts
:
NightwatchVerifyContractOpts
,
callback
:
CallableFunction
)
{
function
getCompiledContracts
(
browser
:
NightwatchBrowser
,
opts
:
NightwatchVerifyContractOpts
,
callback
:
(
result
:
NightwatchCallbackResult
<
any
>
)
=>
void
)
{
browser
browser
.
clickLaunchIcon
(
'solidity'
)
.
clickLaunchIcon
(
'solidity'
)
.
pause
(
opts
.
wait
)
.
pause
(
opts
.
wait
)
...
...
apps/remix-ide-e2e/src/tests/editor.test.ts
View file @
63b07563
'use strict'
'use strict'
import
{
NightwatchBrowser
}
from
"nightwatch"
import
{
NightwatchBrowser
}
from
"nightwatch"
import
init
from
'../helpers/init'
const
init
=
require
(
'../helpers/init'
)
import
sauce
from
'./sauce'
const
sauce
=
require
(
'./sauce'
)
module
.
exports
=
{
module
.
exports
=
{
...
...
apps/remix-ide-e2e/src/tests/fileExplorer.test.ts
View file @
63b07563
'use strict'
'use strict'
import
{
NightwatchBrowser
}
from
"nightwatch"
import
{
NightwatchBrowser
}
from
"nightwatch"
import
init
from
'../helpers/init'
import
sauce
from
'./sauce'
import
*
as
path
from
'path'
const
init
=
require
(
'../helpers/init'
)
const
sauce
=
require
(
'./sauce'
)
const
path
=
require
(
'path'
)
const
testData
=
{
const
testData
=
{
testFile1
:
path
.
resolve
(
__dirname
+
'/editor.test.js'
),
// eslint-disable-line
testFile1
:
path
.
resolve
(
__dirname
+
'/editor.test.js'
),
// eslint-disable-line
testFile2
:
path
.
resolve
(
__dirname
+
'/fileExplorer.test.js'
),
// eslint-disable-line
testFile2
:
path
.
resolve
(
__dirname
+
'/fileExplorer.test.js'
),
// eslint-disable-line
...
...
apps/remix-ide-e2e/src/tests/fileManager_api.test.ts
View file @
63b07563
'use strict'
'use strict'
import
{
NightwatchBrowser
}
from
"nightwatch"
import
{
NightwatchBrowser
}
from
"nightwatch"
import
init
from
'../helpers/init'
const
init
=
require
(
'../helpers/init'
)
import
sauce
from
'./sauce'
const
sauce
=
require
(
'./sauce'
)
module
.
exports
=
{
module
.
exports
=
{
before
:
function
(
browser
:
NightwatchBrowser
,
done
:
VoidFunction
)
{
before
:
function
(
browser
:
NightwatchBrowser
,
done
:
VoidFunction
)
{
...
...
apps/remix-ide-e2e/src/tests/generalSettings.test.ts
View file @
63b07563
'use strict'
'use strict'
import
{
NightwatchBrowser
}
from
"nightwatch"
import
{
NightwatchBrowser
}
from
"nightwatch"
import
init
from
'../helpers/init'
const
init
=
require
(
'../helpers/init'
)
import
sauce
from
'./sauce'
const
sauce
=
require
(
'./sauce'
)
module
.
exports
=
{
module
.
exports
=
{
before
:
function
(
browser
:
NightwatchBrowser
,
done
:
VoidFunction
)
{
before
:
function
(
browser
:
NightwatchBrowser
,
done
:
VoidFunction
)
{
...
...
apps/remix-ide-e2e/src/tests/gist.test.ts
View file @
63b07563
'use strict'
'use strict'
import
{
NightwatchBrowser
}
from
"nightwatch"
import
{
NightwatchBrowser
}
from
"nightwatch"
import
init
from
'../helpers/init'
import
sauce
from
'./sauce'
const
init
=
require
(
'../helpers/init'
)
const
sauce
=
require
(
'./sauce'
)
const
testData
=
{
const
testData
=
{
validGistId
:
'1859c97c6e1efc91047d725d5225888e'
,
validGistId
:
'1859c97c6e1efc91047d725d5225888e'
,
invalidGistId
:
'6368b389f9302v32902msk2402'
invalidGistId
:
'6368b389f9302v32902msk2402'
...
...
apps/remix-ide-e2e/src/tests/libraryDeployment.test.ts
0 → 100644
View file @
63b07563
'use strict'
import
{
NightwatchBrowser
}
from
"nightwatch"
import
init
from
'../helpers/init'
import
sauce
from
'./sauce'
module
.
exports
=
{
before
:
function
(
browser
:
NightwatchBrowser
,
done
:
VoidFunction
)
{
init
(
browser
,
done
)
},
'@sources'
:
function
()
{
return
sources
},
'Add Lib Test File'
:
function
(
browser
:
NightwatchBrowser
)
{
browser
.
addFile
(
'Untitled5.sol'
,
sources
[
0
][
'browser/Untitled5.sol'
])
.
clickLaunchIcon
(
'udapp'
)
.
selectAccount
(
'0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c'
)
// this account will be used for this test suite
},
'Test Auto Deploy Lib'
:
function
(
browser
:
NightwatchBrowser
)
{
let
addressRef
:
string
browser
.
verifyContracts
([
'test'
])
.
selectContract
(
'test'
)
.
createContract
(
''
)
.
getAddressAtPosition
(
0
,
(
address
)
=>
{
console
.
log
(
'testAutoDeployLib '
+
address
)
addressRef
=
address
})
.
waitForElementPresent
(
'.instance:nth-of-type(2)'
)
.
click
(
'.instance:nth-of-type(2) > div > button'
)
.
perform
((
done
)
=>
{
browser
.
testConstantFunction
(
addressRef
,
'get - call'
,
null
,
'0:
\
nuint256: 45'
).
perform
(()
=>
{
done
()
})
})
},
'Test Manual Deploy Lib'
:
function
(
browser
:
NightwatchBrowser
)
{
console
.
log
(
'testManualDeployLib'
)
browser
.
click
(
'*[data-id="deployAndRunClearInstances"]'
)
.
pause
(
5000
)
.
clickLaunchIcon
(
'settings'
)
.
click
(
'#generatecontractmetadata'
)
.
clickLaunchIcon
(
'solidity'
)
.
click
(
'#compileTabView button[title="Compile"]'
)
// that should generate the JSON artefact
.
verifyContracts
([
'test'
])
.
selectContract
(
'lib'
)
// deploy lib
.
createContract
(
''
)
.
perform
((
done
)
=>
{
browser
.
getAddressAtPosition
(
0
,
(
address
)
=>
{
console
.
log
(
address
)
checkDeployShouldFail
(
browser
,
()
=>
{
checkDeployShouldSucceed
(
browser
,
address
,
()
=>
{
done
()
})
})
})
})
.
end
()
},
tearDown
:
sauce
}
function
checkDeployShouldFail
(
browser
:
NightwatchBrowser
,
callback
:
VoidFunction
)
{
let
config
browser
.
openFile
(
'browser/artifacts'
).
openFile
(
'browser/artifacts/test.json'
)
.
getEditorValue
((
content
)
=>
{
config
=
JSON
.
parse
(
content
)
config
.
deploy
[
'VM:-'
].
autoDeployLib
=
false
})
.
perform
(()
=>
{
browser
.
setEditorValue
(
JSON
.
stringify
(
config
))
})
.
openFile
(
'browser/Untitled5.sol'
)
.
selectContract
(
'test'
)
// deploy lib
.
createContract
(
''
)
.
assert
.
containsText
(
'div[class^="terminal"]'
,
'<address> is not a valid address'
)
.
perform
(()
=>
{
callback
()
})
}
function
checkDeployShouldSucceed
(
browser
:
NightwatchBrowser
,
address
:
string
,
callback
:
VoidFunction
)
{
let
addressRef
:
string
let
config
browser
.
openFile
(
'browser/artifacts'
).
openFile
(
'browser/artifacts/test.json'
)
.
getEditorValue
((
content
)
=>
{
config
=
JSON
.
parse
(
content
)
config
.
deploy
[
'VM:-'
].
autoDeployLib
=
false
config
.
deploy
[
'VM:-'
][
'linkReferences'
][
'browser/Untitled5.sol'
].
lib
=
address
})
.
perform
(()
=>
{
browser
.
setEditorValue
(
JSON
.
stringify
(
config
))
})
.
openFile
(
'browser/Untitled5.sol'
)
.
selectContract
(
'test'
)
// deploy lib
.
createContract
(
''
)
.
getAddressAtPosition
(
1
,
(
address
)
=>
{
addressRef
=
address
})
.
waitForElementPresent
(
'.instance:nth-of-type(3)'
)
.
click
(
'.instance:nth-of-type(3) > div > button'
)
.
perform
(()
=>
{
browser
.
testConstantFunction
(
addressRef
,
'get - call'
,
null
,
'0:
\
nuint256: 45'
)
.
perform
(()
=>
{
callback
()
})
})
}
const
sources
=
[
{
'browser/Untitled5.sol'
:
{
content
:
`library lib {
function getInt () public view returns (uint) {
return 45;
}
}
contract test {
function get () public view returns (uint) {
return lib.getInt();
}
}`
}
}
]
apps/remix-ide-e2e/src/types/index.d.ts
View file @
63b07563
...
@@ -31,8 +31,13 @@ declare module "nightwatch" {
...
@@ -31,8 +31,13 @@ declare module "nightwatch" {
renameFile
(
path
:
string
,
newFileName
:
string
,
renamedPath
:
string
):
NightwatchBrowser
,
renameFile
(
path
:
string
,
newFileName
:
string
,
renamedPath
:
string
):
NightwatchBrowser
,
rightClick
(
cssSelector
:
string
):
NightwatchBrowser
,
rightClick
(
cssSelector
:
string
):
NightwatchBrowser
,
waitForElementContainsText
(
id
:
string
,
value
:
string
):
NightwatchBrowser
,
waitForElementContainsText
(
id
:
string
,
value
:
string
):
NightwatchBrowser
,
getModalBody
(
callback
:
CallableFunction
):
NightwatchBrowser
,
getModalBody
(
callback
:
(
value
:
string
,
cb
:
VoidFunction
)
=>
void
):
NightwatchBrowser
,
modalFooterCancelClick
():
NightwatchBrowser
modalFooterCancelClick
():
NightwatchBrowser
,
selectContract
(
contractName
:
string
):
NightwatchBrowser
,
createContract
(
inputParams
:
string
):
NightwatchBrowser
,
getAddressAtPosition
(
index
:
number
,
cb
:
(
pos
:
string
)
=>
void
):
NightwatchBrowser
,
testConstantFunction
(
address
:
string
,
fnFullName
:
string
,
expectedInput
:
NightwatchTestConstantFunctionExpectedInput
|
null
,
expectedOutput
:
string
):
NightwatchBrowser
,
getEditorValue
(
callback
:
(
content
:
string
)
=>
void
):
NightwatchBrowser
}
}
export
interface
NightwatchBrowser
{
export
interface
NightwatchBrowser
{
...
@@ -62,5 +67,10 @@ declare module "nightwatch" {
...
@@ -62,5 +67,10 @@ declare module "nightwatch" {
[
key
:
string
]:
any
[
key
:
string
]:
any
}
}
export
interface
NightwatchTestConstantFunctionExpectedInput
{
types
:
string
,
values
:
string
}
export
type
NightwatchCheckVariableDebugValue
=
NightwatchTestFunctionExpectedInput
export
type
NightwatchCheckVariableDebugValue
=
NightwatchTestFunctionExpectedInput
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment