From f89c2047619fad26f5e087863e8a4860a8019f4c Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 18 Nov 2021 12:36:44 +0530 Subject: [PATCH] listing test files --- apps/remix-ide/src/app/tabs/test-tab.js | 9 --- .../src/lib/logic/testTabLogic.ts | 1 - .../src/lib/solidity-unit-testing.tsx | 81 +++++++++---------- 3 files changed, 40 insertions(+), 51 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 42529f94b9..8b4aa8672f 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -61,7 +61,6 @@ module.exports = class TestTab extends ViewPlugin { } onActivationInternal () { - console.log('onActivationInternal---start->') this.testTabLogic = new TestTabLogic(this.fileManager) this.listenToEvents() this.call('filePanel', 'registerContextMenuItem', { @@ -73,7 +72,6 @@ module.exports = class TestTab extends ViewPlugin { path: [], pattern: [] }) - console.log('onActivationInternal---end->') } async setTestFolderPath (event) { @@ -95,7 +93,6 @@ module.exports = class TestTab extends ViewPlugin { } async onActivation () { - console.log('onActivation--->') const isSolidityActive = await this.call('manager', 'isActive', 'solidity') if (!isSolidityActive) { await this.call('manager', 'activatePlugin', 'solidity') @@ -106,7 +103,6 @@ module.exports = class TestTab extends ViewPlugin { } onDeactivation () { - console.log('onDeactivation--->') this.off('filePanel', 'newTestFileCreated') this.off('filePanel', 'setWorkspace') // 'currentFileChanged' event is added more than once @@ -114,7 +110,6 @@ module.exports = class TestTab extends ViewPlugin { } listenToEvents () { - console.log('listenToEvents--start-->') this.on('filePanel', 'newTestFileCreated', async file => { try { await this.testTabLogic.getTests((error, tests) => { @@ -152,7 +147,6 @@ module.exports = class TestTab extends ViewPlugin { }) this.fileManager.events.on('currentFileChanged', (file, provider) => this.updateForNewCurrent(file)) - console.log('listenToEvents--end-->') } async updateForNewCurrent (file) { @@ -709,18 +703,15 @@ module.exports = class TestTab extends ViewPlugin { } render () { - console.log('render--->') this.onActivationInternal() this.renderComponent() return this.element } renderComponent () { - console.log('renderComponent-start-->') ReactDOM.render( , this.element) - console.log('renderComponent-end-->') } render2 () { diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts b/libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts index 49d5b62f2e..91f24b2872 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts +++ b/libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts @@ -39,7 +39,6 @@ export class TestTabLogic { generateTestFile () { console.log('Inside generateTestFile-1SUT-') - console.log('Inside generateTestFile---fileManager-SUT-->', this.fileManager) let fileName = this.fileManager.currentFile() const hasCurrent = !!fileName && this.fileManager.currentFile().split('.').pop().toLowerCase() === 'sol' if (!hasCurrent) fileName = this.currentPath + '/newFile.sol' diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx index e638ebf804..b6da011134 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx +++ b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx @@ -21,7 +21,7 @@ export const SolidityUnitTesting = (props: any) => { const [testsExecutionStoppedErrorHidden, setTestsExecutionStoppedErrorHidden] = useState(true) const [testsMessage, setTestsMessage] = useState('No test file available') const [pathOptions, setPathOptions] = useState(['']) - const [allTests, setAllTests] = useState([]) + let [allTests, setAllTests] = useState([]) const [selectedTests, setSelectedTests] = useState([]) const [inputPathValue, setInputPathValue] = useState('tests') @@ -48,9 +48,10 @@ export const SolidityUnitTesting = (props: any) => { // this.clearResults() // if (!this.areTestsRunning) this.updateRunAction(file) try { - await testTabLogic.getTests((error: any, tests: any) => { + testTabLogic.getTests((error: any, tests: any) => { // if (error) return tooltip(error) - setAllTests(tests) + console.log('tests in updateForNewCurrent testTabLogic.getTests', tests) + allTests = tests setSelectedTests(tests) updateTestFileList(tests) // if (!this.testsOutput) return // eslint-disable-line @@ -84,7 +85,6 @@ export const SolidityUnitTesting = (props: any) => { return } } - if (testDirInput) { if (testDirInput.endsWith('/') && testDirInput !== '/') { testDirInput = helper.removeTrailingSlashes(testDirInput) @@ -98,6 +98,8 @@ export const SolidityUnitTesting = (props: any) => { if (await testTabLogic.pathExists(testDirInput)) { setDisableCreateButton(true) setDisableGenerateButton(false) + testTabLogic.setCurrentPath(testDirInput) + updateForNewCurrent() } else { // Enable Create button setDisableCreateButton(false) @@ -118,7 +120,7 @@ export const SolidityUnitTesting = (props: any) => { if (disableCreateButton) { if (await testTabLogic.pathExists(inputPath)) { testTabLogic.setCurrentPath(inputPath) - // this.updateForNewCurrent() + updateForNewCurrent() } } } @@ -136,39 +138,11 @@ export const SolidityUnitTesting = (props: any) => { console.log('path-->', path) console.log('inputPath-->', inputPath) // this.updateRunAction() - // this.updateForNewCurrent() + updateForNewCurrent() pathOptions.push(inputPath) setPathOptions(pathOptions) } - // const updateGenerateFileAction = () => { - // console.log('updateGenerateFileAction') - // return ( - // ) - // const el = yo` - // - // ` - // if (!this.generateFileActionElement) { - // this.generateFileActionElement = el - // } else { - // yo.update(this.generateFileActionElement, el) - // } - // return this.generateFileActionElement - // } - const updateRunAction = (currentFile = null) => { console.log('updateRunAction --currentFile-->', currentFile) @@ -214,6 +188,31 @@ export const SolidityUnitTesting = (props: any) => { // runBtn.setAttribute('disabled', 'disabled') } + const toggleCheckbox = (eChecked: any, test:any) => { + console.log('toggleCheckbox--->', test) + // if (!this.data.selectedTests) { + // this.data.selectedTests = this._view.el.querySelectorAll('.singleTest:checked') + // } + // let selectedTests = this.data.selectedTests + // selectedTests = eChecked ? [...selectedTests, test] : selectedTests.filter(el => el !== test) + // this.data.selectedTests = selectedTests + // const checkAll = this._view.el.querySelector('[id="checkAllTests"]') + // const runBtn = document.getElementById('runTestsTabRunAction') + + // if (eChecked) { + // checkAll.checked = true + // const stopBtnInnerText = document.getElementById('runTestsTabStopAction').innerText + // if ((this.readyTestsNumber === this.runningTestsNumber || this.hasBeenStopped) && stopBtnInnerText.trim() === 'Stop') { + // runBtn.removeAttribute('disabled') + // runBtn.setAttribute('title', 'Run tests') + // } + // } else if (!selectedTests.length) { + // checkAll.checked = false + // runBtn.setAttribute('disabled', 'disabled') + // runBtn.setAttribute('title', 'No test file selected') + // } + } + const checkAll = (event: any) => { console.log('checkAll --event-->', event) @@ -226,13 +225,13 @@ export const SolidityUnitTesting = (props: any) => { // } } - const createSingleTest = (testFile) => { - return yo` -
- this.toggleCheckbox(e.target.checked, testFile)} type="checkbox" checked="true"> - + const createSingleTest = (testFile: string) => { + return ( +
+ toggleCheckbox(e.target.checked, testFile)} type="checkbox"/> +
- ` + ) } const listTests = () => { @@ -244,6 +243,7 @@ export const SolidityUnitTesting = (props: any) => { } const updateTestFileList = (tests = []) => { + console.log('updateTestFileList--tests->', tests) const testsMsg: any = (tests && tests.length) ? listTests() : 'No test file available' setTestsMessage(testsMsg) } @@ -257,7 +257,6 @@ export const SolidityUnitTesting = (props: any) => { const [resultStatistics] = useState(createResultLabel()) - console.log('props---->', props) return (