test: fix and adapt test to latest UI

This commit is contained in:
poka 2023-11-24 02:18:08 +01:00
parent e3dc579da7
commit a13d19177b
9 changed files with 53 additions and 27 deletions

View File

@ -5,8 +5,7 @@ services:
container_name: duniter-v2s-gecko-tests
# image: duniter/duniter-v2s:debug-sha-4d5e08be
image: duniter/duniter-v2s:debug-sha-44b09061
command: --alice
# --sealing=manual
command: --alice --sealing=manual
ports:
- "127.0.0.1:9615:9615"
- "127.0.0.1:9933:9933"

View File

@ -65,10 +65,11 @@ Future payTest2() async {
Future certifyTest5() async {
// Create identity with Test1 account
await pump(number: 8);
await tapKey(keyCertify);
await tapKey(keyConfirm);
spawnBlock(duration: 1000);
await tester.pump(const Duration(seconds: 2));
await pump(number: 3);
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen);
@ -83,7 +84,7 @@ Future certifyTest5() async {
await enterText(keyEnterIdentityUsername, test5.name);
await tapKey(keyConfirm);
spawnBlock(duration: 1000);
await tester.pump(const Duration(seconds: 2));
await pump(number: 3);
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen);
@ -111,7 +112,7 @@ Future certifyTest5() async {
await tapKey(keyCertify);
await tapKey(keyConfirm);
spawnBlock(duration: 1000);
await tester.pump(const Duration(seconds: 2));
await pump(number: 3);
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen);
@ -119,16 +120,16 @@ Future certifyTest5() async {
// Change default wallet to test3
await tapKey(keyPay);
await tapKey(keyChangeChest);
await tapKey(keyDropdownWallets);
await tapKey(keySelectThisWallet(test3.address));
await tapKey(keyConfirm);
await tapKey(keyPopButton);
await sleep();
// Certify with test3 account
await tapKey(keyCertify);
await tapKey(keyConfirm);
spawnBlock(duration: 1000);
await tester.pump(const Duration(seconds: 2));
await pump(number: 3);
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen);

View File

@ -44,6 +44,7 @@ void main() async {
await tapKey(keyConfirm);
spawnBlock(duration: 1000);
await tester.pump(const Duration(seconds: 2));
await tester.pump(const Duration(seconds: 1));
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen, duration: 0);
@ -52,7 +53,7 @@ void main() async {
await waitFor('3', exactMatch: true);
await waitFor('memberValidated'.tr());
await waitFor('99.98', exactMatch: true);
await waitFor('110.01', exactMatch: true);
}, timeout: testTimeout());
}

View File

