From e8aaa0e2c02952a46a2bded11fcb582b938d3b4c Mon Sep 17 00:00:00 2001
From: poka <poka@p2p.legal>
Date: Sat, 24 Apr 2021 20:27:18 +0200
Subject: [PATCH] Test go to restore sentance generation

---
 lib/screens/commonElements.dart               | 15 +++---
 lib/screens/onBoarding/0_noKeychainFound.dart |  1 +
 lib/screens/onBoarding/1.dart                 |  5 +-
 lib/screens/onBoarding/10.dart                |  5 +-
 lib/screens/onBoarding/11.dart                | 26 +++++-----
 lib/screens/onBoarding/12.dart                |  4 +-
 .../onBoarding/13_congratulations.dart        |  2 +
 lib/screens/onBoarding/2.dart                 |  2 +
 lib/screens/onBoarding/3.dart                 |  2 +
 lib/screens/onBoarding/4.dart                 |  2 +
 lib/screens/onBoarding/5.dart                 |  2 +
 lib/screens/onBoarding/6.dart                 |  2 +
 lib/screens/onBoarding/7.dart                 |  2 +
 lib/screens/onBoarding/8.dart                 | 30 +++++++-----
 lib/screens/onBoarding/9.dart                 | 22 +++++----
 test_driver/app_test.dart                     | 48 ++++++++++++-------
 16 files changed, 109 insertions(+), 61 deletions(-)

diff --git a/lib/screens/commonElements.dart b/lib/screens/commonElements.dart
index 80d4f787..b6c3d6b8 100644
--- a/lib/screens/commonElements.dart
+++ b/lib/screens/commonElements.dart
@@ -25,7 +25,7 @@ class CommonElements {
     );
   }
 
-  Widget bubbleSpeakRich(List<TextSpan> text) {
+  Widget bubbleSpeakRich(List<TextSpan> text, {Key textKey}) {
     return Bubble(
       padding: BubbleEdges.all(18),
       elevation: 5,
@@ -33,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/onBoarding/0_noKeychainFound.dart b/lib/screens/onBoarding/0_noKeychainFound.dart
index f4ed053d..3cc2c101 100644
--- a/lib/screens/onBoarding/0_noKeychainFound.dart
+++ b/lib/screens/onBoarding/0_noKeychainFound.dart
@@ -31,6 +31,7 @@ class NoKeyChainScreen extends StatelessWidget {
                 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 8be67640..cf6ba138 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 a70f5e87..798d4635 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 b10fd026..f622416a 100644
--- a/lib/screens/onBoarding/11.dart
+++ b/lib/screens/onBoarding/11.dart
@@ -35,17 +35,20 @@ class OnboardingStepThirteen extends StatelessWidget {
                 }),
             common.onboardingProgressBar(
                 context, 'Ma phrase de restauration', progress),
-            common.bubbleSpeakRich(<TextSpan>[
-              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>[
+                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(
@@ -97,6 +100,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 7d104158..48326c15 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)
           ]),
diff --git a/lib/screens/onBoarding/13_congratulations.dart b/lib/screens/onBoarding/13_congratulations.dart
index 2cde659f..0a1f432d 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 6cdfaf89..0c220199 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 279568ff..2300cbb4 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: <Widget>[
@@ -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 4f239df9..bb08542e 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 38eeece6..c2135ba6 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 2988d1ad..97eacfe1 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 be08955f..f0f865c6 100644
--- a/lib/screens/onBoarding/7.dart
+++ b/lib/screens/onBoarding/7.dart
@@ -29,6 +29,7 @@ class OnboardingStepNine extends StatelessWidget {
                 context, 'Ma phrase de restauration', progress),
             common.bubbleSpeak(
               "C’est le moment de noter votre phrase !",
+              textKey: Key('step7'),
               long: 60,
             ),
             SizedBox(height: isTall ? 100 : 70),
@@ -71,6 +72,7 @@ class OnboardingStepNine extends StatelessWidget {
               width: 400,
               height: 62,
               child: ElevatedButton(
+                  key: Key('goStep8'),
                   style: ElevatedButton.styleFrom(
                     elevation: 5,
                     primary: Color(0xffD28928),
diff --git a/lib/screens/onBoarding/8.dart b/lib/screens/onBoarding/8.dart
index 020e8c3a..e7405277 100644
--- a/lib/screens/onBoarding/8.dart
+++ b/lib/screens/onBoarding/8.dart
@@ -46,19 +46,22 @@ class OnboardingStepTen extends StatelessWidget {
               child: Column(children: <Widget>[
                 common.onboardingProgressBar(
                     context, 'Valider ma phrase de restauration', progress),
-                common.bubbleSpeakRich(<TextSpan>[
-                  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>[
+                    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
@@ -154,6 +157,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 d34f1380..3c0a8764 100644
--- a/lib/screens/onBoarding/9.dart
+++ b/lib/screens/onBoarding/9.dart
@@ -20,15 +20,18 @@ class OnboardingStepEleven extends StatelessWidget {
           child: Column(children: <Widget>[
             common.onboardingProgressBar(
                 context, 'Ma phrase de restauration', progress),
-            common.bubbleSpeakRich(<TextSpan>[
-              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>[
+                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('step8'),
+            ),
             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/test_driver/app_test.dart b/test_driver/app_test.dart
index aeebab8b..670f1fae 100644
--- a/test_driver/app_test.dart
+++ b/test_driver/app_test.dart
@@ -26,23 +26,37 @@ void main() {
       }
     });
 
-    test('Open wallets management - OnBoarding', () async {
-      await driver.runUnsynchronized(() async {
-        // First, tap the button manage wallets
-        await driver.tap(manageWalletsFinder);
-
-        // Get the SerializableFinder for text widget with key 'textOnboarding'
-        SerializableFinder textOnboarding = find.byValueKey(
-          'textOnboarding',
-        );
-
-        print(
-            '####################################################################');
-
-        // 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 - Open wallets management', (
+        {timeout: const Duration(seconds: 2)}) async {
+      // await driver.runUnsynchronized(() async { // Needed if we want to manage async drivers
+      await driver.tap(manageWalletsFinder);
+
+      // Get the SerializableFinder for text widget with key 'textOnboarding'
+      SerializableFinder textOnboarding = find.byValueKey(
+        'textOnboarding',
+      );
+
+      print(
+          '####################################################################');
+
+      // 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: const Duration(seconds: 5)}) async {
+      await driver.tap(find.byValueKey('goStep1'));
+      await driver.tap(find.byValueKey('goStep2'));
+      await driver.tap(find.byValueKey('goStep3'));
+      await driver.tap(find.byValueKey('goStep4'));
+      await driver.tap(find.byValueKey('goStep5'));
+
+      expect(
+          await driver.getText(find.byValueKey(
+            'step5',
+          )),
+          "Munissez-vous d'un papier et d’un crayon\nafin de pouvoir noter votre phrase de restauration.");
     });
   });
 }
-- 
GitLab