From b579f5e38c938836b32f59708ebdb326059003b0 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Wed, 8 Sep 2021 15:10:17 +0530 Subject: [PATCH] e2e tests for hh logs in SUT plugin --- .../src/tests/solidityUnittests.spec.ts | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts index 99ccb1b0b8..4d4f1a4abf 100644 --- a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts +++ b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts @@ -187,6 +187,32 @@ module.exports = { }, <<<<<<< HEAD +<<<<<<< HEAD +======= + 'Solidity Unit tests with hardhat console log': function (browser: NightwatchBrowser) { + browser + .waitForElementPresent('*[data-id="verticalIconsKindfilePanel"]') + .addFile('tests/hhLogs_test.sol', sources[0]['tests/hhLogs_test.sol']) + .clickLaunchIcon('solidityUnitTesting') + .waitForElementVisible('*[id="singleTesttests/4_Ballot_test.sol"]', 60000) + .click('*[id="singleTesttests/4_Ballot_test.sol"]') + .click('#runTestsTabRunAction') + .pause(2000) + .waitForElementVisible('*[data-id="testTabSolidityUnitTestsOutputheader"]', 120000) + .waitForElementPresent('#solidityUnittestsOutput div[class^="testPass"]', 60000) + .waitForElementContainsText('#solidityUnittestsOutput', 'tests/hhLogs_test.sol', 60000) + .assert.containsText('#journal > div:nth-child(3) > span > div', 'Before all:') + .assert.containsText('#journal > div:nth-child(3) > span > div', 'Inside beforeAll') + .assert.containsText('#journal > div:nth-child(4) > span > div', 'Check sender:') + .assert.containsText('#journal > div:nth-child(4) > span > div', 'msg.sender is 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4') + .assert.containsText('#journal > div:nth-child(5) > span > div', 'Check int logs:') + .assert.containsText('#journal > div:nth-child(5) > span > div', '10 20') + .assert.containsText('#journal > div:nth-child(5) > span > div', 'Number is 25') + .openFile('tests/hhLogs_test.sol') + .removeFile('tests/hhLogs_test.sol', 'workspace_new') + }, + +>>>>>>> 348f2d6ab (e2e tests for hh logs in SUT plugin) 'Debug failed test using debugger': function (browser: NightwatchBrowser) { browser .waitForElementPresent('*[data-id="verticalIconsKindfilePanel"]') @@ -466,6 +492,31 @@ const sources = [ return ballotToTest.winningProposal() == 0; } }` + }, + 'tests/hhLogs_test.sol': { + content: `// SPDX-License-Identifier: GPL-3.0 + + pragma solidity >=0.7.0 <0.9.0; + import "remix_tests.sol"; // this import is automatically injected by Remix. + import "hardhat/console.sol"; + + contract hhLogs { + + function beforeAll () public { + console.log('Inside beforeAll'); + } + + function checkSender () public { + console.log('msg.sender is %s', msg.sender); + Assert.ok(true, "should be true"); + } + + function checkIntLogs () public { + console.log(10,20); + console.log('Number is %d', 25); + Assert.ok(true, "should be true"); + } + }` } } ]