From 8a36939f8c9dc682d07c976e113662f084249386 Mon Sep 17 00:00:00 2001 From: David Disu Date: Thu, 6 Jan 2022 10:30:27 +0100 Subject: [PATCH] Fixed specialFunction e2e --- .../src/commands/sendLowLevelTx.ts | 5 +++-- .../src/tests/specialFunctions.test.ts | 1 + .../src/lib/components/contractDropdownUI.tsx | 19 +++++++++++-------- .../run-tab/src/lib/components/value.tsx | 19 +++++++++---------- .../run-tab/src/lib/reducers/runTab.ts | 7 +++++-- libs/remix-ui/run-tab/src/lib/types/index.ts | 1 + 6 files changed, 30 insertions(+), 22 deletions(-) diff --git a/apps/remix-ide-e2e/src/commands/sendLowLevelTx.ts b/apps/remix-ide-e2e/src/commands/sendLowLevelTx.ts index a910a391c8..94f4a249d3 100644 --- a/apps/remix-ide-e2e/src/commands/sendLowLevelTx.ts +++ b/apps/remix-ide-e2e/src/commands/sendLowLevelTx.ts @@ -6,10 +6,11 @@ class sendLowLevelTx extends EventEmitter { console.log('low level transact to ', address, value, callData) this.api.waitForElementVisible(`#instance${address} #deployAndRunLLTxSendTransaction`, 1000) .clearValue(`#instance${address} #deployAndRunLLTxCalldata`) - .setValue(`#instance${address} #deployAndRunLLTxCalldata`, callData) + .sendKeys(`#instance${address} #deployAndRunLLTxCalldata`, ['_', this.api.Keys.BACK_SPACE, callData]) .waitForElementVisible('#value') .clearValue('#value') - .setValue('#value', value) + .sendKeys('#value', ['1', this.api.Keys.BACK_SPACE, value]) + .pause(2000) .scrollAndClick(`#instance${address} #deployAndRunLLTxSendTransaction`) .perform(() => { this.emit('complete') diff --git a/apps/remix-ide-e2e/src/tests/specialFunctions.test.ts b/apps/remix-ide-e2e/src/tests/specialFunctions.test.ts index dd405cc243..b3e463b63f 100644 --- a/apps/remix-ide-e2e/src/tests/specialFunctions.test.ts +++ b/apps/remix-ide-e2e/src/tests/specialFunctions.test.ts @@ -173,6 +173,7 @@ module.exports = { .waitForElementVisible('#value') .clearValue('#value') .setValue('#value', '0') + .pause(2000) .createContract('') .clickInstance(1) .pause(1000) diff --git a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx index e34ba83250..7afc77ee83 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx @@ -26,7 +26,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) { const [loadedContractData, setLoadedContractData] = useState(null) const [constructorInterface, setConstructorInterface] = useState(null) const [constructorInputs, setConstructorInputs] = useState(null) - const { contractList, loadType, currentFile } = props.contracts + const { contractList, loadType, currentFile, compilationCount } = props.contracts useEffect(() => { enableAtAddress(false) @@ -72,20 +72,23 @@ export function ContractDropdownUI (props: ContractDropdownProps) { setCompFails('block') } initSelectedContract() - }, [loadType, currentFile]) + }, [loadType, currentFile, compilationCount]) useEffect(() => { if (selectedContract) { const contract = contractList.find(contract => contract.alias === selectedContract) - const loadedContractData = props.getSelectedContract(selectedContract, contract.name) - if (loadedContractData) { - setLoadedContractData(loadedContractData) - setConstructorInterface(loadedContractData.getConstructorInterface()) - setConstructorInputs(loadedContractData.getConstructorInputs()) + if (contract) { + const loadedContractData = props.getSelectedContract(selectedContract, contract.name) + + if (loadedContractData) { + setLoadedContractData(loadedContractData) + setConstructorInterface(loadedContractData.getConstructorInterface()) + setConstructorInputs(loadedContractData.getConstructorInputs()) + } } } - }, [selectedContract]) + }, [selectedContract, compilationCount]) useEffect(() => { initSelectedContract() diff --git a/libs/remix-ui/run-tab/src/lib/components/value.tsx b/libs/remix-ui/run-tab/src/lib/components/value.tsx index dcb90745b6..3b2008a5f1 100644 --- a/libs/remix-ui/run-tab/src/lib/components/value.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/value.tsx @@ -5,11 +5,11 @@ import { isNumeric } from '@remix-ui/helper' import { ValueProps } from '../types' export function ValueUI (props: ValueProps) { - const inputValue = useRef(null) - const [sendValue, setSendValue] = useState('') + const [sendValue, setSendValue] = useState(props.sendValue) + const inputValue = useRef({} as HTMLInputElement) useEffect(() => { - sendValue && props.setSendValue(sendValue) + (sendValue !== props.sendValue) && props.setSendValue(sendValue) }, [sendValue]) const validateInputKey = (e) => { @@ -27,8 +27,7 @@ export function ValueUI (props: ValueProps) { if (!value) { // assign 0 if given value is // - empty - setSendValue('0') - return + return setSendValue('0') } let v @@ -59,16 +58,16 @@ export function ValueUI (props: ValueProps) { className="form-control udapp_gasNval udapp_col2" id="value" data-id="dandrValue" - value={sendValue || '0'} title="Enter the value and choose the unit" onKeyPress={validateInputKey} onChange={validateValue} + value={props.sendValue} /> diff --git a/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts b/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts index e544951971..7ad0b0f500 100644 --- a/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts +++ b/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts @@ -52,6 +52,7 @@ export interface RunTabState { }[], loadType: 'abi' | 'sol' | 'other' currentFile: string, + compilationCount: number, isRequesting: boolean, isSuccessful: boolean, error: string @@ -91,7 +92,7 @@ export const runTabInitialState: RunTabState = { selectedAccount: '' }, sendValue: '0', - sendUnit: 'ether', + sendUnit: 'wei', gasLimit: 3000000, selectExEnv: 'vm-london', personalMode: false, @@ -145,6 +146,7 @@ export const runTabInitialState: RunTabState = { contractList: [], loadType: 'other', currentFile: '', + compilationCount: 0, isRequesting: false, isSuccessful: false, error: null @@ -475,7 +477,8 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A ...state, contracts: { ...state.contracts, - currentFile: payload + currentFile: payload, + compilationCount: state.contracts.compilationCount + 1 } } } diff --git a/libs/remix-ui/run-tab/src/lib/types/index.ts b/libs/remix-ui/run-tab/src/lib/types/index.ts index c641962fcc..0647fca2fd 100644 --- a/libs/remix-ui/run-tab/src/lib/types/index.ts +++ b/libs/remix-ui/run-tab/src/lib/types/index.ts @@ -156,6 +156,7 @@ export interface ContractDropdownProps { }[], loadType: 'abi' | 'sol' | 'other', currentFile: string, + compilationCount: number, isRequesting: boolean, isSuccessful: boolean, error: string