From 2ac7488df6bf3fd565d195046becbc88d8093a17 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 2 Nov 2021 13:00:52 +0100 Subject: [PATCH] add shouldHaveOnlyOneOccurence param in e2e test command --- apps/remix-ide-e2e/src/commands/journalChildIncludes.ts | 4 ++-- apps/remix-ide-e2e/src/tests/terminal.test.ts | 6 +++--- apps/remix-ide-e2e/src/types/index.d.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/remix-ide-e2e/src/commands/journalChildIncludes.ts b/apps/remix-ide-e2e/src/commands/journalChildIncludes.ts index 5f8e096cd7..689be3bf34 100644 --- a/apps/remix-ide-e2e/src/commands/journalChildIncludes.ts +++ b/apps/remix-ide-e2e/src/commands/journalChildIncludes.ts @@ -5,7 +5,7 @@ import EventEmitter from 'events' Checks if any child elements of journal (console) contains a matching value. */ class JournalChildIncludes extends EventEmitter { - command (this: NightwatchBrowser, val: string): NightwatchBrowser { + command (this: NightwatchBrowser, val: string, opts = { shouldHaveOnlyOneOccurence: false }): NightwatchBrowser { let isTextFound = false const browser = this.api let occurence = 0 @@ -25,7 +25,7 @@ class JournalChildIncludes extends EventEmitter { }) 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(occurence === 1, `${occurence} occurence found of "${val}"`) + if (opts.shouldHaveOnlyOneOccurence) browser.assert.ok(occurence === 1, `${occurence} occurence found of "${val}"`) this.emit('complete') }) return this diff --git a/apps/remix-ide-e2e/src/tests/terminal.test.ts b/apps/remix-ide-e2e/src/tests/terminal.test.ts index d374724aa7..b30bb5e8da 100644 --- a/apps/remix-ide-e2e/src/tests/terminal.test.ts +++ b/apps/remix-ide-e2e/src/tests/terminal.test.ts @@ -140,16 +140,16 @@ module.exports = { .selectContract('OwnerTest') .createContract('') .pause(1000) - .journalChildIncludes('constructor') + .journalChildIncludes('constructor', { shouldHaveOnlyOneOccurence: true }) .pause(5000) .click('*[data-id="terminalClearConsole"]') // clear the terminal .clickInstance(0) .clickFunction('changeOwner - transact (not payable)', { types: 'address newOwner', values: '0xd9145CCE52D386f254917e481eB44e9943F39138' }) .pause(1000) - .journalChildIncludes('inside changeOwner') + .journalChildIncludes('inside changeOwner', { shouldHaveOnlyOneOccurence: true }) .clickFunction('getOwner - call') .pause(1000) - .journalChildIncludes('inside getOwner') + .journalChildIncludes('inside getOwner', { shouldHaveOnlyOneOccurence: true }) .end() } } diff --git a/apps/remix-ide-e2e/src/types/index.d.ts b/apps/remix-ide-e2e/src/types/index.d.ts index 7033bf2057..f5f9287065 100644 --- a/apps/remix-ide-e2e/src/types/index.d.ts +++ b/apps/remix-ide-e2e/src/types/index.d.ts @@ -23,7 +23,7 @@ declare module 'nightwatch' { journalLastChildIncludes(val: string): NightwatchBrowser, executeScript(script: string): NightwatchBrowser, clearEditableContent(cssSelector: string): NightwatchBrowser, - journalChildIncludes(val: string): NightwatchBrowser, + journalChildIncludes(val: string, opts = { shouldHaveOnlyOneOccurence: boolean }): NightwatchBrowser, debugTransaction(index: number): NightwatchBrowser, checkElementStyle(cssSelector: string, styleProperty: string, expectedResult: string): NightwatchBrowser, openFile(name: string): NightwatchBrowser,