Skip to content

Commit

Permalink
Add new scenario & code improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltomasik committed Mar 14, 2018
1 parent 84c1c7a commit e8a2ca5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions i18n/locales/en/common.json
Expand Up @@ -234,6 +234,7 @@
"You have not forged any blocks yet": "You have not forged any blocks yet",
"You need to become a delegate to start forging. If you already registered to become a delegate, your registration hasn't been processed, yet.": "You need to become a delegate to start forging. If you already registered to become a delegate, your registration hasn't been processed, yet.",
"You've received {{value}} LSK.": "You've received {{value}} LSK.",
"Your ID is now secured!": "Your ID is now secured!",
"Your favorite Lisk IDs": "Your favorite Lisk IDs",
"You’re votes are being processed and will be confirmed. It may take up to 10 minutes to be secured in the blockchain.": "You’re votes are being processed and will be confirmed. It may take up to 10 minutes to be secured in the blockchain.",
"Zero not allowed": "Zero not allowed",
Expand Down
9 changes: 8 additions & 1 deletion src/components/savedAccounts/savedAccounts.css
Expand Up @@ -183,7 +183,8 @@
}

.network,
.unlocked {
.unlocked,
.unlockedSecured {
font-size: 1em;
position: absolute;
top: 0;
Expand All @@ -208,10 +209,16 @@
& span {
transform: scale(1.1);
transform-origin: 100%;
transition: transform ease-in-out 500ms;
}
}
}

.unlockedSecured {
left: 0;
padding-top: 30px;
}

.network {
padding-top: 30px;
right: 0;
Expand Down
17 changes: 14 additions & 3 deletions src/components/savedAccounts/savedAccounts.js
Expand Up @@ -27,6 +27,7 @@ class SavedAccounts extends React.Component {
super();

this.state = {
isSecureAppears: {},
};
}

Expand Down Expand Up @@ -60,13 +61,19 @@ class SavedAccounts extends React.Component {
handleRemovePassphrase(account, e) {
e.stopPropagation();

const uniqueID = `${account.network}${account.publicKey}`;
const { savedAccounts } = this.props;
const savedActiveAccount = savedAccounts.find(acc => `${acc.network} ${acc.network}` === `${account.network} ${account.network}`);
const savedActiveAccount = savedAccounts.find(acc => `${acc.network}${acc.passphrase}` === `${account.network}${account.passphrase}`);
if (savedActiveAccount) {
this.props.removePassphrase(account);
}

this.props.removeSavedAccountPassphrase(account);

this.setState({ isSecureAppears: { ...this.state.isSecureAppears, [uniqueID]: true } });
setTimeout(() => {
this.setState({ isSecureAppears: { ...this.state.isSecureAppears, [uniqueID]: false } });
}, 3000);
}

render() {
Expand Down Expand Up @@ -116,12 +123,16 @@ class SavedAccounts extends React.Component {
{(account.passphrase ?
<strong
className={`unlocked ${styles.unlocked}`}
onClick={this.handleRemovePassphrase.bind(this, account)}
>
onClick={this.handleRemovePassphrase.bind(this, account)}>
<FontIcon value='unlocked' />
{t('Lock ID')}
</strong> :
null)}
{(this.state.isSecureAppears[`${account.network}${account.publicKey}`] ?
<strong className={`unlockedSecured ${styles.unlockedSecured}`}>
{t('Your ID is now secured!')}
</strong> :
null)}
{(account.network !== networks.mainnet.code ?
<strong className={styles.network}>
{account.address ? account.address : t(getNetwork(account.network).name)}
Expand Down
1 change: 1 addition & 0 deletions src/components/savedAccounts/savedAccounts.test.js
Expand Up @@ -66,6 +66,7 @@ describe('SavedAccounts', () => {
account: {
balance: 100e8,
},
isSecureAppears: false,
});
wrapper = mountWithRouter(<SavedAccounts {...props} />, {
context: { store, i18n },
Expand Down
2 changes: 1 addition & 1 deletion src/store/reducers/savedAccounts.js
Expand Up @@ -63,7 +63,7 @@ const savedAccounts = (state = { accounts: [] }, action) => {
return {
...state,
accounts: state.accounts.map((account) => {
if ((`${action.data.network} ${action.data.network}` === `${account.network} ${account.network}`)) {
if ((`${action.data.network}${action.data.passphrase}` === `${account.network}${account.passphrase}`)) {
delete account.passphrase;
}
return account;
Expand Down
4 changes: 2 additions & 2 deletions test/integration/accountSwitch.test.js
Expand Up @@ -89,9 +89,9 @@ describe('@integration: Account switch', () => {

describe('Scenario: should allow to "Lock ID" account', () => {
step('Given I\'m on "account switcher" with accounts: "genesis,delegate,empty account"', setupStep);
step('Then I should see 3 instances of "saved account card"', () => helper.shouldSeeCountInstancesOf(1, 'strong.unlocked'));
step('Then I should see 1 instance of "Lock ID"', () => helper.shouldSeeCountInstancesOf(1, 'strong.unlocked'));
step('When I click "Lock ID"', () => helper.clickOnElement('strong.unlocked'));
step('Then I should see 2 instances of "saved account card"', () => helper.shouldSeeCountInstancesOf(0, 'strong.unlocked'));
step('Then I should see 0 instances of "Lock ID"', () => helper.shouldSeeCountInstancesOf(0, 'strong.unlocked'));
});

describe('Scenario: should allow to switch account', () => {
Expand Down

0 comments on commit e8a2ca5

Please sign in to comment.