fix e2e: force select checkbox

yann300-patch-33
yann300 3 years ago
parent bdf6088aca
commit b6fe36fc1e
  1. 15
      apps/remix-ide-e2e/src/commands/clickElementAtPosition.ts
  2. 2
      apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts
  3. 2
      apps/remix-ide-e2e/src/types/index.d.ts

@ -2,9 +2,9 @@ import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events' import EventEmitter from 'events'
class ClickElement extends EventEmitter { class ClickElement extends EventEmitter {
command (this: NightwatchBrowser, cssSelector: string, index = 0): NightwatchBrowser { command (this: NightwatchBrowser, cssSelector: string, index = 0 , opt = { forceSelectIfUnselected: false }): NightwatchBrowser {
this.api.perform((done) => { this.api.perform((done) => {
_clickElement(this.api, cssSelector, index, () => { _clickElement(this.api, cssSelector, index, opt.forceSelectIfUnselected, () => {
done() done()
this.emit('complete') this.emit('complete')
}) })
@ -13,13 +13,14 @@ class ClickElement extends EventEmitter {
} }
} }
function _clickElement (browser: NightwatchBrowser, cssSelector: string, index: number, cb: VoidFunction) { function _clickElement (browser: NightwatchBrowser, cssSelector: string, index: number, forceSelectIfUnselected: boolean, cb: VoidFunction) {
browser.waitForElementPresent(cssSelector) browser.waitForElementPresent(cssSelector)
.execute(function (cssSelector: string, index: number) { .execute(function (cssSelector: string, index: number, forceSelectIfUnselected: boolean) {
const elem = document.querySelectorAll(cssSelector)[index] as HTMLElement const elem = document.querySelectorAll(cssSelector)[index] as HTMLElement
if (forceSelectIfUnselected) {
elem.click() if (!(elem as any).checked) elem.click()
}, [cssSelector, index], function () { } else elem.click()
}, [cssSelector, index, forceSelectIfUnselected], function () {
cb() cb()
}) })
} }

@ -140,7 +140,7 @@ module.exports = {
.clickLaunchIcon('solidityUnitTesting') .clickLaunchIcon('solidityUnitTesting')
.setValue('*[data-id="uiPathInput"]', 'myTests') .setValue('*[data-id="uiPathInput"]', 'myTests')
.click('*[data-id="testTabGenerateTestFolder"]') .click('*[data-id="testTabGenerateTestFolder"]')
.clickElementAtPosition('.singleTestLabel', 0) .clickElementAtPosition('.singleTestLabel', 0, { forceSelectIfUnselected: true })
.scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]') .scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]')
.waitForElementPresent('*[data-id="testTabSolidityUnitTestsOutputheader"]', 60000) .waitForElementPresent('*[data-id="testTabSolidityUnitTestsOutputheader"]', 60000)
.waitForElementPresent('*[data-id="testTabSolidityUnitTestsOutput"]') .waitForElementPresent('*[data-id="testTabSolidityUnitTestsOutput"]')

@ -46,7 +46,7 @@ declare module 'nightwatch' {
setupMetamask(passphrase: string, password: string): NightwatchBrowser, setupMetamask(passphrase: string, password: string): NightwatchBrowser,
signMessage(msg: string, callback: (hash: { value: string }, signature: { value: string }) => void): NightwatchBrowser, signMessage(msg: string, callback: (hash: { value: string }, signature: { value: string }) => void): NightwatchBrowser,
setSolidityCompilerVersion(version: string): NightwatchBrowser, setSolidityCompilerVersion(version: string): NightwatchBrowser,
clickElementAtPosition(cssSelector: string, index: number): NightwatchBrowser, clickElementAtPosition(cssSelector: string, index: number, opt?: { forceSelectIfUnselected: boolean }): NightwatchBrowser,
notContainsText(cssSelector: string, text: string): NightwatchBrowser, notContainsText(cssSelector: string, text: string): NightwatchBrowser,
sendLowLevelTx(address: string, value: string, callData: string): NightwatchBrowser, sendLowLevelTx(address: string, value: string, callData: string): NightwatchBrowser,
journalLastChild(val: string): NightwatchBrowser, journalLastChild(val: string): NightwatchBrowser,

Loading…
Cancel
Save