Skip to content

Commit f6c93a0

Browse files
ci-bothsy822
authored andcommitted
fix e2e test code
1 parent 74b018c commit f6c93a0

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

apps/remix-ide-e2e/src/commands/switchEnvironment.ts

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict'
12
import { NightwatchBrowser } from 'nightwatch'
23
import EventEmitter from 'events'
34

@@ -80,29 +81,27 @@ class switchEnvironment extends EventEmitter {
8081
}
8182
browser
8283
.execute(function(xpath) {
83-
const element = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
84-
if (element) {
85-
const event = new MouseEvent('mouseover', { 'view': window, 'bubbles': true, 'cancelable': true })
86-
element.dispatchEvent(event)
87-
}
88-
},
89-
[submenuXPath]
90-
)
84+
const element = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
85+
if (element) {
86+
const event = new MouseEvent('mouseover', { 'view': window, 'bubbles': true, 'cancelable': true })
87+
element.dispatchEvent(event)
88+
}
89+
},
90+
[submenuXPath]
91+
)
9192
.useCss()
92-
.waitForElementVisible(
93-
`body .dropdown-menu.show [data-id="dropdown-item-${providerName}"]`,
94-
5000,
95-
undefined,
96-
false,
97-
(result) => {
98-
if (result.status === 0) {
93+
.isPresent({
94+
selector: `body .dropdown-menu.show [data-id="dropdown-item-${providerName}"]`,
95+
suppressNotFoundErrors: true,
96+
timeout: 2000
97+
}, (inPortal) => {
98+
if (inPortal.value) {
9999
clickAndMaybeWait(browser, `body .dropdown-menu.show [data-id="dropdown-item-${providerName}"]`, providerName, shouldWait)
100100
onDone()
101101
} else {
102102
tryOne(i + 1)
103103
}
104-
}
105-
)
104+
})
106105
})
107106
}
108107
tryOne(0)
@@ -133,19 +132,21 @@ class switchEnvironment extends EventEmitter {
133132
.perform((done) => {
134133
this.api.isPresent({ selector: `[data-id="selected-provider-${provider}"]`, suppressNotFoundErrors: true, timeout: 1000 }, (result) => {
135134
if (result.value) return done()
136-
135+
137136
this.api.click('[data-id="settingsSelectEnvOptions"] button')
138-
139-
attemptSelect(this.api, provider, returnWhenInitialized, () => {
140-
waitForSelectedOrModal(this.api, provider, 10000, (ok) => {
141-
if (ok) {
142-
return done()
143-
} else {
144-
this.api.assert.fail(`Environment "${provider}" could not be selected or found in the dropdown.`)
145-
done()
146-
}
137+
.waitForElementVisible('body .dropdown-menu.show', 3000)
138+
.perform(() => {
139+
attemptSelect(this.api, provider, returnWhenInitialized, () => {
140+
waitForSelectedOrModal(this.api, provider, 10000, (ok) => {
141+
if (ok) {
142+
return done()
143+
} else {
144+
this.api.assert.fail(`Environment "${provider}" could not be selected or found in the dropdown.`)
145+
done()
146+
}
147+
})
148+
})
147149
})
148-
})
149150
})
150151
})
151152
.perform(() => this.emit('complete'))
@@ -154,4 +155,4 @@ class switchEnvironment extends EventEmitter {
154155
}
155156
}
156157

157-
module.exports = switchEnvironment
158+
module.exports = switchEnvironment

0 commit comments

Comments
 (0)