Skip to content

Commit d2c01cc

Browse files
author
ci-bot
committed
fix test
1 parent b608d51 commit d2c01cc

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

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

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,46 @@ import EventEmitter from 'events'
44
class WaitForElementContainsText extends EventEmitter {
55
command (this: NightwatchBrowser, id: string, value: string, timeout = 10000): NightwatchBrowser {
66
let waitId // eslint-disable-line
7-
let currentValue
8-
const runid = setInterval(() => {
9-
this.api.getText(id, (result) => {
10-
currentValue = result.value
11-
if (typeof result.value === 'string' && result.value.indexOf(value) !== -1) {
12-
clearInterval(runid)
13-
clearTimeout(waitId)
14-
this.api.assert.ok(true, `WaitForElementContainsText ${id} contains ${value}`)
15-
this.emit('complete')
7+
let currentValues: string[] = []
8+
const runid = setInterval(async () => {
9+
const elements = await this.api.findElements('css selector', id)
10+
11+
if (elements.length === 0) {
12+
currentValues = []
13+
return
14+
}
15+
16+
// Check all elements that match the selector
17+
let foundMatch = false
18+
const textValues: string[] = []
19+
20+
for (const element of elements) {
21+
let text
22+
this.api.getText(element.getId(), (result) => {
23+
text = typeof result === 'string' ? result : result.value
24+
currentValues.push(text)
25+
})
26+
27+
if (typeof text === 'string' && text.indexOf(value) !== -1) {
28+
foundMatch = true
29+
break
1630
}
17-
})
31+
}
32+
33+
currentValues = textValues
34+
35+
if (foundMatch) {
36+
clearInterval(runid)
37+
clearTimeout(waitId)
38+
this.api.assert.ok(true, `WaitForElementContainsText ${id} contains ${value}`)
39+
this.emit('complete')
40+
}
1841
}, 200)
1942

2043
waitId = setTimeout(() => {
2144
clearInterval(runid)
22-
this.api.assert.fail(`TimeoutError: An error occurred while running .waitForElementContainsText() command on ${id} after ${timeout} milliseconds. expected: ${value} - got: ${currentValue}`)
45+
const valuesFound = currentValues.length > 0 ? currentValues.join(', ') : 'none'
46+
this.api.assert.fail(`TimeoutError: An error occurred while running .waitForElementContainsText() command on ${id} after ${timeout} milliseconds. expected: ${value} - got: ${valuesFound}`)
2347
}, timeout)
2448
return this
2549
}

apps/remix-ide-e2e/src/tests/url.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,14 @@ module.exports = {
384384
.openFile('contracts/governance/UnionGovernor.sol')
385385
},
386386

387-
'Should execute function call from URL parameters #group3': function (browser: NightwatchBrowser) {
387+
'Should execute function call from URL parameters #group3 #pr': function (browser: NightwatchBrowser) {
388388
browser
389389
.switchWorkspace('default_workspace')
390390
.url('http://127.0.0.1:8080?calls=fileManager//open//contracts/3_Ballot.sol///terminal//log//log')
391391
.refreshPage()
392392
.waitForElementVisible('*[data-shared="tooltipPopup"]')
393393
.waitForElementContainsText('*[data-shared="tooltipPopup"]', 'initiating fileManager and calling "open" ...')
394-
.waitForElementContainsText('*[data-shared="tooltipPopup"]', 'initiating terminal and calling "log" ...')
394+
.waitForElementContainsText('*[data-shared="tooltipPopup"]:nth-of-type(2)', 'initiating terminal and calling "log" ...', 10000, 1)
395395
},
396396

397397
'Import Github folder from URL params #group4': function (browser: NightwatchBrowser) {

apps/remix-ide-e2e/src/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ declare module 'nightwatch' {
3535
renamePath(path: string, newFileName: string, renamedPath: string): NightwatchBrowser
3636
rightClickCustom(cssSelector: string): NightwatchBrowser
3737
scrollToLine(line: number): NightwatchBrowser
38-
waitForElementContainsText(id: string, value: string, timeout?: number): NightwatchBrowser
38+
waitForElementContainsText(id: string, value: string, timeout?: number, index?: number): NightwatchBrowser
3939
getModalBody(callback: (value: string, cb: VoidFunction) => void): NightwatchBrowser
4040
modalFooterCancelClick(id?: string): NightwatchBrowser
4141
selectContract(contractName: string): NightwatchBrowser

0 commit comments

Comments
 (0)