2023-02-26 02:23:28 +01:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2022-08-27 05:43:43 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:gecko/globals.dart';
|
|
|
|
import 'package:gecko/models/widgets_keys.dart';
|
2022-09-01 04:51:51 +02:00
|
|
|
import 'package:gecko/providers/generate_wallets.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
2022-08-27 05:43:43 +02:00
|
|
|
import 'tests_utility.dart';
|
|
|
|
|
|
|
|
// GENERAL ACTIONS
|
|
|
|
|
2022-08-28 05:08:41 +02:00
|
|
|
Future changeNode() async {
|
2022-08-27 05:43:43 +02:00
|
|
|
final ipAddress = dotenv.env['ip_address'] ?? '127.0.0.1';
|
|
|
|
log.d('ip address: $ipAddress');
|
|
|
|
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyDrawerMenu);
|
|
|
|
await tapKey(keyParameters);
|
|
|
|
await tapKey(keySelectDuniterNodeDropDown, duration: 5);
|
|
|
|
await tapKey(keySelectDuniterNode('Personnalisé'), selectLast: true);
|
2022-08-28 05:08:41 +02:00
|
|
|
await enterText(keyCustomDuniterEndpoint, 'ws://$ipAddress:9944');
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyConnectToEndpoint);
|
2022-08-28 05:08:41 +02:00
|
|
|
await isIconPresent(Icons.add_card_sharp,
|
2022-08-27 05:43:43 +02:00
|
|
|
timeout: const Duration(seconds: 8));
|
2022-08-28 05:08:41 +02:00
|
|
|
await goBack();
|
2022-08-27 05:43:43 +02:00
|
|
|
}
|
|
|
|
|
2022-08-28 05:08:41 +02:00
|
|
|
Future deleteAllWallets() async {
|
|
|
|
if (await isPresent('Rechercher')) {
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyDrawerMenu);
|
|
|
|
await tapKey(keyParameters);
|
2022-09-11 13:14:52 +02:00
|
|
|
|
|
|
|
// Check if ud unit checkbox is checked
|
|
|
|
final isUdUnit = await isIconPresent(Icons.check_box);
|
|
|
|
// If yes, tap on to use currency value
|
|
|
|
if (isUdUnit) await tapKey(keyUdUnit, duration: 0);
|
|
|
|
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyDeleteAllWallets);
|
|
|
|
await tapKey(keyConfirm);
|
2022-08-27 05:43:43 +02:00
|
|
|
await tester.pumpAndSettle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-28 05:08:41 +02:00
|
|
|
Future restoreChest() async {
|
2022-08-27 05:43:43 +02:00
|
|
|
// Copy test mnemonic in clipboard
|
2022-08-29 06:03:05 +02:00
|
|
|
await clipCopy(testMnemonic);
|
2022-08-27 05:43:43 +02:00
|
|
|
|
|
|
|
// Open screen import chest
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyRestoreChest, duration: 0);
|
2022-08-27 05:43:43 +02:00
|
|
|
|
|
|
|
// Tap on button to paste mnemonic
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyPastMnemonic);
|
2022-08-27 05:43:43 +02:00
|
|
|
|
|
|
|
// Tap on next button 4 times to skip 3 screen
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyGoNext);
|
|
|
|
await tapKey(keyGoNext);
|
|
|
|
await tapKey(keyGoNext);
|
|
|
|
await tapKey(keyGoNext);
|
2022-08-27 05:43:43 +02:00
|
|
|
|
|
|
|
// Check if cached password checkbox is checked
|
2022-08-28 05:08:41 +02:00
|
|
|
final isCached = await isIconPresent(Icons.check_box);
|
2022-08-27 05:43:43 +02:00
|
|
|
|
|
|
|
// If not, tap on to cache password
|
2022-08-29 06:03:05 +02:00
|
|
|
if (!isCached) await tapKey(keyCachePassword, duration: 0);
|
2022-08-27 05:43:43 +02:00
|
|
|
|
|
|
|
// Enter password
|
2022-08-28 05:08:41 +02:00
|
|
|
await enterText(keyPinForm, 'AAAAA', 0);
|
2022-08-27 05:43:43 +02:00
|
|
|
|
|
|
|
// Check if string "Accéder à mon coffre" is present in screen
|
2023-02-26 02:23:28 +01:00
|
|
|
await waitFor('accessMyChest'.tr());
|
2022-08-27 05:43:43 +02:00
|
|
|
|
|
|
|
// Go to wallets home
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyGoWalletsHome, duration: 0);
|
2022-08-27 05:43:43 +02:00
|
|
|
|
|
|
|
// Check if string "ĞD" is present in screen
|
2022-08-28 05:08:41 +02:00
|
|
|
await waitFor('ĞD');
|
2022-08-27 05:43:43 +02:00
|
|
|
|
|
|
|
// Tap on add a new derivation button
|
2022-08-28 05:08:41 +02:00
|
|
|
await addDerivation();
|
2022-08-27 05:43:43 +02:00
|
|
|
|
|
|
|
// Tap on Wallet 5
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyOpenWallet(test5.address));
|
2022-08-27 05:43:43 +02:00
|
|
|
|
|
|
|
// Copy address of Wallet 5
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyCopyAddress);
|
2022-08-27 05:43:43 +02:00
|
|
|
|
|
|
|
// Check if string "Cette adresse a été copié" is present in screen
|
2023-02-26 02:23:28 +01:00
|
|
|
await waitFor('thisAddressHasBeenCopiedToClipboard'.tr());
|
2022-08-27 05:43:43 +02:00
|
|
|
|
2022-08-28 05:08:41 +02:00
|
|
|
// Pop screen 2 time to go back home
|
|
|
|
await goBack();
|
|
|
|
await goBack();
|
|
|
|
}
|
2022-08-27 05:43:43 +02:00
|
|
|
|
2022-09-01 04:51:51 +02:00
|
|
|
Future onboardingNewChest() async {
|
|
|
|
final generateWalletProvider =
|
|
|
|
Provider.of<GenerateWalletsProvider>(homeContext, listen: false);
|
|
|
|
// Open screen create new wallet
|
|
|
|
await tapKey(keyOnboardingNewChest);
|
|
|
|
|
|
|
|
// Tap on next button 4 times to skip 3 screen
|
|
|
|
await tapKey(keyGoNext);
|
|
|
|
await tapKey(keyGoNext);
|
|
|
|
await tapKey(keyGoNext);
|
|
|
|
await tapKey(keyGoNext);
|
|
|
|
await waitFor('7', exactMatch: true);
|
|
|
|
|
|
|
|
final word41 = getWidgetText(keyMnemonicWord('4'));
|
|
|
|
|
|
|
|
// Change 2 times mnemonic
|
|
|
|
await tapKey(keyGenerateMnemonic);
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
final word42 = getWidgetText(keyMnemonicWord('4'));
|
|
|
|
expect(word41, isNot(word42));
|
|
|
|
await tapKey(keyGenerateMnemonic, duration: 500);
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
final word43 = getWidgetText(keyMnemonicWord('4'));
|
|
|
|
expect(word42, isNot(word43));
|
|
|
|
|
|
|
|
// Go next screen
|
|
|
|
await tapKey(keyGoNext);
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
|
|
// Enter asked word
|
|
|
|
final askedWordNumber = int.parse(getWidgetText(keyAskedWord));
|
|
|
|
List mnemonic = generateWalletProvider.generatedMnemonic!.split(' ');
|
|
|
|
|
|
|
|
final askedWord = mnemonic[askedWordNumber - 1];
|
|
|
|
await enterText(keyInputWord, askedWord);
|
2023-02-26 02:23:28 +01:00
|
|
|
await waitFor('continue'.tr(), exactMatch: true);
|
2022-09-01 04:51:51 +02:00
|
|
|
await tapKey(keyGoNext);
|
|
|
|
await tapKey(keyGoNext);
|
|
|
|
await tapKey(keyGoNext);
|
|
|
|
await waitFor('AAAAA', exactMatch: true);
|
|
|
|
await tapKey(keyGoNext);
|
|
|
|
|
|
|
|
// Check if cached password checkbox is checked
|
|
|
|
final isCached = await isIconPresent(Icons.check_box);
|
|
|
|
|
|
|
|
// If not, tap on to cache password
|
|
|
|
if (!isCached) await tapKey(keyCachePassword, duration: 0);
|
|
|
|
|
|
|
|
// Enter password
|
|
|
|
await enterText(keyPinForm, 'AAAAA', 0);
|
|
|
|
|
|
|
|
// Check if string "Accéder à mon coffre" is present in screen
|
2023-02-26 02:23:28 +01:00
|
|
|
await waitFor('accessMyChest'.tr());
|
2022-09-01 04:51:51 +02:00
|
|
|
|
|
|
|
// Go to wallets home
|
|
|
|
await tapKey(keyGoWalletsHome, duration: 0);
|
|
|
|
|
2022-09-11 13:14:52 +02:00
|
|
|
// Check if string "Mon portefeuille co" is present in screen
|
2023-02-26 02:23:28 +01:00
|
|
|
await waitFor('currentWallet'.tr());
|
2022-09-11 13:14:52 +02:00
|
|
|
await waitFor('0.0', exactMatch: true);
|
2022-09-05 08:09:12 +02:00
|
|
|
// await waitFor('Scanner un');
|
2022-09-01 04:51:51 +02:00
|
|
|
}
|
|
|
|
|
2022-08-28 05:08:41 +02:00
|
|
|
Future addDerivation() async {
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyAddDerivation);
|
2022-08-28 05:08:41 +02:00
|
|
|
await waitFor('Portefeuille 5');
|
2022-08-27 05:43:43 +02:00
|
|
|
}
|
|
|
|
|
2022-08-28 05:08:41 +02:00
|
|
|
Future firstOpenChest() async {
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyOpenWalletsHomme);
|
2022-08-28 05:08:41 +02:00
|
|
|
sleep(300);
|
|
|
|
final isCached = await isIconPresent(Icons.check_box);
|
2022-08-29 06:03:05 +02:00
|
|
|
if (!isCached) await tapKey(keyCachePassword, duration: 0);
|
2022-08-28 05:08:41 +02:00
|
|
|
await enterText(keyPinForm, 'AAAAA', 0);
|
2022-09-11 13:14:52 +02:00
|
|
|
await waitFor('100.0', exactMatch: true);
|
2022-08-27 05:43:43 +02:00
|
|
|
}
|