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

Move network selection to login module - Closes #89 #102

Merged
merged 12 commits into from
Apr 13, 2017
Merged
6 changes: 6 additions & 0 deletions src/app/components/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ app.component('login', {
this.$scope.$watch('$ctrl.$peers.currentPeerConfig', () => {
this.$peers.setActive(this.$peers.currentPeerConfig);
});

$scope.$watch('$ctrl.$peers.stack', (val) => {
if (val && !this.$peers.currentPeerConfig.node) {
this.$peers.setActive($peers.stack.official[0]);
}
});
}

reset() {
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/login/login.pug
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ md-card
md-card-content(flex='100', flex-gt-sm='70', flex-offset-gt-sm='15')
form(ng-submit='$ctrl.doTheLogin()')
md-input-container.md-block(md-is-error='$ctrl.valid === 0')
label.select Choose your network
label.select Choose your network node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would phrase it as: Choose a peer.

Also, upon logging in, the selection is referred to as a "Peer", not a node.

I'm happy to see either or, as long as the terminology is consistently applied.

md-select(ng-model='$ctrl.$peers.currentPeerConfig', aria-label='Peer')
md-optgroup(ng-repeat='(name, peers) in $ctrl.$peers.stack', ng-if='peers.length', label='{{ name }}')
md-option(ng-repeat='peer in peers', ng-value='peer') {{ peer.node }}{{ peer.port ? ':' + peer.port : '' }}
Expand Down
15 changes: 9 additions & 6 deletions src/app/components/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ app.component('main', {
this.update.bind(this);
});

$scope.$watch('$ctrl.$peers.active', (peer, old) => {
if (peer && old) {
this.$peers.check();
this.$rootScope.$broadcast('peerUpdate');
}
});
/**
* Since we're setting network nodes in login we won't need this one
*/
// $scope.$watch('$ctrl.$peers.active', (peer, old) => {
// if (peer && old) {
// this.$peers.check();
// this.$rootScope.$broadcast('peerUpdate');
// }
// });
}

reset() {
Expand Down
23 changes: 13 additions & 10 deletions src/spec/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function checkErrorMessage(message) {

function launchApp() {
browser.ignoreSynchronization = true;
browser.driver.manage().window().setSize(1000, 1000);
browser.get('http://localhost:8080#?peerStack=localhost');
}

Expand Down Expand Up @@ -83,11 +84,15 @@ function testNewAccount() {
launchApp();

element.all(by.css('.md-button.md-primary')).get(0).click();
/**
* To generate a random pattern of mousemove events, we're randomizing the x,y pairs that
* based on even/odd valkuds of i will locate right/left halves of screen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling and grammar.

/**
 * To generate a random pattern of mousemove events, we are randomizing the x,y pairs that
 * based on even/odd values we locate the right/left halves of the screen
 */

*/
for (let i = 0; i < 250; i++) {
browser.actions()
.mouseMove(element(by.css('body')), {
x: Math.floor(Math.random() * 1000),
y: Math.floor(Math.random() * 1000),
x: 500 + (Math.floor((((i % 2) * 2) - 1) * (249 + (Math.random() * 250)))),
y: 500 + (Math.floor((((i % 2) * 2) - 1) * (249 + (Math.random() * 250)))),
}).perform();
browser.sleep(5);
}
Expand Down Expand Up @@ -120,22 +125,19 @@ function testAddress() {
}

function testPeer() {
login(masterAccount);
waitForElemAndCheckItsText('.peer md-select-value .md-text', 'localhost:4000');
expect(element.all(by.css('form md-select md-select-value span:first-child')).get(0).getText()).toEqual('Choose your network node');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test doesn't work if you run only this one because you first need to launchApp();

}

function testChangePeer() {
login(masterAccount);

const peerElem = element(by.css('.peer md-select-value'));
browser.wait(EC.presenceOf(peerElem), waitTime);
const peerElem = element(by.css('form md-select'));
// browser.wait(EC.presenceOf(peerElem), waitTime);
peerElem.click();

const optionElem = element.all(by.css('md-select-menu md-optgroup md-option')).get(0);
browser.wait(EC.presenceOf(optionElem), waitTime);
optionElem.click();

waitForElemAndCheckItsText('.peer md-select-value .md-text', 'node01.lisk.io');
waitForElemAndCheckItsText('form md-select-value .md-text', 'node01.lisk.io');
}

function testShowBalance() {
Expand Down Expand Up @@ -177,16 +179,17 @@ function testLoadMoreTransactions() {
const moreButton = element(by.css('transactions button.more'));
browser.wait(EC.presenceOf(moreButton), waitTime);
moreButton.click();
browser.sleep(200);

expect(element.all(by.css('transactions table tbody tr')).count()).toEqual(20);
}

describe('Lisk Nano functionality', () => {
it('should allow to login', testLogin);
it('should allow to logout', testLogout);
it('should show address', testAddress);
it('should show peer', testPeer);
it('should allow to change peer', testChangePeer);
it('should show address', testAddress);
it('should show balance', testShowBalance);
it('should allow to send transaction when enough funds and correct address form', testSend);
it('should not allow to send transaction when not enough funds', testSendWithNotEnoughFunds);
Expand Down
2 changes: 1 addition & 1 deletion src/test/components/login/login.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Login component', () => {
expect(element.find('form md-input-container label.pass').text()).to.equal(PASS_LABEL_TEXT);
});

const SELECT_LABEL_TEXT = 'Choose your network';
const SELECT_LABEL_TEXT = 'Choose your network node';
it(`should contain a select element with label saying "${SELECT_LABEL_TEXT}"`, () => {
expect(element.find('form md-input-container label.select').text()).to.equal(SELECT_LABEL_TEXT);
});
Expand Down