Continue to test wallets management views

This commit is contained in:
poka 2021-04-27 23:05:58 +02:00
parent 347aff7059
commit f193f5efac
5 changed files with 134 additions and 42 deletions

View File

@ -268,13 +268,13 @@ class WalletOptionsProvider with ChangeNotifier {
),
actions: <Widget>[
TextButton(
child: Text("Non"),
child: Text("Non", key: Key('cancelDeleting')),
onPressed: () {
Navigator.pop(context, false);
},
),
TextButton(
child: Text("Oui"),
child: Text("Oui", key: Key('confirmDeleting')),
onPressed: () {
Navigator.pop(context, true);
},

View File

@ -94,7 +94,7 @@ class UnlockingWallet extends StatelessWidget {
fontWeight: FontWeight.bold,
),
length: _pinLenght,
obscureText: false,
obscureText: true,
obscuringCharacter: '*',
animationType: AnimationType.fade,
validator: (v) {

View File

@ -205,6 +205,7 @@ class WalletOptions extends StatelessWidget {
),
SizedBox(height: 5),
InkWell(
key: Key('displayBalance'),
onTap: () {
_walletOptions.bluringBalance();
},
@ -279,6 +280,7 @@ class WalletOptions extends StatelessWidget {
}),
SizedBox(height: 15 * ratio),
GestureDetector(
key: Key('copyPubkey'),
onTap: () {
Clipboard.setData(
ClipboardData(text: _walletOptions.pubkey.text));
@ -334,6 +336,7 @@ class WalletOptions extends StatelessWidget {
]))),
SizedBox(height: 10 * ratio),
InkWell(
key: Key('displayHistory'),
onTap: () {
_historyProvider.isPubkey(ctx, _walletOptions.pubkey.text,
goHistory: true);
@ -352,6 +355,7 @@ class WalletOptions extends StatelessWidget {
]))),
SizedBox(height: 12 * ratio),
InkWell(
key: Key('setDefaultWallet'),
onTap: !_walletOptions.isDefaultWallet
? () {
defaultWallet = wallet;
@ -381,25 +385,31 @@ class WalletOptions extends StatelessWidget {
: Colors.black)),
]))),
SizedBox(height: 17 * ratio),
InkWell(
onTap: () async {
await _walletOptions.deleteWallet(context, wallet);
WidgetsBinding.instance.addPostFrameCallback((_) {
_myWalletProvider.listWallets =
_myWalletProvider.readAllWallets(_currentChest);
_myWalletProvider.rebuildWidget();
});
},
child: Row(children: <Widget>[
SizedBox(width: 33),
Image.asset(
'assets/walletOptions/trash.png',
),
SizedBox(width: 14),
Text('Supprimer ce portefeuille',
style: TextStyle(
fontSize: 20, color: Color(0xffD80000))),
])),
if (!_walletOptions.isDefaultWallet)
InkWell(
key: Key('deleteWallet'),
onTap: !_walletOptions.isDefaultWallet
? () async {
await _walletOptions.deleteWallet(
context, wallet);
WidgetsBinding.instance.addPostFrameCallback((_) {
_myWalletProvider.listWallets =
_myWalletProvider
.readAllWallets(_currentChest);
_myWalletProvider.rebuildWidget();
});
}
: null,
child: Row(children: <Widget>[
SizedBox(width: 33),
Image.asset(
'assets/walletOptions/trash.png',
),
SizedBox(width: 14),
Text('Supprimer ce portefeuille',
style: TextStyle(
fontSize: 20, color: Color(0xffD80000))),
])),
]),
),
),

View File

