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

Add autocomplete module to 'confirm votes modal' - Closes #587 #625

Merged
merged 22 commits into from
Aug 23, 2017

Conversation

yasharAyari
Copy link
Contributor

Create a autocomplete module based on react-toolbox components and use it in confirm votes modal to complete migration of this component.

Copy link
Contributor

@slaweet slaweet left a comment

Choose a reason for hiding this comment

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

It works like charm. A big piece of a good job.

Please, also, re-enable the e2e test of this feature
https://github.com/LiskHQ/lisk-nano/blob/2c3d897a6dbc27dc5c7ff463bc887c811395581c/features/voting.feature#L60-L67
This step will need to be updated
https://github.com/LiskHQ/lisk-nano/blob/2c3d897a6dbc27dc5c7ff463bc887c811395581c/features/step_definitions/voting.step.js#L15-L20

Unit test coverage of voteAutocomplete.js can be increased - look at the report - some else branches and mapDispatchToProps not covered.

Here's a refactoring suggestion if it's not too much work: voteAutocomplete.js has over 200 lines. A way to split it into two components would be to separate out a generic 'autocomplete' component which would be used twice in voteAutocomplete.js

@@ -26,7 +36,9 @@ export const voteAutocomplete = (activePeer, username, votedDict) => {
return new Promise((resolve, reject) =>
listDelegates(activePeer, options)
.then((response) => {
resolve(response.delegates.filter(d => !votedDict[d.username]));
resolve(response.delegates.filter(delegate =>
!findDelegateInList(delegate.username, votedDict),
Copy link
Contributor

Choose a reason for hiding this comment

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

findDelegateInList is unnecessary. This can be just !votedDict.find(d => delegate.username === d.username), which can even be faster, as it doesn't go through the rest of the list if a delegate is found.

Also the argument votedDict was supposed to be a key-value dictionary (object), but since you use it for a list, votedList would be a more appropriate name.

case 38:
this.handleArrowUp(this.state[listName], listName);
return false;
case 27 :
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment saying what key is 27

[className]: styles.hidden,
});
return false;
case 13 :
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment saying what key is 13

@slaweet
Copy link
Contributor

slaweet commented Aug 23, 2017

voteAutocomplete.js is still missing unit test coverage of some else branches and mapDispatchToProps:
https://coveralls.io/builds/12918462/source?filename=src%2Fcomponents%2Fvoting%2FvoteAutocomplete.js

@yasharAyari
Copy link
Contributor Author

yasharAyari commented Aug 23, 2017

mapDispatchToProps is part of react-redux package and we don't need to write unit test for that.
I will write more unit tests to cover other parts.

@slaweet
Copy link
Contributor

slaweet commented Aug 23, 2017

We don't tests mapDispatchToProps. What we test is that we mapped props.removedFromVoteList to dispatching removedFromVoteList event, not some other event or no event at all.
It's an easy test to write, we have plenty of them, e.g. here:
https://github.com/LiskHQ/lisk-nano/blob/b092c2deb2b13b3a29bddc9b3620976cc8cf86f6/src/components/forging/index.test.js#L33-L37

@yasharAyari yasharAyari merged commit 192db4e into development Aug 23, 2017
@yasharAyari yasharAyari deleted the 587-add-autocomplete-to-confirm-votes branch August 23, 2017 13:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants