From 8e8d840848c863d2b4352ce365c6aaed9ec838a1 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Fri, 14 Jan 2022 13:55:17 +0530 Subject: [PATCH 1/2] root test file creation --- .../solidity-unit-testing/src/lib/solidity-unit-testing.tsx | 1 + 1 file changed, 1 insertion(+) 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 6cb5bc3820..a69883d9dd 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 @@ -672,6 +672,7 @@ export const SolidityUnitTesting = (props: Record) => { // eslint-d value={inputPathValue} title="Press 'Enter' to change the path for test files." style={{ backgroundImage: "var(--primary)" }} + onKeyDown={() => { if (inputPathValue === '/') setInputPathValue('')} } onKeyUp={handleTestDirInput} onChange={handleEnter} onClick = {() => { if (inputPathValue === '/') setInputPathValue('')} } From d8655f3710781b8cc54ba1b5f52a8303d648e8c7 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Fri, 14 Jan 2022 14:25:03 +0530 Subject: [PATCH 2/2] show toaster on test folder creation --- .../solidity-unit-testing/src/lib/logic/testTabLogic.ts | 9 +++------ .../src/lib/solidity-unit-testing.tsx | 3 ++- 2 files changed, 5 insertions(+), 7 deletions(-) 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 6e1af409a4..87a6f33d80 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 @@ -21,23 +21,20 @@ export class TestTabLogic { this.currentPath = this.helper.removeMultipleSlashes(this.helper.removeTrailingSlashes(path)) } - generateTestFolder (path:string) { + async generateTestFolder (path:string) { // Todo move this check to File Manager after refactoring // Checking to ignore the value which contains only whitespaces if (!path || !(/\S/.test(path))) return path = this.helper.removeMultipleSlashes(path) const fileProvider = this.fileManager.fileProviderOf(path.split('/')[0]) - fileProvider.exists(path).then((res: boolean) => { - if (!res) fileProvider.createDir(path) - }) + if(!await fileProvider.exists(path)) fileProvider.createDir(path) } async pathExists (path: string) { // Checking to ignore the value which contains only whitespaces if (!path || !(/\S/.test(path))) return const fileProvider = this.fileManager.fileProviderOf(path.split('/')[0]) - const res = await fileProvider.exists(path, (e: Error, res: boolean) => { return res }) - return res + return await fileProvider.exists(path) } // eslint-disable-next-line @typescript-eslint/no-explicit-any 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 a69883d9dd..2acb1ee4e4 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 @@ -222,7 +222,8 @@ export const SolidityUnitTesting = (props: Record) => { // eslint-d if (path !== '/') path = helper.removeTrailingSlashes(path) if (inputPath === '') inputPath = defaultPath setInputPathValue(path) - testTabLogic.generateTestFolder(inputPath) + await testTabLogic.generateTestFolder(inputPath) + setToasterMsg('Folder created successfully') setDisableCreateButton(true) setDisableGenerateButton(false) testTabLogic.setCurrentPath(inputPath)