forked from cypherstack/stack_wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings_test.dart
643 lines (550 loc) · 25.9 KB
/
settings_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:stackwallet/main.dart' as campfireApp;
import 'package:stackwallet/notifications/modal_popup_dialog.dart';
import 'package:stackwallet/pages/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view.dart';
import 'package:stackwallet/utilities/address_utils.dart';
import 'package:stackwallet/widgets/custom_buttons/gradient_button.dart';
import 'package:stackwallet/widgets/custom_buttons/simple_button.dart';
import 'package:stackwallet/widgets/node_card.dart';
import 'package:pretty_qr_code/pretty_qr_code.dart';
import 'bot_runners/create_wallet_until_pin_confirmation.dart';
import 'bots/addressbook/add_address_book_entry_view_bot.dart';
import 'bots/addressbook/address_book_card_bot.dart';
import 'bots/addressbook/address_book_entry_details_view_bot.dart';
import 'bots/addressbook/address_book_view_bot.dart';
import 'bots/addressbook/edit_address_book_entry_view_bot.dart';
import 'bots/lockscreen_view_bot.dart';
import 'bots/main_view_bot.dart';
import 'bots/onboarding/backup_key_warning_bot.dart';
import 'bots/onboarding/create_pin_view_bot.dart';
import 'bots/onboarding/name_your_wallet_view_bot.dart';
import 'bots/onboarding/onboarding_view_bot.dart';
import 'bots/onboarding/terms_and_conditions_bot.dart';
import 'bots/settings/currency_view_bot.dart';
import 'bots/settings/network_settings/add_custom_node_view_bot.dart';
import 'bots/settings/network_settings/network_settings_view_bot.dart';
import 'bots/settings/network_settings/node_details_view_bot.dart';
import 'bots/settings/settings_view_bot.dart';
import 'bots/settings/wallet_backup_view_bot.dart';
import 'bots/settings/wallet_settings/change_pin_view_bot.dart';
import 'bots/settings/wallet_settings/delete_wallet_warning_view_bot.dart';
import 'bots/settings/wallet_settings/rename_wallet_view_bot.dart';
import 'bots/settings/wallet_settings/wallet_delete_mnemonic_view_bot.dart';
import 'bots/settings/wallet_settings_view_bot.dart';
const bool TEST_ADDRESS_BOOK = true;
const bool TEST_NETWORK_SETTINGS = true;
const bool TEST_WALLET_BACKUP = true;
const bool TEST_CURRENCY = true;
const bool TEST_WALLET_SETTINGS = true;
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
// may fail if a network connection fails somewhere
testWidgets("settings integration test", (tester) async {
campfireApp.main();
await tester.pumpAndSettle(Duration(seconds: 10));
// robots
final onboardingViewBot = OnboardingViewBot(tester);
final termsAndConditionsViewBot = TermsAndConditionsViewBot(tester);
final nameYourWalletViewBot = NameYourWalletViewBot(tester);
final createPinViewBot = CreatePinViewBot(tester);
final backupKeyWarningViewBot = BackupKeyWarningViewBot(tester);
final mainViewBot = MainViewBot(tester);
final settingsViewBot = SettingsViewBot(tester);
// tap create new wallet button
await onboardingViewBot.ensureVisible();
await onboardingViewBot.tapCreateNewWallet();
await termsAndConditionsViewBot.ensureVisible();
await createWalletUntilPinConfirmation(
termsAndConditionsViewBot,
nameYourWalletViewBot,
createPinViewBot,
);
// wait for wallet generation
await tester.pumpAndSettle(Duration(seconds: 60));
await backupKeyWarningViewBot.ensureVisible();
// tap skip to load into main wallet view
await backupKeyWarningViewBot.tapSkip();
await mainViewBot.ensureVisible();
// tap settings button
await mainViewBot.tapSettings();
await settingsViewBot.ensureVisible();
if (TEST_ADDRESS_BOOK) {
// tap address book
await settingsViewBot.tapAddressBook();
final addressBookViewBot = AddressBookViewBot(tester);
await addressBookViewBot.ensureVisible();
// add entry
await addressBookViewBot.tapAdd();
final addAddressBookEntryViewBot = AddAddressBookEntryViewBot(tester);
await addAddressBookEntryViewBot.ensureVisible();
// test back and cancel
await addAddressBookEntryViewBot.tapBack();
await addressBookViewBot.ensureVisible();
await addressBookViewBot.tapAdd();
await addAddressBookEntryViewBot.tapCancel();
await addressBookViewBot.ensureVisible();
// now add an entry
await addressBookViewBot.tapAdd();
await addAddressBookEntryViewBot.ensureVisible();
await addAddressBookEntryViewBot
.enterAddress("aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh");
await addAddressBookEntryViewBot.enterName("john doe");
// save entry
await addAddressBookEntryViewBot.tapSave();
await addressBookViewBot.ensureVisible();
final addressBookCardBot = AddressBookCardBot(tester);
await addressBookCardBot.ensureVisible();
// expand options
await addressBookCardBot.toggleExpandCard();
// tap copy
await addressBookCardBot.tapCopy();
expect((await Clipboard.getData(Clipboard.kTextPlain))!.text,
"aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh");
expect(find.text("Address copied to clipboard"), findsOneWidget);
await tester.pumpAndSettle(Duration(seconds: 2));
// clear clipboard
await Clipboard.setData(ClipboardData(text: ""));
// tap details
await addressBookCardBot.tapDetails();
final addressBookEntryDetailsViewBot =
AddressBookEntryDetailsViewBot(tester);
await addressBookEntryDetailsViewBot.ensureVisible();
// tap back then go back to details
await addressBookEntryDetailsViewBot.tapBack();
await addressBookCardBot.ensureVisible();
await addressBookCardBot.tapDetails();
await addressBookEntryDetailsViewBot.ensureVisible();
// copy address
await addressBookEntryDetailsViewBot.tapCopyAddress();
expect((await Clipboard.getData(Clipboard.kTextPlain))!.text,
"aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh");
expect(find.text("Address copied to clipboard"), findsOneWidget);
await tester.pumpAndSettle(Duration(seconds: 2));
// clear clipboard
await Clipboard.setData(ClipboardData(text: ""));
// delete and cancel
await addressBookEntryDetailsViewBot.tapMore();
await addressBookEntryDetailsViewBot.tapDelete();
await addressBookEntryDetailsViewBot.tapCancelDelete();
// delete and confirm
await addressBookEntryDetailsViewBot.tapMore();
await addressBookEntryDetailsViewBot.tapDelete();
await addressBookEntryDetailsViewBot.tapConfirmDelete();
await addressBookViewBot.ensureVisible();
// add and save another entry, then go to details
await addressBookViewBot.tapAdd();
await addAddressBookEntryViewBot.ensureVisible();
await addAddressBookEntryViewBot
.enterAddress("aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh");
await addAddressBookEntryViewBot.enterName("john doe");
await addAddressBookEntryViewBot.tapSave();
await addressBookViewBot.ensureVisible();
await addressBookCardBot.ensureVisible();
await addressBookCardBot.toggleExpandCard();
await addressBookCardBot.tapDetails();
await addressBookEntryDetailsViewBot.ensureVisible();
// tap edit
await addressBookEntryDetailsViewBot.tapEdit();
final editAddressBookEntryViewBot = EditAddressBookEntryViewBot(tester);
await editAddressBookEntryViewBot.ensureVisible();
// tap back
await editAddressBookEntryViewBot.tapBack();
await addressBookEntryDetailsViewBot.ensureVisible();
await addressBookEntryDetailsViewBot.tapEdit();
await editAddressBookEntryViewBot.ensureVisible();
// tap cancel
await editAddressBookEntryViewBot.tapCancel();
await addressBookEntryDetailsViewBot.ensureVisible();
await addressBookEntryDetailsViewBot.tapEdit();
await editAddressBookEntryViewBot.ensureVisible();
// tap save without editing
await editAddressBookEntryViewBot.tapSave();
await addressBookEntryDetailsViewBot.ensureVisible();
await addressBookEntryDetailsViewBot.tapEdit();
await editAddressBookEntryViewBot.ensureVisible();
// tap save with editing
await editAddressBookEntryViewBot.enterName("jane doe");
await editAddressBookEntryViewBot
.enterAddress("aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh");
await editAddressBookEntryViewBot.tapSave();
await addressBookViewBot.ensureVisible();
await addressBookCardBot.ensureVisible();
// expand and tap send
await addressBookCardBot.toggleExpandCard();
await addressBookCardBot.tapSend();
await mainViewBot.ensureVisible();
// go to details and send
await mainViewBot.tapSettings();
await settingsViewBot.tapAddressBook();
await addressBookCardBot.toggleExpandCard();
await addressBookCardBot.tapDetails();
await addressBookEntryDetailsViewBot.tapSend();
await mainViewBot.ensureVisible();
// open settings again to continue testing
await mainViewBot.tapSettings();
await settingsViewBot.ensureVisible();
}
if (TEST_NETWORK_SETTINGS) {
// network settings
await settingsViewBot.tapNetwork();
final networkSettingsViewBot = NetworkSettingsViewBot(tester);
await networkSettingsViewBot.ensureVisible();
// test back
await networkSettingsViewBot.tapBack();
await settingsViewBot.tapNetwork();
await networkSettingsViewBot.ensureVisible();
expect(find.byType(NodeCard), findsOneWidget);
// test add node back
await networkSettingsViewBot.tapAdd();
final addCustomNodeViewBot = AddCustomNodeViewBot(tester);
await addCustomNodeViewBot.ensureVisible();
await addCustomNodeViewBot.tapBack();
await networkSettingsViewBot.tapAdd();
await addCustomNodeViewBot.ensureVisible();
// test add node
await addCustomNodeViewBot.enterNodeName("MyNode");
await addCustomNodeViewBot.enterNodeAddress("MyNodeAddress");
await addCustomNodeViewBot.enterNodePort("0");
// tap test connection
await addCustomNodeViewBot.tapTestConnection();
expect(find.text("Connection failed!"), findsOneWidget);
await tester.pumpAndSettle(Duration(seconds: 2));
// test save non connecting node
await addCustomNodeViewBot.tapSave();
expect(find.byType(CouldNotConnectOnSaveDialog), findsOneWidget);
await tester
.tap(find.byKey(Key("couldNotConnectOnSaveConfirmSaveButtonKey")));
await tester.pumpAndSettle();
await networkSettingsViewBot.ensureVisible();
expect(find.byType(NodeCard), findsNWidgets(2));
// tap default node to get context menu
expect(find.text("Connect"), findsNothing);
expect(find.text("Details"), findsNothing);
expect(find.text("Edit"), findsNothing);
expect(find.text("Delete"), findsNothing);
await networkSettingsViewBot.tapNode("Campfire default");
expect(find.text("Connect"), findsOneWidget);
expect(find.text("Details"), findsOneWidget);
expect(find.text("Edit"), findsNothing);
expect(find.text("Delete"), findsNothing);
// tap connect
await tester.tap(find.text("Connect"));
await tester.pumpAndSettle();
// tap details
await networkSettingsViewBot.tapNode("Campfire default");
await tester.tap(find.text("Details"));
await tester.pumpAndSettle();
final nodeDetailsViewBot = NodeDetailsViewBot(tester);
await nodeDetailsViewBot.ensureVisible();
// tap test connection
await nodeDetailsViewBot.tapTestConnection();
await tester.pumpAndSettle(Duration(seconds: 3));
// tap back
await nodeDetailsViewBot.tapBack();
await networkSettingsViewBot.ensureVisible();
// tap custom node to get context menu
expect(find.text("Connect"), findsNothing);
expect(find.text("Details"), findsNothing);
expect(find.text("Edit"), findsNothing);
expect(find.text("Delete"), findsNothing);
await networkSettingsViewBot.tapNode("MyNode");
expect(find.text("Connect"), findsOneWidget);
expect(find.text("Details"), findsOneWidget);
expect(find.text("Edit"), findsOneWidget);
expect(find.text("Delete"), findsOneWidget);
// tap details
await tester.tap(find.text("Details"));
await tester.pumpAndSettle();
await nodeDetailsViewBot.ensureVisible();
// test back
await nodeDetailsViewBot.tapBack();
await networkSettingsViewBot.ensureVisible();
await networkSettingsViewBot.tapNode("MyNode");
await tester.tap(find.text("Details"));
await tester.pumpAndSettle();
await nodeDetailsViewBot.ensureVisible();
// tap test connection
await nodeDetailsViewBot.tapTestConnection();
expect(find.text("Connection failed!"), findsOneWidget);
await tester.pumpAndSettle(Duration(seconds: 2));
// open context and edit
await nodeDetailsViewBot.tapMoreAndEdit();
// tap disabled save
await nodeDetailsViewBot.tapSave();
await nodeDetailsViewBot.ensureVisible();
// edit and save node
await nodeDetailsViewBot.tapUseSSLCheckbox();
await nodeDetailsViewBot.enterName("MyNode2");
await nodeDetailsViewBot.tapSave();
await networkSettingsViewBot.ensureVisible();
expect(find.text("MyNode2"), findsOneWidget);
expect(find.text("MyNode"), findsNothing);
// tap delete node from details view
await networkSettingsViewBot.tapNode("MyNode2");
await tester.tap(find.text("Details"));
await tester.pumpAndSettle();
await nodeDetailsViewBot.tapMoreAndDelete();
// cancel delete
expect(find.byType(ModalPopupDialog), findsOneWidget);
await nodeDetailsViewBot.tapCancelDelete();
expect(find.byType(ModalPopupDialog), findsNothing);
// confirm delete
await nodeDetailsViewBot.tapMoreAndDelete();
await nodeDetailsViewBot.tapConfirmDelete();
await networkSettingsViewBot.ensureVisible();
// expect only the default node now
expect(find.byType(NodeCard), findsOneWidget);
// create new node to test remaining two context options
// on the main network settings page
await networkSettingsViewBot.tapAdd();
await addCustomNodeViewBot.ensureVisible();
await addCustomNodeViewBot.enterNodeName("MyNode");
await addCustomNodeViewBot.enterNodeAddress("MyNodeAddress");
await addCustomNodeViewBot.enterNodePort("0");
await addCustomNodeViewBot.tapSave();
await tester
.tap(find.byKey(Key("couldNotConnectOnSaveConfirmSaveButtonKey")));
await tester.pumpAndSettle();
await networkSettingsViewBot.ensureVisible();
expect(find.byType(NodeCard), findsNWidgets(2));
// tap edit node from the main network settings page, then save
await networkSettingsViewBot.tapNode("MyNode");
await tester.tap(find.text("Edit"));
await tester.pumpAndSettle();
await nodeDetailsViewBot.ensureVisible();
await nodeDetailsViewBot.enterName("MyNode3");
await nodeDetailsViewBot.enterAddress("somenewaddress");
await nodeDetailsViewBot.enterPort("00");
await nodeDetailsViewBot.tapUseSSLCheckbox();
await tester.tap(find.text("Use SSL"));
await tester.pumpAndSettle();
await nodeDetailsViewBot.tapSave();
await networkSettingsViewBot.ensureVisible();
// tap edit node from the main network settings page, then back
await networkSettingsViewBot.tapNode("MyNode3");
await tester.tap(find.text("Edit"));
await tester.pumpAndSettle();
await nodeDetailsViewBot.tapBack();
await networkSettingsViewBot.ensureVisible();
// tap delete node from the main network settings page, then cancel
await networkSettingsViewBot.tapNode("MyNode3");
await tester.tap(find.text("Delete"));
await tester.pumpAndSettle();
await tester.tap(find.byType(SimpleButton));
await tester.pumpAndSettle();
await networkSettingsViewBot.ensureVisible();
expect(find.byType(NodeCard), findsNWidgets(2));
// tap delete node from the main network settings page, then confirm
await networkSettingsViewBot.tapNode("MyNode3");
await tester.tap(find.text("Delete"));
await tester.pumpAndSettle();
await tester.tap(find.byType(GradientButton));
await tester.pumpAndSettle();
await networkSettingsViewBot.ensureVisible();
expect(find.byType(NodeCard), findsOneWidget);
// go back to main settings
await networkSettingsViewBot.tapBack();
await settingsViewBot.ensureVisible();
}
if (TEST_WALLET_BACKUP) {
await settingsViewBot.tapWalletBackup();
final lockscreenViewBot = LockscreenViewBot(tester);
await lockscreenViewBot.ensureVisible();
// test back
await lockscreenViewBot.tapBack();
await settingsViewBot.ensureVisible();
await settingsViewBot.tapWalletBackup();
// enter wrong pin
await lockscreenViewBot.enterPin("2222");
await tester.pumpAndSettle(Duration(seconds: 2));
await lockscreenViewBot.ensureVisible();
// test back again
await lockscreenViewBot.tapBack();
await settingsViewBot.ensureVisible();
await settingsViewBot.tapWalletBackup();
// enter correct pin
await lockscreenViewBot.enterPin("1234");
await tester.pumpAndSettle(Duration(seconds: 2));
final walletBackUpViewBot = WalletBackUpViewBot(tester);
await walletBackUpViewBot.ensureVisible();
// tap copy
await Clipboard.setData(ClipboardData(text: ""));
await walletBackUpViewBot.tapCopy();
final mnemonic =
(await Clipboard.getData(Clipboard.kTextPlain))!.text!.split(" ");
expect(mnemonic.length, 24);
await tester.pumpAndSettle(Duration(seconds: 2));
await Clipboard.setData(ClipboardData(text: ""));
// tap qr code then cancel
await walletBackUpViewBot.tapQrCode();
final qr = find.byType(PrettyQr).evaluate().first.widget as PrettyQr;
expect(qr.data, AddressUtils.encodeQRSeedData(mnemonic));
await walletBackUpViewBot.tapQrCodeCancel();
expect(find.byType(ModalPopupDialog), findsNothing);
// tap back to settings
await walletBackUpViewBot.tapBack();
await settingsViewBot.ensureVisible();
}
if (TEST_CURRENCY) {
// change to a different currency from default USD
await settingsViewBot.tapCurrency();
final currencyViewBot = CurrencyViewBot(tester);
await currencyViewBot.ensureVisible();
await currencyViewBot.tapCurrency("CHF");
// go back to main view to check for "CHF"
await currencyViewBot.tapBack();
await settingsViewBot.ensureVisible();
await settingsViewBot.tapBack();
await mainViewBot.ensureVisible();
expect(find.text("CHF"), findsOneWidget);
// open settings again to continue testing
await mainViewBot.tapSettings();
await settingsViewBot.ensureVisible();
}
if (TEST_WALLET_SETTINGS) {
// tap wallet settings
await settingsViewBot.tapWalletSettings();
final walletSettingsViewBot = WalletSettingsViewBot(tester);
await walletSettingsViewBot.ensureVisible();
// test all change pin back taps
await walletSettingsViewBot.tapChangePIN();
final lockScreenViewBot = LockscreenViewBot(tester);
await lockScreenViewBot.ensureVisible();
await lockScreenViewBot.tapBack();
await walletSettingsViewBot.tapChangePIN();
await lockScreenViewBot.enterPin("1234");
await tester.pumpAndSettle(Duration(seconds: 2));
final changePinViewBot = ChangePinViewBot(tester);
await changePinViewBot.ensureVisible();
await changePinViewBot.tapBack();
await walletSettingsViewBot.tapChangePIN();
await lockScreenViewBot.enterPin("1234");
await tester.pumpAndSettle(Duration(seconds: 2));
await changePinViewBot.enterPin();
await changePinViewBot.tapBack();
await walletSettingsViewBot.ensureVisible();
// change pin with a few fails
await walletSettingsViewBot.tapChangePIN();
await lockScreenViewBot.enterPin("2222");
await tester.pumpAndSettle(Duration(seconds: 2));
await lockScreenViewBot.enterPin("1234");
await tester.pumpAndSettle(Duration(seconds: 2));
await changePinViewBot.enterPin();
await changePinViewBot.confirmUnmatchedPin();
await changePinViewBot.enterPin();
await changePinViewBot.confirmUnmatchedPin();
await changePinViewBot.enterPin();
await changePinViewBot.confirmMatchedPin();
await walletSettingsViewBot.ensureVisible();
await tester.pumpAndSettle(Duration(seconds: 2));
// change pin with no fails
await walletSettingsViewBot.tapChangePIN();
await lockScreenViewBot.enterPin("2222");
await tester.pumpAndSettle(Duration(seconds: 2));
await lockScreenViewBot.enterPin("1234");
await tester.pumpAndSettle(Duration(seconds: 2));
await changePinViewBot.enterPin();
await changePinViewBot.confirmMatchedPin();
await walletSettingsViewBot.ensureVisible();
await tester.pumpAndSettle(Duration(seconds: 2));
// biometrics doesn't test well as it prompts for system settings
// await walletSettingsViewBot.tapToggleBiometrics();
// await walletSettingsViewBot.tapCancelBiometricsSystemSettingsDialog();
// rename wallet save
await walletSettingsViewBot.tapRenameWallet();
final renameWalletViewBot = RenameWalletViewBot(tester);
await renameWalletViewBot.tapSave();
await renameWalletViewBot.enterWalletName("My Firo Wallet2");
await renameWalletViewBot.tapSave();
await walletSettingsViewBot.tapRenameWallet();
expect(find.text("My Firo Wallet2"), findsOneWidget);
await renameWalletViewBot.enterWalletName("My Firo Wallet");
await renameWalletViewBot.tapSave();
// tap back
await walletSettingsViewBot.tapRenameWallet();
await renameWalletViewBot.tapBack();
await walletSettingsViewBot.ensureVisible();
// tap clear cache and cancel
await walletSettingsViewBot.tapClearCache();
await walletSettingsViewBot.tapCancelClearCache();
await walletSettingsViewBot.ensureVisible();
// tap clear cache and clear
await walletSettingsViewBot.tapClearCache();
await walletSettingsViewBot.tapClearOnClearCache();
await walletSettingsViewBot.tapOkOnCacheClearedAlert();
await walletSettingsViewBot.ensureVisible();
// tap delete wallet and cancel
await walletSettingsViewBot.tapDeleteWallet();
await walletSettingsViewBot.tapCancelDeleteConfirmationDialog();
// tap delete wallet and continue running though
// and testing back taps throughout
await walletSettingsViewBot.tapDeleteWallet();
await walletSettingsViewBot.tapDeleteOnDeleteConfirmationDialog();
await lockScreenViewBot.ensureVisible();
await lockScreenViewBot.tapBack();
await walletSettingsViewBot.tapDeleteWallet();
await walletSettingsViewBot.tapDeleteOnDeleteConfirmationDialog();
await lockScreenViewBot.ensureVisible();
await lockScreenViewBot.enterPin("9999");
await tester.pumpAndSettle(Duration(seconds: 2));
await lockScreenViewBot.ensureVisible();
await lockScreenViewBot.tapBack();
await walletSettingsViewBot.tapDeleteWallet();
await walletSettingsViewBot.tapDeleteOnDeleteConfirmationDialog();
await lockScreenViewBot.ensureVisible();
await lockScreenViewBot.enterPin("1234");
await tester.pumpAndSettle(Duration(seconds: 2));
final deleteWalletWarningViewBot = DeleteWalletWarningViewBot(tester);
await deleteWalletWarningViewBot.ensureVisible();
await deleteWalletWarningViewBot.tapBack();
await walletSettingsViewBot.ensureVisible();
await walletSettingsViewBot.tapDeleteWallet();
await walletSettingsViewBot.tapDeleteOnDeleteConfirmationDialog();
await lockScreenViewBot.ensureVisible();
await lockScreenViewBot.enterPin("1234");
await tester.pumpAndSettle(Duration(seconds: 2));
await deleteWalletWarningViewBot.ensureVisible();
await deleteWalletWarningViewBot.tapCancelAndGoBack();
await walletSettingsViewBot.ensureVisible();
// finally go through and tap view backup key
await walletSettingsViewBot.tapDeleteWallet();
await walletSettingsViewBot.tapDeleteOnDeleteConfirmationDialog();
await lockScreenViewBot.ensureVisible();
await lockScreenViewBot.enterPin("1234");
await tester.pumpAndSettle(Duration(seconds: 2));
await deleteWalletWarningViewBot.ensureVisible();
await deleteWalletWarningViewBot.tapViewBackupKey();
final walletDeleteMnemonicViewBot = WalletDeleteMnemonicViewBot(tester);
await walletDeleteMnemonicViewBot.ensureVisible();
// test back
await walletDeleteMnemonicViewBot.tapBack();
await deleteWalletWarningViewBot.ensureVisible();
await deleteWalletWarningViewBot.tapViewBackupKey();
await walletDeleteMnemonicViewBot.ensureVisible();
// tap qr code
await walletDeleteMnemonicViewBot.tapQrCode();
await walletDeleteMnemonicViewBot.tapCancelQrCode();
await walletDeleteMnemonicViewBot.ensureVisible();
// tap copy
await Clipboard.setData(ClipboardData(text: ""));
await walletDeleteMnemonicViewBot.tapCopy();
final mnemonic =
(await Clipboard.getData(Clipboard.kTextPlain))!.text!.split(" ");
expect(mnemonic.length, 24);
await tester.pumpAndSettle(Duration(seconds: 2));
await Clipboard.setData(ClipboardData(text: ""));
await walletDeleteMnemonicViewBot.ensureVisible();
// tap continue and cancel
await walletDeleteMnemonicViewBot.tapContinue();
await walletDeleteMnemonicViewBot.tapCancelContinue();
await walletDeleteMnemonicViewBot.ensureVisible();
// tap continue and finally confirm deletion
await walletDeleteMnemonicViewBot.tapContinue();
await walletDeleteMnemonicViewBot.tapConfirmContinue();
await onboardingViewBot.ensureVisible();
}
});
}