Filter tests

pull/3094/head
ninabreznik 7 years ago committed by yann300
parent f261218b64
commit ca8d0a5cf9
  1. 6
      src/app/panels/file-panel.js
  2. 7
      src/app/tabs/styles/test-tab-styles.js
  3. 43
      src/app/tabs/test-tab.js
  4. 11
      src/app/ui/styles-guide/style-guide.js

@ -249,7 +249,11 @@ function filepanel (localRegistry) {
if (!self._deps.fileProviders['browser'].set(newName, '')) {
modalDialogCustom.alert('Failed to create file ' + newName)
} else {
self._deps.fileManager.switchFile(self._deps.fileProviders['browser'].type + '/' + newName)
var file = self._deps.fileProviders['browser'].type + '/' + newName
self._deps.fileManager.switchFile(file)
if (file.includes('_test.sol')) {
self.event.trigger('newTestFileCreated', [file])
}
}
})
}, null, true)

@ -51,6 +51,13 @@ a {
height: 70%;
margin-right: 2%;
}
.testList {
${styles.rightPanel.testTab.box_listTests}
line-height: 2em;
display: flex;
flex-direction: column;
margin: 2%;
}
`
module.exports = css

@ -16,7 +16,6 @@ module.exports = class TestTab {
app: self._components.registry.get('app').api
}
self.data = {}
self._view.el = self.render()
self._deps.app.event.register('tabChanged', tabName => {
if (tabName !== 'test') return
@ -29,13 +28,15 @@ module.exports = class TestTab {
render () {
var self = this
var container = yo`<div class="tests" id="tests"></div>`
self.data.allTests = getTests()
self.data.selectedTests = self.data.allTests
console.log(self.data.selectedTests)
function append (container, txt) {
let child = yo`<div>${txt}</div>`
var child = yo`<div>${txt}</div>`
container.appendChild(child)
}
let testCallback = function (result) {
var testCallback = function (result) {
if (result.type === 'contract') {
append(container, '\n ' + result.value)
} else if (result.type === 'testPass') {
@ -45,7 +46,7 @@ module.exports = class TestTab {
}
}
let resultsCallback = function (_err, result, cb) {
var resultsCallback = function (_err, result, cb) {
// total stats for the test
// result.passingNum
// result.failureNum
@ -53,7 +54,7 @@ module.exports = class TestTab {
cb()
}
let updateFinalResult = function (_err, result) {
var updateFinalResult = function (_err, result) {
if (result.totalPassing > 0) {
append(container, (' ' + result.totalPassing + ' passing ') + ('(' + result.totalTime + 's)'))
}
@ -81,8 +82,7 @@ module.exports = class TestTab {
})
}
let runTests = function () {
container.innerHTML = ''
function getTests () {
var path = this._deps.fileManager.currentPath()
var provider = this._deps.fileManager.fileProviderOf(path)
var tests = []
@ -91,9 +91,31 @@ module.exports = class TestTab {
for (var file in files) {
if (/.(_test.sol)$/.exec(file)) tests.push(provider.type + '/' + file)
}
async.eachOfSeries(tests, (value, key, callback) => { runTest(value, provider, callback) })
}
})
return tests
}
self._events.app.register('newTestFileCreated', file => {
self.data.allTests.push(file)
self.data.selectedTests.push(file)
})
function listTests () {
var tests = self.data.allTests
return tests.map(test => yo`<label><input onchange =${(e) => toggleCheckbox(e, test)} type="checkbox" checked="true">${test} </label>`)
}
function toggleCheckbox (e, test) {
var selectedTests = self.data.selectedTests
selectedTests = e.target.checked ? [...selectedTests, test] : selectedTests.filter(el => el !== test)
self.data.selectedTests = selectedTests
}
var runTests = function () {
container.innerHTML = ''
var tests = self.data.selectedTests
async.eachOfSeries(tests, (value, key, callback) => { runTest(value, callback) })
}
var el = yo`
@ -103,6 +125,9 @@ module.exports = class TestTab {
</div>
</div>
<div class="${css.testList}">
<div class=${css.testList}>
${listTests()}
</div>
<p><button onclick=${runTests}>Run Tests</button></p>
${container}
</div>

@ -654,6 +654,17 @@ function styleGuide () {
},
/* ::::::::::::::
TEST TAB
::::::::::::::: */
testTab: {
box_listTests: appProperties.uiElements.solidBorderBox({
BackgroundColor: appProperties.solidBorderBox_BackgroundColor,
BorderColor: appProperties.solidBorderBox_BackgroundColor,
Color: appProperties.solidBorderBox_TextColor
})
},
/* ::::::::::::::
SETTINGS TAB
::::::::::::::: */

Loading…
Cancel
Save