hover tests

editorcontextDummy
filip mertens 3 years ago
parent 833e1372ca
commit 323c59e3cc
  1. 149
      apps/remix-ide-e2e/src/tests/editorHoverContext.test.ts

@ -2,88 +2,86 @@
import { NightwatchBrowser } from 'nightwatch' import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init' import init from '../helpers/init'
const checkEditorHoverContent = (browser: NightwatchBrowser, path: string, expectedContent: string, offsetLeft: number = 0) => {
browser.useXpath()
.useXpath()
.moveToElement('//body', 0, 0) // always move away from the hover before the next test in case we hover in the same line on a different element
.waitForElementVisible(path)
.moveToElement(path, offsetLeft, 0)
.useCss()
.waitForElementContainsText('.monaco-hover-content', expectedContent).pause(1000)
}
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)
}, },
'Should show hover over contract in editor #group1': function (browser: NightwatchBrowser) {
'Should load the test file': function (browser: NightwatchBrowser) {
browser.openFile('contracts') browser.openFile('contracts')
.openFile('contracts/3_Ballot.sol') .openFile('contracts/3_Ballot.sol')
.waitForElementVisible('#editorView') .waitForElementVisible('#editorView')
.setEditorValue(BallotWithARefToOwner) .setEditorValue(BallotWithARefToOwner)
.useXpath() .pause(4000) // wait for the compiler to finish
.waitForElementVisible("//*[contains(text(),'BallotHoverTest')]") },
.click("//*[contains(text(),'BallotHoverTest')]") 'Should show hover over contract in editor #group1': function (browser: NightwatchBrowser) {
//.moveToElement("//*[contains(text(),'BallotHoverTest')]", 0, 0) const path = "//*[contains(text(),'BallotHoverTest')]"
.useCss() checkEditorHoverContent(browser, path, 'contract BallotHoverTest is BallotHoverTest')
.findElements('.view-line', function (res) { checkEditorHoverContent(browser, path, 'contracts/3_Ballot.sol 10:0')
checkEditorHoverContent(browser, path, '@title Ballot')
if (Array.isArray(res.value)) { },
let found = false 'Should show hover over var definition in editor #group1': function (browser: NightwatchBrowser) {
for (const jsonWebElement of res.value) { const path = "//*[@class='view-line' and contains(.,'chairperson') and contains(.,'address') and contains(.,'public')]//span//span[contains(.,'chairperson')]"
const jsonWebElementId = jsonWebElement.ELEMENT || jsonWebElement[Object.keys(jsonWebElement)[0]] const expectedContent = 'address public chairperson'
if (!found) { checkEditorHoverContent(browser, path, expectedContent)
browser.elementIdText(jsonWebElementId, (jsonElement) => { },
'Should show hover over constructor in editor #group1': function (browser: NightwatchBrowser) {
const text = jsonElement.value const path: string = "//*[@class='view-line' and contains(.,'constructor') and contains(.,'bytes32') and contains(.,'memory')]//span//span[contains(.,'constructor')]"
if (typeof text == 'string') { const expectedContent = 'Estimated creation cost: infinite gas Estimated code deposit cost:'
checkEditorHoverContent(browser, path, expectedContent)
if (text.indexOf('contract BallotHoverTest') !== -1) { },
console.log(text) 'Should show hover over function in editor #group1': function (browser: NightwatchBrowser) {
console.log(jsonWebElementId) const path: string = "//*[@class='view-line' and contains(.,'giveRightToVote(address') and contains(.,'function') and contains(.,'public')]//span//span[contains(.,'giveRightToVote')]"
browser let expectedContent = 'Estimated execution cost'
browser.moveTo(jsonWebElementId, 0, 0).pause(20000) checkEditorHoverContent(browser, path, expectedContent)
found = true expectedContent = 'function giveRightToVote (address internal voter) public nonpayable returns ()'
} checkEditorHoverContent(browser, path, expectedContent)
} expectedContent = "@dev Give 'voter' the right to vote on this ballot. May only be called by 'chairperson'"
} checkEditorHoverContent(browser, path, expectedContent)
) },
} 'Should show hover over var components in editor #group1': function (browser: NightwatchBrowser) {
} let path = "//*[@class='view-line' and contains(.,'voters') and contains(.,'weight')]//span//span[contains(.,'voters')]"
/* let expectedContent = 'mapping(address => struct BallotHoverTest.Voter) public voters'
res.value.forEach(function (jsonWebElement) { checkEditorHoverContent(browser, path, expectedContent, 15)
path = "//*[@class='view-line' and contains(.,'voters') and contains(.,'weight')]//span//span[contains(.,'chairperson')]"
expectedContent = 'address public chairperson'
browser.elementIdText(jsonWebElementId, (jsonElement) => { checkEditorHoverContent(browser, path, expectedContent, 3)
path = "//*[@class='view-line' and contains(.,'voters') and contains(.,'weight')]//span//span[contains(.,'weight')]"
const text = jsonElement.value expectedContent = 'uint256 internal weight'
if (typeof text == 'string') { checkEditorHoverContent(browser, path, expectedContent)
},
if (text.indexOf('contract BallotHoverTest') !== -1) { 'Should show hover over new contract creation in editor #group1': function (browser: NightwatchBrowser) {
console.log(text) let path = "//*[@class='view-line' and contains(.,'Owner') and contains(.,'new')]//span//span[contains(.,'cowner')]"
console.log(jsonWebElementId) let expectedContent = 'contract Owner internal cowner'
browser.moveTo(jsonWebElementId, 0, 0).pause(20000) checkEditorHoverContent(browser, path, expectedContent, 10)
path = "//*[@class='view-line' and contains(.,'Owner') and contains(.,'new')]//span//span[contains(.,'Owner')]"
} expectedContent = 'contract Owner is Owner'
} checkEditorHoverContent(browser, path, expectedContent, 10)
}) },
})*/ 'Should show hover over external class member in editor #group1': function (browser: NightwatchBrowser) {
} const path = "//*[@class='view-line' and contains(.,'getOwner') and contains(.,'cowner')]//span//span[contains(.,'getOwner')]"
}) let expectedContent = 'function getOwner () external view returns (address internal )'
/* checkEditorHoverContent(browser, path, expectedContent, 0)
.useCss() expectedContent = 'contracts/2_Owner.sol'
.waitForElementContainsText('.monaco-hover-content', 'contract BallotHoverTest is BallotHoverTest') checkEditorHoverContent(browser, path, expectedContent, 0)
.waitForElementContainsText('.monaco-hover-content', 'contracts/3_Ballot.sol 10:0') expectedContent = '@dev Return owner address'
.waitForElementContainsText('.monaco-hover-content', '@title Ballot') checkEditorHoverContent(browser, path, expectedContent, 0)
.findElements('.view-line', function (res) { },
Array.isArray(res.value) && res.value.forEach(function (jsonWebElement) { 'Should show hover over struct definition in editor #group1': function (browser: NightwatchBrowser) {
const jsonWebElementId = jsonWebElement.ELEMENT || jsonWebElement[Object.keys(jsonWebElement)[0]] const path = "//*[@class='view-line' and contains(.,'Voter') and contains(.,'struct')]//span//span[contains(.,'Voter')]"
const expectedContent = 'StructDefinition'
browser.elementIdText(jsonWebElementId, (jsonElement) => { checkEditorHoverContent(browser, path, expectedContent)
const text = jsonElement.value
if (typeof text == 'string') {
if (text.indexOf('address public chairperson;') !== -1) {
console.log(jsonWebElementId)
browser.moveTo(jsonWebElementId, 20, 0).pause(20000)
}
}
})
})
})
*/
} }
} }
@ -100,7 +98,7 @@ import "./2_Owner.sol";
* @dev Implements voting process along with vote delegation * @dev Implements voting process along with vote delegation
*/ */
contract BallotHoverTest { contract BallotHoverTest {
Owner c; Owner cowner;
struct Voter { struct Voter {
uint weight; // weight is accumulated by delegation uint weight; // weight is accumulated by delegation
bool voted; // if true, that person already voted bool voted; // if true, that person already voted
@ -126,7 +124,8 @@ contract BallotHoverTest {
* @param proposalNames names of proposals * @param proposalNames names of proposals
*/ */
constructor(bytes32[] memory proposalNames) { constructor(bytes32[] memory proposalNames) {
c = new Owner(); cowner = new Owner();
cowner.getOwner();
chairperson = msg.sender; chairperson = msg.sender;
voters[chairperson].weight = 1; voters[chairperson].weight = 1;

Loading…
Cancel
Save