Fixed failing e2e tests

pull/5370/head
ioedeveloper 2 years ago committed by Aniket
parent 43bbe4da97
commit 1404bab675
  1. 21
      apps/remix-ide-e2e/src/tests/proxy.test.ts
  2. 7
      libs/remix-ui/helper/src/lib/components/custom-dropdown.tsx
  3. 11
      libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx

@ -4,6 +4,8 @@ import init from '../helpers/init'
let firstProxyAddress: string let firstProxyAddress: string
let lastProxyAddress: string let lastProxyAddress: string
let shortenedFirstAddress: string
let shortenedLastAddress: string
module.exports = { module.exports = {
'@disabled': true, '@disabled': true,
before: function (browser: NightwatchBrowser, done: VoidFunction) { before: function (browser: NightwatchBrowser, done: VoidFunction) {
@ -94,6 +96,7 @@ module.exports = {
browser browser
.getAddressAtPosition(1, (address) => { .getAddressAtPosition(1, (address) => {
firstProxyAddress = address firstProxyAddress = address
shortenedFirstAddress = address.slice(0, 5) + '...' + address.slice(address.length - 5, address.length)
}) })
.clickInstance(1) .clickInstance(1)
.perform((done) => { .perform((done) => {
@ -143,6 +146,7 @@ module.exports = {
browser browser
.getAddressAtPosition(1, (address) => { .getAddressAtPosition(1, (address) => {
lastProxyAddress = address lastProxyAddress = address
shortenedLastAddress = address.slice(0, 5) + '...' + address.slice(address.length - 5, address.length)
}) })
.clickInstance(1) .clickInstance(1)
.perform((done) => { .perform((done) => {
@ -157,7 +161,7 @@ module.exports = {
}) })
}, },
'Should upgrade contract using last deployed proxy address (MyTokenV1 to MyTokenV2) #group1': function (browser: NightwatchBrowser) { 'Should upgrade contract by selecting a previously deployed proxy address from dropdown (MyTokenV1 to MyTokenV2) #group1': function (browser: NightwatchBrowser) {
browser browser
.waitForElementPresent('[data-id="deployAndRunClearInstances"]') .waitForElementPresent('[data-id="deployAndRunClearInstances"]')
.click('[data-id="deployAndRunClearInstances"]') .click('[data-id="deployAndRunClearInstances"]')
@ -171,10 +175,12 @@ module.exports = {
.click('select.udapp_contractNames option[value=MyTokenV2]') .click('select.udapp_contractNames option[value=MyTokenV2]')
.waitForElementPresent('[data-id="contractGUIUpgradeImplementationLabel"]') .waitForElementPresent('[data-id="contractGUIUpgradeImplementationLabel"]')
.click('[data-id="contractGUIUpgradeImplementationLabel"]') .click('[data-id="contractGUIUpgradeImplementationLabel"]')
.waitForElementPresent('[data-id="contractGUIProxyAddressLabel"]') .waitForElementPresent('[data-id="toggleProxyAddressDropdown"]')
.click('[data-id="contractGUIProxyAddressLabel"]') .click('[data-id="toggleProxyAddressDropdown"]')
.waitForElementPresent('[data-id="lastDeployedERC1967Address"]') .waitForElementVisible('[data-id="proxy-dropdown-items"]')
.assert.containsText('[data-id="lastDeployedERC1967Address"]', lastProxyAddress) .assert.textContains('[data-id="proxy-dropdown-items"]', shortenedFirstAddress)
.assert.textContains('[data-id="proxy-dropdown-items"]', shortenedLastAddress)
.click('[data-id="proxyAddress1"]')
.createContract('') .createContract('')
.waitForElementContainsText('[data-id="udappNotifyModalDialogModalTitle-react"]', 'Deploy Implementation & Update Proxy') .waitForElementContainsText('[data-id="udappNotifyModalDialogModalTitle-react"]', 'Deploy Implementation & Update Proxy')
.waitForElementVisible('[data-id="udappNotify-modal-footer-ok-react"]') .waitForElementVisible('[data-id="udappNotify-modal-footer-ok-react"]')
@ -212,9 +218,8 @@ module.exports = {
.click('select.udapp_contractNames') .click('select.udapp_contractNames')
.click('select.udapp_contractNames option[value=MyTokenV2]') .click('select.udapp_contractNames option[value=MyTokenV2]')
.waitForElementPresent('[data-id="contractGUIUpgradeImplementationLabel"]') .waitForElementPresent('[data-id="contractGUIUpgradeImplementationLabel"]')
.waitForElementPresent('[data-id="contractGUIProxyAddressLabel"]') .waitForElementPresent('[data-id="toggleProxyAddressDropdown"]')
.click('[data-id="contractGUIProxyAddressLabel"]') .clearValue('[data-id="ERC1967AddressInput"]')
.waitForElementPresent('[data-id="ERC1967AddressInput"]')
.setValue('[data-id="ERC1967AddressInput"]', firstProxyAddress) .setValue('[data-id="ERC1967AddressInput"]', firstProxyAddress)
.createContract('') .createContract('')
.waitForElementContainsText('[data-id="udappNotifyModalDialogModalTitle-react"]', 'Deploy Implementation & Update Proxy') .waitForElementContainsText('[data-id="udappNotifyModalDialogModalTitle-react"]', 'Deploy Implementation & Update Proxy')

@ -63,16 +63,19 @@ export const ProxyAddressToggle = React.forwardRef(({ address, onClick, classNam
e.preventDefault() e.preventDefault()
onClick(e) onClick(e)
}} }}
className={'d-flex '+ className.replace('dropdown-toggle', '')}> className={'d-flex '+ className.replace('dropdown-toggle', '')}
data-id="toggleProxyAddressDropdown"
>
<input <input
onChange={(e) => { onChange={(e) => {
e.preventDefault() e.preventDefault()
onChange(e) onChange(e)
}} }}
className="udapp_input udapp_ataddressinput form-control" className="udapp_input form-control"
value={address} value={address}
placeholder="Enter Proxy Address" placeholder="Enter Proxy Address"
style={{ width: '100%' }} style={{ width: '100%' }}
data-id="ERC1967AddressInput"
/> />
</div> </div>
)) ))

@ -37,12 +37,6 @@ export function ContractGUI (props: ContractGUIProps) {
} }
}, [props.deployOption]) }, [props.deployOption])
useEffect(() => {
if (!proxyAddress && props.proxy && props.proxy.deployments.length > 0) {
setProxyAddress(props.proxy.deployments[0].address)
}
}, [props.proxy])
useEffect(() => { useEffect(() => {
if (props.title) { if (props.title) {
setTitle(props.title) setTitle(props.title)
@ -531,11 +525,12 @@ export function ContractGUI (props: ContractGUIProps) {
toggleUpgradeImp ? "d-flex" : "d-none" toggleUpgradeImp ? "d-flex" : "d-none"
}`} }`}
> >
<div data-id="proxy-dropdown-items">
<Dropdown onToggle={toggleDropdown} show={showDropdown}> <Dropdown onToggle={toggleDropdown} show={showDropdown}>
<Dropdown.Toggle id="dropdown-custom-components" as={ProxyAddressToggle} address={proxyAddress} onChange={handleAddressChange} className="d-inline-block border border-dark bg-dark" /> <Dropdown.Toggle id="dropdown-custom-components" as={ProxyAddressToggle} address={proxyAddress} onChange={handleAddressChange} className="d-inline-block border border-dark bg-dark" />
{ props.proxy.deployments.length > 0 && { props.proxy.deployments.length > 0 &&
<Dropdown.Menu as={ProxyDropdownMenu} className='w-100 custom-dropdown-items' data-id="custom-dropdown-items" style={{ overflow: 'hidden' }}> <Dropdown.Menu as={ProxyDropdownMenu} className='w-100 custom-dropdown-items' style={{ overflow: 'hidden' }}>
{ {
props.proxy.deployments.map((deployment, index) => ( props.proxy.deployments.map((deployment, index) => (
<CustomTooltip <CustomTooltip
@ -549,6 +544,7 @@ export function ContractGUI (props: ContractGUIProps) {
onClick={() => { onClick={() => {
switchProxyAddress(deployment.address) switchProxyAddress(deployment.address)
}} }}
data-id={`proxyAddress${index}`}
> >
<span>{ proxyAddress === deployment.address ? <span>&#10003; { deployment.contractName + ' ' + shortenProxyAddress(deployment.address) } </span> : <span className="pl-3">{ deployment.contractName + ' ' + shortenProxyAddress(deployment.address) }</span> }</span> <span>{ proxyAddress === deployment.address ? <span>&#10003; { deployment.contractName + ' ' + shortenProxyAddress(deployment.address) } </span> : <span className="pl-3">{ deployment.contractName + ' ' + shortenProxyAddress(deployment.address) }</span> }</span>
</Dropdown.Item> </Dropdown.Item>
@ -558,6 +554,7 @@ export function ContractGUI (props: ContractGUIProps) {
</Dropdown.Menu> </Dropdown.Menu>
} }
</Dropdown> </Dropdown>
</div>
<div className={`flex-column 'd-flex'}`}> <div className={`flex-column 'd-flex'}`}>
<div className="mb-2"> <div className="mb-2">
{ proxyAddressError && <span className='text-lowercase' data-id="errorMsgProxyAddress" style={{ fontSize: '.8em' }}>{ proxyAddressError }</span> } { proxyAddressError && <span className='text-lowercase' data-id="errorMsgProxyAddress" style={{ fontSize: '.8em' }}>{ proxyAddressError }</span> }

Loading…
Cancel
Save