@ -25,7 +25,7 @@ Future changeNode() async {
}
Future deleteAllWallets() async {
if (await isPresent('Rechercher')) {
if (await isPresent('searchWallet'.tr())) {
await tapKey(keyDrawerMenu);
await tapKey(keyParameters);
@ -65,15 +65,17 @@ Future restoreChest() async {
// Enter password
await enterText(keyPinForm, 'AAAAA', 0);
// pump a few frame
await pump(duration: const Duration(milliseconds: 500), number: 10);
// Check if string "Accéder à mon coffre" is present in screen
await waitFor('accessMyChest'.tr(), pumpDuration: 30);
await waitFor('accessMyChest'.tr(), settle: false);
// Go to wallets home
await tapKey(keyGoWalletsHome, duration: 0);
// Skip tutorial
await sleep(500);
await tapKey(keyDragAndDrop).timeout(const Duration(seconds: 3));
await skipWalletDragTutorial();
// Check if string "ĞD" is present in screen
await waitFor('ĞD');
@ -168,5 +170,15 @@ Future firstOpenChest() async {
final isCached = await isIconPresent(Icons.check_box);
if (!isCached) await tapKey(keyCachePassword, duration: 0);
await enterText(keyPinForm, 'AAAAA', 0);
await waitFor('100.0', exactMatch: true);
await skipWalletDragTutorial();
await waitFor(test1.name);
}
Future skipWalletDragTutorial() async {
await pump(duration: const Duration(milliseconds: 500), number: 4);
await pump(duration: const Duration(seconds: 2));
if (await isPresent('explainDraggableWallet'.tr().substring(0, 13),
timeout: const Duration(seconds: 5), settle: false)) {
await tapKey(keyDragAndDrop, duration: 0);
}
}

View File

@ -53,6 +53,15 @@ Future sleep([int time = 1000]) async {
await Future.delayed(Duration(milliseconds: time));
}
Future pump(
{Duration duration = const Duration(milliseconds: 300),
int number = 1}) async {
for (int i = 0; i < number; i++) {
log.d("pump $i");
await tester.pump(duration = duration);
}
}
Future<String> clipPaste() async =>
(await Clipboard.getData('text/plain'))?.text ?? '';
@ -146,7 +155,8 @@ Future<void> waitFor(String text,
}
if (settle) {
await tester.pumpAndSettle(Duration(milliseconds: pumpDuration));
await tester.pumpAndSettle(Duration(milliseconds: pumpDuration),
EnginePhase.sendSemanticsUpdate, timeout);
}
await Future.delayed(const Duration(milliseconds: 100));
} while (reverse ? finder.evaluate().isNotEmpty : finder.evaluate().isEmpty);
@ -155,9 +165,9 @@ Future<void> waitFor(String text,
// Test if text is visible on screen, return a boolean
Future<bool> isPresent(String text,
{Duration timeout = const Duration(seconds: 1)}) async {
{Duration timeout = const Duration(seconds: 1), bool settle = true}) async {
try {
await waitFor(text, timeout: timeout);
await waitFor(text, timeout: timeout, settle: settle);
humanRead();
return true;
} catch (exception) {
@ -278,8 +288,8 @@ Future<WalletData> _addImportAccount(
Future bkDeleteAllWallets() async {
final myWalletProvider =
Provider.of<MyWalletsProvider>(homeContext, listen: false);
final isWalletsPresents =
await isPresent('Scanner un', timeout: const Duration(milliseconds: 300));
final isWalletsPresents = await isPresent('scanQRCode'.tr(),
timeout: const Duration(milliseconds: 300));
if (isWalletsPresents) {
await walletBox.clear();
await chestBox.clear();

View File

@ -98,6 +98,8 @@ const keyCesiumPassword = Key('keyCesiumPassword');
const keySelectWallet = Key('keySelectWallet');
const keyCesiumIdVisible = Key('keyCesiumIdVisible');
const keyDropdownWallets = Key('keyDropdownKey');
// Items keys
Key keyTransaction(int keyId) => Key('keyTransaction$keyId');
Key keyMnemonicWord(String word) => Key('keyMnemonicWord$word');

View File

@ -343,7 +343,7 @@ class WalletOptions extends StatelessWidget {
future: sub.idtyStatus(walletProvider.address.text),
initialData: '',
builder: (context, snapshot) {
if (snapshot.data == 'Created') {
if (snapshot.data == IdtyStatus.created) {
return Column(children: [
SizedBox(
width: 320,
@ -542,7 +542,7 @@ class WalletOptions extends StatelessWidget {
// WalletData defaultWallet = _myWalletProvider.getDefaultWallet()!;
// defaultWallet = wallet;
await sub.setCurrentWallet(wallet);
myWalletProvider.readAllWallets(currentChest);
await myWalletProvider.readAllWallets(currentChest);
myWalletProvider.reload();
walletOptions.reload();
}
@ -575,9 +575,9 @@ class WalletOptions extends StatelessWidget {
onTap: canDelete
? () async {
await walletOptions.deleteWallet(context, wallet);
WidgetsBinding.instance.addPostFrameCallback((_) {
WidgetsBinding.instance.addPostFrameCallback((_) async {
myWalletProvider.listWallets =
myWalletProvider.readAllWallets(currentChest);
await myWalletProvider.readAllWallets(currentChest);
myWalletProvider.reload();
});
}

View File

@ -28,7 +28,6 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
var defaultWallet = myWalletProvider.getDefaultWallet();
bool canValidate = false;
final amountFocus = FocusNode();
final dropdownKey = GlobalKey();
walletViewProvider.payAmount.text = '';
@ -132,6 +131,7 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
fontSize: 26, fontWeight: FontWeight.w700),
),
IconButton(
key: keyPopButton,
iconSize: 40,
icon: const Icon(Icons.cancel_outlined),
onPressed: () {
@ -152,7 +152,7 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
return DropdownButton(
dropdownColor: const Color(0xffffeed1),
elevation: 12,
key: dropdownKey,
key: keyDropdownWallets,
value: defaultWallet,
menuMaxHeight: 300,
onTap: () {
@ -197,6 +197,7 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
.map((WalletData wallet) {
return DropdownMenuItem(
value: wallet,
key: keySelectThisWallet(wallet.address),
child: Container(
color: const Color(0xffffeed1),
width: 408,

View File

@ -100,8 +100,8 @@ class SearchResult extends StatelessWidget {
walletsProfilesClass.address = g1Wallet.address;
return WalletViewScreen(
address: g1Wallet.address,
username: g1WalletsBox.get(g1Wallet)!.username ?? '',
avatar: g1WalletsBox.get(g1Wallet.address)?.avatar,
username: g1Wallet.username ?? '',
avatar: g1Wallet.avatar,
);
}),
);