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
f541d0cf
Unverified
Commit
f541d0cf
authored
May 04, 2021
by
David Zagi
Committed by
GitHub
May 04, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into refactoring-static-analyser
parents
12d3c188
92536a10
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
127 additions
and
31 deletions
+127
-31
solidityUnittests.spec.ts
apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts
+25
-0
test-tab.js
apps/remix-ide/src/app/tabs/test-tab.js
+95
-31
testTab.js
apps/remix-ide/src/app/tabs/testTab/testTab.js
+7
-0
No files found.
apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts
View file @
f541d0cf
...
...
@@ -144,6 +144,29 @@ module.exports = {
.
click
(
'*[data-id="testTabGenerateTestFolder"]'
)
},
'Changing current path when workspace changed'
:
function
(
browser
:
NightwatchBrowser
)
{
browser
.
waitForElementPresent
(
'*[data-id="verticalIconsKindfilePanel"]'
)
.
clickLaunchIcon
(
'settings'
)
.
clickLaunchIcon
(
'solidityUnitTesting'
)
.
waitForElementPresent
(
'*[data-id="uiPathInput"]'
,
3000
)
.
clearValue
(
'*[data-id="uiPathInput"]'
)
.
setValue
(
'*[data-id="uiPathInput"]'
,
'tests1'
)
.
click
(
'*[data-id="testTabGenerateTestFolder"]'
)
.
clickLaunchIcon
(
'filePanel'
)
// creating a new workspace
.
click
(
'*[data-id="workspaceCreate"]'
)
.
waitForElementVisible
(
'*[data-id="modalDialogCustomPromptTextCreate"]'
)
// eslint-disable-next-line dot-notation
.
execute
(
function
()
{
document
.
querySelector
(
'*[data-id="modalDialogCustomPromptTextCreate"]'
)[
'value'
]
=
'workspace_new'
})
.
click
(
'*[data-id="workspacesModalDialogModalDialogModalFooter-react"] .modal-ok'
)
.
click
(
'*[data-id="workspacesSelect"] option[value="workspace_new"]'
)
// end of creating
.
clickLaunchIcon
(
'solidityUnitTesting'
)
.
pause
(
2000
)
.
verify
.
attributeEquals
(
'*[data-id="uiPathInput"]'
,
'value'
,
'tests'
)
},
'Solidity Unittests'
:
function
(
browser
:
NightwatchBrowser
)
{
runTests
(
browser
)
}
...
...
@@ -157,6 +180,8 @@ function runTests (browser: NightwatchBrowser) {
.
openFile
(
'contracts/3_Ballot.sol'
)
.
clickLaunchIcon
(
'solidityUnitTesting'
)
.
pause
(
500
)
.
setValue
(
'*[data-id="uiPathInput"]'
,
'tests'
)
.
pause
(
2000
)
.
scrollAndClick
(
'#runTestsTabRunAction'
)
.
waitForElementVisible
(
'*[data-id="testTabSolidityUnitTestsOutputheader"]'
,
120000
)
.
waitForElementPresent
(
'#solidityUnittestsOutput div[class^="testPass"]'
,
60000
)
...
...
apps/remix-ide/src/app/tabs/test-tab.js
View file @
f541d0cf
...
...
@@ -60,6 +60,12 @@ module.exports = class TestTab extends ViewPlugin {
this
.
data
.
selectedTests
.
push
(
file
)
})
this
.
on
(
'filePanel'
,
'setWorkspace'
,
()
=>
{
this
.
testTabLogic
.
setCurrentPath
(
this
.
defaultPath
)
this
.
inputPath
.
value
=
this
.
defaultPath
this
.
updateForNewCurrent
()
})
this
.
fileManager
.
events
.
on
(
'noFileSelected'
,
()
=>
{
})
...
...
@@ -67,8 +73,9 @@ module.exports = class TestTab extends ViewPlugin {
}
updateForNewCurrent
(
file
)
{
this
.
updateGenerateFileAction
(
file
)
this
.
updateGenerateFileAction
()
if
(
!
this
.
areTestsRunning
)
this
.
updateRunAction
(
file
)
this
.
updateTestFileList
()
this
.
testTabLogic
.
getTests
((
error
,
tests
)
=>
{
if
(
error
)
return
tooltip
(
error
)
this
.
data
.
allTests
=
tests
...
...
@@ -415,11 +422,16 @@ module.exports = class TestTab extends ViewPlugin {
})
}
updateCurrentPath
(
e
)
{
const
newValue
=
e
.
target
.
value
===
''
?
this
.
defaultPath
:
e
.
target
.
value
this
.
testTabLogic
.
setCurrentPath
(
newValue
)
handleCreateFolder
()
{
this
.
inputPath
.
value
=
this
.
trimTestDirInput
(
this
.
inputPath
.
value
)
if
(
this
.
inputPath
.
value
===
''
)
this
.
inputPath
.
value
=
this
.
defaultPath
this
.
testTabLogic
.
generateTestFolder
(
this
.
inputPath
.
value
)
this
.
createTestFolder
.
disabled
=
true
this
.
updateGenerateFileAction
().
disabled
=
false
this
.
testTabLogic
.
setCurrentPath
(
this
.
inputPath
.
value
)
this
.
updateRunAction
()
this
.
updateForNewCurrent
()
this
.
uiPathList
.
appendChild
(
yo
`<option>
${
this
.
inputPath
.
value
}
</option>`
)
}
runTests
()
{
...
...
@@ -456,7 +468,7 @@ module.exports = class TestTab extends ViewPlugin {
runBtn
.
setAttribute
(
'disabled'
,
'disabled'
)
}
updateGenerateFileAction
(
currentFile
)
{
updateGenerateFileAction
()
{
const
el
=
yo
`
<button
class="btn border w-50"
...
...
@@ -537,7 +549,7 @@ module.exports = class TestTab extends ViewPlugin {
infoButton () {
return yo`
<a class="
btn
border
text
-
decoration
-
none
pr
-
0
d
-
flex
w
-
50
ml
-
2
" title="
Check
out
documentation
.
" target="
__blank
" href="
https
:
//remix-ide.readthedocs.io/en/latest/unittesting.html#
generate-test-file
">
<a class="
btn
border
text
-
decoration
-
none
pr
-
0
d
-
flex
w
-
50
ml
-
2
" title="
Check
out
documentation
.
" target="
__blank
" href="
https
:
//remix-ide.readthedocs.io/en/latest/unittesting.html#
test-directory
">
<
label
class
=
"btn p-1 ml-2 m-0"
>
How
to
use
...
<
/label
>
<
/a
>
`
...
...
@@ -549,19 +561,58 @@ module.exports = class TestTab extends ViewPlugin {
return
yo
`<span class='text-info h6'>Progress:
${
ready
}
finished (of
${
this
.
runningTestsNumber
}
)</span>`
}
updateDirList () {
for (
var
o of this.uiPathList.querySelectorAll('option')) o.remove()
this.testTabLogic.dirList(
'/'
).then((options) => {
updateDirList (
path
) {
for (
const
o of this.uiPathList.querySelectorAll('option')) o.remove()
this.testTabLogic.dirList(
path
).then((options) => {
options.forEach((path) => this.uiPathList.appendChild(yo`
<
option
>
$
{
path
}
<
/option>`
)
)
})
/*
It is not possible anymore to see folder from outside of the current workspace
if (this.inputPath.value) {
this.testTabLogic.dirList(this.inputPath.value).then((options) => {
options.forEach((path) => this.uiPathList.appendChild(yo`<option>${path}</option>`))
})
}
trimTestDirInput
(
input
)
{
if
(
input
.
includes
(
'/'
))
return
input
.
split
(
'/'
).
map
(
e
=>
e
.
trim
()).
join
(
'/'
)
else
return
input
.
trim
()
}
pathAdded
(
text
)
{
for
(
const
option
of
this
.
uiPathList
.
querySelectorAll
(
'option'
))
{
if
(
option
.
innerHTML
===
text
)
return
true
}
return
false
}
async
handleTestDirInput
(
e
)
{
const
testDirInput
=
this
.
trimTestDirInput
(
this
.
inputPath
.
value
)
if
(
e
.
key
===
'Enter'
)
{
this
.
inputPath
.
value
=
this
.
trimTestDirInput
(
testDirInput
)
if
(
await
this
.
testTabLogic
.
pathExists
(
testDirInput
))
{
this
.
testTabLogic
.
setCurrentPath
(
testDirInput
)
this
.
updateForNewCurrent
()
return
}
}
if
(
testDirInput
)
{
if
(
testDirInput
.
endsWith
(
'/'
))
{
if
(
this
.
testTabLogic
.
currentPath
===
testDirInput
.
substr
(
0
,
testDirInput
.
length
-
1
))
{
this
.
createTestFolder
.
disabled
=
true
this
.
updateGenerateFileAction
().
disabled
=
true
}
this
.
updateDirList
(
testDirInput
)
}
else
{
// If there is no matching folder in the workspace with entered text, enable Create button
if
(
this
.
testTabLogic
.
pathExists
(
testDirInput
))
{
this
.
createTestFolder
.
disabled
=
true
this
.
updateGenerateFileAction
().
disabled
=
false
}
else
{
// Enable Create button
this
.
createTestFolder
.
disabled
=
false
// Disable Generate button because dir is not existing
this
.
updateGenerateFileAction
().
disabled
=
true
}
}
*/
}
else
{
this
.
updateDirList
(
'/'
)
}
}
render
()
{
...
...
@@ -578,27 +629,40 @@ module.exports = class TestTab extends ViewPlugin {
data-id="uiPathInput"
name="utPath"
style="background-image: var(--primary);"
onkeydown=
${(
e
)
=>
{
if
(
e
.
keyCode
===
191
)
this
.
updateDirList
()
}}
onchange
=
$
{(
e
)
=>
this
.
updateCurrentPath
(
e
)}
/>`
onkeyup=
${(
e
)
=>
this
.
handleTestDirInput
(
e
)}
onchange=
${(
e
)
=>
{
if
(
this
.
createTestFolder
.
disabled
)
{
this
.
inputPath
.
value
=
this
.
trimTestDirInput
(
this
.
inputPath
.
value
)
if
(
this
.
testTabLogic
.
pathExists
(
this
.
inputPath
.
value
))
{
this
.
inputPath
.
value
=
this
.
trimTestDirInput
(
this
.
inputPath
.
value
)
this
.
testTabLogic
.
setCurrentPath
(
this
.
inputPath
.
value
)
this
.
updateForNewCurrent
()
}
}
}}
/>
`
const
createTestFolder
=
yo
`<button
class="btn border ml-2"
data-id="testTabGenerateTestFolder"
title="Create a test folder"
onclick=
${(
e
)
=>
{
this
.
testTabLogic
.
generateTestFolder
(
this
.
inputPath
.
value
)
}}
>
Create
<
/button>
`
this
.
createTestFolder
=
yo
`
<button
class="btn border ml-2"
data-id="testTabGenerateTestFolder"
title="Create a test folder"
disabled=true
onclick=
${(
e
)
=>
this
.
handleCreateFolder
()}
>
Create
</button>
`
const
availablePaths
=
yo
`
<div>
<div class="d-flex p-2">
${
this
.
inputPath
}
${
createTestFolder
}
${
this
.
uiPathList
}
</div>
<div class="d-flex p-2">
${
this
.
inputPath
}
${
this
.
createTestFolder
}
${
this
.
uiPathList
}
</div>
</div>
`
this
.
updateDirList
()
this
.
updateDirList
(
'/'
)
this
.
testsExecutionStopped
.
hidden
=
true
this
.
testsExecutionStoppedError
.
hidden
=
true
this
.
resultStatistics
=
this
.
createResultLabel
()
...
...
apps/remix-ide/src/app/tabs/testTab/testTab.js
View file @
f541d0cf
...
...
@@ -21,6 +21,13 @@ class TestTabLogic {
fileProvider
.
exists
(
path
,
(
e
,
res
)
=>
{
if
(
!
res
)
fileProvider
.
createDir
(
path
)
})
}
pathExists
(
path
)
{
// Checking to ignore the value which contains only whitespaces
if
(
!
path
||
!
(
/
\S
/
.
test
(
path
)))
return
const
fileProvider
=
this
.
fileManager
.
fileProviderOf
(
path
.
split
(
'/'
)[
0
])
return
fileProvider
.
exists
(
path
,
(
e
,
res
)
=>
{
return
res
})
}
generateTestFile
()
{
let
fileName
=
this
.
fileManager
.
currentFile
()
const
hasCurrent
=
!!
fileName
&&
this
.
fileManager
.
currentFile
().
split
(
'.'
).
pop
().
toLowerCase
()
===
'sol'
...
...
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