From ca8d0a5cf90b993a6712fc026fc7798f461055d7 Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Fri, 15 Jun 2018 15:43:32 +0100 Subject: [PATCH] Filter tests --- src/app/panels/file-panel.js | 6 +++- src/app/tabs/styles/test-tab-styles.js | 7 +++++ src/app/tabs/test-tab.js | 43 ++++++++++++++++++++------ src/app/ui/styles-guide/style-guide.js | 11 +++++++ 4 files changed, 57 insertions(+), 10 deletions(-) diff --git a/src/app/panels/file-panel.js b/src/app/panels/file-panel.js index b327bb25c8..b30bfb86eb 100644 --- a/src/app/panels/file-panel.js +++ b/src/app/panels/file-panel.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) diff --git a/src/app/tabs/styles/test-tab-styles.js b/src/app/tabs/styles/test-tab-styles.js index 882ef5f7eb..c7d7c11192 100644 --- a/src/app/tabs/styles/test-tab-styles.js +++ b/src/app/tabs/styles/test-tab-styles.js @@ -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 diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index 1d49eb08a3..c33bc6f531 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -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`
` - + self.data.allTests = getTests() + self.data.selectedTests = self.data.allTests + console.log(self.data.selectedTests) function append (container, txt) { - let child = yo`
${txt}
` + var child = yo`
${txt}
` 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``) + } + + 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 {
+
+ ${listTests()} +

${container}
diff --git a/src/app/ui/styles-guide/style-guide.js b/src/app/ui/styles-guide/style-guide.js index 9398008644..b2a37fceb8 100644 --- a/src/app/ui/styles-guide/style-guide.js +++ b/src/app/ui/styles-guide/style-guide.js @@ -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 ::::::::::::::: */