From 2fb843f5b0c969d807bee377fc6936e712f4a8d2 Mon Sep 17 00:00:00 2001 From: Gina Contrino Date: Tue, 17 Oct 2017 11:43:29 +0200 Subject: [PATCH 1/4] Add toaster and e2e test --- features/login.feature | 9 +++++++++ src/actions/peers.js | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/features/login.feature b/features/login.feature index ba3189ef2..39d3e2963 100644 --- a/features/login.feature +++ b/features/login.feature @@ -5,6 +5,15 @@ Feature: Login page And I click "login button" Then I should be logged in + Scenario: should show toast when trying to connect to an unavailable custom node + Given I'm on login page + When I fill in "wagon stock borrow episode laundry kitten salute link globe zero feed marble" to "passphrase" field + And I select option no. 3 from "network" select + And I fill in "localhost:4218" to "address" field + And I click "login button" + And I wait 1 seconds + Then I should see text "Unable to connect to the node" in "toast" element + Scenario: should allow to login to Mainnet Given I'm on login page When I fill in "wagon stock borrow episode laundry kitten salute link globe zero feed marble" to "passphrase" field diff --git a/src/actions/peers.js b/src/actions/peers.js index 60131e2b5..98324b2cb 100644 --- a/src/actions/peers.js +++ b/src/actions/peers.js @@ -1,6 +1,8 @@ +import i18next from 'i18next'; import Lisk from 'lisk-js'; import actionTypes from '../constants/actions'; import { getNethash } from './../utils/api/nethash'; +import { errorToastDisplayed } from './toaster'; const peerSet = (data, config) => ({ data: Object.assign({ @@ -41,6 +43,8 @@ export const activePeerSet = data => getNethash(Lisk.api(config)).then((response) => { config.nethash = response.nethash; dispatch(peerSet(data, config)); + }).catch(() => { + dispatch(errorToastDisplayed({ label: i18next.t('Unable to connect to the node') })); }); } else { dispatch(peerSet(data, config)); From 651146f12aaadfa1154cac9df13a67792cff1510 Mon Sep 17 00:00:00 2001 From: Gina Contrino Date: Tue, 17 Oct 2017 16:56:19 +0200 Subject: [PATCH 2/4] Fix failing test due to not cleared input field --- features/login.feature | 2 +- features/step_definitions/generic.step.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/features/login.feature b/features/login.feature index 39d3e2963..bd74c3567 100644 --- a/features/login.feature +++ b/features/login.feature @@ -9,7 +9,7 @@ Feature: Login page Given I'm on login page When I fill in "wagon stock borrow episode laundry kitten salute link globe zero feed marble" to "passphrase" field And I select option no. 3 from "network" select - And I fill in "localhost:4218" to "address" field + When I fill in an incorrect address And I click "login button" And I wait 1 seconds Then I should see text "Unable to connect to the node" in "toast" element diff --git a/features/step_definitions/generic.step.js b/features/step_definitions/generic.step.js index 865c6fdfe..48622b0bc 100644 --- a/features/step_definitions/generic.step.js +++ b/features/step_definitions/generic.step.js @@ -129,6 +129,11 @@ defineSupportCode(({ Given, When, Then, setDefaultTimeout }) => { waitForElemAndCheckItsText(selectorClass, text, callback); }); + When('I fill in an incorrect address', () => { + browser.executeScript('window.document.querySelector(".address input").value = "";'); + waitForElemAndSendKeys('.address input, .address textarea', 'http://localhost:4039'); + }); + Given('I\'m logged in as "{accountName}"', (accountName, callback) => { browser.ignoreSynchronization = true; browser.driver.manage().window().setSize(1000, 1000); From 5027ae7c6864a5da619e92b0791224b0430d230f Mon Sep 17 00:00:00 2001 From: Gina Contrino Date: Wed, 18 Oct 2017 08:25:45 +0200 Subject: [PATCH 3/4] Make clearing a field for e2e tests reusable --- features/login.feature | 3 ++- features/step_definitions/generic.step.js | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/features/login.feature b/features/login.feature index bd74c3567..d7f939c16 100644 --- a/features/login.feature +++ b/features/login.feature @@ -9,7 +9,8 @@ Feature: Login page Given I'm on login page When I fill in "wagon stock borrow episode laundry kitten salute link globe zero feed marble" to "passphrase" field And I select option no. 3 from "network" select - When I fill in an incorrect address + When I clear "address" field + And I fill in "http://localhost:4218" to "address" field And I click "login button" And I wait 1 seconds Then I should see text "Unable to connect to the node" in "toast" element diff --git a/features/step_definitions/generic.step.js b/features/step_definitions/generic.step.js index 48622b0bc..ce97f337c 100644 --- a/features/step_definitions/generic.step.js +++ b/features/step_definitions/generic.step.js @@ -129,9 +129,9 @@ defineSupportCode(({ Given, When, Then, setDefaultTimeout }) => { waitForElemAndCheckItsText(selectorClass, text, callback); }); - When('I fill in an incorrect address', () => { - browser.executeScript('window.document.querySelector(".address input").value = "";'); - waitForElemAndSendKeys('.address input, .address textarea', 'http://localhost:4039'); + When('I clear "{elementName}" field', (elementName) => { + const selectorClass = `.${elementName.replace(/ /g, '-')}`; + browser.executeScript(`window.document.querySelector("${selectorClass} input, ${selectorClass} textarea").value = "";`); }); Given('I\'m logged in as "{accountName}"', (accountName, callback) => { From 0b56732d73912708b710b40e0f08bef5163842e2 Mon Sep 17 00:00:00 2001 From: Gina Contrino Date: Wed, 18 Oct 2017 08:52:02 +0200 Subject: [PATCH 4/4] Exchange 'when' with 'and' --- features/login.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/login.feature b/features/login.feature index d7f939c16..8f4260292 100644 --- a/features/login.feature +++ b/features/login.feature @@ -9,7 +9,7 @@ Feature: Login page Given I'm on login page When I fill in "wagon stock borrow episode laundry kitten salute link globe zero feed marble" to "passphrase" field And I select option no. 3 from "network" select - When I clear "address" field + And I clear "address" field And I fill in "http://localhost:4218" to "address" field And I click "login button" And I wait 1 seconds