Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Fix and enable saved accounts e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Nov 8, 2017
1 parent 097fcd8 commit 0732679
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 66 deletions.
103 changes: 40 additions & 63 deletions features/accountManagement.feature
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Feature: Account management
Scenario: should allow to save account locally, after page reload it should require passphrase to do the first transaction, and remember the passphrase for next transactions
Given I'm logged in as "genesis"
When I click "save account" in main menu
And I click "save account button"
When I click "saved accounts" in main menu
And I click "add active account button"
And I click "x button"
And I wait 1 seconds
And I should see text "Account saved" in "toast" element
And I refresh the page
Expand All @@ -22,83 +23,59 @@ Feature: Account management
And I click "submit button"
And I should see alert dialog with title "Success" and text "Your transaction of 2 LSK to 537318935439898807L was accepted and will be processed in a few seconds."

Scenario: should allow to forget locally saved account
Given I'm logged in as "any account"
When I click "save account" in main menu
And I click "save account button"
And I refresh the page
And I wait 2 seconds
And I click "forget account" in main menu
And I wait 1 seconds
Then I should see text "Account was successfully forgotten." in "toast" element
And I refresh the page
And I should be on login page

Scenario: should allow to exit save account dialog with "cancel button"
Given I'm logged in as "any account"
When I click "save account" in main menu
And I click "cancel button"
Then I should see no "modal dialog"

Scenario: should allow to exit save account dialog with "x button"
Given I'm logged in as "any account"
When I click "save account" in main menu
And I click "x button"
Then I should see no "modal dialog"

@pending
Scenario: should allow to save second account
Given I'm logged in as "genesis"
When I click "save account" in main menu
And I click "save account button"
When I click "saved accounts" in main menu
And I click "add active account button"
And I click "x button"
And I log out
And I log in as "delegate"
And I click "save account" in main menu
And I click "save account button"
Then I should see table with 2 lines
And I wait 1 seconds
And I click "logout button"
And I'm logged in as "delegate"
And I click "saved accounts" in main menu
And I click "add active account button"
Then I should see "saved accounts table" table with 2 lines
And I refresh the page
And I wait 2 seconds
And I should be logged in as "genesis" account

@pending
Scenario: should allow to forget second account
Given I'm logged in as "genesis"
When I click "save account" in main menu
And I click "save account button"
When I click "saved accounts" in main menu
And I click "add active account button"
And I click "x button"
And I log out
And I log in as "delegate"
And I click "save account" in main menu
And I click "save account button"
And I should see table with 2 lines
And I click "forget account button"
Then I should see table with 1 lines
And I wait 1 seconds
And I click "logout button"
And I'm logged in as "delegate"
And I click "saved accounts" in main menu
And I click "add active account button"
And I should see "saved accounts table" table with 2 lines
And I click "forget button"
Then I should see "saved accounts table" table with 1 lines

@pending
Scenario: should allow to switch account
Given I'm logged in as "genesis"
When I click "save account" in main menu
And I click "save account button"
And I log out
And I log in as "delegate"
And I click "save account" in main menu
And I click "save account button"
When I click "saved accounts" in main menu
And I click "add active account button"
And I click "x button"
And I select option no. 1 from "account" select
And I should be logged in as "delegate" account
And I wait 1 seconds
And I click "logout button"
And I'm logged in as "delegate"
And I click "saved accounts" in main menu
And I click "add active account button"
And I click "switch button"
And I wait 1 seconds
And I should be logged in as "genesis" account

@pending
Scenario: should allow to set default account
Scenario: should login to last active saved account
Given I'm logged in as "genesis"
When I click "save account" in main menu
And I click "save account button"
When I click "saved accounts" in main menu
And I click "add active account button"
And I click "x button"
And I log out
And I log in as "delegate"
And I click "save account" in main menu
And I click "save account button"
And I click "set as default button"
And I select option no. 1 from "account" select
And I wait 1 seconds
And I click "logout button"
And I'm logged in as "delegate"
And I click "saved accounts" in main menu
And I click "add active account button"
And I refresh the page
And I should be logged in as "genesis" account
And I should be logged in as "delegate" account
12 changes: 11 additions & 1 deletion features/step_definitions/generic.step.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ defineSupportCode(({ Given, When, Then, setDefaultTimeout }) => {
.and.notify(callback);
});

Then('I should see "{elementName}" table with {lineCount} lines', (elementName, lineCount, callback) => {
browser.sleep(500);
expect(element.all(by.css(`table.${elementName.replace(/ /g, '-')} tbody tr`)).count()).to.eventually.equal(parseInt(lineCount, 10))
.and.notify(callback);
});


Then('I should see no "{elementName}"', (elementName, callback) => {
const selector = `.${elementName.replace(/ /g, '-')}`;
waitForElemRemoved(selector).then(() => {
Expand Down Expand Up @@ -139,7 +146,6 @@ defineSupportCode(({ Given, When, Then, setDefaultTimeout }) => {
});

Given('I\'m logged in as "{accountName}"', { timeout: 2 * defaultTimeout }, (accountName, callback) => {
browser.get(browser.params.baseURL);
const passphrase = browser.params.useTestnetPassphrase
? browser.params.testnetPassphrase
: accounts[accountName].passphrase;
Expand Down Expand Up @@ -203,5 +209,9 @@ defineSupportCode(({ Given, When, Then, setDefaultTimeout }) => {
Then('I should be logged in', (callback) => {
waitForElemAndCheckItsText('.logout-button', 'LOGOUT', callback);
});

Then('I should be logged in as "{accountName}" account', (accountName, callback) => {
waitForElemAndCheckItsText('.full.address', accounts[accountName].address, callback);
});
});

1 change: 1 addition & 0 deletions features/step_definitions/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ defineSupportCode(({ Before, After }) => {
localStorage.clear();
localStorage.setItem('address', browser.params.liskCoreURL);
localStorage.setItem('network', networks[browser.params.network].code);
browser.get(browser.params.baseURL);
callback();
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const Header = props => (
</MenuItem>
<MenuDivider />
<MenuItem theme={styles}>
<RelativeLink className={`${styles.menuLink} save-account`}
<RelativeLink className={`${styles.menuLink} saved-accounts`}
to='saved-accounts'>{props.t('Saved accounts')}</RelativeLink>
</MenuItem>
<MenuItem theme={styles}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/saveAccount/saveAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const SaveAccount = ({
{t('This will save public key of your account on this device, so next time it will launch without the need to log in. However, you will be prompted to enter the passphrase once you want to do any transaction.')}
</InfoParagraph> :
<div style={{ margin: '-24px -24px 24px -24px' }} >
<Table selectable={false}>
<Table selectable={false} className='saved-accounts-table'>
<TableHead>
<TableCell style={{ width: 20 }} >{t('Switch')}</TableCell>
<TableCell>{t('Address')}</TableCell>
Expand Down

0 comments on commit 0732679

Please sign in to comment.