diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 64552f7..e050d5f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,7 @@ stages: - package .env: - image: axiomteam/gecko-ci:v0.0.6 + image: axiomteam/gecko-ci:v0.0.7 tags: - p2plegal before_script: @@ -24,7 +24,7 @@ format: - cargo fmt -- --version - cargo fmt -- --check - flutter format --set-exit-if-changed lib packages/dubp_rs/lib/dubp.dart - + build_and_test: extends: .env rules: diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 73c3d1d..3600761 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -9,11 +9,12 @@ - runesAskedUnaccent = []; - for (int i in runesAsked) { - if (i == 768 || i == 769 || i == 770 || i == 771) { - continue; - } else { - runesAskedUnaccent.add(i); - } - } - final String unaccentedAskedWord = - utf8.decode(runesAskedUnaccent).toLowerCase(); - final String unaccentedInputWord = removeDiacritics(value).toLowerCase(); - - log.i("Is $unaccentedAskedWord equal to input $unaccentedInputWord ?"); - if (unaccentedAskedWord == unaccentedInputWord || - value == 'triche' || - value == '3.14') { + log.i("Is $expectedWord equal to input $normInputWord ?"); + if (expectedWord == normInputWord || + inputWord == 'triche' || + inputWord == '3.14') { log.d('Word is OK'); isAskedWordValid = true; askedWordColor = Colors.green[600]; diff --git a/lib/models/home.dart b/lib/models/home.dart index 0338ded..63fc715 100644 --- a/lib/models/home.dart +++ b/lib/models/home.dart @@ -52,7 +52,7 @@ class HomeProvider with ChangeNotifier { int _statusCode = 0; final _client = new HttpClient(); - _client.connectionTimeout = const Duration(milliseconds: 800); + _client.connectionTimeout = const Duration(milliseconds: 1000); do { i++; diff --git a/lib/models/myWallets.dart b/lib/models/myWallets.dart index 7bc4e5f..3ceff88 100644 --- a/lib/models/myWallets.dart +++ b/lib/models/myWallets.dart @@ -172,6 +172,7 @@ class MyWalletsProvider with ChangeNotifier { }, ), TextButton( + key: Key('confirmDeletingAllWallets'), child: Text("Oui"), onPressed: () { Navigator.pop(context, true); diff --git a/lib/models/walletOptions.dart b/lib/models/walletOptions.dart index 5b43384..d8aed5f 100644 --- a/lib/models/walletOptions.dart +++ b/lib/models/walletOptions.dart @@ -84,6 +84,10 @@ class WalletOptionsProvider with ChangeNotifier { String _localPubkey; // log.d("$_localDewif $_pin $_pinLenght ${_wallet.derivation}"); + // String mnemo = await DubpRust.getBip32DewifMnemonic( + // dewif: _localDewif, secretCode: _pin); + // log.d(mnemo.toString()); + if ((_localPubkey = await _getPubkeyFromDewif( _localDewif, _pin, _pinLenght, _wallet.derivation)) != 'false') { @@ -264,13 +268,13 @@ class WalletOptionsProvider with ChangeNotifier { ), actions: [ 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); }, diff --git a/lib/screens/commonElements.dart b/lib/screens/commonElements.dart index 59bc2b6..b6c3d6b 100644 --- a/lib/screens/commonElements.dart +++ b/lib/screens/commonElements.dart @@ -7,7 +7,7 @@ class CommonElements { return Text('Coucou'); } - Widget bubbleSpeak(String text, {double long}) { + Widget bubbleSpeak(String text, {double long, Key textKey}) { return Bubble( padding: long == null ? BubbleEdges.all(18) @@ -18,13 +18,14 @@ class CommonElements { // nip: BubbleNip.leftTop, child: Text( text, + key: textKey, style: TextStyle( color: Colors.black, fontSize: 18, fontWeight: FontWeight.w400), ), ); } - Widget bubbleSpeakRich(List text) { + Widget bubbleSpeakRich(List text, {Key textKey}) { return Bubble( padding: BubbleEdges.all(18), elevation: 5, @@ -32,13 +33,14 @@ class CommonElements { margin: BubbleEdges.fromLTRB(10, 0, 20, 10), // nip: BubbleNip.leftTop, child: RichText( + key: textKey, text: TextSpan( - style: TextStyle( - fontSize: 18.0, - color: Colors.black, - ), - children: text, - )), + style: TextStyle( + fontSize: 18.0, + color: Colors.black, + ), + children: text, + )), ); } diff --git a/lib/screens/history.dart b/lib/screens/history.dart index 3b877ab..a6ca095 100644 --- a/lib/screens/history.dart +++ b/lib/screens/history.dart @@ -169,6 +169,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { child: Builder( builder: (context) => Expanded( child: ListView( + key: Key('listTransactions'), controller: scrollController, children: [ SizedBox(height: 20), @@ -222,6 +223,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { height: avatarsSize); })), GestureDetector( + key: Key('copyPubkey'), onTap: () { Clipboard.setData(ClipboardData( text: _historyProvider.pubkey)); @@ -288,6 +290,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { style: TextStyle(fontSize: 18.0))), SizedBox(height: 20), ElevatedButton( + key: Key('switchPayHistory'), style: ElevatedButton.styleFrom( elevation: 1, primary: Colors.grey[50], // background @@ -401,6 +404,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { Widget historyView(context, result) { HistoryProvider _historyProvider = Provider.of(context); + int keyID = 0; return _historyProvider.transBC == null ? Text('Aucune transaction à afficher.') @@ -409,6 +413,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { Padding( padding: const EdgeInsets.symmetric(horizontal: 5.0), child: ListTile( + key: Key('transaction${keyID++}'), contentPadding: const EdgeInsets.all(5.0), leading: Text(repository[1].toString(), style: TextStyle( @@ -441,13 +446,15 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { ), // if (_historyProvider.isTheEnd) // What I did before ... if (!_historyProvider.pageInfo['hasPreviousPage']) - Column(children: [ - SizedBox(height: 15), - Text("Début de l'historique.", - textAlign: TextAlign.center, - style: TextStyle(fontSize: 20)), - SizedBox(height: 15) - ]) + Column( + children: [ + SizedBox(height: 15), + Text("Début de l'historique.", + textAlign: TextAlign.center, + style: TextStyle(fontSize: 20)), + SizedBox(height: 15) + ], + ) ]); } } diff --git a/lib/screens/home.dart b/lib/screens/home.dart index b21bc7d..1d349a8 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -47,6 +47,7 @@ class HomeScreen extends StatelessWidget { ), ), ListTile( + key: Key('parameters'), title: Text('Paramètres'), onTap: () { Navigator.pop(context); @@ -77,6 +78,7 @@ class HomeScreen extends StatelessWidget { appBar: AppBar( leading: Builder( builder: (context) => IconButton( + key: Key('drawerMenu'), icon: new Icon(Icons.menu, color: Colors.grey[850]), onPressed: () => Scaffold.of(context).openDrawer(), )), @@ -85,6 +87,7 @@ class HomeScreen extends StatelessWidget { Padding( padding: EdgeInsets.symmetric(horizontal: 16), child: IconButton( + key: Key('searchIcon'), icon: _homeProvider.searchIcon, color: Colors.grey[850], onPressed: () { @@ -94,6 +97,7 @@ class HomeScreen extends StatelessWidget { color: Colors.grey[850], ); _homeProvider.appBarTitle = TextField( + key: Key('searchInput'), autofocus: true, controller: _homeProvider.searchQuery, onChanged: (text) { @@ -257,6 +261,7 @@ class HomeScreen extends StatelessWidget { Column(children: [ Container( child: ClipOval( + key: Key('manageWallets'), child: Material( color: Color(0xffFFD58D), // button color child: InkWell( diff --git a/lib/screens/myWallets/confirmWalletStorage.dart b/lib/screens/myWallets/confirmWalletStorage.dart index 3669fae..614d071 100644 --- a/lib/screens/myWallets/confirmWalletStorage.dart +++ b/lib/screens/myWallets/confirmWalletStorage.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:gecko/models/generateWallets.dart'; import 'package:gecko/models/myWallets.dart'; +import 'package:gecko/models/walletOptions.dart'; import 'package:provider/provider.dart'; // ignore: must_be_immutable @@ -30,6 +31,8 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { Provider.of(context); MyWalletsProvider _myWalletProvider = Provider.of(context); + WalletOptionsProvider _walletOptions = + Provider.of(context); final int _currentChest = _myWalletProvider.getCurrentChest(); this._mnemonicController.text = generatedMnemonic; @@ -67,6 +70,7 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { fontWeight: FontWeight.w400), )), TextFormField( + key: Key('askedWord'), focusNode: _wordFocus, autofocus: true, enabled: !_generateWalletProvider.isAskedWordValid, @@ -95,6 +99,7 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { fontWeight: FontWeight.w400), )), TextFormField( + key: Key('walletName'), focusNode: _generateWalletProvider.walletNameFocus, inputFormatters: [ FilteringTextInputFormatter.allow( @@ -119,6 +124,7 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { width: 200, height: 50, child: ElevatedButton( + key: Key('confirmStorage'), style: ElevatedButton.styleFrom( elevation: 12, primary: Colors.green[ @@ -137,14 +143,13 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { false; _generateWalletProvider.askedWordColor = Colors.black; - WidgetsBinding.instance - .addPostFrameCallback((_) { - _myWalletProvider.listWallets = - _myWalletProvider - .readAllWallets(_currentChest); - scheduleMicrotask(() { - _myWalletProvider.rebuildWidget(); - }); + _myWalletProvider.listWallets = + _myWalletProvider + .readAllWallets(_currentChest); + _myWalletProvider.getDefaultWallet(); + scheduleMicrotask(() { + _walletOptions.reloadBuild(); + _myWalletProvider.rebuildWidget(); }); Navigator.popUntil( context, ModalRoute.withName('/')); diff --git a/lib/screens/myWallets/generateWallets.dart b/lib/screens/myWallets/generateWallets.dart index 0388245..9847000 100644 --- a/lib/screens/myWallets/generateWallets.dart +++ b/lib/screens/myWallets/generateWallets.dart @@ -71,6 +71,7 @@ class GenerateWalletsScreen extends StatelessWidget { alignment: Alignment.centerRight, children: [ TextField( + key: Key('generatedPin'), enabled: false, controller: _generateWalletProvider.pin, maxLines: 1, @@ -93,6 +94,7 @@ class GenerateWalletsScreen extends StatelessWidget { ), SizedBox(height: 20), ElevatedButton( + key: Key('storeKeychain'), style: ElevatedButton.styleFrom( primary: Color(0xffFFD68E), // background onPrimary: Colors.black, // foreground diff --git a/lib/screens/myWallets/unlockingWallet.dart b/lib/screens/myWallets/unlockingWallet.dart index 615b526..1efba3c 100644 --- a/lib/screens/myWallets/unlockingWallet.dart +++ b/lib/screens/myWallets/unlockingWallet.dart @@ -94,7 +94,7 @@ class UnlockingWallet extends StatelessWidget { fontWeight: FontWeight.bold, ), length: _pinLenght, - obscureText: false, + obscureText: true, obscuringCharacter: '*', animationType: AnimationType.fade, validator: (v) { diff --git a/lib/screens/myWallets/walletOptions.dart b/lib/screens/myWallets/walletOptions.dart index 24a63e6..03944c5 100644 --- a/lib/screens/myWallets/walletOptions.dart +++ b/lib/screens/myWallets/walletOptions.dart @@ -124,6 +124,7 @@ class WalletOptions extends StatelessWidget { SizedBox( width: 260, child: TextField( + key: Key('walletName'), focusNode: _walletOptions.walletNameFocus, enabled: _walletOptions.isEditing, controller: _walletOptions.nameController, @@ -205,6 +206,7 @@ class WalletOptions extends StatelessWidget { ), SizedBox(height: 5), InkWell( + key: Key('displayBalance'), onTap: () { _walletOptions.bluringBalance(); }, @@ -217,6 +219,7 @@ class WalletOptions extends StatelessWidget { SizedBox(width: 0), Column(children: [ InkWell( + key: Key('renameWallet'), onTap: () async { // _walletOptions.isEditing = true; // _walletOptions.reloadBuild(); @@ -279,6 +282,7 @@ class WalletOptions extends StatelessWidget { }), SizedBox(height: 15 * ratio), GestureDetector( + key: Key('copyPubkey'), onTap: () { Clipboard.setData( ClipboardData(text: _walletOptions.pubkey.text)); @@ -334,6 +338,7 @@ class WalletOptions extends StatelessWidget { ]))), SizedBox(height: 10 * ratio), InkWell( + key: Key('displayHistory'), onTap: () { _historyProvider.isPubkey(ctx, _walletOptions.pubkey.text, goHistory: true); @@ -352,6 +357,7 @@ class WalletOptions extends StatelessWidget { ]))), SizedBox(height: 12 * ratio), InkWell( + key: Key('setDefaultWallet'), onTap: !_walletOptions.isDefaultWallet ? () { defaultWallet = wallet; @@ -381,25 +387,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: [ - 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: [ + SizedBox(width: 33), + Image.asset( + 'assets/walletOptions/trash.png', + ), + SizedBox(width: 14), + Text('Supprimer ce portefeuille', + style: TextStyle( + fontSize: 20, color: Color(0xffD80000))), + ])), ]), ), ), diff --git a/lib/screens/myWallets/walletsHome.dart b/lib/screens/myWallets/walletsHome.dart index 5105743..dbd5234 100644 --- a/lib/screens/myWallets/walletsHome.dart +++ b/lib/screens/myWallets/walletsHome.dart @@ -52,6 +52,7 @@ class WalletsHome extends StatelessWidget { ); }), title: Text('Mes portefeuilles', + key: Key('myWallets'), style: TextStyle(color: Colors.grey[850])), backgroundColor: Color(0xffFFD58D), ), @@ -62,6 +63,7 @@ class WalletsHome extends StatelessWidget { width: 80.0, child: FittedBox( child: FloatingActionButton( + key: Key('addDerivation'), heroTag: "buttonGenerateWallet", onPressed: () { showDialog( @@ -108,6 +110,7 @@ class WalletsHome extends StatelessWidget { List _listWallets = _myWalletProvider.listWallets; return GridView.count( + key: Key('listWallets'), crossAxisCount: 2, childAspectRatio: 1, crossAxisSpacing: 0, @@ -158,6 +161,9 @@ class WalletsHome extends StatelessWidget { ), )), ListTile( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.vertical( + bottom: Radius.circular(12))), // contentPadding: const EdgeInsets.only(left: 7.0), tileColor: _repository.id() == defaultWallet.id() ? Color(0xffD28928) @@ -219,6 +225,7 @@ class WalletsHome extends StatelessWidget { Padding( padding: const EdgeInsets.all(8.0), child: ElevatedButton( + key: Key('validDerivation'), style: ElevatedButton.styleFrom( elevation: 1, primary: Color(0xffFFD68E), // background diff --git a/lib/screens/onBoarding/0_noKeychainFound.dart b/lib/screens/onBoarding/0_noKeychainFound.dart index d5c9acb..3cc2c10 100644 --- a/lib/screens/onBoarding/0_noKeychainFound.dart +++ b/lib/screens/onBoarding/0_noKeychainFound.dart @@ -23,14 +23,15 @@ class NoKeyChainScreen extends StatelessWidget { child: Column(children: [ common.onboardingProgressBar(context, 'Mes portefeuilles', 0), common.bubbleSpeak( - "Je ne connais pour l’instant aucun de vos portefeuilles.\n\nVous pouvez en créer un nouveau, ou bien importer un portefeuille Cesium existant.", - ), + "Je ne connais pour l’instant aucun de vos portefeuilles.\n\nVous pouvez en créer un nouveau, ou bien importer un portefeuille Cesium existant.", + textKey: Key('textOnboarding')), SizedBox(height: 90), Container( child: ClipOval( child: Material( color: Color(0xffFFD58D), // button color child: InkWell( + key: Key('goStep1'), splashColor: Color(0xffD28928), // inkwell color child: Padding( padding: EdgeInsets.all(8), diff --git a/lib/screens/onBoarding/1.dart b/lib/screens/onBoarding/1.dart index 8be6764..cf6ba13 100644 --- a/lib/screens/onBoarding/1.dart +++ b/lib/screens/onBoarding/1.dart @@ -22,8 +22,8 @@ class OnboardingStepOne extends StatelessWidget { common.onboardingProgressBar( context, 'Nouveau portefeuilles', progress), common.bubbleSpeak( - "Il semblerait que vous n’ayez pas encore de trousseau.\n\nUn trousseau vous permet de gérer un ou plusieurs portefeuilles.", - ), + "Il semblerait que vous n’ayez pas encore de trousseau.\n\nUn trousseau vous permet de gérer un ou plusieurs portefeuilles.", + textKey: Key('step1')), SizedBox(height: 90), Image.asset( 'assets/onBoarding/keys-and-wallets-horizontal.png', @@ -36,6 +36,7 @@ class OnboardingStepOne extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( + key: Key('goStep2'), style: ElevatedButton.styleFrom( elevation: 5, primary: Color(0xffD28928), diff --git a/lib/screens/onBoarding/10.dart b/lib/screens/onBoarding/10.dart index a70f5e8..798d463 100644 --- a/lib/screens/onBoarding/10.dart +++ b/lib/screens/onBoarding/10.dart @@ -21,7 +21,9 @@ class OnboardingStepTwelve extends StatelessWidget { common.onboardingProgressBar( context, 'Ma phrase de restauration', progress), common.bubbleSpeak( - "Si un jour vous changez de téléphone, votre code secret sera différent, mais il vous suffira de me redonner votre phrase de restauration pour recréer votre trousseau."), + "Si un jour vous changez de téléphone, votre code secret sera différent, mais il vous suffira de me redonner votre phrase de restauration pour recréer votre trousseau.", + textKey: Key('step10'), + ), SizedBox(height: 10), Image.asset( 'assets/onBoarding/plusieurs-codes-secrets-un-trousseau.png', @@ -34,6 +36,7 @@ class OnboardingStepTwelve extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( + key: Key('goStep11'), style: ElevatedButton.styleFrom( elevation: 5, primary: Color(0xffD28928), diff --git a/lib/screens/onBoarding/11.dart b/lib/screens/onBoarding/11.dart index b10fd02..42969df 100644 --- a/lib/screens/onBoarding/11.dart +++ b/lib/screens/onBoarding/11.dart @@ -35,23 +35,27 @@ class OnboardingStepThirteen extends StatelessWidget { }), common.onboardingProgressBar( context, 'Ma phrase de restauration', progress), - common.bubbleSpeakRich([ - TextSpan( - text: - "Et voilà votre code secret !\n\nMémorisez-le ou notez-le, car il vous sera demandé "), - TextSpan( - text: 'à chaque fois', - style: TextStyle(fontWeight: FontWeight.bold)), - TextSpan( - text: - " que vous voudrez effectuer un paiement sur cet appareil."), - ]), + common.bubbleSpeakRich( + [ + TextSpan( + text: + "Et voilà votre code secret !\n\nMémorisez-le ou notez-le, car il vous sera demandé "), + TextSpan( + text: 'à chaque fois', + style: TextStyle(fontWeight: FontWeight.bold)), + TextSpan( + text: + " que vous voudrez effectuer un paiement sur cet appareil."), + ], + textKey: Key('step11'), + ), SizedBox(height: 100), Container( child: Stack( alignment: Alignment.centerRight, children: [ TextField( + key: Key('generatedPin'), enabled: false, controller: _generateWalletProvider.pin, maxLines: 1, @@ -80,6 +84,7 @@ class OnboardingStepThirteen extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( + key: Key('changeSecretCode'), style: ElevatedButton.styleFrom( elevation: 5, primary: Color(0xffFFD58D), @@ -97,6 +102,7 @@ class OnboardingStepThirteen extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( + key: Key('goStep12'), style: ElevatedButton.styleFrom( elevation: 5, primary: Color(0xffD28928), diff --git a/lib/screens/onBoarding/12.dart b/lib/screens/onBoarding/12.dart index 7d10415..8755f57 100644 --- a/lib/screens/onBoarding/12.dart +++ b/lib/screens/onBoarding/12.dart @@ -42,7 +42,9 @@ class OnboardingStepFourteen extends StatelessWidget { common.onboardingProgressBar( context, 'Ma phrase de restauration', progress), common.bubbleSpeak( - "Avez-vous bien mémorisé votre code secret ?\n\nVérifions ça ensemble !\n\nTapez votre code secret dans le champ ci-dessous (après c’est fini, promis-juré-gecko)."), + "Avez-vous bien mémorisé votre code secret ?\n\nVérifions ça ensemble !\n\nTapez votre code secret dans le champ ci-dessous (après c’est fini, promis-juré-gecko).", + textKey: Key('step12'), + ), SizedBox(height: isTall ? 80 : 10), pinForm(context, _walletOptions, _pinLenght, 1, 3) ]), @@ -68,6 +70,7 @@ class OnboardingStepFourteen extends StatelessWidget { child: Padding( padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 30), child: PinCodeTextField( + key: Key('formKey2'), autoFocus: true, appContext: context, pastedTextStyle: TextStyle( @@ -75,7 +78,7 @@ class OnboardingStepFourteen extends StatelessWidget { fontWeight: FontWeight.bold, ), length: _pinLenght, - obscureText: false, + obscureText: true, obscuringCharacter: '*', animationType: AnimationType.fade, validator: (v) { diff --git a/lib/screens/onBoarding/13_congratulations.dart b/lib/screens/onBoarding/13_congratulations.dart index 2cde659..0a1f432 100644 --- a/lib/screens/onBoarding/13_congratulations.dart +++ b/lib/screens/onBoarding/13_congratulations.dart @@ -21,6 +21,7 @@ class OnboardingStepFiveteen extends StatelessWidget { context, 'Ma phrase de restauration', progress), common.bubbleSpeak( "Top !\n\nVotre trousseau de clef et votre portefeuille ont été créés avec un immense succès.\n\nFélicitations !", + textKey: Key('step13'), ), SizedBox(height: isTall ? 20 : 10), Image.asset( @@ -34,6 +35,7 @@ class OnboardingStepFiveteen extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( + key: Key('goWalletHome'), style: ElevatedButton.styleFrom( elevation: 5, primary: Color(0xffD28928), diff --git a/lib/screens/onBoarding/2.dart b/lib/screens/onBoarding/2.dart index 6cdfaf8..0c22019 100644 --- a/lib/screens/onBoarding/2.dart +++ b/lib/screens/onBoarding/2.dart @@ -24,6 +24,7 @@ class OnboardingStepTwo extends StatelessWidget { context, 'Nouveau portefeuilles', progress), common.bubbleSpeak( "Un trousseau est créé à partir d’une phrase de restauration.", + textKey: Key('step2'), ), SizedBox(height: 70), Image.asset( @@ -35,6 +36,7 @@ class OnboardingStepTwo extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( + key: Key('goStep3'), style: ElevatedButton.styleFrom( elevation: 5, primary: Color(0xffD28928), diff --git a/lib/screens/onBoarding/3.dart b/lib/screens/onBoarding/3.dart index 279568f..2300cbb 100644 --- a/lib/screens/onBoarding/3.dart +++ b/lib/screens/onBoarding/3.dart @@ -22,6 +22,7 @@ class OnboardingStepFor extends StatelessWidget { context, 'Ma phrase de restauration', progress), common.bubbleSpeak( "Si un jour vous changez de téléphone, il vous suffira de me redonner votre phrase de restauration pour recréer votre trousseau.", + textKey: Key('step3'), ), SizedBox(height: isTall ? 15 : 0), // Row(children: [ @@ -40,6 +41,7 @@ class OnboardingStepFor extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( + key: Key('goStep4'), style: ElevatedButton.styleFrom( elevation: 5, primary: Color(0xffD28928), diff --git a/lib/screens/onBoarding/4.dart b/lib/screens/onBoarding/4.dart index 4f239df..bb08542 100644 --- a/lib/screens/onBoarding/4.dart +++ b/lib/screens/onBoarding/4.dart @@ -22,6 +22,7 @@ class OnboardingStepFive extends StatelessWidget { context, 'Ma phrase de restauration', progress), common.bubbleSpeak( "Par contre, attention :\n\nDans une blockchain, il n’y a pas de procédure de récupération de trousseau.\n\nSi vous perdez votre phrase de restauration, je ne pourrai pas vous la communiquer, et vous ne pourrez donc plus jamais accéder à votre compte.", + textKey: Key('step4'), ), SizedBox(height: isTall ? 30 : 10), Image.asset( @@ -35,6 +36,7 @@ class OnboardingStepFive extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( + key: Key('goStep5'), style: ElevatedButton.styleFrom( elevation: 5, primary: Color(0xffD28928), diff --git a/lib/screens/onBoarding/5.dart b/lib/screens/onBoarding/5.dart index 38eeece..c2135ba 100644 --- a/lib/screens/onBoarding/5.dart +++ b/lib/screens/onBoarding/5.dart @@ -30,6 +30,7 @@ class OnboardingStepSeven extends StatelessWidget { text: "afin de pouvoir noter votre phrase de restauration."), ], + textKey: Key('step5'), ), Expanded( child: Align( @@ -52,6 +53,7 @@ class OnboardingStepSeven extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( + key: Key('goStep6'), style: ElevatedButton.styleFrom( elevation: 5, primary: Color(0xffD28928), diff --git a/lib/screens/onBoarding/6.dart b/lib/screens/onBoarding/6.dart index 2988d1a..97eacfe 100644 --- a/lib/screens/onBoarding/6.dart +++ b/lib/screens/onBoarding/6.dart @@ -23,6 +23,7 @@ class OnboardingStepEight extends StatelessWidget { context, 'Ma phrase de restauration', progress), common.bubbleSpeak( "J’ai généré votre phrase de restauration !\nTâchez de la garder bien secrète, car elle permet à quiconque la connaît d’accéder à tous vos portefeuilles.", + textKey: Key('step6'), ), SizedBox(height: isTall ? 61 : 31), // SizedBox(height: 30), @@ -35,6 +36,7 @@ class OnboardingStepEight extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( + key: Key('goStep7'), style: ElevatedButton.styleFrom( elevation: 5, primary: Color(0xffD28928), diff --git a/lib/screens/onBoarding/7.dart b/lib/screens/onBoarding/7.dart index be08955..817e0bb 100644 --- a/lib/screens/onBoarding/7.dart +++ b/lib/screens/onBoarding/7.dart @@ -28,7 +28,8 @@ class OnboardingStepNine extends StatelessWidget { common.onboardingProgressBar( context, 'Ma phrase de restauration', progress), common.bubbleSpeak( - "C’est le moment de noter votre phrase !", + "C'est le moment de noter votre phrase !", + textKey: Key('step7'), long: 60, ), SizedBox(height: isTall ? 100 : 70), @@ -55,6 +56,7 @@ class OnboardingStepNine extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( + key: Key('generateMnemonic'), style: ElevatedButton.styleFrom( elevation: 5, primary: Color(0xffFFD58D), @@ -71,6 +73,7 @@ class OnboardingStepNine extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( + key: Key('goStep8'), style: ElevatedButton.styleFrom( elevation: 5, primary: Color(0xffD28928), @@ -124,6 +127,7 @@ Widget sentanceArray(BuildContext context) { '12:...', ], builder: (context, formatedArray) { + // print(formatedArray.data); return Container( padding: EdgeInsets.symmetric(horizontal: 12), child: Container( @@ -171,6 +175,7 @@ Widget arrayCell(dataWord) { Text(dataWord.split(':')[0], style: TextStyle(fontSize: 14)), SizedBox(height: 2), Text(dataWord.split(':')[1], + key: Key('word${dataWord.split(':')[0]}'), style: TextStyle(fontSize: 19, color: Colors.black)), ])); } diff --git a/lib/screens/onBoarding/8.dart b/lib/screens/onBoarding/8.dart index 020e8c3..56733e2 100644 --- a/lib/screens/onBoarding/8.dart +++ b/lib/screens/onBoarding/8.dart @@ -46,19 +46,22 @@ class OnboardingStepTen extends StatelessWidget { child: Column(children: [ common.onboardingProgressBar( context, 'Valider ma phrase de restauration', progress), - common.bubbleSpeakRich([ - TextSpan( - text: - "Avez-vous bien noté votre phrase de restauration ?\n\nPour en être sûr, veuillez taper dans le champ ci-dessous le ", - style: TextStyle(fontSize: 16 * ratio)), - TextSpan( - text: '${_generateWalletProvider.nbrWord + 1}ème mot', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 16 * ratio)), - TextSpan( - text: " de votre phrase de restauration :", - style: TextStyle(fontSize: 16 * ratio)), - ]), + common.bubbleSpeakRich( + [ + TextSpan( + text: + "Avez-vous bien noté votre phrase de restauration ?\n\nPour en être sûr, veuillez taper dans le champ ci-dessous le ", + style: TextStyle(fontSize: 16 * ratio)), + TextSpan( + text: '${_generateWalletProvider.nbrWord + 1}ème mot', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 16 * ratio)), + TextSpan( + text: " de votre phrase de restauration :", + style: TextStyle(fontSize: 16 * ratio)), + ], + textKey: Key('step8'), + ), // LayoutBuilder(builder: (builder, constraints) { // // 2 @@ -103,12 +106,13 @@ class OnboardingStepTen extends StatelessWidget { // ), SizedBox(height: isTall ? 70 : 10), - if (isTall) - Text('${_generateWalletProvider.nbrWord + 1}', - style: TextStyle( - fontSize: 17, - color: Color(0xffD28928), - fontWeight: FontWeight.w400)), + + Text('${_generateWalletProvider.nbrWord + 1}', + key: Key('askedWord'), + style: TextStyle( + fontSize: isTall ? 17 : 10, + color: Color(0xffD28928), + fontWeight: FontWeight.w400)), SizedBox(height: isTall ? 10 : 0), Container( decoration: BoxDecoration( @@ -119,6 +123,7 @@ class OnboardingStepTen extends StatelessWidget { )), width: 430, child: TextFormField( + key: Key('inputWord'), autofocus: true, enabled: !_generateWalletProvider.isAskedWordValid, controller: this.wordController, @@ -154,6 +159,7 @@ class OnboardingStepTen extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( + key: Key('goStep9'), style: ElevatedButton.styleFrom( elevation: 5, primary: Color(0xffD28928), diff --git a/lib/screens/onBoarding/9.dart b/lib/screens/onBoarding/9.dart index d34f138..22e67c9 100644 --- a/lib/screens/onBoarding/9.dart +++ b/lib/screens/onBoarding/9.dart @@ -20,15 +20,18 @@ class OnboardingStepEleven extends StatelessWidget { child: Column(children: [ common.onboardingProgressBar( context, 'Ma phrase de restauration', progress), - common.bubbleSpeakRich([ - TextSpan(text: "Super !\n\nJe vais maintenant créer votre "), - TextSpan( - text: 'code secret.', - style: TextStyle(fontWeight: FontWeight.bold)), - TextSpan( - text: - " \n\nVotre code secret chiffre votre trousseau de clefs, ce qui le rend inutilisable par d’autres, par exemple si vous perdez votre téléphone ou si on vous le vole."), - ]), + common.bubbleSpeakRich( + [ + TextSpan(text: "Super !\n\nJe vais maintenant créer votre "), + TextSpan( + text: 'code secret.', + style: TextStyle(fontWeight: FontWeight.bold)), + TextSpan( + text: + " \n\nVotre code secret chiffre votre trousseau de clefs, ce qui le rend inutilisable par d’autres, par exemple si vous perdez votre téléphone ou si on vous le vole."), + ], + textKey: Key('step9'), + ), SizedBox(height: isTall ? 50 : 10), Image.asset( 'assets/onBoarding/treasure-chest-gecko-souligne.png', @@ -41,6 +44,7 @@ class OnboardingStepEleven extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( + key: Key('goStep10'), style: ElevatedButton.styleFrom( elevation: 5, primary: Color(0xffD28928), diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index 7912f80..56a2628 100644 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -35,7 +35,7 @@ class SettingsScreen extends StatelessWidget { body: Column(children: [ SizedBox(height: 40), SizedBox( - height: 50, + height: 70, width: 500, child: ElevatedButton( style: ElevatedButton.styleFrom( @@ -52,27 +52,30 @@ class SettingsScreen extends StatelessWidget { if (value == true) {Navigator.pop(context)} }), child: Text("Importer un portefeuille Cesium", - style: TextStyle(fontSize: 15)))), - SizedBox(height: 20), + style: TextStyle(fontSize: 16)))), + SizedBox(height: 30), SizedBox( - height: 50, + height: 70, width: 500, child: ElevatedButton( + key: Key('generateKeychain'), style: ElevatedButton.styleFrom( elevation: 5, primary: Color(0xFFFFCA6F), // background onPrimary: Colors.black, // foreground ), - onPressed: () => Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return GenerateWalletsScreen(); - }), - ).then((value) => { - if (value == true) {Navigator.pop(context)} - }), + onPressed: !_myWallets.checkIfWalletExist() + ? () => Navigator.push( + context, + MaterialPageRoute(builder: (context) { + return GenerateWalletsScreen(); + }), + ).then((value) => { + if (value == true) {Navigator.pop(context)} + }) + : null, child: Text("Générer un nouveau trousseau", - style: TextStyle(fontSize: 15)))), + style: TextStyle(fontSize: 16)))), Expanded( child: Align( alignment: Alignment.bottomCenter, @@ -80,6 +83,7 @@ class SettingsScreen extends StatelessWidget { height: 100, width: 500, child: ElevatedButton( + key: Key('deleteAllWallets'), style: ElevatedButton.styleFrom( elevation: 5, primary: Colors.redAccent, // background @@ -89,8 +93,7 @@ class SettingsScreen extends StatelessWidget { log.i('Suppression de tous les wallets'), await _myWallets.deleteAllWallet(context) }, - child: Text( - "EFFACER TOUS MES PORTEFEUILLES, LE TEMPS DE L'ALPHA", + child: Text("EFFACER TOUS MES PORTEFEUILLES", style: TextStyle(fontSize: 20)))))), SizedBox(height: 50), ])); diff --git a/pubspec.lock b/pubspec.lock index 6d1b885..45f9583 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,20 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + url: "https://pub.dartlang.org" + source: hosted + version: "20.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.0" archive: dependency: transitive description: @@ -64,6 +78,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + cli_util: + dependency: transitive + description: + name: cli_util + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0" clock: dependency: transitive description: @@ -99,6 +120,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + coverage: + dependency: transitive + description: + name: coverage + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" crypto: dependency: "direct main" description: @@ -153,6 +188,11 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_driver: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" flutter_launcher_icons: dependency: "direct main" description: @@ -191,6 +231,18 @@ packages: description: flutter source: sdk version: "0.0.0" + fuchsia_remote_debug_protocol: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + glob: + dependency: transitive + description: + name: glob + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" globbing: dependency: transitive description: @@ -275,6 +327,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.13.0" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" http_parser: dependency: transitive description: @@ -324,6 +383,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.17.0" + io: + dependency: transitive + description: + name: io + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" isolate: dependency: transitive description: @@ -352,6 +418,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" + logging: + dependency: transitive + description: + name: logging + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -366,6 +439,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + mime: + dependency: transitive + description: + name: mime + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" nested: dependency: transitive description: @@ -373,6 +453,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.0.4" + node_preamble: + dependency: transitive + description: + name: node_preamble + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" normalize: dependency: transitive description: @@ -380,6 +467,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.5.0-nullsafety.0" + package_config: + dependency: transitive + description: + name: package_config + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" package_info: dependency: "direct main" description: @@ -541,6 +635,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + pool: + dependency: transitive + description: + name: pool + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.0" printing: dependency: "direct main" description: @@ -554,7 +655,7 @@ packages: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.1.0" + version: "4.2.1" provider: dependency: "direct main" description: @@ -562,6 +663,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.3.2+3" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" qr: dependency: transitive description: @@ -653,18 +761,60 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + shelf: + dependency: transitive + description: + name: shelf + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + shelf_static: + dependency: transitive + description: + name: shelf_static + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + source_maps: + dependency: transitive + description: + name: source_maps + url: "https://pub.dartlang.org" + source: hosted + version: "0.10.10" source_span: dependency: transitive description: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -699,7 +849,7 @@ packages: name: sync_http url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.3.0" system_info: dependency: transitive description: @@ -714,13 +864,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + test: + dependency: "direct main" + description: + name: test + url: "https://pub.dartlang.org" + source: hosted + version: "1.16.8" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" + test_core: + dependency: transitive + description: + name: test_core + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.19" truncate: dependency: "direct main" description: @@ -735,6 +899,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + unorm_dart: + dependency: "direct main" + description: + name: unorm_dart + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" uuid: dependency: transitive description: @@ -749,6 +920,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + vm_service: + dependency: transitive + description: + name: vm_service + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.0+1" + watcher: + dependency: transitive + description: + name: watcher + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" web_socket_channel: dependency: transitive description: @@ -756,6 +941,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + webdriver: + dependency: transitive + description: + name: webdriver + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" win32: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 89976f8..ab85da5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,7 +34,7 @@ dependencies: pdf: ^3.0.1 printing: ^5.0.2 shared_preferences: ^2.0.3 - sync_http: ^0.2.0 + sync_http: ^0.3.0 crypto: ^3.0.0 fast_base58: logger: ^1.0.0 @@ -47,6 +47,10 @@ dependencies: responsive_builder: ^0.3.0 jdenticon_dart: ^2.0.0 audioplayers: ^0.18.1 + flutter_driver: + sdk: flutter + test: ^1.16.8 + unorm_dart: ^0.2.0 flutter_icons: android: "ic_launcher" diff --git a/scripts/startIntegrationsTests.sh b/scripts/startIntegrationsTests.sh new file mode 100755 index 0000000..eca24d1 --- /dev/null +++ b/scripts/startIntegrationsTests.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +flutter drive --target=test_driver/app.dart diff --git a/test_driver/app.dart b/test_driver/app.dart new file mode 100644 index 0000000..ec9a318 --- /dev/null +++ b/test_driver/app.dart @@ -0,0 +1,11 @@ +import 'package:flutter_driver/driver_extension.dart'; +import 'package:gecko/main.dart' as app; + +void main() { + // This line enables the extension. + enableFlutterDriverExtension(); + + // Call the `main()` function of the app, or call `runApp` with + // any widget you are interested in testing. + app.main(); +} diff --git a/test_driver/app_test.dart b/test_driver/app_test.dart new file mode 100644 index 0000000..0083329 --- /dev/null +++ b/test_driver/app_test.dart @@ -0,0 +1,430 @@ +// Imports the Flutter Driver API. +import 'dart:async'; +import 'dart:io'; +import 'package:flutter_driver/flutter_driver.dart'; +import 'package:test/test.dart'; +// import 'package:flutter/services.dart'; + +void main() { + int globalTimeout = 2; + group('Gecko App', () { + // First, define the Finders and use them to locate widgets from the + // test suite. Note: the Strings provided to the `byValueKey` method must + // be the same as the Strings we used for the Keys in step 1. + final manageWalletsFinder = find.byValueKey('manageWallets'); + // final buttonFinder = find.byValueKey('increment'); + + FlutterDriver driver; + String pinCode; + + // Connect to the Flutter driver before running any tests. + setUpAll(() async { + driver = await FlutterDriver.connect(); + await driver.waitUntilFirstFrameRasterized(); + }); + + // Close the connection to the driver after the tests have completed. + tearDownAll(() async { + if (driver != null) { + driver.close(); + } + }); + + // *** Global functions *** // + + // Function to tap the widget by key + Future tapOn(String key) async { + await driver.tap(find.byValueKey(key)); + } + + // Easy get text + Future getText(String text) async { + return await driver.getText(find.byValueKey( + text, + )); + } + + // Function to go back to previous screen + Future goBack() async { + await Process.run( + 'adb', + ['shell', 'input', 'keyevent', 'KEYCODE_BACK'], + runInShell: true, + ); + } + + // Easy sleep + Future sleep(int _time) async { + await Future.delayed(Duration(milliseconds: _time)); + } + + // Test if widget exist on screen, return a boolean + Future isPresent(SerializableFinder byValueKey, + {Duration timeout = const Duration(seconds: 1)}) async { + try { + await driver.waitFor(byValueKey, timeout: timeout); + return true; + } catch (exception) { + return false; + } + } + + // Create a derivation + Future createDerivation(String _name) async { + await tapOn('addDerivation'); + await sleep(100); + + await driver.enterText(_name); + + await tapOn('validDerivation'); + await sleep(300); + } + + // 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 all wallets + Future deleteAllWallets() async { + await tapOn('drawerMenu'); + await sleep(300); + await tapOn('parameters'); + await sleep(300); + await tapOn('deleteAllWallets'); + await sleep(300); + await tapOn('confirmDeletingAllWallets'); + await sleep(300); + } + + // Fast creation of new Keychain + Future createNewKeychain(String name) async { + await tapOn('drawerMenu'); + await sleep(300); + await tapOn('parameters'); + await sleep(300); + await tapOn('generateKeychain'); + while (await getText('generatedPin') == '') { + print('Waiting for pin code generation...'); + await sleep(100); + } + pinCode = await getText('generatedPin'); + await tapOn('storeKeychain'); + await sleep(100); + await driver.enterText('triche'); + await tapOn('walletName'); + await driver.enterText(name); + await tapOn('confirmStorage'); + await sleep(300); + return pinCode; + } + + // *** Begin of tests *** // + + test('OnBoarding - Open wallets management', ( + {timeout: Timeout.none}) async { + // await driver.runUnsynchronized(() async { // Needed if we want to manage async drivers + await driver.tap(manageWalletsFinder); + + print( + '####################################################################'); + + // If a wallet exist, go to delete theme all + if (!await isPresent(find.byValueKey('goStep1'))) { + await goBack(); + + await deleteAllWallets(); + + await driver.tap(manageWalletsFinder); + } + + // Get the SerializableFinder for text widget with key 'textOnboarding' + SerializableFinder textOnboarding = find.byValueKey( + 'textOnboarding', + ); + + await sleep(100); + + // Verify onboarding is starting, with text + expect(await driver.getText(textOnboarding), + "Je ne connais pour l’instant aucun de vos portefeuilles.\n\nVous pouvez en créer un nouveau, ou bien importer un portefeuille Cesium existant."); + }); + + test('OnBoarding - Go to create restore sentance', ( + {timeout: Timeout.none}) async { + await tapOn('goStep1'); + await tapOn('goStep2'); + await tapOn('goStep3'); + await tapOn('goStep4'); + await tapOn('goStep5'); + await tapOn('goStep6'); + + expect( + await driver.getText(find.byValueKey( + 'step6', + )), + "J’ai généré votre phrase de restauration !\nTâchez de la garder bien secrète, car elle permet à quiconque la connaît d’accéder à tous vos portefeuilles."); + }); + + test('OnBoarding - Generate sentance and confirme it', ( + {timeout: Timeout.none}) async { + await tapOn('goStep7'); + + while (await getText('word1') == '...') { + print('Waiting for Mnemonic generation...'); + await sleep(100); + } + + Future selectWord() async { + List words = [for (var i = 1; i <= 13; i += 1) i]; + + for (var j = 1; j < 13; j++) { + words[j] = await getText('word$j'); + } + expect( + await getText('step7'), "C'est le moment de noter votre phrase !"); + + await tapOn('goStep8'); + await sleep(200); + + String goodWord = words[int.parse( + await getText('askedWord'), + )]; + + // Enter the expected word + await driver.enterText(goodWord); + + // Check if word is valid + await driver.waitFor(find.text("C'est le bon mot !")); + + // Continue onboarding workflow + await tapOn('goStep9'); + } + + await selectWord(); + + //Go back 2 times to mnemonic generation screen + await goBack(); + await goBack(); + await sleep(100); + + // Generate 3 times mnemonic + await tapOn('generateMnemonic'); + await tapOn('generateMnemonic'); + await tapOn('generateMnemonic'); + await sleep(500); + + await selectWord(); + }); + test('OnBoarding - Generate secret code and confirm it', ( + {timeout: Timeout.none}) async { + expect(await getText('step9'), + "Super !\n\nJe vais maintenant créer votre code secret. \n\nVotre code secret chiffre votre trousseau de clefs, ce qui le rend inutilisable par d’autres, par exemple si vous perdez votre téléphone ou si on vous le vole."); + + await tapOn('goStep10'); + await tapOn('goStep11'); + + while (await getText('generatedPin') == '') { + print('Waiting for pin code generation...'); + await sleep(100); + } + + // 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 sleep(300); + + // //Enter bad secret code + // await driver.enterText('abcde'); + // await tapOn('formKey'); + // await sleep(1500); + // await tapOn('formKey2'); + + //Enter good secret code + await driver.enterText(pinCode); + + expect(await getText('step13'), + "Top !\n\nVotre trousseau de clef et votre portefeuille ont été créés avec un immense succès.\n\nFélicitations !"); + }); + + test('My wallets - Create a derivations, open thems, tap all buttons', ( + {timeout: Timeout.none}) async { + await tapOn('goWalletHome'); + + expect(await getText('myWallets'), "Mes portefeuilles"); + await sleep(300); + + // Add a second derivation + 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 third derivation + await deleteWallet(true); + }); + + test('My wallets - Extra tests', ({timeout: Timeout.none}) async { + // 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')); + await sleep(300); + + // Display history, copy pubkey, go back and rename wallet name + await tapOn('displayHistory'); + await sleep(400); + await tapOn('copyPubkey'); + await driver.waitFor(find + .text('Cette clé publique a été copié dans votre presse-papier.')); + await sleep(800); + await goBack(); + await sleep(300); + await tapOn('renameWallet'); + await sleep(100); + await tapOn('walletName'); + await sleep(100); + await driver.enterText('Renommage wallet 2'); + await sleep(300); + await tapOn('renameWallet'); + await sleep(400); + await goBack(); + await driver.waitFor(find.text('Renommage wallet 2')); + await createDerivation('Derivation 8'); + await createDerivation('Derivation 9'); + await createDerivation('Derivation 10'); + await createDerivation('Derivation 11'); + await createDerivation('Derivation 12'); + await createDerivation('Derivation 13'); + await createDerivation('Derivation 14'); + await createDerivation('Derivation 15'); + await createDerivation('Derivation 16'); + await createDerivation('Derivation 17'); + await createDerivation('Derivation 18'); + await createDerivation('Derivation 19'); + await createDerivation('Derivation 20'); + await sleep(400); + + // Scroll the wallet screen until Derivation 20 and open it + await driver.scrollUntilVisible( + find.byValueKey('listWallets'), + find.text('Derivation 20'), + dyScroll: -300.0, + ); + + await driver.waitFor(find.text('Derivation 20')); + await sleep(400); + await driver.tap(find.text('Derivation 20')); + await tapOn('copyPubkey'); + }); + + test('Search - Search Pi profile, navigate in history transactions', ( + {timeout: Timeout.none}) async { + await goBack(); + await goBack(); + await sleep(200); + await tapOn('searchIcon'); + await sleep(400); + await driver.enterText('D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU'); + await sleep(100); + await tapOn('copyPubkey'); + await sleep(500); + await tapOn('switchPayHistory'); + await sleep(1200); + // await driver.scrollIntoView(find.byValueKey('listTransactions')); + await driver.scrollUntilVisible( + find.byValueKey('listTransactions'), + find.byValueKey('transaction35'), + dyScroll: -600.0, + ); + await sleep(100); + await tapOn('transaction33'); + await driver.waitFor(find.text('Commentaire:')); + + // Want to paste pubkey copied, but doesn't work actualy with flutter driver: https://github.com/flutter/flutter/issues/47448 + // final ClipboardData pubkeyCopied = + // await Clipboard.getData(Clipboard.kTextPlain); + // await driver.enterText(pubkeyCopied.text); + + await sleep(300); + }, timeout: Timeout(Duration(minutes: globalTimeout))); + + test('Wallet generation - Fast wallets generations', ( + {timeout: Timeout.none}) async { + await goBack(); + await goBack(); + await deleteAllWallets(); + await sleep(100); + final String pincode = await createNewKeychain('Fast wallet'); + await sleep(100); + await tapOn('manageWallets'); + await sleep(200); + await driver.enterText(pincode); + await sleep(100); + await createDerivation('Derivation 2'); + await sleep(100); + await driver.tap(find.text('Fast wallet')); + await driver.waitFor(find.text('Fast wallet')); + // Wait 3 seconds at the end + await sleep(3000); + }); + }, timeout: Timeout(Duration(minutes: globalTimeout))); +}