Merge pull request #3876 from ethereum/ssa-button-fix

Static Analyzers Run Button Fix
pull/5370/head
Joseph Izang 1 year ago committed by GitHub
commit 1e2bdf7ea3
  1. 53
      apps/remix-ide-e2e/src/tests/staticAnalysis.test.ts
  2. 28
      libs/remix-ui/static-analyser/src/lib/Button/StaticAnalyserButton.tsx
  3. 2
      libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx

@ -33,29 +33,32 @@ module.exports = {
},
'run analysis and filter results': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('filePanel')
.click('*[data-id="treeViewLitreeViewItemcontracts"]')
.click('*[data-id="treeViewLitreeViewItemcontracts/2_Owner.sol"]')
.clickLaunchIcon('solidity')
.click('*[id="compileBtn"]')
.pause(10000)
.clickLaunchIcon('solidityStaticAnalysis')
.click('*[id="staticAnalysisRunBtn"]')
.waitForElementPresent('#staticanalysisresult .warning', 5000)
// Check warning count
.click('*[data-rb-event-key="remix"]')
.assert.containsText('span#ssaRemixtab > *[data-id="RemixStaticAnalysisErrorCount"]', '1')
.verify.elementPresent('input[name="showLibWarnings"]')
.verify.not.elementPresent('input[name="showLibWarnings"]:checked')
.verify.elementPresent('label[id="headingshowLibWarnings"]')
.click('label[id="headingshowLibWarnings"]')
.pause(1000)
.click('*[data-rb-event-key="remix"]')
.assert.containsText('span#ssaRemixtab > *[data-id="RemixStaticAnalysisErrorCount', '382')
.click('label[id="headingshowLibWarnings"]')
.pause(1000)
.assert.containsText('span#ssaRemixtab > *[data-id="RemixStaticAnalysisErrorCount', '1')
.end()
.clickLaunchIcon('filePanel')
.click('*[data-id="treeViewLitreeViewItemcontracts"]')
.click('*[data-id="treeViewLitreeViewItemcontracts/2_Owner.sol"]')
.clickLaunchIcon('solidity')
.click('*[id="compileBtn"]')
.pause(10000)
.clickLaunchIcon('solidityStaticAnalysis')
.useXpath()
.click('//*[@id="staticAnalysisRunBtn"]')
// .waitForElementPresent('div#staticanalysisresult .warning', 5000)
.waitForElementPresent('//*[@id="staticanalysisresult"]', 5000)
.useCss()
// Check warning count
.click('*[data-rb-event-key="remix"]')
.assert.containsText('span#ssaRemixtab > *[data-id="RemixStaticAnalysisErrorCount"]', '1')
.verify.elementPresent('input[name="showLibWarnings"]')
.verify.not.elementPresent('input[name="showLibWarnings"]:checked')
.verify.elementPresent('label[id="headingshowLibWarnings"]')
.click('label[id="headingshowLibWarnings"]')
.pause(1000)
.click('*[data-rb-event-key="remix"]')
.assert.containsText('span#ssaRemixtab > *[data-id="RemixStaticAnalysisErrorCount', '382')
.click('label[id="headingshowLibWarnings"]')
.pause(1000)
.assert.containsText('span#ssaRemixtab > *[data-id="RemixStaticAnalysisErrorCount', '1')
.end()
}
}
@ -72,8 +75,8 @@ function runTests (browser: NightwatchBrowser) {
'Fallback function of contract TooMuchGas requires too much gas',
'TooMuchGas.() : Variables have very similar names "test" and "test1".',
'TooMuchGas.() : Variables have very similar names "test" and "test1".'],
'#staticanalysisresult .warning',
browser
'#staticanalysisresult .warning',
browser
)
})
}

@ -16,12 +16,17 @@ const StaticAnalyserButton = ({
title,
classList
}: StaticAnalyserButtonProps) => {
const defaultStyle = "btn btn-sm w-25 btn-primary"
const defaultStyle = "btn btn-sm btn-block btn-primary"
const newclassList = disabled && classList.length > 0 ? `${classList} disabled` :
classList.length === 0 && disabled ? `${defaultStyle} disabled` : classList.length > 0 ? `${classList}` : defaultStyle
const buttonWithoutTooltip = () => (
<button id="staticAnalysisRunBtn" className={newclassList} disabled={disabled} onClick={onClick}>
<button
id="staticAnalysisRunBtn"
className={newclassList}
disabled={disabled}
onClick={onClick}
>
<span className="pl-3 pr-4">
{buttonText}
</span>
@ -29,18 +34,27 @@ const StaticAnalyserButton = ({
)
const buttonWithTooltip = () => (
<button id="staticAnalysisRunBtn" className={newclassList} disabled={disabled} onClick={onClick}>
<CustomTooltip
placement="right"
tooltipId="ssaRunButtonTooltip"
tooltipClasses="text-nowrap"
tooltipText={title}
>
<span className="pl-3 pr-4">
{buttonText}
</span>
<div id="staticAnalysisWrapper" className={`${newclassList} p-0`}>
<button
id="staticAnalysisRunBtn"
className={newclassList}
disabled={disabled}
onClick={onClick}
style={{ pointerEvents: 'none', color: 'white' }}
>
<span className="pl-3 pr-4">
{buttonText}
</span>
</button>
</div>
</CustomTooltip>
</button>)
)
return (
title && title.length > 0 ? buttonWithTooltip() : buttonWithoutTooltip()

@ -130,7 +130,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
`${
state && state.data && state.file.length > 0
? "Run analysis"
: "To run analysis tools, first compile a contract."
: "To run analysis for selected tools, first compile a contract"
}`
);
}

Loading…
Cancel
Save