From adbe4d2d2931293549a60526ed08ed52b1fd2696 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Wed, 16 Dec 2020 14:08:18 +0100 Subject: [PATCH] added a command 'validateValueInput' added file --- .../src/commands/validateValueInput.ts | 22 ++++++++++ apps/remix-ide-e2e/src/tests/runAndDeploy.ts | 40 ++----------------- apps/remix-ide-e2e/src/types/index.d.ts | 3 +- 3 files changed, 28 insertions(+), 37 deletions(-) create mode 100644 apps/remix-ide-e2e/src/commands/validateValueInput.ts diff --git a/apps/remix-ide-e2e/src/commands/validateValueInput.ts b/apps/remix-ide-e2e/src/commands/validateValueInput.ts new file mode 100644 index 0000000000..640ead9f7a --- /dev/null +++ b/apps/remix-ide-e2e/src/commands/validateValueInput.ts @@ -0,0 +1,22 @@ +import { NightwatchBrowser } from 'nightwatch' +import EventEmitter from 'events' + +class ValidateValueInput extends EventEmitter { + command (this: NightwatchBrowser, selector: string, valueTosSet: string, expectedValue: string) { + const browser = this.api + browser.perform((done) => { + browser.clearValue(selector) + .setValue(selector, valueTosSet) + .execute(function (selector) { + const elem = document.querySelector(selector) as HTMLInputElement + return elem.value + }, [selector], function (result) { + browser.assert.equal(result.value, expectedValue) + done() + }) + }) + return this + } +} + +module.exports = ValidateValueInput diff --git a/apps/remix-ide-e2e/src/tests/runAndDeploy.ts b/apps/remix-ide-e2e/src/tests/runAndDeploy.ts index a5c07092d0..444ab314a0 100644 --- a/apps/remix-ide-e2e/src/tests/runAndDeploy.ts +++ b/apps/remix-ide-e2e/src/tests/runAndDeploy.ts @@ -27,42 +27,10 @@ module.exports = { 'Should load run and deploy tab and check value validation': function (browser: NightwatchBrowser) { browser.waitForElementPresent('*[data-id="remixIdeSidePanel"]') .assert.containsText('*[data-id="sidePanelSwapitTitle"]', 'DEPLOY & RUN TRANSACTIONS') - .clearValue('#value') - .setValue('#value', '0000') - .click('*[data-id="remixDRValueLabel"]') - .execute(function () { - const elem = document.getElementById('value') as HTMLInputElement - return elem.value - }, [], function (result) { - console.log('logging ', result) - browser.assert.equal(result.value, "0") - }) - .clearValue('#value') - .setValue('#value', '-44') - .execute(function () { - const elem = document.getElementById('value') as HTMLInputElement - return elem - }, [], function (result) { - console.log('loging ', result.value) - browser.assert.equal(result.value, "0") - }) - .clearValue('#value') - .setValue('#value', '') - .execute(function () { - const elem = document.getElementById('value') as HTMLInputElement - return elem - }, [], function (result) { - console.log('loging ', result.value) - browser.assert.equal(result.value, "0") - }) - .setValue('#value', 'dragon') - .execute(function () { - const elem = document.getElementById('value') as HTMLInputElement - return elem - }, [], function (result) { - console.log('loging ', result.value) - browser.assert.equal(result.value, "0") - }) + .validateValueInput('#value', '0000', '0') + .validateValueInput('#value', '-44', '0') + .validateValueInput('#value', '', '0') + .validateValueInput('#value', 'dragon', '0') }, 'Should sign message using account key': function (browser: NightwatchBrowser) { diff --git a/apps/remix-ide-e2e/src/types/index.d.ts b/apps/remix-ide-e2e/src/types/index.d.ts index d8ed811bc9..afd92f7e2f 100644 --- a/apps/remix-ide-e2e/src/types/index.d.ts +++ b/apps/remix-ide-e2e/src/types/index.d.ts @@ -51,7 +51,8 @@ declare module "nightwatch" { sendLowLevelTx(address: string, value: string, callData: string): NightwatchBrowser, journalLastChild(val: string): NightwatchBrowser, checkTerminalFilter(filter: string, test: string): NightwatchBrowser, - noWorkerErrorFor(version: string): NightwatchBrowser + noWorkerErrorFor(version: string): NightwatchBrowser, + validateValueInput(selector: string, valueTosSet: string, expectedValue: string): NightwatchBrowser } export interface NightwatchBrowser {