diff --git a/integration_test/gecko_complete.dart b/integration_test/gecko_complete.dart index 7157f11..bcf1c23 100644 --- a/integration_test/gecko_complete.dart +++ b/integration_test/gecko_complete.dart @@ -134,6 +134,6 @@ Future certifyTest5() async { // Check UD reval await spawnBlock(until: 50); - await waitFor('509.35'); + await waitFor('509.36'); humanRead(5); } diff --git a/integration_test/general_actions.dart b/integration_test/general_actions.dart index cf8dfc1..8a734cd 100644 --- a/integration_test/general_actions.dart +++ b/integration_test/general_actions.dart @@ -3,6 +3,8 @@ 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'; +import 'package:gecko/providers/generate_wallets.dart'; +import 'package:provider/provider.dart'; import 'tests_utility.dart'; // GENERAL ACTIONS @@ -83,6 +85,68 @@ Future restoreChest() async { await goBack(); } +Future onboardingNewChest() async { + final generateWalletProvider = + Provider.of(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); + await waitFor('Continuer', exactMatch: true); + 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 + await waitFor('Accéder à mon coffre'); + + // Go to wallets home + await tapKey(keyGoWalletsHome, duration: 0); + + // Check if string "ĞD" is present in screen + await waitFor('Mon portefeuille co'); + await waitFor('0.0 $currencyName'); +} + Future addDerivation() async { await tapKey(keyAddDerivation); await waitFor('Portefeuille 5'); diff --git a/integration_test/launch_test.sh b/integration_test/launch_test.sh index 9259b2f..44e9c02 100755 --- a/integration_test/launch_test.sh +++ b/integration_test/launch_test.sh @@ -17,7 +17,7 @@ docker-compose up -d cd ../.. # Start integration test -flutter test integration_test/$testName.dart +flutter test integration_test/$testName.dart && echo '0' > /tmp/geckoTestResult || echo '1' > /tmp/geckoTestResult # Reset .env echo "ip_address=127.0.0.1" > .env diff --git a/integration_test/multi_chests.dart b/integration_test/multi_chests.dart new file mode 100644 index 0000000..2b299db --- /dev/null +++ b/integration_test/multi_chests.dart @@ -0,0 +1,17 @@ +import 'package:flutter_dotenv/flutter_dotenv.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:gecko/models/widgets_keys.dart'; +import 'package:integration_test/integration_test.dart'; +import 'general_actions.dart'; +import 'tests_utility.dart'; + +void main() async { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + await dotenv.load(); + + testWidgets('Onboarding and multi chest', (testerLoc) async { + tester = testerLoc; + await bkFastStart(false); + await onboardingNewChest(); + }, timeout: testTimeout()); +} diff --git a/integration_test/tests_utility.dart b/integration_test/tests_utility.dart index bb39cab..e8c60b7 100644 --- a/integration_test/tests_utility.dart +++ b/integration_test/tests_utility.dart @@ -265,13 +265,19 @@ Future _addImportAccount( Future bkDeleteAllWallets() async { final myWalletProvider = Provider.of(homeContext, listen: false); - if (myWalletProvider.listWallets.isNotEmpty) { - await myWalletProvider.deleteAllWallet(homeContext); + final isWalletsPresents = + await isPresent('Scanner un', timeout: const Duration(milliseconds: 300)); + if (isWalletsPresents) { + await walletBox.clear(); + await chestBox.clear(); + await configBox.delete('defaultWallet'); + await sub.deleteAllAccounts(); + myWalletProvider.pinCode = ''; myWalletProvider.rebuildWidget(); } } -Future bkFastStart() async { +Future bkFastStart([bool restoreChest = true]) async { // Start app and wait finish starting await startWait(); @@ -282,16 +288,23 @@ Future bkFastStart() async { // Delete all existing chests is exists await bkDeleteAllWallets(); - // Restore the test chest - await bkRestoreChest(); - await waitFor("y'a pas de lézard"); + if (restoreChest) { + // Restore the test chest + await bkRestoreChest(); + await waitFor("y'a pas de lézard"); + } } Future startWait() async { app.main(); await waitFor('Test starting...', reverse: true); await tester.pumpAndSettle(const Duration(milliseconds: 300)); - await sleep(2000); + await sleep(3000); +} + +String getWidgetText(Key key) { + final word4Finder = find.byKey(key); + return (word4Finder.evaluate().single.widget as Text).data!; } class TestWallet { diff --git a/lib/models/widgets_keys.dart b/lib/models/widgets_keys.dart index e10c39d..85bb691 100644 --- a/lib/models/widgets_keys.dart +++ b/lib/models/widgets_keys.dart @@ -16,6 +16,7 @@ const keyDrawerMenu = Key('keyDrawerMenu'); const keyOpenWalletsHomme = Key('keyOpenWalletsHomme'); const keyOpenSearch = Key('keyOpenSearch'); const keyRestoreChest = Key('keyRestoreChest'); +const keyOnboardingNewChest = Key('keyOnboardingNewChest'); // Wallets home const keyImportG1v1 = Key('keyImportG1v1'); diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 8850781..2516f86 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -538,7 +538,7 @@ Widget welcomeHome(context) { SizedBox( width: 410, height: 70, - child: ElevatedButton( + child: ElevatedButton(key: keyOnboardingNewChest, style: ElevatedButton.styleFrom( elevation: 4, primary: orangeC, // background diff --git a/lib/screens/onBoarding/10.dart b/lib/screens/onBoarding/10.dart index 82df70c..e3150a1 100644 --- a/lib/screens/onBoarding/10.dart +++ b/lib/screens/onBoarding/10.dart @@ -1,6 +1,7 @@ // ignore_for_file: file_names import 'dart:async'; +import 'dart:io'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; @@ -228,6 +229,7 @@ class OnboardingStepTen extends StatelessWidget { generateWalletProvider.generatedMnemonic = ''; myWalletProvider.resetPinCode(); + // sleep(const Duration(milliseconds: 500)); Navigator.push( context, FaderTransition( diff --git a/lib/screens/onBoarding/11_congratulations.dart b/lib/screens/onBoarding/11_congratulations.dart index 11f6b29..de1747d 100644 --- a/lib/screens/onBoarding/11_congratulations.dart +++ b/lib/screens/onBoarding/11_congratulations.dart @@ -1,5 +1,7 @@ // ignore_for_file: file_names +import 'dart:io'; + import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; @@ -62,13 +64,12 @@ Widget finishButton(BuildContext context) { onPrimary: Colors.white, // foreground ), onPressed: () { - Navigator.pushAndRemoveUntil( - context, - MaterialPageRoute(builder: (context) { - return const WalletsHome(); - }), - ModalRoute.withName('/'), - ); + // sleep(const Duration(milliseconds: 50)); + Navigator.popUntil(homeContext, ModalRoute.withName('/')); + // sleep(const Duration(milliseconds: 500)); + Navigator.pushNamed(homeContext, '/mywallets'); + // Navigator.pushNamedAndRemoveUntil( + // homeContext, '/mywallets', ModalRoute.withName('/')); }, child: Text("accessMyChest".tr(), style: diff --git a/lib/screens/onBoarding/5.dart b/lib/screens/onBoarding/5.dart index 55e2466..dd4907c 100644 --- a/lib/screens/onBoarding/5.dart +++ b/lib/screens/onBoarding/5.dart @@ -102,7 +102,8 @@ class _ChooseChestState extends State { SizedBox(height: 22 * ratio), nextButton( context, "iNotedMyMnemonic".tr(), false, widget.skipIntro), - SizedBox(height: 35 * ratio), + const Spacer(), + // SizedBox(height: 35 * ratio), ]), CommonElements().offlineInfo(context), ]), @@ -231,6 +232,7 @@ Widget nextButton( width: 380 * ratio, height: 60 * ratio, child: ElevatedButton( + key: keyGoNext, style: ElevatedButton.styleFrom( elevation: 4, primary: orangeC, // background diff --git a/lib/screens/onBoarding/6.dart b/lib/screens/onBoarding/6.dart index 309ae29..2c8562b 100644 --- a/lib/screens/onBoarding/6.dart +++ b/lib/screens/onBoarding/6.dart @@ -225,6 +225,7 @@ Widget nextButton(BuildContext context, String text, nextScreen, bool isFast) { width: 380 * ratio, height: 60 * ratio, child: ElevatedButton( + key: keyGoNext, style: ElevatedButton.styleFrom( elevation: 4, primary: orangeC, // background diff --git a/lib/screens/transaction_in_progress.dart b/lib/screens/transaction_in_progress.dart index febc0ed..9c8b261 100644 --- a/lib/screens/transaction_in_progress.dart +++ b/lib/screens/transaction_in_progress.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/services.dart'; import 'package:gecko/globals.dart';