From 2357488eb08713936bc84872bd44a8b25d6daac3 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Fri, 8 Mar 2024 21:52:13 +0100 Subject: [PATCH] Add e2e for vm-state --- .../src/tests/runAndDeploy.test.ts | 115 ++++++++++++++++-- .../settings/src/lib/remix-ui-settings.tsx | 2 +- 2 files changed, 103 insertions(+), 14 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/runAndDeploy.test.ts b/apps/remix-ide-e2e/src/tests/runAndDeploy.test.ts index cebc84bc93..943292cc82 100644 --- a/apps/remix-ide-e2e/src/tests/runAndDeploy.test.ts +++ b/apps/remix-ide-e2e/src/tests/runAndDeploy.test.ts @@ -82,21 +82,21 @@ module.exports = { instanceAddress = address console.log('instanceAddress', instanceAddress) browser - .waitForElementVisible(`#instance${instanceAddress} [data-id="instanceContractBal"]`) + .waitForElementVisible(`#instance${instanceAddress} [data-id="instanceContractBal"]`) //*[@id="instance0xbBF289D846208c16EDc8474705C748aff07732dB" and contains(.,"Balance") and contains(.,'0.000000000000000111')] - .waitForElementVisible({ - locateStrategy: 'xpath', - selector: `//*[@id="instance${instanceAddress}" and contains(.,"Balance") and contains(.,'0.000000000000000111')]`, - timeout: 60000 - }) + .waitForElementVisible({ + locateStrategy: 'xpath', + selector: `//*[@id="instance${instanceAddress}" and contains(.,"Balance") and contains(.,'0.000000000000000111')]`, + timeout: 60000 + }) //.waitForElementContainsText(`#instance${instanceAddress} [data-id="instanceContractBal"]`, 'Balance: 0.000000000000000111 ETH', 60000) - .clickFunction('sendSomeEther - transact (not payable)', { types: 'uint256 num', values: '2' }) - .pause(1000) - .waitForElementVisible({ - locateStrategy: 'xpath', - selector: `//*[@id="instance${instanceAddress}" and contains(.,"Balance") and contains(.,'0.000000000000000109')]`, - timeout: 60000 - }) + .clickFunction('sendSomeEther - transact (not payable)', { types: 'uint256 num', values: '2' }) + .pause(1000) + .waitForElementVisible({ + locateStrategy: 'xpath', + selector: `//*[@id="instance${instanceAddress}" and contains(.,"Balance") and contains(.,'0.000000000000000109')]`, + timeout: 60000 + }) }) }, @@ -238,6 +238,95 @@ module.exports = { .executeScriptInTerminal('web3.eth.getAccounts()') .journalLastChildIncludes('[ "0x76a3ABb5a12dcd603B52Ed22195dED17ee82708f" ]') .end() + }, + + 'Should ensure that save environment state is checked by default #group4 #group5': function (browser: NightwatchBrowser) { + browser.waitForElementPresent('*[data-id="remixIdeSidePanel"]') + .clickLaunchIcon('settings') + .waitForElementPresent('[data-id="settingsEnableSaveEnvStateLabel"]') + .scrollInto('[data-id="settingsEnableSaveEnvStateLabel"]') + .verify.elementPresent('[data-id="settingsEnableSaveEnvState"]:checked') + }, + + 'Should deploy default storage contract; store value and ensure that state is saved. #group4 #group5': function (browser: NightwatchBrowser) { + browser + .clickLaunchIcon('filePanel') + .click('*[data-id="treeViewLitreeViewItemcontracts"]') + .openFile('contracts/1_Storage.sol') + .pause(5000) + .clickLaunchIcon('udapp') + .waitForElementPresent('*[data-id="Deploy - transact (not payable)"]') + .click('*[data-id="Deploy - transact (not payable)"]') + .waitForElementPresent('#instance0xd9145CCE52D386f254917e481eB44e9943F39138') + .clickInstance(0) + .clickFunction('store - transact (not payable)', { types: 'uint256 num', values: '10' }) + .clickFunction('retrieve - call') + .waitForElementContainsText('[data-id="treeViewLi0"]', 'uint256: 10') + .clickLaunchIcon('filePanel') + .openFile('.states/vm-shanghai/state.json') + .getEditorValue((content) => { + browser + .assert.ok(content.includes('"latestBlockNumber": "0x02"'), 'State is saved') + }) + }, + + 'Should load state after page refresh #group4': function (browser: NightwatchBrowser) { + browser.refreshPage() + .waitForElementVisible('*[data-id="remixIdeSidePanel"]') + .click('*[data-id="treeViewLitreeViewItemcontracts"]') + .openFile('contracts/1_Storage.sol') + .addAtAddressInstance('0xd9145CCE52D386f254917e481eB44e9943F39138', true, true, false) + .clickInstance(0) + .clickFunction('retrieve - call') + .waitForElementContainsText('[data-id="treeViewLi0"]', 'uint256: 10') + }, + + 'Should save state after running web3 script #group4': function (browser: NightwatchBrowser) { + browser + .clickLaunchIcon('settings') + .waitForElementPresent('[data-id="settingsTabGenerateContractMetadataLabel"]') + .click('[data-id="settingsTabGenerateContractMetadataLabel"]') + .verify.elementPresent('[data-id="settingsTabGenerateContractMetadata"]:checked') + .clickLaunchIcon('solidity') + .click('.remixui_compilerConfigSection') + .setValue('#evmVersionSelector', 'london') + .click('*[data-id="compilerContainerCompileBtn"]') + .pause(5000) + .clickLaunchIcon('udapp') + .switchEnvironment('vm-london') + .clickLaunchIcon('filePanel') + .click('*[data-id="treeViewLitreeViewItemscripts"]') + .openFile('scripts/deploy_with_web3.ts') + .click('[data-id="play-editor"]') + .waitForElementPresent('[data-id="treeViewDivDraggableItem.states/vm-london/state.json"]') + .click('[data-id="treeViewDivDraggableItem.states/vm-london/state.json"]') + .pause(100000) + .getEditorValue((content) => { + browser + .assert.ok(content.includes('"latestBlockNumber": "0x01"'), 'State is saved') + }) + }, + + 'Should ensure that .states is not updated when save env option is unchecked #group5': function (browser: NightwatchBrowser) { + browser + .clickLaunchIcon('settings') + .waitForElementPresent('[data-id="settingsEnableSaveEnvStateLabel"]') + .click('[data-id="settingsEnableSaveEnvStateLabel"]') + .verify.elementNotPresent('[data-id="settingsEnableSaveEnvState"]:checked') + .clickLaunchIcon('filePanel') + .openFile('contracts/1_Storage.sol') + .pause(5000) + .clickLaunchIcon('udapp') + .waitForElementPresent('*[data-id="Deploy - transact (not payable)"]') + .click('*[data-id="Deploy - transact (not payable)"]') + .pause(5000) + .clickLaunchIcon('filePanel') + .openFile('.states/vm-shanghai/state.json') + .getEditorValue((content) => { + browser + .assert.ok(content.includes('"latestBlockNumber": "0x02"'), 'State is unchanged') + }) + .end() } } diff --git a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx index 603c5c3be0..57f0cc7dd1 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -343,7 +343,7 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
- +