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( TextButton(
key: Key('confirmDeletingAllWallets'),
child: Text("Oui"), child: Text("Oui"),
onPressed: () { onPressed: () {
Navigator.pop(context, true); Navigator.pop(context, true);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,12 +1,12 @@
// Imports the Flutter Driver API. // Imports the Flutter Driver API.
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:flutter_driver/flutter_driver.dart'; import 'package:flutter_driver/flutter_driver.dart';
// import 'package:flutter_test/flutter_test.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
// import 'package:flutter/services.dart';
void main() { void main() {
int globalTimeout = 2;
group('Gecko App', () { group('Gecko App', () {
// First, define the Finders and use them to locate widgets from the // First, define the Finders and use them to locate widgets from the
// test suite. Note: the Strings provided to the `byValueKey` method must // 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', ( 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.runUnsynchronized(() async { // Needed if we want to manage async drivers
await driver.tap(manageWalletsFinder); 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' // Get the SerializableFinder for text widget with key 'textOnboarding'
SerializableFinder textOnboarding = find.byValueKey( SerializableFinder textOnboarding = find.byValueKey(
'textOnboarding', 'textOnboarding',
); );
print( await sleep(100);
'####################################################################');
// Verify onboarding is starting, with text // Verify onboarding is starting, with text
expect(await driver.getText(textOnboarding), expect(await driver.getText(textOnboarding),
@ -60,7 +86,7 @@ void main() {
}); });
test('OnBoarding - Go to create restore sentance', ( test('OnBoarding - Go to create restore sentance', (
{timeout: const Duration(seconds: 5)}) async { {timeout: Timeout.none}) async {
await tapOn('goStep1'); await tapOn('goStep1');
await tapOn('goStep2'); await tapOn('goStep2');
await tapOn('goStep3'); await tapOn('goStep3');
@ -76,7 +102,7 @@ void main() {
}); });
test('OnBoarding - Generate sentance and confirme it', ( test('OnBoarding - Generate sentance and confirme it', (
{timeout: const Duration(seconds: 5)}) async { {timeout: Timeout.none}) async {
await tapOn('goStep7'); await tapOn('goStep7');
while (await getText('word1') == '...') { while (await getText('word1') == '...') {
@ -126,7 +152,7 @@ void main() {
await selectWord(); await selectWord();
}); });
test('OnBoarding - Generate secret code and confirm it', ( test('OnBoarding - Generate secret code and confirm it', (
{timeout: const Duration(seconds: 5)}) async { {timeout: Timeout.none}) async {
expect(await getText('step9'), 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."); "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', ( test('My wallets - Create a derivation and display it', (
{timeout: const Duration(seconds: 5)}) async { {timeout: Timeout.none}) async {
await tapOn('goWalletHome'); await tapOn('goWalletHome');
expect(await getText('myWallets'), "Mes portefeuilles"); expect(await getText('myWallets'), "Mes portefeuilles");
@ -252,11 +278,83 @@ void main() {
await tapOn('setDefaultWallet'); await tapOn('setDefaultWallet');
await sleep(100); await sleep(100);
await driver.waitFor(find.text('Ce portefeuille est celui par defaut')); 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 // Wait 3 seconds at the end
await sleep(3000); await sleep(3000);
}); }, timeout: Timeout(Duration(minutes: globalTimeout)));
}); }, timeout: Timeout(Duration(minutes: globalTimeout)));
} }
// Function to go back to previous screen // Function to go back to previous screen