Skip to content

Commit

Permalink
test: settings password and mnemonic
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed May 24, 2023
1 parent 46c1ef1 commit 318f037
Show file tree
Hide file tree
Showing 35 changed files with 815 additions and 26 deletions.
16 changes: 3 additions & 13 deletions src/components/ListItemSettingsReset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
? $t('settings.reset.subtitle')
: $t('settings.reset.subtitle-desktop')"
data-cy="reset"
@click="reset"
@click="resetConfirm"
>
<ListItemCircle slot="icon">
<SignOut />
Expand All @@ -19,20 +19,10 @@
import ListItem from './ListItem.vue';
import ListItemCircle from './ListItemCircle.vue';
import { SignOut } from './icons';
import { resetConfirm } from '../lib/methods';
export default {
components: { ListItem, ListItemCircle, SignOut },
methods: {
async reset() {
await this.$store.dispatch('modals/open', {
name: 'confirm',
text: ENV_MOBILE_DEVICE
? this.$t('settings.reset.confirm')
: this.$t('settings.reset.confirm-desktop'),
primaryButtonText: this.$t('settings.reset.button'),
});
this.$store.dispatch('reset');
},
},
methods: { resetConfirm },
};
</script>
11 changes: 11 additions & 0 deletions src/lib/methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// eslint-disable-next-line import/prefer-default-export
export async function resetConfirm() {
await this.$store.dispatch('modals/open', {
name: 'confirm',
text: ENV_MOBILE_DEVICE
? this.$t('settings.reset.confirm')
: this.$t('settings.reset.confirm-desktop'),
primaryButtonText: this.$t('settings.reset.button'),
});
await this.$store.dispatch('reset');
}
12 changes: 8 additions & 4 deletions src/pages/mobile/Intro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
<AeButton
fill="light"
plain
data-cy="create"
@click="() => createWallet()"
:data-cy="encryptedWallet ? 'reset' : 'create'"
@click="() => encryptedWallet ? resetConfirm() : createWallet()"
>
{{ $t('intro.create-account') }}
{{ encryptedWallet ? $t('settings.reset.title') : $t('intro.create-account') }}
</AeButton>
<hr>
<AeButton
Expand All @@ -44,11 +44,15 @@ import { mapState, mapActions } from 'vuex';
import Page from '../../components/Page.vue';
import Guide from '../../components/Guide.vue';
import AeButton from '../../components/AeButton.vue';
import { resetConfirm } from '../../lib/methods';
export default {
components: { Page, AeButton, Guide },
computed: mapState('accounts/hdWallet', ['encryptedWallet']),
methods: mapActions('accounts/hdWallet', ['createWallet']),
methods: {
...mapActions('accounts/hdWallet', ['createWallet']),
resetConfirm,
},
};
</script>

Expand Down
9 changes: 7 additions & 2 deletions src/pages/mobile/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
</template>

<script>
import { mapState, mapActions } from 'vuex';
import { mapState } from 'vuex';
import { get } from 'lodash-es';
import AeCard from '../../components/AeCard.vue';
import Page from '../../components/Page.vue';
Expand Down Expand Up @@ -188,7 +188,12 @@ export default {
.filter(({ source: { type } }) => type !== 'hd-wallet'),
isWalletEncrypted: (state, getters) => getters['accounts/hdWallet/isWalletEncrypted'],
}),
methods: mapActions(['logout']),
methods: {
async logout() {
await this.$store.dispatch('logout');
await this.$router.push({ name: 'login' });
},
},
};
</script>

