improve test speed

This commit is contained in:
poka 2022-08-25 00:26:04 +02:00
parent c060c85df8
commit 05f41e16a9
3 changed files with 36 additions and 30 deletions

View File

@ -72,7 +72,6 @@ Future restoreChest(WidgetTester tester) async {
// Tap on button to paste mnemonic
await goKey(tester, keyPastMnemonic);
await tester.pumpAndSettle();
// Tap on next button 4 times to skip 3 screen
await goKey(tester, keyGoNext);
@ -84,16 +83,16 @@ Future restoreChest(WidgetTester tester) async {
final isCached = await isIconPresent(tester, Icons.check_box);
// If not, tap on to cache password
if (!isCached) await goKey(tester, keyCachePassword);
if (!isCached) await goKey(tester, keyCachePassword, duration: 0);
// Enter password
await enterText(tester, keyPinForm, 'AAAAA');
await enterText(tester, keyPinForm, 'AAAAA', 0);
// Check if string "Accéder à mon coffre" is present in screen
await waitFor(tester, 'Accéder à mon coffre');
// Go to wallets home
await goKey(tester, keyGoWalletsHome);
await goKey(tester, keyGoWalletsHome, duration: 0);
// Check if string "ĞD" is present in screen
await waitFor(tester, 'ĞD');
@ -138,7 +137,7 @@ Future payTest2(WidgetTester tester) async {
await spawnBlock(tester, keyCloseTransactionScreen);
await waitFor(tester, 'validé !', timeout: const Duration(seconds: 1));
await goKey(tester, keyCloseTransactionScreen);
await goKey(tester, keyCloseTransactionScreen, duration: 0);
await waitFor(tester, '12.14');
await spawnBlock(tester, keyViewActivity);
await waitFor(tester, '9.14');
@ -155,7 +154,7 @@ Future certifyTest5(WidgetTester tester) async {
// await sleep(tester);
await goKey(tester, keyCertify);
await goKey(tester, keyConfirm);
await spawnBlock(tester, keyViewActivity);
await spawnBlock(tester, keyViewActivity, duration: 500);
await waitFor(tester, 'validé !', timeout: const Duration(seconds: 1));
await goKey(tester, keyCloseTransactionScreen);
await waitFor(tester, 'Identité créée');
@ -168,7 +167,7 @@ Future certifyTest5(WidgetTester tester) async {
await goKey(tester, keyConfirmIdentity);
await enterText(tester, keyEnterIdentityUsername, 'test5');
await goKey(tester, keyConfirm);
await spawnBlock(tester, keyCloseTransactionScreen);
await spawnBlock(tester, keyCloseTransactionScreen, duration: 500);
await waitFor(tester, 'validé !', timeout: const Duration(seconds: 1));
await goKey(tester, keyCloseTransactionScreen);
await waitFor(tester, 'Identité confirmée');
@ -192,7 +191,7 @@ Future certifyTest5(WidgetTester tester) async {
// Certify with test2 account
await goKey(tester, keyCertify);
await goKey(tester, keyConfirm);
await spawnBlock(tester, keyViewActivity);
await spawnBlock(tester, keyViewActivity, duration: 500);
await waitFor(tester, 'validé !', timeout: const Duration(seconds: 1));
await goKey(tester, keyCloseTransactionScreen);
await waitFor(tester, '2');
@ -208,7 +207,7 @@ Future certifyTest5(WidgetTester tester) async {
// Certify with test3 account
await goKey(tester, keyCertify);
await goKey(tester, keyConfirm);
await spawnBlock(tester, keyViewActivity);
await spawnBlock(tester, keyViewActivity, duration: 500);
await waitFor(tester, 'validé !', timeout: const Duration(seconds: 1));
await goKey(tester, keyCloseTransactionScreen);
await waitFor(tester, 'Vous devez attendre');

View File

@ -12,7 +12,9 @@ Future sleep(WidgetTester tester, [int time = 1000]) async {
Future goKey(WidgetTester tester, Key buttonKey,
{Finder? customFinder, int duration = 100, bool selectLast = false}) async {
await tester.pumpAndSettle(Duration(milliseconds: duration));
if (duration != 0) {
await tester.pumpAndSettle(Duration(milliseconds: duration));
}
final Finder finder = customFinder ?? find.byKey(buttonKey);
log.d('INTEGRATION TEST: Tap on ${finder.description}}');
await tester.tap(selectLast ? finder.last : finder);
@ -28,7 +30,9 @@ Future goBack(WidgetTester tester) async {
Future enterText(WidgetTester tester, Key fieldKey, String textIn,
[int duration = 200]) async {
await tester.pumpAndSettle(Duration(milliseconds: duration));
if (duration != 0) {
await tester.pumpAndSettle(Duration(milliseconds: duration));
}
log.d('INTEGRATION TEST: Enter text: $textIn');
await tester.enterText(find.byKey(fieldKey), textIn);
}
@ -73,8 +77,11 @@ Future<bool> isIconPresent(WidgetTester tester, IconData icon,
return finder.evaluate().isEmpty ? false : true;
}
Future spawnBlock(WidgetTester tester, Key customKey, [int number = 1]) async {
await sleep(tester, 1000);
Future spawnBlock(WidgetTester tester, Key customKey,
{int number = 1, int duration = 200}) async {
if (duration != 0) {
await sleep(tester, duration);
}
final BuildContext context = tester.element(find.byKey(customKey));
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
sub.spawnBlock(number);

View File

@ -133,23 +133,23 @@ class HomeScreen extends StatelessWidget {
// }
// TODO: fix random bad network status on startup
// HomeProvider homeProvider =
// Provider.of<HomeProvider>(ctx, listen: false);
// Connectivity()
// .onConnectivityChanged
// .listen((ConnectivityResult result) async {
// log.d('Network changed: $result');
// if (result == ConnectivityResult.none) {
// sub.nodeConnected = false;
// await sub.sdk.api.setting.unsubscribeBestNumber();
// homeProvider.changeMessage(
// "notConnectedToInternet".tr(), 0);
// sub.reload();
// } else {
// await sub.connectNode(ctx);
// }
// });
await sub.connectNode(ctx);
HomeProvider homeProvider =
Provider.of<HomeProvider>(ctx, listen: false);
Connectivity()
.onConnectivityChanged
.listen((ConnectivityResult result) async {
log.d('Network changed: $result');
if (result == ConnectivityResult.none) {
sub.nodeConnected = false;
await sub.sdk.api.setting.unsubscribeBestNumber();
homeProvider.changeMessage(
"notConnectedToInternet".tr(), 0);
sub.reload();
} else {
await sub.connectNode(ctx);
}
});
// await sub.connectNode(ctx);
}
// _duniterIndexer.checkIndexerEndpointBackground();
});