fix tests & linting

pull/4355/head
yann300 11 months ago
parent f44183bd5b
commit 7c5c00687c
  1. 2
      apps/remix-ide-e2e/src/commands/sendLowLevelTx.ts
  2. 56
      apps/remix-ide-e2e/src/helpers/init.ts
  3. 4
      apps/remix-ide-e2e/src/tests/editor.test.ts
  4. 6
      apps/remix-ide-e2e/src/tests/editorHoverContext.test.ts
  5. 2
      apps/remix-ide-e2e/src/tests/etherscan_api.test.ts
  6. 2
      apps/remix-ide-e2e/src/tests/plugin_api.ts
  7. 4
      apps/remix-ide-e2e/src/tests/runAndDeploy.test.ts
  8. 4
      apps/remix-ide-e2e/src/tests/staticAnalysis.test.ts
  9. 5
      apps/remix-ide/src/app/editor/editor.js
  10. 6
      libs/remix-ui/editor/src/lib/actions/editor.ts
  11. 12
      libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
  12. 2
      libs/remix-ui/helper/src/lib/components/custom-tooltip.tsx
  13. 8
      libs/remix-ui/run-tab/src/lib/components/value.tsx
  14. 5
      libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx
  15. 2
      libs/remix-ui/workspace/src/lib/components/workspace-hamburger-item.tsx

@ -9,7 +9,7 @@ class sendLowLevelTx extends EventEmitter {
.sendKeys(`#instance${address} #deployAndRunLLTxCalldata`, ['_', this.api.Keys.BACK_SPACE, callData]) .sendKeys(`#instance${address} #deployAndRunLLTxCalldata`, ['_', this.api.Keys.BACK_SPACE, callData])
.waitForElementVisible('#value') .waitForElementVisible('#value')
.clearValue('#value') .clearValue('#value')
.sendKeys('#value', ['1', this.api.Keys.BACK_SPACE, value]) .sendKeys('#value', value)
.pause(2000) .pause(2000)
.scrollAndClick(`#instance${address} #deployAndRunLLTxSendTransaction`) .scrollAndClick(`#instance${address} #deployAndRunLLTxSendTransaction`)
.perform(() => { .perform(() => {

@ -10,8 +10,6 @@ type LoadPlugin = {
export default function (browser: NightwatchBrowser, callback: VoidFunction, url?: string, preloadPlugins = true, loadPlugin?: LoadPlugin, hideToolTips: boolean = true): void { export default function (browser: NightwatchBrowser, callback: VoidFunction, url?: string, preloadPlugins = true, loadPlugin?: LoadPlugin, hideToolTips: boolean = true): void {
browser browser
.url(url || 'http://127.0.0.1:8080') .url(url || 'http://127.0.0.1:8080')
//.switchBrowserTab(0)
.perform((done) => { .perform((done) => {
if (!loadPlugin) return done() if (!loadPlugin) return done()
browser browser
@ -34,35 +32,37 @@ export default function (browser: NightwatchBrowser, callback: VoidFunction, url
} }
addStyle(` addStyle(`
.bs-popover-right { .popover {
display:none !important; display:none !important;
} }
.bs-popover-top {
display:none !important;
}
.bs-popover-left {
display:none !important;
}
.bs-popover-bottom {
display:none !important;
}
`); `);
}) })
} }})
if (preloadPlugins) { .perform(() => {
initModules(browser, () => { browser.execute(function () {
browser (window as any).logs = []
.clickLaunchIcon('solidity') console.log = function () {
.waitForElementVisible('[for="autoCompile"]') (window as any).logs.push(JSON.stringify(arguments))
.click('[for="autoCompile"]') }
.verify.elementPresent('[data-id="compilerContainerAutoCompile"]:checked') console.error = function () {
.perform(() => { callback() }) (window as any).logs.push(JSON.stringify(arguments))
}
}) })
})
} else { .perform(() => {
callback() if (preloadPlugins) {
} initModules(browser, () => {
}) browser
.clickLaunchIcon('solidity')
.waitForElementVisible('[for="autoCompile"]')
.click('[for="autoCompile"]')
.verify.elementPresent('[data-id="compilerContainerAutoCompile"]:checked')
.perform(() => { callback() })
})
} else {
callback()
}
})
} }
function initModules(browser: NightwatchBrowser, callback: VoidFunction) { function initModules(browser: NightwatchBrowser, callback: VoidFunction) {

@ -20,13 +20,13 @@ module.exports = {
.checkElementStyle('.view-lines', 'font-size', '14px') .checkElementStyle('.view-lines', 'font-size', '14px')
.click('*[data-id="tabProxyZoomIn"]') .click('*[data-id="tabProxyZoomIn"]')
.click('*[data-id="tabProxyZoomIn"]') .click('*[data-id="tabProxyZoomIn"]')
.checkElementStyle('.view-lines', 'font-size', '16px') .checkElementStyle('.view-lines', 'font-size', '16.8px')
}, },
'Should zoom out editor #group1': function (browser: NightwatchBrowser) { 'Should zoom out editor #group1': function (browser: NightwatchBrowser) {
browser browser
.waitForElementVisible('#editorView') .waitForElementVisible('#editorView')
.checkElementStyle('.view-lines', 'font-size', '16px') .checkElementStyle('.view-lines', 'font-size', '16.8px')
.click('*[data-id="tabProxyZoomOut"]') .click('*[data-id="tabProxyZoomOut"]')
.click('*[data-id="tabProxyZoomOut"]') .click('*[data-id="tabProxyZoomOut"]')
.checkElementStyle('.view-lines', 'font-size', '14px') .checkElementStyle('.view-lines', 'font-size', '14px')

@ -15,9 +15,9 @@ const checkEditorHoverContent = (browser: NightwatchBrowser, path: string, expec
module.exports = { module.exports = {
'@disabled': true, '@disabled': true,
before: function (browser: NightwatchBrowser, done: VoidFunction) { before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done, 'http://127.0.0.1:8080', false) init(browser, done, 'http://127.0.0.1:8080', false, null, true)
}, },
'Should load the test file': function (browser: NightwatchBrowser) { 'Should load the test file #group1': function (browser: NightwatchBrowser) {
browser.openFile('contracts') browser.openFile('contracts')
.openFile('contracts/3_Ballot.sol') .openFile('contracts/3_Ballot.sol')
.waitForElementVisible('#editorView') .waitForElementVisible('#editorView')
@ -86,7 +86,7 @@ module.exports = {
const expectedContent = 'StructDefinition' const expectedContent = 'StructDefinition'
checkEditorHoverContent(browser, path, expectedContent) checkEditorHoverContent(browser, path, expectedContent)
}, },
'Add token file': function (browser: NightwatchBrowser) { 'Add token file #group1': function (browser: NightwatchBrowser) {
browser browser
.clickLaunchIcon('solidity') .clickLaunchIcon('solidity')
.setSolidityCompilerVersion('soljson-v0.8.20+commit.a1b79de6.js') .setSolidityCompilerVersion('soljson-v0.8.20+commit.a1b79de6.js')

@ -45,7 +45,7 @@ module.exports = {
.setValue('*[name="contractAddress"]', ['0x9981c9d00103da481c3c65b22a79582a3e3ff50b', browser.Keys.TAB]) .setValue('*[name="contractAddress"]', ['0x9981c9d00103da481c3c65b22a79582a3e3ff50b', browser.Keys.TAB])
.click('[data-id="verify-contract"]') .click('[data-id="verify-contract"]')
.waitForElementVisible('[data-id="verify-result"]') .waitForElementVisible('[data-id="verify-result"]')
.waitForElementContainsText('[data-id="verify-result"]', 'Contract source code already verified') .waitForElementContainsText('[data-id="verify-result"]', 'Contract source code already verified', 15000)
}, },
'Should call the etherscan plugin api #group1': function (browser: NightwatchBrowser) { 'Should call the etherscan plugin api #group1': function (browser: NightwatchBrowser) {

@ -431,7 +431,7 @@ module.exports = {
.waitForElementContainsText('*[data-shared="tooltipPopup"]', 'I am a re-toast') .waitForElementContainsText('*[data-shared="tooltipPopup"]', 'I am a re-toast')
}, },
'Should open 2 alerts from localplugin #group9': function (browser: NightwatchBrowser) { 'Should open 2 alerts from localplugin #group9': !function (browser: NightwatchBrowser) {
browser browser
.clickLaunchIcon('localPlugin') .clickLaunchIcon('localPlugin')
.useXpath() .useXpath()

@ -81,10 +81,10 @@ module.exports = {
instanceAddress = address instanceAddress = address
browser browser
.waitForElementVisible(`#instance${instanceAddress} [data-id="instanceContractBal"]`) .waitForElementVisible(`#instance${instanceAddress} [data-id="instanceContractBal"]`)
.assert.containsText(`#instance${instanceAddress} [data-id="instanceContractBal"]`, 'Balance: 0.000000000000000111 ETH') .waitForElementContainsText(`#instance${instanceAddress} [data-id="instanceContractBal"]`, 'Balance: 0.000000000000000111 ETH', 10000)
.clickFunction('sendSomeEther - transact (not payable)', { types: 'uint256 num', values: '2' }) .clickFunction('sendSomeEther - transact (not payable)', { types: 'uint256 num', values: '2' })
.pause(1000) .pause(1000)
.assert.containsText(`#instance${instanceAddress} [data-id="instanceContractBal"]`, 'Balance: 0.000000000000000109 ETH') .waitForElementContainsText(`#instance${instanceAddress} [data-id="instanceContractBal"]`, 'Balance: 0.000000000000000109 ETH', 10000)
}) })
}, },

@ -46,14 +46,14 @@ module.exports = {
.waitForElementPresent('//*[@id="staticanalysisresult"]', 5000) .waitForElementPresent('//*[@id="staticanalysisresult"]', 5000)
.useCss() .useCss()
// Check warning count // Check warning count
.click('*[data-rb-event-key="remix"]') .click('*[data-rr-ui-event-key="remix"]')
.assert.containsText('span#ssaRemixtab > *[data-id="RemixStaticAnalysisErrorCount"]', '1') .assert.containsText('span#ssaRemixtab > *[data-id="RemixStaticAnalysisErrorCount"]', '1')
.verify.elementPresent('input[name="showLibWarnings"]') .verify.elementPresent('input[name="showLibWarnings"]')
.verify.not.elementPresent('input[name="showLibWarnings"]:checked') .verify.not.elementPresent('input[name="showLibWarnings"]:checked')
.verify.elementPresent('label[id="headingshowLibWarnings"]') .verify.elementPresent('label[id="headingshowLibWarnings"]')
.click('label[id="headingshowLibWarnings"]') .click('label[id="headingshowLibWarnings"]')
.pause(1000) .pause(1000)
.click('*[data-rb-event-key="remix"]') .click('*[data-rr-ui-event-key="remix"]')
.assert.containsText('span#ssaRemixtab > *[data-id="RemixStaticAnalysisErrorCount', '386') .assert.containsText('span#ssaRemixtab > *[data-id="RemixStaticAnalysisErrorCount', '386')
.click('label[id="headingshowLibWarnings"]') .click('label[id="headingshowLibWarnings"]')
.pause(1000) .pause(1000)

@ -402,10 +402,7 @@ class Editor extends Plugin {
*/ */
editorFontSize (incr) { editorFontSize (incr) {
if (!this.activated) return if (!this.activated) return
const newSize = this.api.getFontSize() + incr this.emit('setFontSize', incr)
if (newSize >= 6) {
this.emit('setFontSize', newSize)
}
} }
/** /**

@ -85,7 +85,11 @@ export const reducerActions = (models = initialState, action: Action) => {
case 'SET_FONTSIZE': { case 'SET_FONTSIZE': {
if (!editor) return models if (!editor) return models
const size = action.payload.size const size = action.payload.size
editor.updateOptions({ fontSize: size }) if (size === 1) {
editor.trigger('keyboard', 'editor.action.fontZoomIn', {});
} else{
editor.trigger('keyboard', 'editor.action.fontZoomOut', {});
}
return models return models
} }
case 'SET_WORDWRAP': { case 'SET_WORDWRAP': {

@ -645,14 +645,6 @@ export const EditorUI = (props: EditorUIProps) => {
} }
}) })
// zoomin zoomout
editor.addCommand(monacoRef.current.KeyMod.CtrlCmd | (monacoRef.current.KeyCode as any).US_EQUAL, () => {
editor.updateOptions({fontSize: editor.getOption(51) + 1})
})
editor.addCommand(monacoRef.current.KeyMod.CtrlCmd | (monacoRef.current.KeyCode as any).US_MINUS, () => {
editor.updateOptions({fontSize: editor.getOption(51) - 1})
})
// add context menu items // add context menu items
const zoominAction = { const zoominAction = {
id: 'zoomIn', id: 'zoomIn',
@ -664,7 +656,7 @@ export const EditorUI = (props: EditorUIProps) => {
monacoRef.current.KeyMod.CtrlCmd | monacoRef.current.KeyCode.Equal, monacoRef.current.KeyMod.CtrlCmd | monacoRef.current.KeyCode.Equal,
], ],
run: () => { run: () => {
editor.updateOptions({fontSize: editor.getOption(51) + 1}) editor.trigger('keyboard', 'editor.action.fontZoomIn', {});
} }
} }
const zoomOutAction = { const zoomOutAction = {
@ -677,7 +669,7 @@ export const EditorUI = (props: EditorUIProps) => {
monacoRef.current.KeyMod.CtrlCmd | monacoRef.current.KeyCode.Minus, monacoRef.current.KeyMod.CtrlCmd | monacoRef.current.KeyCode.Minus,
], ],
run: () => { run: () => {
editor.updateOptions({fontSize: editor.getOption(51) - 1}) editor.trigger('keyboard', 'editor.action.fontZoomOut', {});
} }
} }
const formatAction = { const formatAction = {

@ -27,7 +27,7 @@ export function CustomTooltip({ children, placement, tooltipId, tooltipClasses,
<>{typeof tooltipText === 'string' ? <span className={'text-wrap p-1 px-2 bg-secondary ' + { tooltipTextClasses }}>{tooltipText}</span> : tooltipText}</> <>{typeof tooltipText === 'string' ? <span className={'text-wrap p-1 px-2 bg-secondary ' + { tooltipTextClasses }}>{tooltipText}</span> : tooltipText}</>
</Popover.Body> </Popover.Body>
</Popover> </Popover>
</>} </>}
delay={delay} delay={delay}
> >
<>{children}</> <>{children}</>

@ -13,6 +13,12 @@ export function ValueUI(props: ValueProps) {
sendValue !== props.sendValue && props.setSendValue(sendValue) sendValue !== props.sendValue && props.setSendValue(sendValue)
}, [sendValue]) }, [sendValue])
useEffect(() => {
if(props.sendValue !== sendValue) {
setSendValue(props.sendValue)
}
},[props.sendValue])
const validateInputKey = (e) => { const validateInputKey = (e) => {
// preventing not numeric keys // preventing not numeric keys
// preventing 000 case // preventing 000 case
@ -63,7 +69,7 @@ export function ValueUI(props: ValueProps) {
data-id="dandrValue" data-id="dandrValue"
onKeyPress={validateInputKey} onKeyPress={validateInputKey}
onChange={validateValue} onChange={validateValue}
value={props.sendValue} value={sendValue}
/> />
</CustomTooltip> </CustomTooltip>

@ -164,6 +164,11 @@ export const SolidityUnitTesting = (props: Record<string, any>) => {
} }
}) })
testTab.on('filePanel', 'workspaceCreated', async () => {
setTimeout(async () => {
await setCurrentPath(defaultPath)}, 100)
})
testTab.on('filePanel', 'setWorkspace', async () => { testTab.on('filePanel', 'setWorkspace', async () => {
await setCurrentPath(defaultPath) await setCurrentPath(defaultPath)
}) })

@ -78,7 +78,7 @@ export interface HamburgerSubMenuItemProps {
export function HamburgerSubMenuItem(props: HamburgerSubMenuItemProps) { export function HamburgerSubMenuItem(props: HamburgerSubMenuItemProps) {
return ( return (
<> <>
<NavDropdown title={props.title} as={CustomMenu} key={props.id} id={props.id} dir='right'> <NavDropdown title={props.title} as={CustomMenu} key={props.id} id={props.id} drop={'end'}>
{props.subMenus.map((item) => ( {props.subMenus.map((item) => (
<NavHamburgerMenuItem platforms={props.platforms} kind={item.kind} fa={item.fa} hideOption={item.hideOption} actionOnClick={item.actionOnClick} /> <NavHamburgerMenuItem platforms={props.platforms} kind={item.kind} fa={item.fa} hideOption={item.hideOption} actionOnClick={item.actionOnClick} />
))} ))}

Loading…
Cancel
Save