Expand Down
6 changes: 2 additions & 4 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ export default (async () => {
router.push(store.state.loginTarget || ROUTE_MOBILE_LOGGED_IN);
store.commit('setLoginTarget');
}
} else {
const { fullPath } = router.currentRoute;
router.replace({ name: ENV_MOBILE_DEVICE ? 'intro' : 'apps' });
router.replace(fullPath);
} else if (!ENV_MOBILE_DEVICE) {
router.replace({ name: 'apps' });
}
},
);
Expand Down
49 changes: 49 additions & 0 deletions tests/e2e/fixtures/state-created-mnemonic-not-backup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"migrations": {
"0": true,
"1": true,
"2": true,
"3": true,
"4": true,
"5": true
},
"peerId": "EecRNs8PmyiN75IBOI6+",
"languages": {
"activeCode": "en"
},
"currencies": {
"activeCode": "eur",
"swapped": false
},
"sdkUrl": "https://mainnet.aeternity.io",
"names": {
"defaults": {}
},
"customNetworks": [],
"accounts": {
"list": [
{
"address": "ak_oXPEaapaDF7R1QcUuvaDDEeanMAVWFSq8TLAaUxdSKpSgUyqY",
"source": {
"type": "hd-wallet",
"idx": 0
}
}
],
"activeIdx": 0,
"hdWallet": {
"encryptedWallet": {
"mnemonic": "abandon amount liar amount expire adjust cage candy arch gather drum buyer"
},
"mnemonicBackedUp": false
}
},
"apps": [],
"mobile": {
"readSecurityCourses": [
"intro"
],
"followers": {},
"skipAddingToHomeScreen": true
}
}
49 changes: 49 additions & 0 deletions tests/e2e/fixtures/state-created-mnemonic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"migrations": {
"0": true,
"1": true,
"2": true,
"3": true,
"4": true,
"5": true
},
"peerId": "EecRNs8PmyiN75IBOI6+",
"languages": {
"activeCode": "en"
},
"currencies": {
"activeCode": "eur",
"swapped": false
},
"sdkUrl": "https://mainnet.aeternity.io",
"names": {
"defaults": {}
},
"customNetworks": [],
"accounts": {
"list": [
{
"address": "ak_oXPEaapaDF7R1QcUuvaDDEeanMAVWFSq8TLAaUxdSKpSgUyqY",
"source": {
"type": "hd-wallet",
"idx": 0
}
}
],
"activeIdx": 0,
"hdWallet": {
"encryptedWallet": {
"mnemonic": "abandon amount liar amount expire adjust cage candy arch gather drum buyer"
},
"mnemonicBackedUp": true
}
},
"apps": [],
"mobile": {
"readSecurityCourses": [
"intro"
],
"followers": {},
"skipAddingToHomeScreen": true
}
}
122 changes: 122 additions & 0 deletions tests/e2e/fixtures/state-created.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"migrations": {
"0": true,
"1": true,
"2": true,
"3": true,
"4": true,
"5": true
},
"peerId": "EecRNs8PmyiN75IBOI6+",
"languages": {
"activeCode": "en"
},
"currencies": {
"activeCode": "eur",
"swapped": false
},
"sdkUrl": "https://mainnet.aeternity.io",
"names": {
"defaults": {}
},
"customNetworks": [],
"accounts": {
"list": [
{
"address": "ak_oXPEaapaDF7R1QcUuvaDDEeanMAVWFSq8TLAaUxdSKpSgUyqY",
"source": {
"type": "hd-wallet",
"idx": 0
}
}
],
"activeIdx": 0,
"hdWallet": {
"encryptedWallet": {
"privateKey": {
"type": "Uint8Array",
"data": [
210,
161,
18,
171,
157,
165,
226,
140,
201,
105,
223,
157,
7,
142,
220,
86,
118,
81,
56,
75,
25,
148,
158,
101,
175,
225,
92,
229,
245,
104,
136,
211
]
},
"chainCode": {
"type": "Uint8Array",
"data": [
15,
69,
204,
91,
35,
237,
101,
204,
166,
145,
55,
31,
11,
160,
225,
81,
114,
102,
118,
154,
162,
177,
55,
122,
125,
38,
211,
27,
101,
240,
223,
143
]
}
},
"mnemonicBackedUp": true
}
},
"apps": [],
"mobile": {
"readSecurityCourses": [
"intro"
],
"followers": {},
"skipAddingToHomeScreen": true
}
}
Loading

0 comments on commit 318f037

Please sign in to comment.