@ -84,6 +84,7 @@ class OnboardingStepThirteen extends StatelessWidget {
width: 400,
height: 62,
child: ElevatedButton(
key: Key('changeSecretCode'),
style: ElevatedButton.styleFrom(
elevation: 5,
primary: Color(0xffFFD58D),

View File

@ -15,6 +15,7 @@ void main() {
// final buttonFinder = find.byValueKey('increment');
FlutterDriver driver;
String pinCode;
// Connect to the Flutter driver before running any tests.
setUpAll(() async {
@ -80,7 +81,7 @@ void main() {
while (await getText('word1') == '...') {
print('Waiting for Mnemonic generation...');
await Future.delayed(const Duration(milliseconds: 100));
await sleep(100);
}
Future selectWord() async {
@ -93,15 +94,12 @@ void main() {
await getText('step7'), "C'est le moment de noter votre phrase !");
await tapOn('goStep8');
await Future.delayed(const Duration(milliseconds: 200));
await sleep(200);
String goodWord = words[int.parse(
await getText('askedWord'),
)];
// await tapOn('inputWord');
// await Future.delayed(const Duration(milliseconds: 500));
// Enter the expected word
await driver.enterText(goodWord);
@ -117,13 +115,13 @@ void main() {
//Go back 2 times to mnemonic generation screen
await goBack();
await goBack();
await Future.delayed(const Duration(milliseconds: 100));
await sleep(100);
// Generate 3 times mnemonic
await tapOn('generateMnemonic');
await tapOn('generateMnemonic');
await tapOn('generateMnemonic');
await Future.delayed(const Duration(milliseconds: 500));
await sleep(500);
await selectWord();
});
@ -137,18 +135,22 @@ void main() {
while (await getText('generatedPin') == '') {
print('Waiting for pin code generation...');
await Future.delayed(const Duration(milliseconds: 100));
await sleep(100);
}
final pinCode = await getText('generatedPin');
// Change secret code 4 times
for (int i = 0; i < 4; i++) await tapOn('changeSecretCode');
await sleep(500);
pinCode = await getText('generatedPin');
await tapOn('goStep12');
await Future.delayed(const Duration(milliseconds: 300));
await sleep(300);
// //Enter bad secret code
// await driver.enterText('abcde');
// await tapOn('formKey');
// await Future.delayed(const Duration(milliseconds: 4000));
// await sleep(1500);
// await tapOn('formKey2');
//Enter good secret code
@ -163,21 +165,96 @@ void main() {
await tapOn('goWalletHome');
expect(await getText('myWallets'), "Mes portefeuilles");
await Future.delayed(const Duration(milliseconds: 300));
await sleep(300);
// Create a derivation
Future createDerivation(String _name) async {
await tapOn('addDerivation');
await sleep(100);
await driver.enterText(_name);
await tapOn('validDerivation');
await sleep(300);
}
// Add a second derivation
await tapOn('addDerivation');
await Future.delayed(const Duration(milliseconds: 50));
await driver.enterText('Derivation 2');
await tapOn('validDerivation');
await Future.delayed(const Duration(milliseconds: 300));
await createDerivation('Derivation 2');
// Go to second derivation options
await driver.tap(find.text('Derivation 2'));
await sleep(100);
// Test options
await tapOn('displayBalance');
await tapOn('displayHistory');
await sleep(300);
await goBack();
await tapOn('displayBalance');
await sleep(100);
await tapOn('displayBalance');
await sleep(100);
await tapOn('displayBalance');
await tapOn('setDefaultWallet');
await sleep(50);
await tapOn('copyPubkey');
await driver.waitFor(find
.text('Cette clé publique a été copié dans votre presse-papier.'));
await goBack();
// Add a third derivation
await createDerivation('Derivation 3');
// Add a fourth derivation
await createDerivation('Derivation 4');
await sleep(50);
// Go to third derivation options
await driver.tap(find.text('Derivation 3'));
await sleep(100);
await tapOn('displayBalance');
// Delete a derivation
Future deleteWallet(bool _confirm) async {
await tapOn('deleteWallet');
await sleep(100);
_confirm
? await tapOn('confirmDeleting')
: await tapOn('cancelDeleting');
await sleep(300);
}
// Delete third derivation
await deleteWallet(true);
// Add derivation 5,6 and 7
await createDerivation('Derivation 5');
await createDerivation('Derivation 6');
await createDerivation('Derivation 7');
// Go home and come back to my wallets view
await goBack();
await sleep(100);
await tapOn('manageWallets');
await sleep(200);
//Enter secret code
await driver.enterText(pinCode);
await sleep(200);
// Go to derivation 6 and delete it
await driver.tap(find.text('Derivation 6'));
await sleep(100);
await deleteWallet(true);
// Go to 2nd derivation and check if it's de default
await driver.tap(find.text('Derivation 2'));
await driver.waitFor(find.text('Ce portefeuille est celui par defaut'));
await tapOn('setDefaultWallet');
await sleep(100);
await driver.waitFor(find.text('Ce portefeuille est celui par defaut'));
// Wait 3 seconds at the end
await Future.delayed(const Duration(seconds: 3));
await sleep(3000);
});
});
}
@ -190,3 +267,7 @@ Future goBack() async {
runInShell: true,
);
}
Future sleep(int _time) async {
await Future.delayed(Duration(milliseconds: _time));
}