From 641294934aa43b0d8a4ee5a64bd1c22edfb8246a Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 1 Apr 2022 18:13:52 +0530 Subject: [PATCH] e2e tests for filtering analysis --- .../src/tests/staticAnalysis.test.ts | 28 +++++++++++++++---- .../src/lib/remix-ui-static-analyser.tsx | 2 ++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/staticAnalysis.test.ts b/apps/remix-ide-e2e/src/tests/staticAnalysis.test.ts index 504148b266..2a2b39b523 100644 --- a/apps/remix-ide-e2e/src/tests/staticAnalysis.test.ts +++ b/apps/remix-ide-e2e/src/tests/staticAnalysis.test.ts @@ -30,6 +30,27 @@ module.exports = { }, 'Static Analysis': function (browser: NightwatchBrowser) { runTests(browser) + }, + 'run analysis and filter results': function (browser: NightwatchBrowser) { + browser + .clickLaunchIcon('filePanel') + .click('*[data-id="treeViewLitreeViewItemcontracts"]') + .click('*[data-id="treeViewLitreeViewItemcontracts/2_Owner.sol"]') + .clickLaunchIcon('solidity') + .pause(10000) + .clickLaunchIcon('solidityStaticAnalysis') + .waitForElementPresent('#staticanalysisresult .warning', 5000) + .assert.containsText('#verticalIconsKindsolidityStaticAnalysis .remixui_status', '1') // Check warning count + .verify.elementPresent('input[name="showLibWarnings"]') + .verify.elementNotPresent('input[name="showLibWarnings"]:checked') + .verify.elementPresent('label[id="headingshowLibWarnings"]') + .click('label[id="headingshowLibWarnings"]') + .pause(1000) + .assert.containsText('#verticalIconsKindsolidityStaticAnalysis .remixui_status', '382') + .click('label[id="headingshowLibWarnings"]') + .pause(1000) + .assert.containsText('#verticalIconsKindsolidityStaticAnalysis .remixui_status', '1') + .end() } } @@ -47,14 +68,12 @@ function runTests (browser: NightwatchBrowser) { 'TooMuchGas.() : Variables have very similar names "test" and "test1".', 'TooMuchGas.() : Variables have very similar names "test" and "test1".'], '#staticanalysisresult .warning', - browser, function () { - browser.end() - } + browser ) }) } -function listSelectorContains (textsToFind: string[], selector: string, browser: NightwatchBrowser, callback: VoidFunction) { +function listSelectorContains (textsToFind: string[], selector: string, browser: NightwatchBrowser) { browser.execute(function (selector) { const items = document.querySelectorAll(selector) const ret = [] @@ -68,6 +87,5 @@ function listSelectorContains (textsToFind: string[], selector: string, browser: console.log('testing `' + result.value[k] + '` against `' + textsToFind[k] + '`') browser.assert.equal(result.value[k].indexOf(textsToFind[k]) !== -1, true) } - callback() }) } diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index c9be9bc3a1..f7665c41f6 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -519,6 +519,8 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {