Skip to content
Snippets Groups Projects
Commit f4ed793e authored by poka's avatar poka
Browse files

tests: fix transactions not validate

parent ea94b457
No related branches found
No related tags found
No related merge requests found
Pipeline #19145 waiting for manual action
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:gecko/models/widgets_keys.dart';
import 'package:integration_test/integration_test.dart';
......@@ -10,6 +11,7 @@ void main() async {
// await dotenv.load();
testWidgets('Gecko complete', (testerLoc) async {
FlutterError.onError = ignoreOverflowErrors;
// Share WidgetTester to test provider
tester = testerLoc;
......@@ -50,8 +52,10 @@ Future payTest2() async {
await enterText(keyAmountField, '12.14');
await tapKey(keyConfirmPayment);
spawnBlock(duration: 500);
await tester.pump(const Duration(seconds: 2));
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await waitFor('extrinsicValidated'.tr(), timeout: const Duration(seconds: 1));
await tapKey(keyCloseTransactionScreen, duration: 0);
await waitFor('12.14');
spawnBlock(duration: 500);
......@@ -63,8 +67,10 @@ Future certifyTest5() async {
// Create identity with Test1 account
await tapKey(keyCertify);
await tapKey(keyConfirm);
spawnBlock(duration: 500);
await waitFor('extrinsicValidated'.tr(), timeout: const Duration(seconds: 1));
spawnBlock(duration: 1000);
await tester.pump(const Duration(seconds: 2));
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen);
await waitFor('identityCreated'.tr());
......@@ -76,8 +82,10 @@ Future certifyTest5() async {
await tapKey(keyConfirmIdentity);
await enterText(keyEnterIdentityUsername, test5.name);
await tapKey(keyConfirm);
spawnBlock(duration: 500);
await waitFor('extrinsicValidated'.tr(), timeout: const Duration(seconds: 1));
spawnBlock(duration: 1000);
await tester.pump(const Duration(seconds: 2));
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen);
await waitFor('identityConfirmed'.tr());
humanRead(2);
......@@ -102,8 +110,10 @@ Future certifyTest5() async {
// Certify with test2 account
await tapKey(keyCertify);
await tapKey(keyConfirm);
spawnBlock(duration: 500);
await waitFor('extrinsicValidated'.tr(), timeout: const Duration(seconds: 1));
spawnBlock(duration: 1000);
await tester.pump(const Duration(seconds: 2));
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen);
await waitFor('2');
......@@ -117,10 +127,12 @@ Future certifyTest5() async {
// Certify with test3 account
await tapKey(keyCertify);
await tapKey(keyConfirm);
spawnBlock(duration: 500);
await waitFor('extrinsicValidated'.tr(), timeout: const Duration(seconds: 1));
spawnBlock(duration: 1000);
await tester.pump(const Duration(seconds: 2));
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen);
await waitFor('mustWaitXBeforeCertify'.substring(0, 12));
await waitFor('mustWaitXBeforeCertify'.tr().substring(0, 8));
// Check if test5 is member
await tapKey(keyAppBarChest, duration: 300);
......
......@@ -35,12 +35,15 @@ void main() async {
await waitFor('memberValidated'.tr(), exactMatch: true);
// Revoke test5
await tapKey(keyManageMembership, duration: 5000);
await goBack();
await tapKey(keyOpenWallet(test5.address));
await tapKey(keyManageMembership, duration: 100);
await tapKey(keyRevokeIdty);
await tapKey(keyConfirm);
spawnBlock(duration: 2000);
await waitFor('extrinsicValidated'.tr().substring(3),
timeout: const Duration(seconds: 4));
spawnBlock(duration: 1000);
await tester.pump(const Duration(seconds: 2));
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen, duration: 0);
await waitFor('noIdentity'.tr(), exactMatch: true);
await sleep();
......@@ -48,8 +51,8 @@ void main() async {
// Check test1 cannot be revoked
await goBack();
await tapKey(keyAddDerivation);
await tapKey(keyOpenWallet(test1.address), duration: 500);
await tapKey(keyManageMembership, duration: 3000);
await tapKey(keyOpenWallet(test1.address), duration: 300);
await tapKey(keyManageMembership, duration: 300);
await waitFor('youCannotRevokeThisIdentity'.tr().substring(0, 15));
}, timeout: testTimeout());
}
......@@ -42,8 +42,10 @@ void main() async {
await tapKey(keySelectThisWallet(test6.address), selectLast: true);
await waitForButtonEnabled(keyConfirm);
await tapKey(keyConfirm);
spawnBlock(duration: 2000);
await waitFor('extrinsicValidated'.tr());
spawnBlock(duration: 1000);
await tester.pump(const Duration(seconds: 2));
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen, duration: 0);
await tapKey(keyOpenWallet(test6.address), duration: 300);
......
......@@ -66,7 +66,7 @@ Future restoreChest() async {
await enterText(keyPinForm, 'AAAAA', 0);
// Check if string "Accéder à mon coffre" is present in screen
await waitFor('accessMyChest'.tr());
await waitFor('accessMyChest'.tr(), pumpDuration: 30);
// Go to wallets home
await tapKey(keyGoWalletsHome, duration: 0);
......
......@@ -114,7 +114,7 @@ Future goBack() async {
final NavigatorState navigator = tester.state(find.byType(Navigator));
log.d('INTEGRATION TEST: Go back');
navigator.pop();
await tester.pump();
await tester.pumpAndSettle();
humanRead();
}
......@@ -129,8 +129,10 @@ Future enterText(Key fieldKey, String textIn, [int duration = 200]) async {
Future<void> waitFor(String text,
{Duration timeout = const Duration(seconds: 5),
bool reverse = false,
bool exactMatch = false}) async {
final bool reverse = false,
final bool exactMatch = false,
final bool settle = true,
final int pumpDuration = 100}) async {
final end = DateTime.now().add(timeout);
Finder finder = exactMatch ? find.text(text) : find.textContaining(text);
......@@ -143,7 +145,9 @@ Future<void> waitFor(String text,
throw Exception('Timed out waiting for $searchType : "$text"');
}
await tester.pumpAndSettle();
if (settle) {
await tester.pumpAndSettle(Duration(milliseconds: pumpDuration));
}
await Future.delayed(const Duration(milliseconds: 100));
} while (reverse ? finder.evaluate().isNotEmpty : finder.evaluate().isEmpty);
humanRead();
......@@ -317,6 +321,32 @@ String getWidgetText(Key key) {
return (word4Finder.evaluate().single.widget as Text).data!;
}
void ignoreOverflowErrors(
FlutterErrorDetails details, {
bool forceReport = false,
}) {
bool ifIsOverflowError = false;
bool isUnableToLoadAsset = false;
// Detect overflow error.
var exception = details.exception;
if (exception is FlutterError) {
ifIsOverflowError = !exception.diagnostics.any(
(e) => e.value.toString().startsWith("A RenderFlex overflowed by"),
);
isUnableToLoadAsset = !exception.diagnostics.any(
(e) => e.value.toString().startsWith("Unable to load asset"),
);
}
// Ignore if is overflow error.
if (ifIsOverflowError || isUnableToLoadAsset) {
debugPrint('Ignored Error');
} else {
FlutterError.dumpErrorToConsole(details, forceReport: forceReport);
}
}
class TestWallet {
String address;
String name;
......
......@@ -11,6 +11,7 @@ const keyAppBarChest = Key('keyAppBarChest');
// Home
const keyParameters = Key('keyParameters');
const keyDebugScreen = Key('keyDebugScreen');
const keyContacts = Key('keyContacts');
const keyDrawerMenu = Key('keyDrawerMenu');
const keyOpenWalletsHomme = Key('keyOpenWalletsHomme');
......
......@@ -41,7 +41,7 @@ class WalletOptions extends StatelessWidget {
Provider.of<MyWalletsProvider>(context, listen: false);
final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false);
// final sub = Provider.of<SubstrateSdk>(context, listen: false);
final sub = Provider.of<SubstrateSdk>(context, listen: false);
// sub.spawnBlock();
// sub.spawnBlock(0, 20);
......@@ -249,9 +249,6 @@ class WalletOptions extends StatelessWidget {
walletProvider.isDefaultWallet =
walletOptions.address.text ==
defaultWallet.address;
final walletData = walletBox
.get(walletOptions.address.text) ??
WalletData(address: walletOptions.address.text);
return Column(children: [
confirmIdentityButton(walletProvider),
pubkeyWidget(walletProvider, ctx),
......@@ -267,16 +264,27 @@ class WalletOptions extends StatelessWidget {
currentChest),
SizedBox(height: 17 * ratio),
// walletProvider.isMember(context, _walletOptions.address.text)
Column(children: [
if (!walletProvider.isDefaultWallet &&
!walletData.isMember)
deleteWallet(
context, walletProvider, currentChest)
else
const SizedBox(),
if (walletData.isMember)
const ManageMembershipButton()
])
FutureBuilder(
future:
sub.isMember(walletOptions.address.text),
builder: (BuildContext context,
AsyncSnapshot<bool> isMember) {
if (isMember.connectionState !=
ConnectionState.done ||
isMember.hasError) {
return const Text('');
}
return Column(children: [
if (!walletProvider.isDefaultWallet &&
!isMember.data!)
deleteWallet(context, walletProvider,
currentChest)
else
const SizedBox(),
if (isMember.data!)
const ManageMembershipButton()
]);
}),
]);
}),
]),
......
......@@ -6,7 +6,6 @@ import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/chest_data.dart';
import 'package:gecko/models/widgets_keys.dart';
import 'package:gecko/providers/duniter_indexer.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/models/wallet_data.dart';
import 'package:flutter/material.dart';
......@@ -25,7 +24,6 @@ import 'package:gecko/widgets/commons/smooth_transition.dart';
import 'package:gecko/widgets/name_by_address.dart';
import 'package:provider/provider.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:truncate/truncate.dart';
// import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';
class WalletsHome extends StatefulWidget {
......@@ -228,7 +226,6 @@ class _WalletsHomeState extends State<WalletsHome> {
Provider.of<WalletOptionsProvider>(context, listen: false);
final bool isWalletsExists = myWalletProvider.checkIfWalletExist();
final sub = Provider.of<SubstrateSdk>(context, listen: false);
final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false);
if (!isWalletsExists) {
return const Text('');
......
......@@ -64,7 +64,7 @@ class MainDrawer extends StatelessWidget {
),
if (kDebugMode)
ListTile(
key: keyParameters,
key: keyDebugScreen,
title: Text('Debug screen'.tr()),
onTap: () {
Navigator.pop(context);
......
......@@ -75,7 +75,7 @@ class SearchIdentityQuery extends StatelessWidget {
}
searchProvider.resultLenght = identities.length;
// TODO: Find a way to reload a provider here, in Widget build... riverpod refacto needed...
// TODO: Find a way to reload a provider here, in Widget build... riverpod refacto needed... or not ...
double avatarSize = 55;
return Expanded(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment