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

Commit

Permalink
Set up end-to-end tests with protractor #41
Browse files Browse the repository at this point in the history
  • Loading branch information
Vit Stanislav authored and Vit Stanislav committed Mar 3, 2017
1 parent 6ee05fc commit a9e14a9
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,28 @@ Build package for Linux.
npm run dist:linux
```

## Run end-to-end tests

### Setup
As described on http://www.protractortest.org/#/ run:
```
npm install -g protractor
webdriver-manager update
webdriver-manager start
```

### Run
As described on http://www.protractortest.org/#/ run:
Start the development version as described above.

Run the tests:
```
cd src
protractor spec/conf.js
```



## Authors

Ricardo Ferro <[email protected]>
Expand Down
7 changes: 7 additions & 0 deletions src/spec/conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js'],
capabilities: {
browserName: 'chrome'
}
};
60 changes: 60 additions & 0 deletions src/spec/spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
var testAcocunt = {
passphrase: 'stay undo beyond powder sand laptop grow gloom apology hamster primary arrive',
address: '5932438298200837883L',
};
var EC = protractor.ExpectedConditions;

describe('Lisk Nano functionality', function() {
it('should allow to login', testLogin);
it('should allow to logout', testLogout);
it('should allow to create a new account', testUndefined);
it('should show address', testAddress);
it('should show peer', testUndefined);
it('should allow to change peer', testUndefined);
it('should show balance', testUndefined);
it('should allow to send transaction when enough funds and correct address form', testUndefined);
it('should not allow to send transaction when not enough funds', testUndefined);
it('should not allow to send transaction when incorrect address form', testUndefined);
it('should show transactions', testUndefined);
it('should allow to load more transactions', testUndefined);
});


function testUndefined() {
throw 'Not defined yet.';
}

function testLogin() {
login(testAcocunt);

var elem = element(by.css('.logout'));
browser.wait(EC.presenceOf(elem), 10000);
expect(elem.getText()).toEqual('LOGOUT');
}

function testLogout() {
login(testAcocunt);

var logoutButton = element(by.css('.logout'));
browser.wait(EC.presenceOf(logoutButton), 10000);
logoutButton.click();

var loginButton = element(by.css('.md-button.md-primary.md-raised'));
browser.wait(EC.presenceOf(loginButton), 10000);
expect(loginButton.getText()).toEqual('LOGIN');
}

function testAddress() {
login(testAcocunt);

var addressElem = element(by.css('.address'));
browser.wait(EC.presenceOf(addressElem), 10000);
expect(addressElem.getText()).toEqual(testAcocunt.address);
}

function login(account) {
browser.ignoreSynchronization = true;
browser.get('http://localhost:8080');
element(by.css('input[type="password"]')).sendKeys(account.passphrase);
element(by.css('.md-button.md-primary.md-raised')).click();
}

0 comments on commit a9e14a9

Please sign in to comment.