Continue tests: All wallets view tested; pubkey search and view tested; All right for now

This commit is contained in:
poka 2021-04-28 23:44:07 +02:00
parent f193f5efac
commit 5027b4eb2a
7 changed files with 132 additions and 18 deletions

View File

@ -172,6 +172,7 @@ class MyWalletsProvider with ChangeNotifier {
},
),
TextButton(
key: Key('confirmDeletingAllWallets'),
child: Text("Oui"),
onPressed: () {
Navigator.pop(context, true);

View File

@ -169,6 +169,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
child: Builder(
builder: (context) => Expanded(
child: ListView(
key: Key('listTransactions'),
controller: scrollController,
children: <Widget>[
SizedBox(height: 20),
@ -222,6 +223,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
height: avatarsSize);
})),
GestureDetector(
key: Key('copyPubkey'),
onTap: () {
Clipboard.setData(ClipboardData(
text: _historyProvider.pubkey));
@ -288,6 +290,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
style: TextStyle(fontSize: 18.0))),
SizedBox(height: 20),
ElevatedButton(
key: Key('switchPayHistory'),
style: ElevatedButton.styleFrom(
elevation: 1,
primary: Colors.grey[50], // background
@ -401,6 +404,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
Widget historyView(context, result) {
HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
int keyID = 0;
return _historyProvider.transBC == null
? Text('Aucune transaction à afficher.')
@ -409,6 +413,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
Padding(
padding: const EdgeInsets.symmetric(horizontal: 5.0),
child: ListTile(
key: Key('transaction${keyID++}'),
contentPadding: const EdgeInsets.all(5.0),
leading: Text(repository[1].toString(),
style: TextStyle(
@ -441,13 +446,15 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
),
// if (_historyProvider.isTheEnd) // What I did before ...
if (!_historyProvider.pageInfo['hasPreviousPage'])
Column(children: <Widget>[
SizedBox(height: 15),
Text("Début de l'historique.",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20)),
SizedBox(height: 15)
])
Column(
children: <Widget>[
SizedBox(height: 15),
Text("Début de l'historique.",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20)),
SizedBox(height: 15)
],
)
]);
}
}

View File

@ -47,6 +47,7 @@ class HomeScreen extends StatelessWidget {
),
),
ListTile(
key: Key('parameters'),
title: Text('Paramètres'),
onTap: () {
Navigator.pop(context);
@ -77,6 +78,7 @@ class HomeScreen extends StatelessWidget {
appBar: AppBar(
leading: Builder(
builder: (context) => IconButton(
key: Key('drawerMenu'),
icon: new Icon(Icons.menu, color: Colors.grey[850]),
onPressed: () => Scaffold.of(context).openDrawer(),
)),
@ -85,6 +87,7 @@ class HomeScreen extends StatelessWidget {
Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: IconButton(
key: Key('searchIcon'),
icon: _homeProvider.searchIcon,
color: Colors.grey[850],
onPressed: () {
@ -94,6 +97,7 @@ class HomeScreen extends StatelessWidget {
color: Colors.grey[850],
);
_homeProvider.appBarTitle = TextField(
key: Key('searchInput'),
autofocus: true,
controller: _homeProvider.searchQuery,
onChanged: (text) {

View File

@ -124,6 +124,7 @@ class WalletOptions extends StatelessWidget {
SizedBox(
width: 260,
child: TextField(
key: Key('walletName'),
focusNode: _walletOptions.walletNameFocus,
enabled: _walletOptions.isEditing,
controller: _walletOptions.nameController,
@ -218,6 +219,7 @@ class WalletOptions extends StatelessWidget {
SizedBox(width: 0),
Column(children: <Widget>[
InkWell(
key: Key('renameWallet'),
onTap: () async {
// _walletOptions.isEditing = true;
// _walletOptions.reloadBuild();

View File

@ -110,6 +110,7 @@ class WalletsHome extends StatelessWidget {
List _listWallets = _myWalletProvider.listWallets;
return GridView.count(
key: Key('listWallets'),
crossAxisCount: 2,
childAspectRatio: 1,
crossAxisSpacing: 0,

View File

@ -80,6 +80,7 @@ class SettingsScreen extends StatelessWidget {
height: 100,
width: 500,
child: ElevatedButton(
key: Key('deleteAllWallets'),
style: ElevatedButton.styleFrom(
elevation: 5,
primary: Colors.redAccent, // background

View File

@ -1,12 +1,12 @@
// Imports the Flutter Driver API.
import 'dart:async';
import 'dart:io';
import 'package:flutter_driver/flutter_driver.dart';
// import 'package:flutter_test/flutter_test.dart';
import 'package:test/test.dart';
// import 'package:flutter/services.dart';
void main() {
int globalTimeout = 2;
group('Gecko App', () {
// First, define the Finders and use them to locate widgets from the
// test suite. Note: the Strings provided to the `byValueKey` method must
@ -41,18 +41,44 @@ void main() {
));
}
Future<bool> isPresent(SerializableFinder byValueKey,
{Duration timeout = const Duration(seconds: 1)}) async {
try {
await driver.waitFor(byValueKey, timeout: timeout);
return true;
} catch (exception) {
return false;
}
}
test('OnBoarding - Open wallets management', (
{timeout: const Duration(seconds: 2)}) async {
{timeout: Timeout.none}) async {
// await driver.runUnsynchronized(() async { // Needed if we want to manage async drivers
await driver.tap(manageWalletsFinder);
print(
'####################################################################');
// If a wallet exist, go to delete theme all
if (!await isPresent(find.byValueKey('goStep1'))) {
await goBack();
await tapOn('drawerMenu');
await sleep(300);
await tapOn('parameters');
await sleep(300);
await tapOn('deleteAllWallets');
await sleep(300);
await tapOn('confirmDeletingAllWallets');
await sleep(300);
await driver.tap(manageWalletsFinder);
}
// Get the SerializableFinder for text widget with key 'textOnboarding'
SerializableFinder textOnboarding = find.byValueKey(
'textOnboarding',
);
print(
'####################################################################');
await sleep(100);
// Verify onboarding is starting, with text
expect(await driver.getText(textOnboarding),
@ -60,7 +86,7 @@ void main() {
});
test('OnBoarding - Go to create restore sentance', (
{timeout: const Duration(seconds: 5)}) async {
{timeout: Timeout.none}) async {
await tapOn('goStep1');
await tapOn('goStep2');
await tapOn('goStep3');
@ -76,7 +102,7 @@ void main() {
});
test('OnBoarding - Generate sentance and confirme it', (
{timeout: const Duration(seconds: 5)}) async {
{timeout: Timeout.none}) async {
await tapOn('goStep7');
while (await getText('word1') == '...') {
@ -126,7 +152,7 @@ void main() {
await selectWord();
});
test('OnBoarding - Generate secret code and confirm it', (
{timeout: const Duration(seconds: 5)}) async {
{timeout: Timeout.none}) async {
expect(await getText('step9'),
"Super !\n\nJe vais maintenant créer votre code secret. \n\nVotre code secret chiffre votre trousseau de clefs, ce qui le rend inutilisable par dautres, par exemple si vous perdez votre téléphone ou si on vous le vole.");
@ -161,7 +187,7 @@ void main() {
});
test('My wallets - Create a derivation and display it', (
{timeout: const Duration(seconds: 5)}) async {
{timeout: Timeout.none}) async {
await tapOn('goWalletHome');
expect(await getText('myWallets'), "Mes portefeuilles");
@ -252,11 +278,83 @@ void main() {
await tapOn('setDefaultWallet');
await sleep(100);
await driver.waitFor(find.text('Ce portefeuille est celui par defaut'));
await sleep(300);
// Display history, copy pubkey, go back and rename wallet name
await tapOn('displayHistory');
await sleep(400);
await tapOn('copyPubkey');
await driver.waitFor(find
.text('Cette clé publique a été copié dans votre presse-papier.'));
await sleep(800);
await goBack();
await sleep(300);
await tapOn('renameWallet');
await sleep(100);
await tapOn('walletName');
await sleep(100);
await driver.enterText('Renommage wallet 2');
await sleep(300);
await tapOn('renameWallet');
await sleep(400);
await goBack();
await driver.waitFor(find.text('Renommage wallet 2'));
await createDerivation('Derivation 8');
await createDerivation('Derivation 9');
await createDerivation('Derivation 10');
await createDerivation('Derivation 11');
await createDerivation('Derivation 12');
await createDerivation('Derivation 13');
await createDerivation('Derivation 14');
await createDerivation('Derivation 15');
await createDerivation('Derivation 16');
await createDerivation('Derivation 17');
await createDerivation('Derivation 18');
await createDerivation('Derivation 19');
await createDerivation('Derivation 20');
await sleep(400);
// Scroll the wallet screen
await driver.scrollUntilVisible(
find.byValueKey('listWallets'),
find.text('Derivation 20'),
dyScroll: -300.0,
);
await driver.waitFor(find.text('Derivation 20'));
await sleep(400);
await driver.tap(find.text('Derivation 20'));
await tapOn('copyPubkey');
await goBack();
await goBack();
await sleep(200);
await tapOn('searchIcon');
await sleep(400);
await driver.enterText('D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU');
await sleep(100);
await tapOn('copyPubkey');
await sleep(500);
await tapOn('switchPayHistory');
await sleep(1200);
// await driver.scrollIntoView(find.byValueKey('listTransactions'));
await driver.scrollUntilVisible(
find.byValueKey('listTransactions'),
find.byValueKey('transaction35'),
dyScroll: -600.0,
);
await sleep(100);
await tapOn('transaction33');
await driver.waitFor(find.text('Commentaire:'));
// Want to paste pubkey copied, but doesn't work actualy with flutter driver: https://github.com/flutter/flutter/issues/47448
// final ClipboardData pubkeyCopied =
// await Clipboard.getData(Clipboard.kTextPlain);
// await driver.enterText(pubkeyCopied.text);
// Wait 3 seconds at the end
await sleep(3000);
});
});
}, timeout: Timeout(Duration(minutes: globalTimeout)));
}, timeout: Timeout(Duration(minutes: globalTimeout)));
}
// Function to go back to previous screen