e2e added. scrol of fE fixed

pull/2470/head
lianahus 3 years ago committed by yann300
parent 3d123440b7
commit a0162a8ac4
  1. 23
      apps/remix-ide-e2e/src/commands/verifyContracts.ts
  2. 35
      apps/remix-ide-e2e/src/tests/ballot.test.ts
  3. 1
      apps/remix-ide-e2e/src/tests/compiler_api.test.ts
  4. 2
      apps/remix-ide-e2e/src/types/index.d.ts
  5. 11
      libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
  6. 1
      libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css
  7. 6
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -2,7 +2,7 @@ import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events' import EventEmitter from 'events'
class VerifyContracts extends EventEmitter { class VerifyContracts extends EventEmitter {
command (this: NightwatchBrowser, compiledContractNames: string[], opts = { wait: 1000, version: null }): NightwatchBrowser { command (this: NightwatchBrowser, compiledContractNames: string[], opts = { wait: 1000, version: null, runs: '200' }): NightwatchBrowser {
this.api.perform((done) => { this.api.perform((done) => {
verifyContracts(this.api, compiledContractNames, opts, () => { verifyContracts(this.api, compiledContractNames, opts, () => {
done() done()
@ -13,7 +13,7 @@ class VerifyContracts extends EventEmitter {
} }
} }
function verifyContracts (browser: NightwatchBrowser, compiledContractNames: string[], opts: { wait: number, version?: string }, callback: VoidFunction) { function verifyContracts (browser: NightwatchBrowser, compiledContractNames: string[], opts: { wait: number, version?: string, runs?: string }, callback: VoidFunction) {
browser browser
.clickLaunchIcon('solidity') .clickLaunchIcon('solidity')
.pause(opts.wait) .pause(opts.wait)
@ -36,6 +36,25 @@ function verifyContracts (browser: NightwatchBrowser, compiledContractNames: str
done() done()
callback() callback()
}) })
} if (opts.runs) {
browser
.click('*[data-id="compilation-details"]')
.waitForElementVisible('*[data-id="remixui_treeviewitem_metadata"]')
.pause(2000)
.click('*[data-id="remixui_treeviewitem_metadata"]')
.waitForElementVisible('*[data-id="treeViewDivtreeViewItemsettings"]')
.pause(2000)
.click('*[data-id="treeViewDivtreeViewItemsettings"]')
.waitForElementVisible('*[data-id="treeViewDivtreeViewItemoptimizer"]')
.click('*[data-id="treeViewDivtreeViewItemoptimizer"]')
.waitForElementVisible('*[data-id="treeViewDivruns"]')
.assert.containsText('*[data-id="treeViewDivruns"]', `${opts.runs}`)
.click('[data-id="workspacesModalDialog-modal-footer-ok-react"]')
.perform(() => {
done()
callback()
})
} else { } else {
compiledContractNames.forEach((name) => { compiledContractNames.forEach((name) => {
browser.waitForElementContainsText('[data-id="compiledContracts"]', name, 60000) browser.waitForElementContainsText('[data-id="compiledContracts"]', name, 60000)

@ -123,6 +123,21 @@ module.exports = {
// Test in Udapp UI , treeViewDiv0 shows returned value on method click // Test in Udapp UI , treeViewDiv0 shows returned value on method click
.assert.containsText('*[data-id="treeViewDiv0"]', 'bytes32: winnerName_ 0x48656c6c6f20576f726c64210000000000000000000000000000000000000000') .assert.containsText('*[data-id="treeViewDiv0"]', 'bytes32: winnerName_ 0x48656c6c6f20576f726c64210000000000000000000000000000000000000000')
.end() .end()
},
'Compile Ballot using config file': function (browser: NightwatchBrowser) {
browser
.addFile('cf.json', {content: configFile})
.clickLaunchIcon('solidity')
.click('*[data-id="scConfigExpander"]')
.click('*[data-id="scFileConfiguration"]')
.click('*[data-id="scConfigChangeFilePath"]')
.click('*[data-id="scConfigFilePathInput]')
.clearValue('*[data-id="scConfigFilePathInput"]')
.setValue('*[data-id="scConfigFilePathInput"]', 'cf.json')
.openFile('Untitled.sol')
.pause(5000)
.verifyContracts(['Ballot'], {wait: 2000, runs: '300'})
} }
} }
@ -190,6 +205,7 @@ const stateCheck = {
immutable: false immutable: false
} }
} }
const ballotABI = `[ const ballotABI = `[
{ {
"inputs": [ "inputs": [
@ -356,3 +372,22 @@ const ballotABI = `[
"type": "function" "type": "function"
} }
]` ]`
const configFile = `
{
"language": "Solidity",
"settings": {
"optimizer": {
"enabled": true,
"runs": 300
},
"outputSelection": {
"*": {
"": ["ast"],
"*": []
}
},
"evmVersion": "byzantium"
}
}
`

@ -168,3 +168,4 @@ contract DoesNotCompile {
function fStackLimit(uint u1, uint u2, uint u3, uint u4, uint u5, uint u6, uint u7, uint u8, uint u9, uint u10, uint u11, uint u12) public { function fStackLimit(uint u1, uint u2, uint u3, uint u4, uint u5, uint u6, uint u7, uint u8, uint u9, uint u10, uint u11, uint u12) public {
} }
}` }`

@ -11,7 +11,7 @@ declare module 'nightwatch' {
testContracts(fileName: string, contractCode: NightwatchContractContent, compiledContractNames: string[]): NightwatchBrowser, testContracts(fileName: string, contractCode: NightwatchContractContent, compiledContractNames: string[]): NightwatchBrowser,
setEditorValue(value: string, callback?: () => void): NightwatchBrowser, setEditorValue(value: string, callback?: () => void): NightwatchBrowser,
addFile(name: string, content: NightwatchContractContent): NightwatchBrowser, addFile(name: string, content: NightwatchContractContent): NightwatchBrowser,
verifyContracts(compiledContractNames: string[], opts?: { wait: number, version?: string }): NightwatchBrowser, verifyContracts(compiledContractNames: string[], opts?: { wait: number, version?: string, runs?: string }): NightwatchBrowser,
selectAccount(account?: string): NightwatchBrowser, selectAccount(account?: string): NightwatchBrowser,
clickFunction(fnFullName: string, expectedInput?: NightwatchClickFunctionExpectedInput): NightwatchBrowser, clickFunction(fnFullName: string, expectedInput?: NightwatchClickFunctionExpectedInput): NightwatchBrowser,
testFunction(txHash: string, expectedInput: NightwatchTestFunctionExpectedInput): NightwatchBrowser, testFunction(txHash: string, expectedInput: NightwatchTestFunctionExpectedInput): NightwatchBrowser,

@ -67,20 +67,18 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const [compilerContainer, dispatch] = useReducer(compilerReducer, compilerInitialState) const [compilerContainer, dispatch] = useReducer(compilerReducer, compilerInitialState)
useEffect(() => { useEffect(() => {
if (workspaceName) {
api.setAppParameter('configFilePath', defaultPath) api.setAppParameter('configFilePath', defaultPath)
if (state.useFileConfiguration) { if (state.useFileConfiguration) {
api.fileExists(defaultPath).then((exists) => { api.fileExists(defaultPath).then((exists) => {
if (!exists || state.useFileConfiguration ) createNewConfigFile() if (!exists || state.useFileConfiguration ) createNewConfigFile()
}) })
} }
api.setAppParameter('configFilePath', defaultPath)
setShowFilePathInput(false) setShowFilePathInput(false)
}
}, [workspaceName]) }, [workspaceName])
useEffect(() => { useEffect(() => {
if (state.useFileConfiguration) if (state.useFileConfiguration)
api.fileExists(defaultPath).then((exists) => { api.fileExists(defaultPath).then((exists) => {
if (!exists || state.useFileConfiguration ) createNewConfigFile() if (!exists || state.useFileConfiguration ) createNewConfigFile()
@ -781,7 +779,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
</div> </div>
</div> </div>
<div className="d-flex pb-1 remixui_compilerConfig custom-control custom-radio"> <div className="d-flex pb-1 remixui_compilerConfig custom-control custom-radio">
<input className="custom-control-input" type="radio" name="configradio" value="file" onChange={toggleConfigType} checked={state.useFileConfiguration} id="scFileConfig" /> <input className="custom-control-input" type="radio" name="configradio" value="file" onChange={toggleConfigType} checked={state.useFileConfiguration} id="scFileConfig" data-id="scFileConfiguration"/>
<label className="form-check-label custom-control-label" htmlFor="scFileConfig">Use configuration file</label> <label className="form-check-label custom-control-label" htmlFor="scFileConfig">Use configuration file</label>
</div> </div>
<div className={`pt-2 ml-4 ml-2 align-items-start justify-content-between d-flex`}> <div className={`pt-2 ml-4 ml-2 align-items-start justify-content-between d-flex`}>
@ -797,13 +795,14 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
placeholder={"Enter the new path"} placeholder={"Enter the new path"}
title="If the file you entered does not exist you will be able to create one in the next step." title="If the file you entered does not exist you will be able to create one in the next step."
disabled={!state.useFileConfiguration} disabled={!state.useFileConfiguration}
data-id="scConfigFilePathInput"
onKeyPress={event => { onKeyPress={event => {
if (event.key === 'Enter') { if (event.key === 'Enter') {
handleConfigPathChange() handleConfigPathChange()
} }
}} }}
/> />
{ !showFilePathInput && <button disabled={!state.useFileConfiguration} className="btn-secondary" onClick={() => {setShowFilePathInput(true)}}>Change</button> } { !showFilePathInput && <button disabled={!state.useFileConfiguration} data-id="scConfigChangeFilePath" className="btn-secondary" onClick={() => {setShowFilePathInput(true)}}>Change</button> }
</div> </div>
</div> </div>
<div className="px-4"> <div className="px-4">

@ -13,6 +13,7 @@
padding-left : 6px; padding-left : 6px;
padding-right : 6px; padding-right : 6px;
padding-top : 6px; padding-top : 6px;
overflow-y : auto;
} }
.remixui_fileExplorerTree { .remixui_fileExplorerTree {
cursor : default; cursor : default;

@ -228,9 +228,9 @@ export function Workspace () {
</div> </div>
</header> </header>
</div> </div>
<div className='remixui_fileExplorerTree'> <div className='h-100 remixui_fileExplorerTree'>
<div> <div className='h-100'>
<div className='pl-2 remixui_treeview' data-id='filePanelFileExplorerTree'> <div className='pl-2 h-100 remixui_treeview' data-id='filePanelFileExplorerTree'>
{ (global.fs.mode === 'browser') && (currentWorkspace !== NO_WORKSPACE) && { (global.fs.mode === 'browser') && (currentWorkspace !== NO_WORKSPACE) &&
<FileExplorer <FileExplorer
name={currentWorkspace} name={currentWorkspace}

Loading…
Cancel
Save