From 64cce1ec154801e95bf71ffcd6e49afc3c7dfdf8 Mon Sep 17 00:00:00 2001 From: lianahus Date: Tue, 29 Aug 2023 14:01:06 +0200 Subject: [PATCH 01/22] checkboxes styles for SUT --- .../src/lib/solidity-unit-testing.tsx | 87 ++++++----- .../terminal/src/lib/remix-ui-terminal.tsx | 141 +++++++++--------- 2 files changed, 119 insertions(+), 109 deletions(-) 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 6129df0a91..c90bcf4bd6 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 @@ -1,14 +1,14 @@ -import React, {useState, useRef, useEffect, ReactElement} from 'react' // eslint-disable-line -import {FormattedMessage, useIntl} from 'react-intl' +import React, { useState, useRef, useEffect, ReactElement } from 'react' // eslint-disable-line +import { FormattedMessage, useIntl } from 'react-intl' import * as semver from 'semver' -import {eachOfSeries} from 'async' // eslint-disable-line +import { eachOfSeries } from 'async' // eslint-disable-line import type Web3 from 'web3' -import {canUseWorker, urlFromVersion} from '@remix-project/remix-solidity' -import {Renderer} from '@remix-ui/renderer' // eslint-disable-line -import {Toaster} from '@remix-ui/toaster' // eslint-disable-line -import {format} from 'util' +import { canUseWorker, urlFromVersion } from '@remix-project/remix-solidity' +import { Renderer } from '@remix-ui/renderer' // eslint-disable-line +import { Toaster } from '@remix-ui/toaster' // eslint-disable-line +import { format } from 'util' import './css/style.css' -import {CustomTooltip} from '@remix-ui/helper' +import { CustomTooltip } from '@remix-ui/helper' const _paq = ((window as any)._paq = (window as any)._paq || []) // eslint-disable-line @typescript-eslint/no-explicit-any @@ -44,8 +44,8 @@ interface FinalResult { export const SolidityUnitTesting = (props: Record) => { // eslint-disable-line @typescript-eslint/no-explicit-any - const {helper, testTab, initialPath} = props - const {testTabLogic} = testTab + const { helper, testTab, initialPath } = props + const { testTabLogic } = testTab const intl = useIntl() @@ -55,8 +55,8 @@ export const SolidityUnitTesting = (props: Record) => { const [disableGenerateButton, setDisableGenerateButton] = useState(false) const [disableStopButton, setDisableStopButton] = useState(true) const [disableRunButton, setDisableRunButton] = useState(false) - const [runButtonTitle, setRunButtonTitle] = useState(intl.formatMessage({id: 'solidityUnitTesting.runButtonTitle1'})) - const [stopButtonLabel, setStopButtonLabel] = useState(intl.formatMessage({id: 'solidityUnitTesting.stopButtonLabel1'})) + const [runButtonTitle, setRunButtonTitle] = useState(intl.formatMessage({ id: 'solidityUnitTesting.runButtonTitle1' })) + const [stopButtonLabel, setStopButtonLabel] = useState(intl.formatMessage({ id: 'solidityUnitTesting.stopButtonLabel1' })) const [checkSelectAll, setCheckSelectAll] = useState(true) const [testsOutput, setTestsOutput] = useState([]) @@ -179,11 +179,11 @@ export const SolidityUnitTesting = (props: Record) => { await updateForNewCurrent(file) }) testTab.on('solidity', 'compilerLoaded', async (version: string, license: string) => { - const {currentVersion} = testTab.compileTab.getCurrentCompilerConfig() + const { currentVersion } = testTab.compileTab.getCurrentCompilerConfig() if (!semver.gt(truncateVersion(currentVersion), '0.4.12')) { setDisableRunButton(true) - setRunButtonTitle(intl.formatMessage({id: 'solidityUnitTesting.runButtonTitle2'})) + setRunButtonTitle(intl.formatMessage({ id: 'solidityUnitTesting.runButtonTitle2' })) } }) }, []) // eslint-disable-line @@ -272,7 +272,7 @@ export const SolidityUnitTesting = (props: Record) => { finalLogs = finalLogs + ' ' + formattedLog + '\n' } _paq.push(['trackEvent', 'solidityUnitTesting', 'hardhat', 'console.log']) - testTab.call('terminal', 'logHtml', {type: 'log', value: finalLogs}) + testTab.call('terminal', 'logHtml', { type: 'log', value: finalLogs }) } const discardHighlight = async () => { @@ -285,11 +285,11 @@ export const SolidityUnitTesting = (props: Record) => { const file = split[2] const parsedLocation = { start: parseInt(split[0]), - length: parseInt(split[1]) + length: parseInt(split[1]), } const locationToHighlight = testTab.offsetToLineColumnConverter.offsetToLineColumnWithContent(parsedLocation, parseInt(file), filesContent[fileName].content) await testTab.call('editor', 'discardHighlight') - await testTab.call('editor', 'highlight', locationToHighlight, fileName, '', {focus: true}) + await testTab.call('editor', 'highlight', locationToHighlight, fileName, '', { focus: true }) } } @@ -346,9 +346,9 @@ export const SolidityUnitTesting = (props: Record) => { if (!test.rendered) { let debugBtn if (test.debugTxHash) { - const {web3, debugTxHash} = test + const { web3, debugTxHash } = test debugBtn = ( -
startDebug(debugTxHash, web3)}> +
startDebug(debugTxHash, web3)}> @@ -465,17 +465,17 @@ export const SolidityUnitTesting = (props: Record) => { if (errors && errors.errors) { errors.errors.forEach((err: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any - const errorCard: ReactElement = + const errorCard: ReactElement = setTestsOutput((prevCards) => [...prevCards, errorCard]) }) } else if (errors && Array.isArray(errors) && (errors[0].message || errors[0].formattedMessage)) { errors.forEach((err) => { - const errorCard: ReactElement = + const errorCard: ReactElement = setTestsOutput((prevCards) => [...prevCards, errorCard]) }) } else if (errors && !errors.errors && !Array.isArray(errors)) { // To track error like this: https://github.com/ethereum/remix/pull/1438 - const errorCard: ReactElement = + const errorCard: ReactElement = setTestsOutput((prevCards) => [...prevCards, errorCard]) } } @@ -549,7 +549,7 @@ export const SolidityUnitTesting = (props: Record) => { passed: result.totalPassing, failed: result.totalFailing, timeTaken: totalTime, - rendered: false + rendered: false, } testsResultByFilename[filename]['summary'] = testsSummary showTestsResult() @@ -569,7 +569,7 @@ export const SolidityUnitTesting = (props: Record) => { if (_errors || hasBeenStopped.current || readyTestsNumber === runningTestsNumber) { // All tests are ready or the operation has been canceled or there was a compilation error in one of the test files. setDisableStopButton(true) - setStopButtonLabel(intl.formatMessage({id: 'solidityUnitTesting.stopButtonLabel1'})) + setStopButtonLabel(intl.formatMessage({ id: 'solidityUnitTesting.stopButtonLabel1' })) if (selectedTests.current?.length !== 0) { setDisableRunButton(false) } @@ -588,16 +588,16 @@ export const SolidityUnitTesting = (props: Record) => { .readFile(testFilePath) .then(async (content: string) => { const runningTests: Record> = {} - runningTests[testFilePath] = {content} - filesContent[testFilePath] = {content} - const {currentVersion, evmVersion, optimize, runs, isUrl} = testTab.compileTab.getCurrentCompilerConfig() + runningTests[testFilePath] = { content } + filesContent[testFilePath] = { content } + const { currentVersion, evmVersion, optimize, runs, isUrl } = testTab.compileTab.getCurrentCompilerConfig() const currentCompilerUrl = isUrl ? currentVersion : urlFromVersion(currentVersion) const compilerConfig = { currentCompilerUrl, evmVersion, optimize, usingWorker: canUseWorker(currentVersion), - runs + runs, } const deployCb = async (file: string, contractAddress: string) => { const compilerData = await testTab.call('compilerArtefacts', 'getCompilerAbstract', file) @@ -624,7 +624,7 @@ export const SolidityUnitTesting = (props: Record) => { .then((result: any) => cb(null, result)) .catch((error: Error) => cb(error.message)) // eslint-disable-line @typescript-eslint/no-explicit-any }, - {testFilePath: testFilePath} + { testFilePath: testFilePath } ) }) .catch((error: Error) => { @@ -660,16 +660,16 @@ export const SolidityUnitTesting = (props: Record) => { if (!isSolidityActive || !selectedTests.current.length) { setDisableRunButton(true) if (!currentFile || (currentFile && currentFile.split('.').pop().toLowerCase() !== 'sol')) { - setRunButtonTitle(intl.formatMessage({id: 'solidityUnitTesting.runButtonTitle3'})) + setRunButtonTitle(intl.formatMessage({ id: 'solidityUnitTesting.runButtonTitle3' })) } else { - setRunButtonTitle(intl.formatMessage({id: 'solidityUnitTesting.runButtonTitle4'})) + setRunButtonTitle(intl.formatMessage({ id: 'solidityUnitTesting.runButtonTitle4' })) } } else setDisableRunButton(false) } const stopTests = () => { hasBeenStopped.current = true - setStopButtonLabel(intl.formatMessage({id: 'solidityUnitTesting.stopButtonLabel2'})) + setStopButtonLabel(intl.formatMessage({ id: 'solidityUnitTesting.stopButtonLabel2' })) setDisableStopButton(true) setDisableRunButton(true) } @@ -687,12 +687,12 @@ export const SolidityUnitTesting = (props: Record) => { setCheckSelectAll(true) setDisableRunButton(false) if ((readyTestsNumber === runningTestsNumber || hasBeenStopped.current) && stopButtonLabel.trim() === 'Stop') { - setRunButtonTitle(intl.formatMessage({id: 'solidityUnitTesting.runButtonTitle1'})) + setRunButtonTitle(intl.formatMessage({ id: 'solidityUnitTesting.runButtonTitle1' })) } } else if (!selectedTests.current.length) { setCheckSelectAll(false) setDisableRunButton(true) - setRunButtonTitle(intl.formatMessage({id: 'solidityUnitTesting.runButtonTitle5'})) + setRunButtonTitle(intl.formatMessage({ id: 'solidityUnitTesting.runButtonTitle5' })) } else setCheckSelectAll(false) } @@ -713,7 +713,7 @@ export const SolidityUnitTesting = (props: Record) => { const updateTestFileList = () => { if (allTests.current?.length) { testFiles = allTests.current.map((testFile: string) => { - return {fileName: testFile, checked: true} + return { fileName: testFile, checked: true } }) setCheckSelectAll(true) } else testFiles = [] @@ -755,7 +755,7 @@ export const SolidityUnitTesting = (props: Record) => { data-id="uiPathInput" name="utPath" value={inputPathValue} - style={{backgroundImage: 'var(--primary)'}} + style={{ backgroundImage: 'var(--primary)' }} onKeyDown={() => { if (inputPathValue === '/') setInputPathValue('') }} @@ -841,13 +841,14 @@ export const SolidityUnitTesting = (props: Record) => {
{}} // eslint-disable-line /> -