add shouldHaveOnlyOneOccurence param in e2e test command

pull/5370/head
yann300 3 years ago
parent ba1d2d886b
commit 2ac7488df6
  1. 4
      apps/remix-ide-e2e/src/commands/journalChildIncludes.ts
  2. 6
      apps/remix-ide-e2e/src/tests/terminal.test.ts
  3. 2
      apps/remix-ide-e2e/src/types/index.d.ts

@ -5,7 +5,7 @@ import EventEmitter from 'events'
Checks if any child elements of journal (console) contains a matching value. Checks if any child elements of journal (console) contains a matching value.
*/ */
class JournalChildIncludes extends EventEmitter { class JournalChildIncludes extends EventEmitter {
command (this: NightwatchBrowser, val: string): NightwatchBrowser { command (this: NightwatchBrowser, val: string, opts = { shouldHaveOnlyOneOccurence: false }): NightwatchBrowser {
let isTextFound = false let isTextFound = false
const browser = this.api const browser = this.api
let occurence = 0 let occurence = 0
@ -25,7 +25,7 @@ class JournalChildIncludes extends EventEmitter {
}) })
browser.perform(() => { browser.perform(() => {
browser.assert.ok(isTextFound, isTextFound ? `<*[data-id="terminalJournal"]> contains ${val}.` : `${val} not found in <*[data-id="terminalJournal"]> div:last-child>`) browser.assert.ok(isTextFound, isTextFound ? `<*[data-id="terminalJournal"]> contains ${val}.` : `${val} not found in <*[data-id="terminalJournal"]> div:last-child>`)
browser.assert.ok(occurence === 1, `${occurence} occurence found of "${val}"`) if (opts.shouldHaveOnlyOneOccurence) browser.assert.ok(occurence === 1, `${occurence} occurence found of "${val}"`)
this.emit('complete') this.emit('complete')
}) })
return this return this

@ -140,16 +140,16 @@ module.exports = {
.selectContract('OwnerTest') .selectContract('OwnerTest')
.createContract('') .createContract('')
.pause(1000) .pause(1000)
.journalChildIncludes('constructor') .journalChildIncludes('constructor', { shouldHaveOnlyOneOccurence: true })
.pause(5000) .pause(5000)
.click('*[data-id="terminalClearConsole"]') // clear the terminal .click('*[data-id="terminalClearConsole"]') // clear the terminal
.clickInstance(0) .clickInstance(0)
.clickFunction('changeOwner - transact (not payable)', { types: 'address newOwner', values: '0xd9145CCE52D386f254917e481eB44e9943F39138' }) .clickFunction('changeOwner - transact (not payable)', { types: 'address newOwner', values: '0xd9145CCE52D386f254917e481eB44e9943F39138' })
.pause(1000) .pause(1000)
.journalChildIncludes('inside changeOwner') .journalChildIncludes('inside changeOwner', { shouldHaveOnlyOneOccurence: true })
.clickFunction('getOwner - call') .clickFunction('getOwner - call')
.pause(1000) .pause(1000)
.journalChildIncludes('inside getOwner') .journalChildIncludes('inside getOwner', { shouldHaveOnlyOneOccurence: true })
.end() .end()
} }
} }

@ -23,7 +23,7 @@ declare module 'nightwatch' {
journalLastChildIncludes(val: string): NightwatchBrowser, journalLastChildIncludes(val: string): NightwatchBrowser,
executeScript(script: string): NightwatchBrowser, executeScript(script: string): NightwatchBrowser,
clearEditableContent(cssSelector: string): NightwatchBrowser, clearEditableContent(cssSelector: string): NightwatchBrowser,
journalChildIncludes(val: string): NightwatchBrowser, journalChildIncludes(val: string, opts = { shouldHaveOnlyOneOccurence: boolean }): NightwatchBrowser,
debugTransaction(index: number): NightwatchBrowser, debugTransaction(index: number): NightwatchBrowser,
checkElementStyle(cssSelector: string, styleProperty: string, expectedResult: string): NightwatchBrowser, checkElementStyle(cssSelector: string, styleProperty: string, expectedResult: string): NightwatchBrowser,
openFile(name: string): NightwatchBrowser, openFile(name: string): NightwatchBrowser,

Loading…
Cancel
Save